Closed thlorenz closed 2 years ago
For anchor programs solita now renders an optional anchorRemainingAccounts property for the instruction accounts, allowing users to specify them.
anchorRemainingAccounts
This can be turned off by setting anchorRemainingAccounts = false in the solita config.
anchorRemainingAccounts = false
Renders code outlined in this issue and thus fixes it.
export type ExecuteSaleInstructionAccounts = { buyer: web3.PublicKey seller: web3.PublicKey tokenAccount: web3.PublicKey tokenMint: web3.PublicKey [ .. many more .. ] programAsSigner: web3.PublicKey rent?: web3.PublicKey anchorRemainingAccounts?: web3.AccountMeta[] } [ .. ] export function createExecuteSaleInstruction( accounts: ExecuteSaleInstructionAccounts, args: ExecuteSaleInstructionArgs, programId = new web3.PublicKey('hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk') ) { const [data] = executeSaleStruct.serialize({ instructionDiscriminator: executeSaleInstructionDiscriminator, ...args, }) const keys: web3.AccountMeta[] = [ { pubkey: accounts.buyer, isWritable: true, isSigner: false, }, { pubkey: accounts.seller, isWritable: true, isSigner: false, }, [ .. many more .. ] } if (accounts.anchorRemainingAccounts != null) { for (const acc of accounts.anchorRemainingAccounts) { keys.push(acc) } } const ix = new web3.TransactionInstruction({ programId, keys, data, }) return ix
Summary
For anchor programs solita now renders an optional
anchorRemainingAccounts
property for the instruction accounts, allowing users to specify them.This can be turned off by setting
anchorRemainingAccounts = false
in the solita config.Renders code outlined in this issue and thus fixes it.
Sample Code Rendered