/** * 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, TransactionBuilder, transactionBuilder, } from '@metaplex-foundation/umi'; import { Serializer, bytes, mapSerializer, struct, u128, u32, u64, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type GetFeeInstructionAccounts = { priceFeed: PublicKey | Pda; }; // Data. export type GetFeeInstructionData = { discriminator: Uint8Array; dstEid: number; calldataSize: bigint; totalGas: bigint; }; export type GetFeeInstructionDataArgs = { dstEid: number; calldataSize: number | bigint; totalGas: number | bigint; }; export function getGetFeeInstructionDataSerializer(): Serializer< GetFeeInstructionDataArgs, GetFeeInstructionData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['dstEid', u32()], ['calldataSize', u64()], ['totalGas', u128()], ], { description: 'GetFeeInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([115, 195, 235, 161, 25, 219, 60, 29]), }) ) as Serializer; } // Args. export type GetFeeInstructionArgs = GetFeeInstructionDataArgs; // Instruction. export function getFee( context: Pick, input: GetFeeInstructionAccounts & GetFeeInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'pricefeed', '8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP' ); // Accounts. const resolvedAccounts = { priceFeed: { index: 0, isWritable: false as boolean, value: input.priceFeed ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: GetFeeInstructionArgs = { ...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 = getGetFeeInstructionDataSerializer().serialize( resolvedArgs as GetFeeInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }