Recursively flattens nested instruction account structures from Anchor IDL v0.1.0 format.
This function handles the nested account structures (account groups) that appear in Anchor IDLs and flattens them into a single array of instruction account nodes. Parent-child relationships are preserved through naming conventions.
All account nodes available in the program
Arguments for the instruction
The instruction account items from the Anchor IDL, potentially nested
The parent account name prefix for nested accounts
Flattened array of instruction account nodes
// Given nested accounts:const nested = [ { name: "mintAccounts", accounts: [ { name: "mint", ... }, { name: "metadata", ... } ] }];// Returns flattened:// [// { name: "mintAccounts_mint", ... },// { name: "mintAccounts_metadata", ... }// ] Copy
// Given nested accounts:const nested = [ { name: "mintAccounts", accounts: [ { name: "mint", ... }, { name: "metadata", ... } ] }];// Returns flattened:// [// { name: "mintAccounts_mint", ... },// { name: "mintAccounts_metadata", ... }// ]
Recursively flattens nested instruction account structures from Anchor IDL v0.1.0 format.
This function handles the nested account structures (account groups) that appear in Anchor IDLs and flattens them into a single array of instruction account nodes. Parent-child relationships are preserved through naming conventions.