UNPKG

@nosana/kit

Version:

Nosana KIT

70 lines 2.83 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 { NOSANA_JOBS_PROGRAM_ADDRESS } from '../programs/index.js'; import { getAccountMetaFactory } from '../shared/index.js'; export const QUIT_ADMIN_DISCRIMINATOR = new Uint8Array([ 103, 238, 110, 8, 182, 20, 56, 196, ]); export function getQuitAdminDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(QUIT_ADMIN_DISCRIMINATOR); } export function getQuitAdminInstructionDataEncoder() { return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: QUIT_ADMIN_DISCRIMINATOR })); } export function getQuitAdminInstructionDataDecoder() { return getStructDecoder([ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getQuitAdminInstructionDataCodec() { return combineCodec(getQuitAdminInstructionDataEncoder(), getQuitAdminInstructionDataDecoder()); } export function getQuitAdminInstruction(input, config) { // Program address. const programAddress = config?.programAddress ?? NOSANA_JOBS_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { run: { value: input.run ?? null, isWritable: true }, payer: { value: input.payer ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: false }, }; const accounts = originalAccounts; const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); return Object.freeze({ accounts: [ getAccountMeta(accounts.run), getAccountMeta(accounts.payer), getAccountMeta(accounts.authority), ], data: getQuitAdminInstructionDataEncoder().encode({}), programAddress, }); } export function parseQuitAdminInstruction(instruction) { if (instruction.accounts.length < 3) { // 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: { run: getNextAccount(), payer: getNextAccount(), authority: getNextAccount(), }, data: getQuitAdminInstructionDataDecoder().decode(instruction.data), }; } //# sourceMappingURL=quitAdmin.js.map