coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.36k stars 1.25k forks source link

`declare_program!()` macro not supported for previous version IDLs #2972

Closed VY5FR2NWJ9 closed 1 month ago

VY5FR2NWJ9 commented 1 month ago

The macro attempts to parse the Idl type using serde_json, but complains about mandatory discriminator field for IDLs generated before anchor 0.30

Example IDL that does not work with this macro: https://github.com/drift-labs/protocol-v2/blob/master/sdk/src/idl/drift.json

I wonder if it would be sensible to have the option to make backwards incompatible fields such as discriminator Option<>, or if there is a way of migrating old IDL JSON files to the new format (as a client, who does not have access to the project)

acheroncrypto commented 1 month ago

I wonder if it would be sensible to have the option to make backwards incompatible fields such as discriminator Option<>, or if there is a way of migrating old IDL JSON files to the new format (as a client, who does not have access to the project)

Yes, I'll add a utility to convert an old IDL to a new one, and this will be supported by default with declare_program!.

VY5FR2NWJ9 commented 1 month ago

awesome, that sounds great