@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
package/src/eth/eth.ts CHANGED
@@ -23,8 +23,9 @@ import {
23
23
  import type { AccessList } from 'ethers/transaction'
24
24
  import { ContractContext } from './context.js'
25
25
  import { getAddress } from 'ethers/address'
26
- import { getBigInt } from 'ethers/utils'
27
- import { EthCallContext, EthCallParam } from '@sentio/protos'
26
+ import { getBigInt, getNumber } from 'ethers/utils'
27
+ import { type EthCallContext, type EthCallParam, EthCallParamSchema } from '@sentio/protos'
28
+ import { create } from '@bufbuild/protobuf'
28
29
  import { ALL_ADDRESS } from '../core/index.js'
29
30
 
30
31
  export interface IResult {
@@ -126,14 +127,14 @@ class FormattedTransactionReceipt implements TransactionReceiptParams {
126
127
  return this.data.transactionHash
127
128
  }
128
129
  get index(): number {
129
- return this.data.transactionIndex
130
+ return getNumber(this.data.transactionIndex)
130
131
  }
131
132
 
132
133
  get blockHash(): string {
133
134
  return this.data.blockHash
134
135
  }
135
136
  get blockNumber(): number {
136
- return this.data.blockNumber
137
+ return getNumber(this.data.blockNumber)
137
138
  }
138
139
  get logsBloom(): string {
139
140
  return this.data.logsBloom
@@ -178,10 +179,10 @@ class FormattedTransactionReceipt implements TransactionReceiptParams {
178
179
  return this._l1Fee !== undefined ? this._l1Fee : (this._l1Fee = allowNull(getBigInt)(this.data.l1Fee))
179
180
  }
180
181
  get type(): number {
181
- return this.data.type
182
+ return allowNull(getNumber, 0)(this.data.type)
182
183
  }
183
184
  get status(): number | null {
184
- return this.data.status
185
+ return allowNull(getNumber)(this.data.status)
185
186
  }
186
187
  get root(): string | null {
187
188
  return this.data.root
@@ -197,7 +198,7 @@ export class FormattedLog implements LogParams {
197
198
  return this.raw.blockHash
198
199
  }
199
200
  get blockNumber(): number {
200
- return this.raw.blockNumber
201
+ return getNumber(this.raw.blockNumber)
201
202
  }
202
203
  get removed(): boolean {
203
204
  return this.raw.removed
@@ -213,11 +214,14 @@ export class FormattedLog implements LogParams {
213
214
  }
214
215
 
215
216
  get transactionIndex(): number {
216
- return this.raw.transactionIndex
217
+ // Raw RPC logs carry these as hex strings (e.g. "0xf3"); coerce so the value honors the
218
+ // declared `number` type and is valid for the int32 RecordMetaData fields it feeds.
219
+ // (Restores the getNumber coercion that ethers' formatLog applied before #1411.)
220
+ return getNumber(this.raw.transactionIndex)
217
221
  }
218
222
 
219
223
  get index(): number {
220
- return this.raw.logIndex
224
+ return getNumber(this.raw.logIndex)
221
225
  }
222
226
 
223
227
  get data(): string {
@@ -240,11 +244,12 @@ function formatLog(log: any): LogParams {
240
244
  }
241
245
 
242
246
  export function formatEthData(data: {
243
- log?: any
244
- block?: any
245
- trace?: any
246
- transaction?: any
247
- transactionReceipt?: any
247
+ // raw_* JSON payloads sent by the driver
248
+ rawLog?: string
249
+ rawBlock?: string
250
+ rawTrace?: string
251
+ rawTransaction?: string
252
+ rawTransactionReceipt?: string
248
253
  __formattedEthData?: any
249
254
  }) {
250
255
  // Return cached result if it exists
@@ -253,22 +258,29 @@ export function formatEthData(data: {
253
258
  }
254
259
 
255
260
  try {
256
- const log = data.log ? formatLog(data.log) : undefined
257
- if (data.block && !data.block.transactions) {
258
- data.block.transactions = []
261
+ // All Eth* data is delivered as raw_* JSON payloads; parse them here.
262
+ const logObj = data.rawLog ? JSON.parse(data.rawLog) : undefined
263
+ const blockObj = data.rawBlock ? JSON.parse(data.rawBlock) : undefined
264
+ const traceObj = data.rawTrace ? JSON.parse(data.rawTrace) : undefined
265
+ const transactionObj = data.rawTransaction ? JSON.parse(data.rawTransaction) : undefined
266
+ const transactionReceiptObj = data.rawTransactionReceipt ? JSON.parse(data.rawTransactionReceipt) : undefined
267
+
268
+ const log = logObj ? formatLog(logObj) : undefined
269
+ if (blockObj && !blockObj.transactions) {
270
+ blockObj.transactions = []
259
271
  }
260
- const block = data.block ? formatRichBlock(data.block) : undefined
261
- const trace = data.trace ? (data.trace as Trace) : undefined
272
+ const block = blockObj ? formatRichBlock(blockObj) : undefined
273
+ const trace = traceObj ? (traceObj as Trace) : undefined
262
274
  let transaction = undefined
263
- if (data.transaction) {
264
- if (!data.transaction.v) {
265
- data.transaction.v = '0x1c'
266
- data.transaction.r = '0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0'
267
- data.transaction.s = '0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'
275
+ if (transactionObj) {
276
+ if (!transactionObj.v) {
277
+ transactionObj.v = '0x1c'
278
+ transactionObj.r = '0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0'
279
+ transactionObj.s = '0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'
268
280
  }
269
- transaction = formatTransactionResponse(data.transaction)
281
+ transaction = formatTransactionResponse(transactionObj)
270
282
  }
271
- const transactionReceipt = data.transactionReceipt ? formatTransactionReceipt(data.transactionReceipt) : undefined
283
+ const transactionReceipt = transactionReceiptObj ? formatTransactionReceipt(transactionReceiptObj) : undefined
272
284
 
273
285
  const result = {
274
286
  log,
@@ -291,7 +303,7 @@ class FormattedTransactionResponse implements TransactionResponseParams {
291
303
  constructor(readonly raw: any) {}
292
304
 
293
305
  get blockNumber(): number | null {
294
- return this.raw.blockNumber
306
+ return allowNull(getNumber)(this.raw.blockNumber)
295
307
  }
296
308
  _blockHash: string | undefined | null
297
309
  get blockHash(): string | null {
@@ -309,13 +321,15 @@ class FormattedTransactionResponse implements TransactionResponseParams {
309
321
  return this.raw.hash
310
322
  }
311
323
  get index(): number {
312
- return this.raw.transactionIndex
324
+ // transactionIndex is absent for pending/partial txs; default to 0 (matches the prior
325
+ // `this.transaction.index || 0` handling) while still coercing hex strings when present.
326
+ return allowNull(getNumber, 0)(this.raw.transactionIndex)
313
327
  }
314
328
  get type(): number {
315
329
  if (this.raw.type === '0x' || this.raw.type == null) {
316
330
  return 0
317
331
  }
318
- return this.raw.type
332
+ return getNumber(this.raw.type)
319
333
  }
320
334
  _to: string | null
321
335
  get to(): string | null {
@@ -332,7 +346,7 @@ class FormattedTransactionResponse implements TransactionResponseParams {
332
346
  return this._from ?? (this._from = getAddress(this.raw.from))
333
347
  }
334
348
  get nonce(): number {
335
- return this.raw.nonce
349
+ return getNumber(this.raw.nonce)
336
350
  }
337
351
  _gasLimit: bigint
338
352
  get gasLimit(): bigint {
@@ -528,10 +542,10 @@ export function encodeCallData(
528
542
  try {
529
543
  const iface = new Interface([funcABI])
530
544
  const calldata = iface.encodeFunctionData(name, values)
531
- return {
545
+ return create(EthCallParamSchema, {
532
546
  context,
533
547
  calldata
534
- }
548
+ })
535
549
  } catch (e) {
536
550
  const stack = new Error().stack
537
551
  throw transformEtherError(e, undefined, stack)
package/src/eth/index.ts CHANGED
@@ -13,7 +13,7 @@ export { AccountContext, ContractContext, GlobalContext, ContractView, BoundCont
13
13
 
14
14
  export { EthPlugin } from './eth-plugin.js'
15
15
 
16
- export { EthFetchConfig, PreprocessResult } from '@sentio/protos'
16
+ export type { EthFetchConfig, PreprocessResult } from '@sentio/protos'
17
17
 
18
18
  export { EthChainId } from '@sentio/chain'
19
19
 
@@ -1,5 +1,11 @@
1
1
  import { CallHandler, FuelBaseProcessor, FuelProcessorState } from './types.js'
2
- import { Data_FuelReceipt, Data_FuelTransaction, FuelAssetHandlerConfig_AssetFilter } from '@sentio/protos'
2
+ import {
3
+ Data_FuelTransaction,
4
+ FuelAssetHandlerConfig_AssetFilter,
5
+ FuelAssetHandlerConfig_AssetFilterSchema,
6
+ timestampDate
7
+ } from '@sentio/protos'
8
+ import { create } from '@bufbuild/protobuf'
3
9
  import { FuelNetwork, getProvider } from './network.js'
4
10
  import { FuelContext } from './context.js'
5
11
  import { decodeFuelTransaction } from './transaction.js'
@@ -8,7 +14,7 @@ import { getOptionsSignature } from './fuel-processor.js'
8
14
  import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
9
15
 
10
16
  export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
11
- txHandlers: CallHandler<Data_FuelTransaction | Data_FuelReceipt>[] = []
17
+ txHandlers: CallHandler<Data_FuelTransaction>[] = []
12
18
  blockHandlers = []
13
19
  private provider: Provider
14
20
 
@@ -42,11 +48,13 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
42
48
  for (const assetId of assetIds) {
43
49
  for (const from of froms) {
44
50
  for (const to of tos) {
45
- filters.push({
46
- assetId: assetId,
47
- fromAddress: from,
48
- toAddress: to
49
- })
51
+ filters.push(
52
+ create(FuelAssetHandlerConfig_AssetFilterSchema, {
53
+ assetId: assetId,
54
+ fromAddress: from,
55
+ toAddress: to
56
+ })
57
+ )
50
58
  }
51
59
  }
52
60
  }
@@ -94,7 +102,7 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
94
102
  this.config.chainId,
95
103
  assetId,
96
104
  this.config.name ?? '',
97
- call.timestamp || new Date(0),
105
+ call.timestamp ? timestampDate(call.timestamp) : new Date(0),
98
106
  tx,
99
107
  null
100
108
  )
@@ -1,6 +1,7 @@
1
1
  import { BaseContext, Labels, normalizeLabels } from '../core/index.js'
2
2
  import { FuelChainId } 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 type { CallResult, Contract } from 'fuels'
5
6
  import { InvocationScopeLike } from 'fuels'
6
7
  import { FuelBlock, FuelLog, FuelTransaction } from './types.js'
@@ -39,7 +40,7 @@ export class FuelContext extends BaseContext {
39
40
  }
40
41
 
41
42
  protected getMetaDataInternal(name: string, labels: Labels): RecordMetaData {
42
- return {
43
+ return create(RecordMetaDataSchema, {
43
44
  address: this.contractAddress,
44
45
  contractName: this.contractName,
45
46
  blockNumber: BigInt(this.block?.height?.toString() ?? (this.transaction?.blockNumber || 0)),
@@ -49,7 +50,7 @@ export class FuelContext extends BaseContext {
49
50
  name: name,
50
51
  logIndex: this.logIndex,
51
52
  labels: normalizeLabels(labels)
52
- }
53
+ })
53
54
  }
54
55
  }
55
56
 
@@ -2,17 +2,22 @@ import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager,
2
2
  import { PartitionHandlerManager } from '../core/index.js'
3
3
  import { HandlerRegister } from '../core/handler-register.js'
4
4
  import {
5
- ContractConfig,
5
+ ContractConfigSchema,
6
6
  DataBinding,
7
+ FuelAssetHandlerConfigSchema,
8
+ FuelReceiptHandlerConfigSchema,
9
+ FuelTransactionHandlerConfigSchema,
7
10
  HandlerType,
8
11
  InitResponse,
12
+ OnIntervalConfigSchema,
9
13
  ProcessConfigResponse,
10
14
  ProcessResult,
11
15
  ProcessStreamResponse_Partitions,
16
+ ProcessStreamResponse_PartitionsSchema,
12
17
  StartRequest
13
18
  } from '@sentio/protos'
14
-
15
- import { ServerError, Status } from 'nice-grpc'
19
+ import { create } from '@bufbuild/protobuf'
20
+ import { ConnectError, Code } from '@connectrpc/connect'
16
21
  import { FuelAssetProcessor } from './asset-processor.js'
17
22
  import { FuelProcessorState } from './types.js'
18
23
  import { FuelProcessor } from './fuel-processor.js'
@@ -39,7 +44,7 @@ export class FuelPlugin extends Plugin {
39
44
  continue
40
45
  }
41
46
  const processorConfig = processor.config
42
- const contractConfig = ContractConfig.fromPartial({
47
+ const contractConfig = create(ContractConfigSchema, {
43
48
  processorType: USER_PROCESSOR,
44
49
  contract: {
45
50
  name: processorConfig.name,
@@ -60,24 +65,25 @@ export class FuelPlugin extends Plugin {
60
65
  const handlerName = txHandler.handlerName
61
66
  if (processor instanceof FuelProcessor) {
62
67
  // on transaction
63
- const fetchConfig = {
68
+ const fetchConfig = create(FuelTransactionHandlerConfigSchema, {
64
69
  handlerId,
65
70
  handlerName
66
- }
71
+ })
67
72
  contractConfig.fuelTransactionConfigs.push(fetchConfig)
68
73
  } else if (processor instanceof FuelAssetProcessor) {
69
74
  const assetConfig = txHandler.assetConfig
70
- contractConfig.assetConfigs.push({
71
- filters: assetConfig?.filters || [],
75
+ contractConfig.assetConfigs.push(
76
+ create(FuelAssetHandlerConfigSchema, {
77
+ filters: assetConfig?.filters || [],
78
+ handlerId,
79
+ handlerName
80
+ })
81
+ )
82
+ } else if (processor instanceof FuelGlobalProcessor) {
83
+ const fetchConfig = create(FuelTransactionHandlerConfigSchema, {
72
84
  handlerId,
73
85
  handlerName
74
86
  })
75
- } else if (processor instanceof FuelGlobalProcessor) {
76
- const fetchConfig = {
77
- handlerId,
78
- handlerName,
79
- filters: []
80
- }
81
87
  contractConfig.fuelTransactionConfigs.push(fetchConfig)
82
88
  contractConfig.contract!.address = '*'
83
89
  }
@@ -92,39 +98,38 @@ export class FuelPlugin extends Plugin {
92
98
  )
93
99
  const handlerName = receiptHandler.handlerName
94
100
  if (processor instanceof FuelProcessor) {
95
- contractConfig.fuelReceiptConfigs.push({
96
- ...receiptHandler.receiptConfig,
97
- handlerId,
98
- handlerName
99
- })
101
+ contractConfig.fuelReceiptConfigs.push(
102
+ create(FuelReceiptHandlerConfigSchema, {
103
+ ...receiptHandler.receiptConfig,
104
+ handlerId,
105
+ handlerName
106
+ })
107
+ )
100
108
  }
101
109
  }
102
110
 
103
111
  for (const blockHandler of processor.blockHandlers) {
104
112
  const handlerId = this.handlerRegister.register(blockHandler.handler, chainId)
105
113
  this.partitionManager.registerPartitionHandler(HandlerType.FUEL_BLOCK, handlerId, blockHandler.partitionHandler)
106
- contractConfig.intervalConfigs.push({
107
- slot: 0,
108
- slotInterval: blockHandler.blockInterval,
109
- minutes: 0,
110
- minutesInterval: blockHandler.timeIntervalInMinutes,
111
- handlerId: handlerId,
112
- handlerName: blockHandler.handlerName,
113
- fetchConfig: undefined
114
- // fetchConfig: blockHandler.fetchConfig
115
- })
114
+ contractConfig.intervalConfigs.push(
115
+ create(OnIntervalConfigSchema, {
116
+ slot: 0,
117
+ slotInterval: blockHandler.blockInterval,
118
+ minutes: 0,
119
+ minutesInterval: blockHandler.timeIntervalInMinutes,
120
+ handlerId: handlerId,
121
+ handlerName: blockHandler.handlerName,
122
+ fetchConfig: undefined
123
+ // fetchConfig: blockHandler.fetchConfig
124
+ })
125
+ )
116
126
  }
117
127
 
118
128
  config.contractConfigs.push(contractConfig)
119
129
  }
120
130
  }
121
131
 
122
- supportedHandlers = [
123
- HandlerType.FUEL_TRANSACTION,
124
- HandlerType.FUEL_RECEIPT,
125
- HandlerType.FUEL_CALL,
126
- HandlerType.FUEL_BLOCK
127
- ]
132
+ supportedHandlers = [HandlerType.FUEL_TRANSACTION, HandlerType.FUEL_RECEIPT, HandlerType.FUEL_BLOCK]
128
133
 
129
134
  processBinding(request: DataBinding): Promise<ProcessResult> {
130
135
  switch (request.handlerType) {
@@ -135,7 +140,7 @@ export class FuelPlugin extends Plugin {
135
140
  case HandlerType.FUEL_BLOCK:
136
141
  return this.processBlock(request)
137
142
  default:
138
- throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
143
+ throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
139
144
  }
140
145
  }
141
146
 
@@ -143,41 +148,34 @@ export class FuelPlugin extends Plugin {
143
148
  let data: any
144
149
  switch (request.handlerType) {
145
150
  case HandlerType.FUEL_TRANSACTION:
146
- if (!request.data?.fuelTransaction) {
147
- throw new ServerError(Status.INVALID_ARGUMENT, "fuelTransaction can't be empty")
151
+ if (request.data?.value.case !== 'fuelTransaction') {
152
+ throw new ConnectError("fuelTransaction can't be empty", Code.InvalidArgument)
148
153
  }
149
- data = request.data.fuelTransaction
154
+ data = request.data.value.value
150
155
  break
151
156
  case HandlerType.FUEL_RECEIPT:
152
- if (!request.data?.fuelLog) {
153
- throw new ServerError(Status.INVALID_ARGUMENT, "fuelReceipt can't be empty")
157
+ if (request.data?.value.case !== 'fuelLog') {
158
+ throw new ConnectError("fuelReceipt can't be empty", Code.InvalidArgument)
154
159
  }
155
- data = request.data.fuelLog
160
+ data = request.data.value.value
156
161
  break
157
162
  case HandlerType.FUEL_BLOCK:
158
- if (!request.data?.fuelBlock) {
159
- throw new ServerError(Status.INVALID_ARGUMENT, "fuelBlock can't be empty")
160
- }
161
- data = request.data.fuelBlock
162
- break
163
- case HandlerType.FUEL_CALL:
164
- // FUEL_CALL uses the same data as FUEL_TRANSACTION
165
- if (!request.data?.fuelTransaction) {
166
- throw new ServerError(Status.INVALID_ARGUMENT, "fuelTransaction can't be empty for FUEL_CALL")
163
+ if (request.data?.value.case !== 'fuelBlock') {
164
+ throw new ConnectError("fuelBlock can't be empty", Code.InvalidArgument)
167
165
  }
168
- data = request.data.fuelTransaction
166
+ data = request.data.value.value
169
167
  break
170
168
  default:
171
- throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
169
+ throw new ConnectError('No handle type registered ' + request.handlerType, Code.InvalidArgument)
172
170
  }
173
171
  const partitions = await this.partitionManager.processPartitionForHandlerType(
174
172
  request.handlerType,
175
173
  request.handlerIds,
176
174
  data
177
175
  )
178
- return {
176
+ return create(ProcessStreamResponse_PartitionsSchema, {
179
177
  partitions
180
- }
178
+ })
181
179
  }
182
180
 
183
181
  async start(request: StartRequest) {
@@ -186,15 +184,15 @@ export class FuelPlugin extends Plugin {
186
184
  await processor.configure()
187
185
  }
188
186
  } catch (e) {
189
- throw new ServerError(Status.INTERNAL, 'error starting FuelPlugin: ' + errorString(e))
187
+ throw new ConnectError('error starting FuelPlugin: ' + errorString(e), Code.Internal)
190
188
  }
191
189
  }
192
190
 
193
191
  async processReceipt(binding: DataBinding): Promise<ProcessResult> {
194
- const receipt = binding?.data?.fuelLog
192
+ const receipt = binding?.data?.value.case === 'fuelLog' ? binding.data.value.value : undefined
195
193
 
196
194
  if (!receipt?.transaction) {
197
- throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
195
+ throw new ConnectError("transaction can't be null", Code.InvalidArgument)
198
196
  }
199
197
 
200
198
  const promises: Promise<ProcessResult>[] = []
@@ -206,9 +204,9 @@ export class FuelPlugin extends Plugin {
206
204
  handlerId
207
205
  )(receipt)
208
206
  .catch((e: any) => {
209
- throw new ServerError(
210
- Status.INTERNAL,
211
- 'error processing transaction: ' + JSON.stringify(receipt) + '\n' + errorString(e)
207
+ throw new ConnectError(
208
+ 'error processing transaction: ' + JSON.stringify(receipt) + '\n' + errorString(e),
209
+ Code.Internal
212
210
  )
213
211
  })
214
212
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -220,10 +218,10 @@ export class FuelPlugin extends Plugin {
220
218
  }
221
219
 
222
220
  async processTransaction(binding: DataBinding): Promise<ProcessResult> {
223
- if (!binding.data?.fuelTransaction?.transaction) {
224
- throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
221
+ if (binding.data?.value.case !== 'fuelTransaction' || !binding.data.value.value.transaction) {
222
+ throw new ConnectError("transaction can't be null", Code.InvalidArgument)
225
223
  }
226
- const fuelTransaction = binding.data.fuelTransaction
224
+ const fuelTransaction = binding.data.value.value
227
225
 
228
226
  const promises: Promise<ProcessResult>[] = []
229
227
 
@@ -234,9 +232,9 @@ export class FuelPlugin extends Plugin {
234
232
  handlerId
235
233
  )(fuelTransaction)
236
234
  .catch((e: any) => {
237
- throw new ServerError(
238
- Status.INTERNAL,
239
- 'error processing transaction: ' + JSON.stringify(fuelTransaction.transaction) + '\n' + errorString(e)
235
+ throw new ConnectError(
236
+ 'error processing transaction: ' + JSON.stringify(fuelTransaction.transaction) + '\n' + errorString(e),
237
+ Code.Internal
240
238
  )
241
239
  })
242
240
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -248,10 +246,10 @@ export class FuelPlugin extends Plugin {
248
246
  }
249
247
 
250
248
  async processBlock(binding: DataBinding): Promise<ProcessResult> {
251
- if (!binding.data?.fuelBlock?.block) {
252
- throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
249
+ if (binding.data?.value.case !== 'fuelBlock' || !binding.data.value.value.block) {
250
+ throw new ConnectError("Block can't be empty", Code.InvalidArgument)
253
251
  }
254
- const ethBlock = binding.data.fuelBlock
252
+ const ethBlock = binding.data.value.value
255
253
 
256
254
  const promises: Promise<ProcessResult>[] = []
257
255
  for (const handlerId of binding.handlerIds) {
@@ -262,9 +260,9 @@ export class FuelPlugin extends Plugin {
262
260
  )(ethBlock)
263
261
  .catch((e: any) => {
264
262
  console.error('error processing block: ', e)
265
- throw new ServerError(
266
- Status.INTERNAL,
267
- 'error processing block: ' + ethBlock.block?.height + '\n' + errorString(e)
263
+ throw new ConnectError(
264
+ 'error processing block: ' + (ethBlock.block as any)?.height + '\n' + errorString(e),
265
+ Code.Internal
268
266
  )
269
267
  })
270
268
  if (GLOBAL_CONFIG.execution.sequential) {
@@ -1,5 +1,6 @@
1
1
  import { FuelContext, FuelContractContext } from './context.js'
2
- import { HandleInterval, TemplateInstance } from '@sentio/protos'
2
+ import { HandleInterval, HandleIntervalSchema, TemplateInstance, TemplateInstanceSchema } from '@sentio/protos'
3
+ import { create } from '@bufbuild/protobuf'
3
4
  import { PromiseOrVoid } from '../core/promises.js'
4
5
  import { ListStateStorage, processMetrics } from '@sentio/runtime'
5
6
  import { Contract } from 'fuels'
@@ -53,7 +54,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
53
54
  * @param ctx
54
55
  */
55
56
  public bind(options: Omit<Omit<FuelProcessorConfig, 'chainId'>, 'abi'>, ctx: FuelContext): void {
56
- const instance: TemplateInstance = {
57
+ const instance: TemplateInstance = create(TemplateInstanceSchema, {
57
58
  templateId: this.id,
58
59
  contract: {
59
60
  address: options.address,
@@ -65,7 +66,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
65
66
  endBlock: BigInt(options.endBlock || 0),
66
67
  baseLabels: {}
67
68
  // baseLabels: options.baseLabels
68
- }
69
+ })
69
70
 
70
71
  ctx.sendTemplateInstance(instance)
71
72
 
@@ -130,10 +131,10 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
130
131
  return this.onInterval(
131
132
  handler,
132
133
  undefined,
133
- {
134
+ create(HandleIntervalSchema, {
134
135
  recentInterval: blockInterval,
135
136
  backfillInterval: backfillBlockInterval
136
- }
137
+ })
137
138
  // fetchConfig
138
139
  )
139
140
  }
@@ -146,7 +147,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
146
147
  ) {
147
148
  return this.onInterval(
148
149
  handler,
149
- { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },
150
+ create(HandleIntervalSchema, { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval }),
150
151
  undefined
151
152
  // fetchConfig
152
153
  )