@sentio/sdk 2.59.0-rc.23 → 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 +19 -19
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +95 -44
- 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 +333 -332
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +664 -664
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +66 -65
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +130 -130
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +29 -28
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +56 -56
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +27 -0
- 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/index.d.ts +1 -0
- package/lib/aptos/index.d.ts.map +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +1 -0
- 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.d.ts.map +1 -1
- package/lib/move/shared-network-codegen.js +5 -4
- 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 -0
- 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 +104 -60
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1565 -664
- package/src/aptos/builtin/0x3.ts +302 -130
- package/src/aptos/builtin/0x4.ts +123 -56
- package/src/aptos/codegen/codegen.ts +34 -1
- package/src/aptos/data.ts +78 -3
- package/src/aptos/index.ts +2 -0
- package/src/aptos/models.ts +2 -0
- 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 -4
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +28 -2
- package/src/sui/builtin/0x1.ts +22 -12
- package/src/sui/builtin/0x2.ts +220 -120
- package/src/sui/builtin/0x3.ts +241 -96
- package/src/sui/models.ts +2 -0
- package/src/sui/sui-plugin.ts +68 -22
- package/src/sui/sui-processor.ts +48 -11
package/src/sui/models.ts
CHANGED
package/src/sui/sui-plugin.ts
CHANGED
@@ -13,10 +13,12 @@ import {
|
|
13
13
|
MoveResourceChangeConfig,
|
14
14
|
ProcessConfigResponse,
|
15
15
|
ProcessResult,
|
16
|
+
ProcessStreamResponse_Partitions,
|
16
17
|
StartRequest
|
17
18
|
} from '@sentio/protos'
|
18
19
|
|
19
20
|
import { ServerError, Status } from 'nice-grpc'
|
21
|
+
import { PartitionHandlerManager } from '../core/index.js'
|
20
22
|
|
21
23
|
import { SuiProcessorState } from './sui-processor.js'
|
22
24
|
import { SuiAccountProcessorState, SuiAddressProcessor } from './sui-object-processor.js'
|
@@ -44,6 +46,8 @@ export class SuiPlugin extends Plugin {
|
|
44
46
|
suiObjectHandlers: [],
|
45
47
|
suiObjectChangeHandlers: []
|
46
48
|
}
|
49
|
+
|
50
|
+
partitionManager = new PartitionHandlerManager()
|
47
51
|
async start(request: StartRequest): Promise<void> {
|
48
52
|
await initCoinList()
|
49
53
|
|
@@ -94,6 +98,7 @@ export class SuiPlugin extends Plugin {
|
|
94
98
|
})
|
95
99
|
for (const handler of suiProcessor.eventHandlers) {
|
96
100
|
const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1
|
101
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler)
|
97
102
|
const eventHandlerConfig: MoveEventHandlerConfig = {
|
98
103
|
filters: handler.filters.map((f) => {
|
99
104
|
return {
|
@@ -110,6 +115,7 @@ export class SuiPlugin extends Plugin {
|
|
110
115
|
}
|
111
116
|
for (const handler of suiProcessor.callHandlers) {
|
112
117
|
const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1
|
118
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler)
|
113
119
|
const functionHandlerConfig: MoveCallHandlerConfig = {
|
114
120
|
filters: handler.filters.map((filter) => {
|
115
121
|
return {
|
@@ -207,6 +213,68 @@ export class SuiPlugin extends Plugin {
|
|
207
213
|
this.handlers = handlers
|
208
214
|
}
|
209
215
|
|
216
|
+
supportedHandlers = [
|
217
|
+
HandlerType.SUI_EVENT,
|
218
|
+
HandlerType.SUI_CALL,
|
219
|
+
HandlerType.SUI_OBJECT,
|
220
|
+
HandlerType.SUI_OBJECT_CHANGE
|
221
|
+
]
|
222
|
+
|
223
|
+
processBinding(request: DataBinding): Promise<ProcessResult> {
|
224
|
+
switch (request.handlerType) {
|
225
|
+
case HandlerType.SUI_EVENT:
|
226
|
+
return this.processSuiEvent(request)
|
227
|
+
case HandlerType.SUI_CALL:
|
228
|
+
return this.processSuiFunctionCall(request)
|
229
|
+
case HandlerType.SUI_OBJECT:
|
230
|
+
return this.processSuiObject(request)
|
231
|
+
case HandlerType.SUI_OBJECT_CHANGE:
|
232
|
+
return this.processSuiObjectChange(request)
|
233
|
+
default:
|
234
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
239
|
+
let data: any
|
240
|
+
switch (request.handlerType) {
|
241
|
+
case HandlerType.SUI_EVENT:
|
242
|
+
if (!request.data?.suiEvent) {
|
243
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "suiEvent can't be empty")
|
244
|
+
}
|
245
|
+
data = request.data.suiEvent
|
246
|
+
break
|
247
|
+
case HandlerType.SUI_CALL:
|
248
|
+
if (!request.data?.suiCall) {
|
249
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "suiCall can't be empty")
|
250
|
+
}
|
251
|
+
data = request.data.suiCall
|
252
|
+
break
|
253
|
+
case HandlerType.SUI_OBJECT:
|
254
|
+
if (!request.data?.suiObject) {
|
255
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "suiObject can't be empty")
|
256
|
+
}
|
257
|
+
data = request.data.suiObject
|
258
|
+
break
|
259
|
+
case HandlerType.SUI_OBJECT_CHANGE:
|
260
|
+
if (!request.data?.suiObjectChange) {
|
261
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "suiObjectChange can't be empty")
|
262
|
+
}
|
263
|
+
data = request.data.suiObjectChange
|
264
|
+
break
|
265
|
+
default:
|
266
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
267
|
+
}
|
268
|
+
const partitions = await this.partitionManager.processPartitionForHandlerType(
|
269
|
+
request.handlerType,
|
270
|
+
request.handlerIds,
|
271
|
+
data
|
272
|
+
)
|
273
|
+
return {
|
274
|
+
partitions
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
210
278
|
async processSuiEvent(binding: DataBinding): Promise<ProcessResult> {
|
211
279
|
if (!binding.data?.suiEvent) {
|
212
280
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
@@ -282,28 +350,6 @@ export class SuiPlugin extends Plugin {
|
|
282
350
|
}
|
283
351
|
return mergeProcessResults(await Promise.all(promises))
|
284
352
|
}
|
285
|
-
|
286
|
-
supportedHandlers = [
|
287
|
-
HandlerType.SUI_EVENT,
|
288
|
-
HandlerType.SUI_CALL,
|
289
|
-
HandlerType.SUI_OBJECT,
|
290
|
-
HandlerType.SUI_OBJECT_CHANGE
|
291
|
-
]
|
292
|
-
|
293
|
-
processBinding(request: DataBinding): Promise<ProcessResult> {
|
294
|
-
switch (request.handlerType) {
|
295
|
-
case HandlerType.SUI_EVENT:
|
296
|
-
return this.processSuiEvent(request)
|
297
|
-
case HandlerType.SUI_CALL:
|
298
|
-
return this.processSuiFunctionCall(request)
|
299
|
-
case HandlerType.SUI_OBJECT:
|
300
|
-
return this.processSuiObject(request)
|
301
|
-
case HandlerType.SUI_OBJECT_CHANGE:
|
302
|
-
return this.processSuiObjectChange(request)
|
303
|
-
default:
|
304
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
305
|
-
}
|
306
|
-
}
|
307
353
|
}
|
308
354
|
|
309
355
|
PluginManager.INSTANCE.register(new SuiPlugin())
|
package/src/sui/sui-processor.ts
CHANGED
@@ -19,6 +19,7 @@ import { defaultMoveCoder, MoveCoder } from './index.js'
|
|
19
19
|
import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
|
20
20
|
import { Required } from 'utility-types'
|
21
21
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
22
|
+
import { HandlerOptions } from './models.js'
|
22
23
|
|
23
24
|
export const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
|
24
25
|
resourceChanges: false,
|
@@ -76,10 +77,10 @@ export class SuiBaseProcessor {
|
|
76
77
|
protected onMoveEvent(
|
77
78
|
handler: (event: SuiEvent, ctx: SuiContext) => PromiseOrVoid,
|
78
79
|
filter: EventFilter | EventFilter[],
|
79
|
-
|
80
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
|
80
81
|
): SuiBaseProcessor {
|
81
82
|
let _filters: EventFilter[] = []
|
82
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
83
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
83
84
|
|
84
85
|
if (Array.isArray(filter)) {
|
85
86
|
_filters = filter
|
@@ -123,7 +124,17 @@ export class SuiBaseProcessor {
|
|
123
124
|
return ctx.stopAndGetResult()
|
124
125
|
},
|
125
126
|
filters: _filters,
|
126
|
-
fetchConfig: _fetchConfig
|
127
|
+
fetchConfig: _fetchConfig,
|
128
|
+
partitionHandler: async (data: Data_SuiEvent): Promise<string | undefined> => {
|
129
|
+
const p = handlerOptions?.partitionKey
|
130
|
+
if (!p) return undefined
|
131
|
+
if (typeof p === 'function') {
|
132
|
+
const evt = JSON.parse(data.rawEvent) as SuiEvent
|
133
|
+
const decoded = await processor.coder.decodeEvent<any>(evt)
|
134
|
+
return p(decoded || evt)
|
135
|
+
}
|
136
|
+
return p
|
137
|
+
}
|
127
138
|
})
|
128
139
|
return this
|
129
140
|
}
|
@@ -131,10 +142,10 @@ export class SuiBaseProcessor {
|
|
131
142
|
protected onEntryFunctionCall(
|
132
143
|
handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => PromiseOrVoid,
|
133
144
|
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
|
134
|
-
|
145
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, MoveCallSuiTransaction>
|
135
146
|
): SuiBaseProcessor {
|
136
147
|
let _filters: FunctionNameAndCallFilter[] = []
|
137
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
148
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
138
149
|
|
139
150
|
if (Array.isArray(filter)) {
|
140
151
|
_filters = filter
|
@@ -188,22 +199,39 @@ export class SuiBaseProcessor {
|
|
188
199
|
return ctx.stopAndGetResult()
|
189
200
|
},
|
190
201
|
filters: _filters,
|
191
|
-
fetchConfig: _fetchConfig
|
202
|
+
fetchConfig: _fetchConfig,
|
203
|
+
partitionHandler: async (data: Data_SuiCall): Promise<string | undefined> => {
|
204
|
+
const p = handlerOptions?.partitionKey
|
205
|
+
if (!p) return undefined
|
206
|
+
if (typeof p === 'function') {
|
207
|
+
const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
208
|
+
const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)
|
209
|
+
// For simplicity, use the first call for partitioning
|
210
|
+
if (calls.length > 0) {
|
211
|
+
return p(calls[0])
|
212
|
+
}
|
213
|
+
return undefined
|
214
|
+
}
|
215
|
+
return p
|
216
|
+
}
|
192
217
|
})
|
193
218
|
return this
|
194
219
|
}
|
195
220
|
|
196
|
-
onEvent(
|
197
|
-
|
221
|
+
onEvent(
|
222
|
+
handler: (event: SuiEvent, ctx: SuiContext) => void,
|
223
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
|
224
|
+
): this {
|
225
|
+
this.onMoveEvent(handler, { type: '' }, handlerOptions)
|
198
226
|
return this
|
199
227
|
}
|
200
228
|
|
201
229
|
onTransactionBlock(
|
202
230
|
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
|
203
231
|
filter?: TransactionFilter,
|
204
|
-
|
232
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiTransactionBlockResponse>
|
205
233
|
): this {
|
206
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
234
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
207
235
|
|
208
236
|
const processor = this
|
209
237
|
|
@@ -231,7 +259,16 @@ export class SuiBaseProcessor {
|
|
231
259
|
return ctx.stopAndGetResult()
|
232
260
|
},
|
233
261
|
filters: [{ ...filter, function: '' }],
|
234
|
-
fetchConfig: _fetchConfig
|
262
|
+
fetchConfig: _fetchConfig,
|
263
|
+
partitionHandler: async (data: Data_SuiCall): Promise<string | undefined> => {
|
264
|
+
const p = handlerOptions?.partitionKey
|
265
|
+
if (!p) return undefined
|
266
|
+
if (typeof p === 'function') {
|
267
|
+
const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
268
|
+
return p(tx)
|
269
|
+
}
|
270
|
+
return p
|
271
|
+
}
|
235
272
|
})
|
236
273
|
return this
|
237
274
|
}
|