@sentio/sdk 2.0.0-rc.13 → 2.0.0-rc.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/lib/aptos/api.d.ts +5 -0
  2. package/lib/aptos/api.js +21 -0
  3. package/lib/aptos/api.js.map +1 -0
  4. package/lib/aptos/aptos-plugin.d.ts +14 -0
  5. package/lib/aptos/aptos-plugin.js +146 -0
  6. package/lib/aptos/aptos-plugin.js.map +1 -0
  7. package/lib/aptos/aptos-processor.d.ts +72 -0
  8. package/lib/aptos/aptos-processor.js +201 -0
  9. package/lib/aptos/aptos-processor.js.map +1 -0
  10. package/lib/aptos/builtin/0x1.d.ts +2140 -0
  11. package/lib/aptos/builtin/0x1.js +2727 -0
  12. package/lib/aptos/builtin/0x1.js.map +1 -0
  13. package/lib/aptos/builtin/0x3.d.ts +573 -0
  14. package/lib/aptos/builtin/0x3.js +496 -0
  15. package/lib/aptos/builtin/0x3.js.map +1 -0
  16. package/lib/aptos/builtin/index.d.ts +2 -0
  17. package/lib/aptos/builtin/index.js +6 -0
  18. package/lib/aptos/builtin/index.js.map +1 -0
  19. package/lib/aptos/codegen/codegen.d.ts +23 -0
  20. package/lib/aptos/codegen/codegen.js +388 -0
  21. package/lib/aptos/codegen/codegen.js.map +1 -0
  22. package/lib/aptos/codegen/index.d.ts +1 -0
  23. package/lib/aptos/codegen/index.js +2 -0
  24. package/lib/aptos/codegen/index.js.map +1 -0
  25. package/lib/aptos/codegen/typegen.d.ts +18 -0
  26. package/lib/aptos/codegen/typegen.js +145 -0
  27. package/lib/aptos/codegen/typegen.js.map +1 -0
  28. package/lib/aptos/codegen/typegen.test.d.ts +1 -0
  29. package/lib/aptos/codegen/typegen.test.js.map +1 -0
  30. package/lib/aptos/context.d.ts +21 -0
  31. package/lib/aptos/context.js +59 -0
  32. package/lib/aptos/context.js.map +1 -0
  33. package/lib/aptos/index.d.ts +9 -0
  34. package/lib/aptos/index.js +8 -0
  35. package/lib/aptos/index.js.map +1 -0
  36. package/lib/aptos/models.d.ts +37 -0
  37. package/lib/aptos/models.js +2 -0
  38. package/lib/aptos/models.js.map +1 -0
  39. package/lib/aptos/move-coder.d.ts +22 -0
  40. package/lib/aptos/move-coder.js +164 -0
  41. package/lib/aptos/move-coder.js.map +1 -0
  42. package/lib/aptos/move-types.d.ts +10 -0
  43. package/lib/aptos/move-types.js +2 -0
  44. package/lib/aptos/move-types.js.map +1 -0
  45. package/lib/aptos/network.d.ts +11 -0
  46. package/lib/aptos/network.js +27 -0
  47. package/lib/aptos/network.js.map +1 -0
  48. package/lib/aptos/run-codegen.d.ts +1 -0
  49. package/lib/aptos/run-codegen.js +12 -0
  50. package/lib/aptos/run-codegen.js.map +1 -0
  51. package/lib/aptos/tests/aptos.test.d.ts +1 -0
  52. package/lib/aptos/tests/aptos.test.js.map +1 -0
  53. package/lib/aptos/tests/souffl3.d.ts +1 -0
  54. package/lib/aptos/tests/souffl3.js +44 -0
  55. package/lib/aptos/tests/souffl3.js.map +1 -0
  56. package/lib/aptos/tests/types/index.d.ts +3 -0
  57. package/lib/aptos/tests/types/index.js +7 -0
  58. package/lib/aptos/tests/types/index.js.map +1 -0
  59. package/lib/aptos/tests/types/reserved.d.ts +445 -0
  60. package/lib/aptos/tests/types/reserved.js +301 -0
  61. package/lib/aptos/tests/types/reserved.js.map +1 -0
  62. package/lib/aptos/tests/types/soffl3.d.ts +1065 -0
  63. package/lib/aptos/tests/types/soffl3.js +548 -0
  64. package/lib/aptos/tests/types/soffl3.js.map +1 -0
  65. package/lib/aptos/tests/types/souffle.d.ts +440 -0
  66. package/lib/aptos/tests/types/souffle.js +295 -0
  67. package/lib/aptos/tests/types/souffle.js.map +1 -0
  68. package/lib/aptos/types.d.ts +9 -0
  69. package/lib/aptos/types.js +130 -0
  70. package/lib/aptos/types.js.map +1 -0
  71. package/lib/aptos/types.test.d.ts +1 -0
  72. package/lib/aptos/types.test.js.map +1 -0
  73. package/lib/aptos/utils.d.ts +7 -0
  74. package/lib/aptos/utils.js +20 -0
  75. package/lib/aptos/utils.js.map +1 -0
  76. package/lib/builtin/internal/eacaggregatorproxy_processor.js +90 -180
  77. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
  78. package/lib/builtin/internal/erc1155_processor.js +25 -50
  79. package/lib/builtin/internal/erc1155_processor.js.map +1 -1
  80. package/lib/builtin/internal/erc20_processor.js +40 -80
  81. package/lib/builtin/internal/erc20_processor.js.map +1 -1
  82. package/lib/builtin/internal/erc20bytes_processor.js +30 -60
  83. package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
  84. package/lib/builtin/internal/erc721_processor.js +45 -90
  85. package/lib/builtin/internal/erc721_processor.js.map +1 -1
  86. package/lib/builtin/internal/weth9_processor.js +30 -60
  87. package/lib/builtin/internal/weth9_processor.js.map +1 -1
  88. package/lib/{utils/chain.d.ts → chain.d.ts} +0 -0
  89. package/lib/{utils/chain.js → chain.js} +0 -0
  90. package/lib/chain.js.map +1 -0
  91. package/lib/core/context.js +1 -1
  92. package/lib/core/context.js.map +1 -1
  93. package/lib/core/sui-plugin.js +1 -1
  94. package/lib/core/sui-plugin.js.map +1 -1
  95. package/lib/error.d.ts +1 -1
  96. package/lib/error.js +10 -12
  97. package/lib/error.js.map +1 -1
  98. package/lib/eth/base-processor-template.d.ts +3 -3
  99. package/lib/eth/base-processor-template.js.map +1 -1
  100. package/lib/eth/base-processor.d.ts +3 -3
  101. package/lib/eth/base-processor.js.map +1 -1
  102. package/lib/eth/{eth-event.d.ts → eth.d.ts} +1 -1
  103. package/lib/eth/eth.js +2 -0
  104. package/lib/eth/eth.js.map +1 -0
  105. package/lib/eth/index.d.ts +1 -0
  106. package/lib/eth/index.js +1 -0
  107. package/lib/eth/index.js.map +1 -1
  108. package/lib/index.d.ts +2 -2
  109. package/lib/index.js +2 -2
  110. package/lib/index.js.map +1 -1
  111. package/lib/solana/builtin/index.d.ts +1 -0
  112. package/lib/solana/builtin/index.js +2 -0
  113. package/lib/solana/builtin/index.js.map +1 -0
  114. package/lib/solana/builtin/spl-token-processor.d.ts +39 -0
  115. package/lib/solana/builtin/spl-token-processor.js +254 -0
  116. package/lib/solana/builtin/spl-token-processor.js.map +1 -0
  117. package/lib/solana/builtin/types.d.ts +427 -0
  118. package/lib/solana/builtin/types.js +200 -0
  119. package/lib/solana/builtin/types.js.map +1 -0
  120. package/lib/solana/codegen/codegen.d.ts +1 -0
  121. package/lib/solana/codegen/codegen.js +122 -0
  122. package/lib/solana/codegen/codegen.js.map +1 -0
  123. package/lib/solana/codegen/index.d.ts +1 -0
  124. package/lib/solana/codegen/index.js +2 -0
  125. package/lib/solana/codegen/index.js.map +1 -0
  126. package/lib/solana/index.d.ts +4 -0
  127. package/lib/solana/index.js +5 -0
  128. package/lib/solana/index.js.map +1 -0
  129. package/lib/solana/run-codegen.d.ts +2 -0
  130. package/lib/solana/run-codegen.js +12 -0
  131. package/lib/solana/run-codegen.js.map +1 -0
  132. package/lib/solana/solana-context.d.ts +9 -0
  133. package/lib/solana/solana-context.js +28 -0
  134. package/lib/solana/solana-context.js.map +1 -0
  135. package/lib/solana/solana-options.d.ts +10 -0
  136. package/lib/solana/solana-options.js +10 -0
  137. package/lib/solana/solana-options.js.map +1 -0
  138. package/lib/solana/solana-plugin.d.ts +9 -0
  139. package/lib/solana/solana-plugin.js +87 -0
  140. package/lib/solana/solana-plugin.js.map +1 -0
  141. package/lib/solana/solana-processor.d.ts +43 -0
  142. package/lib/solana/solana-processor.js +72 -0
  143. package/lib/solana/solana-processor.js.map +1 -0
  144. package/lib/solana/tests/solana.test.d.ts +1 -0
  145. package/lib/solana/tests/solana.test.js.map +1 -0
  146. package/lib/solana/tests/types/basic_1.d.ts +26 -0
  147. package/lib/solana/tests/types/basic_1.js +63 -0
  148. package/lib/solana/tests/types/basic_1.js.map +1 -0
  149. package/lib/solana/tests/types/basic_1_processor.d.ts +21 -0
  150. package/lib/solana/tests/types/basic_1_processor.js +35 -0
  151. package/lib/solana/tests/types/basic_1_processor.js.map +1 -0
  152. package/lib/solana/tests/types/token_bridge.d.ts +29 -0
  153. package/lib/solana/tests/types/token_bridge.js +938 -0
  154. package/lib/solana/tests/types/token_bridge.js.map +1 -0
  155. package/lib/solana/tests/types/token_bridge_processor.d.ts +212 -0
  156. package/lib/solana/tests/types/token_bridge_processor.js +134 -0
  157. package/lib/solana/tests/types/token_bridge_processor.js.map +1 -0
  158. package/lib/solana/tests/wormhole-token-bridge.d.ts +15 -0
  159. package/lib/solana/tests/wormhole-token-bridge.js +79 -0
  160. package/lib/solana/tests/wormhole-token-bridge.js.map +1 -0
  161. package/lib/target-ethers-sentio/view-function.cjs +4 -9
  162. package/lib/target-ethers-sentio/view-function.cjs.map +1 -1
  163. package/lib/testing/test-processor-server.js +1 -1
  164. package/lib/testing/test-processor-server.js.map +1 -1
  165. package/lib/testing/test-provider.js +1 -1
  166. package/lib/testing/test-provider.js.map +1 -1
  167. package/lib/utils/index.d.ts +0 -1
  168. package/lib/utils/index.js +0 -1
  169. package/lib/utils/index.js.map +1 -1
  170. package/package.json +34 -11
  171. package/src/aptos/abis/0x1.json +9205 -0
  172. package/src/aptos/abis/0x3.json +1515 -0
  173. package/src/aptos/api.ts +23 -0
  174. package/src/aptos/aptos-plugin.ts +183 -0
  175. package/src/aptos/aptos-processor.ts +331 -0
  176. package/src/aptos/builtin/0x1.ts +4911 -0
  177. package/src/aptos/builtin/0x3.ts +1092 -0
  178. package/src/aptos/builtin/index.ts +5 -0
  179. package/src/aptos/codegen/codegen.ts +470 -0
  180. package/src/aptos/codegen/index.ts +1 -0
  181. package/src/aptos/codegen/tsconfig.json +8 -0
  182. package/src/aptos/codegen/typegen.ts +165 -0
  183. package/src/aptos/context.ts +72 -0
  184. package/src/aptos/index.ts +10 -0
  185. package/src/aptos/models.ts +47 -0
  186. package/src/aptos/move-coder.ts +201 -0
  187. package/src/aptos/move-types.ts +11 -0
  188. package/src/aptos/network.ts +29 -0
  189. package/src/aptos/run-codegen.ts +13 -0
  190. package/src/aptos/tests/abis/reserved.json +402 -0
  191. package/src/aptos/tests/abis/soffl3.json +1411 -0
  192. package/src/aptos/tests/abis/souffle.json +389 -0
  193. package/src/aptos/tests/souffl3.ts +57 -0
  194. package/src/aptos/tests/types/index.ts +6 -0
  195. package/src/aptos/tests/types/reserved.ts +881 -0
  196. package/src/aptos/tests/types/soffl3.ts +1820 -0
  197. package/src/aptos/tests/types/souffle.ts +880 -0
  198. package/src/aptos/types.ts +149 -0
  199. package/src/aptos/utils.ts +26 -0
  200. package/src/builtin/internal/eacaggregatorproxy_processor.ts +90 -162
  201. package/src/builtin/internal/erc1155_processor.ts +25 -49
  202. package/src/builtin/internal/erc20_processor.ts +40 -72
  203. package/src/builtin/internal/erc20bytes_processor.ts +30 -54
  204. package/src/builtin/internal/erc721_processor.ts +45 -81
  205. package/src/builtin/internal/weth9_processor.ts +30 -54
  206. package/src/{utils/chain.ts → chain.ts} +0 -0
  207. package/src/core/context.ts +1 -1
  208. package/src/core/sui-plugin.ts +1 -1
  209. package/src/error.ts +12 -14
  210. package/src/eth/base-processor-template.ts +3 -3
  211. package/src/eth/base-processor.ts +4 -4
  212. package/src/eth/{eth-event.ts → eth.ts} +1 -1
  213. package/src/eth/index.ts +2 -0
  214. package/src/index.ts +2 -2
  215. package/src/solana/builtin/index.ts +1 -0
  216. package/src/solana/builtin/spl-token-processor.ts +298 -0
  217. package/src/solana/builtin/types.ts +279 -0
  218. package/src/solana/codegen/codegen.ts +140 -0
  219. package/src/solana/codegen/index.ts +1 -0
  220. package/src/solana/codegen/tsconfig.json +8 -0
  221. package/src/solana/index.ts +4 -0
  222. package/src/solana/run-codegen.ts +13 -0
  223. package/src/solana/solana-context.ts +30 -0
  224. package/src/solana/solana-options.ts +11 -0
  225. package/src/solana/solana-plugin.ts +103 -0
  226. package/src/solana/solana-processor.ts +102 -0
  227. package/src/solana/tests/abis/basic_1.json +62 -0
  228. package/src/solana/tests/abis/token_bridge.json +937 -0
  229. package/src/solana/tests/types/basic_1.ts +62 -0
  230. package/src/solana/tests/types/basic_1_processor.ts +42 -0
  231. package/src/solana/tests/types/token_bridge.ts +937 -0
  232. package/src/solana/tests/types/token_bridge_processor.ts +150 -0
  233. package/src/solana/tests/wormhole-token-bridge.ts +96 -0
  234. package/src/target-ethers-sentio/view-function.cts +4 -11
  235. package/src/testing/test-processor-server.ts +1 -1
  236. package/src/testing/test-provider.ts +1 -1
  237. package/src/utils/index.ts +0 -1
  238. package/lib/eth/eth-event.js +0 -2
  239. package/lib/eth/eth-event.js.map +0 -1
  240. package/lib/utils/chain.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/solana/builtin/types.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,iHAAiH;AAEjH,OAAO,EACL,KAAK,EACL,IAAI,EAEJ,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,sBAAsB;AACtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CACvC,QAAQ,CAAC,MAAM,CAAC,EAChB,MAAM,EAAE,EACR,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CACnB,CAAC;AAWF,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE;IAChB,QAAQ,EAAE,MAAM,EAAE;IAClB,cAAc,EAAE,MAAM,EAAE;CACzB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,mBAAmB;IACzB,QAAQ,EAAE,MAAM,EAAE;IAClB,aAAa,EAAE,mBAAmB;IAClC,UAAU,EAAE,mBAAmB;IAC/B,eAAe,EAAE,QAAQ,CAAC,mBAAmB,CAAC;CAC/C,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,IAAI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AAa,EAAE,QAAQ,CAAC,mBAAmB,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;CAC9C,CAAC,CAAC;AAGH,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,mBAAmB;IAC1B,UAAU,EAAE,mBAAmB;IAC/B,aAAa,EAAE,mBAAmB;CACnC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-redeclare */\n// copy from https://github.com/solana-labs/solana/blob/master/explorer/src/components/instruction/token/types.ts\n\nimport {\n enums,\n type,\n Infer,\n number,\n string,\n optional,\n array,\n nullable,\n union,\n coerce,\n instance,\n} from \"superstruct\";\n\n// Replace with string\nexport const PublicKeyFromString = coerce(\n instance(String),\n string(),\n (value) => (value)\n);\n\nexport type TokenAmountUi = Infer<typeof TokenAmountUi>;\nexport type MintTo = Infer<typeof MintTo>;\nexport type Burn = Infer<typeof Burn>;\nexport type InitializeMint = Infer<typeof InitializeMint>;\nexport type InitializeAccount = Infer<typeof InitializeAccount>;\nexport type InitializeAccount2 = Infer<typeof InitializeAccount2>;\nexport type InitializeAccount3 = Infer<typeof InitializeAccount3>;\nexport type InitializeMultisig = Infer<typeof InitializeMultisig>;\n\nexport const TokenAmountUi = type({\n amount: string(),\n decimals: number(),\n uiAmountString: string(),\n});\n\nconst InitializeMint = type({\n mint: PublicKeyFromString,\n decimals: number(),\n mintAuthority: PublicKeyFromString,\n rentSysvar: PublicKeyFromString,\n freezeAuthority: optional(PublicKeyFromString),\n});\n\nconst InitializeAccount = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n owner: PublicKeyFromString,\n rentSysvar: PublicKeyFromString,\n});\n\nconst InitializeAccount2 = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n rentSysvar: PublicKeyFromString,\n owner: PublicKeyFromString,\n});\n\nconst InitializeAccount3 = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n owner: PublicKeyFromString,\n});\n\nconst InitializeMultisig = type({\n multisig: PublicKeyFromString,\n rentSysvar: PublicKeyFromString,\n signers: array(PublicKeyFromString),\n m: number(),\n});\n\nexport type Transfer = Infer<typeof Transfer>;\nexport const Transfer = type({\n source: PublicKeyFromString,\n destination: PublicKeyFromString,\n amount: union([string(), number()]),\n authority: optional(PublicKeyFromString),\n multisigAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nexport type Approve = Infer<typeof Approve>;\nconst Approve = type({\n source: PublicKeyFromString,\n delegate: PublicKeyFromString,\n amount: union([string(), number()]),\n owner: optional(PublicKeyFromString),\n multisigOwner: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nexport type Revoke = Infer<typeof Revoke>;\nconst Revoke = type({\n source: PublicKeyFromString,\n owner: optional(PublicKeyFromString),\n multisigOwner: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nconst AuthorityType = enums([\n \"mintTokens\",\n \"freezeAccount\",\n \"accountOwner\",\n \"closeAccount\",\n]);\n\nexport type SetAuthority = Infer<typeof SetAuthority>;\nconst SetAuthority = type({\n mint: optional(PublicKeyFromString),\n account: optional(PublicKeyFromString),\n authorityType: AuthorityType,\n newAuthority: nullable(PublicKeyFromString),\n authority: optional(PublicKeyFromString),\n multisigAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nconst MintTo = type({\n mint: PublicKeyFromString,\n account: PublicKeyFromString,\n amount: union([string(), number()]),\n mintAuthority: optional(PublicKeyFromString),\n multisigMintAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nconst Burn = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n amount: union([string(), number()]),\n authority: optional(PublicKeyFromString),\n multisigAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nconst CloseAccount = type({\n account: PublicKeyFromString,\n destination: PublicKeyFromString,\n owner: optional(PublicKeyFromString),\n multisigOwner: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\nexport type CloseAccount = Infer<typeof CloseAccount>;\n\nexport type FreezeAccount = Infer<typeof FreezeAccount>;\nconst FreezeAccount = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n freezeAuthority: optional(PublicKeyFromString),\n multisigFreezeAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nexport type ThawAccount = Infer<typeof ThawAccount>;\nconst ThawAccount = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n freezeAuthority: optional(PublicKeyFromString),\n multisigFreezeAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nexport type TransferChecked = Infer<typeof TransferChecked>;\nexport const TransferChecked = type({\n source: PublicKeyFromString,\n mint: PublicKeyFromString,\n destination: PublicKeyFromString,\n authority: optional(PublicKeyFromString),\n multisigAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n tokenAmount: TokenAmountUi,\n});\n\nexport type ApproveChecked = Infer<typeof ApproveChecked>;\nconst ApproveChecked = type({\n source: PublicKeyFromString,\n mint: PublicKeyFromString,\n delegate: PublicKeyFromString,\n owner: optional(PublicKeyFromString),\n multisigOwner: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n tokenAmount: TokenAmountUi,\n});\n\nexport type MintToChecked = Infer<typeof MintToChecked>;\nconst MintToChecked = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n mintAuthority: optional(PublicKeyFromString),\n multisigMintAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n tokenAmount: TokenAmountUi,\n});\n\nexport type BurnChecked = Infer<typeof BurnChecked>;\nconst BurnChecked = type({\n account: PublicKeyFromString,\n mint: PublicKeyFromString,\n authority: optional(PublicKeyFromString),\n multisigAuthority: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n tokenAmount: TokenAmountUi,\n});\n\nexport type SyncNative = Infer<typeof BurnChecked>;\nconst SyncNative = type({\n account: PublicKeyFromString,\n});\n\nexport type GetAccountDataSize = Infer<typeof GetAccountDataSize>;\nconst GetAccountDataSize = type({\n mint: PublicKeyFromString,\n extensionTypes: optional(array(string())),\n});\n\nexport type InitializeImmutableOwner = Infer<typeof InitializeImmutableOwner>;\nconst InitializeImmutableOwner = type({\n account: PublicKeyFromString,\n});\n\nexport type AmountToUiAmount = Infer<typeof AmountToUiAmount>;\nconst AmountToUiAmount = type({\n mint: PublicKeyFromString,\n amount: union([string(), number()]),\n});\n\nexport type UiAmountToAmount = Infer<typeof UiAmountToAmount>;\nconst UiAmountToAmount = type({\n mint: PublicKeyFromString,\n uiAmount: string(),\n});\n\nexport type InitializeMintCloseAuthority = Infer<typeof InitializeMintCloseAuthority>;\nconst InitializeMintCloseAuthority = type({\n mint: PublicKeyFromString,\n newAuthority: PublicKeyFromString,\n});\n\nexport type TransferFeeExtension = Infer<typeof TransferFeeExtension>;\nconst TransferFeeExtension = type({\n mint: PublicKeyFromString,\n transferFeeConfigAuthority: PublicKeyFromString,\n withdrawWitheldAuthority: PublicKeyFromString,\n transferFeeBasisPoints: number(),\n maximumFee: number(),\n});\n\nexport type DefaultAccountStateExtension = Infer<typeof DefaultAccountStateExtension>;\nconst DefaultAccountStateExtension = type({\n mint: PublicKeyFromString,\n accountState: string(),\n freezeAuthority: optional(PublicKeyFromString),\n});\n\nexport type Reallocate = Infer<typeof Reallocate>;\nconst Reallocate = type({\n account: PublicKeyFromString,\n payer: PublicKeyFromString,\n systemProgram: PublicKeyFromString,\n extensionTypes: array(string()),\n});\n\nexport type MemoTransferExtension = Infer<typeof MemoTransferExtension>;\nconst MemoTransferExtension = type({\n account: PublicKeyFromString,\n owner: optional(PublicKeyFromString),\n multisigOwner: optional(PublicKeyFromString),\n signers: optional(array(PublicKeyFromString)),\n});\n\nexport type CreateNativeMint = Infer<typeof CreateNativeMint>;\nconst CreateNativeMint = type({\n payer: PublicKeyFromString,\n nativeMint: PublicKeyFromString,\n systemProgram: PublicKeyFromString,\n});\n"]}
@@ -0,0 +1 @@
1
+ export declare function codeGenSolanaProcessor(abisDir: string, targetPath?: string): void;
@@ -0,0 +1,122 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import chalk from 'chalk';
4
+ export function codeGenSolanaProcessor(abisDir, targetPath = path.join('src', 'types', 'solana')) {
5
+ if (!fs.existsSync(abisDir)) {
6
+ return;
7
+ }
8
+ const abisFiles = fs.readdirSync(abisDir);
9
+ if (abisFiles.length > 0) {
10
+ console.log(chalk.green('Generated Types for Solana'));
11
+ }
12
+ for (const file of abisFiles) {
13
+ if (path.extname(file) === '.json') {
14
+ if (!fs.existsSync(targetPath)) {
15
+ fs.mkdirSync(targetPath, { recursive: true });
16
+ }
17
+ const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8');
18
+ const idlObj = JSON.parse(idlContent);
19
+ const idlName = idlObj.name;
20
+ const idlFile = path.join(targetPath, idlName + '.ts');
21
+ fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`);
22
+ fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj));
23
+ }
24
+ }
25
+ }
26
+ function codeGenSolanaIdlProcessor(idlObj) {
27
+ const idlName = idlObj.name;
28
+ const idlNamePascalCase = toPascalCase(idlName);
29
+ const instructions = idlObj.instructions;
30
+ return `import { BorshInstructionCoder, Instruction, Idl } from '@project-serum/anchor'
31
+ import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk/solana"
32
+ import { ${idlName}_idl } from "./${idlName}.js"
33
+ import { PublicKey } from '@solana/web3.js'
34
+
35
+ export class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {
36
+ static DEFAULT_OPTIONS = {
37
+ name: '${idlNamePascalCase}',
38
+ instructionCoder: new BorshInstructionCoder(${idlName}_idl as Idl)
39
+ }
40
+
41
+ static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {
42
+ return new ${idlNamePascalCase}Processor( { ...${idlNamePascalCase}Processor.DEFAULT_OPTIONS, ...options })
43
+ }
44
+
45
+ ${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}
46
+ }
47
+ `;
48
+ }
49
+ function codeGenSolanaInstruction(idlName, ins) {
50
+ const instructionName = ins.name;
51
+ const argsType = codeGenInstructionArgsType(ins.args);
52
+ const accountType = codeGenAccountType(ins.accounts);
53
+ return `
54
+ on${instructionName.charAt(0).toUpperCase() + instructionName.slice(1)}(handler: (args: ${argsType}, accounts: ${accountType}, ctx: SolanaContext) => void): ${idlName}Processor {
55
+ this.onInstruction('${instructionName}', (ins: Instruction, ctx, accounts: string[]) => {
56
+ const origin = ins.data as any
57
+ if (origin) {
58
+ const data = ${codeGenInstructionArgs(ins.args)}
59
+ const accountData = ${codeGenAccountTypeArgs(ins.accounts)}
60
+ handler(data, accountData, ctx)
61
+ }
62
+ })
63
+ return this
64
+ }
65
+ `;
66
+ }
67
+ function codeGenInstructionArgs(args) {
68
+ return `{ ${args.map((arg) => codeGenInstructionArg(arg.name, arg.type)).join(', ')} }`;
69
+ }
70
+ function codeGenInstructionArg(name, type) {
71
+ const mType = mapType(type);
72
+ if (mType === 'bigint') {
73
+ return `${name}: BigInt(origin.${name}.toString())`;
74
+ }
75
+ return `${name}: origin.${name} as ${mType}`;
76
+ }
77
+ function codeGenInstructionArgsType(args) {
78
+ return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`;
79
+ }
80
+ function codeGenAccountType(args) {
81
+ return `{ ${args.map((arg) => arg.name + ': string').join(', ')} }`;
82
+ }
83
+ function codeGenAccountTypeArgs(args) {
84
+ return `{ ${args.map((arg, idx) => `${arg.name}: accounts[${idx}]`).join(', ')} }`;
85
+ }
86
+ // Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104
87
+ function mapType(tpe) {
88
+ // TODO handle complex type
89
+ switch (tpe) {
90
+ case 'publicKey':
91
+ return 'PublicKey';
92
+ case 'bool':
93
+ return 'boolean';
94
+ case 'string':
95
+ return 'string';
96
+ case 'u8':
97
+ case 'i8':
98
+ case 'u16':
99
+ case 'i16':
100
+ case 'u32':
101
+ case 'i32':
102
+ case 'f32':
103
+ case 'f64':
104
+ return 'number';
105
+ case 'u64':
106
+ case 'i64':
107
+ case 'u128':
108
+ case 'i128':
109
+ return 'bigint';
110
+ default:
111
+ return 'any';
112
+ }
113
+ }
114
+ function toPascalCase(str) {
115
+ return `${str}`
116
+ .toLowerCase()
117
+ .replace(new RegExp(/[-_]+/, 'g'), ' ')
118
+ .replace(new RegExp(/[^\w\s]/, 'g'), '')
119
+ .replace(new RegExp(/\s+(.)(\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)
120
+ .replace(new RegExp(/\w/), (s) => s.toUpperCase());
121
+ }
122
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/solana/codegen/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,UAAU,sBAAsB,CAAC,OAAe,EAAE,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC;IACtG,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAM;KACP;IAED,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;IAEzC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAA;KACvD;IA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CAAC,EAAE,GAAG,CAAC;SACtC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;SACvC,OAAO,CAAC,IAAI,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE,CAAC;SACnF,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;AACtD,CAAC","sourcesContent":["import path from 'path'\nimport fs from 'fs'\nimport chalk from 'chalk'\nimport { Idl } from '@project-serum/anchor'\nimport { IdlAccountItem, IdlField, IdlInstruction, IdlType } from '@project-serum/anchor/dist/cjs/idl.js'\n\nexport function codeGenSolanaProcessor(abisDir: string, targetPath = path.join('src', 'types', 'solana')) {\n if (!fs.existsSync(abisDir)) {\n return\n }\n\n const abisFiles = fs.readdirSync(abisDir)\n\n if (abisFiles.length > 0) {\n console.log(chalk.green('Generated Types for Solana'))\n }\n\n for (const file of abisFiles) {\n if (path.extname(file) === '.json') {\n if (!fs.existsSync(targetPath)) {\n fs.mkdirSync(targetPath, { recursive: true })\n }\n const idlContent = fs.readFileSync(path.join(abisDir, file), 'utf-8')\n const idlObj = JSON.parse(idlContent)\n const idlName = idlObj.name\n const idlFile = path.join(targetPath, idlName + '.ts')\n fs.writeFileSync(idlFile, `export const ${idlName}_idl = ${idlContent}`)\n fs.writeFileSync(path.join(targetPath, `${idlName}_processor.ts`), codeGenSolanaIdlProcessor(idlObj))\n }\n }\n}\n\nfunction codeGenSolanaIdlProcessor(idlObj: Idl): string {\n const idlName = idlObj.name\n const idlNamePascalCase = toPascalCase(idlName)\n const instructions: any[] = idlObj.instructions\n return `import { BorshInstructionCoder, Instruction, Idl } from '@project-serum/anchor'\nimport { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from \"@sentio/sdk/solana\"\nimport { ${idlName}_idl } from \"./${idlName}.js\"\nimport { PublicKey } from '@solana/web3.js'\n\nexport class ${idlNamePascalCase}Processor extends SolanaBaseProcessor {\n static DEFAULT_OPTIONS = {\n name: '${idlNamePascalCase}',\n instructionCoder: new BorshInstructionCoder(${idlName}_idl as Idl)\n }\n\n static bind(options: SolanaBindOptions): ${idlNamePascalCase}Processor {\n return new ${idlNamePascalCase}Processor( { ...${idlNamePascalCase}Processor.DEFAULT_OPTIONS, ...options })\n }\n\n ${instructions.map((ins) => codeGenSolanaInstruction(idlNamePascalCase, ins)).join('')}\n}\n `\n}\n\nfunction codeGenSolanaInstruction(idlName: string, ins: IdlInstruction): string {\n const instructionName = ins.name\n\n const argsType = codeGenInstructionArgsType(ins.args)\n const accountType = codeGenAccountType(ins.accounts)\n\n return `\n on${\n instructionName.charAt(0).toUpperCase() + instructionName.slice(1)\n }(handler: (args: ${argsType}, accounts: ${accountType}, ctx: SolanaContext) => void): ${idlName}Processor {\n this.onInstruction('${instructionName}', (ins: Instruction, ctx, accounts: string[]) => {\n const origin = ins.data as any\n if (origin) {\n const data = ${codeGenInstructionArgs(ins.args)}\n const accountData = ${codeGenAccountTypeArgs(ins.accounts)}\n handler(data, accountData, ctx)\n }\n })\n return this\n }\n `\n}\n\nfunction codeGenInstructionArgs(args: IdlField[]): string {\n return `{ ${args.map((arg) => codeGenInstructionArg(arg.name, arg.type)).join(', ')} }`\n}\n\nfunction codeGenInstructionArg(name: string, type: IdlType): string {\n const mType = mapType(type)\n if (mType === 'bigint') {\n return `${name}: BigInt(origin.${name}.toString())`\n }\n return `${name}: origin.${name} as ${mType}`\n}\n\nfunction codeGenInstructionArgsType(args: IdlField[]): string {\n return `{ ${args.map((arg) => arg.name + ': ' + mapType(arg.type)).join(', ')} }`\n}\n\nfunction codeGenAccountType(args: IdlAccountItem[]): string {\n return `{ ${args.map((arg) => arg.name + ': string').join(', ')} }`\n}\n\nfunction codeGenAccountTypeArgs(args: IdlAccountItem[]): string {\n return `{ ${args.map((arg, idx) => `${arg.name}: accounts[${idx}]`).join(', ')} }`\n}\n\n// Reference: https://github.com/coral-xyz/anchor/blob/93332766f13e86efbe77c9986722731742317ede/ts/src/program/namespace/types.ts#L104\nfunction mapType(tpe: IdlType): string {\n // TODO handle complex type\n switch (tpe) {\n case 'publicKey':\n return 'PublicKey'\n case 'bool':\n return 'boolean'\n case 'string':\n return 'string'\n case 'u8':\n case 'i8':\n case 'u16':\n case 'i16':\n case 'u32':\n case 'i32':\n case 'f32':\n case 'f64':\n return 'number'\n case 'u64':\n case 'i64':\n case 'u128':\n case 'i128':\n return 'bigint'\n default:\n return 'any'\n }\n}\n\nfunction toPascalCase(str: string) {\n return `${str}`\n .toLowerCase()\n .replace(new RegExp(/[-_]+/, 'g'), ' ')\n .replace(new RegExp(/[^\\w\\s]/, 'g'), '')\n .replace(new RegExp(/\\s+(.)(\\w*)/, 'g'), ($1, $2, $3) => `${$2.toUpperCase() + $3}`)\n .replace(new RegExp(/\\w/), (s) => s.toUpperCase())\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from './codegen.js';
@@ -0,0 +1,2 @@
1
+ export * from './codegen.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/solana/codegen/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA","sourcesContent":["export * from './codegen.js'\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './solana-plugin.js';
2
+ export * from './solana-context.js';
3
+ export * from './solana-processor.js';
4
+ export * from './solana-options.js';
@@ -0,0 +1,5 @@
1
+ export * from './solana-plugin.js';
2
+ export * from './solana-context.js';
3
+ export * from './solana-processor.js';
4
+ export * from './solana-options.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/solana/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './solana-plugin.js'\nexport * from './solana-context.js'\nexport * from './solana-processor.js'\nexport * from './solana-options.js'\n"]}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { codeGenSolanaProcessor } from './codegen/codegen.js';
3
+ if (process.argv.length > 3) {
4
+ const abisDir = process.argv[2];
5
+ const targetDir = process.argv[3];
6
+ codeGenSolanaProcessor(abisDir, targetDir);
7
+ }
8
+ else {
9
+ console.error('Not enough argument');
10
+ process.exit(1);
11
+ }
12
+ //# sourceMappingURL=run-codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-codegen.js","sourceRoot":"","sources":["../../src/solana/run-codegen.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;IAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,sBAAsB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;CAC3C;KAAM;IACL,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;CAChB","sourcesContent":["#!/usr/bin/env node\n\nimport path from 'path'\nimport { codeGenSolanaProcessor } from './codegen/codegen.js'\n\nif (process.argv.length > 3) {\n const abisDir = process.argv[2]\n const targetDir = process.argv[3]\n codeGenSolanaProcessor(abisDir, targetDir)\n} else {\n console.error('Not enough argument')\n process.exit(1)\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Labels, BaseContext, RecordMetaData } from '@sentio/sdk';
2
+ export declare class SolanaContext extends BaseContext {
3
+ network: string;
4
+ address: string;
5
+ programName: string;
6
+ blockNumber: bigint;
7
+ constructor(programName: string, network: string, address: string, slot: bigint);
8
+ getMetaData(name: string, labels: Labels): RecordMetaData;
9
+ }
@@ -0,0 +1,28 @@
1
+ import { normalizeLabels, BaseContext, CHAIN_IDS } from '@sentio/sdk';
2
+ export class SolanaContext extends BaseContext {
3
+ network;
4
+ address;
5
+ programName;
6
+ blockNumber;
7
+ constructor(programName, network, address, slot) {
8
+ super();
9
+ this.network = network || CHAIN_IDS.SOLANA_MAINNET;
10
+ this.programName = programName;
11
+ this.address = address;
12
+ this.blockNumber = slot;
13
+ }
14
+ getMetaData(name, labels) {
15
+ return {
16
+ address: this.address,
17
+ contractName: this.programName,
18
+ blockNumber: this.blockNumber,
19
+ transactionIndex: 0,
20
+ transactionHash: '',
21
+ logIndex: 0,
22
+ chainId: this.network,
23
+ name: name,
24
+ labels: normalizeLabels(labels),
25
+ };
26
+ }
27
+ }
28
+ //# sourceMappingURL=solana-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-context.js","sourceRoot":"","sources":["../../src/solana/solana-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,WAAW,EAAkB,SAAS,EAAE,MAAM,aAAa,CAAA;AAE7F,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,OAAO,CAAQ;IACf,OAAO,CAAQ;IACf,WAAW,CAAQ;IACnB,WAAW,CAAQ;IAEnB,YAAY,WAAmB,EAAE,OAAe,EAAE,OAAe,EAAE,IAAY;QAC7E,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,SAAS,CAAC,cAAc,CAAA;QAClD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,IAAI,CAAC,WAAW;YAC9B,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { normalizeLabels, Labels, BaseContext, RecordMetaData, CHAIN_IDS } from '@sentio/sdk'\n\nexport class SolanaContext extends BaseContext {\n network: string\n address: string\n programName: string\n blockNumber: bigint\n\n constructor(programName: string, network: string, address: string, slot: bigint) {\n super()\n this.network = network || CHAIN_IDS.SOLANA_MAINNET\n this.programName = programName\n this.address = address\n this.blockNumber = slot\n }\n\n getMetaData(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.programName,\n blockNumber: this.blockNumber,\n transactionIndex: 0,\n transactionHash: '', // TODO add\n logIndex: 0,\n chainId: this.network,\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { InstructionCoder } from './solana-processor.js';
2
+ export declare class SolanaBindOptions {
3
+ address: string;
4
+ network?: string;
5
+ name?: string;
6
+ startBlock?: bigint | number;
7
+ endBlock?: bigint | number;
8
+ processInnerInstruction?: boolean;
9
+ instructionCoder?: InstructionCoder;
10
+ }
@@ -0,0 +1,10 @@
1
+ export class SolanaBindOptions {
2
+ address;
3
+ network;
4
+ name;
5
+ startBlock;
6
+ endBlock;
7
+ processInnerInstruction;
8
+ instructionCoder;
9
+ }
10
+ //# sourceMappingURL=solana-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-options.js","sourceRoot":"","sources":["../../src/solana/solana-options.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,iBAAiB;IAC5B,OAAO,CAAQ;IACf,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,UAAU,CAAkB;IAC5B,QAAQ,CAAkB;IAC1B,uBAAuB,CAAU;IACjC,gBAAgB,CAAmB;CACpC","sourcesContent":["import { InstructionCoder } from './solana-processor.js'\n\nexport class SolanaBindOptions {\n address: string\n network?: string\n name?: string\n startBlock?: bigint | number\n endBlock?: bigint | number\n processInnerInstruction?: boolean\n instructionCoder?: InstructionCoder\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Plugin } from '@sentio/runtime';
2
+ import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos';
3
+ export declare class SolanaPlugin extends Plugin {
4
+ name: string;
5
+ configure(config: ProcessConfigResponse): Promise<void>;
6
+ supportedHandlers: HandlerType[];
7
+ processBinding(request: DataBinding): Promise<ProcessResult>;
8
+ processSolInstruction(request: DataBinding): Promise<ProcessResult>;
9
+ }
@@ -0,0 +1,87 @@
1
+ import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime';
2
+ import { HandlerType } from '@sentio/protos';
3
+ import { ServerError, Status } from 'nice-grpc';
4
+ import { SolanaProcessorState } from './solana-processor.js';
5
+ export class SolanaPlugin extends Plugin {
6
+ name = 'SolanaPlugin';
7
+ async configure(config) {
8
+ // Part 2, prepare solana constractors
9
+ for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {
10
+ const contractConfig = {
11
+ transactionConfig: [],
12
+ processorType: USER_PROCESSOR,
13
+ contract: {
14
+ name: solanaProcessor.contractName,
15
+ chainId: solanaProcessor.network,
16
+ address: solanaProcessor.address,
17
+ abi: '',
18
+ },
19
+ logConfigs: [],
20
+ traceConfigs: [],
21
+ intervalConfigs: [],
22
+ startBlock: solanaProcessor.config.startSlot,
23
+ endBlock: 0n,
24
+ instructionConfig: {
25
+ innerInstruction: solanaProcessor.processInnerInstruction,
26
+ parsedInstruction: solanaProcessor.fromParsedInstruction !== null,
27
+ rawDataInstruction: solanaProcessor.decodeInstruction !== null,
28
+ },
29
+ aptosEventConfigs: [],
30
+ aptosCallConfigs: [],
31
+ };
32
+ config.contractConfigs.push(contractConfig);
33
+ }
34
+ }
35
+ supportedHandlers = [HandlerType.SOL_INSTRUCTION];
36
+ processBinding(request) {
37
+ switch (request.handlerType) {
38
+ case HandlerType.SOL_INSTRUCTION:
39
+ return this.processSolInstruction(request);
40
+ default:
41
+ throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
42
+ }
43
+ }
44
+ async processSolInstruction(request) {
45
+ if (!request.data) {
46
+ throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty');
47
+ }
48
+ if (!request.data.solInstruction) {
49
+ throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty');
50
+ }
51
+ const instruction = request.data.solInstruction;
52
+ const promises = [];
53
+ // Only have instruction handlers for solana processors
54
+ for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
55
+ if (processor.address === instruction.programAccountId) {
56
+ let parsedInstruction = null;
57
+ try {
58
+ if (instruction.parsed) {
59
+ parsedInstruction = processor.getParsedInstruction(instruction.parsed);
60
+ }
61
+ else if (instruction.instructionData) {
62
+ parsedInstruction = processor.getParsedInstruction(instruction.instructionData);
63
+ }
64
+ }
65
+ catch (e) {
66
+ throw new ServerError(Status.INTERNAL, 'Failed to decode instruction: ' + JSON.stringify(instruction) + errorString(e));
67
+ }
68
+ if (parsedInstruction == null) {
69
+ continue;
70
+ }
71
+ const insHandler = processor.getInstructionHandler(parsedInstruction);
72
+ if (insHandler == null) {
73
+ continue;
74
+ }
75
+ const res = processor
76
+ .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction.slot)
77
+ .catch((e) => {
78
+ throw new ServerError(Status.INTERNAL, 'Error processing instruction: ' + JSON.stringify(instruction) + '\n' + errorString(e));
79
+ });
80
+ promises.push(res);
81
+ }
82
+ }
83
+ return mergeProcessResults(await Promise.all(promises));
84
+ }
85
+ }
86
+ PluginManager.INSTANCE.register(new SolanaPlugin());
87
+ //# sourceMappingURL=solana-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-plugin.js","sourceRoot":"","sources":["../../src/solana/solana-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACzG,OAAO,EAA+B,WAAW,EAAwC,MAAM,gBAAgB,CAAA;AAE/G,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAG5D,MAAM,OAAO,YAAa,SAAQ,MAAM;IACtC,IAAI,GAAW,cAAc,CAAA;IAE7B,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,sCAAsC;QACtC,KAAK,MAAM,eAAe,IAAI,oBAAoB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;YACvE,MAAM,cAAc,GAAmB;gBACrC,iBAAiB,EAAE,EAAE;gBACrB,aAAa,EAAE,cAAc;gBAC7B,QAAQ,EAAE;oBACR,IAAI,EAAE,eAAe,CAAC,YAAY;oBAClC,OAAO,EAAE,eAAe,CAAC,OAAO;oBAChC,OAAO,EAAE,eAAe,CAAC,OAAO;oBAChC,GAAG,EAAE,EAAE;iBACR;gBACD,UAAU,EAAE,EAAE;gBACd,YAAY,EAAE,EAAE;gBAChB,eAAe,EAAE,EAAE;gBACnB,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,SAAS;gBAC5C,QAAQ,EAAE,EAAE;gBACZ,iBAAiB,EAAE;oBACjB,gBAAgB,EAAE,eAAe,CAAC,uBAAuB;oBACzD,iBAAiB,EAAE,eAAe,CAAC,qBAAqB,KAAK,IAAI;oBACjE,kBAAkB,EAAE,eAAe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CAAA;qBACtG;yBAAM,IAAI,WAAW,CAAC,eAAe,EAAE;wBACtC,iBAAiB,GAAG,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;qBAChF;iBACF;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,IAAI,WAAW,CACnB,MAAM,CAAC,QAAQ,EACf,gCAAgC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAChF,CAAA;iBACF;gBACD,IAAI,iBAAiB,IAAI,IAAI,EAAE;oBAC7B,SAAQ;iBACT;gBACD,MAAM,UAAU,GAAG,SAAS,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAA;gBACrE,IAAI,UAAU,IAAI,IAAI,EAAE;oBACtB,SAAQ;iBACT;gBACD,MAAM,GAAG,GAAG,SAAS;qBAClB,iBAAiB,CAAC,iBAAiB,EAAE,WAAW,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC;qBACxF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,MAAM,IAAI,WAAW,CACnB,MAAM,CAAC,QAAQ,EACf,gCAAgC,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CACvF,CAAA;gBACH,CAAC,CAAC,CAAA;gBAEJ,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;aACnB;SACF;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,YAAY,EAAE,CAAC,CAAA","sourcesContent":["import { errorString, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { SolanaProcessorState } from './solana-processor.js'\nimport { Instruction as SolInstruction } from '@project-serum/anchor'\n\nexport class SolanaPlugin extends Plugin {\n name: string = 'SolanaPlugin'\n\n async configure(config: ProcessConfigResponse) {\n // Part 2, prepare solana constractors\n for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n transactionConfig: [],\n processorType: USER_PROCESSOR,\n contract: {\n name: solanaProcessor.contractName,\n chainId: solanaProcessor.network,\n address: solanaProcessor.address,\n abi: '',\n },\n logConfigs: [],\n traceConfigs: [],\n intervalConfigs: [],\n startBlock: solanaProcessor.config.startSlot,\n endBlock: 0n,\n instructionConfig: {\n innerInstruction: solanaProcessor.processInnerInstruction,\n parsedInstruction: solanaProcessor.fromParsedInstruction !== null,\n rawDataInstruction: solanaProcessor.decodeInstruction !== null,\n },\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n config.contractConfigs.push(contractConfig)\n }\n }\n\n supportedHandlers = [HandlerType.SOL_INSTRUCTION]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SOL_INSTRUCTION:\n return this.processSolInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processSolInstruction(request: DataBinding): Promise<ProcessResult> {\n if (!request.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')\n }\n if (!request.data.solInstruction) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')\n }\n\n const instruction = request.data.solInstruction\n const promises: Promise<ProcessResult>[] = []\n\n // Only have instruction handlers for solana processors\n for (const processor of SolanaProcessorState.INSTANCE.getValues()) {\n if (processor.address === instruction.programAccountId) {\n let parsedInstruction: SolInstruction | null = null\n\n try {\n if (instruction.parsed) {\n parsedInstruction = processor.getParsedInstruction(instruction.parsed as { type: string; info: any })\n } else if (instruction.instructionData) {\n parsedInstruction = processor.getParsedInstruction(instruction.instructionData)\n }\n } catch (e) {\n throw new ServerError(\n Status.INTERNAL,\n 'Failed to decode instruction: ' + JSON.stringify(instruction) + errorString(e)\n )\n }\n if (parsedInstruction == null) {\n continue\n }\n const insHandler = processor.getInstructionHandler(parsedInstruction)\n if (insHandler == null) {\n continue\n }\n const res = processor\n .handleInstruction(parsedInstruction, instruction.accounts, insHandler, instruction.slot)\n .catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'Error processing instruction: ' + JSON.stringify(instruction) + '\\n' + errorString(e)\n )\n })\n\n promises.push(res)\n }\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n}\n\nPluginManager.INSTANCE.register(new SolanaPlugin())\n"]}
@@ -0,0 +1,43 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { ProcessResult } from '@sentio/protos';
3
+ import { SolanaContext } from './solana-context.js';
4
+ import { Instruction } from '@project-serum/anchor';
5
+ import { SolanaBindOptions } from './solana-options.js';
6
+ import { ListStateStorage } from '@sentio/runtime';
7
+ type IndexConfigure = {
8
+ startSlot: bigint;
9
+ endSlot?: bigint;
10
+ };
11
+ export interface InstructionCoder {
12
+ decode(ix: Buffer | string, encoding?: 'hex' | 'base58'): Instruction | null;
13
+ }
14
+ export type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void;
15
+ export declare class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {
16
+ static INSTANCE: SolanaProcessorState;
17
+ }
18
+ export declare class SolanaBaseProcessor {
19
+ instructionHandlerMap: Map<string, SolanaInstructionHandler>;
20
+ address: string;
21
+ endpoint: string;
22
+ contractName: string;
23
+ network: string;
24
+ processInnerInstruction: boolean;
25
+ config: IndexConfigure;
26
+ instructionCoder: InstructionCoder;
27
+ decodeInstruction(rawInstruction: string): Instruction | null;
28
+ fromParsedInstruction: (instruction: {
29
+ type: string;
30
+ info: any;
31
+ }) => Instruction | null;
32
+ constructor(options: SolanaBindOptions);
33
+ onInstruction(instructionName: string, handler: SolanaInstructionHandler): this;
34
+ getParsedInstruction(ins: string | {
35
+ type: string;
36
+ info: any;
37
+ }): Instruction | null;
38
+ getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined;
39
+ handleInstruction(parsedInstruction: Instruction, accounts: string[], handler: SolanaInstructionHandler, slot: bigint): Promise<ProcessResult>;
40
+ startSlot(startSlot: bigint | number): this;
41
+ endBlock(endBlock: bigint | number): this;
42
+ }
43
+ export {};
@@ -0,0 +1,72 @@
1
+ import { SolanaContext } from './solana-context.js';
2
+ import { ListStateStorage } from '@sentio/runtime';
3
+ import { CHAIN_IDS } from '@sentio/sdk';
4
+ export class SolanaProcessorState extends ListStateStorage {
5
+ static INSTANCE = new SolanaProcessorState();
6
+ }
7
+ export class SolanaBaseProcessor {
8
+ instructionHandlerMap = new Map();
9
+ address;
10
+ endpoint;
11
+ contractName;
12
+ network;
13
+ processInnerInstruction;
14
+ config = { startSlot: 0n };
15
+ instructionCoder;
16
+ decodeInstruction(rawInstruction) {
17
+ if (this.instructionCoder) {
18
+ return this.instructionCoder.decode(rawInstruction, 'base58');
19
+ }
20
+ return null;
21
+ }
22
+ fromParsedInstruction;
23
+ constructor(options) {
24
+ this.address = options.address;
25
+ this.contractName = options.name || '';
26
+ this.processInnerInstruction = options.processInnerInstruction || false;
27
+ this.network = options.network || CHAIN_IDS.SOLANA_MAINNET;
28
+ if (options.instructionCoder) {
29
+ this.instructionCoder = options.instructionCoder;
30
+ }
31
+ if (options.startBlock) {
32
+ this.startSlot(options.startBlock);
33
+ }
34
+ if (options.endBlock) {
35
+ this.endBlock(options.endBlock);
36
+ }
37
+ this.endpoint = options.network || 'https://api.mainnet-beta.solana.com';
38
+ SolanaProcessorState.INSTANCE.addValue(this);
39
+ }
40
+ onInstruction(instructionName, handler) {
41
+ this.instructionHandlerMap.set(instructionName, handler);
42
+ return this;
43
+ }
44
+ getParsedInstruction(ins) {
45
+ if (ins) {
46
+ if (ins.info) {
47
+ return this.fromParsedInstruction ? this.fromParsedInstruction(ins) : null;
48
+ }
49
+ if (this.decodeInstruction != null) {
50
+ return this.decodeInstruction(ins);
51
+ }
52
+ }
53
+ return null;
54
+ }
55
+ getInstructionHandler(parsedInstruction) {
56
+ return this.instructionHandlerMap.get(parsedInstruction.name);
57
+ }
58
+ async handleInstruction(parsedInstruction, accounts, handler, slot) {
59
+ const ctx = new SolanaContext(this.contractName, this.network, this.address, slot);
60
+ await handler(parsedInstruction, ctx, accounts);
61
+ return ctx.getProcessResult();
62
+ }
63
+ startSlot(startSlot) {
64
+ this.config.startSlot = BigInt(startSlot);
65
+ return this;
66
+ }
67
+ endBlock(endBlock) {
68
+ this.config.endSlot = BigInt(endBlock);
69
+ return this;
70
+ }
71
+ }
72
+ //# sourceMappingURL=solana-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/solana/solana-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAavC,MAAM,OAAO,oBAAqB,SAAQ,gBAAqC;IAC7E,MAAM,CAAC,QAAQ,GAAyB,IAAI,oBAAoB,EAAE,CAAA;;AAGpE,MAAM,OAAO,mBAAmB;IACvB,qBAAqB,GAA0C,IAAI,GAAG,EAAE,CAAA;IAC/E,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,YAAY,CAAQ;IACpB,OAAO,CAAQ;IACf,uBAAuB,CAAS;IAChC,MAAM,GAAmB,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;IAC1C,gBAAgB,CAAkB;IAElC,iBAAiB,CAAC,cAAsB;QACtC,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACzB,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,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CAAC,iBAAiB,IAAI,IAAI,EAAE;gBAClC,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAa,CAAC,CAAA;aAC7C;SACF;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,qBAAqB,CAAC,iBAA8B;QACzD,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAC5B,iBAA8B,EAC9B,QAAkB,EAClB,OAAiC,EACjC,IAAY;QAEZ,MAAM,GAAG,GAAG,IAAI,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAClF,MAAM,OAAO,CAAC,iBAAiB,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAA;QAC/C,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC/B,CAAC;IAEM,SAAS,CAAC,SAA0B;QACzC,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QACzC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAyB;QACvC,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { ProcessResult } from '@sentio/protos'\nimport { SolanaContext } from './solana-context.js'\nimport { Instruction } from '@project-serum/anchor'\nimport { SolanaBindOptions } from './solana-options.js'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { CHAIN_IDS } from '@sentio/sdk'\n\ntype IndexConfigure = {\n startSlot: bigint\n endSlot?: bigint\n}\n\nexport interface InstructionCoder {\n decode(ix: Buffer | string, encoding?: 'hex' | 'base58'): Instruction | null\n}\n\nexport type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void\n\nexport class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {\n static INSTANCE: SolanaProcessorState = new SolanaProcessorState()\n}\n\nexport class SolanaBaseProcessor {\n public instructionHandlerMap: Map<string, SolanaInstructionHandler> = new Map()\n address: string\n endpoint: string\n contractName: string\n network: string\n processInnerInstruction: boolean\n config: IndexConfigure = { startSlot: 0n }\n instructionCoder: InstructionCoder\n\n decodeInstruction(rawInstruction: string): Instruction | null {\n if (this.instructionCoder) {\n return this.instructionCoder.decode(rawInstruction, 'base58')\n }\n return null\n }\n\n fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null\n\n constructor(options: SolanaBindOptions) {\n this.address = options.address\n this.contractName = options.name || ''\n this.processInnerInstruction = options.processInnerInstruction || false\n this.network = options.network || CHAIN_IDS.SOLANA_MAINNET\n if (options.instructionCoder) {\n this.instructionCoder = options.instructionCoder\n }\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n this.endpoint = options.network || 'https://api.mainnet-beta.solana.com'\n\n SolanaProcessorState.INSTANCE.addValue(this)\n }\n\n public onInstruction(instructionName: string, handler: SolanaInstructionHandler) {\n this.instructionHandlerMap.set(instructionName, handler)\n return this\n }\n\n public getParsedInstruction(ins: string | { type: string; info: any }): Instruction | null {\n if (ins) {\n if ((ins as { type: string; info: any }).info) {\n return this.fromParsedInstruction ? this.fromParsedInstruction(ins as { type: string; info: any }) : null\n }\n if (this.decodeInstruction != null) {\n return this.decodeInstruction(ins as string)\n }\n }\n return null\n }\n\n public getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined {\n return this.instructionHandlerMap.get(parsedInstruction.name)\n }\n\n public async handleInstruction(\n parsedInstruction: Instruction,\n accounts: string[],\n handler: SolanaInstructionHandler,\n slot: bigint\n ): Promise<ProcessResult> {\n const ctx = new SolanaContext(this.contractName, this.network, this.address, slot)\n await handler(parsedInstruction, ctx, accounts)\n return ctx.getProcessResult()\n }\n\n public startSlot(startSlot: bigint | number) {\n this.config.startSlot = BigInt(startSlot)\n return this\n }\n\n public endBlock(endBlock: bigint | number) {\n this.config.endSlot = BigInt(endBlock)\n return this\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana.test.js","sourceRoot":"","sources":["../../../src/solana/tests/solana.test.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE5E,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,KAAK,IAAI,EAAE;QACjD,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC1C,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,YAAY,GAAG;YACnB;gBACE,eAAe,EAAE,6EAA6E;gBAC9F,IAAI,EAAE,MAAM;gBACZ,gBAAgB,EAAE,6CAA6C;gBAC/D,QAAQ,EAAE,CAAC,MAAM,CAAC;aACnB;YACD;gBACE,eAAe,EAAE,6EAA6E;gBAC9F,IAAI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6CAA6C;gBAC/D,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE,EAAE;aACb;SACF,CAAA;QACD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAA;QACxD,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACtC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC/D,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QAC7F,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;IACvF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["// TODO move out of this package\n\nimport { expect } from 'chai'\n\nimport { HandlerType } from '@sentio/sdk'\n\nimport { TestProcessorServer, firstCounterValue } from '@sentio/sdk/testing'\n\ndescribe('Test Solana Example', () => {\n const service = new TestProcessorServer(async () => {\n await import('./wormhole-token-bridge.js')\n })\n\n beforeAll(async () => {\n await service.start({ templateInstances: [] })\n })\n\n test('check configuration ', async () => {\n const config = await service.getConfig({})\n expect(config.contractConfigs).length(2)\n })\n\n test('Check wormhole token bridge instruction dispatch', async () => {\n const instructions = [\n {\n instructionData: '33G5T8yXAQWdH8FX7fTy1mBJ6e4dUKfQWbViSrT7qJjpS8UAA3ftEQx9sNzrkaJm56xtENhDsWf',\n slot: 12345n,\n programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',\n accounts: ['worm'],\n },\n {\n instructionData: '33G5T8yXAQWdH8FX7fTy1mBJ6e4dUKfQWbViSrT7qJjpS8UAA3ftEQx9sNzrkaJm56xtENhDsWf',\n slot: 1n,\n programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',\n accounts: ['worm'],\n },\n ]\n\n const res = await service.testInstructions(instructions)\n expect(res.result?.counters).length(4)\n expect(res.result?.gauges).length(0)\n expect(res.result?.counters[0].metadata?.blockNumber).equal(12345n)\n expect(firstCounterValue(res.result, 'total_transfer_amount')).equal(1000000n)\n expect(firstCounterValue(res.result, 'worm')).equal(1000000n)\n expect(res.result?.counters[0].runtimeInfo?.from).equals(HandlerType.SOL_INSTRUCTION)\n })\n\n test('Check SPLToken parsed instruction dispatch', async () => {\n const parsedIns = {\n info: {\n account: '2SDN4vEJdCdW3pGyhx2km9gB3LeHzMGLrG2j4uVNZfrx',\n amount: '12000000000000',\n mint: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs',\n mintAuthority: 'BCD75RNBHrJJpW4dXVagL5mPjzRLnVZq4YirJdjEYMV7',\n },\n type: 'mintTo',\n }\n const instructions = [\n {\n instructionData: '',\n slot: 0n,\n programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',\n parsed: parsedIns,\n accounts: [],\n },\n ]\n const res = await service.testInstructions(instructions)\n expect(res.result?.counters).length(1)\n expect(res.result?.gauges).length(0)\n expect(res.result?.counters[0].metadata?.blockNumber).equal(0n)\n expect(firstCounterValue(res.result, 'totalWeth_supply')?.toString()).equal('12000000000000')\n expect(res.result?.counters[0].runtimeInfo?.from).equals(HandlerType.SOL_INSTRUCTION)\n })\n})\n"]}
@@ -0,0 +1,26 @@
1
+ export declare const basic_1_idl: {
2
+ accounts: {
3
+ name: string;
4
+ type: {
5
+ kind: string;
6
+ fields: {
7
+ name: string;
8
+ type: string;
9
+ }[];
10
+ };
11
+ }[];
12
+ instructions: {
13
+ name: string;
14
+ accounts: {
15
+ name: string;
16
+ isMut: boolean;
17
+ isSigner: boolean;
18
+ }[];
19
+ args: {
20
+ name: string;
21
+ type: string;
22
+ }[];
23
+ }[];
24
+ name: string;
25
+ version: string;
26
+ };