/** * 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, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type LzReceiveAlertInstructionAccounts = { executor: Signer; eventAuthority: PublicKey | Pda; program: PublicKey | Pda; }; // Data. export type LzReceiveAlertInstructionData = { discriminator: Uint8Array; receiver: PublicKey; srcEid: number; sender: Uint8Array; nonce: bigint; guid: Uint8Array; computeUnits: bigint; value: bigint; message: Uint8Array; extraData: Uint8Array; reason: Uint8Array; }; export type LzReceiveAlertInstructionDataArgs = { receiver: PublicKey; srcEid: number; sender: Uint8Array; nonce: number | bigint; guid: Uint8Array; computeUnits: number | bigint; value: number | bigint; message: Uint8Array; extraData: Uint8Array; reason: Uint8Array; }; export function getLzReceiveAlertInstructionDataSerializer(): Serializer< LzReceiveAlertInstructionDataArgs, LzReceiveAlertInstructionData > { return mapSerializer< LzReceiveAlertInstructionDataArgs, any, LzReceiveAlertInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['receiver', publicKeySerializer()], ['srcEid', u32()], ['sender', bytes({ size: 32 })], ['nonce', u64()], ['guid', bytes({ size: 32 })], ['computeUnits', u64()], ['value', u64()], ['message', bytes({ size: u32() })], ['extraData', bytes({ size: u32() })], ['reason', bytes({ size: u32() })], ], { description: 'LzReceiveAlertInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([131, 141, 48, 222, 15, 235, 141, 160]), }) ) as Serializer< LzReceiveAlertInstructionDataArgs, LzReceiveAlertInstructionData >; } // Args. export type LzReceiveAlertInstructionArgs = LzReceiveAlertInstructionDataArgs; // Instruction. export function lzReceiveAlert( context: Pick, input: LzReceiveAlertInstructionAccounts & LzReceiveAlertInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'endpoint', '76y77prsiCMvXMjuoZ5VRrhG5qYBrUMYTE5WgHqgjEn6' ); // Accounts. const resolvedAccounts = { executor: { index: 0, isWritable: false as boolean, value: input.executor ?? null, }, eventAuthority: { index: 1, isWritable: false as boolean, value: input.eventAuthority ?? null, }, program: { index: 2, isWritable: false as boolean, value: input.program ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: LzReceiveAlertInstructionArgs = { ...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 = getLzReceiveAlertInstructionDataSerializer().serialize( resolvedArgs as LzReceiveAlertInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }