/** * 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 SetConfigInstructionAccounts = { /** The PDA of the OApp or delegate */ signer: Signer; oappRegistry: PublicKey | Pda; /** The PDA signer to the message lib when the endpoint calls the message lib program */ messageLibInfo: PublicKey | Pda; /** the pda of the message_lib_program */ messageLib: PublicKey | Pda; messageLibProgram: PublicKey | Pda; }; // Data. export type SetConfigInstructionData = { discriminator: Uint8Array; oapp: PublicKey; eid: number; configType: number; config: Uint8Array; }; export type SetConfigInstructionDataArgs = { oapp: PublicKey; eid: number; configType: number; config: Uint8Array; }; export function getSetConfigInstructionDataSerializer(): Serializer< SetConfigInstructionDataArgs, SetConfigInstructionData > { return mapSerializer< SetConfigInstructionDataArgs, any, SetConfigInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['oapp', publicKeySerializer()], ['eid', u32()], ['configType', u32()], ['config', bytes({ size: u32() })], ], { description: 'SetConfigInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([108, 158, 154, 175, 212, 98, 52, 66]), }) ) as Serializer; } // Args. export type SetConfigInstructionArgs = SetConfigInstructionDataArgs; // Instruction. export function setConfig( context: Pick, input: SetConfigInstructionAccounts & SetConfigInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { signer: { index: 0, isWritable: false as boolean, value: input.signer ?? null, }, oappRegistry: { index: 1, isWritable: false as boolean, value: input.oappRegistry ?? null, }, messageLibInfo: { index: 2, isWritable: false as boolean, value: input.messageLibInfo ?? null, }, messageLib: { index: 3, isWritable: false as boolean, value: input.messageLib ?? null, }, messageLibProgram: { index: 4, isWritable: false as boolean, value: input.messageLibProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: SetConfigInstructionArgs = { ...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 = getSetConfigInstructionDataSerializer().serialize( resolvedArgs as SetConfigInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }