diff --git a/packages/nodes-from-anchor/src/v01/ProgramNode.ts b/packages/nodes-from-anchor/src/v01/ProgramNode.ts index 57eadca2..b0596e4c 100644 --- a/packages/nodes-from-anchor/src/v01/ProgramNode.ts +++ b/packages/nodes-from-anchor/src/v01/ProgramNode.ts @@ -13,13 +13,13 @@ export function programNodeFromAnchorV01(idl: IdlV01): ProgramNode { const instructions = idl.instructions ?? []; const errors = idl.errors ?? []; - const definedTypes = types.map(definedTypeNodeFromAnchorV01); + const filteredTypes = types.filter(type => !accounts.some(account => account.name === type.name)); + const definedTypes = filteredTypes.map(definedTypeNodeFromAnchorV01); const accountNodeFromAnchorV01 = accountNodeFromAnchorV01WithTypeDefinition(types); const pdas = instructions .flatMap(instruction => instruction.accounts) .filter(account => !!account.pda && !account.pda?.program) .map(pdaNodeFromAnchorV01); - return programNode({ accounts: accounts.map(accountNodeFromAnchorV01), definedTypes, diff --git a/packages/nodes-from-anchor/test/v01/ProgramNode.test.ts b/packages/nodes-from-anchor/test/v01/ProgramNode.test.ts index 1ac600a8..349397e5 100644 --- a/packages/nodes-from-anchor/test/v01/ProgramNode.test.ts +++ b/packages/nodes-from-anchor/test/v01/ProgramNode.test.ts @@ -2,7 +2,6 @@ import { accountNode, bytesTypeNode, constantPdaSeedNode, - definedTypeNode, errorNode, fieldDiscriminatorNode, instructionAccountNode, @@ -65,7 +64,7 @@ test('it creates program nodes', () => { name: 'myAccount', }), ], - definedTypes: [definedTypeNode({ name: 'myAccount', type: structTypeNode([]) })], + definedTypes: [], errors: [ errorNode({ code: 42,