/** * 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, array, bytes, mapSerializer, publicKey as publicKeySerializer, struct, u128, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type SetPriceFeedInstructionAccounts = { admin: Signer; priceFeed: PublicKey | Pda; }; // Data. export type SetPriceFeedInstructionData = { discriminator: Uint8Array; updaters: Array; priceRatioDenominator: bigint; arbitrumCompressionPercent: bigint; }; export type SetPriceFeedInstructionDataArgs = { updaters: Array; priceRatioDenominator: number | bigint; arbitrumCompressionPercent: number | bigint; }; export function getSetPriceFeedInstructionDataSerializer(): Serializer< SetPriceFeedInstructionDataArgs, SetPriceFeedInstructionData > { return mapSerializer< SetPriceFeedInstructionDataArgs, any, SetPriceFeedInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['updaters', array(publicKeySerializer())], ['priceRatioDenominator', u128()], ['arbitrumCompressionPercent', u128()], ], { description: 'SetPriceFeedInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([13, 15, 231, 129, 61, 7, 28, 122]), }) ) as Serializer; } // Args. export type SetPriceFeedInstructionArgs = SetPriceFeedInstructionDataArgs; // Instruction. export function setPriceFeed( context: Pick, input: SetPriceFeedInstructionAccounts & SetPriceFeedInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'pricefeed', '8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP' ); // Accounts. const resolvedAccounts = { admin: { index: 0, isWritable: true as boolean, value: input.admin ?? null, }, priceFeed: { index: 1, isWritable: true as boolean, value: input.priceFeed ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: SetPriceFeedInstructionArgs = { ...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 = getSetPriceFeedInstructionDataSerializer().serialize( resolvedArgs as SetPriceFeedInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }