@sentio/sdk 1.0.0-development → 1.0.0-rc.2

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 (609) hide show
  1. package/LICENSE +55 -0
  2. package/lib/aptos/api.d.ts +2 -0
  3. package/lib/aptos/api.js +14 -0
  4. package/lib/aptos/api.js.map +1 -0
  5. package/lib/aptos/aptos-plugin.d.ts +14 -0
  6. package/lib/aptos/aptos-plugin.js +190 -0
  7. package/lib/aptos/aptos-plugin.js.map +1 -0
  8. package/lib/aptos/aptos-processor.d.ts +75 -0
  9. package/lib/aptos/aptos-processor.js +193 -0
  10. package/lib/aptos/aptos-processor.js.map +1 -0
  11. package/lib/aptos/context.d.ts +22 -0
  12. package/lib/aptos/context.js +69 -0
  13. package/lib/aptos/context.js.map +1 -0
  14. package/lib/aptos/index.d.ts +9 -0
  15. package/lib/aptos/index.js +34 -0
  16. package/lib/aptos/index.js.map +1 -0
  17. package/lib/aptos/models.d.ts +23 -0
  18. package/lib/aptos/models.js +3 -0
  19. package/lib/aptos/models.js.map +1 -0
  20. package/lib/aptos/network.d.ts +14 -0
  21. package/lib/aptos/network.js +46 -0
  22. package/lib/aptos/network.js.map +1 -0
  23. package/lib/aptos/runtime.d.ts +2 -0
  24. package/lib/aptos/runtime.js +16 -0
  25. package/lib/aptos/runtime.js.map +1 -0
  26. package/lib/aptos/type-registry.d.ts +21 -0
  27. package/lib/aptos/type-registry.js +156 -0
  28. package/lib/aptos/type-registry.js.map +1 -0
  29. package/lib/aptos/types.d.ts +9 -0
  30. package/lib/aptos/types.js +135 -0
  31. package/lib/aptos/types.js.map +1 -0
  32. package/{dist/numberish.test.d.ts → lib/aptos/types.test.d.ts} +0 -0
  33. package/lib/aptos/types.test.js.map +1 -0
  34. package/lib/aptos/utils.d.ts +7 -0
  35. package/lib/aptos/utils.js +27 -0
  36. package/lib/aptos/utils.js.map +1 -0
  37. package/lib/aptos-codegen/codegen.d.ts +23 -0
  38. package/lib/aptos-codegen/codegen.js +364 -0
  39. package/lib/aptos-codegen/codegen.js.map +1 -0
  40. package/lib/aptos-codegen/typegen.d.ts +17 -0
  41. package/lib/aptos-codegen/typegen.js +142 -0
  42. package/lib/aptos-codegen/typegen.js.map +1 -0
  43. package/lib/binds.d.ts +12 -0
  44. package/lib/binds.js +38 -0
  45. package/lib/binds.js.map +1 -0
  46. package/lib/builtin/aptos/0x1.d.ts +1913 -0
  47. package/lib/builtin/aptos/0x1.js +2748 -0
  48. package/lib/builtin/aptos/0x1.js.map +1 -0
  49. package/lib/builtin/aptos/0x3.d.ts +482 -0
  50. package/lib/builtin/aptos/0x3.js +526 -0
  51. package/lib/builtin/aptos/0x3.js.map +1 -0
  52. package/lib/builtin/aptos/index.d.ts +2 -0
  53. package/{dist/builtin/internal → lib/builtin/aptos}/index.js +3 -4
  54. package/lib/builtin/aptos/index.js.map +1 -0
  55. package/lib/builtin/eacaggregatorproxy/index.d.ts +2 -0
  56. package/lib/builtin/eacaggregatorproxy/index.js +22 -0
  57. package/lib/builtin/eacaggregatorproxy/index.js.map +1 -0
  58. package/lib/builtin/eacaggregatorproxy/test-utils.d.ts +6 -0
  59. package/lib/builtin/eacaggregatorproxy/test-utils.js +57 -0
  60. package/lib/builtin/eacaggregatorproxy/test-utils.js.map +1 -0
  61. package/lib/builtin/erc1155/index.d.ts +2 -0
  62. package/lib/builtin/erc1155/index.js +22 -0
  63. package/lib/builtin/erc1155/index.js.map +1 -0
  64. package/lib/builtin/erc1155/test-utils.d.ts +6 -0
  65. package/lib/builtin/erc1155/test-utils.js +57 -0
  66. package/lib/builtin/erc1155/test-utils.js.map +1 -0
  67. package/{dist → lib}/builtin/erc20/index.d.ts +1 -1
  68. package/{dist → lib}/builtin/erc20/index.js +1 -1
  69. package/lib/builtin/erc20/index.js.map +1 -0
  70. package/lib/builtin/erc20/test-utils.d.ts +5 -0
  71. package/lib/builtin/erc20/test-utils.js +46 -0
  72. package/lib/builtin/erc20/test-utils.js.map +1 -0
  73. package/lib/builtin/erc20bytes/index.d.ts +2 -0
  74. package/lib/builtin/erc20bytes/index.js +22 -0
  75. package/lib/builtin/erc20bytes/index.js.map +1 -0
  76. package/lib/builtin/erc20bytes/test-utils.d.ts +4 -0
  77. package/lib/builtin/erc20bytes/test-utils.js +35 -0
  78. package/lib/builtin/erc20bytes/test-utils.js.map +1 -0
  79. package/lib/builtin/erc721/index.d.ts +2 -0
  80. package/lib/builtin/erc721/index.js +22 -0
  81. package/lib/builtin/erc721/index.js.map +1 -0
  82. package/lib/builtin/erc721/test-utils.d.ts +5 -0
  83. package/lib/builtin/erc721/test-utils.js +46 -0
  84. package/lib/builtin/erc721/test-utils.js.map +1 -0
  85. package/lib/builtin/index.d.ts +6 -0
  86. package/lib/builtin/index.js +33 -0
  87. package/lib/builtin/index.js.map +1 -0
  88. package/lib/builtin/internal/EACAggregatorProxy.d.ts +460 -0
  89. package/lib/builtin/internal/EACAggregatorProxy.js +3 -0
  90. package/lib/builtin/internal/EACAggregatorProxy.js.map +1 -0
  91. package/lib/builtin/internal/ERC1155.d.ts +199 -0
  92. package/lib/builtin/internal/ERC1155.js +3 -0
  93. package/lib/builtin/internal/ERC1155.js.map +1 -0
  94. package/lib/builtin/internal/ERC20.d.ts +307 -0
  95. package/{dist/builtin/internal/Erc20.js → lib/builtin/internal/ERC20.js} +1 -1
  96. package/lib/builtin/internal/ERC20.js.map +1 -0
  97. package/{dist/builtin/internal/Erc20.d.ts → lib/builtin/internal/ERC20Bytes.d.ts} +62 -46
  98. package/lib/builtin/internal/ERC20Bytes.js +3 -0
  99. package/lib/builtin/internal/ERC20Bytes.js.map +1 -0
  100. package/lib/builtin/internal/ERC721.d.ts +252 -0
  101. package/lib/builtin/internal/ERC721.js +3 -0
  102. package/lib/builtin/internal/ERC721.js.map +1 -0
  103. package/lib/builtin/internal/WETH9.d.ts +221 -0
  104. package/lib/builtin/internal/WETH9.js +3 -0
  105. package/lib/builtin/internal/WETH9.js.map +1 -0
  106. package/{dist → lib}/builtin/internal/common.d.ts +0 -0
  107. package/{dist → lib}/builtin/internal/common.js +0 -0
  108. package/lib/builtin/internal/common.js.map +1 -0
  109. package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +294 -0
  110. package/lib/builtin/internal/eacaggregatorproxy_processor.js +761 -0
  111. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -0
  112. package/lib/builtin/internal/erc1155_processor.d.ts +126 -0
  113. package/lib/builtin/internal/erc1155_processor.js +313 -0
  114. package/lib/builtin/internal/erc1155_processor.js.map +1 -0
  115. package/lib/builtin/internal/erc20_processor.d.ts +166 -0
  116. package/lib/builtin/internal/erc20_processor.js +418 -0
  117. package/lib/builtin/internal/erc20_processor.js.map +1 -0
  118. package/lib/builtin/internal/erc20bytes_processor.d.ts +101 -0
  119. package/lib/builtin/internal/erc20bytes_processor.js +311 -0
  120. package/lib/builtin/internal/erc20bytes_processor.js.map +1 -0
  121. package/lib/builtin/internal/erc721_processor.d.ts +155 -0
  122. package/lib/builtin/internal/erc721_processor.js +437 -0
  123. package/lib/builtin/internal/erc721_processor.js.map +1 -0
  124. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +46 -0
  125. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +528 -0
  126. package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -0
  127. package/{dist/builtin/internal/factories/Erc20__factory.d.ts → lib/builtin/internal/factories/ERC1155__factory.d.ts} +4 -4
  128. package/lib/builtin/internal/factories/ERC1155__factory.js +333 -0
  129. package/lib/builtin/internal/factories/ERC1155__factory.js.map +1 -0
  130. package/lib/builtin/internal/factories/ERC20Bytes__factory.d.ts +48 -0
  131. package/{dist/builtin/internal/factories/Erc20__factory.js → lib/builtin/internal/factories/ERC20Bytes__factory.js} +128 -89
  132. package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -0
  133. package/lib/builtin/internal/factories/ERC20__factory.d.ts +42 -0
  134. package/lib/builtin/internal/factories/ERC20__factory.js +405 -0
  135. package/lib/builtin/internal/factories/ERC20__factory.js.map +1 -0
  136. package/lib/builtin/internal/factories/ERC721__factory.d.ts +51 -0
  137. package/lib/builtin/internal/factories/ERC721__factory.js +365 -0
  138. package/lib/builtin/internal/factories/ERC721__factory.js.map +1 -0
  139. package/lib/builtin/internal/factories/WETH9__factory.d.ts +45 -0
  140. package/lib/builtin/internal/factories/WETH9__factory.js +298 -0
  141. package/lib/builtin/internal/factories/WETH9__factory.js.map +1 -0
  142. package/lib/builtin/internal/factories/index.d.ts +6 -0
  143. package/lib/builtin/internal/factories/index.js +19 -0
  144. package/lib/builtin/internal/factories/index.js.map +1 -0
  145. package/lib/builtin/internal/index.d.ts +13 -0
  146. package/lib/builtin/internal/index.js +40 -0
  147. package/lib/builtin/internal/index.js.map +1 -0
  148. package/lib/builtin/internal/weth9_processor.d.ts +115 -0
  149. package/lib/builtin/internal/weth9_processor.js +353 -0
  150. package/lib/builtin/internal/weth9_processor.js.map +1 -0
  151. package/lib/builtin/solana/index.d.ts +2 -0
  152. package/lib/builtin/solana/index.js +19 -0
  153. package/lib/builtin/solana/index.js.map +1 -0
  154. package/lib/builtin/solana/spl-token-processor.d.ts +39 -0
  155. package/lib/builtin/solana/spl-token-processor.js +258 -0
  156. package/lib/builtin/solana/spl-token-processor.js.map +1 -0
  157. package/lib/builtin/solana/types.d.ts +427 -0
  158. package/lib/builtin/solana/types.js +203 -0
  159. package/lib/builtin/solana/types.js.map +1 -0
  160. package/lib/builtin/solana/wormhole-processor.d.ts +16 -0
  161. package/{dist/test-case/types/wormhole_processor.js → lib/builtin/solana/wormhole-processor.js} +57 -54
  162. package/lib/builtin/solana/wormhole-processor.js.map +1 -0
  163. package/lib/builtin/weth9/index.d.ts +2 -0
  164. package/lib/builtin/weth9/index.js +22 -0
  165. package/lib/builtin/weth9/index.js.map +1 -0
  166. package/lib/builtin/weth9/test-utils.d.ts +6 -0
  167. package/lib/builtin/weth9/test-utils.js +57 -0
  168. package/lib/builtin/weth9/test-utils.js.map +1 -0
  169. package/lib/chain-config.d.ts +6 -0
  170. package/lib/chain-config.js +3 -0
  171. package/lib/chain-config.js.map +1 -0
  172. package/lib/core/account-processor.d.ts +58 -0
  173. package/lib/core/account-processor.js +147 -0
  174. package/lib/core/account-processor.js.map +1 -0
  175. package/lib/core/base-context.d.ts +12 -0
  176. package/lib/core/base-context.js +25 -0
  177. package/lib/core/base-context.js.map +1 -0
  178. package/lib/core/base-processor-template.d.ts +42 -0
  179. package/{dist → lib/core}/base-processor-template.js +32 -6
  180. package/lib/core/base-processor-template.js.map +1 -0
  181. package/lib/core/base-processor.d.ts +39 -0
  182. package/lib/core/base-processor.js +153 -0
  183. package/lib/core/base-processor.js.map +1 -0
  184. package/lib/core/big-decimal.d.ts +1 -0
  185. package/lib/core/big-decimal.js +6 -0
  186. package/lib/core/big-decimal.js.map +1 -0
  187. package/{dist → lib/core}/bind-options.d.ts +5 -0
  188. package/{dist → lib/core}/bind-options.js +10 -1
  189. package/lib/core/bind-options.js.map +1 -0
  190. package/lib/core/context.d.ts +55 -0
  191. package/lib/core/context.js +162 -0
  192. package/lib/core/context.js.map +1 -0
  193. package/lib/core/eth-plugin.d.ts +14 -0
  194. package/lib/core/eth-plugin.js +221 -0
  195. package/lib/core/eth-plugin.js.map +1 -0
  196. package/lib/core/event-tracker.d.ts +26 -0
  197. package/lib/core/event-tracker.js +54 -0
  198. package/lib/core/event-tracker.js.map +1 -0
  199. package/lib/core/exporter.d.ts +13 -0
  200. package/lib/core/exporter.js +30 -0
  201. package/lib/core/exporter.js.map +1 -0
  202. package/lib/core/generic-processor.d.ts +10 -0
  203. package/lib/core/generic-processor.js +32 -0
  204. package/lib/core/generic-processor.js.map +1 -0
  205. package/{dist/test-case/erc20-template.test.d.ts → lib/core/generic-processor.test.d.ts} +0 -0
  206. package/lib/core/generic-processor.test.js.map +1 -0
  207. package/lib/core/index.d.ts +17 -0
  208. package/lib/core/index.js +46 -0
  209. package/lib/core/index.js.map +1 -0
  210. package/lib/core/logger.d.ts +14 -0
  211. package/lib/core/logger.js +42 -0
  212. package/lib/core/logger.js.map +1 -0
  213. package/lib/core/metadata.d.ts +7 -0
  214. package/lib/core/metadata.js +12 -0
  215. package/lib/core/metadata.js.map +1 -0
  216. package/lib/core/meter.d.ts +59 -0
  217. package/lib/core/meter.js +166 -0
  218. package/lib/core/meter.js.map +1 -0
  219. package/{dist/test-case/erc20.test.d.ts → lib/core/meter.test.d.ts} +0 -0
  220. package/lib/core/meter.test.js.map +1 -0
  221. package/lib/core/numberish.d.ts +8 -0
  222. package/lib/core/numberish.js +115 -0
  223. package/lib/core/numberish.js.map +1 -0
  224. package/{dist/test-case/mirrorworld.d.ts → lib/core/numberish.test.d.ts} +0 -0
  225. package/lib/core/numberish.test.js.map +1 -0
  226. package/lib/core/solana-context.d.ts +12 -0
  227. package/lib/core/solana-context.js +34 -0
  228. package/lib/core/solana-context.js.map +1 -0
  229. package/lib/core/solana-options.d.ts +9 -0
  230. package/lib/core/solana-options.js +13 -0
  231. package/lib/core/solana-options.js.map +1 -0
  232. package/lib/core/solana-plugin.d.ts +9 -0
  233. package/lib/core/solana-plugin.js +79 -0
  234. package/lib/core/solana-plugin.js.map +1 -0
  235. package/lib/core/solana-processor.d.ts +41 -0
  236. package/lib/core/solana-processor.js +90 -0
  237. package/lib/core/solana-processor.js.map +1 -0
  238. package/lib/core/sui-plugin.d.ts +8 -0
  239. package/lib/core/sui-plugin.js +46 -0
  240. package/lib/core/sui-plugin.js.map +1 -0
  241. package/lib/core/sui-processor.d.ts +26 -0
  242. package/lib/core/sui-processor.js +59 -0
  243. package/lib/core/sui-processor.js.map +1 -0
  244. package/lib/core/trace.d.ts +35 -0
  245. package/lib/core/trace.js +43 -0
  246. package/lib/core/trace.js.map +1 -0
  247. package/lib/endpoints.d.ts +6 -0
  248. package/lib/endpoints.js +11 -0
  249. package/lib/endpoints.js.map +1 -0
  250. package/lib/error.d.ts +7 -0
  251. package/lib/error.js +43 -0
  252. package/lib/error.js.map +1 -0
  253. package/{dist → lib}/gen/builtin.d.ts +0 -0
  254. package/{dist → lib}/gen/builtin.js +0 -0
  255. package/lib/gen/builtin.js.map +1 -0
  256. package/lib/gen/chainquery/protos/chainquery.d.ts +400 -0
  257. package/lib/gen/chainquery/protos/chainquery.js +972 -0
  258. package/lib/gen/chainquery/protos/chainquery.js.map +1 -0
  259. package/{dist → lib}/gen/google/protobuf/empty.d.ts +0 -0
  260. package/{dist → lib}/gen/google/protobuf/empty.js +0 -0
  261. package/lib/gen/google/protobuf/empty.js.map +1 -0
  262. package/lib/gen/google/protobuf/struct.d.ts +73 -0
  263. package/lib/gen/google/protobuf/struct.js +371 -0
  264. package/lib/gen/google/protobuf/struct.js.map +1 -0
  265. package/lib/gen/google/protobuf/timestamp.d.ts +18 -0
  266. package/lib/gen/google/protobuf/timestamp.js +71 -0
  267. package/lib/gen/google/protobuf/timestamp.js.map +1 -0
  268. package/lib/gen/index.d.ts +2 -0
  269. package/lib/gen/index.js +19 -0
  270. package/lib/gen/index.js.map +1 -0
  271. package/lib/gen/processor/protos/processor.d.ts +826 -0
  272. package/lib/gen/processor/protos/processor.js +3988 -0
  273. package/lib/gen/processor/protos/processor.js.map +1 -0
  274. package/lib/gen/service/price/protos/price.d.ts +85 -0
  275. package/lib/gen/service/price/protos/price.js +269 -0
  276. package/lib/gen/service/price/protos/price.js.map +1 -0
  277. package/lib/index.d.ts +7 -0
  278. package/lib/index.js +48 -0
  279. package/lib/index.js.map +1 -0
  280. package/lib/loader.d.ts +5 -0
  281. package/lib/loader.js +30 -0
  282. package/lib/loader.js.map +1 -0
  283. package/lib/plugin.d.ts +15 -0
  284. package/lib/plugin.js +32 -0
  285. package/lib/plugin.js.map +1 -0
  286. package/{dist → lib}/processor-runner.d.ts +0 -0
  287. package/lib/processor-runner.js +102 -0
  288. package/lib/processor-runner.js.map +1 -0
  289. package/lib/promise-or-void.d.ts +1 -0
  290. package/lib/promise-or-void.js +3 -0
  291. package/lib/promise-or-void.js.map +1 -0
  292. package/{dist → lib}/provider.d.ts +2 -1
  293. package/{dist → lib}/provider.js +19 -9
  294. package/lib/provider.js.map +1 -0
  295. package/lib/service.d.ts +26 -0
  296. package/lib/service.js +225 -0
  297. package/lib/service.js.map +1 -0
  298. package/lib/solana-codegen/codegen.d.ts +1 -0
  299. package/lib/solana-codegen/codegen.js +113 -0
  300. package/lib/solana-codegen/codegen.js.map +1 -0
  301. package/lib/state/processor-state.d.ts +3 -0
  302. package/lib/state/processor-state.js +8 -0
  303. package/lib/state/processor-state.js.map +1 -0
  304. package/lib/state/state-storage.d.ts +17 -0
  305. package/lib/state/state-storage.js +60 -0
  306. package/lib/state/state-storage.js.map +1 -0
  307. package/{dist/test-case/solana.test.d.ts → lib/state/state-storage.test.d.ts} +0 -0
  308. package/lib/state/state-storage.test.js.map +1 -0
  309. package/lib/target-ethers-sentio/event-handler.d.ts +3 -0
  310. package/lib/target-ethers-sentio/event-handler.js +35 -0
  311. package/lib/target-ethers-sentio/event-handler.js.map +1 -0
  312. package/{dist/target-ethers-sentio/codegen.d.ts → lib/target-ethers-sentio/file.d.ts} +1 -0
  313. package/lib/target-ethers-sentio/file.js +226 -0
  314. package/lib/target-ethers-sentio/file.js.map +1 -0
  315. package/lib/target-ethers-sentio/functions-handler.d.ts +3 -0
  316. package/lib/target-ethers-sentio/functions-handler.js +50 -0
  317. package/lib/target-ethers-sentio/functions-handler.js.map +1 -0
  318. package/{dist → lib}/target-ethers-sentio/index.d.ts +1 -0
  319. package/{dist → lib}/target-ethers-sentio/index.js +16 -3
  320. package/{dist → lib}/target-ethers-sentio/index.js.map +1 -1
  321. package/lib/target-ethers-sentio/types.d.ts +4 -0
  322. package/lib/target-ethers-sentio/types.js +46 -0
  323. package/lib/target-ethers-sentio/types.js.map +1 -0
  324. package/lib/target-ethers-sentio/view-function.d.ts +5 -0
  325. package/lib/target-ethers-sentio/view-function.js +74 -0
  326. package/lib/target-ethers-sentio/view-function.js.map +1 -0
  327. package/{dist/cli/cli.d.ts → lib/test-abi-code-gen.d.ts} +0 -0
  328. package/lib/test-abi-code-gen.js +20 -0
  329. package/lib/test-abi-code-gen.js.map +1 -0
  330. package/lib/testing/index.d.ts +2 -0
  331. package/lib/testing/index.js +11 -0
  332. package/lib/testing/index.js.map +1 -0
  333. package/lib/testing/metric-utils.d.ts +5 -0
  334. package/lib/testing/metric-utils.js +50 -0
  335. package/lib/testing/metric-utils.js.map +1 -0
  336. package/lib/testing/test-processor-server.d.ts +42 -0
  337. package/lib/testing/test-processor-server.js +293 -0
  338. package/lib/testing/test-processor-server.js.map +1 -0
  339. package/lib/testing/test-provider.d.ts +1 -0
  340. package/lib/testing/test-provider.js +33 -0
  341. package/lib/testing/test-provider.js.map +1 -0
  342. package/lib/utils/chain.d.ts +89 -0
  343. package/lib/utils/chain.js +128 -0
  344. package/lib/utils/chain.js.map +1 -0
  345. package/lib/utils/chainlink-oracles-goerli.csv +8 -0
  346. package/lib/utils/chainlink-oracles.csv +217 -0
  347. package/lib/utils/conversion.d.ts +6 -0
  348. package/lib/utils/conversion.js +27 -0
  349. package/lib/utils/conversion.js.map +1 -0
  350. package/lib/utils/dex-price.d.ts +22 -0
  351. package/lib/utils/dex-price.js +114 -0
  352. package/lib/utils/dex-price.js.map +1 -0
  353. package/{dist/test-case/wormhole-token-bridge.d.ts → lib/utils/dex-price.test.d.ts} +0 -0
  354. package/lib/utils/dex-price.test.js.map +1 -0
  355. package/lib/utils/erc20.test.d.ts +1 -0
  356. package/lib/utils/erc20.test.js.map +1 -0
  357. package/lib/utils/index.d.ts +4 -0
  358. package/lib/utils/index.js +31 -0
  359. package/lib/utils/index.js.map +1 -0
  360. package/lib/utils/price.d.ts +52 -0
  361. package/lib/utils/price.js +86 -0
  362. package/lib/utils/price.js.map +1 -0
  363. package/lib/utils/token.d.ts +15 -0
  364. package/lib/utils/token.js +60 -0
  365. package/lib/utils/token.js.map +1 -0
  366. package/package.json +43 -42
  367. package/src/abis/EACAggregatorProxy.json +227 -0
  368. package/src/abis/ERC1155.json +314 -0
  369. package/src/abis/ERC20.json +174 -0
  370. package/src/abis/ERC20Bytes.json +236 -0
  371. package/src/abis/ERC721.json +346 -0
  372. package/src/abis/WETH9.json +153 -0
  373. package/src/abis/aptos/0x1.json +9205 -0
  374. package/src/abis/aptos/0x3.json +1515 -0
  375. package/src/aptos/api.ts +11 -0
  376. package/src/aptos/aptos-plugin.ts +217 -0
  377. package/src/aptos/aptos-processor.ts +305 -0
  378. package/src/aptos/context.ts +75 -0
  379. package/src/aptos/index.ts +10 -0
  380. package/src/aptos/models.ts +34 -0
  381. package/src/aptos/network.ts +42 -0
  382. package/src/aptos/runtime.ts +13 -0
  383. package/src/aptos/type-registry.ts +187 -0
  384. package/src/aptos/types.ts +149 -0
  385. package/src/aptos/utils.ts +26 -0
  386. package/src/aptos-codegen/codegen.ts +428 -0
  387. package/src/aptos-codegen/tsconfig.json +9 -0
  388. package/src/aptos-codegen/typegen.ts +153 -0
  389. package/src/binds.ts +45 -0
  390. package/src/builtin/aptos/0x1.ts +4210 -0
  391. package/src/builtin/aptos/0x3.ts +888 -0
  392. package/src/builtin/aptos/index.ts +2 -0
  393. package/src/builtin/eacaggregatorproxy/index.ts +6 -0
  394. package/src/builtin/eacaggregatorproxy/test-utils.ts +89 -0
  395. package/src/builtin/erc1155/index.ts +6 -0
  396. package/src/builtin/erc1155/test-utils.ts +89 -0
  397. package/src/builtin/erc20/index.ts +6 -0
  398. package/src/builtin/erc20/test-utils.ts +71 -0
  399. package/src/builtin/erc20bytes/index.ts +6 -0
  400. package/src/builtin/erc20bytes/test-utils.ts +53 -0
  401. package/src/builtin/erc721/index.ts +6 -0
  402. package/src/builtin/erc721/test-utils.ts +71 -0
  403. package/src/builtin/index.ts +7 -0
  404. package/src/builtin/internal/EACAggregatorProxy.ts +861 -0
  405. package/src/builtin/internal/ERC1155.ts +529 -0
  406. package/src/builtin/internal/ERC20.ts +679 -0
  407. package/src/builtin/internal/ERC20Bytes.ts +384 -0
  408. package/src/builtin/internal/ERC721.ts +639 -0
  409. package/src/builtin/internal/WETH9.ts +480 -0
  410. package/src/builtin/internal/common.ts +46 -0
  411. package/src/builtin/internal/eacaggregatorproxy_processor.ts +1219 -0
  412. package/src/builtin/internal/erc1155_processor.ts +534 -0
  413. package/src/builtin/internal/erc20_processor.ts +663 -0
  414. package/src/builtin/internal/erc20bytes_processor.ts +474 -0
  415. package/src/builtin/internal/erc721_processor.ts +686 -0
  416. package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +534 -0
  417. package/src/builtin/internal/factories/ERC1155__factory.ts +336 -0
  418. package/src/builtin/internal/factories/ERC20Bytes__factory.ts +258 -0
  419. package/src/builtin/internal/factories/ERC20__factory.ts +405 -0
  420. package/src/builtin/internal/factories/ERC721__factory.ts +365 -0
  421. package/src/builtin/internal/factories/WETH9__factory.ts +298 -0
  422. package/src/builtin/internal/factories/index.ts +9 -0
  423. package/src/builtin/internal/index.ts +16 -0
  424. package/src/builtin/internal/weth9_processor.ts +536 -0
  425. package/src/builtin/solana/index.ts +2 -0
  426. package/src/builtin/solana/spl-token-processor.ts +298 -0
  427. package/src/builtin/solana/types.ts +279 -0
  428. package/src/builtin/solana/wormhole-processor.ts +178 -0
  429. package/src/builtin/weth9/index.ts +6 -0
  430. package/src/builtin/weth9/test-utils.ts +89 -0
  431. package/src/chain-config.ts +6 -0
  432. package/src/core/account-processor.ts +217 -0
  433. package/src/core/base-context.ts +28 -0
  434. package/src/core/base-processor-template.ts +150 -0
  435. package/src/core/base-processor.ts +217 -0
  436. package/src/core/big-decimal.ts +1 -0
  437. package/src/core/bind-options.ts +45 -0
  438. package/src/core/context.ts +183 -0
  439. package/src/core/eth-plugin.ts +255 -0
  440. package/src/core/event-tracker.ts +69 -0
  441. package/src/core/exporter.ts +32 -0
  442. package/src/core/generic-processor.ts +34 -0
  443. package/src/core/index.ts +22 -0
  444. package/src/core/logger.ts +49 -0
  445. package/src/core/metadata.ts +11 -0
  446. package/src/core/meter.ts +179 -0
  447. package/src/core/numberish.ts +121 -0
  448. package/src/core/solana-context.ts +35 -0
  449. package/src/core/solana-options.ts +10 -0
  450. package/src/core/solana-plugin.ts +97 -0
  451. package/src/core/solana-processor.ts +109 -0
  452. package/src/core/sui-plugin.ts +54 -0
  453. package/src/core/sui-processor.ts +65 -0
  454. package/src/core/trace.ts +86 -0
  455. package/src/endpoints.ts +9 -0
  456. package/src/error.ts +45 -0
  457. package/src/gen/builtin.ts +22 -0
  458. package/src/gen/chainquery/protos/chainquery.ts +1212 -0
  459. package/src/gen/google/protobuf/empty.ts +58 -0
  460. package/src/gen/google/protobuf/struct.ts +422 -0
  461. package/src/gen/google/protobuf/timestamp.ts +85 -0
  462. package/src/gen/index.ts +3 -0
  463. package/src/gen/processor/protos/processor.ts +4619 -0
  464. package/src/gen/service/price/protos/price.ts +329 -0
  465. package/src/index.ts +13 -0
  466. package/src/loader.ts +24 -0
  467. package/src/plugin.ts +41 -0
  468. package/src/processor-runner.ts +93 -0
  469. package/src/promise-or-void.ts +1 -0
  470. package/src/provider.ts +74 -0
  471. package/src/service.ts +255 -0
  472. package/src/solana-codegen/codegen.ts +116 -0
  473. package/src/state/processor-state.ts +3 -0
  474. package/src/state/state-storage.ts +65 -0
  475. package/src/target-ethers-sentio/event-handler.ts +31 -0
  476. package/src/target-ethers-sentio/file.ts +242 -0
  477. package/src/target-ethers-sentio/functions-handler.ts +57 -0
  478. package/src/target-ethers-sentio/index.ts +60 -0
  479. package/src/target-ethers-sentio/tsconfig.json +9 -0
  480. package/src/target-ethers-sentio/types.ts +42 -0
  481. package/src/target-ethers-sentio/view-function.ts +79 -0
  482. package/src/test-abi-code-gen.ts +16 -0
  483. package/src/testing/index.ts +4 -0
  484. package/src/testing/metric-utils.ts +48 -0
  485. package/src/testing/test-processor-server.ts +334 -0
  486. package/src/testing/test-provider.ts +33 -0
  487. package/src/types/global.d.ts +15 -0
  488. package/src/utils/chain.ts +127 -0
  489. package/src/utils/chainlink-oracles-goerli.csv +8 -0
  490. package/src/utils/chainlink-oracles.csv +217 -0
  491. package/src/utils/conversion.ts +27 -0
  492. package/src/utils/dex-price.ts +136 -0
  493. package/src/utils/index.ts +4 -0
  494. package/src/utils/price.ts +95 -0
  495. package/src/utils/token.ts +70 -0
  496. package/dist/base-processor-template.d.ts +0 -20
  497. package/dist/base-processor-template.js.map +0 -1
  498. package/dist/base-processor.d.ts +0 -22
  499. package/dist/base-processor.js +0 -103
  500. package/dist/base-processor.js.map +0 -1
  501. package/dist/bind-options.js.map +0 -1
  502. package/dist/binds.d.ts +0 -10
  503. package/dist/binds.js +0 -58
  504. package/dist/binds.js.map +0 -1
  505. package/dist/builtin/erc20/index.js.map +0 -1
  506. package/dist/builtin/internal/Erc20.js.map +0 -1
  507. package/dist/builtin/internal/common.js.map +0 -1
  508. package/dist/builtin/internal/erc20_processor.d.ts +0 -38
  509. package/dist/builtin/internal/erc20_processor.js +0 -209
  510. package/dist/builtin/internal/erc20_processor.js.map +0 -1
  511. package/dist/builtin/internal/factories/Erc20__factory.js.map +0 -1
  512. package/dist/builtin/internal/factories/index.d.ts +0 -1
  513. package/dist/builtin/internal/factories/index.js +0 -9
  514. package/dist/builtin/internal/factories/index.js.map +0 -1
  515. package/dist/builtin/internal/index.d.ts +0 -3
  516. package/dist/builtin/internal/index.js.map +0 -1
  517. package/dist/cli/build.d.ts +0 -3
  518. package/dist/cli/build.js +0 -161
  519. package/dist/cli/build.js.map +0 -1
  520. package/dist/cli/cli.js +0 -212
  521. package/dist/cli/cli.js.map +0 -1
  522. package/dist/cli/config.d.ts +0 -14
  523. package/dist/cli/config.js +0 -24
  524. package/dist/cli/config.js.map +0 -1
  525. package/dist/cli/key.d.ts +0 -2
  526. package/dist/cli/key.js +0 -44
  527. package/dist/cli/key.js.map +0 -1
  528. package/dist/cli/solana-code-gen.d.ts +0 -2
  529. package/dist/cli/solana-code-gen.js +0 -19
  530. package/dist/cli/solana-code-gen.js.map +0 -1
  531. package/dist/cli/upload.d.ts +0 -2
  532. package/dist/cli/upload.js +0 -76
  533. package/dist/cli/upload.js.map +0 -1
  534. package/dist/cli/webpack.config.js +0 -41
  535. package/dist/context.d.ts +0 -39
  536. package/dist/context.js +0 -75
  537. package/dist/context.js.map +0 -1
  538. package/dist/contract-namer.d.ts +0 -6
  539. package/dist/contract-namer.js +0 -20
  540. package/dist/contract-namer.js.map +0 -1
  541. package/dist/error.d.ts +0 -2
  542. package/dist/error.js +0 -39
  543. package/dist/error.js.map +0 -1
  544. package/dist/gen/builtin.js.map +0 -1
  545. package/dist/gen/google/protobuf/empty.js.map +0 -1
  546. package/dist/gen/processor/protos/processor.d.ts +0 -598
  547. package/dist/gen/processor/protos/processor.js +0 -2424
  548. package/dist/gen/processor/protos/processor.js.map +0 -1
  549. package/dist/index.d.ts +0 -13
  550. package/dist/index.js +0 -54
  551. package/dist/index.js.map +0 -1
  552. package/dist/meter.d.ts +0 -25
  553. package/dist/meter.js +0 -114
  554. package/dist/meter.js.map +0 -1
  555. package/dist/numberish.d.ts +0 -7
  556. package/dist/numberish.js +0 -74
  557. package/dist/numberish.js.map +0 -1
  558. package/dist/numberish.test.js +0 -54
  559. package/dist/numberish.test.js.map +0 -1
  560. package/dist/processor-runner.js +0 -66
  561. package/dist/processor-runner.js.map +0 -1
  562. package/dist/processor-state.d.ts +0 -16
  563. package/dist/processor-state.js +0 -20
  564. package/dist/processor-state.js.map +0 -1
  565. package/dist/provider.js.map +0 -1
  566. package/dist/service.d.ts +0 -22
  567. package/dist/service.js +0 -361
  568. package/dist/service.js.map +0 -1
  569. package/dist/solana/builtin/spl-token-processor.d.ts +0 -25
  570. package/dist/solana/builtin/spl-token-processor.js +0 -152
  571. package/dist/solana/builtin/spl-token-processor.js.map +0 -1
  572. package/dist/solana-processor.d.ts +0 -28
  573. package/dist/solana-processor.js +0 -79
  574. package/dist/solana-processor.js.map +0 -1
  575. package/dist/target-ethers-sentio/codegen.js +0 -201
  576. package/dist/target-ethers-sentio/codegen.js.map +0 -1
  577. package/dist/test-case/clean-test.d.ts +0 -1
  578. package/dist/test-case/clean-test.js +0 -9
  579. package/dist/test-case/clean-test.js.map +0 -1
  580. package/dist/test-case/erc20-template.d.ts +0 -1
  581. package/dist/test-case/erc20-template.js +0 -23
  582. package/dist/test-case/erc20-template.js.map +0 -1
  583. package/dist/test-case/erc20-template.test.js +0 -69
  584. package/dist/test-case/erc20-template.test.js.map +0 -1
  585. package/dist/test-case/erc20.d.ts +0 -1
  586. package/dist/test-case/erc20.js +0 -42
  587. package/dist/test-case/erc20.js.map +0 -1
  588. package/dist/test-case/erc20.test.js +0 -154
  589. package/dist/test-case/erc20.test.js.map +0 -1
  590. package/dist/test-case/mirrorworld.js +0 -42
  591. package/dist/test-case/mirrorworld.js.map +0 -1
  592. package/dist/test-case/solana.test.js +0 -58
  593. package/dist/test-case/solana.test.js.map +0 -1
  594. package/dist/test-case/types/game_wallet.d.ts +0 -45
  595. package/dist/test-case/types/game_wallet.js +0 -1396
  596. package/dist/test-case/types/game_wallet.js.map +0 -1
  597. package/dist/test-case/types/game_wallet_processor.d.ts +0 -107
  598. package/dist/test-case/types/game_wallet_processor.js +0 -102
  599. package/dist/test-case/types/game_wallet_processor.js.map +0 -1
  600. package/dist/test-case/types/wormhole_processor.d.ts +0 -16
  601. package/dist/test-case/types/wormhole_processor.js.map +0 -1
  602. package/dist/test-case/wormhole-token-bridge.js +0 -7
  603. package/dist/test-case/wormhole-token-bridge.js.map +0 -1
  604. package/dist/utils/chainmap.d.ts +0 -4
  605. package/dist/utils/chainmap.js +0 -95
  606. package/dist/utils/chainmap.js.map +0 -1
  607. package/dist/utils/index.d.ts +0 -1
  608. package/dist/utils/index.js +0 -6
  609. package/dist/utils/index.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,55 @@
1
+ Apache License
2
+
3
+ Version 2.0, January 2004
4
+
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16
+
17
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18
+
19
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20
+
21
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22
+
23
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24
+
25
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26
+
27
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28
+
29
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30
+
31
+ 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34
+
35
+ 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36
+
37
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
38
+
39
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
40
+
41
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
42
+
43
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
44
+
45
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
46
+
47
+ 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
48
+
49
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
50
+
51
+ 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
52
+
53
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
54
+
55
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,2 @@
1
+ import { AptosQueryClient } from '../gen/chainquery/protos/chainquery';
2
+ export declare function getChainQueryClient(address?: string): AptosQueryClient;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChainQueryClient = void 0;
4
+ const chainquery_1 = require("../gen/chainquery/protos/chainquery");
5
+ const nice_grpc_1 = require("nice-grpc");
6
+ function getChainQueryClient(address) {
7
+ if (!address) {
8
+ address = global.ENDPOINTS.chainQueryAPI;
9
+ }
10
+ const channel = (0, nice_grpc_1.createChannel)(address);
11
+ return (0, nice_grpc_1.createClient)(chainquery_1.AptosQueryDefinition, channel);
12
+ }
13
+ exports.getChainQueryClient = getChainQueryClient;
14
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/aptos/api.ts"],"names":[],"mappings":";;;AAAA,oEAA4F;AAC5F,yCAAuD;AAEvD,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,aAAa,CAAA;KACzC;IACD,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,OAAO,CAAC,CAAA;IAEtC,OAAO,IAAA,wBAAY,EAAC,iCAAoB,EAAE,OAAO,CAAC,CAAA;AACpD,CAAC;AAPD,kDAOC","sourcesContent":["import { AptosQueryClient, AptosQueryDefinition } from '../gen/chainquery/protos/chainquery'\nimport { createChannel, createClient } from 'nice-grpc'\n\nexport function getChainQueryClient(address?: string): AptosQueryClient {\n if (!address) {\n address = global.ENDPOINTS.chainQueryAPI\n }\n const channel = createChannel(address)\n\n return createClient(AptosQueryDefinition, channel)\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { Plugin } from '../plugin';
2
+ import { DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '../gen/processor/protos/processor';
3
+ export declare class AptosPlugin implements Plugin {
4
+ name: string;
5
+ private aptosEventHandlers;
6
+ private aptosCallHandlers;
7
+ private aptosResourceHandlers;
8
+ configure(config: ProcessConfigResponse): void;
9
+ supportedHandlers: HandlerType[];
10
+ processBinding(request: DataBinding): Promise<ProcessResult>;
11
+ processAptosEvent(binding: DataBinding): Promise<ProcessResult>;
12
+ processAptosResource(binding: DataBinding): Promise<ProcessResult>;
13
+ processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult>;
14
+ }
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AptosPlugin = void 0;
7
+ const plugin_1 = require("../plugin");
8
+ const processor_1 = require("../gen/processor/protos/processor");
9
+ const service_1 = require("../service");
10
+ const nice_grpc_1 = require("nice-grpc");
11
+ const aptos_processor_1 = require("./aptos-processor");
12
+ const numberish_1 = require("../core/numberish");
13
+ const long_1 = __importDefault(require("long"));
14
+ class AptosPlugin {
15
+ name = 'AptosPlugin';
16
+ aptosEventHandlers = [];
17
+ aptosCallHandlers = [];
18
+ aptosResourceHandlers = [];
19
+ configure(config) {
20
+ for (const aptosProcessor of aptos_processor_1.AptosProcessorState.INSTANCE.getValues()) {
21
+ const contractConfig = {
22
+ processorType: service_1.USER_PROCESSOR,
23
+ contract: {
24
+ name: aptosProcessor.moduleName,
25
+ chainId: aptosProcessor.getChainId(),
26
+ address: aptosProcessor.config.address,
27
+ abi: '',
28
+ },
29
+ intervalConfigs: [],
30
+ logConfigs: [],
31
+ traceConfigs: [],
32
+ startBlock: long_1.default.fromString(aptosProcessor.config.startVersion.toString()),
33
+ endBlock: service_1.DEFAULT_MAX_BLOCK,
34
+ instructionConfig: undefined,
35
+ aptosEventConfigs: [],
36
+ aptosCallConfigs: [],
37
+ };
38
+ // 1. Prepare event handlers
39
+ for (const handler of aptosProcessor.eventHandlers) {
40
+ const handlerId = this.aptosEventHandlers.push(handler.handler) - 1;
41
+ const eventHandlerConfig = {
42
+ filters: handler.filters.map((f) => {
43
+ return {
44
+ type: f.type,
45
+ account: f.account || '',
46
+ };
47
+ }),
48
+ handlerId,
49
+ };
50
+ contractConfig.aptosEventConfigs.push(eventHandlerConfig);
51
+ }
52
+ // 2. Prepare function handlers
53
+ for (const handler of aptosProcessor.callHandlers) {
54
+ const handlerId = this.aptosCallHandlers.push(handler.handler) - 1;
55
+ const functionHandlerConfig = {
56
+ filters: handler.filters.map((filter) => {
57
+ return {
58
+ function: filter.function,
59
+ typeArguments: filter.typeArguments || [],
60
+ withTypeArguments: filter.typeArguments ? true : false,
61
+ includeFailed: filter.includeFailed || false,
62
+ };
63
+ }),
64
+ handlerId,
65
+ };
66
+ contractConfig.aptosCallConfigs.push(functionHandlerConfig);
67
+ }
68
+ config.contractConfigs.push(contractConfig);
69
+ }
70
+ for (const aptosProcessor of aptos_processor_1.AptosAccountProcessorState.INSTANCE.getValues()) {
71
+ const accountConfig = {
72
+ address: aptosProcessor.config.address,
73
+ chainId: aptosProcessor.getChainId(),
74
+ startBlock: long_1.default.fromValue(aptosProcessor.config.startVersion.toString()),
75
+ aptosIntervalConfigs: [],
76
+ intervalConfigs: [],
77
+ logConfigs: [],
78
+ };
79
+ for (const handler of aptosProcessor.resourcesHandlers) {
80
+ const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1;
81
+ accountConfig.aptosIntervalConfigs.push({
82
+ intervalConfig: {
83
+ handlerId: handlerId,
84
+ minutes: 0,
85
+ minutesInterval: handler.timeIntervalInMinutes,
86
+ slot: 0,
87
+ slotInterval: handler.versionInterval,
88
+ },
89
+ type: handler.type || '',
90
+ });
91
+ }
92
+ config.accountConfigs.push(accountConfig);
93
+ }
94
+ }
95
+ supportedHandlers = [processor_1.HandlerType.APT_CALL, processor_1.HandlerType.APT_RESOURCE, processor_1.HandlerType.APT_EVENT];
96
+ processBinding(request) {
97
+ switch (request.handlerType) {
98
+ case processor_1.HandlerType.APT_CALL:
99
+ return this.processAptosFunctionCall(request);
100
+ case processor_1.HandlerType.APT_EVENT:
101
+ return this.processAptosEvent(request);
102
+ case processor_1.HandlerType.APT_RESOURCE:
103
+ return this.processAptosResource(request);
104
+ // case HandlerType.INSTRUCTION:
105
+ // return this.processInstruction(request)
106
+ default:
107
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
108
+ }
109
+ }
110
+ async processAptosEvent(binding) {
111
+ if (!binding.data) {
112
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
113
+ }
114
+ const promises = [];
115
+ let event;
116
+ if (binding.data.aptEvent?.event) {
117
+ event = binding.data.aptEvent?.event;
118
+ }
119
+ else {
120
+ const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
121
+ event = JSON.parse(jsonString);
122
+ }
123
+ for (const handlerId of binding.handlerIds) {
124
+ // only support aptos event for now
125
+ promises.push(this.aptosEventHandlers[handlerId](event).catch((e) => {
126
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing event: ' + JSON.stringify(event) + '\n' + (0, service_1.errorString)(e));
127
+ }));
128
+ }
129
+ return (0, service_1.mergeProcessResults)(await Promise.all(promises));
130
+ }
131
+ async processAptosResource(binding) {
132
+ if (!binding.data) {
133
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
134
+ }
135
+ const resource = {
136
+ resources: [],
137
+ version: 0n,
138
+ timestamp: 0,
139
+ };
140
+ if (binding.data.aptResource?.resources) {
141
+ if (binding.data.aptResource.timestampMicros.greaterThan(Number.MAX_SAFE_INTEGER)) {
142
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'timestamp is too large');
143
+ }
144
+ resource.timestamp = binding.data.aptResource.timestampMicros.toNumber();
145
+ resource.version = (0, numberish_1.toBigInt)(binding.data.aptResource.version);
146
+ resource.resources = binding.data.aptResource.resources;
147
+ }
148
+ else {
149
+ const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
150
+ const json = JSON.parse(jsonString);
151
+ if (long_1.default.fromString(json.timestamp).greaterThan(Number.MAX_SAFE_INTEGER)) {
152
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, 'timestamp is too large');
153
+ }
154
+ resource.timestamp = parseInt(json.timestamp);
155
+ resource.version = (0, numberish_1.toBigInt)(json.version);
156
+ }
157
+ const promises = [];
158
+ for (const handlerId of binding.handlerIds) {
159
+ promises.push(this.aptosResourceHandlers[handlerId](resource).catch((e) => {
160
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing event: ' + JSON.stringify(resource) + '\n' + (0, service_1.errorString)(e));
161
+ }));
162
+ }
163
+ return (0, service_1.mergeProcessResults)(await Promise.all(promises));
164
+ }
165
+ async processAptosFunctionCall(binding) {
166
+ if (!binding.data) {
167
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INVALID_ARGUMENT, "Event can't be empty");
168
+ }
169
+ let call;
170
+ if (binding.data.aptCall?.call) {
171
+ call = binding.data.aptCall?.call;
172
+ }
173
+ else {
174
+ const jsonString = (0, service_1.Utf8ArrayToStr)(binding.data.raw);
175
+ call = JSON.parse(jsonString);
176
+ }
177
+ const promises = [];
178
+ for (const handlerId of binding.handlerIds) {
179
+ // only support aptos call for now
180
+ const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {
181
+ throw new nice_grpc_1.ServerError(nice_grpc_1.Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + (0, service_1.errorString)(e));
182
+ });
183
+ promises.push(promise);
184
+ }
185
+ return (0, service_1.mergeProcessResults)(await Promise.all(promises));
186
+ }
187
+ }
188
+ exports.AptosPlugin = AptosPlugin;
189
+ plugin_1.PluginManager.INSTANCE.register(new AptosPlugin());
190
+ //# sourceMappingURL=aptos-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aptos-plugin.js","sourceRoot":"","sources":["../../src/aptos/aptos-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAiD;A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H,CAAC,CAAC,CAAA;YACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACvB;QACD,OAAO,IAAA,6BAAmB,EAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAlMD,kCAkMC;AAED,sBAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager } from '../plugin'\nimport {\n AccountConfig,\n AptosCallHandlerConfig,\n AptosEventHandlerConfig,\n ContractConfig,\n DataBinding,\n HandlerType,\n ProcessConfigResponse,\n ProcessResult,\n} from '../gen/processor/protos/processor'\nimport { DEFAULT_MAX_BLOCK, errorString, mergeProcessResults, USER_PROCESSOR, Utf8ArrayToStr } from '../service'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'\nimport { AptosAccountProcessorState, AptosProcessorState, MoveResourcesWithVersionPayload } from './aptos-processor'\nimport { toBigInt } from '../core/numberish'\nimport Long from 'long'\n\nexport class AptosPlugin implements Plugin {\n name: string = 'AptosPlugin'\n\n private aptosEventHandlers: ((event: any) => Promise<ProcessResult>)[] = []\n private aptosCallHandlers: ((func: any) => Promise<ProcessResult>)[] = []\n private aptosResourceHandlers: ((resourceWithVersion: MoveResourcesWithVersionPayload) => Promise<ProcessResult>)[] =\n []\n\n configure(config: ProcessConfigResponse): void {\n for (const aptosProcessor of AptosProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n processorType: USER_PROCESSOR,\n contract: {\n name: aptosProcessor.moduleName,\n chainId: aptosProcessor.getChainId(),\n address: aptosProcessor.config.address,\n abi: '',\n },\n intervalConfigs: [],\n logConfigs: [],\n traceConfigs: [],\n startBlock: Long.fromString(aptosProcessor.config.startVersion.toString()),\n endBlock: DEFAULT_MAX_BLOCK,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n // 1. Prepare event handlers\n for (const handler of aptosProcessor.eventHandlers) {\n const handlerId = this.aptosEventHandlers.push(handler.handler) - 1\n const eventHandlerConfig: AptosEventHandlerConfig = {\n filters: handler.filters.map((f) => {\n return {\n type: f.type,\n account: f.account || '',\n }\n }),\n handlerId,\n }\n contractConfig.aptosEventConfigs.push(eventHandlerConfig)\n }\n\n // 2. Prepare function handlers\n for (const handler of aptosProcessor.callHandlers) {\n const handlerId = this.aptosCallHandlers.push(handler.handler) - 1\n const functionHandlerConfig: AptosCallHandlerConfig = {\n filters: handler.filters.map((filter) => {\n return {\n function: filter.function,\n typeArguments: filter.typeArguments || [],\n withTypeArguments: filter.typeArguments ? true : false,\n includeFailed: filter.includeFailed || false,\n }\n }),\n handlerId,\n }\n contractConfig.aptosCallConfigs.push(functionHandlerConfig)\n }\n config.contractConfigs.push(contractConfig)\n }\n\n for (const aptosProcessor of AptosAccountProcessorState.INSTANCE.getValues()) {\n const accountConfig: AccountConfig = {\n address: aptosProcessor.config.address,\n chainId: aptosProcessor.getChainId(),\n startBlock: Long.fromValue(aptosProcessor.config.startVersion.toString()),\n aptosIntervalConfigs: [],\n intervalConfigs: [],\n logConfigs: [],\n }\n for (const handler of aptosProcessor.resourcesHandlers) {\n const handlerId = this.aptosResourceHandlers.push(handler.handler) - 1\n accountConfig.aptosIntervalConfigs.push({\n intervalConfig: {\n handlerId: handlerId,\n minutes: 0,\n minutesInterval: handler.timeIntervalInMinutes,\n slot: 0,\n slotInterval: handler.versionInterval,\n },\n type: handler.type || '',\n })\n }\n config.accountConfigs.push(accountConfig)\n }\n }\n\n supportedHandlers = [HandlerType.APT_CALL, HandlerType.APT_RESOURCE, HandlerType.APT_EVENT]\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.APT_CALL:\n return this.processAptosFunctionCall(request)\n case HandlerType.APT_EVENT:\n return this.processAptosEvent(request)\n case HandlerType.APT_RESOURCE:\n return this.processAptosResource(request)\n // case HandlerType.INSTRUCTION:\n // return this.processInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n\n async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n const promises: Promise<ProcessResult>[] = []\n let event: Transaction_UserTransaction\n if (binding.data.aptEvent?.event) {\n event = binding.data.aptEvent?.event as Transaction_UserTransaction\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n event = JSON.parse(jsonString)\n }\n\n for (const handlerId of binding.handlerIds) {\n // only support aptos event for now\n promises.push(\n this.aptosEventHandlers[handlerId](event).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing event: ' + JSON.stringify(event) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processAptosResource(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n\n const resource: MoveResourcesWithVersionPayload = {\n resources: [],\n version: 0n,\n timestamp: 0,\n }\n if (binding.data.aptResource?.resources) {\n if (binding.data.aptResource.timestampMicros.greaterThan(Number.MAX_SAFE_INTEGER)) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n resource.timestamp = binding.data.aptResource.timestampMicros.toNumber()\n resource.version = toBigInt(binding.data.aptResource.version)\n resource.resources = binding.data.aptResource.resources as MoveResource[]\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n const json = JSON.parse(jsonString)\n if (Long.fromString(json.timestamp).greaterThan(Number.MAX_SAFE_INTEGER)) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')\n }\n resource.timestamp = parseInt(json.timestamp)\n resource.version = toBigInt(json.version)\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n promises.push(\n this.aptosResourceHandlers[handlerId](resource).catch((e) => {\n throw new ServerError(\n Status.INTERNAL,\n 'error processing event: ' + JSON.stringify(resource) + '\\n' + errorString(e)\n )\n })\n )\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n\n async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {\n if (!binding.data) {\n throw new ServerError(Status.INVALID_ARGUMENT, \"Event can't be empty\")\n }\n let call: Transaction_UserTransaction\n if (binding.data.aptCall?.call) {\n call = binding.data.aptCall?.call as Transaction_UserTransaction\n } else {\n const jsonString = Utf8ArrayToStr(binding.data.raw)\n call = JSON.parse(jsonString)\n }\n\n const promises: Promise<ProcessResult>[] = []\n for (const handlerId of binding.handlerIds) {\n // only support aptos call for now\n const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {\n throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\\n' + errorString(e))\n })\n promises.push(promise)\n }\n return mergeProcessResults(await Promise.all(promises))\n }\n}\n\nPluginManager.INSTANCE.register(new AptosPlugin())\n"]}
@@ -0,0 +1,75 @@
1
+ import { MoveResource, Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos-sdk/src/generated';
2
+ import { TypeRegistry } from './type-registry';
3
+ import { AptosBindOptions, AptosNetwork } from './network';
4
+ import { AptosContext, AptosResourceContext } from './context';
5
+ import { EventInstance } from './models';
6
+ import { ListStateStorage } from '../state/state-storage';
7
+ import { HandleInterval, ProcessResult } from '../gen';
8
+ declare type IndexConfigure = {
9
+ address: string;
10
+ network: AptosNetwork;
11
+ startVersion: bigint;
12
+ };
13
+ export interface EventFilter {
14
+ type: string;
15
+ account?: string;
16
+ }
17
+ export interface FunctionNameAndCallFilter extends CallFilter {
18
+ function: string;
19
+ }
20
+ export interface CallFilter {
21
+ includeFailed?: boolean;
22
+ typeArguments?: string[];
23
+ }
24
+ export interface ArgumentsFilter {
25
+ arguments?: string[];
26
+ }
27
+ declare class EventHandler {
28
+ filters: EventFilter[];
29
+ handler: (event: Transaction_UserTransaction) => Promise<ProcessResult>;
30
+ }
31
+ declare class CallHandler {
32
+ filters: FunctionNameAndCallFilter[];
33
+ handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>;
34
+ }
35
+ export declare class MoveResourcesWithVersionPayload {
36
+ resources: MoveResource[];
37
+ version: bigint;
38
+ timestamp: number;
39
+ }
40
+ declare class ResourceHandlder {
41
+ type?: string;
42
+ versionInterval?: HandleInterval;
43
+ timeIntervalInMinutes?: HandleInterval;
44
+ handler: (resource: MoveResourcesWithVersionPayload) => Promise<ProcessResult>;
45
+ }
46
+ export declare class AptosProcessorState extends ListStateStorage<AptosBaseProcessor> {
47
+ static INSTANCE: AptosProcessorState;
48
+ }
49
+ export declare class AptosBaseProcessor {
50
+ readonly moduleName: string;
51
+ config: IndexConfigure;
52
+ eventHandlers: EventHandler[];
53
+ callHandlers: CallHandler[];
54
+ constructor(moduleName: string, options: AptosBindOptions);
55
+ onTransaction(handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void, includedFailed?: boolean): AptosBaseProcessor;
56
+ onEvent(handler: (event: EventInstance, ctx: AptosContext) => void, filter: EventFilter | EventFilter[]): AptosBaseProcessor;
57
+ onEntryFunctionCall(handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]): AptosBaseProcessor;
58
+ getChainId(): string;
59
+ loadTypes(registry: TypeRegistry): void;
60
+ protected loadTypesInternal(registry: TypeRegistry): void;
61
+ }
62
+ export declare class AptosAccountProcessorState extends ListStateStorage<AptosAccountProcessor> {
63
+ static INSTANCE: AptosAccountProcessorState;
64
+ }
65
+ export declare class AptosAccountProcessor {
66
+ config: IndexConfigure;
67
+ resourcesHandlers: ResourceHandlder[];
68
+ static bind(options: AptosBindOptions): AptosAccountProcessor;
69
+ protected constructor(options: AptosBindOptions);
70
+ getChainId(): string;
71
+ private onInterval;
72
+ onTimeInterval(handler: (resources: MoveResource[], ctx: AptosResourceContext) => void, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number, type?: string): this;
73
+ onVersionInterval(handler: (resources: MoveResource[], ctx: AptosResourceContext) => void, versionInterval?: number, backfillVersionInterval?: number, typePrefix?: string): this;
74
+ }
75
+ export {};
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AptosAccountProcessor = exports.AptosAccountProcessorState = exports.AptosBaseProcessor = exports.AptosProcessorState = exports.MoveResourcesWithVersionPayload = void 0;
4
+ const type_registry_1 = require("./type-registry");
5
+ const network_1 = require("./network");
6
+ const context_1 = require("./context");
7
+ const state_storage_1 = require("../state/state-storage");
8
+ class EventHandler {
9
+ filters;
10
+ handler;
11
+ }
12
+ class CallHandler {
13
+ filters;
14
+ handler;
15
+ }
16
+ class MoveResourcesWithVersionPayload {
17
+ resources;
18
+ version;
19
+ timestamp;
20
+ }
21
+ exports.MoveResourcesWithVersionPayload = MoveResourcesWithVersionPayload;
22
+ class ResourceHandlder {
23
+ type;
24
+ versionInterval;
25
+ timeIntervalInMinutes;
26
+ handler;
27
+ }
28
+ class AptosProcessorState extends state_storage_1.ListStateStorage {
29
+ static INSTANCE = new AptosProcessorState();
30
+ }
31
+ exports.AptosProcessorState = AptosProcessorState;
32
+ class AptosBaseProcessor {
33
+ moduleName;
34
+ config;
35
+ eventHandlers = [];
36
+ callHandlers = [];
37
+ constructor(moduleName, options) {
38
+ this.moduleName = moduleName;
39
+ this.config = configure(options);
40
+ AptosProcessorState.INSTANCE.addValue(this);
41
+ this.loadTypes(type_registry_1.TYPE_REGISTRY);
42
+ }
43
+ // getABI(): MoveModule | undefined {
44
+ // return undefined
45
+ // }
46
+ onTransaction(handler, includedFailed = false) {
47
+ // const address = this.config.address
48
+ // const moduleName = this.moduleName
49
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
50
+ const processor = this;
51
+ this.callHandlers.push({
52
+ handler: async function (tx) {
53
+ const ctx = new context_1.AptosContext(processor.moduleName, processor.config.network, processor.config.address, BigInt(tx.version), tx);
54
+ if (tx) {
55
+ await handler(tx, ctx);
56
+ }
57
+ return ctx.getProcessResult();
58
+ },
59
+ filters: [{ function: '', includeFailed: includedFailed }],
60
+ });
61
+ return this;
62
+ }
63
+ onEvent(handler, filter) {
64
+ let _filters = [];
65
+ if (Array.isArray(filter)) {
66
+ _filters = filter;
67
+ }
68
+ else {
69
+ _filters.push(filter);
70
+ }
71
+ // const address = this.config.address
72
+ // const moduleName = this.moduleName
73
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
74
+ const processor = this;
75
+ this.eventHandlers.push({
76
+ handler: async function (txn) {
77
+ const ctx = new context_1.AptosContext(processor.moduleName, processor.config.network, processor.config.address, BigInt(txn.version), txn);
78
+ if (txn && txn.events) {
79
+ const events = txn.events;
80
+ txn.events = [];
81
+ for (const evt of events) {
82
+ const eventInstance = evt;
83
+ const decoded = type_registry_1.TYPE_REGISTRY.decodeEvent(eventInstance);
84
+ await handler(decoded || eventInstance, ctx);
85
+ }
86
+ }
87
+ return ctx.getProcessResult();
88
+ },
89
+ filters: _filters,
90
+ });
91
+ return this;
92
+ }
93
+ onEntryFunctionCall(handler, filter) {
94
+ let _filters = [];
95
+ if (Array.isArray(filter)) {
96
+ _filters = filter;
97
+ }
98
+ else {
99
+ _filters.push(filter);
100
+ }
101
+ // const address = this.config.address
102
+ // const moduleName = this.moduleName
103
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
104
+ const processor = this;
105
+ this.callHandlers.push({
106
+ handler: async function (tx) {
107
+ const ctx = new context_1.AptosContext(processor.moduleName, processor.config.network, processor.config.address, BigInt(tx.version), tx);
108
+ if (tx) {
109
+ const payload = tx.payload;
110
+ const decoded = type_registry_1.TYPE_REGISTRY.decodeFunctionPayload(payload);
111
+ await handler(decoded, ctx);
112
+ }
113
+ return ctx.getProcessResult();
114
+ },
115
+ filters: _filters,
116
+ });
117
+ return this;
118
+ }
119
+ getChainId() {
120
+ return (0, network_1.getChainId)(this.config.network);
121
+ }
122
+ loadTypes(registry) {
123
+ if (registry.contains(this.config.address, this.moduleName)) {
124
+ return;
125
+ }
126
+ this.loadTypesInternal(registry);
127
+ }
128
+ loadTypesInternal(registry) {
129
+ // should be override by subclass
130
+ console.log('');
131
+ }
132
+ }
133
+ exports.AptosBaseProcessor = AptosBaseProcessor;
134
+ class AptosAccountProcessorState extends state_storage_1.ListStateStorage {
135
+ static INSTANCE = new AptosAccountProcessorState();
136
+ }
137
+ exports.AptosAccountProcessorState = AptosAccountProcessorState;
138
+ class AptosAccountProcessor {
139
+ config;
140
+ resourcesHandlers = [];
141
+ static bind(options) {
142
+ return new AptosAccountProcessor(options);
143
+ }
144
+ constructor(options) {
145
+ this.config = configure(options);
146
+ AptosAccountProcessorState.INSTANCE.addValue(this);
147
+ }
148
+ getChainId() {
149
+ return (0, network_1.getChainId)(this.config.network);
150
+ }
151
+ onInterval(handler, timeInterval, versionInterval, type) {
152
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
153
+ const processor = this;
154
+ this.resourcesHandlers.push({
155
+ handler: async function (arg) {
156
+ const ctx = new context_1.AptosResourceContext(processor.config.network, processor.config.address, arg.version, arg.timestamp);
157
+ await handler(arg.resources, ctx);
158
+ return ctx.getProcessResult();
159
+ },
160
+ timeIntervalInMinutes: timeInterval,
161
+ versionInterval: versionInterval,
162
+ type: type,
163
+ });
164
+ return this;
165
+ }
166
+ onTimeInterval(handler, timeIntervalInMinutes = 60, backfillTimeIntervalInMinutes = 240, type) {
167
+ return this.onInterval(handler, {
168
+ recentInterval: timeIntervalInMinutes,
169
+ backfillInterval: backfillTimeIntervalInMinutes,
170
+ }, undefined, type);
171
+ }
172
+ onVersionInterval(handler, versionInterval = 100000, backfillVersionInterval = 400000, typePrefix) {
173
+ return this.onInterval(handler, undefined, { recentInterval: versionInterval, backfillInterval: backfillVersionInterval }, typePrefix);
174
+ }
175
+ }
176
+ exports.AptosAccountProcessor = AptosAccountProcessor;
177
+ function configure(options) {
178
+ let startVersion = 0n;
179
+ if (options.startVersion !== undefined) {
180
+ if (typeof options.startVersion === 'number') {
181
+ startVersion = BigInt(options.startVersion);
182
+ }
183
+ else {
184
+ startVersion = options.startVersion;
185
+ }
186
+ }
187
+ return {
188
+ startVersion: startVersion,
189
+ address: options.address,
190
+ network: options.network || network_1.AptosNetwork.MAIN_NET,
191
+ };
192
+ }
193
+ //# sourceMappingURL=aptos-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aptos-processor.js","sourceRoot":"","sources":["../../src/aptos/aptos-processor.ts"],"names":[],"mappings":";;;AAMA,mDAA6D;AAC7D,uCAAsE;AACtE,uCAA8D;AAE9D,0DAAyD;AA8BzD,MAAM,YAAY;IAChB,OAAO,CAAe;IACtB,OAAO,CAAgE;CACxE;AAED,MAAM,WAAW;IACf,OAAO,CAA6B;IACpC,OAAO,CAA+D;CACvE;AAED,MAAa,+BAA+B;IAC1C,SAAS,CAAgB;IACzB,OAAO,CAAQ;IACf,SAAS,CAAQ;CAClB;AAJD,0EAIC;AAED,MAAM,gBAAgB;IACpB,IAAI,CAAS;IACb,eAAe,CAAiB;IAChC,qBAAqB,CAAiB;IACtC,OAAO,CAAuE;CAC/E;AAED,MAAa,mBAAoB,SAAQ,gCAAoC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,mBAAmB,EAAE,CAAA;;AAD7C,kDAEC;AAED,MAAa,kBAAkB;IACpB,UAAU,CAAQ;IAC3B,MAAM,CAAgB;IACtB,aAAa,GAAmB,EAAE,CAAA;IAClC,YAAY,GAAkB,EAAE,CAAA;IAEhC,YAAY,UAAkB,EAAE,OAAyB;QACvD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,mBAAmB,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,SAAS,CA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1C,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACtC,IAAI,OAAO,OAAO,CAAC,YAAY,KAAK,QAAQ,EAAE;YAC5C,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;SAC5C;aAAM;YACL,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;SACpC;KACF;IAED,OAAO;QACL,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,sBAAY,CAAC,QAAQ;KAClD,CAAA;AACH,CAAC","sourcesContent":["import {\n MoveResource,\n Transaction_UserTransaction,\n TransactionPayload_EntryFunctionPayload,\n} from 'aptos-sdk/src/generated'\n\nimport { TYPE_REGISTRY, TypeRegistry } from './type-registry'\nimport { AptosBindOptions, AptosNetwork, getChainId } from './network'\nimport { AptosContext, AptosResourceContext } from './context'\nimport { EventInstance } from './models'\nimport { ListStateStorage } from '../state/state-storage'\nimport { HandleInterval, ProcessResult } from '../gen'\n\ntype IndexConfigure = {\n address: string\n network: AptosNetwork\n startVersion: bigint\n // endSeqNumber?: Long\n}\n\n// TODO extends ArgumentsFilter\nexport interface EventFilter {\n type: string\n account?: string\n}\n\nexport interface FunctionNameAndCallFilter extends CallFilter {\n function: string\n}\n\n// TODO extends ArgumentsFilter\nexport interface CallFilter {\n includeFailed?: boolean\n typeArguments?: string[]\n}\n\nexport interface ArgumentsFilter {\n arguments?: string[]\n}\n\nclass EventHandler {\n filters: EventFilter[]\n handler: (event: Transaction_UserTransaction) => Promise<ProcessResult>\n}\n\nclass CallHandler {\n filters: FunctionNameAndCallFilter[]\n handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>\n}\n\nexport class MoveResourcesWithVersionPayload {\n resources: MoveResource[]\n version: bigint\n timestamp: number\n}\n\nclass ResourceHandlder {\n type?: string\n versionInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (resource: MoveResourcesWithVersionPayload) => Promise<ProcessResult>\n}\n\nexport class AptosProcessorState extends ListStateStorage<AptosBaseProcessor> {\n static INSTANCE = new AptosProcessorState()\n}\n\nexport class AptosBaseProcessor {\n readonly moduleName: string\n config: IndexConfigure\n eventHandlers: EventHandler[] = []\n callHandlers: CallHandler[] = []\n\n constructor(moduleName: string, options: AptosBindOptions) {\n this.moduleName = moduleName\n this.config = configure(options)\n AptosProcessorState.INSTANCE.addValue(this)\n this.loadTypes(TYPE_REGISTRY)\n }\n\n // getABI(): MoveModule | undefined {\n // return undefined\n // }\n\n public onTransaction(\n handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void,\n includedFailed = false\n ): AptosBaseProcessor {\n // const address = this.config.address\n // const moduleName = this.moduleName\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(tx.version),\n tx\n )\n if (tx) {\n await handler(tx, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: [{ function: '', includeFailed: includedFailed }],\n })\n return this\n }\n\n public onEvent(\n handler: (event: EventInstance, ctx: AptosContext) => void,\n filter: EventFilter | EventFilter[]\n ): AptosBaseProcessor {\n let _filters: EventFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.eventHandlers.push({\n handler: async function (txn) {\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(txn.version),\n txn\n )\n if (txn && txn.events) {\n const events = txn.events\n txn.events = []\n for (const evt of events) {\n const eventInstance = evt as EventInstance\n const decoded = TYPE_REGISTRY.decodeEvent<any>(eventInstance)\n await handler(decoded || eventInstance, ctx)\n }\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n })\n return this\n }\n\n public onEntryFunctionCall(\n handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,\n filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]\n ): AptosBaseProcessor {\n let _filters: FunctionNameAndCallFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n // const address = this.config.address\n // const moduleName = this.moduleName\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n\n this.callHandlers.push({\n handler: async function (tx) {\n const ctx = new AptosContext(\n processor.moduleName,\n processor.config.network,\n processor.config.address,\n BigInt(tx.version),\n tx\n )\n if (tx) {\n const payload = tx.payload as TransactionPayload_EntryFunctionPayload\n const decoded = TYPE_REGISTRY.decodeFunctionPayload(payload)\n await handler(decoded, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n })\n return this\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n loadTypes(registry: TypeRegistry) {\n if (registry.contains(this.config.address, this.moduleName)) {\n return\n }\n this.loadTypesInternal(registry)\n }\n\n protected loadTypesInternal(registry: TypeRegistry) {\n // should be override by subclass\n console.log('')\n }\n}\n\nexport class AptosAccountProcessorState extends ListStateStorage<AptosAccountProcessor> {\n static INSTANCE = new AptosAccountProcessorState()\n}\n\nexport class AptosAccountProcessor {\n config: IndexConfigure\n\n resourcesHandlers: ResourceHandlder[] = []\n\n static bind(options: AptosBindOptions): AptosAccountProcessor {\n return new AptosAccountProcessor(options)\n }\n\n protected constructor(options: AptosBindOptions) {\n this.config = configure(options)\n AptosAccountProcessorState.INSTANCE.addValue(this)\n }\n\n getChainId(): string {\n return getChainId(this.config.network)\n }\n\n private onInterval(\n handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,\n timeInterval: HandleInterval | undefined,\n versionInterval: HandleInterval | undefined,\n type: string | undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const processor = this\n this.resourcesHandlers.push({\n handler: async function (arg) {\n const ctx = new AptosResourceContext(\n processor.config.network,\n processor.config.address,\n arg.version,\n arg.timestamp\n )\n await handler(arg.resources, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n versionInterval: versionInterval,\n type: type,\n })\n return this\n }\n\n public onTimeInterval(\n handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240,\n type?: string\n ) {\n return this.onInterval(\n handler,\n {\n recentInterval: timeIntervalInMinutes,\n backfillInterval: backfillTimeIntervalInMinutes,\n },\n undefined,\n type\n )\n }\n\n public onVersionInterval(\n handler: (resources: MoveResource[], ctx: AptosResourceContext) => void,\n versionInterval = 100000,\n backfillVersionInterval = 400000,\n typePrefix?: string\n ) {\n return this.onInterval(\n handler,\n undefined,\n { recentInterval: versionInterval, backfillInterval: backfillVersionInterval },\n typePrefix\n )\n }\n}\n\nfunction configure(options: AptosBindOptions): IndexConfigure {\n let startVersion = 0n\n if (options.startVersion !== undefined) {\n if (typeof options.startVersion === 'number') {\n startVersion = BigInt(options.startVersion)\n } else {\n startVersion = options.startVersion\n }\n }\n\n return {\n startVersion: startVersion,\n address: options.address,\n network: options.network || AptosNetwork.MAIN_NET,\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { RecordMetaData } from '../gen';
2
+ import { Labels } from '../core/metadata';
3
+ import { BaseContext } from '../core/base-context';
4
+ import { Transaction_UserTransaction } from 'aptos-sdk/src/generated';
5
+ import { AptosNetwork } from './network';
6
+ export declare class AptosContext extends BaseContext {
7
+ address: string;
8
+ network: AptosNetwork;
9
+ moduleName: string;
10
+ version: bigint;
11
+ transaction: Transaction_UserTransaction;
12
+ constructor(moduleName: string, network: AptosNetwork, address: string, version: bigint, transaction?: Transaction_UserTransaction);
13
+ getMetaData(name: string, labels: Labels): RecordMetaData;
14
+ }
15
+ export declare class AptosResourceContext extends BaseContext {
16
+ address: string;
17
+ network: AptosNetwork;
18
+ version: bigint;
19
+ timestampInMicros: number;
20
+ constructor(network: AptosNetwork, address: string, version: bigint, timestampInMicros: number);
21
+ getMetaData(name: string, labels: Labels): RecordMetaData;
22
+ }