UNPKG

@wuwei-labs/srsly

Version:
195 lines 8.76 kB
"use strict"; /** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CLAIM_CONTRACT_DISCRIMINATOR = void 0; exports.getClaimContractDiscriminatorBytes = getClaimContractDiscriminatorBytes; exports.getClaimContractInstructionDataEncoder = getClaimContractInstructionDataEncoder; exports.getClaimContractInstructionDataDecoder = getClaimContractInstructionDataDecoder; exports.getClaimContractInstructionDataCodec = getClaimContractInstructionDataCodec; exports.getClaimContractInstructionAsync = getClaimContractInstructionAsync; exports.getClaimContractInstruction = getClaimContractInstruction; exports.parseClaimContractInstruction = parseClaimContractInstruction; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); const shared_1 = require("../shared"); exports.CLAIM_CONTRACT_DISCRIMINATOR = new Uint8Array([159, 37, 59, 144, 75, 50, 2, 170]); function getClaimContractDiscriminatorBytes() { return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CLAIM_CONTRACT_DISCRIMINATOR); } function getClaimContractInstructionDataEncoder() { return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)]]), value => ({ ...value, discriminator: exports.CLAIM_CONTRACT_DISCRIMINATOR })); } function getClaimContractInstructionDataDecoder() { return (0, kit_1.getStructDecoder)([['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)]]); } function getClaimContractInstructionDataCodec() { return (0, kit_1.combineCodec)(getClaimContractInstructionDataEncoder(), getClaimContractInstructionDataDecoder()); } async function getClaimContractInstructionAsync(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { payer: { value: input.payer ?? null, isWritable: true }, owner: { value: input.owner ?? null, isWritable: false }, config: { value: input.config ?? null, isWritable: false }, mint: { value: input.mint ?? null, isWritable: false }, contract: { value: input.contract ?? null, isWritable: true }, contractTokenAccount: { value: input.contractTokenAccount ?? null, isWritable: true, }, destinationTokenAccount: { value: input.destinationTokenAccount ?? null, isWritable: true, }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Resolve default values. if (!accounts.config.value) { accounts.config.value = await (0, kit_1.getProgramDerivedAddress)({ programAddress, seeds: [(0, kit_1.getBytesEncoder)().encode(new Uint8Array([99, 111, 110, 102, 105, 103]))], }); } if (!accounts.destinationTokenAccount.value) { accounts.destinationTokenAccount.value = await (0, kit_1.getProgramDerivedAddress)({ programAddress: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', seeds: [ (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.owner.value)), (0, kit_1.getBytesEncoder)().encode(new Uint8Array([ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169, ])), (0, kit_1.getAddressEncoder)().encode((0, shared_1.expectAddress)(accounts.mint.value)), ], }); } if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; } if (!accounts.associatedTokenProgram.value) { accounts.associatedTokenProgram.value = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.payer), getAccountMeta(accounts.owner), getAccountMeta(accounts.config), getAccountMeta(accounts.mint), getAccountMeta(accounts.contract), getAccountMeta(accounts.contractTokenAccount), getAccountMeta(accounts.destinationTokenAccount), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.associatedTokenProgram), getAccountMeta(accounts.systemProgram), ], data: getClaimContractInstructionDataEncoder().encode({}), programAddress, }); } function getClaimContractInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? programs_1.SRSLY_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { payer: { value: input.payer ?? null, isWritable: true }, owner: { value: input.owner ?? null, isWritable: false }, config: { value: input.config ?? null, isWritable: false }, mint: { value: input.mint ?? null, isWritable: false }, contract: { value: input.contract ?? null, isWritable: true }, contractTokenAccount: { value: input.contractTokenAccount ?? null, isWritable: true, }, destinationTokenAccount: { value: input.destinationTokenAccount ?? null, isWritable: true, }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, associatedTokenProgram: { value: input.associatedTokenProgram ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; } if (!accounts.associatedTokenProgram.value) { accounts.associatedTokenProgram.value = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = '11111111111111111111111111111111'; } const getAccountMeta = (0, shared_1.getAccountMetaFactory)(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.payer), getAccountMeta(accounts.owner), getAccountMeta(accounts.config), getAccountMeta(accounts.mint), getAccountMeta(accounts.contract), getAccountMeta(accounts.contractTokenAccount), getAccountMeta(accounts.destinationTokenAccount), getAccountMeta(accounts.tokenProgram), getAccountMeta(accounts.associatedTokenProgram), getAccountMeta(accounts.systemProgram), ], data: getClaimContractInstructionDataEncoder().encode({}), programAddress, }); } function parseClaimContractInstruction(instruction) { if (instruction.accounts.length < 10) { // TODO: Coded error. throw new Error('Not enough accounts'); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = instruction.accounts[accountIndex]; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { payer: getNextAccount(), owner: getNextAccount(), config: getNextAccount(), mint: getNextAccount(), contract: getNextAccount(), contractTokenAccount: getNextAccount(), destinationTokenAccount: getNextAccount(), tokenProgram: getNextAccount(), associatedTokenProgram: getNextAccount(), systemProgram: getNextAccount(), }, data: getClaimContractInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=claimContract.js.map