/** * 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, Pda, PublicKey, Signer, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, array, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u32, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; import { NativeDropRequest, NativeDropRequestArgs, getNativeDropRequestSerializer, } from '../types'; // Accounts. export type NativeDropInstructionAccounts = { executor: Signer; config: PublicKey | Pda; /** For native drop transfer */ systemProgram?: PublicKey | Pda; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type NativeDropInstructionData = { discriminator: Uint8Array; srcEid: number; sender: Uint8Array; nonce: bigint; dstEid: number; oapp: PublicKey; nativeDropRequests: Array; }; export type NativeDropInstructionDataArgs = { srcEid: number; sender: Uint8Array; nonce: number | bigint; dstEid: number; oapp: PublicKey; nativeDropRequests: Array; }; export function getNativeDropInstructionDataSerializer(): Serializer< NativeDropInstructionDataArgs, NativeDropInstructionData > { return mapSerializer< NativeDropInstructionDataArgs, any, NativeDropInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['srcEid', u32()], ['sender', bytes({ size: 32 })], ['nonce', u64()], ['dstEid', u32()], ['oapp', publicKeySerializer()], ['nativeDropRequests', array(getNativeDropRequestSerializer())], ], { description: 'NativeDropInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([105, 30, 218, 121, 155, 234, 85, 12]), }) ) as Serializer; } // Args. export type NativeDropInstructionArgs = NativeDropInstructionDataArgs; // Instruction. export function nativeDrop( context: Pick, input: NativeDropInstructionAccounts & NativeDropInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'executor', '6doghB248px58JSSwG4qejQ46kFMW4AMj7vzJnWZHNZn' ); // Accounts. const resolvedAccounts = { executor: { index: 0, isWritable: true as boolean, value: input.executor ?? null, }, config: { index: 1, isWritable: true as boolean, value: input.config ?? null, }, systemProgram: { index: 2, isWritable: false as boolean, value: input.systemProgram ?? null, }, eventAuthority: { index: 3, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 4, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: NativeDropInstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.systemProgram.value) { resolvedAccounts.systemProgram.value = context.programs.getPublicKey( 'splSystem', '11111111111111111111111111111111' ); resolvedAccounts.systemProgram.isWritable = false; } // 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 = getNativeDropInstructionDataSerializer().serialize( resolvedArgs as NativeDropInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }