/** * 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, } from '@metaplex-foundation/umi/serializers'; import { ResolvedAccount, ResolvedAccountsWithIndices, getAccountMetasAndSigners, } from '../shared'; // Accounts. export type InitPriceFeedInstructionAccounts = { payer?: Signer; priceFeed: PublicKey | Pda; systemProgram?: PublicKey | Pda; }; // Data. export type InitPriceFeedInstructionData = { discriminator: Uint8Array; admin: PublicKey; updaters: Array; }; export type InitPriceFeedInstructionDataArgs = { admin: PublicKey; updaters: Array; }; export function getInitPriceFeedInstructionDataSerializer(): Serializer< InitPriceFeedInstructionDataArgs, InitPriceFeedInstructionData > { return mapSerializer< InitPriceFeedInstructionDataArgs, any, InitPriceFeedInstructionData >( struct( [ ['discriminator', bytes({ size: 8 })], ['admin', publicKeySerializer()], ['updaters', array(publicKeySerializer())], ], { description: 'InitPriceFeedInstructionData' } ), (value) => ({ ...value, discriminator: new Uint8Array([27, 209, 184, 5, 152, 116, 136, 16]), }) ) as Serializer< InitPriceFeedInstructionDataArgs, InitPriceFeedInstructionData >; } // Args. export type InitPriceFeedInstructionArgs = InitPriceFeedInstructionDataArgs; // Instruction. export function initPriceFeed( context: Pick, input: InitPriceFeedInstructionAccounts & InitPriceFeedInstructionArgs ): TransactionBuilder { // Program ID. const programId = context.programs.getPublicKey( 'pricefeed', '8ahPGPjEbpgGaZx2NV1iG5Shj7TDwvsjkEDcGWjt94TP' ); // Accounts. const resolvedAccounts = { payer: { index: 0, isWritable: true as boolean, value: input.payer ?? null, }, priceFeed: { index: 1, isWritable: true as boolean, value: input.priceFeed ?? null, }, systemProgram: { index: 2, isWritable: false as boolean, value: input.systemProgram ?? null, }, } satisfies ResolvedAccountsWithIndices; // Arguments. const resolvedArgs: InitPriceFeedInstructionArgs = { ...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 = getInitPriceFeedInstructionDataSerializer().serialize( resolvedArgs as InitPriceFeedInstructionDataArgs ); // Bytes Created On Chain. const bytesCreatedOnChain = 0; return transactionBuilder([ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain }, ]); }