Skip to content

[nodes-from-anchor] Allow PDA program to point to another instruction account #607

@PtSik

Description

@PtSik

I'm attempting to use @codama/nodes-from-anchor to convert an Anchor-generated IDL into the Codama format for client generation using @codama/renderers-js.

When running the conversion script, i encounter the following error:

/program/node_modules/@codama/nodes-from-anchor/src/v01/InstructionAccountNode.ts:137
                        throw new CodamaError(CODAMA_ERROR__ANCHOR__PROGRAM_ID_KIND_UNIMPLEMENTED, { kind });
                              ^


CodamaError: Program ID kind [account] is not implemented.
    at instructionAccountNodeFromAnchorV01 (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/InstructionAccountNode.ts:137:31)
    at <anonymous> (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/InstructionAccountNode.ts:43:16)
    at Array.flatMap (<anonymous>)
    at instructionAccountNodesFromAnchorV01 (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/InstructionAccountNode.ts:40:16)
    at instructionNodeFromAnchorV01 (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/InstructionNode.ts:31:19)
    at <anonymous> (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/ProgramNode.ts:24:55)
    at Array.map (<anonymous>)
    at programNodeFromAnchorV01 (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/ProgramNode.ts:24:36)
    at rootNodeFromAnchorV01 (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/v01/RootNode.ts:7:25)
    at rootNodeFromAnchorWithoutDefaultVisitor (/Users/kajman/coding/program/node_modules/@codama/nodes-from-anchor/src/index.ts:20:16) {
  context: { __code: 2100005, kind: 'account' }
}

Node.js v18.20.7

Example account definition structure from my IDL that causes the issue:

"program": {
    "kind": "account",
    "path": "token_metadata_program" 
}

However after manually editing pattern in IDL from "program": { "kind": "account", ... } to "program": { "kind": "const", ... }
creates the client successfully

anchor 0.31.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    anchorImproves conversion from Anchor IDLv2Something to look into when updating the Codama standard to v2

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions