/** * 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 InitConfigInstructionAccounts = { endpoint: Signer; payer?: Signer; messageLib: PublicKey | Pda; sendConfig: PublicKey | Pda; receiveConfig: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitConfigInstructionData = { discriminator: Uint8Array; oapp: PublicKey; eid: number; }; export type InitConfigInstructionDataArgs = { oapp: PublicKey; eid: number }; export function getInitConfigInstructionDataSerializer(): Serializer< InitConfigInstructionDataArgs, InitConfigInstructionData > { return mapSerializer< InitConfigInstructionDataArgs, any, InitConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['oapp', publicKeySerializer()], ['eid', u32()], ], { description: 'InitConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([23, 235, 115, 232, 168, 96, 1, 231]), }) ) as Serializer; } // Args. export type InitConfigInstructionArgs = InitConfigInstructionDataArgs; // Instruction. export function initConfig( context: Pick, input: InitConfigInstructionAccounts & InitConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'simpleMessagelib', '6GsmxMTHAAiFKfemuM4zBjumTjNSX5CAiw4xSSXM2Toy' ); // Accounts. const resolvedAccounts = { endpoint: { index: 0, isWritable: false as boolean, value: input.endpoint ?? null, }, payer: { index: 1, isWritable: true as boolean, value: input.payer ?? null, }, messageLib: { index: 2, isWritable: false as boolean, value: input.messageLib ?? null, }, sendConfig: { index: 3, isWritable: true as boolean, value: input.sendConfig ?? null, }, receiveConfig: { index: 4, isWritable: true as boolean, value: input.receiveConfig ?? null, }, systemProgram: { index: 5, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitConfigInstructionArgs = { ...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 = getInitConfigInstructionDataSerializer().serialize( resolvedArgs as InitConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }