solana-token-extension-boost
Version:
SDK for Solana Token Extensions with wallet adapter support
58 lines (57 loc) • 2.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MemberPointerExtension = exports.MemberPointerExtensionType = void 0;
exports.createInitializeMemberPointerInstruction = createInitializeMemberPointerInstruction;
const spl_token_1 = require("@solana/spl-token");
// Define MemberPointer extension type (not yet available in standard ExtensionType)
exports.MemberPointerExtensionType = 21; // Assumed ID for MemberPointer
/**
* Create instruction to initialize member pointer for a token
* @param mint - Mint address
* @param memberMint - Mint address of the token that this token is a member of
* @param programId - Token Extension Program ID
* @returns Instruction to initialize member pointer
*/
function createInitializeMemberPointerInstruction(mint, memberMint, programId = spl_token_1.TOKEN_2022_PROGRAM_ID) {
// In practice, this is where you would implement logic to create the instruction
return {
programId,
keys: [
{ pubkey: mint, isSigner: false, isWritable: true },
{ pubkey: memberMint, isSigner: false, isWritable: false },
],
data: Buffer.from([exports.MemberPointerExtensionType]), // Mock data
};
}
/**
* Class for managing member pointers in token groups
*/
class MemberPointerExtension {
/**
* Create instruction to initialize member pointer for a token
* @param mint - Mint address
* @param memberMint - Mint address of the token that this token is a member of
* @param programId - Token Extension Program ID
* @returns Instruction to initialize member pointer
*/
static createInitializeMemberPointerInstruction(mint, memberMint, programId = spl_token_1.TOKEN_2022_PROGRAM_ID) {
return createInitializeMemberPointerInstruction(mint, memberMint, programId);
}
/**
* Check if a token is a member of a token group
* @param connection - Connection to Solana cluster
* @param mint - Mint address of the token
* @param groupMint - Mint address of the token group
* @returns Promise<boolean> - True if token is a member of the group
*/
static async isMemberOfGroup(
// connection: Connection,
// mint: PublicKey,
// groupMint: PublicKey
) {
// In practice, this is where you would query on-chain data to check
// For demo purposes, we'll return an assumed value
return Promise.resolve(true);
}
}
exports.MemberPointerExtension = MemberPointerExtension;