/** * 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, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u32, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type InitUlnInstructionAccounts = { payer?: Signer; uln: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitUlnInstructionData = { discriminator: Uint8Array; eid: number; endpoint: PublicKey; endpointProgram: PublicKey; admin: PublicKey; }; export type InitUlnInstructionDataArgs = { eid: number; endpoint: PublicKey; endpointProgram: PublicKey; admin: PublicKey; }; export function getInitUlnInstructionDataSerializer(): Serializer< InitUlnInstructionDataArgs, InitUlnInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['eid', u32()], ['endpoint', publicKeySerializer()], ['endpointProgram', publicKeySerializer()], ['admin', publicKeySerializer()], ], { description: 'InitUlnInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([19, 215, 207, 92, 197, 112, 119, 240]), }) ) as Serializer; } // Args. export type InitUlnInstructionArgs = InitUlnInstructionDataArgs; // Instruction. export function initUln( context: Pick, input: InitUlnInstructionAccounts & InitUlnInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'uln', '7a4WjyR8VZ7yZz5XJAKm39BUGn5iT9CKcv2pmG9tdXVH' ); // Accounts. const resolvedAccounts = { payer: { index: 0, isWritable: true as boolean, value: input.payer ?? null, }, uln: { index: 1, isWritable: true as boolean, value: input.uln ?? null }, systemProgram: { index: 2, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitUlnInstructionArgs = { ...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 = getInitUlnInstructionDataSerializer().serialize( resolvedArgs as InitUlnInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }