UNPKG

@nosana/kit

Version:

Nosana KIT

73 lines 3.15 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 CLOSE_CLAIM_STATUS_DISCRIMINATOR = new Uint8Array([ 163, 214, 191, 165, 245, 188, 17, 185, ]); export function getCloseClaimStatusDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(CLOSE_CLAIM_STATUS_DISCRIMINATOR); } export function getCloseClaimStatusInstructionDataEncoder() { return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: CLOSE_CLAIM_STATUS_DISCRIMINATOR })); } export function getCloseClaimStatusInstructionDataDecoder() { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getCloseClaimStatusInstructionDataCodec() { return combineCodec(getCloseClaimStatusInstructionDataEncoder(), getCloseClaimStatusInstructionDataDecoder()); } export function getCloseClaimStatusInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { claimStatus: { value: input.claimStatus ?? null, isWritable: true }, claimant: { value: input.claimant ?? null, isWritable: true }, admin: { value: input.admin ?? null, isWritable: false }, distributor: { value: input.distributor ?? null, isWritable: false }, }; const accounts = originalAccounts; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.claimStatus), getAccountMeta(accounts.claimant), getAccountMeta(accounts.admin), getAccountMeta(accounts.distributor), ], data: getCloseClaimStatusInstructionDataEncoder().encode({}), programAddress, }); } export function parseCloseClaimStatusInstruction(instruction) { if (instruction.accounts.length < 4) { // 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: { claimStatus: getNextAccount(), claimant: getNextAccount(), admin: getNextAccount(), distributor: getNextAccount(), }, data: getCloseClaimStatusInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=closeClaimStatus.js.map