UNPKG

@marinade.finance/kamino-sdk

Version:
45 lines 1.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTransactionV2Message = exports.getLookupTable = void 0; const web3_js_1 = require("@solana/web3.js"); const pubkeys_1 = require("../constants/pubkeys"); async function getLookupTable(cluster, connection) { if (cluster == 'mainnet-beta') { const lookupTableAccount = await connection .getAddressLookupTable(pubkeys_1.MAINNET_GLOBAL_LOOKUP_TABLE) .then((res) => res.value); if (!lookupTableAccount) { throw new Error(`Could not get lookup table ${pubkeys_1.MAINNET_GLOBAL_LOOKUP_TABLE}`); } return lookupTableAccount; } else if (cluster == 'devnet') { const lookupTableAccount = await connection .getAddressLookupTable(pubkeys_1.DEVNET_GLOBAL_LOOKUP_TABLE) .then((res) => res.value); if (!lookupTableAccount) { throw new Error(`Could not get lookup table ${pubkeys_1.DEVNET_GLOBAL_LOOKUP_TABLE}`); } return lookupTableAccount; } else { throw Error('There is no lookup table for localnet yet'); } } exports.getLookupTable = getLookupTable; async function getTransactionV2Message(cluster, connection, payer, blockhash, instructions) { if (cluster == 'mainnet-beta' || cluster == 'devnet') { let 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'); } } exports.getTransactionV2Message = getTransactionV2Message; //# sourceMappingURL=lookupTable.js.map