@sentio/sdk 2.59.0-rc.8 → 2.59.0

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