@sentio/sdk 2.59.0-rc.24 → 2.59.0-rc.25
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.
- package/lib/aptos/aptos-plugin.d.ts +6 -5
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +31 -33
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +18 -18
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +83 -38
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +5 -4
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +8 -8
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +334 -333
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +348 -348
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +67 -66
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +28 -28
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +30 -29
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +34 -34
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +19 -2
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +28 -3
- package/lib/aptos/data.d.ts.map +1 -1
- package/lib/aptos/data.js +61 -0
- package/lib/aptos/data.js.map +1 -1
- package/lib/aptos/models.d.ts +1 -5
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/btc/btc-plugin.d.ts +4 -1
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +27 -0
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/btc/btc-processor.d.ts +6 -5
- package/lib/btc/btc-processor.d.ts.map +1 -1
- package/lib/btc/btc-processor.js +35 -9
- package/lib/btc/btc-processor.js.map +1 -1
- package/lib/btc/types.d.ts +2 -1
- package/lib/btc/types.d.ts.map +1 -1
- package/lib/core/handler-options.d.ts +25 -0
- package/lib/core/handler-options.d.ts.map +1 -0
- package/lib/core/handler-options.js +21 -0
- package/lib/core/handler-options.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +44 -0
- package/lib/core/partition-handler-manager.d.ts.map +1 -0
- package/lib/core/partition-handler-manager.js +76 -0
- package/lib/core/partition-handler-manager.js.map +1 -0
- package/lib/cosmos/cosmos-processor.d.ts +3 -2
- package/lib/cosmos/cosmos-processor.d.ts.map +1 -1
- package/lib/cosmos/cosmos-processor.js +11 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/cosmos/types.d.ts +1 -0
- package/lib/cosmos/types.d.ts.map +1 -1
- package/lib/eth/base-processor.d.ts +18 -17
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +147 -26
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -31
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -16
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -24
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +48 -48
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -13
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -20
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +40 -40
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -19
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +38 -38
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/event-handler.js +2 -2
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +1 -0
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +2 -2
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +4 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +42 -1
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +2 -7
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +8 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/codegen/codegen.js +5 -5
- package/lib/fuel/codegen/codegen.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +4 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -0
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts +7 -4
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +11 -9
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +7 -7
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +90 -19
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +3 -0
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/move/filter.d.ts +4 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +4 -0
- package/lib/move/filter.js.map +1 -1
- package/lib/move/shared-network-codegen.js +5 -5
- package/lib/move/shared-network-codegen.js.map +1 -1
- package/lib/solana/solana-processor.d.ts +10 -4
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +13 -4
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/stark/starknet-processor.d.ts +3 -1
- package/lib/stark/starknet-processor.d.ts.map +1 -1
- package/lib/stark/starknet-processor.js +27 -2
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts +7 -6
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +12 -12
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +61 -60
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +120 -120
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +49 -48
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +96 -96
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/models.d.ts +1 -5
- package/lib/sui/models.d.ts.map +1 -1
- package/lib/sui/sui-plugin.d.ts +6 -3
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +59 -20
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +5 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +47 -11
- package/lib/sui/sui-processor.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/aptos-plugin.ts +35 -39
- package/src/aptos/aptos-processor.ts +94 -54
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1407 -507
- package/src/aptos/builtin/0x3.ts +251 -80
- package/src/aptos/builtin/0x4.ts +112 -46
- package/src/aptos/codegen/codegen.ts +23 -2
- package/src/aptos/data.ts +78 -3
- package/src/aptos/models.ts +1 -6
- package/src/btc/btc-plugin.ts +38 -0
- package/src/btc/btc-processor.ts +35 -10
- package/src/btc/types.ts +2 -1
- package/src/core/handler-options.ts +40 -0
- package/src/core/index.ts +5 -0
- package/src/core/partition-handler-manager.ts +94 -0
- package/src/cosmos/cosmos-processor.ts +12 -1
- package/src/cosmos/types.ts +1 -0
- package/src/eth/base-processor.ts +139 -33
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +118 -62
- package/src/eth/builtin/internal/erc1155-processor.ts +76 -32
- package/src/eth/builtin/internal/erc20-processor.ts +79 -48
- package/src/eth/builtin/internal/erc20bytes-processor.ts +47 -26
- package/src/eth/builtin/internal/erc721-processor.ts +77 -40
- package/src/eth/builtin/internal/weth9-processor.ts +79 -38
- package/src/eth/codegen/event-handler.ts +2 -2
- package/src/eth/codegen/file.ts +1 -0
- package/src/eth/codegen/functions-handler.ts +2 -2
- package/src/eth/eth-plugin.ts +55 -3
- package/src/eth/eth.ts +12 -1
- package/src/fuel/codegen/codegen.ts +5 -5
- package/src/fuel/fuel-plugin.ts +56 -0
- package/src/fuel/fuel-processor-template.ts +17 -10
- package/src/fuel/fuel-processor.ts +89 -13
- package/src/fuel/types.ts +3 -0
- package/src/move/filter.ts +4 -0
- package/src/move/shared-network-codegen.ts +5 -5
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +28 -2
- package/src/sui/builtin/0x1.ts +22 -13
- package/src/sui/builtin/0x2.ts +220 -121
- package/src/sui/builtin/0x3.ts +241 -97
- package/src/sui/models.ts +1 -6
- package/src/sui/sui-plugin.ts +68 -22
- package/src/sui/sui-processor.ts +48 -11
@@ -8,6 +8,7 @@ import { FuelBlock, FuelLog, FuelTransaction } from './types.js'
|
|
8
8
|
import { DEFAULT_FUEL_FETCH_CONFIG, FuelFetchConfig } from './transaction.js'
|
9
9
|
import { FuelProcessor, FuelProcessorConfig, getOptionsSignature } from './fuel-processor.js'
|
10
10
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
11
|
+
import { HandlerOptions } from '../core/index.js'
|
11
12
|
|
12
13
|
export class FuelProcessorTemplateProcessorState extends ListStateStorage<FuelBaseProcessorTemplate<Contract>> {
|
13
14
|
static INSTANCE = new FuelProcessorTemplateProcessorState()
|
@@ -21,6 +22,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
21
22
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
22
23
|
blockInterval?: HandleInterval
|
23
24
|
timeIntervalInMinutes?: HandleInterval
|
25
|
+
handlerOptions?: HandlerOptions<object, FuelBlock>
|
24
26
|
// fetchConfig?: FuelFetchConfig
|
25
27
|
}[] = []
|
26
28
|
|
@@ -28,13 +30,14 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
28
30
|
logIdFilter: string | string[]
|
29
31
|
handlerName: string
|
30
32
|
handler: (logs: FuelLog<any>, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
33
|
+
handlerOptions?: HandlerOptions<object, FuelLog<any>>
|
31
34
|
// fetchConfig?: FuelFetchConfig
|
32
35
|
}[] = []
|
33
36
|
|
34
37
|
transactionHandlers: {
|
35
38
|
handlerName: string
|
36
39
|
handler: (transaction: FuelTransaction, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
37
|
-
|
40
|
+
handlerOptions?: HandlerOptions<FuelFetchConfig, FuelTransaction>
|
38
41
|
}[] = []
|
39
42
|
|
40
43
|
constructor() {
|
@@ -62,13 +65,13 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
62
65
|
const processor = this.bindInternal({ ...options, chainId: ctx.chainId })
|
63
66
|
|
64
67
|
for (const eh of this.logHandlers) {
|
65
|
-
processor.onLog(eh.logIdFilter, eh.handler, eh.handlerName)
|
68
|
+
processor.onLog(eh.logIdFilter, eh.handler, eh.handlerOptions, eh.handlerName)
|
66
69
|
}
|
67
70
|
for (const bh of this.blockHandlers) {
|
68
|
-
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.handlerName)
|
71
|
+
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.handlerOptions, bh.handlerName)
|
69
72
|
}
|
70
73
|
for (const th of this.transactionHandlers) {
|
71
|
-
processor.onTransaction(th.handler,
|
74
|
+
processor.onTransaction(th.handler, th.handlerOptions, th.handlerName)
|
72
75
|
}
|
73
76
|
|
74
77
|
const instance: TemplateInstance = {
|
@@ -94,13 +97,15 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
94
97
|
|
95
98
|
protected onLog<T>(
|
96
99
|
logIdFilter: string | string[],
|
97
|
-
handler: (logs: FuelLog<T>, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
100
|
+
handler: (logs: FuelLog<T>, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
101
|
+
handlerOptions: HandlerOptions<object, FuelLog<T>> = {}
|
98
102
|
// fetchConfig?: Partial<FuelFetchConfig>
|
99
103
|
) {
|
100
104
|
this.logHandlers.push({
|
101
105
|
logIdFilter,
|
102
106
|
handlerName: getHandlerName(),
|
103
|
-
handler
|
107
|
+
handler,
|
108
|
+
handlerOptions
|
104
109
|
// fetchConfig: { ...fetchConfig}
|
105
110
|
})
|
106
111
|
return this
|
@@ -140,14 +145,16 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
140
145
|
public onInterval(
|
141
146
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
142
147
|
timeInterval: HandleInterval | undefined,
|
143
|
-
blockInterval: HandleInterval | undefined
|
148
|
+
blockInterval: HandleInterval | undefined,
|
149
|
+
handlerOptions: HandlerOptions<object, FuelBlock> = {}
|
144
150
|
// fetchConfig?: FuelFetchConfig
|
145
151
|
) {
|
146
152
|
this.blockHandlers.push({
|
147
153
|
handlerName: getHandlerName(),
|
148
154
|
handler,
|
149
155
|
timeIntervalInMinutes: timeInterval,
|
150
|
-
blockInterval
|
156
|
+
blockInterval,
|
157
|
+
handlerOptions
|
151
158
|
// fetchConfig: { ...fetchConfig }
|
152
159
|
})
|
153
160
|
return this
|
@@ -155,12 +162,12 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
155
162
|
|
156
163
|
protected onTransaction(
|
157
164
|
handler: (transaction: FuelTransaction, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
158
|
-
|
165
|
+
handlerOptions: HandlerOptions<FuelFetchConfig, FuelTransaction> = DEFAULT_FUEL_FETCH_CONFIG
|
159
166
|
) {
|
160
167
|
this.transactionHandlers.push({
|
161
168
|
handlerName: getHandlerName(),
|
162
169
|
handler,
|
163
|
-
|
170
|
+
handlerOptions
|
164
171
|
})
|
165
172
|
return this
|
166
173
|
}
|
@@ -27,7 +27,7 @@ import {
|
|
27
27
|
FuelTransaction,
|
28
28
|
ReceiptHandler
|
29
29
|
} from './types.js'
|
30
|
-
import { PromiseOrVoid } from '../core/index.js'
|
30
|
+
import { PromiseOrVoid, HandlerOptions } from '../core/index.js'
|
31
31
|
import { ServerError, Status } from 'nice-grpc'
|
32
32
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
33
33
|
|
@@ -88,7 +88,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
88
88
|
|
89
89
|
public onTransaction(
|
90
90
|
handler: (transaction: FuelTransaction, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
91
|
-
|
91
|
+
handlerOptions?: HandlerOptions<FuelFetchConfig, FuelTransaction>,
|
92
92
|
handlerName = getHandlerName()
|
93
93
|
) {
|
94
94
|
const callHandler = {
|
@@ -115,7 +115,21 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
115
115
|
},
|
116
116
|
fetchConfig: {
|
117
117
|
filters: [],
|
118
|
-
...
|
118
|
+
...handlerOptions
|
119
|
+
},
|
120
|
+
partitionHandler: async (call: Data_FuelTransaction): Promise<string | undefined> => {
|
121
|
+
const p = handlerOptions?.partitionKey
|
122
|
+
if (!p) return undefined
|
123
|
+
if (typeof p === 'function') {
|
124
|
+
const abiMap = this.config.abi
|
125
|
+
? {
|
126
|
+
[this.config.address]: this.config.abi
|
127
|
+
}
|
128
|
+
: {}
|
129
|
+
const tx = await decodeFuelTransactionWithAbi(call.transaction, abiMap, this.provider)
|
130
|
+
return p(tx)
|
131
|
+
}
|
132
|
+
return p
|
119
133
|
}
|
120
134
|
}
|
121
135
|
this.txHandlers.push(callHandler)
|
@@ -198,6 +212,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
198
212
|
public onLog<T>(
|
199
213
|
logIdFilter: string | string[],
|
200
214
|
handler: (logs: FuelLog<T>, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
215
|
+
handlerOptions?: HandlerOptions<object, FuelLog<T>>,
|
201
216
|
handlerName = getHandlerName()
|
202
217
|
) {
|
203
218
|
const logIds = new Set(Array.isArray(logIdFilter) ? logIdFilter : [logIdFilter])
|
@@ -236,6 +251,25 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
236
251
|
log: {
|
237
252
|
logIds: Array.from(logIds)
|
238
253
|
}
|
254
|
+
},
|
255
|
+
partitionHandler: async (data: Data_FuelReceipt): Promise<string | undefined> => {
|
256
|
+
const p = handlerOptions?.partitionKey
|
257
|
+
if (!p) return undefined
|
258
|
+
if (typeof p === 'function') {
|
259
|
+
try {
|
260
|
+
const tx = await decodeFuelTransaction(data.transaction, this.provider)
|
261
|
+
const index = Number(data.receiptIndex)
|
262
|
+
const receipt = tx.receipts[index]
|
263
|
+
const log = decodeLog(receipt, this.config.abi)
|
264
|
+
if (log) {
|
265
|
+
return p({ receiptIndex: index, ...log })
|
266
|
+
}
|
267
|
+
} catch (e) {
|
268
|
+
console.error(e)
|
269
|
+
}
|
270
|
+
return undefined
|
271
|
+
}
|
272
|
+
return p
|
239
273
|
}
|
240
274
|
} as ReceiptHandler
|
241
275
|
this.receiptHandlers.push(logHandler)
|
@@ -247,7 +281,8 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
247
281
|
*/
|
248
282
|
public onTransfer(
|
249
283
|
filter: ContractTransferFilter,
|
250
|
-
handler: (transfer: ReceiptTransfer | ReceiptTransferOut, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
284
|
+
handler: (transfer: ReceiptTransfer | ReceiptTransferOut, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
285
|
+
handlerOptions?: HandlerOptions<object, ReceiptTransfer | ReceiptTransferOut>
|
251
286
|
) {
|
252
287
|
const { from, to, assetId } = filter
|
253
288
|
const h = {
|
@@ -280,6 +315,22 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
280
315
|
to,
|
281
316
|
assetId
|
282
317
|
}
|
318
|
+
},
|
319
|
+
partitionHandler: async (data: Data_FuelReceipt): Promise<string | undefined> => {
|
320
|
+
const p = handlerOptions?.partitionKey
|
321
|
+
if (!p) return undefined
|
322
|
+
if (typeof p === 'function') {
|
323
|
+
try {
|
324
|
+
const tx = await decodeFuelTransaction(data.transaction, this.provider)
|
325
|
+
const index = Number(data.receiptIndex)
|
326
|
+
const receipt = tx.receipts[index] as ReceiptTransfer | ReceiptTransferOut
|
327
|
+
return p(receipt)
|
328
|
+
} catch (e) {
|
329
|
+
console.error(e)
|
330
|
+
}
|
331
|
+
return undefined
|
332
|
+
}
|
333
|
+
return p
|
283
334
|
}
|
284
335
|
} as ReceiptHandler
|
285
336
|
this.receiptHandlers.push(h)
|
@@ -290,8 +341,8 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
290
341
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
291
342
|
timeInterval: HandleInterval | undefined,
|
292
343
|
blockInterval: HandleInterval | undefined,
|
344
|
+
handlerOptions?: HandlerOptions<object, FuelBlock>,
|
293
345
|
handlerName = getHandlerName()
|
294
|
-
// fetchConfig: Partial<FuelFetchConfig> | undefined
|
295
346
|
): this {
|
296
347
|
if (timeInterval) {
|
297
348
|
if (timeInterval.backfillInterval < timeInterval.recentInterval) {
|
@@ -338,6 +389,31 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
338
389
|
)
|
339
390
|
await handler(block, ctx)
|
340
391
|
return ctx.stopAndGetResult()
|
392
|
+
},
|
393
|
+
partitionHandler: async (data: Data_FuelBlock): Promise<string | undefined> => {
|
394
|
+
const p = handlerOptions?.partitionKey
|
395
|
+
if (!p) return undefined
|
396
|
+
if (typeof p === 'function') {
|
397
|
+
const header = data.block
|
398
|
+
if (!header) return undefined
|
399
|
+
const block: FuelBlock = {
|
400
|
+
id: header.id,
|
401
|
+
height: bn(header.height),
|
402
|
+
time: header.time,
|
403
|
+
header: {
|
404
|
+
applicationHash: header.applicationHash,
|
405
|
+
daHeight: bn(header.daHeight),
|
406
|
+
eventInboxRoot: header.eventInboxRoot,
|
407
|
+
messageOutboxRoot: header.messageOutboxRoot,
|
408
|
+
prevRoot: header.prevRoot,
|
409
|
+
stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
|
410
|
+
transactionsCount: header.transactionsCount,
|
411
|
+
transactionsRoot: header.transactionsRoot
|
412
|
+
}
|
413
|
+
}
|
414
|
+
return p(block)
|
415
|
+
}
|
416
|
+
return p
|
341
417
|
}
|
342
418
|
})
|
343
419
|
return this
|
@@ -346,8 +422,8 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
346
422
|
public onBlockInterval(
|
347
423
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
348
424
|
blockInterval = 250,
|
349
|
-
backfillBlockInterval = 1000
|
350
|
-
|
425
|
+
backfillBlockInterval = 1000,
|
426
|
+
handlerOptions?: HandlerOptions<object, FuelBlock>
|
351
427
|
): this {
|
352
428
|
return this.onInterval(
|
353
429
|
handler,
|
@@ -355,22 +431,22 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
355
431
|
{
|
356
432
|
recentInterval: blockInterval,
|
357
433
|
backfillInterval: backfillBlockInterval
|
358
|
-
}
|
359
|
-
|
434
|
+
},
|
435
|
+
handlerOptions
|
360
436
|
)
|
361
437
|
}
|
362
438
|
|
363
439
|
public onTimeInterval(
|
364
440
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
365
441
|
timeIntervalInMinutes = 60,
|
366
|
-
backfillTimeIntervalInMinutes = 240
|
367
|
-
|
442
|
+
backfillTimeIntervalInMinutes = 240,
|
443
|
+
handlerOptions?: HandlerOptions<object, FuelBlock>
|
368
444
|
): this {
|
369
445
|
return this.onInterval(
|
370
446
|
handler,
|
371
447
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
372
|
-
undefined
|
373
|
-
|
448
|
+
undefined,
|
449
|
+
handlerOptions
|
374
450
|
)
|
375
451
|
}
|
376
452
|
}
|
package/src/fuel/types.ts
CHANGED
@@ -29,12 +29,14 @@ export type CallHandler<T> = {
|
|
29
29
|
handler: (call: T) => Promise<ProcessResult>
|
30
30
|
fetchConfig?: Partial<FuelCallHandlerConfig>
|
31
31
|
assetConfig?: Partial<FuelAssetHandlerConfig>
|
32
|
+
partitionHandler?: (call: T) => Promise<string | undefined>
|
32
33
|
}
|
33
34
|
|
34
35
|
export type ReceiptHandler = {
|
35
36
|
handlerName: string
|
36
37
|
handler: (receipt: Data_FuelReceipt) => Promise<ProcessResult>
|
37
38
|
receiptConfig?: Partial<FuelReceiptHandlerConfig>
|
39
|
+
partitionHandler?: (receipt: Data_FuelReceipt) => Promise<string | undefined>
|
38
40
|
}
|
39
41
|
|
40
42
|
export type BlockHandler = {
|
@@ -43,6 +45,7 @@ export type BlockHandler = {
|
|
43
45
|
handler: (block: Data_FuelBlock) => Promise<ProcessResult>
|
44
46
|
handlerName: string
|
45
47
|
fetchConfig?: Partial<OnIntervalConfig>
|
48
|
+
partitionHandler?: (block: Data_FuelBlock) => Promise<string | undefined>
|
46
49
|
}
|
47
50
|
|
48
51
|
export interface FuelLog<T> {
|
package/src/move/filter.ts
CHANGED
@@ -46,6 +46,7 @@ export class CallHandler<T> {
|
|
46
46
|
handlerName: string
|
47
47
|
handler: (call: T) => Promise<ProcessResult>
|
48
48
|
fetchConfig: MoveFetchConfig
|
49
|
+
partitionHandler?: (call: T) => Promise<string | undefined>
|
49
50
|
}
|
50
51
|
|
51
52
|
export class ObjectChangeHandler<T> {
|
@@ -58,6 +59,7 @@ export class ResourceChangeHandler<T> {
|
|
58
59
|
handlerName: string
|
59
60
|
handler: (call: T) => Promise<ProcessResult>
|
60
61
|
type: string
|
62
|
+
partitionHandler?: (call: T) => Promise<string | undefined>
|
61
63
|
}
|
62
64
|
|
63
65
|
export class ResourceIntervalHandler {
|
@@ -67,6 +69,7 @@ export class ResourceIntervalHandler {
|
|
67
69
|
handler: (resource: Data_AptResource) => Promise<ProcessResult>
|
68
70
|
handlerName: string
|
69
71
|
fetchConfig: MoveAccountFetchConfig
|
72
|
+
partitionHandler?: (resource: Data_AptResource) => Promise<string | undefined>
|
70
73
|
}
|
71
74
|
|
72
75
|
export class TransactionIntervalHandler {
|
@@ -75,4 +78,5 @@ export class TransactionIntervalHandler {
|
|
75
78
|
handler: (tx: Data_AptCall) => Promise<ProcessResult>
|
76
79
|
handlerName: string
|
77
80
|
fetchConfig: MoveFetchConfig
|
81
|
+
partitionHandler?: (tx: Data_AptCall) => Promise<string | undefined>
|
78
82
|
}
|
@@ -96,12 +96,12 @@ export abstract class SharedNetworkCodegen<NetworkType, ModuleTypes, StructType>
|
|
96
96
|
|
97
97
|
const camelFuncName = upperFirst(camel(func.name))
|
98
98
|
const source = `
|
99
|
-
onEntry${camelFuncName}(func: (call: ${moduleName}.${camelFuncName}Payload, ctx: ${this.PREFIX}Context) => void, filter?: CallFilter,
|
99
|
+
onEntry${camelFuncName}(func: (call: ${moduleName}.${camelFuncName}Payload, ctx: ${this.PREFIX}Context) => void, filter?: CallFilter, handlerOptions?: HandlerOptions<MoveFetchConfig, ${moduleName}.${camelFuncName}Payload>): ${moduleName} {
|
100
100
|
this.onEntryFunctionCall(func, {
|
101
101
|
...filter,
|
102
102
|
function: '${module.name}::${func.name}'
|
103
103
|
},
|
104
|
-
|
104
|
+
handlerOptions)
|
105
105
|
return this
|
106
106
|
}`
|
107
107
|
|
@@ -113,8 +113,8 @@ export abstract class SharedNetworkCodegen<NetworkType, ModuleTypes, StructType>
|
|
113
113
|
const source = `
|
114
114
|
onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(struct.name)}Instance, ctx: ${
|
115
115
|
this.PREFIX
|
116
|
-
}Context) => void,
|
117
|
-
this.onMoveEvent(func, {...eventFilter ?? {}, type: '${module.name}::${struct.name}' },
|
116
|
+
}Context) => void, handlerOptions?: HandlerOptions<MoveFetchConfig, ${moduleName}.${normalizeToJSName(struct.name)}Instance>, eventFilter?: Omit<EventFilter, "type"|"account">): ${moduleName} {
|
117
|
+
this.onMoveEvent(func, {...eventFilter ?? {}, type: '${module.name}::${struct.name}' }, handlerOptions)
|
118
118
|
return this
|
119
119
|
}`
|
120
120
|
return source
|
@@ -123,10 +123,10 @@ onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(struct.nam
|
|
123
123
|
generateImports() {
|
124
124
|
return `
|
125
125
|
import { CallFilter, MoveFetchConfig, EventFilter } from "@sentio/sdk/move"
|
126
|
+
import { HandlerOptions } from "@sentio/sdk"
|
126
127
|
import {
|
127
128
|
${this.PREFIX}BindOptions, ${this.PREFIX}BaseProcessor,
|
128
129
|
${this.PREFIX}Network, TypedFunctionPayload,
|
129
|
-
HandlerOptions,
|
130
130
|
${this.PREFIX}Context } from "@sentio/sdk/${this.PREFIX.toLowerCase()}"
|
131
131
|
`
|
132
132
|
}
|
@@ -5,6 +5,7 @@ import { SolanaBindOptions } from './solana-options.js'
|
|
5
5
|
import { ListStateStorage } from '@sentio/runtime'
|
6
6
|
import { Labels } from '../core/index.js'
|
7
7
|
import { SolanaChainId } from '@sentio/chain'
|
8
|
+
import { HandlerOptions } from '../core/handler-options.js'
|
8
9
|
|
9
10
|
type IndexConfigure = {
|
10
11
|
startSlot: bigint
|
@@ -17,12 +18,17 @@ export interface InstructionCoder {
|
|
17
18
|
|
18
19
|
export type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void
|
19
20
|
|
21
|
+
export interface InstructionHandlerEntry {
|
22
|
+
handler: SolanaInstructionHandler
|
23
|
+
handlerOptions?: HandlerOptions<object, Instruction>
|
24
|
+
}
|
25
|
+
|
20
26
|
export class SolanaProcessorState extends ListStateStorage<SolanaBaseProcessor> {
|
21
27
|
static INSTANCE: SolanaProcessorState = new SolanaProcessorState()
|
22
28
|
}
|
23
29
|
|
24
30
|
export class SolanaBaseProcessor {
|
25
|
-
public instructionHandlerMap: Map<string,
|
31
|
+
public instructionHandlerMap: Map<string, InstructionHandlerEntry> = new Map()
|
26
32
|
address: string
|
27
33
|
endpoint: string
|
28
34
|
contractName: string
|
@@ -61,8 +67,12 @@ export class SolanaBaseProcessor {
|
|
61
67
|
SolanaProcessorState.INSTANCE.addValue(this)
|
62
68
|
}
|
63
69
|
|
64
|
-
public onInstruction(
|
65
|
-
|
70
|
+
public onInstruction(
|
71
|
+
instructionName: string,
|
72
|
+
handler: SolanaInstructionHandler,
|
73
|
+
handlerOptions?: HandlerOptions<object, Instruction>
|
74
|
+
) {
|
75
|
+
this.instructionHandlerMap.set(instructionName, { handler, handlerOptions })
|
66
76
|
return this
|
67
77
|
}
|
68
78
|
|
@@ -78,21 +88,33 @@ export class SolanaBaseProcessor {
|
|
78
88
|
return null
|
79
89
|
}
|
80
90
|
|
81
|
-
public getInstructionHandler(parsedInstruction: Instruction):
|
91
|
+
public getInstructionHandler(parsedInstruction: Instruction): InstructionHandlerEntry | undefined {
|
82
92
|
return this.instructionHandlerMap.get(parsedInstruction.name)
|
83
93
|
}
|
84
94
|
|
85
95
|
public async handleInstruction(
|
86
96
|
parsedInstruction: Instruction,
|
87
97
|
accounts: string[],
|
88
|
-
|
98
|
+
handlerEntry: InstructionHandlerEntry,
|
89
99
|
slot: bigint
|
90
100
|
): Promise<ProcessResult> {
|
91
101
|
const ctx = new SolanaContext(this.contractName, this.network, this.address, slot, this.baseLabels)
|
92
|
-
await handler(parsedInstruction, ctx, accounts)
|
102
|
+
await handlerEntry.handler(parsedInstruction, ctx, accounts)
|
93
103
|
return ctx.stopAndGetResult()
|
94
104
|
}
|
95
105
|
|
106
|
+
public async getPartitionKey(
|
107
|
+
parsedInstruction: Instruction,
|
108
|
+
handlerEntry: InstructionHandlerEntry
|
109
|
+
): Promise<string | undefined> {
|
110
|
+
const p = handlerEntry.handlerOptions?.partitionKey
|
111
|
+
if (!p) return undefined
|
112
|
+
if (typeof p === 'function') {
|
113
|
+
return p(parsedInstruction)
|
114
|
+
}
|
115
|
+
return p
|
116
|
+
}
|
117
|
+
|
96
118
|
public startSlot(startSlot: bigint | number) {
|
97
119
|
this.config.startSlot = BigInt(startSlot)
|
98
120
|
return this
|
@@ -7,6 +7,7 @@ import { ListStateStorage, mergeProcessResults } from '@sentio/runtime'
|
|
7
7
|
import { StarknetProcessorConfig } from './types.js'
|
8
8
|
import { StarknetContractView } from './contract.js'
|
9
9
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
10
|
+
import { HandlerOptions } from '../core/handler-options.js'
|
10
11
|
|
11
12
|
export class StarknetProcessor {
|
12
13
|
callHandlers: CallHandler<Data_StarknetEvent>[] = []
|
@@ -42,7 +43,8 @@ export class StarknetProcessor {
|
|
42
43
|
|
43
44
|
public onEvent(
|
44
45
|
event: string | string[],
|
45
|
-
handler: (events: StarknetEvent<ParsedEvent>, ctx: StarknetContext<StarknetContractView>) => void | Promise<void
|
46
|
+
handler: (events: StarknetEvent<ParsedEvent>, ctx: StarknetContext<StarknetContractView>) => void | Promise<void>,
|
47
|
+
handlerOptions?: HandlerOptions<object, StarknetEvent<ParsedEvent>>
|
46
48
|
) {
|
47
49
|
const eventFilter = Array.isArray(event) ? event : [event]
|
48
50
|
if (!this.config.abi) {
|
@@ -86,7 +88,30 @@ export class StarknetProcessor {
|
|
86
88
|
return ProcessResult.fromPartial({})
|
87
89
|
}
|
88
90
|
},
|
89
|
-
eventFilter
|
91
|
+
eventFilter,
|
92
|
+
partitionHandler: async (call: Data_StarknetEvent): Promise<string | undefined> => {
|
93
|
+
const p = handlerOptions?.partitionKey
|
94
|
+
if (!p) return undefined
|
95
|
+
if (typeof p === 'function') {
|
96
|
+
try {
|
97
|
+
const eventData = [call.result] as any[]
|
98
|
+
const abiEvents = events.getAbiEvents(abi)
|
99
|
+
const abiStructs = CallData.getAbiStruct(abi)
|
100
|
+
const abiEnums = CallData.getAbiEnum(abi)
|
101
|
+
const parsedEvents = events.parseEvents(eventData, abiEvents, abiStructs, abiEnums)
|
102
|
+
if (parsedEvents.length > 0) {
|
103
|
+
const { from_address, transaction_hash } = call.result!
|
104
|
+
const e = new StarknetEvent(from_address, transaction_hash, parsedEvents[0])
|
105
|
+
return p(e)
|
106
|
+
}
|
107
|
+
return undefined
|
108
|
+
} catch (e) {
|
109
|
+
console.error(e)
|
110
|
+
return undefined
|
111
|
+
}
|
112
|
+
}
|
113
|
+
return p
|
114
|
+
}
|
90
115
|
}
|
91
116
|
this.callHandlers.push(callHandler)
|
92
117
|
return this
|
@@ -97,6 +122,7 @@ export type CallHandler<T> = {
|
|
97
122
|
handlerName: string
|
98
123
|
handler: (call: T) => Promise<ProcessResult>
|
99
124
|
eventFilter?: string[]
|
125
|
+
partitionHandler?: (call: T) => Promise<string | undefined>
|
100
126
|
}
|
101
127
|
|
102
128
|
function getRpcEndpoint(chainId: StarknetChainId | string) {
|
package/src/sui/builtin/0x1.ts
CHANGED
@@ -36,12 +36,12 @@ import {
|
|
36
36
|
} from "@typemove/sui";
|
37
37
|
|
38
38
|
import { CallFilter, MoveFetchConfig, EventFilter } from "@sentio/sdk/move";
|
39
|
+
import { HandlerOptions } from "@sentio/sdk";
|
39
40
|
import {
|
40
41
|
SuiBindOptions,
|
41
42
|
SuiBaseProcessor,
|
42
43
|
SuiNetwork,
|
43
44
|
TypedFunctionPayload,
|
44
|
-
HandlerOptions,
|
45
45
|
SuiContext,
|
46
46
|
} from "@sentio/sdk/sui";
|
47
47
|
|
@@ -723,13 +723,16 @@ export class bit_vector extends SuiBaseProcessor {
|
|
723
723
|
|
724
724
|
onEventBitVector(
|
725
725
|
func: (event: bit_vector.BitVectorInstance, ctx: SuiContext) => void,
|
726
|
-
|
726
|
+
handlerOptions?: HandlerOptions<
|
727
|
+
MoveFetchConfig,
|
728
|
+
bit_vector.BitVectorInstance
|
729
|
+
>,
|
727
730
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
728
731
|
): bit_vector {
|
729
732
|
this.onMoveEvent(
|
730
733
|
func,
|
731
734
|
{ ...(eventFilter ?? {}), type: "bit_vector::BitVector" },
|
732
|
-
|
735
|
+
handlerOptions,
|
733
736
|
);
|
734
737
|
return this;
|
735
738
|
}
|
@@ -1067,13 +1070,16 @@ export class fixed_point32 extends SuiBaseProcessor {
|
|
1067
1070
|
|
1068
1071
|
onEventFixedPoint32(
|
1069
1072
|
func: (event: fixed_point32.FixedPoint32Instance, ctx: SuiContext) => void,
|
1070
|
-
|
1073
|
+
handlerOptions?: HandlerOptions<
|
1074
|
+
MoveFetchConfig,
|
1075
|
+
fixed_point32.FixedPoint32Instance
|
1076
|
+
>,
|
1071
1077
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
1072
1078
|
): fixed_point32 {
|
1073
1079
|
this.onMoveEvent(
|
1074
1080
|
func,
|
1075
1081
|
{ ...(eventFilter ?? {}), type: "fixed_point32::FixedPoint32" },
|
1076
|
-
|
1082
|
+
handlerOptions,
|
1077
1083
|
);
|
1078
1084
|
return this;
|
1079
1085
|
}
|
@@ -2004,13 +2010,13 @@ export class string$ extends SuiBaseProcessor {
|
|
2004
2010
|
|
2005
2011
|
onEventString(
|
2006
2012
|
func: (event: string$.StringInstance, ctx: SuiContext) => void,
|
2007
|
-
|
2013
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, string$.StringInstance>,
|
2008
2014
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
2009
2015
|
): string$ {
|
2010
2016
|
this.onMoveEvent(
|
2011
2017
|
func,
|
2012
2018
|
{ ...(eventFilter ?? {}), type: "string::String" },
|
2013
|
-
|
2019
|
+
handlerOptions,
|
2014
2020
|
);
|
2015
2021
|
return this;
|
2016
2022
|
}
|
@@ -2510,13 +2516,16 @@ export class type_name extends SuiBaseProcessor {
|
|
2510
2516
|
|
2511
2517
|
onEventTypeName(
|
2512
2518
|
func: (event: type_name.TypeNameInstance, ctx: SuiContext) => void,
|
2513
|
-
|
2519
|
+
handlerOptions?: HandlerOptions<
|
2520
|
+
MoveFetchConfig,
|
2521
|
+
type_name.TypeNameInstance
|
2522
|
+
>,
|
2514
2523
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
2515
2524
|
): type_name {
|
2516
2525
|
this.onMoveEvent(
|
2517
2526
|
func,
|
2518
2527
|
{ ...(eventFilter ?? {}), type: "type_name::TypeName" },
|
2519
|
-
|
2528
|
+
handlerOptions,
|
2520
2529
|
);
|
2521
2530
|
return this;
|
2522
2531
|
}
|
@@ -4579,13 +4588,13 @@ export class uq32_32 extends SuiBaseProcessor {
|
|
4579
4588
|
|
4580
4589
|
onEventUQ32_32(
|
4581
4590
|
func: (event: uq32_32.UQ32_32Instance, ctx: SuiContext) => void,
|
4582
|
-
|
4591
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, uq32_32.UQ32_32Instance>,
|
4583
4592
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
4584
4593
|
): uq32_32 {
|
4585
4594
|
this.onMoveEvent(
|
4586
4595
|
func,
|
4587
4596
|
{ ...(eventFilter ?? {}), type: "uq32_32::UQ32_32" },
|
4588
|
-
|
4597
|
+
handlerOptions,
|
4589
4598
|
);
|
4590
4599
|
return this;
|
4591
4600
|
}
|
@@ -5093,13 +5102,13 @@ export class uq64_64 extends SuiBaseProcessor {
|
|
5093
5102
|
|
5094
5103
|
onEventUQ64_64(
|
5095
5104
|
func: (event: uq64_64.UQ64_64Instance, ctx: SuiContext) => void,
|
5096
|
-
|
5105
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, uq64_64.UQ64_64Instance>,
|
5097
5106
|
eventFilter?: Omit<EventFilter, "type" | "account">,
|
5098
5107
|
): uq64_64 {
|
5099
5108
|
this.onMoveEvent(
|
5100
5109
|
func,
|
5101
5110
|
{ ...(eventFilter ?? {}), type: "uq64_64::UQ64_64" },
|
5102
|
-
|
5111
|
+
handlerOptions,
|
5103
5112
|
);
|
5104
5113
|
return this;
|
5105
5114
|
}
|