UNPKG

@nosana/kit

Version:

Nosana KIT

70 lines 2.92 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, getU64Decoder, getU64Encoder, transformEncoder, } from '@solana/kit'; import { MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS } from '../programs/index.js'; import { getAccountMetaFactory } from '../shared/index.js'; export const SET_ENABLE_SLOT_DISCRIMINATOR = new Uint8Array([ 5, 52, 73, 33, 150, 115, 97, 206, ]); export function getSetEnableSlotDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(SET_ENABLE_SLOT_DISCRIMINATOR); } export function getSetEnableSlotInstructionDataEncoder() { return transformEncoder(getStructEncoder([ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['enableSlot', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SET_ENABLE_SLOT_DISCRIMINATOR })); } export function getSetEnableSlotInstructionDataDecoder() { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['enableSlot', getU64Decoder()], ]); } export function getSetEnableSlotInstructionDataCodec() { return combineCodec(getSetEnableSlotInstructionDataEncoder(), getSetEnableSlotInstructionDataDecoder()); } export function getSetEnableSlotInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { distributor: { value: input.distributor ?? null, isWritable: true }, admin: { value: input.admin ?? null, isWritable: true }, }; const accounts = originalAccounts; // Original args. const args = { ...input }; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.distributor), getAccountMeta(accounts.admin), ], data: getSetEnableSlotInstructionDataEncoder().encode(args), programAddress, }); } export function parseSetEnableSlotInstruction(instruction) { if (instruction.accounts.length < 2) { // 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(), admin: getNextAccount() }, data: getSetEnableSlotInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=setEnableSlot.js.map