codama-idl / codama

Generate clients, CLIs, documentation and more from your Solana programs
MIT License
73 stars 16 forks source link

Anchor IDL V01 #15

Closed kespinola closed 5 months ago

kespinola commented 5 months ago

Goal

Kinobi is able to generate clients for protocols using the latest IDL schema of anchor.

Changes

kespinola commented 5 months ago

@lorisleiva here is the initial scaffolding based on the V00. I'm now going through writing specs and resolving the type violations caused by the updated IDL definition.

kespinola commented 5 months ago

@lorisleiva getting somewhere now. List of considerations:

  1. New version of IDL does referencing to types from accounts and instructions. I passed types to accounts but lower structs used as args don't have access to the types list.
  2. Pdas and seed constant fields.
  3. I dropped tuple and map field types. Give these a look could use some guidance.
kespinola commented 5 months ago

All specs passing but still needs work on type linking and pdas.

kespinola commented 5 months ago

I've started setting up the PDAs but current kinibo node catalogue doesn't look to support references other field on an instruction.

Able to represent the const now but no node types for kind 'account' | 'arg'

export type IdlV01Pda = {
    program?: IdlV01Seed;
    seeds: IdlV01Seed[];
};

export type IdlV01Seed = IdlV01SeedAccount | IdlV01SeedArg | IdlV01SeedConst;

export type IdlV01SeedConst = {
    kind: 'const';
    value: number[];
};

export type IdlV01SeedArg = {
    kind: 'arg';
    path: string;
};

export type IdlV01SeedAccount = {
    account?: string;
    kind: 'account';
    path: string;
};
kespinola commented 5 months ago

@lorisleiva I think we are in a good spot now. Ready to test on a program and final review.

changeset-bot[bot] commented 5 months ago

⚠️ No Changeset found

Latest commit: b880ad7925bd6cbf4060262634541c7eaa36156b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

kespinola commented 5 months ago

@lorisleiva CR is in.

lorisleiva commented 5 months ago

Thanks! There are a few final touches to fix but I can sort this out in a subsequent commit. 🍻