/** * This code was AUTOGENERATED using the kinobi library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun kinobi to update it. * * @see https://github.com/kinobi-so/kinobi */ import { Context, Option, OptionOrNullable, Pda, PublicKey, Signer, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, bytes, mapSerializer, option, publicKey as publicKeySerializer, struct, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type SetLzTokenInstructionAccounts = { admin: Signer; endpoint: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type SetLzTokenInstructionData = { discriminator: Uint8Array; lzToken: Option; }; export type SetLzTokenInstructionDataArgs = { lzToken: OptionOrNullable; }; export function getSetLzTokenInstructionDataSerializer(): Serializer< SetLzTokenInstructionDataArgs, SetLzTokenInstructionData > { return mapSerializer< SetLzTokenInstructionDataArgs, any, SetLzTokenInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['lzToken', option(publicKeySerializer())], ], { description: 'SetLzTokenInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([22, 151, 112, 174, 213, 225, 223, 72]), }) ) as Serializer; } // Args. export type SetLzTokenInstructionArgs = SetLzTokenInstructionDataArgs; // Instruction. export function setLzToken( context: Pick, input: SetLzTokenInstructionAccounts & SetLzTokenInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: false as boolean, value: input.admin ?? null, }, endpoint: { index: 1, isWritable: true as boolean, value: input.endpoint ?? null, }, eventAuthority: { index: 2, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 3, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: SetLzTokenInstructionArgs = { ...input }; // Accounts in order. const orderedAccounts: ResolvedAccount[] = Object.values( resolvedAccounts ).sort((a, b) => a.index - b.index); // Keys and Signers. const [keys, signers] = getAccountMetasAndSigners( orderedAccounts, 'programId', programId ); // Data. const data = getSetLzTokenInstructionDataSerializer().serialize( resolvedArgs as SetLzTokenInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }