idl.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. export type Idl = {
  2. version: string;
  3. name: string;
  4. instructions: IdlInstruction[];
  5. accounts?: IdlTypeDef[];
  6. types?: IdlTypeDef[];
  7. errors?: IdlErrorCode[];
  8. };
  9. export type IdlInstruction = {
  10. name: string;
  11. accounts: IdlAccount[];
  12. args: IdlField[];
  13. };
  14. export type IdlAccount = {
  15. name: string;
  16. isMut: boolean;
  17. isSigner: boolean;
  18. };
  19. export type IdlField = {
  20. name: string;
  21. type: IdlType;
  22. };
  23. export type IdlTypeDef = {
  24. name: string;
  25. type: IdlTypeDefTy;
  26. };
  27. type IdlTypeDefTy = {
  28. kind: "struct" | "enum";
  29. fields?: IdlTypeDefStruct;
  30. variants?: IdlTypeDefEnum;
  31. };
  32. type IdlTypeDefStruct = Array<IdlField>;
  33. // TODO
  34. type IdlTypeDefEnum = {
  35. variants: IdlEnumVariant;
  36. };
  37. type IdlType =
  38. | "bool"
  39. | "u8"
  40. | "i8"
  41. | "u16"
  42. | "i16"
  43. | "u32"
  44. | "i32"
  45. | "u64"
  46. | "i64"
  47. | "bytes"
  48. | "string"
  49. | "publicKey"
  50. | IdlTypeVec
  51. | IdlTypeOption
  52. | IdlTypeDefined;
  53. export type IdlTypeVec = {
  54. vec: IdlType;
  55. };
  56. export type IdlTypeOption = {
  57. option: IdlType;
  58. };
  59. // User defined type.
  60. export type IdlTypeDefined = {
  61. defined: string;
  62. };
  63. type IdlEnumVariant = {
  64. // todo
  65. };
  66. type IdlErrorCode = {
  67. code: number;
  68. name: string;
  69. msg?: string;
  70. };