@wormhole-foundation/sdk-solana-tbtc
Version:
SDK for Solana chains, used in conjunction with @wormhole-foundation/sdk
32 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMinterInfoPda = exports.getConfigPda = exports.TBTC_PROGRAM_ID = exports.getGatewayInfoPda = exports.getCoreMessagePda = exports.getCustodianPda = void 0;
const web3_js_1 = require("@solana/web3.js");
const sdk_connect_1 = require("@wormhole-foundation/sdk-connect");
function getCustodianPda(gatewayProgramId) {
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('redeemer')], new web3_js_1.PublicKey(gatewayProgramId))[0];
}
exports.getCustodianPda = getCustodianPda;
function getCoreMessagePda(gatewayProgramId, sequence) {
const encodedSequence = Buffer.alloc(8);
encodedSequence.writeBigUInt64LE(sequence);
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('msg'), encodedSequence], new web3_js_1.PublicKey(gatewayProgramId))[0];
}
exports.getCoreMessagePda = getCoreMessagePda;
function getGatewayInfoPda(gatewayProgramId, targetChain) {
const encodedChain = Buffer.alloc(2);
encodedChain.writeUInt16LE((0, sdk_connect_1.toChainId)(targetChain));
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('gateway-info'), encodedChain], new web3_js_1.PublicKey(gatewayProgramId))[0];
}
exports.getGatewayInfoPda = getGatewayInfoPda;
// same address in mainnet and testnet
exports.TBTC_PROGRAM_ID = new web3_js_1.PublicKey('Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV');
function getConfigPda() {
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('config')], exports.TBTC_PROGRAM_ID)[0];
}
exports.getConfigPda = getConfigPda;
function getMinterInfoPda(minter) {
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('minter-info'), minter.toBuffer()], exports.TBTC_PROGRAM_ID)[0];
}
exports.getMinterInfoPda = getMinterInfoPda;
//# sourceMappingURL=utils.js.map