Skip to content

Add package that dynamically resolve IDL components #85

@lorisleiva

Description

@lorisleiva

Currently, we only use the Codama IDL statically by generating code that can they be used by consumers to interact with the program.

We also need a dynamic version of this such that any app can dynamically interact with a program's components (accounts, instructions, types, errors, etc.) by simply providing it's Codama IDL.

This would be hugely beneficial for apps like explorer that need to access that information on demand.

This package would offer various helper functions that would always accept a Codama IDL first and then any required parameters afterwards.

For instance:

  • getAccountCodec(rootNode, accountName), getDefinedTypeCodec(rootNode, typeName), getInstructionCodec(rootNode, instructionName), etc.: Returns a web3.js Codec for a given component. Encoder / decoder versions can also be provided.
  • decodeAccount(rootNode, accountName, rawData), decodeInstruction(rootNode, instructionName, rawData), decodeDefinedType(rootNode, typeName, rawData), etc.: Similar but decodes directly.
  • identifyAccount(rootNode, rawData), identifyInstruction(rootNode, rawData), etc.: Tells us which components we are dealing with based on its raw data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions