I am trying to decode a Solana transaction using anchor's BorshCoder. I have a seperate file with the IDL of which the content was copied 1 on 1 from here: https://github.com/raydium-io/raydium-idl/blob/master/raydium_amm/idl.json
When creating a new BorshCoder class like this:
const { BorshCoder } = require('@coral-xyz/anchor');
const IDL = require("./idl.json");
const borshCoder = new BorshCoder(IDL);
This error is thrown
throw new error_js_1.IdlError(`Type not found: ${field.name}`);
IdlError: Type not found: undefined
Is the IDL file incorrect? All IDL files I have tried so far didn't work one way or the other. So if this is the case could you provide me with a IDL json file that should work?
It seems that you use last (or one of the last) @coral-xyz/anchor
sdk version. Since v0.30.0
IDL format has been changed. There is three ways to process provided idl json file:
anchor idl convert old_type.json -o new_type.json
@coral-xyz/anchor
for example to 0.29.0
in your project.