kamino-sdk-beta
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
38 lines • 1.57 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLookupTable = getLookupTable;
exports.getTransactionV2Message = getTransactionV2Message;
const web3_js_1 = require("@solana/web3.js");
const pubkeys_1 = require("../constants/pubkeys");
async function getLookupTable(cluster, connection) {
if (cluster == 'mainnet-beta' || cluster == 'devnet') {
return await connection
.getProgramAccounts(pubkeys_1.ADDRESS_LUT_PROGRAM_ID, {
filters: [{ memcmp: { offset: 22, bytes: new web3_js_1.PublicKey(pubkeys_1.LUT_OWNER_KEY).toString() } }],
})
.then((res) => res.map((raw) => {
return new web3_js_1.AddressLookupTableAccount({
key: raw.pubkey,
state: web3_js_1.AddressLookupTableAccount.deserialize(raw.account.data),
});
}));
}
else {
throw Error('There is no lookup table for localnet yet');
}
}
async function getTransactionV2Message(cluster, connection, payer, blockhash, instructions) {
if (cluster == 'mainnet-beta' || cluster == 'devnet') {
const lookupTable = await getLookupTable(cluster, connection);
const v2Tx = new web3_js_1.TransactionMessage({
payerKey: payer,
recentBlockhash: blockhash,
instructions: instructions,
}).compileToV0Message(lookupTable);
return v2Tx;
}
else {
throw Error('No TransactionV2 on localnet as no lookup table was created');
}
}
//# sourceMappingURL=lookupTable.js.map