@sentio/sdk 4.0.0-rc.1 → 4.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 (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 +12 -10
  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 +22 -14
  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 +1 -1
  234. package/lib/testing/memory-database.d.ts.map +1 -1
  235. package/lib/testing/memory-database.js +81 -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 +19 -13
  249. package/lib/testing/test-processor-server.d.ts.map +1 -1
  250. package/lib/testing/test-processor-server.js +22 -20
  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 +18 -11
  288. package/src/eth/eth-plugin.ts +135 -118
  289. package/src/eth/eth.ts +29 -20
  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 +109 -85
  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 +64 -58
  331. package/src/utils/price.ts +20 -13
@@ -1,5 +1,12 @@
1
1
  import { TestProcessorServer } from './test-processor-server.js'
2
- import { DataBinding, HandlerType, ProcessBindingResponse } from '@sentio/protos'
2
+ import {
3
+ type DataBinding,
4
+ DataBindingSchema,
5
+ HandlerType,
6
+ type ProcessBindingResponse,
7
+ timestampNow
8
+ } from '@sentio/protos'
9
+ import { create } from '@bufbuild/protobuf'
3
10
  import { Trace } from '../eth/eth.js'
4
11
  import { BlockParams, LogParams, TransactionResponseParams } from 'ethers/providers'
5
12
  import { ChainId, EthChainId } from '@sentio/chain'
@@ -48,17 +55,20 @@ export class EthFacet {
48
55
  }
49
56
  for (const config of contract.traceConfigs) {
50
57
  if (config.signature == signature) {
51
- return {
58
+ return create(DataBindingSchema, {
52
59
  data: {
53
- ethTrace: {
54
- trace,
55
- timestamp: new Date()
60
+ value: {
61
+ case: 'ethTrace',
62
+ value: {
63
+ rawTrace: JSON.stringify(trace),
64
+ timestamp: timestampNow()
65
+ }
56
66
  }
57
67
  },
58
68
  handlerIds: [config.handlerId],
59
69
  handlerType: HandlerType.ETH_TRACE,
60
70
  chainId: network
61
- }
71
+ })
62
72
  }
63
73
  }
64
74
  }
@@ -116,14 +126,17 @@ export class EthFacet {
116
126
  break
117
127
  }
118
128
  if (match) {
119
- return {
129
+ return create(DataBindingSchema, {
120
130
  data: {
121
- ethLog: { log, timestamp: new Date(), rawLog: JSON.stringify(log) }
131
+ value: {
132
+ case: 'ethLog',
133
+ value: { timestamp: timestampNow(), rawLog: JSON.stringify(log) }
134
+ }
122
135
  },
123
136
  handlerIds: [config.handlerId],
124
137
  handlerType: HandlerType.ETH_LOG,
125
138
  chainId: network
126
- }
139
+ })
127
140
  }
128
141
  }
129
142
  }
@@ -190,14 +203,17 @@ export class EthFacet {
190
203
  break
191
204
  }
192
205
  if (match) {
193
- return {
206
+ return create(DataBindingSchema, {
194
207
  data: {
195
- ethLog: { log, timestamp: new Date(), rawLog: JSON.stringify(log) }
208
+ value: {
209
+ case: 'ethLog',
210
+ value: { timestamp: timestampNow(), rawLog: JSON.stringify(log) }
211
+ }
196
212
  },
197
213
  handlerIds: [config.handlerId],
198
214
  handlerType: HandlerType.ETH_LOG,
199
215
  chainId: network
200
- }
216
+ })
201
217
  }
202
218
  }
203
219
  }
@@ -230,14 +246,17 @@ export class EthFacet {
230
246
  block: Partial<BlockParams> & { number: number },
231
247
  network: EthChainId = EthChainId.ETHEREUM
232
248
  ): DataBinding {
233
- const binding: DataBinding = {
249
+ const binding: DataBinding = create(DataBindingSchema, {
234
250
  data: {
235
- ethBlock: { block }
251
+ value: {
252
+ case: 'ethBlock',
253
+ value: { rawBlock: JSON.stringify(block) }
254
+ }
236
255
  },
237
256
  handlerType: HandlerType.ETH_BLOCK,
238
257
  handlerIds: [],
239
258
  chainId: network
240
- }
259
+ })
241
260
  for (const contract of this.server.contractConfigs) {
242
261
  if (contract.contract?.chainId !== network) {
243
262
  continue
@@ -282,14 +301,17 @@ export class EthFacet {
282
301
  transaction: Partial<TransactionResponseParams>,
283
302
  network: EthChainId = EthChainId.ETHEREUM
284
303
  ): DataBinding {
285
- const binding: DataBinding = {
304
+ const binding: DataBinding = create(DataBindingSchema, {
286
305
  data: {
287
- ethTransaction: { transaction, timestamp: new Date(), rawTransaction: JSON.stringify(transaction) }
306
+ value: {
307
+ case: 'ethTransaction',
308
+ value: { timestamp: timestampNow(), rawTransaction: JSON.stringify(transaction) }
309
+ }
288
310
  },
289
311
  handlerType: HandlerType.ETH_TRANSACTION,
290
312
  handlerIds: [],
291
313
  chainId: network
292
- }
314
+ })
293
315
  for (const contract of this.server.contractConfigs) {
294
316
  if (contract.contract?.chainId !== network) {
295
317
  continue
@@ -1,6 +1,7 @@
1
1
  import { TestProcessorServer } from './test-processor-server.js'
2
2
  import { FuelChainId } from '@sentio/chain'
3
- import { DataBinding, HandlerType } from '@sentio/protos'
3
+ import { type DataBinding, DataBindingSchema, HandlerType, timestampNow } from '@sentio/protos'
4
+ import { create } from '@bufbuild/protobuf'
4
5
  import { FuelNetwork } from '../fuel/index.js'
5
6
  import { getRpcEndpoint } from '../fuel/network.js'
6
7
 
@@ -47,33 +48,39 @@ export class FuelFacet {
47
48
  continue
48
49
  }
49
50
  for (const callConfig of config.fuelTransactionConfigs) {
50
- const binding = {
51
+ const binding = create(DataBindingSchema, {
51
52
  data: {
52
- fuelTransaction: {
53
- transaction,
54
- timestamp: new Date()
53
+ value: {
54
+ case: 'fuelTransaction',
55
+ value: {
56
+ transaction,
57
+ timestamp: timestampNow()
58
+ }
55
59
  }
56
60
  },
57
61
  handlerIds: [callConfig.handlerId],
58
62
  handlerType: HandlerType.FUEL_TRANSACTION,
59
63
  chainId: network
60
- }
64
+ })
61
65
 
62
66
  res.push(binding)
63
67
  }
64
68
 
65
69
  for (const assetConfig of config.assetConfigs) {
66
- const binding = {
70
+ const binding = create(DataBindingSchema, {
67
71
  data: {
68
- fuelTransaction: {
69
- transaction,
70
- timestamp: new Date()
72
+ value: {
73
+ case: 'fuelTransaction',
74
+ value: {
75
+ transaction,
76
+ timestamp: timestampNow()
77
+ }
71
78
  }
72
79
  },
73
80
  handlerIds: [assetConfig.handlerId],
74
81
  handlerType: HandlerType.FUEL_TRANSACTION,
75
82
  chainId: network
76
- }
83
+ })
77
84
 
78
85
  res.push(binding)
79
86
  }
@@ -89,20 +96,23 @@ export class FuelFacet {
89
96
 
90
97
  for (const config of this.server.contractConfigs) {
91
98
  for (const logConfig of config.fuelReceiptConfigs) {
92
- const logIds = logConfig.log?.logIds ?? []
99
+ const logIds = logConfig.receiptFilter?.case === 'log' ? logConfig.receiptFilter.value.logIds : []
93
100
  if (logIds.includes(receipt.rb)) {
94
- const binding = {
101
+ const binding = create(DataBindingSchema, {
95
102
  data: {
96
- fuelLog: {
97
- transaction,
98
- timestamp: new Date(),
99
- receiptIndex: BigInt(i)
103
+ value: {
104
+ case: 'fuelLog',
105
+ value: {
106
+ transaction,
107
+ timestamp: timestampNow(),
108
+ receiptIndex: BigInt(i)
109
+ }
100
110
  }
101
111
  },
102
112
  handlerIds: [logConfig.handlerId],
103
113
  handlerType: HandlerType.FUEL_RECEIPT,
104
114
  chainId: network
105
- }
115
+ })
106
116
  res.push(binding)
107
117
  }
108
118
  }
@@ -1,5 +1,6 @@
1
1
  import { MoveCallIotaTransaction, IotaTransactionBlockResponse } from '@iota/iota-sdk/client'
2
- import { DataBinding, HandlerType } from '@sentio/protos'
2
+ import { type DataBinding, DataBindingSchema, HandlerType, timestampFromDate, timestampNow } from '@sentio/protos'
3
+ import { create } from '@bufbuild/protobuf'
3
4
  import { TestProcessorServer } from './test-processor-server.js'
4
5
  import { accountTypeString, parseMoveType, SPLITTER } from '../move/index.js'
5
6
  import { IotaNetwork } from '../iota/index.js'
@@ -47,18 +48,21 @@ export class IotaFacet {
47
48
  for (const callConfig of config.moveCallConfigs) {
48
49
  for (const callFilter of callConfig.filters) {
49
50
  if (accountTypeString(config.contract.address) + '::' + callFilter.function === functionType) {
50
- return {
51
+ return create(DataBindingSchema, {
51
52
  data: {
52
- suiCall: {
53
- rawTransaction: JSON.stringify(transaction),
54
- timestamp: new Date(),
55
- slot: 10000n
53
+ value: {
54
+ case: 'suiCall',
55
+ value: {
56
+ rawTransaction: JSON.stringify(transaction),
57
+ timestamp: timestampNow(),
58
+ slot: 10000n
59
+ }
56
60
  }
57
61
  },
58
62
  handlerIds: [callConfig.handlerId],
59
63
  handlerType: HandlerType.SUI_CALL,
60
64
  chainId: network
61
- }
65
+ })
62
66
  }
63
67
  }
64
68
  }
@@ -91,18 +95,23 @@ export class IotaFacet {
91
95
  throw Error('Invalid test global transaction: ' + JSON.stringify(transaction))
92
96
  }
93
97
 
94
- const binding: DataBinding = {
98
+ const binding: DataBinding = create(DataBindingSchema, {
95
99
  handlerIds,
96
100
  handlerType: HandlerType.SUI_CALL,
97
101
  data: {
98
- suiCall: {
99
- rawTransaction: JSON.stringify(transaction),
100
- timestamp: transaction.timestampMs ? new Date(transaction.timestampMs) : new Date(),
101
- slot: BigInt(transaction.checkpoint || 0)
102
+ value: {
103
+ case: 'suiCall',
104
+ value: {
105
+ rawTransaction: JSON.stringify(transaction),
106
+ timestamp: transaction.timestampMs
107
+ ? timestampFromDate(new Date(Number(transaction.timestampMs)))
108
+ : timestampNow(),
109
+ slot: BigInt(transaction.checkpoint || 0)
110
+ }
102
111
  }
103
112
  },
104
113
  chainId: network
105
- }
114
+ })
106
115
  return this.server.processBinding(binding)
107
116
  }
108
117
 
@@ -123,19 +132,22 @@ export class IotaFacet {
123
132
  accountTypeString(config.contract.address) + '::' + eventFilter.type ===
124
133
  parseMoveType(event.type).qname
125
134
  ) {
126
- return {
135
+ return create(DataBindingSchema, {
127
136
  data: {
128
- suiEvent: {
129
- rawEvent: JSON.stringify(event),
130
- rawTransaction: JSON.stringify(transaction),
131
- timestamp: new Date(transaction.timestampMs || 0),
132
- slot: 10000n
137
+ value: {
138
+ case: 'suiEvent',
139
+ value: {
140
+ rawEvent: JSON.stringify(event),
141
+ rawTransaction: JSON.stringify(transaction),
142
+ timestamp: timestampFromDate(new Date(Number(transaction.timestampMs || 0))),
143
+ slot: 10000n
144
+ }
133
145
  }
134
146
  },
135
147
  handlerIds: [eventConfig.handlerId],
136
148
  handlerType: HandlerType.SUI_EVENT,
137
149
  chainId: network
138
- }
150
+ })
139
151
  }
140
152
  }
141
153
  }
@@ -1,13 +1,18 @@
1
1
  import { StoreContext } from '../store/context.js'
2
2
  import {
3
- DBRequest,
4
- DBRequest_DBFilter,
3
+ type DBRequest,
4
+ type DBRequest_DBFilter,
5
5
  DBRequest_DBOperator,
6
- ProcessStreamResponse,
7
- RichStruct,
8
- RichValue,
9
- RichValueList
6
+ DBResponseSchema,
7
+ type ProcessStreamResponse,
8
+ type RichStruct,
9
+ type RichValue,
10
+ RichValueSchema,
11
+ type RichValueList,
12
+ RichValueListSchema,
13
+ timestampNow
10
14
  } from '@sentio/protos'
15
+ import { create } from '@bufbuild/protobuf'
11
16
  import { GraphQLField, GraphQLSchema, parse, StringValueNode } from 'graphql/index.js'
12
17
  import { DatabaseSchemaState } from '../core/database-schema.js'
13
18
  import { buildSchema } from '../store/schema.js'
@@ -43,10 +48,9 @@ export class MemoryDatabase {
43
48
  }
44
49
 
45
50
  start() {
46
- // The subject is typed `DeepPartial<ProcessStreamResponse>`, but at runtime it always carries a
47
- // full response. Match the subscriber's parameter type and narrow inside (a bound method with the
48
- // narrower `ProcessStreamResponse` parameter is rejected under `strictFunctionTypes`).
49
- this.dbContext.subject.subscribe((request) => this.processRequest(request as ProcessStreamResponse))
51
+ // The subject is typed as the `ProcessStreamResponse` init-shape, but at runtime it always carries a
52
+ // full response (the store context emits the complete oneof). Treat it as a full message and narrow inside.
53
+ this.dbContext.subject.subscribe((request) => this.processRequest(request as unknown as ProcessStreamResponse))
50
54
  }
51
55
 
52
56
  stop() {
@@ -114,20 +118,25 @@ export class MemoryDatabase {
114
118
  if (elemDb) {
115
119
  for (const elemID of Object.keys(elemDb)) {
116
120
  const value = elemDb[elemID]
117
- const deriveField = value.fields[derivedFrom]
121
+ const deriveField: RichValue | undefined = value.fields[derivedFrom]
118
122
  let hasRelation = false
119
- if (deriveField?.stringValue === id) {
123
+ if (deriveField?.value.case === 'stringValue' && deriveField.value.value === id) {
120
124
  hasRelation = true
121
125
  }
122
- if (deriveField?.listValue) {
123
- hasRelation = deriveField.listValue.values.some((v: any) => v.stringValue === id)
126
+ if (deriveField?.value.case === 'listValue') {
127
+ hasRelation = deriveField.value.value.values.some(
128
+ (v) => v.value.case === 'stringValue' && v.value.value === id
129
+ )
124
130
  }
125
131
  if (hasRelation) {
126
- const arr = result.fields[field.name]
127
- if (arr) {
128
- arr.listValue.values.push({ stringValue: elemID })
132
+ const arr: RichValue | undefined = result.fields[field.name]
133
+ const elem = create(RichValueSchema, { value: { case: 'stringValue', value: elemID } })
134
+ if (arr && arr.value.case === 'listValue') {
135
+ arr.value.value.values.push(elem)
129
136
  } else {
130
- result.fields[field.name] = { listValue: { values: [{ stringValue: elemID }] } }
137
+ result.fields[field.name] = create(RichValueSchema, {
138
+ value: { case: 'listValue', value: { values: [elem] } }
139
+ })
131
140
  }
132
141
  }
133
142
  }
@@ -141,7 +150,7 @@ export class MemoryDatabase {
141
150
  }
142
151
 
143
152
  private processRequest(request: ProcessStreamResponse) {
144
- const req = request.dbRequest
153
+ const req = request.value.case === 'dbRequest' ? request.value.value : undefined
145
154
 
146
155
  // Check if schema is required for this request
147
156
  const requiresSchema = this.requestRequiresSchema(req)
@@ -152,58 +161,63 @@ export class MemoryDatabase {
152
161
 
153
162
  this.lastDbRequest = req
154
163
  if (req) {
155
- if (req.upsert) {
156
- const { entityData, entity } = req.upsert
164
+ if (req.op.case === 'upsert') {
165
+ const { entityData, entity } = req.op.value
157
166
  entityData.forEach((d, i) => {
158
- const id = d.fields['id'].stringValue!
167
+ const idField = d.fields['id']
168
+ const id = idField?.value.case === 'stringValue' ? idField.value.value : ''
159
169
  const entityName = entity[i]
160
170
  this.upsert(entityName, id, d)
161
171
  })
162
172
 
163
- this.dbContext.result({
164
- opId: req.opId
165
- })
173
+ this.dbContext.result(create(DBResponseSchema, { opId: req.opId }))
166
174
  }
167
- if (req.delete) {
168
- const { id, entity } = req.delete
175
+ if (req.op.case === 'delete') {
176
+ const { id, entity } = req.op.value
169
177
  id.forEach((i, idx) => {
170
178
  const entityName = entity[idx]
171
179
  this.delete(entityName, i)
172
180
  })
173
- this.dbContext.result({
174
- opId: req.opId
175
- })
181
+ this.dbContext.result(create(DBResponseSchema, { opId: req.opId }))
176
182
  }
177
183
 
178
- if (req.get) {
179
- const { entity, id } = req.get
184
+ if (req.op.case === 'get') {
185
+ const { entity, id } = req.op.value
180
186
  const data = this.getById(entity, id)
181
- this.dbContext.result({
182
- opId: req.opId,
183
- // entities: { entities: data ? [data] : [] },
184
- entityList: {
185
- entities: data ? [toEntity(data)] : []
186
- }
187
- })
187
+ this.dbContext.result(
188
+ create(DBResponseSchema, {
189
+ opId: req.opId,
190
+ value: {
191
+ case: 'entityList',
192
+ value: {
193
+ entities: data ? [toEntity(data)] : []
194
+ }
195
+ }
196
+ })
197
+ )
188
198
  }
189
- if (req.list) {
190
- const { entity, cursor, filters } = req.list
199
+ if (req.op.case === 'list') {
200
+ const { entity, cursor, filters } = req.op.value
191
201
  const list = this.listEntities(entity, filters)
192
202
 
193
203
  if (cursor) {
194
204
  const idx = parseInt(cursor)
195
205
 
196
- this.dbContext.result({
197
- opId: req.opId,
198
- entityList: { entities: list.slice(idx, idx + 1).map((d) => toEntity(d)) },
199
- nextCursor: idx + 1 < list.length ? `${idx + 1}` : undefined
200
- })
206
+ this.dbContext.result(
207
+ create(DBResponseSchema, {
208
+ opId: req.opId,
209
+ value: { case: 'entityList', value: { entities: list.slice(idx, idx + 1).map((d) => toEntity(d)) } },
210
+ nextCursor: idx + 1 < list.length ? `${idx + 1}` : undefined
211
+ })
212
+ )
201
213
  } else {
202
- this.dbContext.result({
203
- opId: req.opId,
204
- entityList: { entities: list.length ? [toEntity(list[0])] : [] },
205
- nextCursor: '1'
206
- })
214
+ this.dbContext.result(
215
+ create(DBResponseSchema, {
216
+ opId: req.opId,
217
+ value: { case: 'entityList', value: { entities: list.length ? [toEntity(list[0])] : [] } },
218
+ nextCursor: '1'
219
+ })
220
+ )
207
221
  }
208
222
  }
209
223
  }
@@ -218,19 +232,18 @@ export class MemoryDatabase {
218
232
  if (!req) return false
219
233
 
220
234
  // Check if all entities in the request are MemoryCacheItem
221
- if (req.upsert) {
222
- return !req.upsert.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
235
+ switch (req.op.case) {
236
+ case 'upsert':
237
+ return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
238
+ case 'delete':
239
+ return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
240
+ case 'get':
241
+ return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
242
+ case 'list':
243
+ return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
244
+ default:
245
+ return false
223
246
  }
224
- if (req.delete) {
225
- return !req.delete.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
226
- }
227
- if (req.get) {
228
- return req.get.entity !== MEMORY_CACHE_ITEM_ENTITY
229
- }
230
- if (req.list) {
231
- return req.list.entity !== MEMORY_CACHE_ITEM_ENTITY
232
- }
233
- return false
234
247
  }
235
248
 
236
249
  private listEntities(entity: string, filters?: DBRequest_DBFilter[]) {
@@ -271,37 +284,46 @@ function filter(entity: RichStruct, filter: DBRequest_DBFilter) {
271
284
  case DBRequest_DBOperator.LE:
272
285
  return lessThan(value, filter.value) || equal(value, filter.value)
273
286
  case DBRequest_DBOperator.IN:
274
- return filter.value?.values.some((v) => equal(value, { values: [v] }))
287
+ return filter.value?.values.some((v) => equal(value, singleList(v)))
275
288
  case DBRequest_DBOperator.NOT_IN:
276
- return !filter.value?.values.some((v) => equal(value, { values: [v] }))
289
+ return !filter.value?.values.some((v) => equal(value, singleList(v)))
277
290
  case DBRequest_DBOperator.HAS_ALL:
278
- return filter.value?.values.every((v) => equal(value, { values: [v] }))
291
+ return filter.value?.values.every((v) => equal(value, singleList(v)))
279
292
  case DBRequest_DBOperator.HAS_ANY:
280
293
  for (const a of filter.value?.values ?? []) {
281
- if ((value.listValue?.values ?? []).some((v) => equal(a, { values: [v] }))) {
294
+ const listValues = value.value.case === 'listValue' ? value.value.value.values : []
295
+ if (listValues.some((v) => equal(a, singleList(v)))) {
282
296
  return true
283
297
  }
284
298
  }
285
299
  return false
286
300
  case DBRequest_DBOperator.LIKE:
287
- return like(value.stringValue, filter.value?.values[0]?.stringValue)
301
+ return like(richString(value), filter.value?.values[0] ? richString(filter.value.values[0]) : undefined)
288
302
  default:
289
303
  return false
290
304
  }
291
305
  }
292
306
 
307
+ function singleList(v: RichValue): RichValueList {
308
+ return create(RichValueListSchema, { values: [v] })
309
+ }
310
+
311
+ function richString(v?: RichValue): string | undefined {
312
+ return v?.value.case === 'stringValue' ? v.value.value : undefined
313
+ }
314
+
293
315
  function getValue(entity: RichStruct, field: string) {
294
316
  return entity.fields[field]
295
317
  }
296
318
 
297
319
  function equal(field: RichValue, value?: RichValueList): boolean {
298
- if (field.stringValue !== undefined) {
299
- return field.stringValue === value?.values[0]?.stringValue
320
+ if (field.value.case === 'stringValue') {
321
+ return field.value.value === richString(value?.values[0])
300
322
  }
301
- if (field.listValue) {
302
- return field.listValue.values.every((v, i) => {
323
+ if (field.value.case === 'listValue') {
324
+ return field.value.value.values.every((v, i) => {
303
325
  const vv = value?.values[i]
304
- return equal(v, vv ? { values: [vv] } : undefined)
326
+ return equal(v, vv ? singleList(vv) : undefined)
305
327
  })
306
328
  }
307
329
  const a = toNumber(field)
@@ -338,19 +360,21 @@ function lessThan(field: RichValue, value: RichValueList | undefined) {
338
360
  }
339
361
 
340
362
  function toNumber(value?: RichValue) {
341
- if (value?.intValue !== undefined) {
342
- return value.intValue
343
- }
344
- if (value?.floatValue !== undefined) {
345
- return value.floatValue
346
- }
347
- if (value?.bigintValue !== undefined) {
348
- return BigIntConverter.to(value) as bigint
363
+ if (value === undefined) {
364
+ return undefined
349
365
  }
350
- if (value?.bigdecimalValue !== undefined) {
351
- return BigDecimalConverter.to(value) as BigDecimal
366
+ switch (value.value.case) {
367
+ case 'intValue':
368
+ return value.value.value
369
+ case 'floatValue':
370
+ return value.value.value
371
+ case 'bigintValue':
372
+ return BigIntConverter.to(value) as bigint
373
+ case 'bigdecimalValue':
374
+ return BigDecimalConverter.to(value) as BigDecimal
375
+ default:
376
+ return undefined
352
377
  }
353
- return undefined
354
378
  }
355
379
 
356
380
  function toEntity(data: any) {
@@ -358,7 +382,7 @@ function toEntity(data: any) {
358
382
  entity: data.entity,
359
383
  genBlockChain: '',
360
384
  genBlockNumber: 0n,
361
- genBlockTime: new Date(),
385
+ genBlockTime: timestampNow(),
362
386
  data: { fields: data.fields }
363
387
  }
364
388
  }
@@ -1,26 +1,27 @@
1
- import { MetricValue, ProcessResult } from '@sentio/protos'
1
+ import type { MetricValue, ProcessResult } from '@sentio/protos'
2
2
  import { Numberish, BigDecimal } from '../core/index.js'
3
3
  import { bytesToBigInt } from '../utils/conversion.js'
4
4
 
5
- export function MetricValueToNumber(v: Partial<MetricValue> | undefined): Numberish | undefined {
5
+ export function MetricValueToNumber(v: MetricValue | undefined): Numberish | undefined {
6
6
  if (v === undefined) {
7
7
  return undefined
8
8
  }
9
9
 
10
- if (v.doubleValue !== undefined) {
11
- return v.doubleValue
12
- }
13
- if (v.bigInteger !== undefined) {
14
- let intValue = bytesToBigInt(v.bigInteger.data)
15
- if (v.bigInteger.negative) {
16
- intValue = -intValue
10
+ switch (v.value.case) {
11
+ case 'doubleValue':
12
+ return v.value.value
13
+ case 'bigInteger': {
14
+ let intValue = bytesToBigInt(v.value.value.data)
15
+ if (v.value.value.negative) {
16
+ intValue = -intValue
17
+ }
18
+ return intValue
17
19
  }
18
- return intValue
19
- }
20
- if (v.bigDecimal !== undefined) {
21
- return new BigDecimal(v.bigDecimal)
20
+ case 'bigDecimal':
21
+ return new BigDecimal(v.value.value)
22
+ default:
23
+ return undefined
22
24
  }
23
- return undefined
24
25
  }
25
26
 
26
27
  export function firstCounterValue(result: ProcessResult | undefined, name: string): Numberish | undefined {