UNPKG

@nosana/kit

Version:

Nosana KIT

84 lines 3.55 kB
/** * 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 */ import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, transformEncoder, } from '@solana/kit'; import { MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS } from '../programs/index.js'; import { getAccountMetaFactory } from '../shared/index.js'; export const CLAIM_LOCKED_DISCRIMINATOR = new Uint8Array([ 34, 206, 181, 23, 11, 207, 147, 90, ]); export function getClaimLockedDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(CLAIM_LOCKED_DISCRIMINATOR); } export function getClaimLockedInstructionDataEncoder() { return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: CLAIM_LOCKED_DISCRIMINATOR })); } export function getClaimLockedInstructionDataDecoder() { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getClaimLockedInstructionDataCodec() { return combineCodec(getClaimLockedInstructionDataEncoder(), getClaimLockedInstructionDataDecoder()); } export function getClaimLockedInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { distributor: { value: input.distributor ?? null, isWritable: true }, claimStatus: { value: input.claimStatus ?? null, isWritable: true }, from: { value: input.from ?? null, isWritable: true }, to: { value: input.to ?? null, isWritable: true }, claimant: { value: input.claimant ?? null, isWritable: true }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, }; const accounts = originalAccounts; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.distributor), getAccountMeta(accounts.claimStatus), getAccountMeta(accounts.from), getAccountMeta(accounts.to), getAccountMeta(accounts.claimant), getAccountMeta(accounts.tokenProgram), ], data: getClaimLockedInstructionDataEncoder().encode({}), programAddress, }); } export function parseClaimLockedInstruction(instruction) { if (instruction.accounts.length < 6) { // 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: { distributor: getNextAccount(), claimStatus: getNextAccount(), from: getNextAccount(), to: getNextAccount(), claimant: getNextAccount(), tokenProgram: getNextAccount(), }, data: getClaimLockedInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=claimLocked.js.map