@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,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,10 +55,9 @@ export class MemoryDatabase {
43
55
  }
44
56
 
45
57
  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))
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))
50
61
  }
51
62
 
52
63
  stop() {
@@ -114,20 +125,25 @@ export class MemoryDatabase {
114
125
  if (elemDb) {
115
126
  for (const elemID of Object.keys(elemDb)) {
116
127
  const value = elemDb[elemID]
117
- const deriveField = value.fields[derivedFrom]
128
+ const deriveField: RichValue | undefined = value.fields[derivedFrom]
118
129
  let hasRelation = false
119
- if (deriveField?.stringValue === id) {
130
+ if (deriveField?.value.case === 'stringValue' && deriveField.value.value === id) {
120
131
  hasRelation = true
121
132
  }
122
- if (deriveField?.listValue) {
123
- 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
+ )
124
137
  }
125
138
  if (hasRelation) {
126
- const arr = result.fields[field.name]
127
- if (arr) {
128
- 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)
129
143
  } else {
130
- result.fields[field.name] = { listValue: { values: [{ stringValue: elemID }] } }
144
+ result.fields[field.name] = create(RichValueSchema, {
145
+ value: { case: 'listValue', value: { values: [elem] } }
146
+ })
131
147
  }
132
148
  }
133
149
  }
@@ -140,8 +156,8 @@ export class MemoryDatabase {
140
156
  return result
141
157
  }
142
158
 
143
- private processRequest(request: ProcessStreamResponse) {
144
- const req = request.dbRequest
159
+ private processRequest(request: ProcessStreamResponseV3) {
160
+ const req = request.value.case === 'dbRequest' ? request.value.value : undefined
145
161
 
146
162
  // Check if schema is required for this request
147
163
  const requiresSchema = this.requestRequiresSchema(req)
@@ -152,63 +168,75 @@ export class MemoryDatabase {
152
168
 
153
169
  this.lastDbRequest = req
154
170
  if (req) {
155
- if (req.upsert) {
156
- const { entityData, entity } = req.upsert
171
+ if (req.op.case === 'upsert') {
172
+ const { entityData, entity } = req.op.value
157
173
  entityData.forEach((d, i) => {
158
- const id = d.fields['id'].stringValue!
174
+ const idField = d.fields['id']
175
+ const id = idField?.value.case === 'stringValue' ? idField.value.value : ''
159
176
  const entityName = entity[i]
160
177
  this.upsert(entityName, id, d)
161
178
  })
162
179
 
163
- this.dbContext.result({
164
- opId: req.opId
165
- })
180
+ this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
166
181
  }
167
- if (req.delete) {
168
- const { id, entity } = req.delete
182
+ if (req.op.case === 'delete') {
183
+ const { id, entity } = req.op.value
169
184
  id.forEach((i, idx) => {
170
185
  const entityName = entity[idx]
171
186
  this.delete(entityName, i)
172
187
  })
173
- this.dbContext.result({
174
- opId: req.opId
175
- })
188
+ this.sendResult(request, create(DBResponseSchema, { opId: req.opId }))
176
189
  }
177
190
 
178
- if (req.get) {
179
- const { entity, id } = req.get
191
+ if (req.op.case === 'get') {
192
+ const { entity, id } = req.op.value
180
193
  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
- })
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
+ )
188
206
  }
189
- if (req.list) {
190
- const { entity, cursor, filters } = req.list
207
+ if (req.op.case === 'list') {
208
+ const { entity, cursor, filters } = req.op.value
191
209
  const list = this.listEntities(entity, filters)
192
210
 
193
211
  if (cursor) {
194
212
  const idx = parseInt(cursor)
195
213
 
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
- })
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
+ )
201
222
  } else {
202
- this.dbContext.result({
203
- opId: req.opId,
204
- entityList: { entities: list.length ? [toEntity(list[0])] : [] },
205
- nextCursor: '1'
206
- })
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
+ )
207
231
  }
208
232
  }
209
233
  }
210
234
  }
211
235
 
236
+ private sendResult(request: ProcessStreamResponseV3, response: DBResponse) {
237
+ this.dbContext.result(response, request.processId)
238
+ }
239
+
212
240
  reset() {
213
241
  this.db.clear()
214
242
  }
@@ -218,19 +246,18 @@ export class MemoryDatabase {
218
246
  if (!req) return false
219
247
 
220
248
  // 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)
223
- }
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
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
229
260
  }
230
- if (req.list) {
231
- return req.list.entity !== MEMORY_CACHE_ITEM_ENTITY
232
- }
233
- return false
234
261
  }
235
262
 
236
263
  private listEntities(entity: string, filters?: DBRequest_DBFilter[]) {
@@ -271,37 +298,46 @@ function filter(entity: RichStruct, filter: DBRequest_DBFilter) {
271
298
  case DBRequest_DBOperator.LE:
272
299
  return lessThan(value, filter.value) || equal(value, filter.value)
273
300
  case DBRequest_DBOperator.IN:
274
- return filter.value?.values.some((v) => equal(value, { values: [v] }))
301
+ return filter.value?.values.some((v) => equal(value, singleList(v)))
275
302
  case DBRequest_DBOperator.NOT_IN:
276
- return !filter.value?.values.some((v) => equal(value, { values: [v] }))
303
+ return !filter.value?.values.some((v) => equal(value, singleList(v)))
277
304
  case DBRequest_DBOperator.HAS_ALL:
278
- return filter.value?.values.every((v) => equal(value, { values: [v] }))
305
+ return filter.value?.values.every((v) => equal(value, singleList(v)))
279
306
  case DBRequest_DBOperator.HAS_ANY:
280
307
  for (const a of filter.value?.values ?? []) {
281
- 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)))) {
282
310
  return true
283
311
  }
284
312
  }
285
313
  return false
286
314
  case DBRequest_DBOperator.LIKE:
287
- return like(value.stringValue, filter.value?.values[0]?.stringValue)
315
+ return like(richString(value), filter.value?.values[0] ? richString(filter.value.values[0]) : undefined)
288
316
  default:
289
317
  return false
290
318
  }
291
319
  }
292
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
+
293
329
  function getValue(entity: RichStruct, field: string) {
294
330
  return entity.fields[field]
295
331
  }
296
332
 
297
333
  function equal(field: RichValue, value?: RichValueList): boolean {
298
- if (field.stringValue !== undefined) {
299
- return field.stringValue === value?.values[0]?.stringValue
334
+ if (field.value.case === 'stringValue') {
335
+ return field.value.value === richString(value?.values[0])
300
336
  }
301
- if (field.listValue) {
302
- return field.listValue.values.every((v, i) => {
337
+ if (field.value.case === 'listValue') {
338
+ return field.value.value.values.every((v, i) => {
303
339
  const vv = value?.values[i]
304
- return equal(v, vv ? { values: [vv] } : undefined)
340
+ return equal(v, vv ? singleList(vv) : undefined)
305
341
  })
306
342
  }
307
343
  const a = toNumber(field)
@@ -338,19 +374,21 @@ function lessThan(field: RichValue, value: RichValueList | undefined) {
338
374
  }
339
375
 
340
376
  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
377
+ if (value === undefined) {
378
+ return undefined
349
379
  }
350
- if (value?.bigdecimalValue !== undefined) {
351
- 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
352
391
  }
353
- return undefined
354
392
  }
355
393
 
356
394
  function toEntity(data: any) {
@@ -358,7 +396,7 @@ function toEntity(data: any) {
358
396
  entity: data.entity,
359
397
  genBlockChain: '',
360
398
  genBlockNumber: 0n,
361
- genBlockTime: new Date(),
399
+ genBlockTime: timestampNow(),
362
400
  data: { fields: data.fields }
363
401
  }
364
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
  }