@sentio/sdk 3.9.0-rc.9 → 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 (340) 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 +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 +14 -8
  71. package/lib/eth/base-processor-template.js.map +1 -1
  72. package/lib/eth/base-processor.d.ts +3 -3
  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 +9 -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 +3 -3
  152. package/lib/iota/iota-processor.d.ts.map +1 -1
  153. package/lib/iota/iota-processor.js +20 -19
  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/codegen/codegen.d.ts +1 -1
  165. package/lib/solana/codegen/codegen.d.ts.map +1 -1
  166. package/lib/solana/codegen/codegen.js +2 -2
  167. package/lib/solana/codegen/codegen.js.map +1 -1
  168. package/lib/solana/solana-context.d.ts.map +1 -1
  169. package/lib/solana/solana-context.js +4 -3
  170. package/lib/solana/solana-context.js.map +1 -1
  171. package/lib/solana/solana-plugin.d.ts.map +1 -1
  172. package/lib/solana/solana-plugin.js +19 -18
  173. package/lib/solana/solana-plugin.js.map +1 -1
  174. package/lib/solana/solana-processor.d.ts +2 -2
  175. package/lib/solana/solana-processor.d.ts.map +1 -1
  176. package/lib/solana/solana-processor.js +8 -3
  177. package/lib/solana/solana-processor.js.map +1 -1
  178. package/lib/store/cache.d.ts.map +1 -1
  179. package/lib/store/cache.js +22 -17
  180. package/lib/store/cache.js.map +1 -1
  181. package/lib/store/codegen.js +2 -2
  182. package/lib/store/codegen.js.map +1 -1
  183. package/lib/store/convert.d.ts +1 -1
  184. package/lib/store/convert.d.ts.map +1 -1
  185. package/lib/store/convert.js +67 -104
  186. package/lib/store/convert.js.map +1 -1
  187. package/lib/store/decorators.d.ts +1 -1
  188. package/lib/store/decorators.d.ts.map +1 -1
  189. package/lib/store/decorators.js +3 -1
  190. package/lib/store/decorators.js.map +1 -1
  191. package/lib/store/store.d.ts.map +1 -1
  192. package/lib/store/store.js +24 -16
  193. package/lib/store/store.js.map +1 -1
  194. package/lib/store/types.js +24 -32
  195. package/lib/store/types.js.map +1 -1
  196. package/lib/store/util.d.ts +1 -1
  197. package/lib/store/util.d.ts.map +1 -1
  198. package/lib/store/util.js +13 -17
  199. package/lib/store/util.js.map +1 -1
  200. package/lib/sui/context.d.ts +1 -1
  201. package/lib/sui/context.d.ts.map +1 -1
  202. package/lib/sui/context.js +8 -6
  203. package/lib/sui/context.js.map +1 -1
  204. package/lib/sui/sui-object-processor-template.d.ts +1 -1
  205. package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
  206. package/lib/sui/sui-object-processor-template.js +17 -12
  207. package/lib/sui/sui-object-processor-template.js.map +1 -1
  208. package/lib/sui/sui-object-processor.d.ts +1 -1
  209. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  210. package/lib/sui/sui-object-processor.js +23 -16
  211. package/lib/sui/sui-object-processor.js.map +1 -1
  212. package/lib/sui/sui-plugin-part.d.ts +1 -1
  213. package/lib/sui/sui-plugin-part.d.ts.map +1 -1
  214. package/lib/sui/sui-plugin-part.js +16 -15
  215. package/lib/sui/sui-plugin-part.js.map +1 -1
  216. package/lib/sui/sui-plugin.d.ts +1 -1
  217. package/lib/sui/sui-plugin.d.ts.map +1 -1
  218. package/lib/sui/sui-plugin.js +35 -34
  219. package/lib/sui/sui-plugin.js.map +1 -1
  220. package/lib/sui/sui-processor.d.ts +3 -3
  221. package/lib/sui/sui-processor.d.ts.map +1 -1
  222. package/lib/sui/sui-processor.js +20 -19
  223. package/lib/sui/sui-processor.js.map +1 -1
  224. package/lib/testing/aptos-facet.d.ts.map +1 -1
  225. package/lib/testing/aptos-facet.js +18 -11
  226. package/lib/testing/aptos-facet.js.map +1 -1
  227. package/lib/testing/cosmos-facet.d.ts.map +1 -1
  228. package/lib/testing/cosmos-facet.js +10 -6
  229. package/lib/testing/cosmos-facet.js.map +1 -1
  230. package/lib/testing/eth-facet.d.ts +1 -1
  231. package/lib/testing/eth-facet.d.ts.map +1 -1
  232. package/lib/testing/eth-facet.js +34 -18
  233. package/lib/testing/eth-facet.js.map +1 -1
  234. package/lib/testing/fuel-facet.d.ts.map +1 -1
  235. package/lib/testing/fuel-facet.js +28 -18
  236. package/lib/testing/fuel-facet.js.map +1 -1
  237. package/lib/testing/iota-facet.d.ts.map +1 -1
  238. package/lib/testing/iota-facet.js +32 -20
  239. package/lib/testing/iota-facet.js.map +1 -1
  240. package/lib/testing/memory-database.d.ts +1 -1
  241. package/lib/testing/memory-database.d.ts.map +1 -1
  242. package/lib/testing/memory-database.js +82 -69
  243. package/lib/testing/memory-database.js.map +1 -1
  244. package/lib/testing/metric-utils.d.ts +2 -2
  245. package/lib/testing/metric-utils.d.ts.map +1 -1
  246. package/lib/testing/metric-utils.js +13 -12
  247. package/lib/testing/metric-utils.js.map +1 -1
  248. package/lib/testing/solana-facet.d.ts +3 -2
  249. package/lib/testing/solana-facet.d.ts.map +1 -1
  250. package/lib/testing/solana-facet.js +8 -5
  251. package/lib/testing/solana-facet.js.map +1 -1
  252. package/lib/testing/sui-facet.d.ts.map +1 -1
  253. package/lib/testing/sui-facet.js +30 -20
  254. package/lib/testing/sui-facet.js.map +1 -1
  255. package/lib/testing/test-processor-server.d.ts +19 -13
  256. package/lib/testing/test-processor-server.d.ts.map +1 -1
  257. package/lib/testing/test-processor-server.js +22 -20
  258. package/lib/testing/test-processor-server.js.map +1 -1
  259. package/lib/utils/price.d.ts +1 -1
  260. package/lib/utils/price.d.ts.map +1 -1
  261. package/lib/utils/price.js +19 -12
  262. package/lib/utils/price.js.map +1 -1
  263. package/package.json +10 -12
  264. package/src/aptos/aptos-plugin.ts +105 -91
  265. package/src/aptos/aptos-processor.ts +42 -34
  266. package/src/aptos/aptos-resource-processor-template.ts +15 -6
  267. package/src/aptos/context.ts +8 -7
  268. package/src/aptos/data.ts +4 -4
  269. package/src/core/base-context.ts +19 -12
  270. package/src/core/core-plugin.ts +10 -7
  271. package/src/core/event-logger.ts +63 -34
  272. package/src/core/exporter.ts +5 -4
  273. package/src/core/handler-options.ts +1 -1
  274. package/src/core/handler-register.ts +3 -3
  275. package/src/core/meter.ts +9 -7
  276. package/src/core/normalization.ts +53 -31
  277. package/src/core/numberish.ts +46 -30
  278. package/src/core/partition-handler-manager.ts +13 -11
  279. package/src/cosmos/context.ts +4 -3
  280. package/src/cosmos/cosmos-plugin.ts +19 -15
  281. package/src/cosmos/cosmos-processor.ts +2 -2
  282. package/src/eth/abi-decoder/decode-worker.ts +2 -2
  283. package/src/eth/account-processor.ts +21 -12
  284. package/src/eth/base-processor-template.ts +27 -11
  285. package/src/eth/base-processor.ts +77 -65
  286. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +177 -116
  287. package/src/eth/builtin/internal/erc1155-processor.ts +73 -38
  288. package/src/eth/builtin/internal/erc20-processor.ts +152 -91
  289. package/src/eth/builtin/internal/erc20bytes-processor.ts +80 -46
  290. package/src/eth/builtin/internal/erc721-processor.ts +109 -65
  291. package/src/eth/builtin/internal/weth9-processor.ts +95 -56
  292. package/src/eth/codegen/file.ts +2 -1
  293. package/src/eth/codegen/function-calls.ts +1 -1
  294. package/src/eth/context.ts +18 -11
  295. package/src/eth/eth-plugin.ts +135 -118
  296. package/src/eth/eth.ts +29 -20
  297. package/src/eth/index.ts +1 -1
  298. package/src/fuel/asset-processor.ts +16 -8
  299. package/src/fuel/context.ts +4 -3
  300. package/src/fuel/fuel-plugin.ts +71 -73
  301. package/src/fuel/fuel-processor-template.ts +10 -7
  302. package/src/fuel/fuel-processor.ts +35 -23
  303. package/src/fuel/global-processor.ts +3 -3
  304. package/src/fuel/types.ts +10 -4
  305. package/src/iota/context.ts +8 -7
  306. package/src/iota/iota-object-processor-template.ts +25 -15
  307. package/src/iota/iota-object-processor.ts +33 -22
  308. package/src/iota/iota-plugin-part.ts +41 -34
  309. package/src/iota/iota-processor.ts +35 -27
  310. package/src/iota/network.ts +2 -2
  311. package/src/move/filter.ts +1 -1
  312. package/src/move/index.ts +1 -1
  313. package/src/solana/codegen/codegen.ts +2 -2
  314. package/src/solana/solana-context.ts +4 -3
  315. package/src/solana/solana-plugin.ts +27 -24
  316. package/src/solana/solana-processor.ts +23 -11
  317. package/src/store/cache.ts +22 -18
  318. package/src/store/codegen.ts +2 -2
  319. package/src/store/convert.ts +68 -104
  320. package/src/store/decorators.ts +3 -2
  321. package/src/store/store.ts +31 -23
  322. package/src/store/types.ts +24 -33
  323. package/src/store/util.ts +13 -18
  324. package/src/sui/context.ts +8 -7
  325. package/src/sui/sui-object-processor-template.ts +25 -15
  326. package/src/sui/sui-object-processor.ts +33 -22
  327. package/src/sui/sui-plugin-part.ts +41 -34
  328. package/src/sui/sui-plugin.ts +49 -47
  329. package/src/sui/sui-processor.ts +35 -27
  330. package/src/testing/aptos-facet.ts +18 -11
  331. package/src/testing/cosmos-facet.ts +10 -6
  332. package/src/testing/eth-facet.ts +40 -18
  333. package/src/testing/fuel-facet.ts +28 -18
  334. package/src/testing/iota-facet.ts +32 -20
  335. package/src/testing/memory-database.ts +109 -82
  336. package/src/testing/metric-utils.ts +15 -14
  337. package/src/testing/solana-facet.ts +11 -6
  338. package/src/testing/sui-facet.ts +30 -20
  339. package/src/testing/test-processor-server.ts +64 -58
  340. package/src/utils/price.ts +20 -13
@@ -1,4 +1,16 @@
1
- import { BigDecimalRichValue, BigInteger, MetricValue, RichStruct, RichValue_NullValue } from '@sentio/protos'
1
+ import {
2
+ type BigDecimalRichValue,
3
+ BigDecimalRichValueSchema,
4
+ type BigInteger,
5
+ BigIntegerSchema,
6
+ type MetricValue,
7
+ MetricValueSchema,
8
+ type RichStruct,
9
+ RichStructSchema,
10
+ RichValueSchema,
11
+ RichValue_NullValue
12
+ } from '@sentio/protos'
13
+ import { create } from '@bufbuild/protobuf'
2
14
  import { BigDecimal } from './big-decimal.js'
3
15
 
4
16
  export type Numberish = number | bigint | BigDecimal | string
@@ -12,30 +24,30 @@ export function toMetricValue(value: Numberish): MetricValue {
12
24
  throw new Error('Cannot record infinite value')
13
25
  }
14
26
  if (Number.isInteger(value) && !Number.isSafeInteger(value)) {
15
- return MetricValue.fromPartial({
16
- bigInteger: toBigInteger(value)
27
+ return create(MetricValueSchema, {
28
+ value: { case: 'bigInteger', value: toBigInteger(value) }
17
29
  })
18
30
  }
19
31
 
20
- return MetricValue.fromPartial({
21
- doubleValue: Number(value)
32
+ return create(MetricValueSchema, {
33
+ value: { case: 'doubleValue', value: Number(value) }
22
34
  })
23
35
  }
24
36
  if (typeof value === 'bigint') {
25
- return MetricValue.fromPartial({
26
- bigInteger: toBigInteger(value)
37
+ return create(MetricValueSchema, {
38
+ value: { case: 'bigInteger', value: toBigInteger(value) }
27
39
  })
28
40
  }
29
41
  if (typeof value === 'string') {
30
- return MetricValue.fromPartial({
31
- bigDecimal: value
42
+ return create(MetricValueSchema, {
43
+ value: { case: 'bigDecimal', value: value }
32
44
  })
33
45
  }
34
46
  // if (value instanceof BigDecimal) {
35
47
  // Carefully consider the use case here
36
48
  if (value.isInteger()) {
37
- return MetricValue.fromPartial({
38
- bigInteger: bigDecimalToBigInteger(value)
49
+ return create(MetricValueSchema, {
50
+ value: { case: 'bigInteger', value: bigDecimalToBigInteger(value) }
39
51
  })
40
52
  } else {
41
53
  if (value.isNaN()) {
@@ -45,8 +57,8 @@ export function toMetricValue(value: Numberish): MetricValue {
45
57
  // NaN also not finite
46
58
  throw new Error('Cannot record infinite value')
47
59
  }
48
- return MetricValue.fromPartial({
49
- bigDecimal: value.toString() // e.g. -7.350918e-428
60
+ return create(MetricValueSchema, {
61
+ value: { case: 'bigDecimal', value: value.toString() } // e.g. -7.350918e-428
50
62
  })
51
63
  }
52
64
  // }
@@ -101,10 +113,10 @@ function hexToBigInteger(hex: string, negative: boolean): BigInteger {
101
113
  }
102
114
  const buffer = Buffer.from(hex, 'hex')
103
115
 
104
- return {
116
+ return create(BigIntegerSchema, {
105
117
  negative: negative,
106
118
  data: new Uint8Array(buffer)
107
- }
119
+ })
108
120
  }
109
121
 
110
122
  export function toBigDecimal(value: BigDecimal): BigDecimalRichValue {
@@ -115,41 +127,45 @@ export function toBigDecimal(value: BigDecimal): BigDecimalRichValue {
115
127
  .join('')
116
128
  const exp = -(s.length - (value.e ?? 0) - 1)
117
129
 
118
- return {
130
+ return create(BigDecimalRichValueSchema, {
119
131
  value: toBigInteger(BigInt(s) * BigInt(value.s ?? 1)),
120
132
  exp: exp
121
- }
133
+ })
122
134
  }
123
135
 
124
136
  export function toTimeSeriesData(value: Numberish, labels: Record<string, string>, neg: boolean) {
125
137
  const mv = toMetricValue(value)
126
- const data: RichStruct = {
138
+ const data: RichStruct = create(RichStructSchema, {
127
139
  fields: {
128
140
  value: {}
129
141
  }
130
- }
142
+ })
131
143
 
132
144
  for (const key in labels) {
133
145
  if (labels[key] == null) {
134
- data.fields[key] = { nullValue: RichValue_NullValue.NULL_VALUE }
146
+ data.fields[key] = create(RichValueSchema, {
147
+ value: { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE }
148
+ })
135
149
  } else {
136
- data.fields[key] = { stringValue: labels[key] }
150
+ data.fields[key] = create(RichValueSchema, { value: { case: 'stringValue', value: labels[key] } })
137
151
  }
138
152
  }
139
153
 
140
- if (mv.bigInteger != null) {
141
- mv.bigInteger.negative = neg ? !mv.bigInteger.negative : mv.bigInteger.negative
142
- data.fields.value.bigintValue = mv.bigInteger
143
- } else if (mv.bigDecimal != null) {
144
- let v = new BigDecimal(mv.bigDecimal)
154
+ if (mv.value.case === 'bigInteger') {
155
+ const bigInteger = mv.value.value
156
+ bigInteger.negative = neg ? !bigInteger.negative : bigInteger.negative
157
+ data.fields.value.value = { case: 'bigintValue', value: bigInteger }
158
+ } else if (mv.value.case === 'bigDecimal') {
159
+ let v = new BigDecimal(mv.value.value)
145
160
  if (neg) {
146
161
  v = v.negated()
147
162
  }
148
- data.fields.value.bigdecimalValue = toBigDecimal(v)
149
- } else if (mv.doubleValue != null) {
150
- data.fields.value.floatValue = neg ? -mv.doubleValue : mv.doubleValue
163
+ data.fields.value.value = { case: 'bigdecimalValue', value: toBigDecimal(v) }
164
+ } else if (mv.value.case === 'doubleValue') {
165
+ const doubleValue = mv.value.value
166
+ data.fields.value.value = { case: 'floatValue', value: neg ? -doubleValue : doubleValue }
151
167
  } else {
152
- data.fields.value.nullValue = RichValue_NullValue.NULL_VALUE
168
+ data.fields.value.value = { case: 'nullValue', value: RichValue_NullValue.NULL_VALUE }
153
169
  }
154
170
  return data
155
171
  }
@@ -1,9 +1,11 @@
1
1
  import {
2
2
  HandlerType,
3
- ProcessStreamResponse_Partitions_Partition,
3
+ type ProcessStreamResponse_Partitions_Partition,
4
+ ProcessStreamResponse_Partitions_PartitionSchema,
4
5
  ProcessStreamResponse_Partitions_Partition_SysValue
5
6
  } from '@sentio/protos'
6
- import { ServerError, Status } from 'nice-grpc'
7
+ import { create } from '@bufbuild/protobuf'
8
+ import { ConnectError, Code } from '@connectrpc/connect'
7
9
 
8
10
  /**
9
11
  * Type for partition handler functions that can process any data type
@@ -51,20 +53,20 @@ export class PartitionHandlerManager {
51
53
  if (partitionHandler && data) {
52
54
  try {
53
55
  const partitionValue = await partitionHandler(data)
54
- result[handlerId] = {
55
- userValue: partitionValue
56
- }
56
+ result[handlerId] = create(ProcessStreamResponse_Partitions_PartitionSchema, {
57
+ value: { case: 'userValue', value: partitionValue ?? '' }
58
+ })
57
59
  } catch (error) {
58
60
  // If partition handler fails, fall back to unrecognized
59
- throw new ServerError(
60
- Status.INVALID_ARGUMENT,
61
- 'compute partition key failed, error:' + (error instanceof Error ? error.message : String(error))
61
+ throw new ConnectError(
62
+ 'compute partition key failed, error:' + (error instanceof Error ? error.message : String(error)),
63
+ Code.InvalidArgument
62
64
  )
63
65
  }
64
66
  } else {
65
- result[handlerId] = {
66
- sysValue: ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED
67
- }
67
+ result[handlerId] = create(ProcessStreamResponse_Partitions_PartitionSchema, {
68
+ value: { case: 'sysValue', value: ProcessStreamResponse_Partitions_Partition_SysValue.BLOCK_NUMBER }
69
+ })
68
70
  }
69
71
  }
70
72
 
@@ -1,6 +1,7 @@
1
1
  import { BaseContext, Labels, normalizeLabels } from '../core/index.js'
2
2
  import { ChainId, CosmosChainId } from '@sentio/chain'
3
- import { RecordMetaData } from '@sentio/protos'
3
+ import { RecordMetaData, RecordMetaDataSchema } from '@sentio/protos'
4
+ import { create } from '@bufbuild/protobuf'
4
5
  import { CosmosTransaction } from './transaction.js'
5
6
 
6
7
  export class CosmosContext extends BaseContext {
@@ -23,7 +24,7 @@ export class CosmosContext extends BaseContext {
23
24
  }
24
25
 
25
26
  protected getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
26
- return {
27
+ return create(RecordMetaDataSchema, {
27
28
  address: this.contractAddress,
28
29
  contractName: labels['name'] || '',
29
30
  blockNumber: BigInt(this.transaction?.height || 0),
@@ -33,6 +34,6 @@ export class CosmosContext extends BaseContext {
33
34
  name: name,
34
35
  logIndex: this.logIndex,
35
36
  labels: normalizeLabels(labels)
36
- }
37
+ })
37
38
  }
38
39
  }
@@ -1,6 +1,7 @@
1
1
  import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'
2
2
  import {
3
- ContractConfig,
3
+ ContractConfigSchema,
4
+ CosmosLogHandlerConfigSchema,
4
5
  DataBinding,
5
6
  HandlerType,
6
7
  InitResponse,
@@ -8,7 +9,8 @@ import {
8
9
  ProcessResult,
9
10
  StartRequest
10
11
  } from '@sentio/protos'
11
- import { ServerError, Status } from 'nice-grpc'
12
+ import { create } from '@bufbuild/protobuf'
13
+ import { ConnectError, Code } from '@connectrpc/connect'
12
14
  import { HandlerRegister } from '../core/handler-register.js'
13
15
  import { CosmosProcessorState } from './types.js'
14
16
 
@@ -31,7 +33,7 @@ export class CosmosPlugin extends Plugin {
31
33
  if (forChainId !== undefined && forChainId !== chainId.toString()) {
32
34
  continue
33
35
  }
34
- const contractConfig = ContractConfig.fromPartial({
36
+ const contractConfig = create(ContractConfigSchema, {
35
37
  processorType: USER_PROCESSOR,
36
38
  contract: {
37
39
  name: processor.config.name,
@@ -46,11 +48,13 @@ export class CosmosPlugin extends Plugin {
46
48
  for (const callHandler of processor.callHandlers) {
47
49
  const handlerId = this.handlerRegister.register(callHandler.handler, chainId)
48
50
 
49
- contractConfig.cosmosLogConfigs.push({
50
- handlerId,
51
- handlerName: callHandler.handlerName,
52
- logFilters: callHandler.logConfig?.logFilters || []
53
- })
51
+ contractConfig.cosmosLogConfigs.push(
52
+ create(CosmosLogHandlerConfigSchema, {
53
+ handlerId,
54
+ handlerName: callHandler.handlerName,
55
+ logFilters: callHandler.logConfig?.logFilters || []
56
+ })
57
+ )
54
58
  }
55
59
 
56
60
  // Finish up a contract
@@ -65,17 +69,17 @@ export class CosmosPlugin extends Plugin {
65
69
  case HandlerType.COSMOS_CALL:
66
70
  return this.processTransaction(request)
67
71
  default:
68
- throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
72
+ throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
69
73
  }
70
74
  }
71
75
 
72
76
  async start(request: StartRequest) {}
73
77
 
74
78
  async processTransaction(binding: DataBinding): Promise<ProcessResult> {
75
- if (!binding.data?.cosmosCall?.transaction) {
76
- throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
79
+ if (binding.data?.value.case !== 'cosmosCall' || !binding.data.value.value.transaction) {
80
+ throw new ConnectError("transaction can't be null", Code.InvalidArgument)
77
81
  }
78
- const call = binding.data.cosmosCall
82
+ const call = binding.data.value.value
79
83
 
80
84
  const promises: Promise<ProcessResult>[] = []
81
85
 
@@ -86,9 +90,9 @@ export class CosmosPlugin extends Plugin {
86
90
  handlerId
87
91
  )(call)
88
92
  .catch((e) => {
89
- throw new ServerError(
90
- Status.INTERNAL,
91
- 'error processing transaction: ' + JSON.stringify(call.transaction) + '\n' + errorString(e)
93
+ throw new ConnectError(
94
+ 'error processing transaction: ' + JSON.stringify(call.transaction) + '\n' + errorString(e),
95
+ Code.Internal
92
96
  )
93
97
  })
94
98
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -27,7 +27,7 @@ export class CosmosProcessor {
27
27
  const callHandler = {
28
28
  handlerName: getHandlerName(),
29
29
  handler: async (call: Data_CosmosCall) => {
30
- const transaction = call.transaction as CosmosTransaction
30
+ const transaction = call.transaction as unknown as CosmosTransaction
31
31
 
32
32
  const ctx = new CosmosContext(this.config.chainId, this.config.address, transaction)
33
33
 
@@ -46,7 +46,7 @@ export class CosmosProcessor {
46
46
  const p = handlerOptions?.partitionKey
47
47
  if (!p) return undefined
48
48
  if (typeof p === 'function') {
49
- const transaction = call.transaction as CosmosTransaction
49
+ const transaction = call.transaction as unknown as CosmosTransaction
50
50
  return p(transaction)
51
51
  }
52
52
  return p
@@ -1,6 +1,6 @@
1
1
  import { Interface, LogDescription, LogParams, ParamType, Result } from 'ethers'
2
2
  import { Piscina } from 'piscina'
3
- import { ServerError, Status } from 'nice-grpc'
3
+ import { ConnectError, Code } from '@connectrpc/connect'
4
4
  import { FormattedLog } from '../eth.js'
5
5
 
6
6
  export interface IResult {
@@ -41,7 +41,7 @@ export interface ILogDescription {
41
41
 
42
42
  export function parseLogInline(contractViewInterface: any, log: LogParams): LogDescription | null {
43
43
  if (!log) {
44
- throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
44
+ throw new ConnectError('Log is empty', Code.InvalidArgument)
45
45
  }
46
46
  const topics = log.topics
47
47
  const data = log.data
@@ -1,5 +1,15 @@
1
1
  import { ERC20__factory, ERC721__factory } from './builtin/internal/index.js'
2
- import { AddressType, EthFetchConfig, PreprocessResult, ProcessResult } from '@sentio/protos'
2
+ import {
3
+ AddressType,
4
+ type EthFetchConfig,
5
+ EthFetchConfigSchema,
6
+ type PreprocessResult,
7
+ PreprocessResultSchema,
8
+ ProcessResultSchema,
9
+ timestampDate
10
+ } from '@sentio/protos'
11
+ import { create } from '@bufbuild/protobuf'
12
+ import { ConnectError, Code } from '@connectrpc/connect'
3
13
 
4
14
  import { PartiallyOptional, PromiseOrVoid } from '../core/index.js'
5
15
 
@@ -12,7 +22,6 @@ import { Block } from 'ethers'
12
22
  import { AccountProcessorState } from './account-processor-state.js'
13
23
  import { fixEmptyKey, formatEthData, TypedEvent, validateAndNormalizeAddress } from './eth.js'
14
24
  import { EthChainId } from '@sentio/chain'
15
- import { ServerError, Status } from 'nice-grpc'
16
25
  import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
17
26
 
18
27
  const ERC20_INTERFACE = ERC20__factory.createInterface()
@@ -258,7 +267,7 @@ export class AccountProcessor {
258
267
  protected onEvent(
259
268
  handler: (event: TypedEvent, ctx: AccountContext) => PromiseOrVoid,
260
269
  filter: AddressOrTypeEventFilter | AddressOrTypeEventFilter[],
261
- fetchConfig?: Partial<EthFetchConfig>,
270
+ fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
262
271
  preprocessHandler: (
263
272
  event: TypedEvent,
264
273
  ctx: AccountContext,
@@ -295,19 +304,19 @@ export class AccountProcessor {
295
304
 
296
305
  this.eventHandlers.push({
297
306
  filters: _filters,
298
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
307
+ fetchConfig: create(EthFetchConfigSchema, fetchConfig || {}),
299
308
  handlerName: getHandlerName(),
300
309
  handler: async function (data) {
301
310
  const { log, block, transaction, transactionReceipt } = formatEthData(data)
302
311
  if (!log) {
303
- throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
312
+ throw new ConnectError('Log is empty', Code.InvalidArgument)
304
313
  }
305
314
  // const log = data.log as { topics: Array<string>; data: string }
306
315
  const ctx = new AccountContext(
307
316
  chainId,
308
317
  config.address,
309
- data.timestamp,
310
- data.block as Block,
318
+ data.timestamp ? timestampDate(data.timestamp) : undefined,
319
+ block as Block,
311
320
  log,
312
321
  undefined,
313
322
  transaction,
@@ -321,19 +330,19 @@ export class AccountProcessor {
321
330
  await handler(event, ctx)
322
331
  return ctx.stopAndGetResult()
323
332
  }
324
- return ProcessResult.fromPartial({})
333
+ return create(ProcessResultSchema)
325
334
  },
326
335
  preprocessHandler: async function (data, preprocessStore: { [k: string]: any }) {
327
336
  const { log, block, transaction, transactionReceipt } = formatEthData(data)
328
337
  if (!log) {
329
- throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
338
+ throw new ConnectError('Log is empty', Code.InvalidArgument)
330
339
  }
331
340
  // const log = data.log as { topics: Array<string>; data: string }
332
341
  const ctx = new AccountContext(
333
342
  chainId,
334
343
  config.address,
335
- data.timestamp,
336
- data.block as Block,
344
+ data.timestamp ? timestampDate(data.timestamp) : undefined,
345
+ block as Block,
337
346
  log,
338
347
  undefined,
339
348
  transaction,
@@ -346,7 +355,7 @@ export class AccountProcessor {
346
355
  const event: TypedEvent = new TypedEvent(log, parsed.name, fixEmptyKey(parsed))
347
356
  return preprocessHandler(event, ctx, preprocessStore)
348
357
  }
349
- return PreprocessResult.fromPartial({})
358
+ return create(PreprocessResultSchema)
350
359
  }
351
360
  })
352
361
 
@@ -2,7 +2,16 @@ import { BoundContractView, ContractContext, ContractView, EthContext } from './
2
2
  import { BaseContract } from 'ethers'
3
3
  import { BaseProcessor, defaultPreprocessHandler } from './base-processor.js'
4
4
  import { BindOptions, getOptionsSignature } from './bind-options.js'
5
- import { EthFetchConfig, HandleInterval, TemplateInstance, PreprocessResult } from '@sentio/protos'
5
+ import {
6
+ type EthFetchConfig,
7
+ EthFetchConfigSchema,
8
+ type HandleInterval,
9
+ HandleIntervalSchema,
10
+ type TemplateInstance,
11
+ TemplateInstanceSchema,
12
+ type PreprocessResult
13
+ } from '@sentio/protos'
14
+ import { create } from '@bufbuild/protobuf'
6
15
  import { PromiseOrVoid } from '../core/promises.js'
7
16
  import { ListStateStorage, processMetrics } from '@sentio/runtime'
8
17
  import { BlockParams } from 'ethers/providers'
@@ -62,7 +71,11 @@ export abstract class BaseProcessorTemplate<
62
71
 
63
72
  constructor() {
64
73
  this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length
65
- ProcessorTemplateProcessorState.INSTANCE.addValue(this)
74
+ // Stored type-erased as the base instantiation; the concrete type parameters only appear in
75
+ // handler parameter positions, which `strictFunctionTypes` checks contravariantly.
76
+ ProcessorTemplateProcessorState.INSTANCE.addValue(
77
+ this as unknown as BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
78
+ )
66
79
  return proxyProcessor(this)
67
80
  }
68
81
 
@@ -74,7 +87,7 @@ export abstract class BaseProcessorTemplate<
74
87
  public bind(options: Omit<BindOptions, 'network'>, ctx: EthContext): void {
75
88
  options = { ...options, address: validateAndNormalizeAddress(options.address) }
76
89
 
77
- const instance: TemplateInstance = {
90
+ const instance: TemplateInstance = create(TemplateInstanceSchema, {
78
91
  templateId: this.id,
79
92
  contract: {
80
93
  address: options.address,
@@ -85,7 +98,7 @@ export abstract class BaseProcessorTemplate<
85
98
  startBlock: BigInt(options.startBlock || 0),
86
99
  endBlock: BigInt(options.endBlock || 0),
87
100
  baseLabels: options.baseLabels
88
- }
101
+ })
89
102
 
90
103
  ctx.sendTemplateInstance(instance)
91
104
 
@@ -137,7 +150,7 @@ export abstract class BaseProcessorTemplate<
137
150
  protected onEthEvent(
138
151
  handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
139
152
  filter: DeferredTopicFilter | DeferredTopicFilter[],
140
- fetchConfig?: Partial<EthFetchConfig>,
153
+ fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
141
154
  preprocessHandler: (
142
155
  event: TypedEvent,
143
156
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -149,7 +162,7 @@ export abstract class BaseProcessorTemplate<
149
162
  handler: handler,
150
163
  preprocessHandler,
151
164
  filter: filter,
152
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
165
+ fetchConfig: create(EthFetchConfigSchema, fetchConfig || {})
153
166
  })
154
167
  return this
155
168
  }
@@ -168,10 +181,10 @@ export abstract class BaseProcessorTemplate<
168
181
  return this.onInterval(
169
182
  handler,
170
183
  undefined,
171
- {
184
+ create(HandleIntervalSchema, {
172
185
  recentInterval: blockInterval,
173
186
  backfillInterval: backfillBlockInterval
174
- },
187
+ }),
175
188
  fetchConfig,
176
189
  preprocessHandler
177
190
  )
@@ -190,7 +203,10 @@ export abstract class BaseProcessorTemplate<
190
203
  ) {
191
204
  return this.onInterval(
192
205
  handler,
193
- { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
206
+ create(HandleIntervalSchema, {
207
+ recentInterval: timeIntervalInMinutes,
208
+ backfillInterval: backfillTimeIntervalInMinutes
209
+ }),
194
210
  undefined,
195
211
  fetchConfig,
196
212
  preprocessHandler
@@ -222,7 +238,7 @@ export abstract class BaseProcessorTemplate<
222
238
  public onTrace(
223
239
  signature: string,
224
240
  handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
225
- fetchConfig?: Partial<EthFetchConfig>,
241
+ fetchConfig?: Omit<Partial<EthFetchConfig>, '$typeName' | '$unknown'>,
226
242
  preprocessHandler: (
227
243
  trace: TypedCallTrace,
228
244
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -234,7 +250,7 @@ export abstract class BaseProcessorTemplate<
234
250
  handlerName: getHandlerName(),
235
251
  handler,
236
252
  preprocessHandler,
237
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
253
+ fetchConfig: create(EthFetchConfigSchema, fetchConfig || {})
238
254
  })
239
255
  return this
240
256
  }