idl parse vs idl gen
705 lines
{
{
"version": "0.1.0",
"version": "0.1.0",
"name": "example_program",
"name": "example_program",
"docs": [
"docs": [
"This is an example program used for testing"
"This is an example program used for testing"
],
],
"constants": [
"constants": [
{
{
"name": "BAR_CONST",
"name": "BAR_CONST",
"type": "u8",
"type": "u8",
"value": "6"
"value": "6"
},
},
{
{
"name": "FOO_CONST",
"name": "FOO_CONST",
"type": "u128",
"type": "u128",
"value": "1_000_000"
"value": "1000000"
}
}
],
],
"instructions": [
"instructions": [
{
{
"name": "initialize",
"name": "initialize",
"accounts": [
"accounts": [
{
{
"name": "state",
"name": "state",
"isMut": true,
"isMut": true,
"isSigner": true,
"isSigner": true,
"docs": [
"docs": [
"State account"
"State account"
]
]
},
},
{
{
"name": "nested",
"name": "nested",
"accounts": [
"accounts": [
{
{
"name": "clock",
"name": "clock",
"isMut": false,
"isMut": false,
"isSigner": false,
"isSigner": false,
"docs": [
"docs": [
"Sysvar clock"
"Sysvar clock"
]
]
},
},
{
{
"name": "rent",
"name": "rent",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
}
}
]
]
},
},
{
{
"name": "zcAccount",
"name": "zcAccount",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
},
},
{
{
"name": "payer",
"name": "payer",
"isMut": true,
"isMut": true,
"isSigner": true
"isSigner": true
},
},
{
{
"name": "systemProgram",
"name": "systemProgram",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
}
}
],
],
"args": []
"args": []
},
},
{
{
"name": "initializeWithValues",
"name": "initializeWithValues",
"docs": [
"docs": [
"Initializes an account with specified values"
"Initializes an account with specified values"
],
],
"accounts": [
"accounts": [
{
{
"name": "state",
"name": "state",
"isMut": true,
"isMut": true,
"isSigner": true,
"isSigner": true,
"docs": [
"docs": [
"State account"
"State account"
]
]
},
},
{
{
"name": "nested",
"name": "nested",
"accounts": [
"accounts": [
{
{
"name": "clock",
"name": "clock",
"isMut": false,
"isMut": false,
"isSigner": false,
"isSigner": false,
"docs": [
"docs": [
"Sysvar clock"
"Sysvar clock"
]
]
},
},
{
{
"name": "rent",
"name": "rent",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
}
}
]
]
},
},
{
{
"name": "zcAccount",
"name": "zcAccount",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
},
},
{
{
"name": "payer",
"name": "payer",
"isMut": true,
"isMut": true,
"isSigner": true
"isSigner": true
},
},
{
{
"name": "systemProgram",
"name": "systemProgram",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
}
}
],
],
"args": [
"args": [
{
{
"name": "boolField",
"name": "boolField",
"type": "bool"
"type": "bool"
},
},
{
{
"name": "u8Field",
"name": "u8Field",
"type": "u8"
"type": "u8"
},
},
{
{
"name": "i8Field",
"name": "i8Field",
"type": "i8"
"type": "i8"
},
},
{
{
"name": "u16Field",
"name": "u16Field",
"type": "u16"
"type": "u16"
},
},
{
{
"name": "i16Field",
"name": "i16Field",
"type": "i16"
"type": "i16"
},
},
{
{
"name": "u32Field",
"name": "u32Field",
"type": "u32"
"type": "u32"
},
},
{
{
"name": "i32Field",
"name": "i32Field",
"type": "i32"
"type": "i32"
},
},
{
{
"name": "f32Field",
"name": "f32Field",
"type": "f32"
"type": "f32"
},
},
{
{
"name": "u64Field",
"name": "u64Field",
"type": "u64"
"type": "u64"
},
},
{
{
"name": "i64Field",
"name": "i64Field",
"type": "i64"
"type": "i64"
},
},
{
{
"name": "f64Field",
"name": "f64Field",
"type": "f64"
"type": "f64"
},
},
{
{
"name": "u128Field",
"name": "u128Field",
"type": "u128"
"type": "u128"
},
},
{
{
"name": "i128Field",
"name": "i128Field",
"type": "i128"
"type": "i128"
},
},
{
{
"name": "bytesField",
"name": "bytesField",
"type": "bytes"
"type": "bytes"
},
},
{
{
"name": "stringField",
"name": "stringField",
"type": "string"
"type": "string"
},
},
{
{
"name": "pubkeyField",
"name": "pubkeyField",
"type": "publicKey"
"type": "publicKey"
},
},
{
{
"name": "vecField",
"name": "vecField",
"type": {
"type": {
"vec": "u64"
"vec": "u64"
}
}
},
},
{
{
"name": "vecStructField",
"name": "vecStructField",
"type": {
"type": {
"vec": {
"vec": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
}
}
},
},
{
{
"name": "optionField",
"name": "optionField",
"type": {
"type": {
"option": "bool"
"option": "bool"
}
}
},
},
{
{
"name": "optionStructField",
"name": "optionStructField",
"type": {
"type": {
"option": {
"option": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
}
}
},
},
{
{
"name": "structField",
"name": "structField",
"type": {
"type": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
},
},
{
{
"name": "arrayField",
"name": "arrayField",
"type": {
"type": {
"array": [
"array": [
"bool",
"bool",
3
3
]
]
}
}
},
},
{
{
"name": "enumField1",
"name": "enumField1",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField2",
"name": "enumField2",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField3",
"name": "enumField3",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField4",
"name": "enumField4",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
}
}
]
]
},
},
{
{
"name": "initializeWithValues2",
"name": "initializeWithValues2",
"docs": [
"docs": [
"a separate instruction due to initialize_with_values having too many arguments",
"a separate instruction due to initialize_with_values having too many arguments",
"https://github.com/solana-labs/solana/issues/23978"
"https://github.com/solana-labs/solana/issues/23978"
],
],
"accounts": [
"accounts": [
{
{
"name": "state",
"name": "state",
"isMut": true,
"isMut": true,
"isSigner": true
"isSigner": true
},
},
{
{
"name": "payer",
"name": "payer",
"isMut": true,
"isMut": true,
"isSigner": true
"isSigner": true
},
},
{
{
"name": "systemProgram",
"name": "systemProgram",
"isMut": false,
"isMut": false,
"isSigner": false
"isSigner": false
}
}
],
],
"args": [
"args": [
{
{
"name": "vecOfOption",
"name": "vecOfOption",
"type": {
"type": {
"vec": {
"vec": {
"option": "u64"
"option": "u64"
}
}
}
}
},
},
{
{
"name": "boxField",
"name": "boxField",
"type": "bool"
"type": "bool"
}
}
],
],
"returns": {
"returns": {
"defined": "SomeRetStruct"
"defined": "idl::SomeRetStruct"
}
}
},
},
{
{
"name": "causeError",
"name": "causeError",
"accounts": [],
"accounts": [],
"args": []
"args": []
}
}
],
],
"accounts": [
"accounts": [
{
{
"name": "State",
"name": "State",
"full_path": "idl::State",
"docs": [
"docs": [
"An account containing various fields"
"An account containing various fields"
],
],
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "boolField",
"name": "boolField",
"docs": [
"docs": [
"A boolean field"
"A boolean field"
],
],
"type": "bool"
"type": "bool"
},
},
{
{
"name": "u8Field",
"name": "u8Field",
"type": "u8"
"type": "u8"
},
},
{
{
"name": "i8Field",
"name": "i8Field",
"type": "i8"
"type": "i8"
},
},
{
{
"name": "u16Field",
"name": "u16Field",
"type": "u16"
"type": "u16"
},
},
{
{
"name": "i16Field",
"name": "i16Field",
"type": "i16"
"type": "i16"
},
},
{
{
"name": "u32Field",
"name": "u32Field",
"type": "u32"
"type": "u32"
},
},
{
{
"name": "i32Field",
"name": "i32Field",
"type": "i32"
"type": "i32"
},
},
{
{
"name": "f32Field",
"name": "f32Field",
"type": "f32"
"type": "f32"
},
},
{
{
"name": "u64Field",
"name": "u64Field",
"type": "u64"
"type": "u64"
},
},
{
{
"name": "i64Field",
"name": "i64Field",
"type": "i64"
"type": "i64"
},
},
{
{
"name": "f64Field",
"name": "f64Field",
"type": "f64"
"type": "f64"
},
},
{
{
"name": "u128Field",
"name": "u128Field",
"type": "u128"
"type": "u128"
},
},
{
{
"name": "i128Field",
"name": "i128Field",
"type": "i128"
"type": "i128"
},
},
{
{
"name": "bytesField",
"name": "bytesField",
"type": "bytes"
"type": "bytes"
},
},
{
{
"name": "stringField",
"name": "stringField",
"type": "string"
"type": "string"
},
},
{
{
"name": "pubkeyField",
"name": "pubkeyField",
"type": "publicKey"
"type": "publicKey"
},
},
{
{
"name": "vecField",
"name": "vecField",
"type": {
"type": {
"vec": "u64"
"vec": "u64"
}
}
},
},
{
{
"name": "vecStructField",
"name": "vecStructField",
"type": {
"type": {
"vec": {
"vec": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
}
}
},
},
{
{
"name": "optionField",
"name": "optionField",
"type": {
"type": {
"option": "bool"
"option": "bool"
}
}
},
},
{
{
"name": "optionStructField",
"name": "optionStructField",
"type": {
"type": {
"option": {
"option": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
}
}
},
},
{
{
"name": "structField",
"name": "structField",
"type": {
"type": {
"defined": "FooStruct"
"defined": "idl::FooStruct"
}
}
},
},
{
{
"name": "arrayField",
"name": "arrayField",
"type": {
"type": {
"array": [
"array": [
"bool",
"bool",
3
3
]
]
}
}
},
},
{
{
"name": "enumField1",
"name": "enumField1",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField2",
"name": "enumField2",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField3",
"name": "enumField3",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
},
},
{
{
"name": "enumField4",
"name": "enumField4",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
}
}
]
]
}
}
},
},
{
{
"name": "State2",
"name": "State2",
"full_path": "idl::State2",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "vecOfOption",
"name": "vecOfOption",
"type": {
"type": {
"vec": {
"vec": {
"option": "u64"
"option": "u64"
}
}
}
}
},
},
{
{
"name": "boxField",
"name": "boxField",
"type": "bool"
"type": "bool"
}
}
]
]
}
}
},
},
{
{
"name": "SomeZcAccount",
"name": "SomeZcAccount",
"full_path": "idl::SomeZcAccount",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "field",
"name": "field",
"type": {
"type": {
"defined": "ZcStruct"
"defined": "idl::ZcStruct"
}
}
}
}
]
]
}
}
}
}
],
],
"types": [
"types": [
{
{
"name": "Baz",
"name": "Baz",
"full_path": "idl::some_other_module::Baz",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "someU8",
"name": "someU8",
"type": "u8"
"type": "u8"
}
}
]
]
}
}
},
},
{
{
"name": "BarStruct",
"name": "BarStruct",
"full_path": "idl::BarStruct",
"docs": [
"docs": [
"Bar struct type"
"Bar struct type"
],
],
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "someField",
"name": "someField",
"docs": [
"docs": [
"Some field"
"Some field"
],
],
"type": "bool"
"type": "bool"
},
},
{
{
"name": "otherField",
"name": "otherField",
"type": "u8"
"type": "u8"
}
}
]
]
}
}
},
},
{
{
"name": "FooStruct",
"name": "FooStruct",
"full_path": "idl::FooStruct",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "field1",
"name": "field1",
"type": "u8"
"type": "u8"
},
},
{
{
"name": "field2",
"name": "field2",
"type": "u16"
"type": "u16"
},
},
{
{
"name": "nested",
"name": "nested",
"type": {
"type": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
},
},
{
{
"name": "vecNested",
"name": "vecNested",
"type": {
"type": {
"vec": {
"vec": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
}
}
},
},
{
{
"name": "optionNested",
"name": "optionNested",
"type": {
"type": {
"option": {
"option": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
}
}
},
},
{
{
"name": "enumField",
"name": "enumField",
"type": {
"type": {
"defined": "FooEnum"
"defined": "idl::FooEnum"
}
}
}
}
]
]
}
}
},
},
{
{
"name": "ZcStruct",
"name": "ZcStruct",
"full_path": "idl::ZcStruct",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "someField",
"name": "someField",
"type": "u16"
"type": "u16"
}
}
]
]
}
}
},
},
{
{
"name": "SomeRetStruct",
"name": "SomeRetStruct",
"full_path": "idl::SomeRetStruct",
"type": {
"type": {
"kind": "struct",
"kind": "struct",
"fields": [
"fields": [
{
{
"name": "someField",
"name": "someField",
"type": "u8"
"type": "u8"
}
}
]
]
}
}
},
},
{
{
"name": "FooEnum",
"name": "FooEnum",
"full_path": "idl::FooEnum",
"docs": [
"docs": [
"Enum type"
"Enum type"
],
],
"type": {
"type": {
"kind": "enum",
"kind": "enum",
"variants": [
"variants": [
{
{
"name": "Unnamed",
"name": "Unnamed",
"fields": [
"fields": [
"bool",
"bool",
"u8",
"u8",
{
{
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
]
]
},
},
{
{
"name": "UnnamedSingle",
"name": "UnnamedSingle",
"fields": [
"fields": [
{
{
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
]
]
},
},
{
{
"name": "Named",
"name": "Named",
"fields": [
"fields": [
{
{
"name": "bool_field",
"name": "boolField",
"docs": [
"docs": [
"A bool field inside a struct tuple kind"
"A bool field inside a struct tuple kind"
],
],
"type": "bool"
"type": "bool"
},
},
{
{
"name": "u8_field",
"name": "u8Field",
"type": "u8"
"type": "u8"
},
},
{
{
"name": "nested",
"name": "nested",
"type": {
"type": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
}
}
]
]
},
},
{
{
"name": "Struct",
"name": "Struct",
"fields": [
"fields": [
{
{
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
]
]
},
},
{
{
"name": "OptionStruct",
"name": "OptionStruct",
"fields": [
"fields": [
{
{
"option": {
"option": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
}
}
]
]
},
},
{
{
"name": "VecStruct",
"name": "VecStruct",
"fields": [
"fields": [
{
{
"vec": {
"vec": {
"defined": "BarStruct"
"defined": "idl::BarStruct"
}
}
}
}
]
]
},
},
{
{
"name": "NoFields"
"name": "NoFields"
}
}
]
]
}
}
},
{
"name": "Baz",
"full_path": "some_external_program::Baz",
"type": {
"kind": "struct",
"fields": [
{
"name": "someField",
"type": "u8"
}
]
}
}
}
],
],
"events": [
"events": [
{
{
"name": "SomeEvent",
"name": "SomeEvent",
"fields": [
"fields": [
{
{
"name": "boolField",
"name": "boolField",
"type": "bool",
"type": "bool",
"index": false
"index": false
},
},
{
{
"name": "externalBaz",
"name": "externalBaz",
"type": {
"type": {
"defined": "some_external_program::Baz"
"defined": "some_external_program::Baz"
},
},
"index": false
"index": false
},
},
{
{
"name": "otherModuleBaz",
"name": "otherModuleBaz",
"type": {
"type": {
"defined": "some_other_module::Baz"
"defined": "idl::some_other_module::Baz"
},
},
"index": false
"index": false
}
}
]
]
}
}
],
],
"errors": [
"errors": [
{
{
"code": 6000,
"code": 6000,
"name": "SomeError",
"name": "SomeError",
"msg": "Example error."
"msg": "Example error."
},
},
{
{
"code": 6001,
"code": 6001,
"name": "OtherError",
"name": "OtherError",
"msg": "Another error."
"msg": "Another error."
},
},
{
{
"code": 6002,
"code": 6002,
"name": "ErrorWithoutMsg"
"name": "ErrorWithoutMsg"
}
}
]
]
}
}