@sentio/sdk 3.9.0-rc.9 → 4.0.0-rc.10

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 (366) 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 +4 -4
  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 +11 -9
  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/aptos/network.js +1 -1
  20. package/lib/aptos/network.js.map +1 -1
  21. package/lib/core/base-context.d.ts +3 -2
  22. package/lib/core/base-context.d.ts.map +1 -1
  23. package/lib/core/base-context.js +12 -11
  24. package/lib/core/base-context.js.map +1 -1
  25. package/lib/core/core-plugin.d.ts.map +1 -1
  26. package/lib/core/core-plugin.js +6 -4
  27. package/lib/core/core-plugin.js.map +1 -1
  28. package/lib/core/event-logger.d.ts +10 -2
  29. package/lib/core/event-logger.d.ts.map +1 -1
  30. package/lib/core/event-logger.js +42 -27
  31. package/lib/core/event-logger.js.map +1 -1
  32. package/lib/core/exporter.d.ts.map +1 -1
  33. package/lib/core/exporter.js +5 -3
  34. package/lib/core/exporter.js.map +1 -1
  35. package/lib/core/handler-options.d.ts +1 -1
  36. package/lib/core/handler-options.d.ts.map +1 -1
  37. package/lib/core/handler-register.d.ts +1 -1
  38. package/lib/core/handler-register.d.ts.map +1 -1
  39. package/lib/core/handler-register.js +2 -2
  40. package/lib/core/handler-register.js.map +1 -1
  41. package/lib/core/meter.d.ts +4 -3
  42. package/lib/core/meter.d.ts.map +1 -1
  43. package/lib/core/meter.js +5 -4
  44. package/lib/core/meter.js.map +1 -1
  45. package/lib/core/normalization.d.ts +1 -1
  46. package/lib/core/normalization.d.ts.map +1 -1
  47. package/lib/core/normalization.js +41 -31
  48. package/lib/core/normalization.js.map +1 -1
  49. package/lib/core/numberish.d.ts +1 -1
  50. package/lib/core/numberish.d.ts.map +1 -1
  51. package/lib/core/numberish.js +35 -30
  52. package/lib/core/numberish.js.map +1 -1
  53. package/lib/core/partition-handler-manager.d.ts +1 -1
  54. package/lib/core/partition-handler-manager.d.ts.map +1 -1
  55. package/lib/core/partition-handler-manager.js +10 -9
  56. package/lib/core/partition-handler-manager.js.map +1 -1
  57. package/lib/cosmos/context.d.ts.map +1 -1
  58. package/lib/cosmos/context.js +4 -2
  59. package/lib/cosmos/context.js.map +1 -1
  60. package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
  61. package/lib/cosmos/cosmos-plugin.js +11 -10
  62. package/lib/cosmos/cosmos-plugin.js.map +1 -1
  63. package/lib/cosmos/cosmos-processor.js.map +1 -1
  64. package/lib/eth/abi-decoder/decode-worker.js +2 -2
  65. package/lib/eth/abi-decoder/decode-worker.js.map +1 -1
  66. package/lib/eth/account-processor.d.ts +2 -2
  67. package/lib/eth/account-processor.d.ts.map +1 -1
  68. package/lib/eth/account-processor.js +10 -9
  69. package/lib/eth/account-processor.js.map +1 -1
  70. package/lib/eth/base-processor-template.d.ts +3 -3
  71. package/lib/eth/base-processor-template.d.ts.map +1 -1
  72. package/lib/eth/base-processor-template.js +14 -8
  73. package/lib/eth/base-processor-template.js.map +1 -1
  74. package/lib/eth/base-processor.d.ts +3 -3
  75. package/lib/eth/base-processor.d.ts.map +1 -1
  76. package/lib/eth/base-processor.js +53 -46
  77. package/lib/eth/base-processor.js.map +1 -1
  78. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  79. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +48 -46
  80. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  81. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  82. package/lib/eth/builtin/internal/erc1155-processor.js +18 -16
  83. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  84. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  85. package/lib/eth/builtin/internal/erc20-processor.js +38 -36
  86. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  87. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  88. package/lib/eth/builtin/internal/erc20bytes-processor.js +20 -18
  89. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  90. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  91. package/lib/eth/builtin/internal/erc721-processor.js +30 -28
  92. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  93. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  94. package/lib/eth/builtin/internal/weth9-processor.js +24 -22
  95. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  96. package/lib/eth/codegen/file.d.ts.map +1 -1
  97. package/lib/eth/codegen/file.js +2 -1
  98. package/lib/eth/codegen/file.js.map +1 -1
  99. package/lib/eth/codegen/function-calls.js +1 -1
  100. package/lib/eth/context.d.ts +1 -1
  101. package/lib/eth/context.d.ts.map +1 -1
  102. package/lib/eth/context.js +17 -11
  103. package/lib/eth/context.js.map +1 -1
  104. package/lib/eth/eth-plugin.d.ts.map +1 -1
  105. package/lib/eth/eth-plugin.js +85 -76
  106. package/lib/eth/eth-plugin.js.map +1 -1
  107. package/lib/eth/eth.d.ts +6 -6
  108. package/lib/eth/eth.d.ts.map +1 -1
  109. package/lib/eth/eth.js +39 -26
  110. package/lib/eth/eth.js.map +1 -1
  111. package/lib/eth/generic-processor.js +1 -1
  112. package/lib/eth/generic-processor.js.map +1 -1
  113. package/lib/eth/index.d.ts +2 -2
  114. package/lib/eth/index.d.ts.map +1 -1
  115. package/lib/eth/index.js +1 -2
  116. package/lib/eth/index.js.map +1 -1
  117. package/lib/eth/provider.d.ts +13 -0
  118. package/lib/eth/provider.d.ts.map +1 -0
  119. package/lib/eth/provider.js +164 -0
  120. package/lib/eth/provider.js.map +1 -0
  121. package/lib/fuel/asset-processor.d.ts +2 -2
  122. package/lib/fuel/asset-processor.d.ts.map +1 -1
  123. package/lib/fuel/asset-processor.js +5 -3
  124. package/lib/fuel/asset-processor.js.map +1 -1
  125. package/lib/fuel/context.d.ts.map +1 -1
  126. package/lib/fuel/context.js +4 -2
  127. package/lib/fuel/context.js.map +1 -1
  128. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  129. package/lib/fuel/fuel-plugin.js +41 -53
  130. package/lib/fuel/fuel-plugin.js.map +1 -1
  131. package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
  132. package/lib/fuel/fuel-processor-template.js +9 -5
  133. package/lib/fuel/fuel-processor-template.js.map +1 -1
  134. package/lib/fuel/fuel-processor.d.ts.map +1 -1
  135. package/lib/fuel/fuel-processor.js +30 -20
  136. package/lib/fuel/fuel-processor.js.map +1 -1
  137. package/lib/fuel/global-processor.d.ts.map +1 -1
  138. package/lib/fuel/global-processor.js +2 -1
  139. package/lib/fuel/global-processor.js.map +1 -1
  140. package/lib/fuel/network.js +5 -5
  141. package/lib/fuel/network.js.map +1 -1
  142. package/lib/fuel/types.d.ts +10 -4
  143. package/lib/fuel/types.d.ts.map +1 -1
  144. package/lib/fuel/types.js.map +1 -1
  145. package/lib/iota/context.d.ts +1 -1
  146. package/lib/iota/context.d.ts.map +1 -1
  147. package/lib/iota/context.js +8 -6
  148. package/lib/iota/context.js.map +1 -1
  149. package/lib/iota/iota-object-processor-template.d.ts +1 -1
  150. package/lib/iota/iota-object-processor-template.d.ts.map +1 -1
  151. package/lib/iota/iota-object-processor-template.js +17 -12
  152. package/lib/iota/iota-object-processor-template.js.map +1 -1
  153. package/lib/iota/iota-object-processor.d.ts +1 -1
  154. package/lib/iota/iota-object-processor.d.ts.map +1 -1
  155. package/lib/iota/iota-object-processor.js +23 -16
  156. package/lib/iota/iota-object-processor.js.map +1 -1
  157. package/lib/iota/iota-plugin-part.d.ts +1 -1
  158. package/lib/iota/iota-plugin-part.d.ts.map +1 -1
  159. package/lib/iota/iota-plugin-part.js +16 -15
  160. package/lib/iota/iota-plugin-part.js.map +1 -1
  161. package/lib/iota/iota-processor.d.ts +3 -3
  162. package/lib/iota/iota-processor.d.ts.map +1 -1
  163. package/lib/iota/iota-processor.js +20 -19
  164. package/lib/iota/iota-processor.js.map +1 -1
  165. package/lib/iota/network.js +6 -6
  166. package/lib/iota/network.js.map +1 -1
  167. package/lib/move/filter.d.ts +1 -1
  168. package/lib/move/filter.d.ts.map +1 -1
  169. package/lib/move/index.d.ts +1 -1
  170. package/lib/move/index.d.ts.map +1 -1
  171. package/lib/move/index.js +0 -1
  172. package/lib/move/index.js.map +1 -1
  173. package/lib/solana/builtin/types.d.ts +4 -4
  174. package/lib/solana/codegen/codegen.d.ts +1 -1
  175. package/lib/solana/codegen/codegen.d.ts.map +1 -1
  176. package/lib/solana/codegen/codegen.js +2 -2
  177. package/lib/solana/codegen/codegen.js.map +1 -1
  178. package/lib/solana/solana-context.d.ts.map +1 -1
  179. package/lib/solana/solana-context.js +4 -3
  180. package/lib/solana/solana-context.js.map +1 -1
  181. package/lib/solana/solana-plugin.d.ts.map +1 -1
  182. package/lib/solana/solana-plugin.js +19 -18
  183. package/lib/solana/solana-plugin.js.map +1 -1
  184. package/lib/solana/solana-processor.d.ts +2 -2
  185. package/lib/solana/solana-processor.d.ts.map +1 -1
  186. package/lib/solana/solana-processor.js +8 -3
  187. package/lib/solana/solana-processor.js.map +1 -1
  188. package/lib/store/cache.d.ts.map +1 -1
  189. package/lib/store/cache.js +22 -17
  190. package/lib/store/cache.js.map +1 -1
  191. package/lib/store/codegen.js +2 -2
  192. package/lib/store/codegen.js.map +1 -1
  193. package/lib/store/convert.d.ts +1 -1
  194. package/lib/store/convert.d.ts.map +1 -1
  195. package/lib/store/convert.js +67 -104
  196. package/lib/store/convert.js.map +1 -1
  197. package/lib/store/decorators.d.ts +1 -1
  198. package/lib/store/decorators.d.ts.map +1 -1
  199. package/lib/store/decorators.js +3 -1
  200. package/lib/store/decorators.js.map +1 -1
  201. package/lib/store/store.d.ts.map +1 -1
  202. package/lib/store/store.js +24 -16
  203. package/lib/store/store.js.map +1 -1
  204. package/lib/store/types.js +24 -32
  205. package/lib/store/types.js.map +1 -1
  206. package/lib/store/util.d.ts +1 -1
  207. package/lib/store/util.d.ts.map +1 -1
  208. package/lib/store/util.js +13 -17
  209. package/lib/store/util.js.map +1 -1
  210. package/lib/sui/context.d.ts +1 -1
  211. package/lib/sui/context.d.ts.map +1 -1
  212. package/lib/sui/context.js +8 -6
  213. package/lib/sui/context.js.map +1 -1
  214. package/lib/sui/network.d.ts.map +1 -1
  215. package/lib/sui/network.js +11 -6
  216. package/lib/sui/network.js.map +1 -1
  217. package/lib/sui/sui-object-processor-template.d.ts +1 -1
  218. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  219. package/lib/sui/sui-object-processor-template.js +17 -12
  220. package/lib/sui/sui-object-processor-template.js.map +1 -1
  221. package/lib/sui/sui-object-processor.d.ts +1 -1
  222. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  223. package/lib/sui/sui-object-processor.js +29 -21
  224. package/lib/sui/sui-object-processor.js.map +1 -1
  225. package/lib/sui/sui-plugin-part.d.ts +1 -1
  226. package/lib/sui/sui-plugin-part.d.ts.map +1 -1
  227. package/lib/sui/sui-plugin-part.js +16 -15
  228. package/lib/sui/sui-plugin-part.js.map +1 -1
  229. package/lib/sui/sui-plugin.d.ts +1 -1
  230. package/lib/sui/sui-plugin.d.ts.map +1 -1
  231. package/lib/sui/sui-plugin.js +35 -34
  232. package/lib/sui/sui-plugin.js.map +1 -1
  233. package/lib/sui/sui-processor.d.ts +3 -3
  234. package/lib/sui/sui-processor.d.ts.map +1 -1
  235. package/lib/sui/sui-processor.js +23 -21
  236. package/lib/sui/sui-processor.js.map +1 -1
  237. package/lib/sui/to-client-types.d.ts +4 -0
  238. package/lib/sui/to-client-types.d.ts.map +1 -0
  239. package/lib/sui/to-client-types.js +69 -0
  240. package/lib/sui/to-client-types.js.map +1 -0
  241. package/lib/testing/aptos-facet.d.ts.map +1 -1
  242. package/lib/testing/aptos-facet.js +18 -11
  243. package/lib/testing/aptos-facet.js.map +1 -1
  244. package/lib/testing/cosmos-facet.d.ts.map +1 -1
  245. package/lib/testing/cosmos-facet.js +10 -6
  246. package/lib/testing/cosmos-facet.js.map +1 -1
  247. package/lib/testing/eth-facet.d.ts +1 -1
  248. package/lib/testing/eth-facet.d.ts.map +1 -1
  249. package/lib/testing/eth-facet.js +34 -18
  250. package/lib/testing/eth-facet.js.map +1 -1
  251. package/lib/testing/fuel-facet.d.ts.map +1 -1
  252. package/lib/testing/fuel-facet.js +28 -18
  253. package/lib/testing/fuel-facet.js.map +1 -1
  254. package/lib/testing/iota-facet.d.ts.map +1 -1
  255. package/lib/testing/iota-facet.js +32 -20
  256. package/lib/testing/iota-facet.js.map +1 -1
  257. package/lib/testing/memory-database.d.ts +11 -3
  258. package/lib/testing/memory-database.d.ts.map +1 -1
  259. package/lib/testing/memory-database.js +85 -69
  260. package/lib/testing/memory-database.js.map +1 -1
  261. package/lib/testing/metric-utils.d.ts +2 -2
  262. package/lib/testing/metric-utils.d.ts.map +1 -1
  263. package/lib/testing/metric-utils.js +13 -12
  264. package/lib/testing/metric-utils.js.map +1 -1
  265. package/lib/testing/solana-facet.d.ts +3 -2
  266. package/lib/testing/solana-facet.d.ts.map +1 -1
  267. package/lib/testing/solana-facet.js +8 -5
  268. package/lib/testing/solana-facet.js.map +1 -1
  269. package/lib/testing/sui-facet.d.ts.map +1 -1
  270. package/lib/testing/sui-facet.js +30 -20
  271. package/lib/testing/sui-facet.js.map +1 -1
  272. package/lib/testing/test-processor-server.d.ts +1452 -16
  273. package/lib/testing/test-processor-server.d.ts.map +1 -1
  274. package/lib/testing/test-processor-server.js +109 -46
  275. package/lib/testing/test-processor-server.js.map +1 -1
  276. package/lib/testing/test-provider.js +1 -1
  277. package/lib/testing/test-provider.js.map +1 -1
  278. package/lib/utils/price.d.ts +1 -1
  279. package/lib/utils/price.d.ts.map +1 -1
  280. package/lib/utils/price.js +19 -12
  281. package/lib/utils/price.js.map +1 -1
  282. package/package.json +10 -12
  283. package/src/aptos/aptos-plugin.ts +105 -91
  284. package/src/aptos/aptos-processor.ts +42 -34
  285. package/src/aptos/aptos-resource-processor-template.ts +15 -6
  286. package/src/aptos/context.ts +11 -10
  287. package/src/aptos/data.ts +4 -4
  288. package/src/aptos/network.ts +1 -1
  289. package/src/core/base-context.ts +19 -12
  290. package/src/core/core-plugin.ts +10 -7
  291. package/src/core/event-logger.ts +63 -35
  292. package/src/core/exporter.ts +5 -4
  293. package/src/core/handler-options.ts +1 -1
  294. package/src/core/handler-register.ts +3 -3
  295. package/src/core/meter.ts +9 -7
  296. package/src/core/normalization.ts +53 -31
  297. package/src/core/numberish.ts +46 -30
  298. package/src/core/partition-handler-manager.ts +13 -11
  299. package/src/cosmos/context.ts +4 -3
  300. package/src/cosmos/cosmos-plugin.ts +19 -15
  301. package/src/cosmos/cosmos-processor.ts +2 -2
  302. package/src/eth/abi-decoder/decode-worker.ts +2 -2
  303. package/src/eth/account-processor.ts +21 -12
  304. package/src/eth/base-processor-template.ts +27 -11
  305. package/src/eth/base-processor.ts +77 -65
  306. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
  307. package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
  308. package/src/eth/builtin/internal/erc20-processor.ts +152 -91
  309. package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
  310. package/src/eth/builtin/internal/erc721-processor.ts +109 -65
  311. package/src/eth/builtin/internal/weth9-processor.ts +95 -56
  312. package/src/eth/codegen/file.ts +2 -1
  313. package/src/eth/codegen/function-calls.ts +1 -1
  314. package/src/eth/context.ts +29 -13
  315. package/src/eth/eth-plugin.ts +137 -127
  316. package/src/eth/eth.ts +46 -32
  317. package/src/eth/generic-processor.ts +1 -1
  318. package/src/eth/index.ts +2 -2
  319. package/src/eth/provider.ts +193 -0
  320. package/src/fuel/asset-processor.ts +16 -8
  321. package/src/fuel/context.ts +4 -3
  322. package/src/fuel/fuel-plugin.ts +71 -73
  323. package/src/fuel/fuel-processor-template.ts +10 -7
  324. package/src/fuel/fuel-processor.ts +35 -23
  325. package/src/fuel/global-processor.ts +3 -3
  326. package/src/fuel/network.ts +5 -5
  327. package/src/fuel/types.ts +10 -4
  328. package/src/iota/context.ts +8 -7
  329. package/src/iota/iota-object-processor-template.ts +25 -15
  330. package/src/iota/iota-object-processor.ts +33 -22
  331. package/src/iota/iota-plugin-part.ts +41 -34
  332. package/src/iota/iota-processor.ts +35 -27
  333. package/src/iota/network.ts +6 -6
  334. package/src/move/filter.ts +1 -1
  335. package/src/move/index.ts +1 -1
  336. package/src/solana/codegen/codegen.ts +2 -2
  337. package/src/solana/solana-context.ts +4 -3
  338. package/src/solana/solana-plugin.ts +27 -24
  339. package/src/solana/solana-processor.ts +23 -11
  340. package/src/store/cache.ts +22 -18
  341. package/src/store/codegen.ts +2 -2
  342. package/src/store/convert.ts +68 -104
  343. package/src/store/decorators.ts +3 -2
  344. package/src/store/store.ts +31 -23
  345. package/src/store/types.ts +24 -33
  346. package/src/store/util.ts +13 -18
  347. package/src/sui/context.ts +8 -7
  348. package/src/sui/network.ts +12 -7
  349. package/src/sui/sui-object-processor-template.ts +25 -15
  350. package/src/sui/sui-object-processor.ts +50 -28
  351. package/src/sui/sui-plugin-part.ts +41 -34
  352. package/src/sui/sui-plugin.ts +49 -47
  353. package/src/sui/sui-processor.ts +38 -29
  354. package/src/sui/to-client-types.ts +75 -0
  355. package/src/testing/aptos-facet.ts +18 -11
  356. package/src/testing/cosmos-facet.ts +10 -6
  357. package/src/testing/eth-facet.ts +40 -18
  358. package/src/testing/fuel-facet.ts +28 -18
  359. package/src/testing/iota-facet.ts +32 -20
  360. package/src/testing/memory-database.ts +126 -85
  361. package/src/testing/metric-utils.ts +15 -14
  362. package/src/testing/solana-facet.ts +11 -6
  363. package/src/testing/sui-facet.ts +30 -20
  364. package/src/testing/test-processor-server.ts +170 -80
  365. package/src/testing/test-provider.ts +1 -1
  366. package/src/utils/price.ts +20 -13
@@ -1,31 +1,43 @@
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
+ type DBResponse,
7
+ DBResponseSchema,
8
+ type ProcessStreamResponseV3,
9
+ type RichStruct,
10
+ type RichValue,
11
+ RichValueSchema,
12
+ type RichValueList,
13
+ RichValueListSchema,
14
+ timestampNow
10
15
  } from '@sentio/protos'
16
+ import { create } from '@bufbuild/protobuf'
11
17
  import { GraphQLField, GraphQLSchema, parse, StringValueNode } from 'graphql/index.js'
12
18
  import { DatabaseSchemaState } from '../core/database-schema.js'
13
19
  import { buildSchema } from '../store/schema.js'
14
20
  import { GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLOutputType } from 'graphql'
15
- import { PluginManager } from '@sentio/runtime'
21
+ import { type IStoreContext, PluginManager } from '@sentio/runtime'
16
22
  import { BigDecimalConverter, BigIntConverter } from '../store/convert.js'
17
23
  import { BigDecimal } from '@sentio/bigdecimal'
18
24
  import { Store } from '../store/store.js'
25
+ import { Subject } from 'rxjs'
19
26
 
20
27
  // Internal entity name used by MemoryCache - bypasses schema validation
21
28
  const MEMORY_CACHE_ITEM_ENTITY = 'MemoryCacheItem'
22
29
 
30
+ type MemoryDatabaseContext = IStoreContext & {
31
+ subject: Subject<any>
32
+ result(dbResult: DBResponse, processId?: number): void
33
+ }
34
+
23
35
  export class MemoryDatabase {
24
36
  db = new Map<string, Record<string, any>>()
25
37
  public lastDbRequest: DBRequest | undefined
26
38
  _schema: GraphQLSchema
27
39
 
28
- constructor(readonly dbContext: StoreContext) {}
40
+ constructor(readonly dbContext: MemoryDatabaseContext) {}
29
41
 
30
42
  get schema() {
31
43
  if (!this._schema) {
@@ -43,7 +55,9 @@ export class MemoryDatabase {
43
55
  }
44
56
 
45
57
  start() {
46
- this.dbContext.subject.subscribe(this.processRequest.bind(this))
58
+ // The subject is typed as the `ProcessStreamResponseV3` init-shape, but at runtime it always carries a
59
+ // full response (the store context emits the complete oneof). Treat it as a full message and narrow inside.
60
+ this.dbContext.subject.subscribe((request) => this.processRequest(request as unknown as ProcessStreamResponseV3))
47
61
  }
48
62
 
49
63
  stop() {
@@ -111,20 +125,25 @@ export class MemoryDatabase {
111
125
  if (elemDb) {
112
126
  for (const elemID of Object.keys(elemDb)) {
113
127
  const value = elemDb[elemID]
114
- const deriveField = value.fields[derivedFrom]
128
+ const deriveField: RichValue | undefined = value.fields[derivedFrom]
115
129
  let hasRelation = false
116
- if (deriveField?.stringValue === id) {
130
+ if (deriveField?.value.case === 'stringValue' && deriveField.value.value === id) {
117
131
  hasRelation = true
118
132
  }
119
- if (deriveField?.listValue) {
120
- hasRelation = deriveField.listValue.values.some((v: any) => v.stringValue === id)
133
+ if (deriveField?.value.case === 'listValue') {
134
+ hasRelation = deriveField.value.value.values.some(
135
+ (v) => v.value.case === 'stringValue' && v.value.value === id
136
+ )
121
137
  }
122
138
  if (hasRelation) {
123
- const arr = result.fields[field.name]
124
- if (arr) {
125
- arr.listValue.values.push({ stringValue: elemID })
139
+ const arr: RichValue | undefined = result.fields[field.name]
140
+ const elem = create(RichValueSchema, { value: { case: 'stringValue', value: elemID } })
141
+ if (arr && arr.value.case === 'listValue') {
142
+ arr.value.value.values.push(elem)
126
143
  } else {
127
- result.fields[field.name] = { listValue: { values: [{ stringValue: elemID }] } }
144
+ result.fields[field.name] = create(RichValueSchema, {
145
+ value: { case: 'listValue', value: { values: [elem] } }
146
+ })
128
147
  }
129
148
  }
130
149
  }
@@ -137,8 +156,8 @@ export class MemoryDatabase {
137
156
  return result
138
157
  }
139
158
 
140
- private processRequest(request: ProcessStreamResponse) {
141
- const req = request.dbRequest
159
+ private processRequest(request: ProcessStreamResponseV3) {
160
+ const req = request.value.case === 'dbRequest' ? request.value.value : undefined
142
161
 
143
162
  // Check if schema is required for this request
144
163
  const requiresSchema = this.requestRequiresSchema(req)
@@ -149,63 +168,75 @@ export class MemoryDatabase {
149
168
 
150
169
  this.lastDbRequest = req
151
170
  if (req) {
152
- if (req.upsert) {
153
- const { entityData, entity } = req.upsert
171
+ if (req.op.case === 'upsert') {
172
+ const { entityData, entity } = req.op.value
154
173
  entityData.forEach((d, i) => {
155
- const id = d.fields['id'].stringValue!
174
+ const idField = d.fields['id']
175
+ const id = idField?.value.case === 'stringValue' ? idField.value.value : ''
156
176
  const entityName = entity[i]
157
177
  this.upsert(entityName, id, d)
158
178
  })
159
179
 
160
- this.dbContext.result({
161
- opId: req.opId
162
- })
180
+ this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
163
181
  }
164
- if (req.delete) {
165
- const { id, entity } = req.delete
182
+ if (req.op.case === 'delete') {
183
+ const { id, entity } = req.op.value
166
184
  id.forEach((i, idx) => {
167
185
  const entityName = entity[idx]
168
186
  this.delete(entityName, i)
169
187
  })
170
- this.dbContext.result({
171
- opId: req.opId
172
- })
188
+ this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
173
189
  }
174
190
 
175
- if (req.get) {
176
- const { entity, id } = req.get
191
+ if (req.op.case === 'get') {
192
+ const { entity, id } = req.op.value
177
193
  const data = this.getById(entity, id)
178
- this.dbContext.result({
179
- opId: req.opId,
180
- // entities: { entities: data ? [data] : [] },
181
- entityList: {
182
- entities: data ? [toEntity(data)] : []
183
- }
184
- })
194
+ this.sendResult(
195
+ request,
196
+ create(DBResponseSchema, {
197
+ opId: req.opId,
198
+ value: {
199
+ case: 'entityList',
200
+ value: {
201
+ entities: data ? [toEntity(data)] : []
202
+ }
203
+ }
204
+ })
205
+ )
185
206
  }
186
- if (req.list) {
187
- const { entity, cursor, filters } = req.list
207
+ if (req.op.case === 'list') {
208
+ const { entity, cursor, filters } = req.op.value
188
209
  const list = this.listEntities(entity, filters)
189
210
 
190
211
  if (cursor) {
191
212
  const idx = parseInt(cursor)
192
213
 
193
- this.dbContext.result({
194
- opId: req.opId,
195
- entityList: { entities: list.slice(idx, idx + 1).map((d) => toEntity(d)) },
196
- nextCursor: idx + 1 < list.length ? `${idx + 1}` : undefined
197
- })
214
+ this.sendResult(
215
+ request,
216
+ create(DBResponseSchema, {
217
+ opId: req.opId,
218
+ value: { case: 'entityList', value: { entities: list.slice(idx, idx + 1).map((d) => toEntity(d)) } },
219
+ nextCursor: idx + 1 < list.length ? `${idx + 1}` : undefined
220
+ })
221
+ )
198
222
  } else {
199
- this.dbContext.result({
200
- opId: req.opId,
201
- entityList: { entities: list.length ? [toEntity(list[0])] : [] },
202
- nextCursor: '1'
203
- })
223
+ this.sendResult(
224
+ request,
225
+ create(DBResponseSchema, {
226
+ opId: req.opId,
227
+ value: { case: 'entityList', value: { entities: list.length ? [toEntity(list[0])] : [] } },
228
+ nextCursor: '1'
229
+ })
230
+ )
204
231
  }
205
232
  }
206
233
  }
207
234
  }
208
235
 
236
+ private sendResult(request: ProcessStreamResponseV3, response: DBResponse) {
237
+ this.dbContext.result(response, request.processId)
238
+ }
239
+
209
240
  reset() {
210
241
  this.db.clear()
211
242
  }
@@ -215,19 +246,18 @@ export class MemoryDatabase {
215
246
  if (!req) return false
216
247
 
217
248
  // Check if all entities in the request are MemoryCacheItem
218
- if (req.upsert) {
219
- return !req.upsert.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
220
- }
221
- if (req.delete) {
222
- return !req.delete.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
223
- }
224
- if (req.get) {
225
- return req.get.entity !== MEMORY_CACHE_ITEM_ENTITY
249
+ switch (req.op.case) {
250
+ case 'upsert':
251
+ return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
252
+ case 'delete':
253
+ return !req.op.value.entity.every((e) => e === MEMORY_CACHE_ITEM_ENTITY)
254
+ case 'get':
255
+ return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
256
+ case 'list':
257
+ return req.op.value.entity !== MEMORY_CACHE_ITEM_ENTITY
258
+ default:
259
+ return false
226
260
  }
227
- if (req.list) {
228
- return req.list.entity !== MEMORY_CACHE_ITEM_ENTITY
229
- }
230
- return false
231
261
  }
232
262
 
233
263
  private listEntities(entity: string, filters?: DBRequest_DBFilter[]) {
@@ -268,37 +298,46 @@ function filter(entity: RichStruct, filter: DBRequest_DBFilter) {
268
298
  case DBRequest_DBOperator.LE:
269
299
  return lessThan(value, filter.value) || equal(value, filter.value)
270
300
  case DBRequest_DBOperator.IN:
271
- return filter.value?.values.some((v) => equal(value, { values: [v] }))
301
+ return filter.value?.values.some((v) => equal(value, singleList(v)))
272
302
  case DBRequest_DBOperator.NOT_IN:
273
- return !filter.value?.values.some((v) => equal(value, { values: [v] }))
303
+ return !filter.value?.values.some((v) => equal(value, singleList(v)))
274
304
  case DBRequest_DBOperator.HAS_ALL:
275
- return filter.value?.values.every((v) => equal(value, { values: [v] }))
305
+ return filter.value?.values.every((v) => equal(value, singleList(v)))
276
306
  case DBRequest_DBOperator.HAS_ANY:
277
307
  for (const a of filter.value?.values ?? []) {
278
- if ((value.listValue?.values ?? []).some((v) => equal(a, { values: [v] }))) {
308
+ const listValues = value.value.case === 'listValue' ? value.value.value.values : []
309
+ if (listValues.some((v) => equal(a, singleList(v)))) {
279
310
  return true
280
311
  }
281
312
  }
282
313
  return false
283
314
  case DBRequest_DBOperator.LIKE:
284
- return like(value.stringValue, filter.value?.values[0]?.stringValue)
315
+ return like(richString(value), filter.value?.values[0] ? richString(filter.value.values[0]) : undefined)
285
316
  default:
286
317
  return false
287
318
  }
288
319
  }
289
320
 
321
+ function singleList(v: RichValue): RichValueList {
322
+ return create(RichValueListSchema, { values: [v] })
323
+ }
324
+
325
+ function richString(v?: RichValue): string | undefined {
326
+ return v?.value.case === 'stringValue' ? v.value.value : undefined
327
+ }
328
+
290
329
  function getValue(entity: RichStruct, field: string) {
291
330
  return entity.fields[field]
292
331
  }
293
332
 
294
333
  function equal(field: RichValue, value?: RichValueList): boolean {
295
- if (field.stringValue !== undefined) {
296
- return field.stringValue === value?.values[0]?.stringValue
334
+ if (field.value.case === 'stringValue') {
335
+ return field.value.value === richString(value?.values[0])
297
336
  }
298
- if (field.listValue) {
299
- return field.listValue.values.every((v, i) => {
337
+ if (field.value.case === 'listValue') {
338
+ return field.value.value.values.every((v, i) => {
300
339
  const vv = value?.values[i]
301
- return equal(v, vv ? { values: [vv] } : undefined)
340
+ return equal(v, vv ? singleList(vv) : undefined)
302
341
  })
303
342
  }
304
343
  const a = toNumber(field)
@@ -335,19 +374,21 @@ function lessThan(field: RichValue, value: RichValueList | undefined) {
335
374
  }
336
375
 
337
376
  function toNumber(value?: RichValue) {
338
- if (value?.intValue !== undefined) {
339
- return value.intValue
340
- }
341
- if (value?.floatValue !== undefined) {
342
- return value.floatValue
343
- }
344
- if (value?.bigintValue !== undefined) {
345
- return BigIntConverter.to(value) as bigint
377
+ if (value === undefined) {
378
+ return undefined
346
379
  }
347
- if (value?.bigdecimalValue !== undefined) {
348
- return BigDecimalConverter.to(value) as BigDecimal
380
+ switch (value.value.case) {
381
+ case 'intValue':
382
+ return value.value.value
383
+ case 'floatValue':
384
+ return value.value.value
385
+ case 'bigintValue':
386
+ return BigIntConverter.to(value) as bigint
387
+ case 'bigdecimalValue':
388
+ return BigDecimalConverter.to(value) as BigDecimal
389
+ default:
390
+ return undefined
349
391
  }
350
- return undefined
351
392
  }
352
393
 
353
394
  function toEntity(data: any) {
@@ -355,7 +396,7 @@ function toEntity(data: any) {
355
396
  entity: data.entity,
356
397
  genBlockChain: '',
357
398
  genBlockNumber: 0n,
358
- genBlockTime: new Date(),
399
+ genBlockTime: timestampNow(),
359
400
  data: { fields: data.fields }
360
401
  }
361
402
  }
@@ -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 {
@@ -1,5 +1,6 @@
1
1
  import { TestProcessorServer } from './test-processor-server.js'
2
- import { Data_SolInstruction, HandlerType, ProcessBindingResponse } from '@sentio/protos'
2
+ import { Data_SolInstructionSchema, DataBindingSchema, HandlerType, type ProcessBindingResponse } from '@sentio/protos'
3
+ import { create, type MessageInitShape } from '@bufbuild/protobuf'
3
4
  import { ChainId } from '@sentio/chain'
4
5
 
5
6
  export class SolanaFacet {
@@ -9,18 +10,22 @@ export class SolanaFacet {
9
10
  this.server = server
10
11
  }
11
12
 
12
- testInstructions(instructions: Data_SolInstruction[]): Promise<ProcessBindingResponse> {
13
+ testInstructions(
14
+ instructions: MessageInitShape<typeof Data_SolInstructionSchema>[]
15
+ ): Promise<ProcessBindingResponse> {
13
16
  return this.server.processBindings({
14
17
  bindings: instructions.map((instruction) => {
15
- return {
18
+ return create(DataBindingSchema, {
16
19
  data: {
17
- raw: new Uint8Array(),
18
- solInstruction: instruction
20
+ value: {
21
+ case: 'solInstruction',
22
+ value: instruction
23
+ }
19
24
  },
20
25
  handlerIds: [],
21
26
  handlerType: HandlerType.SOL_INSTRUCTION,
22
27
  chainId: ChainId.SOLANA_MAINNET
23
- }
28
+ })
24
29
  })
25
30
  })
26
31
  }
@@ -1,5 +1,6 @@
1
1
  import type { GrpcTypes } from '@mysten/sui/grpc'
2
- import { DataBinding, HandlerType } from '@sentio/protos'
2
+ import { type DataBinding, DataBindingSchema, HandlerType, 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 { SuiNetwork } from '../sui/index.js'
@@ -47,18 +48,21 @@ export class SuiFacet {
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,21 @@ export class SuiFacet {
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: new Date(),
101
- slot: BigInt(transaction.checkpoint || 0)
102
+ value: {
103
+ case: 'suiCall',
104
+ value: {
105
+ rawTransaction: JSON.stringify(transaction),
106
+ timestamp: timestampNow(),
107
+ slot: BigInt(transaction.checkpoint || 0)
108
+ }
102
109
  }
103
110
  },
104
111
  chainId: network
105
- }
112
+ })
106
113
  return this.server.processBinding(binding)
107
114
  }
108
115
 
@@ -123,19 +130,22 @@ export class SuiFacet {
123
130
  accountTypeString(config.contract.address) + '::' + eventFilter.type ===
124
131
  parseMoveType(event.eventType ?? '').qname
125
132
  ) {
126
- return {
133
+ return create(DataBindingSchema, {
127
134
  data: {
128
- suiEvent: {
129
- rawEvent: JSON.stringify(event),
130
- rawTransaction: JSON.stringify(transaction),
131
- timestamp: new Date(),
132
- slot: 10000n
135
+ value: {
136
+ case: 'suiEvent',
137
+ value: {
138
+ rawEvent: JSON.stringify(event),
139
+ rawTransaction: JSON.stringify(transaction),
140
+ timestamp: timestampNow(),
141
+ slot: 10000n
142
+ }
133
143
  }
134
144
  },
135
145
  handlerIds: [eventConfig.handlerId],
136
146
  handlerType: HandlerType.SUI_EVENT,
137
147
  chainId: network
138
- }
148
+ })
139
149
  }
140
150
  }
141
151
  }