@sentio/sdk 2.59.0-rc.4 → 2.59.0-rc.41

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 (280) hide show
  1. package/lib/aptos/api.d.ts +1 -0
  2. package/lib/aptos/api.d.ts.map +1 -1
  3. package/lib/aptos/api.js +13 -1
  4. package/lib/aptos/api.js.map +1 -1
  5. package/lib/aptos/aptos-plugin.d.ts +8 -4
  6. package/lib/aptos/aptos-plugin.d.ts.map +1 -1
  7. package/lib/aptos/aptos-plugin.js +51 -8
  8. package/lib/aptos/aptos-plugin.js.map +1 -1
  9. package/lib/aptos/aptos-processor.d.ts +21 -19
  10. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  11. package/lib/aptos/aptos-processor.js +102 -50
  12. package/lib/aptos/aptos-processor.js.map +1 -1
  13. package/lib/aptos/aptos-resource-processor-template.d.ts +5 -4
  14. package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
  15. package/lib/aptos/aptos-resource-processor-template.js +8 -8
  16. package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
  17. package/lib/aptos/builtin/0x1.d.ts +333 -332
  18. package/lib/aptos/builtin/0x1.d.ts.map +1 -1
  19. package/lib/aptos/builtin/0x1.js +664 -664
  20. package/lib/aptos/builtin/0x1.js.map +1 -1
  21. package/lib/aptos/builtin/0x3.d.ts +66 -65
  22. package/lib/aptos/builtin/0x3.d.ts.map +1 -1
  23. package/lib/aptos/builtin/0x3.js +130 -130
  24. package/lib/aptos/builtin/0x3.js.map +1 -1
  25. package/lib/aptos/builtin/0x4.d.ts +29 -28
  26. package/lib/aptos/builtin/0x4.d.ts.map +1 -1
  27. package/lib/aptos/builtin/0x4.js +56 -56
  28. package/lib/aptos/builtin/0x4.js.map +1 -1
  29. package/lib/aptos/codegen/codegen.js +31 -4
  30. package/lib/aptos/codegen/codegen.js.map +1 -1
  31. package/lib/aptos/data.d.ts +45 -0
  32. package/lib/aptos/data.d.ts.map +1 -0
  33. package/lib/aptos/data.js +99 -0
  34. package/lib/aptos/data.js.map +1 -0
  35. package/lib/aptos/index.d.ts +1 -0
  36. package/lib/aptos/index.d.ts.map +1 -1
  37. package/lib/aptos/index.js.map +1 -1
  38. package/lib/aptos/models.d.ts +1 -0
  39. package/lib/aptos/models.d.ts.map +1 -1
  40. package/lib/aptos/move-coder.d.ts +8 -2
  41. package/lib/aptos/move-coder.d.ts.map +1 -1
  42. package/lib/aptos/move-coder.js +84 -1
  43. package/lib/aptos/move-coder.js.map +1 -1
  44. package/lib/aptos/network.d.ts +1 -0
  45. package/lib/aptos/network.d.ts.map +1 -1
  46. package/lib/aptos/network.js +1 -0
  47. package/lib/aptos/network.js.map +1 -1
  48. package/lib/btc/btc-plugin.d.ts +4 -1
  49. package/lib/btc/btc-plugin.d.ts.map +1 -1
  50. package/lib/btc/btc-plugin.js +27 -0
  51. package/lib/btc/btc-plugin.js.map +1 -1
  52. package/lib/btc/btc-processor.d.ts +6 -5
  53. package/lib/btc/btc-processor.d.ts.map +1 -1
  54. package/lib/btc/btc-processor.js +35 -9
  55. package/lib/btc/btc-processor.js.map +1 -1
  56. package/lib/btc/types.d.ts +2 -1
  57. package/lib/btc/types.d.ts.map +1 -1
  58. package/lib/core/base-context.d.ts +4 -2
  59. package/lib/core/base-context.d.ts.map +1 -1
  60. package/lib/core/base-context.js +10 -5
  61. package/lib/core/base-context.js.map +1 -1
  62. package/lib/core/event-logger.d.ts +5 -0
  63. package/lib/core/event-logger.d.ts.map +1 -1
  64. package/lib/core/event-logger.js +36 -1
  65. package/lib/core/event-logger.js.map +1 -1
  66. package/lib/core/handler-options.d.ts +25 -0
  67. package/lib/core/handler-options.d.ts.map +1 -0
  68. package/lib/core/handler-options.js +21 -0
  69. package/lib/core/handler-options.js.map +1 -0
  70. package/lib/core/index.d.ts +3 -1
  71. package/lib/core/index.d.ts.map +1 -1
  72. package/lib/core/index.js +3 -1
  73. package/lib/core/index.js.map +1 -1
  74. package/lib/core/meter.d.ts +45 -2
  75. package/lib/core/meter.d.ts.map +1 -1
  76. package/lib/core/meter.js +124 -2
  77. package/lib/core/meter.js.map +1 -1
  78. package/lib/core/numberish.d.ts +2 -1
  79. package/lib/core/numberish.d.ts.map +1 -1
  80. package/lib/core/numberish.js +35 -1
  81. package/lib/core/numberish.js.map +1 -1
  82. package/lib/core/partition-handler-manager.d.ts +44 -0
  83. package/lib/core/partition-handler-manager.d.ts.map +1 -0
  84. package/lib/core/partition-handler-manager.js +76 -0
  85. package/lib/core/partition-handler-manager.js.map +1 -0
  86. package/lib/cosmos/cosmos-processor.d.ts +3 -2
  87. package/lib/cosmos/cosmos-processor.d.ts.map +1 -1
  88. package/lib/cosmos/cosmos-processor.js +11 -1
  89. package/lib/cosmos/cosmos-processor.js.map +1 -1
  90. package/lib/cosmos/types.d.ts +1 -0
  91. package/lib/cosmos/types.d.ts.map +1 -1
  92. package/lib/eth/base-processor.d.ts +23 -17
  93. package/lib/eth/base-processor.d.ts.map +1 -1
  94. package/lib/eth/base-processor.js +173 -34
  95. package/lib/eth/base-processor.js.map +1 -1
  96. package/lib/eth/bind-options.d.ts +6 -0
  97. package/lib/eth/bind-options.d.ts.map +1 -1
  98. package/lib/eth/bind-options.js +2 -0
  99. package/lib/eth/bind-options.js.map +1 -1
  100. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -31
  101. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  102. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
  103. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  104. package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -16
  105. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  106. package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
  107. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  108. package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -24
  109. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  110. package/lib/eth/builtin/internal/erc20-processor.js +48 -48
  111. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  112. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -13
  113. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  114. package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
  115. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  116. package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -20
  117. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  118. package/lib/eth/builtin/internal/erc721-processor.js +40 -40
  119. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  120. package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -19
  121. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  122. package/lib/eth/builtin/internal/weth9-processor.js +38 -38
  123. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  124. package/lib/eth/codegen/event-handler.js +2 -2
  125. package/lib/eth/codegen/event-handler.js.map +1 -1
  126. package/lib/eth/codegen/file.d.ts.map +1 -1
  127. package/lib/eth/codegen/file.js +1 -0
  128. package/lib/eth/codegen/file.js.map +1 -1
  129. package/lib/eth/codegen/functions-handler.js +2 -2
  130. package/lib/eth/codegen/functions-handler.js.map +1 -1
  131. package/lib/eth/eth-plugin.d.ts +5 -1
  132. package/lib/eth/eth-plugin.d.ts.map +1 -1
  133. package/lib/eth/eth-plugin.js +53 -5
  134. package/lib/eth/eth-plugin.js.map +1 -1
  135. package/lib/eth/eth.d.ts +2 -7
  136. package/lib/eth/eth.d.ts.map +1 -1
  137. package/lib/eth/eth.js +8 -1
  138. package/lib/eth/eth.js.map +1 -1
  139. package/lib/fuel/codegen/codegen.js +5 -5
  140. package/lib/fuel/codegen/codegen.js.map +1 -1
  141. package/lib/fuel/fuel-plugin.d.ts +4 -1
  142. package/lib/fuel/fuel-plugin.d.ts.map +1 -1
  143. package/lib/fuel/fuel-plugin.js +41 -0
  144. package/lib/fuel/fuel-plugin.js.map +1 -1
  145. package/lib/fuel/fuel-processor-template.d.ts +7 -4
  146. package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
  147. package/lib/fuel/fuel-processor-template.js +11 -9
  148. package/lib/fuel/fuel-processor-template.js.map +1 -1
  149. package/lib/fuel/fuel-processor.d.ts +7 -7
  150. package/lib/fuel/fuel-processor.d.ts.map +1 -1
  151. package/lib/fuel/fuel-processor.js +91 -28
  152. package/lib/fuel/fuel-processor.js.map +1 -1
  153. package/lib/fuel/types.d.ts +3 -0
  154. package/lib/fuel/types.d.ts.map +1 -1
  155. package/lib/move/filter.d.ts +5 -0
  156. package/lib/move/filter.d.ts.map +1 -1
  157. package/lib/move/filter.js +5 -0
  158. package/lib/move/filter.js.map +1 -1
  159. package/lib/move/shared-network-codegen.d.ts.map +1 -1
  160. package/lib/move/shared-network-codegen.js +5 -4
  161. package/lib/move/shared-network-codegen.js.map +1 -1
  162. package/lib/solana/solana-processor.d.ts +10 -4
  163. package/lib/solana/solana-processor.d.ts.map +1 -1
  164. package/lib/solana/solana-processor.js +13 -4
  165. package/lib/solana/solana-processor.js.map +1 -1
  166. package/lib/stark/starknet-processor.d.ts +3 -1
  167. package/lib/stark/starknet-processor.d.ts.map +1 -1
  168. package/lib/stark/starknet-processor.js +32 -14
  169. package/lib/stark/starknet-processor.js.map +1 -1
  170. package/lib/store/codegen.d.ts.map +1 -1
  171. package/lib/store/codegen.js +36 -2
  172. package/lib/store/codegen.js.map +1 -1
  173. package/lib/store/schema.d.ts.map +1 -1
  174. package/lib/store/schema.js +3 -1
  175. package/lib/store/schema.js.map +1 -1
  176. package/lib/store/store.d.ts +4 -3
  177. package/lib/store/store.d.ts.map +1 -1
  178. package/lib/store/store.js +41 -1
  179. package/lib/store/store.js.map +1 -1
  180. package/lib/store/types.d.ts +20 -1
  181. package/lib/store/types.d.ts.map +1 -1
  182. package/lib/store/types.js +22 -0
  183. package/lib/store/types.js.map +1 -1
  184. package/lib/sui/builtin/0x1.d.ts +7 -6
  185. package/lib/sui/builtin/0x1.d.ts.map +1 -1
  186. package/lib/sui/builtin/0x1.js +12 -12
  187. package/lib/sui/builtin/0x1.js.map +1 -1
  188. package/lib/sui/builtin/0x2.d.ts +61 -60
  189. package/lib/sui/builtin/0x2.d.ts.map +1 -1
  190. package/lib/sui/builtin/0x2.js +120 -120
  191. package/lib/sui/builtin/0x2.js.map +1 -1
  192. package/lib/sui/builtin/0x3.d.ts +49 -48
  193. package/lib/sui/builtin/0x3.d.ts.map +1 -1
  194. package/lib/sui/builtin/0x3.js +96 -96
  195. package/lib/sui/builtin/0x3.js.map +1 -1
  196. package/lib/sui/models.d.ts +1 -0
  197. package/lib/sui/models.d.ts.map +1 -1
  198. package/lib/sui/sui-object-processor-template.js +1 -1
  199. package/lib/sui/sui-object-processor-template.js.map +1 -1
  200. package/lib/sui/sui-object-processor.d.ts +2 -0
  201. package/lib/sui/sui-object-processor.d.ts.map +1 -1
  202. package/lib/sui/sui-object-processor.js +4 -0
  203. package/lib/sui/sui-object-processor.js.map +1 -1
  204. package/lib/sui/sui-plugin.d.ts +6 -3
  205. package/lib/sui/sui-plugin.d.ts.map +1 -1
  206. package/lib/sui/sui-plugin.js +68 -24
  207. package/lib/sui/sui-plugin.js.map +1 -1
  208. package/lib/sui/sui-processor.d.ts +6 -4
  209. package/lib/sui/sui-processor.d.ts.map +1 -1
  210. package/lib/sui/sui-processor.js +48 -11
  211. package/lib/sui/sui-processor.js.map +1 -1
  212. package/lib/testing/eth-facet.d.ts +2 -1
  213. package/lib/testing/eth-facet.d.ts.map +1 -1
  214. package/lib/testing/eth-facet.js.map +1 -1
  215. package/lib/utils/block.d.ts +2 -0
  216. package/lib/utils/block.d.ts.map +1 -1
  217. package/lib/utils/block.js +13 -0
  218. package/lib/utils/block.js.map +1 -1
  219. package/package.json +8 -7
  220. package/src/aptos/api.ts +13 -1
  221. package/src/aptos/aptos-plugin.ts +62 -13
  222. package/src/aptos/aptos-processor.ts +114 -74
  223. package/src/aptos/aptos-resource-processor-template.ts +9 -8
  224. package/src/aptos/builtin/0x1.ts +1566 -664
  225. package/src/aptos/builtin/0x3.ts +303 -130
  226. package/src/aptos/builtin/0x4.ts +124 -56
  227. package/src/aptos/codegen/codegen.ts +40 -5
  228. package/src/aptos/data.ts +123 -0
  229. package/src/aptos/index.ts +2 -0
  230. package/src/aptos/models.ts +2 -0
  231. package/src/aptos/move-coder.ts +96 -3
  232. package/src/aptos/network.ts +1 -0
  233. package/src/btc/btc-plugin.ts +38 -0
  234. package/src/btc/btc-processor.ts +35 -10
  235. package/src/btc/types.ts +2 -1
  236. package/src/core/base-context.ts +10 -5
  237. package/src/core/event-logger.ts +45 -1
  238. package/src/core/handler-options.ts +40 -0
  239. package/src/core/index.ts +17 -1
  240. package/src/core/meter.ts +159 -4
  241. package/src/core/numberish.ts +34 -1
  242. package/src/core/partition-handler-manager.ts +94 -0
  243. package/src/cosmos/cosmos-processor.ts +12 -1
  244. package/src/cosmos/types.ts +1 -0
  245. package/src/eth/base-processor.ts +163 -41
  246. package/src/eth/bind-options.ts +7 -0
  247. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +118 -62
  248. package/src/eth/builtin/internal/erc1155-processor.ts +76 -32
  249. package/src/eth/builtin/internal/erc20-processor.ts +79 -48
  250. package/src/eth/builtin/internal/erc20bytes-processor.ts +47 -26
  251. package/src/eth/builtin/internal/erc721-processor.ts +77 -40
  252. package/src/eth/builtin/internal/weth9-processor.ts +79 -38
  253. package/src/eth/codegen/event-handler.ts +2 -2
  254. package/src/eth/codegen/file.ts +1 -0
  255. package/src/eth/codegen/functions-handler.ts +2 -2
  256. package/src/eth/eth-plugin.ts +76 -10
  257. package/src/eth/eth.ts +12 -1
  258. package/src/fuel/codegen/codegen.ts +5 -5
  259. package/src/fuel/fuel-plugin.ts +56 -0
  260. package/src/fuel/fuel-processor-template.ts +17 -10
  261. package/src/fuel/fuel-processor.ts +90 -22
  262. package/src/fuel/types.ts +3 -0
  263. package/src/move/filter.ts +5 -0
  264. package/src/move/shared-network-codegen.ts +5 -4
  265. package/src/solana/solana-processor.ts +28 -6
  266. package/src/stark/starknet-processor.ts +31 -13
  267. package/src/store/codegen.ts +50 -2
  268. package/src/store/schema.ts +3 -1
  269. package/src/store/store.ts +57 -4
  270. package/src/store/types.ts +30 -1
  271. package/src/sui/builtin/0x1.ts +22 -12
  272. package/src/sui/builtin/0x2.ts +220 -120
  273. package/src/sui/builtin/0x3.ts +241 -96
  274. package/src/sui/models.ts +2 -0
  275. package/src/sui/sui-object-processor-template.ts +1 -1
  276. package/src/sui/sui-object-processor.ts +6 -0
  277. package/src/sui/sui-plugin.ts +77 -26
  278. package/src/sui/sui-processor.ts +50 -11
  279. package/src/testing/eth-facet.ts +2 -1
  280. package/src/utils/block.ts +15 -0
@@ -3,17 +3,13 @@ import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseP
3
3
  import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
4
4
  import {
5
5
  AddressType,
6
- Data_EthBlock,
7
- Data_EthLog,
8
- Data_EthTrace,
9
- Data_EthTransaction,
10
6
  EthFetchConfig,
11
7
  HandleInterval,
12
8
  PreparedData,
13
9
  PreprocessResult,
14
10
  ProcessResult
15
11
  } from '@sentio/protos'
16
- import { BindOptions } from './bind-options.js'
12
+ import { BindOptions, TimeOrBlock } from './bind-options.js'
17
13
  import { PromiseOrVoid } from '../core/promises.js'
18
14
  import { ServerError, Status } from 'nice-grpc'
19
15
  import {
@@ -27,9 +23,10 @@ import {
27
23
  } from './eth.js'
28
24
  import sha3 from 'js-sha3'
29
25
  import { ListStateStorage } from '@sentio/runtime'
26
+ import { type Data_EthLog, type Data_EthTrace, type Data_EthTransaction, type Data_EthBlock } from '@sentio/runtime'
30
27
  import { EthChainId } from '@sentio/chain'
31
28
  import { getHandlerName, proxyHandlers, proxyProcessor } from '../utils/metrics.js'
32
- import { ALL_ADDRESS } from '../core/index.js'
29
+ import { ALL_ADDRESS, HandlerOptions } from '../core/index.js'
33
30
  import { parseLog, decodeTrace } from './abi-decoder/index.js'
34
31
 
35
32
  export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
@@ -45,6 +42,7 @@ export class EventsHandler {
45
42
  handler: (event: Data_EthLog) => Promise<ProcessResult>
46
43
  preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
47
44
  fetchConfig: EthFetchConfig
45
+ partitionHandler?: (event: Data_EthLog) => Promise<string | undefined>
48
46
  }
49
47
 
50
48
  export class TraceHandler {
@@ -53,6 +51,7 @@ export class TraceHandler {
53
51
  handler: (trace: Data_EthTrace) => Promise<ProcessResult>
54
52
  preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
55
53
  fetchConfig: EthFetchConfig
54
+ partitionHandler?: (trace: Data_EthTrace) => Promise<string | undefined>
56
55
  }
57
56
 
58
57
  export class BlockHandler {
@@ -62,21 +61,23 @@ export class BlockHandler {
62
61
  handler: (block: Data_EthBlock) => Promise<ProcessResult>
63
62
  preprocessHandler?: (event: Data_EthBlock, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
64
63
  fetchConfig: EthFetchConfig
64
+ partitionHandler?: (block: Data_EthBlock) => Promise<string | undefined>
65
65
  }
66
66
 
67
67
  export class TransactionHandler {
68
- handler: (block: Data_EthTransaction) => Promise<ProcessResult>
68
+ handler: (tx: Data_EthTransaction) => Promise<ProcessResult>
69
69
  handlerName: string
70
70
  preprocessHandler?: (event: Data_EthTransaction, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
71
71
  fetchConfig: EthFetchConfig
72
+ partitionHandler?: (tx: Data_EthTransaction) => Promise<string | undefined>
72
73
  }
73
74
 
74
75
  class BindInternalOptions {
75
76
  address: string
76
77
  network: EthChainId
77
78
  name: string
78
- startBlock: bigint
79
- endBlock?: bigint
79
+ start: TimeOrBlock
80
+ end?: TimeOrBlock
80
81
  baseLabels?: { [key: string]: string }
81
82
  }
82
83
 
@@ -101,13 +102,20 @@ export class GlobalProcessor {
101
102
  address: ALL_ADDRESS,
102
103
  name: config.name || 'Global',
103
104
  network: config.network || EthChainId.ETHEREUM,
104
- startBlock: 0n
105
+ start: config.start || {
106
+ block: 0
107
+ },
108
+ end: config.end
105
109
  }
106
110
  if (config.startBlock) {
107
- this.config.startBlock = BigInt(config.startBlock)
111
+ this.config.start = {
112
+ block: config.startBlock
113
+ }
108
114
  }
109
115
  if (config.endBlock) {
110
- this.config.endBlock = BigInt(config.endBlock)
116
+ this.config.end = {
117
+ block: config.endBlock
118
+ }
111
119
  }
112
120
 
113
121
  return proxyProcessor(this)
@@ -117,7 +125,7 @@ export class GlobalProcessor {
117
125
  handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
118
126
  blockInterval = 250,
119
127
  backfillBlockInterval = 1000,
120
- fetchConfig?: Partial<EthFetchConfig>,
128
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
121
129
  preprocessHandler: (
122
130
  block: RichBlock,
123
131
  ctx: GlobalContext,
@@ -133,7 +141,7 @@ export class GlobalProcessor {
133
141
  recentInterval: blockInterval,
134
142
  backfillInterval: backfillBlockInterval
135
143
  },
136
- fetchConfig,
144
+ handlerOptions,
137
145
  preprocessHandler
138
146
  )
139
147
  }
@@ -142,7 +150,7 @@ export class GlobalProcessor {
142
150
  handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
143
151
  timeIntervalInMinutes = 60,
144
152
  backfillTimeIntervalInMinutes = 240,
145
- fetchConfig?: Partial<EthFetchConfig>,
153
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
146
154
  preprocessHandler: (
147
155
  block: RichBlock,
148
156
  ctx: GlobalContext,
@@ -155,7 +163,7 @@ export class GlobalProcessor {
155
163
  handler,
156
164
  { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
157
165
  undefined,
158
- fetchConfig,
166
+ handlerOptions,
159
167
  preprocessHandler
160
168
  )
161
169
  }
@@ -168,7 +176,7 @@ export class GlobalProcessor {
168
176
  handler: (block: RichBlock, ctx: GlobalContext) => PromiseOrVoid,
169
177
  timeInterval: HandleInterval | undefined,
170
178
  blockInterval: HandleInterval | undefined,
171
- fetchConfig: Partial<EthFetchConfig> | undefined,
179
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
172
180
  preprocessHandler: (
173
181
  block: RichBlock,
174
182
  ctx: GlobalContext,
@@ -230,14 +238,24 @@ export class GlobalProcessor {
230
238
  },
231
239
  timeIntervalInMinutes: timeInterval,
232
240
  blockInterval: blockInterval,
233
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
241
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
242
+ partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
243
+ const p = handlerOptions?.partitionKey
244
+ if (!p) return undefined
245
+ if (typeof p === 'function') {
246
+ const { block } = formatEthData(data)
247
+ if (!block) return undefined
248
+ return p(block)
249
+ }
250
+ return p
251
+ }
234
252
  })
235
253
  return this
236
254
  }
237
255
 
238
256
  public onTransaction(
239
257
  handler: (transaction: TransactionResponseParams, ctx: GlobalContext) => PromiseOrVoid,
240
- fetchConfig?: Partial<EthFetchConfig>,
258
+ handlerOptions?: HandlerOptions<EthFetchConfig, TransactionResponseParams>,
241
259
  preprocessHandler: (
242
260
  transaction: TransactionResponseParams,
243
261
  ctx: GlobalContext,
@@ -298,7 +316,16 @@ export class GlobalProcessor {
298
316
  )
299
317
  return preprocessHandler(transaction, ctx, preprocessStore)
300
318
  },
301
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
319
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
320
+ partitionHandler: async (data: Data_EthTransaction): Promise<string | undefined> => {
321
+ const p = handlerOptions?.partitionKey
322
+ if (!p) return undefined
323
+ if (typeof p === 'function') {
324
+ const { transaction } = formatEthData(data)
325
+ return p(transaction)
326
+ }
327
+ return p
328
+ }
302
329
  })
303
330
  return this
304
331
  }
@@ -306,7 +333,7 @@ export class GlobalProcessor {
306
333
  public onTrace(
307
334
  signatures: string | string[],
308
335
  handler: (trace: Trace, ctx: GlobalContext) => PromiseOrVoid,
309
- fetchConfig?: Partial<EthFetchConfig>,
336
+ handlerOptions?: HandlerOptions<EthFetchConfig, Trace>,
310
337
  preprocessHandler: (
311
338
  trace: Trace,
312
339
  ctx: GlobalContext,
@@ -329,7 +356,7 @@ export class GlobalProcessor {
329
356
 
330
357
  this.traceHandlers.push({
331
358
  signatures,
332
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
359
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
333
360
  handlerName: getHandlerName(),
334
361
  handler: async function (data: Data_EthTrace) {
335
362
  const { trace, block, transaction, transactionReceipt } = formatEthData(data)
@@ -369,6 +396,16 @@ export class GlobalProcessor {
369
396
  processor.config.baseLabels
370
397
  )
371
398
  return preprocessHandler(trace, ctx, preprocessStore)
399
+ },
400
+ partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
401
+ const p = handlerOptions?.partitionKey
402
+ if (!p) return undefined
403
+ if (typeof p === 'function') {
404
+ const { trace } = formatEthData(data)
405
+ if (!trace) return undefined
406
+ return p(trace)
407
+ }
408
+ return p
372
409
  }
373
410
  })
374
411
  return this
@@ -390,14 +427,21 @@ export abstract class BaseProcessor<
390
427
  address: validateAndNormalizeAddress(config.address),
391
428
  name: config.name || '',
392
429
  network: config.network || EthChainId.ETHEREUM,
393
- startBlock: 0n,
430
+ start: config.start || {
431
+ block: 0
432
+ },
433
+ end: config.end,
394
434
  baseLabels: config.baseLabels
395
435
  }
396
436
  if (config.startBlock) {
397
- this.config.startBlock = BigInt(config.startBlock)
437
+ this.config.start = {
438
+ block: config.startBlock
439
+ }
398
440
  }
399
441
  if (config.endBlock) {
400
- this.config.endBlock = BigInt(config.endBlock)
442
+ this.config.end = {
443
+ block: config.endBlock
444
+ }
401
445
  }
402
446
 
403
447
  return proxyProcessor(this)
@@ -411,7 +455,7 @@ export abstract class BaseProcessor<
411
455
 
412
456
  public onEvent(
413
457
  handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
414
- fetchConfig?: Partial<EthFetchConfig>,
458
+ handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
415
459
  preprocessHandler: (
416
460
  event: TypedEvent,
417
461
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -427,13 +471,13 @@ export abstract class BaseProcessor<
427
471
  _filters.push(filter())
428
472
  }
429
473
  }
430
- return this.onEthEvent(handler, _filters, fetchConfig, preprocessHandler)
474
+ return this.onEthEvent(handler, _filters, handlerOptions, preprocessHandler)
431
475
  }
432
476
 
433
477
  protected onEthEvent(
434
478
  handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
435
479
  filter: DeferredTopicFilter | DeferredTopicFilter[],
436
- fetchConfig?: Partial<EthFetchConfig>,
480
+ handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>,
437
481
  preprocessHandler: (
438
482
  event: TypedEvent,
439
483
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -454,7 +498,7 @@ export abstract class BaseProcessor<
454
498
  const processor = this
455
499
  this.eventHandlers.push({
456
500
  filters: _filters,
457
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
501
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
458
502
  handlerName,
459
503
  handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
460
504
  const { log, block, transaction, transactionReceipt } = formatEthData(data)
@@ -474,7 +518,7 @@ export abstract class BaseProcessor<
474
518
 
475
519
  let parsed: LogDescription | null = null
476
520
  try {
477
- parsed = await parseLog(processor, log)
521
+ parsed = await getCachedParsedLog(data, processor, log)
478
522
  } catch (e) {
479
523
  // RangeError data out-of-bounds
480
524
  if (e instanceof Error) {
@@ -539,7 +583,7 @@ export abstract class BaseProcessor<
539
583
 
540
584
  let parsed: LogDescription | null = null
541
585
  try {
542
- parsed = await parseLog(processor, log)
586
+ parsed = await getCachedParsedLog(data, processor, log)
543
587
  } catch (e) {
544
588
  // RangeError data out-of-bounds
545
589
  if (e instanceof Error) {
@@ -555,6 +599,26 @@ export abstract class BaseProcessor<
555
599
  return preprocessHandler(event, ctx, preprocessStore)
556
600
  }
557
601
  return PreprocessResult.fromPartial({})
602
+ },
603
+ partitionHandler: async (data: Data_EthLog): Promise<string | undefined> => {
604
+ const p = handlerOptions?.partitionKey
605
+ if (!p) return undefined
606
+ if (typeof p === 'function') {
607
+ const { log } = formatEthData(data)
608
+ if (!log) return undefined
609
+ let parsed: LogDescription | null = null
610
+ try {
611
+ parsed = await getCachedParsedLog(data, processor, log)
612
+ } catch (e) {
613
+ return undefined
614
+ }
615
+ if (parsed) {
616
+ const event: TypedEvent = { ...log, name: parsed.name, args: fixEmptyKey(parsed) }
617
+ return p(event)
618
+ }
619
+ return undefined
620
+ }
621
+ return p
558
622
  }
559
623
  })
560
624
  return this
@@ -564,7 +628,7 @@ export abstract class BaseProcessor<
564
628
  handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
565
629
  blockInterval = 250,
566
630
  backfillBlockInterval = 1000,
567
- fetchConfig?: Partial<EthFetchConfig>,
631
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
568
632
  preprocessHandler: (
569
633
  block: RichBlock,
570
634
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -578,7 +642,7 @@ export abstract class BaseProcessor<
578
642
  recentInterval: blockInterval,
579
643
  backfillInterval: backfillBlockInterval
580
644
  },
581
- fetchConfig,
645
+ handlerOptions,
582
646
  preprocessHandler
583
647
  )
584
648
  }
@@ -587,7 +651,7 @@ export abstract class BaseProcessor<
587
651
  handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
588
652
  timeIntervalInMinutes = 60,
589
653
  backfillTimeIntervalInMinutes = 240,
590
- fetchConfig?: Partial<EthFetchConfig>,
654
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
591
655
  preprocessHandler: (
592
656
  block: RichBlock,
593
657
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -598,7 +662,7 @@ export abstract class BaseProcessor<
598
662
  handler,
599
663
  { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
600
664
  undefined,
601
- fetchConfig,
665
+ handlerOptions,
602
666
  preprocessHandler
603
667
  )
604
668
  }
@@ -607,7 +671,7 @@ export abstract class BaseProcessor<
607
671
  handler: (block: RichBlock, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
608
672
  timeInterval: HandleInterval | undefined,
609
673
  blockInterval: HandleInterval | undefined,
610
- fetchConfig: Partial<EthFetchConfig> | undefined,
674
+ handlerOptions?: HandlerOptions<EthFetchConfig, RichBlock>,
611
675
  preprocessHandler: (
612
676
  block: RichBlock,
613
677
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -671,7 +735,17 @@ export abstract class BaseProcessor<
671
735
  },
672
736
  timeIntervalInMinutes: timeInterval,
673
737
  blockInterval: blockInterval,
674
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
738
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
739
+ partitionHandler: async (data: Data_EthBlock): Promise<string | undefined> => {
740
+ const p = handlerOptions?.partitionKey
741
+ if (!p) return undefined
742
+ if (typeof p === 'function') {
743
+ const { block } = formatEthData(data)
744
+ if (!block) return undefined
745
+ return p(block)
746
+ }
747
+ return p
748
+ }
675
749
  })
676
750
  return this
677
751
  }
@@ -679,7 +753,7 @@ export abstract class BaseProcessor<
679
753
  protected onEthTrace(
680
754
  signatures: string | string[],
681
755
  handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
682
- fetchConfig?: Partial<EthFetchConfig>,
756
+ handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
683
757
  preprocessHandler: (
684
758
  trace: TypedCallTrace,
685
759
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -696,7 +770,7 @@ export abstract class BaseProcessor<
696
770
 
697
771
  this.traceHandlers.push({
698
772
  signatures,
699
- fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
773
+ fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
700
774
  handlerName,
701
775
  handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
702
776
  const contractView = processor.CreateBoundContractView()
@@ -786,6 +860,35 @@ export abstract class BaseProcessor<
786
860
  processor.config.baseLabels
787
861
  )
788
862
  return preprocessHandler(typedTrace, ctx, preprocessStore)
863
+ },
864
+ partitionHandler: async (data: Data_EthTrace): Promise<string | undefined> => {
865
+ const p = handlerOptions?.partitionKey
866
+ if (!p) return undefined
867
+ if (typeof p === 'function') {
868
+ const contractView = processor.CreateBoundContractView()
869
+ const contractInterface = contractView.rawContract.interface
870
+ const { trace } = formatEthData(data)
871
+ if (!trace) return undefined
872
+ const sighash = trace.action.input?.slice(0, 10)
873
+ if (!sighash) return undefined
874
+ const fragment = contractInterface.getFunction(sighash)
875
+ if (!fragment) return undefined
876
+ const typedTrace = trace as TypedCallTrace
877
+ typedTrace.name = fragment.name
878
+ typedTrace.functionSignature = fragment.format()
879
+ if (trace.action.input) {
880
+ const traceData = '0x' + trace.action.input.slice(10)
881
+ try {
882
+ typedTrace.args = await decodeTrace(processor, fragment.inputs, traceData)
883
+ } catch (e) {
884
+ if (!trace.error) {
885
+ throw e
886
+ }
887
+ }
888
+ }
889
+ return p(typedTrace)
890
+ }
891
+ return p
789
892
  }
790
893
  })
791
894
  return this
@@ -793,7 +896,7 @@ export abstract class BaseProcessor<
793
896
 
794
897
  public onTrace(
795
898
  handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
796
- fetchConfig?: Partial<EthFetchConfig>,
899
+ handlerOptions?: HandlerOptions<EthFetchConfig, TypedCallTrace>,
797
900
  preprocessHandler: (
798
901
  trace: TypedCallTrace,
799
902
  ctx: ContractContext<TContract, TBoundContractView>,
@@ -811,6 +914,25 @@ export abstract class BaseProcessor<
811
914
  sighashes.push(sighash)
812
915
  }
813
916
  }
814
- return this.onEthTrace(sighashes, handler, fetchConfig, preprocessHandler)
917
+ return this.onEthTrace(sighashes, handler, handlerOptions, preprocessHandler)
918
+ }
919
+ }
920
+
921
+ // Helper function to get cached or parse log data
922
+ async function getCachedParsedLog(data: any, processor: any, log: any): Promise<LogDescription | null> {
923
+ // Check if parsed log is already cached on data object
924
+ if ((data as any).__parsedLog !== undefined) {
925
+ return (data as any).__parsedLog
926
+ }
927
+
928
+ try {
929
+ const parsed = await parseLog(processor, log)
930
+ // Cache the parsed result on the data object
931
+ ;(data as any).__parsedLog = parsed
932
+ return parsed
933
+ } catch (e) {
934
+ // Cache the null result to avoid retrying
935
+ ;(data as any).__parsedLog = null
936
+ throw e
815
937
  }
816
938
  }
@@ -7,11 +7,18 @@ export class BindOptions {
7
7
  network?: EthChainId = EthChainId.ETHEREUM
8
8
  // Optional, override default contract name
9
9
  name?: string
10
+ start?: TimeOrBlock
11
+ end?: TimeOrBlock
10
12
  startBlock?: bigint | number
11
13
  endBlock?: bigint | number
12
14
  baseLabels?: { [key: string]: string }
13
15
  }
14
16
 
17
+ export interface TimeOrBlock {
18
+ block?: bigint | number
19
+ time?: Date
20
+ }
21
+
15
22
  export function getOptionsSignature(opts: BindOptions): string {
16
23
  const sig = [opts.address]
17
24
  if (opts.network) {