@sentio/sdk 4.0.0-rc.1 → 4.0.0-rc.3

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 (331) hide show
  1. package/lib/aptos/aptos-plugin.d.ts +1 -1
  2. package/lib/aptos/aptos-plugin.d.ts.map +1 -1
  3. package/lib/aptos/aptos-plugin.js +43 -42
  4. package/lib/aptos/aptos-plugin.js.map +1 -1
  5. package/lib/aptos/aptos-processor.d.ts +1 -1
  6. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  7. package/lib/aptos/aptos-processor.js +25 -25
  8. package/lib/aptos/aptos-processor.js.map +1 -1
  9. package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
  10. package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
  11. package/lib/aptos/aptos-resource-processor-template.js +10 -5
  12. package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
  13. package/lib/aptos/context.d.ts +1 -1
  14. package/lib/aptos/context.d.ts.map +1 -1
  15. package/lib/aptos/context.js +8 -6
  16. package/lib/aptos/context.js.map +1 -1
  17. package/lib/aptos/data.d.ts +4 -4
  18. package/lib/aptos/data.d.ts.map +1 -1
  19. package/lib/core/base-context.d.ts +3 -2
  20. package/lib/core/base-context.d.ts.map +1 -1
  21. package/lib/core/base-context.js +12 -11
  22. package/lib/core/base-context.js.map +1 -1
  23. package/lib/core/core-plugin.d.ts.map +1 -1
  24. package/lib/core/core-plugin.js +6 -4
  25. package/lib/core/core-plugin.js.map +1 -1
  26. package/lib/core/event-logger.d.ts +10 -2
  27. package/lib/core/event-logger.d.ts.map +1 -1
  28. package/lib/core/event-logger.js +42 -26
  29. package/lib/core/event-logger.js.map +1 -1
  30. package/lib/core/exporter.d.ts.map +1 -1
  31. package/lib/core/exporter.js +5 -3
  32. package/lib/core/exporter.js.map +1 -1
  33. package/lib/core/handler-options.d.ts +1 -1
  34. package/lib/core/handler-options.d.ts.map +1 -1
  35. package/lib/core/handler-register.d.ts +1 -1
  36. package/lib/core/handler-register.d.ts.map +1 -1
  37. package/lib/core/handler-register.js +2 -2
  38. package/lib/core/handler-register.js.map +1 -1
  39. package/lib/core/meter.d.ts +4 -3
  40. package/lib/core/meter.d.ts.map +1 -1
  41. package/lib/core/meter.js +5 -4
  42. package/lib/core/meter.js.map +1 -1
  43. package/lib/core/normalization.d.ts +1 -1
  44. package/lib/core/normalization.d.ts.map +1 -1
  45. package/lib/core/normalization.js +41 -31
  46. package/lib/core/normalization.js.map +1 -1
  47. package/lib/core/numberish.d.ts +1 -1
  48. package/lib/core/numberish.d.ts.map +1 -1
  49. package/lib/core/numberish.js +35 -30
  50. package/lib/core/numberish.js.map +1 -1
  51. package/lib/core/partition-handler-manager.d.ts +1 -1
  52. package/lib/core/partition-handler-manager.d.ts.map +1 -1
  53. package/lib/core/partition-handler-manager.js +10 -9
  54. package/lib/core/partition-handler-manager.js.map +1 -1
  55. package/lib/cosmos/context.d.ts.map +1 -1
  56. package/lib/cosmos/context.js +4 -2
  57. package/lib/cosmos/context.js.map +1 -1
  58. package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
  59. package/lib/cosmos/cosmos-plugin.js +11 -10
  60. package/lib/cosmos/cosmos-plugin.js.map +1 -1
  61. package/lib/cosmos/cosmos-processor.js.map +1 -1
  62. package/lib/eth/abi-decoder/decode-worker.js +2 -2
  63. package/lib/eth/abi-decoder/decode-worker.js.map +1 -1
  64. package/lib/eth/account-processor.d.ts +2 -2
  65. package/lib/eth/account-processor.d.ts.map +1 -1
  66. package/lib/eth/account-processor.js +10 -9
  67. package/lib/eth/account-processor.js.map +1 -1
  68. package/lib/eth/base-processor-template.d.ts +3 -3
  69. package/lib/eth/base-processor-template.d.ts.map +1 -1
  70. package/lib/eth/base-processor-template.js +12 -8
  71. package/lib/eth/base-processor-template.js.map +1 -1
  72. package/lib/eth/base-processor.d.ts +1 -1
  73. package/lib/eth/base-processor.d.ts.map +1 -1
  74. package/lib/eth/base-processor.js +53 -46
  75. package/lib/eth/base-processor.js.map +1 -1
  76. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  77. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +48 -46
  78. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  79. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  80. package/lib/eth/builtin/internal/erc1155-processor.js +18 -16
  81. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  82. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  83. package/lib/eth/builtin/internal/erc20-processor.js +38 -36
  84. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  85. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  86. package/lib/eth/builtin/internal/erc20bytes-processor.js +20 -18
  87. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  88. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  89. package/lib/eth/builtin/internal/erc721-processor.js +30 -28
  90. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  91. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  92. package/lib/eth/builtin/internal/weth9-processor.js +24 -22
  93. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  94. package/lib/eth/codegen/file.d.ts.map +1 -1
  95. package/lib/eth/codegen/file.js +2 -1
  96. package/lib/eth/codegen/file.js.map +1 -1
  97. package/lib/eth/codegen/function-calls.js +1 -1
  98. package/lib/eth/context.d.ts +1 -1
  99. package/lib/eth/context.d.ts.map +1 -1
  100. package/lib/eth/context.js +17 -11
  101. package/lib/eth/context.js.map +1 -1
  102. package/lib/eth/eth-plugin.d.ts.map +1 -1
  103. package/lib/eth/eth-plugin.js +83 -75
  104. package/lib/eth/eth-plugin.js.map +1 -1
  105. package/lib/eth/eth.d.ts +6 -6
  106. package/lib/eth/eth.d.ts.map +1 -1
  107. package/lib/eth/eth.js +39 -26
  108. package/lib/eth/eth.js.map +1 -1
  109. package/lib/eth/index.d.ts +1 -1
  110. package/lib/eth/index.d.ts.map +1 -1
  111. package/lib/eth/index.js +0 -1
  112. package/lib/eth/index.js.map +1 -1
  113. package/lib/fuel/asset-processor.d.ts +2 -2
  114. package/lib/fuel/asset-processor.d.ts.map +1 -1
  115. package/lib/fuel/asset-processor.js +5 -3
  116. package/lib/fuel/asset-processor.js.map +1 -1
  117. package/lib/fuel/context.d.ts.map +1 -1
  118. package/lib/fuel/context.js +4 -2
  119. package/lib/fuel/context.js.map +1 -1
  120. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  121. package/lib/fuel/fuel-plugin.js +41 -53
  122. package/lib/fuel/fuel-plugin.js.map +1 -1
  123. package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
  124. package/lib/fuel/fuel-processor-template.js +7 -5
  125. package/lib/fuel/fuel-processor-template.js.map +1 -1
  126. package/lib/fuel/fuel-processor.d.ts.map +1 -1
  127. package/lib/fuel/fuel-processor.js +30 -20
  128. package/lib/fuel/fuel-processor.js.map +1 -1
  129. package/lib/fuel/global-processor.d.ts.map +1 -1
  130. package/lib/fuel/global-processor.js +2 -1
  131. package/lib/fuel/global-processor.js.map +1 -1
  132. package/lib/fuel/types.d.ts +10 -4
  133. package/lib/fuel/types.d.ts.map +1 -1
  134. package/lib/fuel/types.js.map +1 -1
  135. package/lib/iota/context.d.ts +1 -1
  136. package/lib/iota/context.d.ts.map +1 -1
  137. package/lib/iota/context.js +8 -6
  138. package/lib/iota/context.js.map +1 -1
  139. package/lib/iota/iota-object-processor-template.d.ts +1 -1
  140. package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
  141. package/lib/iota/iota-object-processor-template.js +17 -12
  142. package/lib/iota/iota-object-processor-template.js.map +1 -1
  143. package/lib/iota/iota-object-processor.d.ts +1 -1
  144. package/lib/iota/iota-object-processor.d.ts.map +1 -1
  145. package/lib/iota/iota-object-processor.js +23 -16
  146. package/lib/iota/iota-object-processor.js.map +1 -1
  147. package/lib/iota/iota-plugin-part.d.ts +1 -1
  148. package/lib/iota/iota-plugin-part.d.ts.map +1 -1
  149. package/lib/iota/iota-plugin-part.js +16 -15
  150. package/lib/iota/iota-plugin-part.js.map +1 -1
  151. package/lib/iota/iota-processor.d.ts +1 -1
  152. package/lib/iota/iota-processor.d.ts.map +1 -1
  153. package/lib/iota/iota-processor.js +18 -17
  154. package/lib/iota/iota-processor.js.map +1 -1
  155. package/lib/iota/network.js +2 -2
  156. package/lib/iota/network.js.map +1 -1
  157. package/lib/move/filter.d.ts +1 -1
  158. package/lib/move/filter.d.ts.map +1 -1
  159. package/lib/move/index.d.ts +1 -1
  160. package/lib/move/index.d.ts.map +1 -1
  161. package/lib/move/index.js +0 -1
  162. package/lib/move/index.js.map +1 -1
  163. package/lib/solana/builtin/types.d.ts +4 -4
  164. package/lib/solana/solana-context.d.ts.map +1 -1
  165. package/lib/solana/solana-context.js +4 -3
  166. package/lib/solana/solana-context.js.map +1 -1
  167. package/lib/solana/solana-plugin.d.ts.map +1 -1
  168. package/lib/solana/solana-plugin.js +19 -18
  169. package/lib/solana/solana-plugin.js.map +1 -1
  170. package/lib/solana/solana-processor.d.ts.map +1 -1
  171. package/lib/solana/solana-processor.js +8 -3
  172. package/lib/solana/solana-processor.js.map +1 -1
  173. package/lib/store/cache.d.ts.map +1 -1
  174. package/lib/store/cache.js +22 -17
  175. package/lib/store/cache.js.map +1 -1
  176. package/lib/store/convert.d.ts +1 -1
  177. package/lib/store/convert.d.ts.map +1 -1
  178. package/lib/store/convert.js +67 -104
  179. package/lib/store/convert.js.map +1 -1
  180. package/lib/store/decorators.d.ts +1 -1
  181. package/lib/store/decorators.d.ts.map +1 -1
  182. package/lib/store/decorators.js +3 -1
  183. package/lib/store/decorators.js.map +1 -1
  184. package/lib/store/store.d.ts.map +1 -1
  185. package/lib/store/store.js +24 -16
  186. package/lib/store/store.js.map +1 -1
  187. package/lib/store/types.js +24 -32
  188. package/lib/store/types.js.map +1 -1
  189. package/lib/store/util.d.ts +1 -1
  190. package/lib/store/util.d.ts.map +1 -1
  191. package/lib/store/util.js +13 -17
  192. package/lib/store/util.js.map +1 -1
  193. package/lib/sui/context.d.ts +1 -1
  194. package/lib/sui/context.d.ts.map +1 -1
  195. package/lib/sui/context.js +8 -6
  196. package/lib/sui/context.js.map +1 -1
  197. package/lib/sui/sui-object-processor-template.d.ts +1 -1
  198. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  199. package/lib/sui/sui-object-processor-template.js +17 -12
  200. package/lib/sui/sui-object-processor-template.js.map +1 -1
  201. package/lib/sui/sui-object-processor.d.ts +1 -1
  202. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  203. package/lib/sui/sui-object-processor.js +23 -16
  204. package/lib/sui/sui-object-processor.js.map +1 -1
  205. package/lib/sui/sui-plugin-part.d.ts +1 -1
  206. package/lib/sui/sui-plugin-part.d.ts.map +1 -1
  207. package/lib/sui/sui-plugin-part.js +16 -15
  208. package/lib/sui/sui-plugin-part.js.map +1 -1
  209. package/lib/sui/sui-plugin.d.ts +1 -1
  210. package/lib/sui/sui-plugin.d.ts.map +1 -1
  211. package/lib/sui/sui-plugin.js +35 -34
  212. package/lib/sui/sui-plugin.js.map +1 -1
  213. package/lib/sui/sui-processor.d.ts +1 -1
  214. package/lib/sui/sui-processor.d.ts.map +1 -1
  215. package/lib/sui/sui-processor.js +18 -17
  216. package/lib/sui/sui-processor.js.map +1 -1
  217. package/lib/testing/aptos-facet.d.ts.map +1 -1
  218. package/lib/testing/aptos-facet.js +18 -11
  219. package/lib/testing/aptos-facet.js.map +1 -1
  220. package/lib/testing/cosmos-facet.d.ts.map +1 -1
  221. package/lib/testing/cosmos-facet.js +10 -6
  222. package/lib/testing/cosmos-facet.js.map +1 -1
  223. package/lib/testing/eth-facet.d.ts +1 -1
  224. package/lib/testing/eth-facet.d.ts.map +1 -1
  225. package/lib/testing/eth-facet.js +34 -18
  226. package/lib/testing/eth-facet.js.map +1 -1
  227. package/lib/testing/fuel-facet.d.ts.map +1 -1
  228. package/lib/testing/fuel-facet.js +28 -18
  229. package/lib/testing/fuel-facet.js.map +1 -1
  230. package/lib/testing/iota-facet.d.ts.map +1 -1
  231. package/lib/testing/iota-facet.js +32 -20
  232. package/lib/testing/iota-facet.js.map +1 -1
  233. package/lib/testing/memory-database.d.ts +11 -3
  234. package/lib/testing/memory-database.d.ts.map +1 -1
  235. package/lib/testing/memory-database.js +84 -71
  236. package/lib/testing/memory-database.js.map +1 -1
  237. package/lib/testing/metric-utils.d.ts +2 -2
  238. package/lib/testing/metric-utils.d.ts.map +1 -1
  239. package/lib/testing/metric-utils.js +13 -12
  240. package/lib/testing/metric-utils.js.map +1 -1
  241. package/lib/testing/solana-facet.d.ts +3 -2
  242. package/lib/testing/solana-facet.d.ts.map +1 -1
  243. package/lib/testing/solana-facet.js +8 -5
  244. package/lib/testing/solana-facet.js.map +1 -1
  245. package/lib/testing/sui-facet.d.ts.map +1 -1
  246. package/lib/testing/sui-facet.js +30 -20
  247. package/lib/testing/sui-facet.js.map +1 -1
  248. package/lib/testing/test-processor-server.d.ts +1453 -16
  249. package/lib/testing/test-processor-server.d.ts.map +1 -1
  250. package/lib/testing/test-processor-server.js +108 -45
  251. package/lib/testing/test-processor-server.js.map +1 -1
  252. package/lib/utils/price.d.ts +1 -1
  253. package/lib/utils/price.d.ts.map +1 -1
  254. package/lib/utils/price.js +19 -12
  255. package/lib/utils/price.js.map +1 -1
  256. package/package.json +5 -7
  257. package/src/aptos/aptos-plugin.ts +105 -91
  258. package/src/aptos/aptos-processor.ts +33 -25
  259. package/src/aptos/aptos-resource-processor-template.ts +15 -6
  260. package/src/aptos/context.ts +8 -7
  261. package/src/aptos/data.ts +4 -4
  262. package/src/core/base-context.ts +19 -12
  263. package/src/core/core-plugin.ts +10 -7
  264. package/src/core/event-logger.ts +63 -34
  265. package/src/core/exporter.ts +5 -4
  266. package/src/core/handler-options.ts +1 -1
  267. package/src/core/handler-register.ts +3 -3
  268. package/src/core/meter.ts +9 -7
  269. package/src/core/normalization.ts +53 -31
  270. package/src/core/numberish.ts +46 -30
  271. package/src/core/partition-handler-manager.ts +13 -11
  272. package/src/cosmos/context.ts +4 -3
  273. package/src/cosmos/cosmos-plugin.ts +19 -15
  274. package/src/cosmos/cosmos-processor.ts +2 -2
  275. package/src/eth/abi-decoder/decode-worker.ts +2 -2
  276. package/src/eth/account-processor.ts +21 -12
  277. package/src/eth/base-processor-template.ts +22 -10
  278. package/src/eth/base-processor.ts +66 -54
  279. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
  280. package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
  281. package/src/eth/builtin/internal/erc20-processor.ts +152 -91
  282. package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
  283. package/src/eth/builtin/internal/erc721-processor.ts +109 -65
  284. package/src/eth/builtin/internal/weth9-processor.ts +95 -56
  285. package/src/eth/codegen/file.ts +2 -1
  286. package/src/eth/codegen/function-calls.ts +1 -1
  287. package/src/eth/context.ts +29 -13
  288. package/src/eth/eth-plugin.ts +135 -118
  289. package/src/eth/eth.ts +46 -32
  290. package/src/eth/index.ts +1 -1
  291. package/src/fuel/asset-processor.ts +16 -8
  292. package/src/fuel/context.ts +4 -3
  293. package/src/fuel/fuel-plugin.ts +71 -73
  294. package/src/fuel/fuel-processor-template.ts +7 -6
  295. package/src/fuel/fuel-processor.ts +35 -23
  296. package/src/fuel/global-processor.ts +3 -3
  297. package/src/fuel/types.ts +10 -4
  298. package/src/iota/context.ts +8 -7
  299. package/src/iota/iota-object-processor-template.ts +25 -15
  300. package/src/iota/iota-object-processor.ts +33 -22
  301. package/src/iota/iota-plugin-part.ts +41 -34
  302. package/src/iota/iota-processor.ts +25 -17
  303. package/src/iota/network.ts +2 -2
  304. package/src/move/filter.ts +1 -1
  305. package/src/move/index.ts +1 -1
  306. package/src/solana/solana-context.ts +4 -3
  307. package/src/solana/solana-plugin.ts +27 -24
  308. package/src/solana/solana-processor.ts +14 -6
  309. package/src/store/cache.ts +22 -18
  310. package/src/store/convert.ts +68 -104
  311. package/src/store/decorators.ts +3 -2
  312. package/src/store/store.ts +30 -22
  313. package/src/store/types.ts +24 -33
  314. package/src/store/util.ts +13 -18
  315. package/src/sui/context.ts +8 -7
  316. package/src/sui/sui-object-processor-template.ts +25 -15
  317. package/src/sui/sui-object-processor.ts +33 -22
  318. package/src/sui/sui-plugin-part.ts +41 -34
  319. package/src/sui/sui-plugin.ts +49 -47
  320. package/src/sui/sui-processor.ts +25 -17
  321. package/src/testing/aptos-facet.ts +18 -11
  322. package/src/testing/cosmos-facet.ts +10 -6
  323. package/src/testing/eth-facet.ts +40 -18
  324. package/src/testing/fuel-facet.ts +28 -18
  325. package/src/testing/iota-facet.ts +32 -20
  326. package/src/testing/memory-database.ts +126 -88
  327. package/src/testing/metric-utils.ts +15 -14
  328. package/src/testing/solana-facet.ts +11 -6
  329. package/src/testing/sui-facet.ts +30 -20
  330. package/src/testing/test-processor-server.ts +169 -79
  331. package/src/utils/price.ts +20 -13
@@ -2,21 +2,27 @@ import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager,
2
2
  import { PartitionHandlerManager } from '../core/index.js'
3
3
  import { HandlerRegister } from '../core/handler-register.js'
4
4
  import {
5
- AccountConfig,
6
- ContractConfig,
7
- DataBinding,
5
+ AccountConfigSchema,
6
+ ContractConfigSchema,
7
+ type DataBinding,
8
8
  HandlerType,
9
- InitResponse,
10
- MoveCallHandlerConfig,
11
- MoveEventHandlerConfig,
9
+ type InitResponse,
10
+ type MoveCallHandlerConfig,
11
+ MoveCallHandlerConfigSchema,
12
+ type MoveEventHandlerConfig,
13
+ MoveEventHandlerConfigSchema,
14
+ MoveOnIntervalConfigSchema,
12
15
  MoveOwnerType,
13
- ProcessConfigResponse,
14
- ProcessResult,
15
- ProcessStreamResponse_Partitions,
16
- StartRequest
16
+ MoveResourceChangeConfigSchema,
17
+ type ProcessConfigResponse,
18
+ type ProcessResult,
19
+ type ProcessStreamResponse_Partitions,
20
+ ProcessStreamResponse_PartitionsSchema,
21
+ type StartRequest
17
22
  } from '@sentio/protos'
23
+ import { create } from '@bufbuild/protobuf'
18
24
 
19
- import { ServerError, Status } from 'nice-grpc'
25
+ import { ConnectError, Code } from '@connectrpc/connect'
20
26
 
21
27
  import { AptosProcessorState, AptosResourceProcessorState } from './aptos-processor.js'
22
28
 
@@ -61,7 +67,7 @@ export class AptosPlugin extends Plugin {
61
67
  network: <AptosNetwork>instance.contract?.chainId || AptosNetwork.MAIN_NET,
62
68
  startVersion: instance.startBlock || 0n,
63
69
  endVersion: instance.endBlock,
64
- baseLabels: instance.baseLabels
70
+ baseLabels: instance.baseLabels as { [key: string]: string } | undefined
65
71
  },
66
72
  NoopContext
67
73
  )
@@ -75,7 +81,7 @@ export class AptosPlugin extends Plugin {
75
81
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
76
82
  continue
77
83
  }
78
- const contractConfig = ContractConfig.fromPartial({
84
+ const contractConfig = create(ContractConfigSchema, {
79
85
  processorType: USER_PROCESSOR,
80
86
  contract: {
81
87
  name: aptosProcessor.moduleName,
@@ -90,7 +96,7 @@ export class AptosPlugin extends Plugin {
90
96
  for (const handler of aptosProcessor.eventHandlers) {
91
97
  const handlerId = this.handlerRegister.register(handler.handler, chainId)
92
98
  this.partitionManager.registerPartitionHandler(HandlerType.APT_EVENT, handlerId, handler.partitionHandler)
93
- const eventHandlerConfig: MoveEventHandlerConfig = {
99
+ const eventHandlerConfig: MoveEventHandlerConfig = create(MoveEventHandlerConfigSchema, {
94
100
  filters: handler.filters.map((f) => {
95
101
  return {
96
102
  type: f.type,
@@ -101,7 +107,7 @@ export class AptosPlugin extends Plugin {
101
107
  fetchConfig: handler.fetchConfig,
102
108
  handlerId,
103
109
  handlerName: handler.handlerName
104
- }
110
+ })
105
111
  contractConfig.moveEventConfigs.push(eventHandlerConfig)
106
112
  }
107
113
 
@@ -109,7 +115,7 @@ export class AptosPlugin extends Plugin {
109
115
  for (const handler of aptosProcessor.callHandlers) {
110
116
  const handlerId = this.handlerRegister.register(handler.handler, chainId)
111
117
  this.partitionManager.registerPartitionHandler(HandlerType.APT_CALL, handlerId, handler.partitionHandler)
112
- const functionHandlerConfig: MoveCallHandlerConfig = {
118
+ const functionHandlerConfig: MoveCallHandlerConfig = create(MoveCallHandlerConfigSchema, {
113
119
  filters: handler.filters.map((filter) => {
114
120
  return {
115
121
  function: filter.function,
@@ -123,7 +129,7 @@ export class AptosPlugin extends Plugin {
123
129
  fetchConfig: handler.fetchConfig,
124
130
  handlerId,
125
131
  handlerName: handler.handlerName
126
- }
132
+ })
127
133
  contractConfig.moveCallConfigs.push(functionHandlerConfig)
128
134
  }
129
135
 
@@ -131,21 +137,23 @@ export class AptosPlugin extends Plugin {
131
137
  for (const handler of aptosProcessor.transactionIntervalHandlers) {
132
138
  const handlerId = this.handlerRegister.register(handler.handler, chainId)
133
139
  this.partitionManager.registerPartitionHandler(HandlerType.APT_CALL, handlerId, handler.partitionHandler)
134
- contractConfig.moveIntervalConfigs.push({
135
- intervalConfig: {
136
- handlerId: handlerId,
137
- handlerName: handler.handlerName,
138
- minutes: 0,
139
- minutesInterval: handler.timeIntervalInMinutes,
140
- slot: 0,
141
- slotInterval: handler.versionInterval,
142
- fetchConfig: undefined
143
- },
144
- ownerType: MoveOwnerType.ADDRESS,
145
- fetchConfig: handler.fetchConfig,
146
- resourceFetchConfig: undefined,
147
- type: ''
148
- })
140
+ contractConfig.moveIntervalConfigs.push(
141
+ create(MoveOnIntervalConfigSchema, {
142
+ intervalConfig: {
143
+ handlerId: handlerId,
144
+ handlerName: handler.handlerName,
145
+ minutes: 0,
146
+ minutesInterval: handler.timeIntervalInMinutes,
147
+ slot: 0,
148
+ slotInterval: handler.versionInterval,
149
+ fetchConfig: undefined
150
+ },
151
+ ownerType: MoveOwnerType.ADDRESS,
152
+ fetchConfig: handler.fetchConfig,
153
+ resourceFetchConfig: undefined,
154
+ type: ''
155
+ })
156
+ )
149
157
  }
150
158
 
151
159
  config.contractConfigs.push(contractConfig)
@@ -157,7 +165,7 @@ export class AptosPlugin extends Plugin {
157
165
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
158
166
  continue
159
167
  }
160
- const accountConfig = AccountConfig.fromPartial({
168
+ const accountConfig = create(AccountConfigSchema, {
161
169
  address: aptosProcessor.config.address,
162
170
  chainId: aptosProcessor.getChainId(),
163
171
  startBlock: aptosProcessor.config.startVersion,
@@ -166,12 +174,14 @@ export class AptosPlugin extends Plugin {
166
174
  for (const handler of aptosProcessor.resourceChangeHandlers) {
167
175
  const handlerId = this.handlerRegister.register(handler.handler, chainId)
168
176
  this.partitionManager.registerPartitionHandler(HandlerType.APT_RESOURCE, handlerId, handler.partitionHandler)
169
- accountConfig.moveResourceChangeConfigs.push({
170
- handlerId: handlerId,
171
- handlerName: handler.handlerName,
172
- types: typeof handler.type === 'string' ? [handler.type] : handler.type,
173
- includeDeleted: false
174
- })
177
+ accountConfig.moveResourceChangeConfigs.push(
178
+ create(MoveResourceChangeConfigSchema, {
179
+ handlerId: handlerId,
180
+ handlerName: handler.handlerName,
181
+ types: typeof handler.type === 'string' ? [handler.type] : handler.type,
182
+ includeDeleted: false
183
+ })
184
+ )
175
185
  }
176
186
 
177
187
  config.accountConfigs.push(accountConfig)
@@ -182,7 +192,7 @@ export class AptosPlugin extends Plugin {
182
192
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
183
193
  continue
184
194
  }
185
- const accountConfig = AccountConfig.fromPartial({
195
+ const accountConfig = create(AccountConfigSchema, {
186
196
  address: aptosProcessor.config.address,
187
197
  chainId: aptosProcessor.getChainId(),
188
198
  startBlock: aptosProcessor.config.startVersion,
@@ -192,29 +202,33 @@ export class AptosPlugin extends Plugin {
192
202
  const handlerId = this.handlerRegister.register(handler.handler, chainId)
193
203
  this.partitionManager.registerPartitionHandler(HandlerType.APT_RESOURCE, handlerId, handler.partitionHandler)
194
204
  if (handler.timeIntervalInMinutes || handler.versionInterval) {
195
- accountConfig.moveIntervalConfigs.push({
196
- intervalConfig: {
197
- handlerId: handlerId,
198
- handlerName: handler.handlerName,
199
- minutes: 0,
200
- minutesInterval: handler.timeIntervalInMinutes,
201
- slot: 0,
202
- slotInterval: handler.versionInterval,
205
+ accountConfig.moveIntervalConfigs.push(
206
+ create(MoveOnIntervalConfigSchema, {
207
+ intervalConfig: {
208
+ handlerId: handlerId,
209
+ handlerName: handler.handlerName,
210
+ minutes: 0,
211
+ minutesInterval: handler.timeIntervalInMinutes,
212
+ slot: 0,
213
+ slotInterval: handler.versionInterval,
214
+ fetchConfig: undefined
215
+ },
216
+ type: (Array.isArray(handler.type) ? handler.type[0] : handler.type) || '',
217
+ ownerType: MoveOwnerType.ADDRESS,
218
+ resourceFetchConfig: handler.fetchConfig,
203
219
  fetchConfig: undefined
204
- },
205
- type: (Array.isArray(handler.type) ? handler.type[0] : handler.type) || '',
206
- ownerType: MoveOwnerType.ADDRESS,
207
- resourceFetchConfig: handler.fetchConfig,
208
- fetchConfig: undefined
209
- })
220
+ })
221
+ )
210
222
  } else if (handler.type) {
211
223
  // on resource change
212
- accountConfig.moveResourceChangeConfigs.push({
213
- handlerId,
214
- handlerName: handler.handlerName,
215
- types: typeof handler.type == 'string' ? [handler.type] : handler.type,
216
- includeDeleted: false
217
- })
224
+ accountConfig.moveResourceChangeConfigs.push(
225
+ create(MoveResourceChangeConfigSchema, {
226
+ handlerId,
227
+ handlerName: handler.handlerName,
228
+ types: typeof handler.type == 'string' ? [handler.type] : handler.type,
229
+ includeDeleted: false
230
+ })
231
+ )
218
232
  }
219
233
  }
220
234
  config.accountConfigs.push(accountConfig)
@@ -232,7 +246,7 @@ export class AptosPlugin extends Plugin {
232
246
  case HandlerType.APT_RESOURCE:
233
247
  return this.processAptosResource(request)
234
248
  default:
235
- throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
249
+ throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
236
250
  }
237
251
  }
238
252
 
@@ -240,42 +254,42 @@ export class AptosPlugin extends Plugin {
240
254
  let data: any
241
255
  switch (request.handlerType) {
242
256
  case HandlerType.APT_EVENT:
243
- if (!request.data?.aptEvent) {
244
- throw new ServerError(Status.INVALID_ARGUMENT, "aptEvent can't be empty")
257
+ if (request.data?.value.case !== 'aptEvent') {
258
+ throw new ConnectError("aptEvent can't be empty", Code.InvalidArgument)
245
259
  }
246
- data = new AptEvent(request.data.aptEvent)
260
+ data = new AptEvent(request.data.value.value)
247
261
  break
248
262
  case HandlerType.APT_CALL:
249
- if (!request.data?.aptCall) {
250
- throw new ServerError(Status.INVALID_ARGUMENT, "aptCall can't be empty")
263
+ if (request.data?.value.case !== 'aptCall') {
264
+ throw new ConnectError("aptCall can't be empty", Code.InvalidArgument)
251
265
  }
252
- data = new AptCall(request.data.aptCall)
266
+ data = new AptCall(request.data.value.value)
253
267
  break
254
268
  case HandlerType.APT_RESOURCE:
255
- if (!request.data?.aptResource) {
256
- throw new ServerError(Status.INVALID_ARGUMENT, "aptResource can't be empty")
269
+ if (request.data?.value.case !== 'aptResource') {
270
+ throw new ConnectError("aptResource can't be empty", Code.InvalidArgument)
257
271
  }
258
- data = new AptResource(request.data.aptResource)
272
+ data = new AptResource(request.data.value.value)
259
273
  break
260
274
  default:
261
- throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
275
+ throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
262
276
  }
263
277
  const partitions = await this.partitionManager.processPartitionForHandlerType(
264
278
  request.handlerType,
265
279
  request.handlerIds,
266
280
  data
267
281
  )
268
- return {
282
+ return create(ProcessStreamResponse_PartitionsSchema, {
269
283
  partitions
270
- }
284
+ })
271
285
  }
272
286
 
273
287
  async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {
274
- if (!binding.data?.aptEvent) {
275
- throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
288
+ if (binding.data?.value.case !== 'aptEvent') {
289
+ throw new ConnectError("Event can't be empty", Code.InvalidArgument)
276
290
  }
277
291
  const promises: Promise<ProcessResult>[] = []
278
- const event = new AptEvent(binding.data.aptEvent)
292
+ const event = new AptEvent(binding.data.value.value)
279
293
 
280
294
  for (const handlerId of binding.handlerIds) {
281
295
  const promise = this.handlerRegister
@@ -284,9 +298,9 @@ export class AptosPlugin extends Plugin {
284
298
  handlerId
285
299
  )(event)
286
300
  .catch((e: any) => {
287
- throw new ServerError(
288
- Status.INTERNAL,
289
- 'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
301
+ throw new ConnectError(
302
+ 'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e),
303
+ Code.Internal
290
304
  )
291
305
  })
292
306
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -298,10 +312,10 @@ export class AptosPlugin extends Plugin {
298
312
  }
299
313
 
300
314
  async processAptosResource(binding: DataBinding): Promise<ProcessResult> {
301
- if (!binding.data?.aptResource) {
302
- throw new ServerError(Status.INVALID_ARGUMENT, "Resource can't be empty")
315
+ if (binding.data?.value.case !== 'aptResource') {
316
+ throw new ConnectError("Resource can't be empty", Code.InvalidArgument)
303
317
  }
304
- const resource = new AptResource(binding.data.aptResource)
318
+ const resource = new AptResource(binding.data.value.value)
305
319
 
306
320
  const promises: Promise<ProcessResult>[] = []
307
321
  for (const handlerId of binding.handlerIds) {
@@ -311,9 +325,9 @@ export class AptosPlugin extends Plugin {
311
325
  handlerId
312
326
  )(resource)
313
327
  .catch((e: any) => {
314
- throw new ServerError(
315
- Status.INTERNAL,
316
- 'error processing resource: ' + JSON.stringify(resource) + '\n' + errorString(e)
328
+ throw new ConnectError(
329
+ 'error processing resource: ' + JSON.stringify(resource) + '\n' + errorString(e),
330
+ Code.Internal
317
331
  )
318
332
  })
319
333
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -325,10 +339,10 @@ export class AptosPlugin extends Plugin {
325
339
  }
326
340
 
327
341
  async processAptosFunctionCall(binding: DataBinding): Promise<ProcessResult> {
328
- if (!binding.data?.aptCall) {
329
- throw new ServerError(Status.INVALID_ARGUMENT, "Call can't be empty")
342
+ if (binding.data?.value.case !== 'aptCall') {
343
+ throw new ConnectError("Call can't be empty", Code.InvalidArgument)
330
344
  }
331
- const call = new AptCall(binding.data.aptCall)
345
+ const call = new AptCall(binding.data.value.value)
332
346
 
333
347
  const promises: Promise<ProcessResult>[] = []
334
348
  for (const handlerId of binding.handlerIds) {
@@ -339,9 +353,9 @@ export class AptosPlugin extends Plugin {
339
353
  handlerId
340
354
  )(call)
341
355
  .catch((e: any) => {
342
- throw new ServerError(
343
- Status.INTERNAL,
344
- 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e)
356
+ throw new ConnectError(
357
+ 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e),
358
+ Code.Internal
345
359
  )
346
360
  })
347
361
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -11,8 +11,17 @@ import {
11
11
  import { AptosBindOptions, AptosNetwork } from './network.js'
12
12
  import { AptosContext, AptosResourcesContext, AptosTransactionContext } from './context.js'
13
13
  import { ListStateStorage } from '@sentio/runtime'
14
- import { Data_AptResource, HandleInterval, MoveAccountFetchConfig, MoveFetchConfig } from '@sentio/protos'
15
- import { ServerError, Status } from 'nice-grpc'
14
+ import {
15
+ type Data_AptResource,
16
+ type HandleInterval,
17
+ HandleIntervalSchema,
18
+ type MoveAccountFetchConfig,
19
+ MoveAccountFetchConfigSchema,
20
+ type MoveFetchConfig,
21
+ MoveFetchConfigSchema
22
+ } from '@sentio/protos'
23
+ import { create } from '@bufbuild/protobuf'
24
+ import { ConnectError, Code } from '@connectrpc/connect'
16
25
  import {
17
26
  accountTypeString,
18
27
  CallHandler,
@@ -34,17 +43,17 @@ import { GeneralTransactionResponse, HandlerOptions } from './models.js'
34
43
  import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
35
44
  import { AptCall, AptEvent, AptResource } from './data.js'
36
45
 
37
- const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
46
+ const DEFAULT_FETCH_CONFIG: MoveFetchConfig = create(MoveFetchConfigSchema, {
38
47
  resourceChanges: false,
39
48
  allEvents: true,
40
49
  inputs: true,
41
50
  // for backward compatibility
42
51
  supportMultisigFunc: true
43
- }
52
+ })
44
53
 
45
- export const DEFAULT_RESOURCE_FETCH_CONFIG: MoveAccountFetchConfig = {
54
+ export const DEFAULT_RESOURCE_FETCH_CONFIG: MoveAccountFetchConfig = create(MoveAccountFetchConfigSchema, {
46
55
  owned: true
47
- }
56
+ })
48
57
 
49
58
  type IndexConfigure = {
50
59
  address: string
@@ -84,7 +93,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
84
93
  handlerOptions?: HandlerOptions<MoveFetchConfig, T>
85
94
  ): this {
86
95
  let _filters: EventFilter[] = []
87
- const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
96
+ const _fetchConfig = create(MoveFetchConfigSchema, { ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
88
97
 
89
98
  if (Array.isArray(filter)) {
90
99
  _filters = filter
@@ -100,7 +109,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
100
109
  handlerName: getHandlerName(),
101
110
  handler: async function (data) {
102
111
  if (!data.rawTransaction) {
103
- throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
112
+ throw new ConnectError('event is null', Code.InvalidArgument)
104
113
  }
105
114
  const txn = data.transaction
106
115
 
@@ -143,7 +152,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
143
152
  handlerOptions?: HandlerOptions<MoveFetchConfig, T>
144
153
  ): this {
145
154
  let _filters: FunctionNameAndCallFilter[] = []
146
- const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
155
+ const _fetchConfig = create(MoveFetchConfigSchema, { ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
147
156
 
148
157
  if (Array.isArray(filter)) {
149
158
  _filters = filter
@@ -159,7 +168,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
159
168
  handlerName: getHandlerName(),
160
169
  handler: async function (data) {
161
170
  if (!data.rawTransaction) {
162
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
171
+ throw new ConnectError('call is null', Code.InvalidArgument)
163
172
  }
164
173
  const tx = data.transaction
165
174
 
@@ -201,7 +210,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
201
210
  },
202
211
  handleOptions?: HandlerOptions<MoveFetchConfig, UserTransactionResponse>
203
212
  ): this {
204
- const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handleOptions })
213
+ const _fetchConfig = create(MoveFetchConfigSchema, { ...DEFAULT_FETCH_CONFIG, ...handleOptions })
205
214
 
206
215
  const processor = this
207
216
  const filter: FunctionNameAndCallFilter = { function: '', includeFailed: transactionFilter?.includeFailed }
@@ -216,7 +225,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
216
225
  handlerName: getHandlerName(),
217
226
  handler: async function (data) {
218
227
  if (!data.rawTransaction) {
219
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
228
+ throw new ConnectError('call is null', Code.InvalidArgument)
220
229
  }
221
230
  const call = data.transaction
222
231
  const ctx = new AptosContext(
@@ -287,9 +296,8 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
287
296
  handlerName: getHandlerName(),
288
297
  handler: async function (data) {
289
298
  if (!data.rawResources || !data.version) {
290
- throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
299
+ throw new ConnectError('resource is null', Code.InvalidArgument)
291
300
  }
292
- const aptResource = new AptResource(data)
293
301
  const timestamp = Number(data.timestampMicros)
294
302
  const ctx = new AptosResourcesContext(
295
303
  processor.config.network,
@@ -298,7 +306,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
298
306
  timestamp,
299
307
  processor.config.baseLabels
300
308
  )
301
- let resources = await aptResource.decodeResources<T>(processor.coder)
309
+ let resources = await data.decodeResources<T>(processor.coder)
302
310
 
303
311
  if (hasAny) {
304
312
  resources = resources.filter((r) => {
@@ -337,12 +345,12 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
337
345
  handlerName: getHandlerName(),
338
346
  handler: async function (data) {
339
347
  if (!data.rawTransaction) {
340
- throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
348
+ throw new ConnectError('call is null', Code.InvalidArgument)
341
349
  }
342
350
  const transaction = JSON.parse(data.rawTransaction) as T
343
351
  const timestampMicros = BigInt(transaction.timestamp)
344
352
  if (timestampMicros > Number.MAX_SAFE_INTEGER) {
345
- throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
353
+ throw new ConnectError('timestamp is too large', Code.InvalidArgument)
346
354
  }
347
355
 
348
356
  const ctx = new AptosTransactionContext(
@@ -381,10 +389,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
381
389
  ): this {
382
390
  return this.onInterval(
383
391
  handler,
384
- {
392
+ create(HandleIntervalSchema, {
385
393
  recentInterval: timeIntervalInMinutes,
386
394
  backfillInterval: backfillTimeIntervalInMinutes
387
- },
395
+ }),
388
396
  undefined,
389
397
  handlerOptions
390
398
  )
@@ -399,7 +407,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
399
407
  return this.onInterval(
400
408
  handler,
401
409
  undefined,
402
- { recentInterval: versionInterval, backfillInterval: backfillVersionInterval },
410
+ create(HandleIntervalSchema, { recentInterval: versionInterval, backfillInterval: backfillVersionInterval }),
403
411
  handlerOptions
404
412
  )
405
413
  }
@@ -521,7 +529,7 @@ export class AptosResourcesProcessor {
521
529
  handlerName,
522
530
  handler: async function (data) {
523
531
  if (data.timestampMicros > Number.MAX_SAFE_INTEGER) {
524
- throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
532
+ throw new ConnectError('timestamp is too large', Code.InvalidArgument)
525
533
  }
526
534
  const aptResource = new AptResource(data)
527
535
  const timestamp = Number(data.timestampMicros)
@@ -562,10 +570,10 @@ export class AptosResourcesProcessor {
562
570
  ): this {
563
571
  return this.onInterval(
564
572
  handler,
565
- {
573
+ create(HandleIntervalSchema, {
566
574
  recentInterval: timeIntervalInMinutes,
567
575
  backfillInterval: backfillTimeIntervalInMinutes
568
- },
576
+ }),
569
577
  undefined,
570
578
  type,
571
579
  handlerOptions
@@ -582,7 +590,7 @@ export class AptosResourcesProcessor {
582
590
  return this.onInterval(
583
591
  handler,
584
592
  undefined,
585
- { recentInterval: versionInterval, backfillInterval: backfillVersionInterval },
593
+ create(HandleIntervalSchema, { recentInterval: versionInterval, backfillInterval: backfillVersionInterval }),
586
594
  typePrefix,
587
595
  handlerOptions
588
596
  )
@@ -622,7 +630,7 @@ export class AptosResourcesProcessor {
622
630
  const timestamp = Number(data.timestampMicros)
623
631
 
624
632
  if (!data.rawResources || !data.version) {
625
- throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
633
+ throw new ConnectError('resource is null', Code.InvalidArgument)
626
634
  }
627
635
  const aptResource = new AptResource(data)
628
636
  const ctx = new AptosResourcesContext(
@@ -2,7 +2,13 @@ import { ListStateStorage, processMetrics } from '@sentio/runtime'
2
2
  import { AptosResourcesContext } from './context.js'
3
3
  import { AptosBindOptions } from './network.js'
4
4
  import { AptosResourcesProcessor, DEFAULT_RESOURCE_FETCH_CONFIG } from './aptos-processor.js'
5
- import { HandleInterval, MoveAccountFetchConfig, TemplateInstance } from '@sentio/protos'
5
+ import {
6
+ type HandleInterval,
7
+ HandleIntervalSchema,
8
+ type MoveAccountFetchConfig,
9
+ TemplateInstanceSchema
10
+ } from '@sentio/protos'
11
+ import { create } from '@bufbuild/protobuf'
6
12
  import { MoveResource } from '@aptos-labs/ts-sdk'
7
13
  import { PromiseOrVoid } from '../core/index.js'
8
14
  import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
@@ -40,7 +46,7 @@ export class AptosResourceProcessorTemplate {
40
46
  options.network = options.network || ctx.network
41
47
  options.startVersion = options.startVersion || ctx.version
42
48
 
43
- const instance: TemplateInstance = {
49
+ const instance = create(TemplateInstanceSchema, {
44
50
  templateId: this.id,
45
51
  contract: {
46
52
  name: '',
@@ -51,7 +57,7 @@ export class AptosResourceProcessorTemplate {
51
57
  startBlock: options.startVersion ? BigInt(options.startVersion) : 0n,
52
58
  endBlock: options.endVersion ? BigInt(options.endVersion) : 0n,
53
59
  baseLabels: options.baseLabels
54
- }
60
+ })
55
61
 
56
62
  ctx.sendTemplateInstance(instance)
57
63
 
@@ -119,10 +125,10 @@ export class AptosResourceProcessorTemplate {
119
125
  ): this {
120
126
  return this.onInterval(
121
127
  handler,
122
- {
128
+ create(HandleIntervalSchema, {
123
129
  recentInterval: timeIntervalInMinutes,
124
130
  backfillInterval: backfillTimeIntervalInMinutes
125
- },
131
+ }),
126
132
  undefined,
127
133
  type,
128
134
  handlerOptions
@@ -139,7 +145,10 @@ export class AptosResourceProcessorTemplate {
139
145
  return this.onInterval(
140
146
  handler,
141
147
  undefined,
142
- { recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
148
+ create(HandleIntervalSchema, {
149
+ recentInterval: checkpointInterval,
150
+ backfillInterval: backfillCheckpointInterval
151
+ }),
143
152
  type,
144
153
  handlerOptions
145
154
  )
@@ -1,4 +1,5 @@
1
- import { RecordMetaData } from '@sentio/protos'
1
+ import { type RecordMetaData, RecordMetaDataSchema } from '@sentio/protos'
2
+ import { create } from '@bufbuild/protobuf'
2
3
  import { type Labels, normalizeLabels } from '../index.js'
3
4
  import { MoveCoder, RichAptosClientWithContext } from './index.js'
4
5
  import {
@@ -12,7 +13,7 @@ import {
12
13
  import { defaultMoveCoder } from './move-coder.js'
13
14
  import { AptosNetwork } from './network.js'
14
15
  import { Endpoints } from '@sentio/runtime'
15
- import { ServerError, Status } from 'nice-grpc'
16
+ import { ConnectError, Code } from '@connectrpc/connect'
16
17
  import { MoveContext } from '../move/index.js'
17
18
  import { GeneralTransactionResponse } from './models.js'
18
19
 
@@ -30,7 +31,7 @@ export abstract class AptosBaseContext extends MoveContext<AptosNetwork, MoveMod
30
31
  getClient(): RichAptosClientWithContext {
31
32
  const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)
32
33
  if (!chainServer) {
33
- throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
34
+ throw new ConnectError('RPC endpoint not provided', Code.Internal)
34
35
  }
35
36
  const fullnode = chainServer + '/v1'
36
37
 
@@ -86,7 +87,7 @@ export class AptosTransactionContext<T extends GeneralTransactionResponse> exten
86
87
  }
87
88
 
88
89
  getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
89
- return {
90
+ return create(RecordMetaDataSchema, {
90
91
  address: this.address,
91
92
  contractName: this.moduleName,
92
93
  blockNumber: this.version,
@@ -96,7 +97,7 @@ export class AptosTransactionContext<T extends GeneralTransactionResponse> exten
96
97
  chainId: this.getChainId(),
97
98
  name: name,
98
99
  labels: normalizeLabels(labels)
99
- }
100
+ })
100
101
  }
101
102
  }
102
103
 
@@ -120,7 +121,7 @@ export class AptosResourcesContext extends AptosBaseContext {
120
121
  }
121
122
 
122
123
  getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
123
- return {
124
+ return create(RecordMetaDataSchema, {
124
125
  address: this.address,
125
126
  contractName: 'resources',
126
127
  blockNumber: this.version,
@@ -130,6 +131,6 @@ export class AptosResourcesContext extends AptosBaseContext {
130
131
  chainId: this.getChainId(),
131
132
  name: name,
132
133
  labels: normalizeLabels(labels)
133
- }
134
+ })
134
135
  }
135
136
  }