UNPKG

@superstateinc/allowlist

Version:

TypeScript library for interacting with the Superstate Allowlist program on Solana

54 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllowlistProgramPda = getAllowlistProgramPda; exports.getPrivateAllowlistPda = getPrivateAllowlistPda; exports.getPublicAllowedAccountPda = getPublicAllowedAccountPda; exports.getPrivateAllowedAccountPda = getPrivateAllowedAccountPda; exports.getAdminPda = getAdminPda; const web3_js_1 = require("@solana/web3.js"); const constants_1 = require("./constants"); /** * Derives the allowlist program PDA * @param programId The allowlist program ID * @returns [PDA address, bump seed] */ function getAllowlistProgramPda(programId) { return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(constants_1.ALLOWLIST_PROGRAM_SEED_PREFIX)], programId); } /** * Derives the private allowlist PDA for a specific mint * @param mint The token mint * @param programId The allowlist program ID * @returns [PDA address, bump seed] */ function getPrivateAllowlistPda(mint, programId) { return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(constants_1.PRIVATE_ALLOWLIST_PREFIX), mint.toBuffer()], programId); } /** * Derives the public allowed account PDA for a user * @param userAccount The user's wallet address * @param programId The allowlist program ID * @returns [PDA address, bump seed] */ function getPublicAllowedAccountPda(userAccount, programId) { return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(constants_1.PUBLIC_ALLOWED_ACCOUNT_SEED_PREFIX), userAccount.toBuffer()], programId); } /** * Derives the private allowed account PDA for a user and specific mint * @param userAccount The user's wallet address * @param mint The token mint * @param programId The allowlist program ID * @returns [PDA address, bump seed] */ function getPrivateAllowedAccountPda(userAccount, mint, programId) { return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(constants_1.PRIVATE_ALLOWED_ACCOUNT_SEED_PREFIX), userAccount.toBuffer(), mint.toBuffer()], programId); } /** * Derives the admin authority PDA * @param programId The allowlist program ID * @returns [PDA address, bump seed] */ function getAdminPda(programId) { return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(constants_1.ADMIN_SEED_PREFIX)], programId); } //# sourceMappingURL=pda.js.map