@nosana/kit
Version:
Nosana KIT
76 lines • 3.11 kB
JavaScript
/**
* 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 SET_CLAWBACK_RECEIVER_DISCRIMINATOR = new Uint8Array([
153, 217, 34, 20, 19, 29, 229, 75,
]);
export function getSetClawbackReceiverDiscriminatorBytes() {
return fixEncoderSize(getBytesEncoder(), 8).encode(SET_CLAWBACK_RECEIVER_DISCRIMINATOR);
}
export function getSetClawbackReceiverInstructionDataEncoder() {
return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({
...value,
discriminator: SET_CLAWBACK_RECEIVER_DISCRIMINATOR,
}));
}
export function getSetClawbackReceiverInstructionDataDecoder() {
return getStructDecoder([
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
]);
}
export function getSetClawbackReceiverInstructionDataCodec() {
return combineCodec(getSetClawbackReceiverInstructionDataEncoder(), getSetClawbackReceiverInstructionDataDecoder());
}
export function getSetClawbackReceiverInstruction(input, config) {
// Program address.
const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS;
// Original accounts.
const originalAccounts = {
distributor: { value: input.distributor ?? null, isWritable: true },
newClawbackAccount: {
value: input.newClawbackAccount ?? null,
isWritable: false,
},
admin: { value: input.admin ?? null, isWritable: true },
};
const accounts = originalAccounts;
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({
accounts: [
getAccountMeta(accounts.distributor),
getAccountMeta(accounts.newClawbackAccount),
getAccountMeta(accounts.admin),
],
data: getSetClawbackReceiverInstructionDataEncoder().encode({}),
programAddress,
});
}
export function parseSetClawbackReceiverInstruction(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: {
distributor: getNextAccount(),
newClawbackAccount: getNextAccount(),
admin: getNextAccount(),
},
data: getSetClawbackReceiverInstructionDataDecoder().decode(instruction.data),
};
}
//# sourceMappingURL=setClawbackReceiver.js.map