Open LucasSte opened 1 year ago
When we define a constant struct in an Anchor contract, it appears in the IDL as a string formatted as a Rust declaration. For instance, the following constant:
struct MyStr { suns: u64, mclass: Planet, // This is an enum data: [u8; 3], } #[constant] const MY_CONST : MyStr = MyStr {suns: 5, mclass: Planet::Mercury, data: [9, 70, 33]};
Is represented in the IDL as:
"constants": [ { "name": "MY_CONST", "type": { "defined": "MyStr" }, "value": "MyStr { suns : 5 , mclass : Planet :: Mercury , data : [9 , 70 , 33] , }" } ]
It is awful to parse and generate the struct in a string with such a formatting when we use languages other than Rust.
When we define a constant struct in an Anchor contract, it appears in the IDL as a string formatted as a Rust declaration. For instance, the following constant:
Is represented in the IDL as:
It is awful to parse and generate the struct in a string with such a formatting when we use languages other than Rust.