UNPKG

@wormhole-foundation/sdk-solana-tbtc

Version:

SDK for Solana chains, used in conjunction with @wormhole-foundation/sdk

24 lines 1.29 kB
import { PublicKey } from '@solana/web3.js'; import { toChainId } from '@wormhole-foundation/sdk-connect'; export function getCustodianPda(gatewayProgramId) { return PublicKey.findProgramAddressSync([Buffer.from('redeemer')], new PublicKey(gatewayProgramId))[0]; } export function getCoreMessagePda(gatewayProgramId, sequence) { const encodedSequence = Buffer.alloc(8); encodedSequence.writeBigUInt64LE(sequence); return PublicKey.findProgramAddressSync([Buffer.from('msg'), encodedSequence], new PublicKey(gatewayProgramId))[0]; } export function getGatewayInfoPda(gatewayProgramId, targetChain) { const encodedChain = Buffer.alloc(2); encodedChain.writeUInt16LE(toChainId(targetChain)); return PublicKey.findProgramAddressSync([Buffer.from('gateway-info'), encodedChain], new PublicKey(gatewayProgramId))[0]; } // same address in mainnet and testnet export const TBTC_PROGRAM_ID = new PublicKey('Gj93RRt6QB7FjmyokAD5rcMAku7pq3Fk2Aa8y6nNbwsV'); export function getConfigPda() { return PublicKey.findProgramAddressSync([Buffer.from('config')], TBTC_PROGRAM_ID)[0]; } export function getMinterInfoPda(minter) { return PublicKey.findProgramAddressSync([Buffer.from('minter-info'), minter.toBuffer()], TBTC_PROGRAM_ID)[0]; } //# sourceMappingURL=utils.js.map