@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
@@ -1,31 +1,35 @@
1
1
  import {
2
- AccountConfig,
3
- ContractConfig,
4
- DataBinding,
5
- DeepPartial,
6
- Empty,
7
- PreprocessStreamRequest,
8
- PreprocessStreamResponse,
9
- ProcessBindingResponse,
10
- ProcessBindingsRequest,
11
- ProcessConfigRequest,
12
- ProcessConfigResponse,
13
- ProcessorServiceImplementation,
14
- ProcessStreamRequest,
15
- ProcessStreamResponse,
16
- ServerStreamingMethodResult,
17
- StartRequest,
18
- TemplateInstance,
19
- TimeseriesResult
2
+ type AccountConfig,
3
+ type ContractConfig,
4
+ type DataBinding,
5
+ type DBResponse,
6
+ type Empty,
7
+ EmptySchema,
8
+ type ProcessBindingResponse,
9
+ ProcessBindingResponseSchema,
10
+ ProcessBindingsRequestSchema,
11
+ ProcessConfigRequestSchema,
12
+ type ProcessConfigResponse,
13
+ type ProcessResult,
14
+ type ProcessStreamRequest,
15
+ ProcessStreamRequestSchema,
16
+ ProcessStreamResponseV3Schema,
17
+ StartRequestSchema,
18
+ type TemplateInstance,
19
+ TemplateInstanceSchema,
20
+ type TimeseriesResult,
21
+ UpdateTemplatesRequestSchema
20
22
  } from '@sentio/protos'
21
- import { CallContext } from 'nice-grpc-common'
23
+ import { create, type MessageInitShape } from '@bufbuild/protobuf'
24
+ import { type HandlerContext } from '@connectrpc/connect'
22
25
  import {
26
+ DataBindingContext,
23
27
  Endpoints,
24
28
  IDataBindingContext,
29
+ mergeProcessResults,
25
30
  PluginManager,
26
- ProcessorServiceImpl,
27
31
  State,
28
- StoreContext
32
+ ProcessorServiceImplV3
29
33
  } from '@sentio/runtime'
30
34
 
31
35
  import { AptosFacet } from './aptos-facet.js'
@@ -40,7 +44,9 @@ import { DatabaseSchemaState } from '../core/database-schema.js'
40
44
  import { IotaFacet } from './iota-facet.js'
41
45
  import { ChainInfo } from '@sentio/chain'
42
46
 
43
- export const TEST_CONTEXT: CallContext = <CallContext>{}
47
+ type ProcessStreamResponseV3Init = MessageInitShape<typeof ProcessStreamResponseV3Schema>
48
+
49
+ export const TEST_CONTEXT = {} as HandlerContext
44
50
 
45
51
  export function cleanTest() {
46
52
  // retain the DatabaseSchemaState
@@ -49,11 +55,12 @@ export function cleanTest() {
49
55
  State.INSTANCE.stateMap.set(DatabaseSchemaState.INSTANCE.key(), state)
50
56
  }
51
57
 
52
- export class TestProcessorServer implements ProcessorServiceImplementation {
53
- service: ProcessorServiceImpl
58
+ export class TestProcessorServer {
59
+ service: ProcessorServiceImplV3
54
60
  contractConfigs: ContractConfig[]
55
61
  accountConfigs: AccountConfig[]
56
62
  storeContext: TestStoreContext
63
+ private nextProcessId = 1
57
64
 
58
65
  aptos: AptosFacet
59
66
  eth: EthFacet
@@ -67,7 +74,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
67
74
  constructor(loader: () => Promise<any>, httpEndpoints: Record<string, string> = {}) {
68
75
  cleanTest()
69
76
 
70
- this.service = new ProcessorServiceImpl(loader)
77
+ this.service = new ProcessorServiceImplV3(loader)
71
78
  this.aptos = new AptosFacet(this)
72
79
  this.solana = new SolanaFacet(this)
73
80
  this.eth = new EthFacet(this)
@@ -82,79 +89,137 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
82
89
  }
83
90
 
84
91
  // start a memory database for testing
85
- const subject = new Subject<DeepPartial<ProcessStreamResponse>>()
86
- this.storeContext = new TestStoreContext(subject, 1)
92
+ const subject = new Subject<ProcessStreamResponseV3Init>()
93
+ this.storeContext = new TestStoreContext(subject, 1, this.service)
87
94
  this._db = new MemoryDatabase(this.storeContext)
88
95
  }
89
96
 
90
- async start(request: StartRequest = { templateInstances: [] }, context = TEST_CONTEXT): Promise<Empty> {
91
- const res = await this.service.start(request, context)
92
- const config = await this.getConfig({})
97
+ async start(
98
+ request: MessageInitShape<typeof StartRequestSchema> = { templateInstances: [] },
99
+ context = TEST_CONTEXT
100
+ ) {
101
+ const req = create(StartRequestSchema, request)
102
+ const res = await this.service.start(req, context)
103
+ const config = await this.getConfig(create(ProcessConfigRequestSchema, {}))
93
104
  this.contractConfigs = config.contractConfigs
94
105
  this.accountConfigs = config.accountConfigs
95
106
  this._db.start()
96
- this.storeContext.templateInstances = request.templateInstances
107
+ this.storeContext.templateInstances = req.templateInstances
97
108
  return res
98
109
  }
99
110
 
100
- stop(request: Empty, context = TEST_CONTEXT): Promise<Empty> {
101
- return this.service.stop(request, context)
111
+ stop(request: Empty = create(EmptySchema), context = TEST_CONTEXT) {
112
+ this._db.stop()
113
+ return request
102
114
  }
103
115
 
104
- async getConfig(request: ProcessConfigRequest, context = TEST_CONTEXT): Promise<ProcessConfigResponse> {
105
- const config = await this.service.getConfig(request, context)
106
- return {
107
- ...config,
108
- templateInstances: this.storeContext.templateInstances
109
- }
116
+ async getConfig(
117
+ request: MessageInitShape<typeof ProcessConfigRequestSchema> = {},
118
+ context = TEST_CONTEXT
119
+ ): Promise<ProcessConfigResponse> {
120
+ const config = await this.service.getConfig(create(ProcessConfigRequestSchema, request), context)
121
+ config.templateInstances = this.storeContext.templateInstances
122
+ return config
110
123
  }
111
124
 
112
125
  processBindings(
113
- request: ProcessBindingsRequest,
114
- context: CallContext = TEST_CONTEXT
126
+ request: MessageInitShape<typeof ProcessBindingsRequestSchema>,
127
+ context: HandlerContext = TEST_CONTEXT
115
128
  ): Promise<ProcessBindingResponse> {
116
- return PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, async () => {
117
- const ret = await this.service.processBindings(request, context)
118
- if (ret.result?.states?.configUpdated) {
119
- // template may changed
120
- await PluginManager.INSTANCE.updateTemplates({
121
- chainId: request.bindings[0].chainId,
122
- templateInstances: this.storeContext.templateInstances
123
- })
129
+ const req = create(ProcessBindingsRequestSchema, request)
130
+ return this.processBindingList(req.bindings, context)
131
+ }
132
+
133
+ async processBinding(request: DataBinding, context: HandlerContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {
134
+ return this.processBindingList([request], context)
135
+ }
136
+
137
+ private async processBindingList(
138
+ bindings: DataBinding[],
139
+ context: HandlerContext = TEST_CONTEXT
140
+ ): Promise<ProcessBindingResponse> {
141
+ const results: ProcessResult[] = []
142
+ for (const binding of bindings) {
143
+ const result = await this.processBindingV3(binding, context)
144
+ results.push(result)
145
+
146
+ if (result.states?.configUpdated) {
147
+ await PluginManager.INSTANCE.updateTemplates(
148
+ create(UpdateTemplatesRequestSchema, {
149
+ chainId: binding.chainId,
150
+ templateInstances: this.storeContext.templateInstances
151
+ })
152
+ )
124
153
  }
125
- return ret
154
+ }
155
+ return create(ProcessBindingResponseSchema, {
156
+ result: mergeProcessResults(results)
126
157
  })
127
158
  }
128
159
 
129
- async processBinding(request: DataBinding, context: CallContext = TEST_CONTEXT): Promise<ProcessBindingResponse> {
130
- const ret = await PluginManager.INSTANCE.dbContextLocalStorage.run(this.storeContext, () => {
131
- return this.service.processBindings({ bindings: [request] }, context)
132
- })
133
- if (ret.result?.states?.configUpdated) {
134
- // template may changed
135
- await PluginManager.INSTANCE.updateTemplates({
136
- chainId: request.chainId,
137
- templateInstances: this.storeContext.templateInstances
160
+ private processBindingV3(request: DataBinding, context: HandlerContext): Promise<ProcessResult> {
161
+ const processId = this.nextProcessId++
162
+ const subject = this.storeContext.subject
163
+
164
+ return new Promise((resolve, reject) => {
165
+ const subscription = subject.subscribe({
166
+ next: (response) => {
167
+ if (response.processId !== processId) {
168
+ return
169
+ }
170
+ if (response.value?.case === 'tplRequest') {
171
+ this.storeContext.applyTemplateRequest(
172
+ (response.value.value.templates ?? []).map((template) => create(TemplateInstanceSchema, template)),
173
+ response.value.value.remove ?? false
174
+ )
175
+ }
176
+ if (response.value?.case === 'result') {
177
+ subscription.unsubscribe()
178
+ // The service always emits a fully-formed ProcessResult message here; use it directly.
179
+ // Do NOT re-`create(ProcessResultSchema, ...)` — that re-validates every field and throws
180
+ // on results carrying loosely-typed values (e.g. a hex string in an int32 field), which
181
+ // the old unary processBindings path passed through untouched.
182
+ const result = response.value.value as ProcessResult
183
+ // The V3 service reports handler failures as a result with `states.error` set (via
184
+ // DataBindingContext.error) rather than erroring the stream. Surface it as a thrown
185
+ // error so tests observe the same behavior as the old unary processBindings path.
186
+ if (result.states?.error) {
187
+ reject(new Error(result.states.error))
188
+ } else {
189
+ resolve(result)
190
+ }
191
+ }
192
+ },
193
+ error: (e) => {
194
+ subscription.unsubscribe()
195
+ reject(e)
196
+ }
138
197
  })
139
- }
140
- return ret
141
- }
142
198
 
143
- processBindingsStream(
144
- requests: AsyncIterable<ProcessStreamRequest>,
145
- context: CallContext
146
- ): ServerStreamingMethodResult<DeepPartial<ProcessStreamResponse>> {
147
- throw new Error('Method not implemented.')
199
+ this.service
200
+ .handleRequest(
201
+ create(ProcessStreamRequestSchema, {
202
+ processId,
203
+ value: {
204
+ case: 'binding',
205
+ value: request
206
+ }
207
+ }),
208
+ undefined,
209
+ subject
210
+ )
211
+ .catch((e) => {
212
+ subscription.unsubscribe()
213
+ reject(e)
214
+ })
215
+ })
148
216
  }
149
217
 
150
- preprocessBindingsStream(
151
- requests: AsyncIterable<PreprocessStreamRequest>,
152
- context: CallContext
153
- ): ServerStreamingMethodResult<DeepPartial<PreprocessStreamResponse>> {
154
- throw new Error('Method not implemented.')
218
+ processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: HandlerContext) {
219
+ return this.service.processBindingsStream(requests, context)
155
220
  }
156
221
 
157
- // processBindingsStream(request: AsyncIterable<ProcessStreamRequest>, context: CallContext) {
222
+ // processBindingsStream(request: AsyncIterable<ProcessStreamRequest>, context: HandlerContext) {
158
223
  // return this.service.processBindingsStream(request, context)
159
224
  // }
160
225
  get db() {
@@ -166,17 +231,37 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
166
231
  }
167
232
  }
168
233
 
169
- class TestStoreContext extends StoreContext implements IDataBindingContext {
234
+ class TestStoreContext extends DataBindingContext implements IDataBindingContext {
170
235
  constructor(
171
- readonly subject: Subject<DeepPartial<ProcessStreamResponse>>,
172
- processId: number
236
+ subject: Subject<ProcessStreamResponseV3Init>,
237
+ processId: number,
238
+ private readonly service: ProcessorServiceImplV3
173
239
  ) {
174
- super(subject, processId)
240
+ super(processId, subject)
175
241
  }
176
242
 
177
243
  templateInstances: TemplateInstance[] = []
178
244
 
179
- sendTemplateRequest(templates: Array<TemplateInstance>, remove: boolean): void {
245
+ result(dbResult: DBResponse, processId = this.processId): void {
246
+ // Resolve a request issued directly from this context (e.g. `service.store.get(...)` in a test,
247
+ // which goes through the TestStoreContext rather than a per-binding context). opIds are globally
248
+ // unique, so this is a no-op when the request originated from the service's per-binding context.
249
+ super.result(dbResult)
250
+ // Forward to the service's per-binding context for requests issued while processing a binding.
251
+ void this.service.handleRequest(
252
+ create(ProcessStreamRequestSchema, {
253
+ processId,
254
+ value: {
255
+ case: 'dbResult',
256
+ value: dbResult
257
+ }
258
+ }),
259
+ undefined,
260
+ this.subject
261
+ )
262
+ }
263
+
264
+ applyTemplateRequest(templates: Array<TemplateInstance>, remove: boolean): void {
180
265
  if (remove) {
181
266
  this.templateInstances = this.templateInstances.filter(
182
267
  (i) => !templates.find((t) => t.templateId === i.templateId && t.contract?.address === i.contract?.address)
@@ -185,7 +270,12 @@ class TestStoreContext extends StoreContext implements IDataBindingContext {
185
270
  this.templateInstances.push(...templates)
186
271
  }
187
272
  }
273
+
274
+ sendTemplateRequest(templates: Array<TemplateInstance>, remove: boolean): void {
275
+ this.applyTemplateRequest(templates, remove)
276
+ }
277
+
188
278
  sendTimeseriesRequest(timeseries: Array<TimeseriesResult>): void {
189
- throw new Error('Method not implemented.')
279
+ // Test helpers currently expose metric/event/export results through ProcessResult.
190
280
  }
191
281
  }
@@ -1,4 +1,5 @@
1
- import { CoinID } from '@sentio/protos'
1
+ import { type CoinID, CoinIDSchema } from '@sentio/protos'
2
+ import { create } from '@bufbuild/protobuf'
2
3
  import { Endpoints, processMetrics } from '@sentio/runtime'
3
4
  import { ChainId } from '@sentio/chain'
4
5
  import { LRUCache } from 'lru-cache'
@@ -56,11 +57,14 @@ export async function getPriceByTypeOrSymbolInternal(
56
57
  const dateStr = dateString(date)
57
58
  const todayDateString = dateString(new Date())
58
59
 
60
+ const symbol = coinId.id.case === 'symbol' ? coinId.id.value : undefined
61
+ const address = coinId.id.case === 'address' ? coinId.id.value : undefined
62
+
59
63
  let key: string
60
- if (coinId.symbol) {
61
- key = `${coinId.symbol}-${dateStr}`
64
+ if (symbol) {
65
+ key = `${symbol}-${dateStr}`
62
66
  } else {
63
- key = `${coinId.address?.address}-${coinId.address?.chain}-${dateStr}`
67
+ key = `${address?.address}-${address?.chain}-${dateStr}`
64
68
  }
65
69
  let price = priceMap.get(key)
66
70
  if (price) {
@@ -71,9 +75,9 @@ export async function getPriceByTypeOrSymbolInternal(
71
75
  const response = priceClient.getPrice({
72
76
  query: {
73
77
  timestamp: date.toISOString(),
74
- 'coinId.symbol': coinId.symbol,
75
- 'coinId.address.address': coinId.address?.address,
76
- 'coinId.address.chain': coinId.address?.chain
78
+ 'coinId.symbol': symbol,
79
+ 'coinId.address.address': address?.address,
80
+ 'coinId.address.chain': address?.chain
77
81
  }
78
82
  })
79
83
  price = response
@@ -131,12 +135,15 @@ export async function getPriceByType(
131
135
  ): Promise<number | undefined> {
132
136
  return getPriceByTypeOrSymbol(
133
137
  date,
134
- {
135
- address: {
136
- chain: chainId,
137
- address: coinType
138
+ create(CoinIDSchema, {
139
+ id: {
140
+ case: 'address',
141
+ value: {
142
+ chain: chainId,
143
+ address: coinType
144
+ }
138
145
  }
139
- },
146
+ }),
140
147
  options
141
148
  )
142
149
  }
@@ -151,7 +158,7 @@ export async function getPriceBySymbol(
151
158
  date: Date,
152
159
  options?: PriceOptions
153
160
  ): Promise<number | undefined> {
154
- return getPriceByTypeOrSymbol(date, { symbol }, options)
161
+ return getPriceByTypeOrSymbol(date, create(CoinIDSchema, { id: { case: 'symbol', value: symbol } }), options)
155
162
  }
156
163
 
157
164
  function dateString(date: Date) {