2021-01-01 13:58:20 -08:00
|
|
|
export type Idl = {
|
2021-01-01 15:48:25 -08:00
|
|
|
version: string;
|
|
|
|
name: string;
|
|
|
|
instructions: IdlInstruction[];
|
|
|
|
accounts?: IdlTypeDef[];
|
|
|
|
types?: IdlTypeDef[];
|
|
|
|
};
|
2021-01-01 13:58:20 -08:00
|
|
|
|
|
|
|
export type IdlInstruction = {
|
2021-01-01 15:48:25 -08:00
|
|
|
name: string;
|
|
|
|
accounts: IdlAccount[];
|
|
|
|
args: IdlField[];
|
|
|
|
};
|
2021-01-01 13:58:20 -08:00
|
|
|
|
|
|
|
export type IdlAccount = {
|
2021-01-01 15:48:25 -08:00
|
|
|
name: string;
|
|
|
|
isMut: boolean;
|
|
|
|
isSigner: boolean;
|
|
|
|
};
|
2021-01-01 13:58:20 -08:00
|
|
|
|
|
|
|
export type IdlField = {
|
2021-01-01 15:48:25 -08:00
|
|
|
name: string;
|
|
|
|
type: IdlType;
|
|
|
|
};
|
2021-01-01 13:58:20 -08:00
|
|
|
|
|
|
|
export type IdlTypeDef = {
|
2021-01-01 15:48:25 -08:00
|
|
|
name: string;
|
|
|
|
type: IdlTypeDefTy;
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
type IdlTypeDefTy = {
|
2021-01-01 15:48:25 -08:00
|
|
|
kind: "struct" | "enum";
|
|
|
|
fields?: IdlTypeDefStruct;
|
|
|
|
variants?: IdlTypeDefEnum;
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
type IdlTypeDefStruct = Array<IdlField>;
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
type IdlTypeDefEnum = {
|
2021-01-01 15:48:25 -08:00
|
|
|
variants: IdlEnumVariant;
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|
|
|
|
|
2021-01-01 15:48:25 -08:00
|
|
|
type IdlType =
|
|
|
|
| "bool"
|
|
|
|
| "u8"
|
|
|
|
| "i8"
|
|
|
|
| "u16"
|
|
|
|
| "i16"
|
|
|
|
| "u32"
|
|
|
|
| "i32"
|
|
|
|
| "u64"
|
|
|
|
| "i64"
|
|
|
|
| "bytes"
|
|
|
|
| "string"
|
|
|
|
| "publicKey"
|
|
|
|
| IdlTypeOption
|
|
|
|
| IdlTypeDefined;
|
2021-01-01 13:58:20 -08:00
|
|
|
|
|
|
|
export type IdlTypeOption = {
|
2021-01-01 15:48:25 -08:00
|
|
|
option: IdlType;
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
// User defined type.
|
|
|
|
export type IdlTypeDefined = {
|
2021-01-01 15:48:25 -08:00
|
|
|
defined: string;
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
type IdlEnumVariant = {
|
2021-01-01 15:48:25 -08:00
|
|
|
// todo
|
2021-01-01 13:58:20 -08:00
|
|
|
};
|