Skip to content

chore: add new anchor with solana/kit#4313

Open
Efcolipt wants to merge 1 commit intosolana-foundation:masterfrom
Efcolipt:master
Open

chore: add new anchor with solana/kit#4313
Efcolipt wants to merge 1 commit intosolana-foundation:masterfrom
Efcolipt:master

Conversation

@Efcolipt
Copy link

@Efcolipt Efcolipt commented Mar 14, 2026

Add new fully typed with solana kit IDL parser
Also added fully typed camelized IDL without having types and json

You no longer need to have two files, a JSON file, and separate types for them. A constant is enough (you can simply copy the JSON and paste it with "as const"). This will be enough to ensure everything is typed and also converted to camelCase mode.

I only wrote the basic functionality I needed for my project.

Encode/Decode Accounts
Decode Logs declared in IDL
Encode/Decode Instructions, also get account(address) by name from instruction by provided accounts in this instruction
Decoded constants

Example

IDL just take from here https://github.com/MeteoraAg/damm-v2-sdk/blob/main/src/idl/cp_amm.json
Just take and paste as const in defineIdl

 const a = new IdlParser(IDL_METEORA_DAMM_V2);
    console.log({
      const: a.constants.binStepBpsDefault.value,
      instrEncode: a.instructions.initializePool.encode({
        params: {
          activationPoint: null,
          liquidity: 1n,
          sqrtPrice: 1n
        }
      }),
      instrDecode: a.instructions.initializePool.decode(
        Buffer.from(
          '5fb40aac54aee8280fdd92347eed6230b19f87e71a0300003a165ec2bc6af151240000000000000000',
          'hex',
        ),
      ).params,
      instrDiscr: a.instructions.initializePool.discriminator,
      accountDecode: a.accounts.pool.decode(
        Buffer.from(
          '8ZptBBGxbbygJSYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA6Fl7CvGrxUSQAAAAAAAAABpuIV/6rgYT7aH9jRhjANdrEOdwa6ztVmKDwAAAAAAENSQ32QJbDreGdK0ju88KDslZz2fpgyTl/LeuPhmIbGBdu6u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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=',
          'base64',
        ),
      )
    });

image image

@vercel
Copy link

vercel bot commented Mar 14, 2026

@Efcolipt is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant