@wormhole-foundation/sdk-solana-cctp
Version:
SDK for Solana, used in conjunction with @wormhole-foundation/sdk
24 lines • 901 B
JavaScript
import { utils } from '@coral-xyz/anchor';
import { PublicKey } from '@solana/web3.js';
export const findProgramAddress = (label, programId, extraSeeds) => {
const seeds = [Buffer.from(utils.bytes.utf8.encode(label))];
if (extraSeeds) {
for (const extraSeed of extraSeeds) {
if (typeof extraSeed === 'string') {
seeds.push(Buffer.from(utils.bytes.utf8.encode(extraSeed)));
}
else if (Array.isArray(extraSeed)) {
seeds.push(Buffer.from(extraSeed));
}
else if (Buffer.isBuffer(extraSeed)) {
seeds.push(extraSeed);
}
else {
seeds.push(extraSeed.toBuffer());
}
}
}
const res = PublicKey.findProgramAddressSync(seeds, programId);
return { publicKey: res[0], bump: res[1] };
};
//# sourceMappingURL=index.js.map