/** * 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, u8, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type InitVerifyInstructionAccounts = { payer?: Signer; confirmations: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitVerifyInstructionData = { discriminator: Uint8Array; packetHeader: Array; payloadHash: Uint8Array; dvn: PublicKey; }; export type InitVerifyInstructionDataArgs = { packetHeader: Array; payloadHash: Uint8Array; dvn: PublicKey; }; export function getInitVerifyInstructionDataSerializer(): Serializer< InitVerifyInstructionDataArgs, InitVerifyInstructionData > { return mapSerializer< InitVerifyInstructionDataArgs, any, InitVerifyInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['packetHeader', array(u8(), { size: 81 })], ['payloadHash', bytes({ size: 32 })], ['dvn', publicKeySerializer()], ], { description: 'InitVerifyInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([76, 246, 244, 124, 115, 17, 235, 91]), }) ) as Serializer; } // Args. export type InitVerifyInstructionArgs = InitVerifyInstructionDataArgs; // Instruction. export function initVerify( context: Pick, input: InitVerifyInstructionAccounts & InitVerifyInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'uln', '7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH' ); // Accounts. const resolvedAccounts = { payer: { index: 0, isWritable: true as boolean, value: input.payer ?? null, }, confirmations: { index: 1, isWritable: true as boolean, value: input.confirmations ?? null, }, systemProgram: { index: 2, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitVerifyInstructionArgs = { ...input }; // Default values. if (!resolvedAccounts.payer.value) { resolvedAccounts.payer.value = context.payer; } 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 = getInitVerifyInstructionDataSerializer().serialize( resolvedArgs as InitVerifyInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }