@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.
- package/lib/aptos/api.d.ts +1 -0
- package/lib/aptos/api.d.ts.map +1 -1
- package/lib/aptos/api.js +13 -1
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-plugin.d.ts +8 -4
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +51 -8
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +21 -19
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +102 -50
- 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 +31 -4
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +45 -0
- package/lib/aptos/data.d.ts.map +1 -0
- package/lib/aptos/data.js +99 -0
- package/lib/aptos/data.js.map +1 -0
- 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/aptos/move-coder.d.ts +8 -2
- package/lib/aptos/move-coder.d.ts.map +1 -1
- package/lib/aptos/move-coder.js +84 -1
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/network.d.ts +1 -0
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +1 -0
- package/lib/aptos/network.js.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/base-context.d.ts +4 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +10 -5
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/event-logger.d.ts +5 -0
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +36 -1
- package/lib/core/event-logger.js.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 +3 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +3 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/meter.d.ts +45 -2
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +124 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +2 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -1
- package/lib/core/numberish.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 +23 -17
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +173 -34
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +6 -0
- package/lib/eth/bind-options.d.ts.map +1 -1
- package/lib/eth/bind-options.js +2 -0
- package/lib/eth/bind-options.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 +5 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +53 -5
- 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 +91 -28
- 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 +5 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +5 -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 +32 -14
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/store/codegen.d.ts.map +1 -1
- package/lib/store/codegen.js +36 -2
- package/lib/store/codegen.js.map +1 -1
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +3 -1
- package/lib/store/schema.js.map +1 -1
- package/lib/store/store.d.ts +4 -3
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +41 -1
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.d.ts +20 -1
- package/lib/store/types.d.ts.map +1 -1
- package/lib/store/types.js +22 -0
- package/lib/store/types.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-object-processor-template.js +1 -1
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +2 -0
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +4 -0
- package/lib/sui/sui-object-processor.js.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 +68 -24
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +6 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +48 -11
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +2 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/utils/block.d.ts +2 -0
- package/lib/utils/block.d.ts.map +1 -1
- package/lib/utils/block.js +13 -0
- package/lib/utils/block.js.map +1 -1
- package/package.json +8 -7
- package/src/aptos/api.ts +13 -1
- package/src/aptos/aptos-plugin.ts +62 -13
- package/src/aptos/aptos-processor.ts +114 -74
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1566 -664
- package/src/aptos/builtin/0x3.ts +303 -130
- package/src/aptos/builtin/0x4.ts +124 -56
- package/src/aptos/codegen/codegen.ts +40 -5
- package/src/aptos/data.ts +123 -0
- package/src/aptos/index.ts +2 -0
- package/src/aptos/models.ts +2 -0
- package/src/aptos/move-coder.ts +96 -3
- package/src/aptos/network.ts +1 -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/base-context.ts +10 -5
- package/src/core/event-logger.ts +45 -1
- package/src/core/handler-options.ts +40 -0
- package/src/core/index.ts +17 -1
- package/src/core/meter.ts +159 -4
- package/src/core/numberish.ts +34 -1
- 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 +163 -41
- package/src/eth/bind-options.ts +7 -0
- 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 +76 -10
- 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 +90 -22
- package/src/fuel/types.ts +3 -0
- package/src/move/filter.ts +5 -0
- package/src/move/shared-network-codegen.ts +5 -4
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +31 -13
- package/src/store/codegen.ts +50 -2
- package/src/store/schema.ts +3 -1
- package/src/store/store.ts +57 -4
- package/src/store/types.ts +30 -1
- 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-object-processor-template.ts +1 -1
- package/src/sui/sui-object-processor.ts +6 -0
- package/src/sui/sui-plugin.ts +77 -26
- package/src/sui/sui-processor.ts +50 -11
- package/src/testing/eth-facet.ts +2 -1
- package/src/utils/block.ts +15 -0
package/src/sui/models.ts
CHANGED
@@ -94,7 +94,7 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
|
|
94
94
|
abi: ''
|
95
95
|
},
|
96
96
|
startBlock: config.startCheckpoint,
|
97
|
-
endBlock: 0n,
|
97
|
+
endBlock: config.endCheckpoint || 0n,
|
98
98
|
baseLabels: config.baseLabels
|
99
99
|
})
|
100
100
|
console.log(`successfully bind template ${sig}`)
|
@@ -24,6 +24,7 @@ export interface SuiObjectBindOptions {
|
|
24
24
|
objectId: string
|
25
25
|
network?: SuiNetwork
|
26
26
|
startCheckpoint?: bigint
|
27
|
+
endCheckpoint?: bigint
|
27
28
|
baseLabels?: { [key: string]: string }
|
28
29
|
}
|
29
30
|
|
@@ -31,6 +32,7 @@ export interface SuiObjectTypeBindOptions<T> {
|
|
31
32
|
objectType: TypeDescriptor<T>
|
32
33
|
network?: SuiNetwork
|
33
34
|
startCheckpoint?: bigint
|
35
|
+
endCheckpoint?: bigint
|
34
36
|
baseLabels?: { [key: string]: string }
|
35
37
|
}
|
36
38
|
|
@@ -71,6 +73,7 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
|
|
71
73
|
if (options.ownerType === MoveOwnerType.TYPE) {
|
72
74
|
this.config = {
|
73
75
|
startCheckpoint: options.startCheckpoint || 0n,
|
76
|
+
endCheckpoint: options.endCheckpoint,
|
74
77
|
address: options.address === '*' ? '*' : accountTypeString(options.address),
|
75
78
|
network: options.network || SuiNetwork.MAIN_NET,
|
76
79
|
baseLabels: options.baseLabels
|
@@ -234,6 +237,7 @@ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
|
|
234
237
|
address: options.objectId,
|
235
238
|
network: options.network,
|
236
239
|
startCheckpoint: options.startCheckpoint,
|
240
|
+
endCheckpoint: options.endCheckpoint,
|
237
241
|
ownerType: MoveOwnerType.OBJECT,
|
238
242
|
baseLabels: options.baseLabels
|
239
243
|
})
|
@@ -266,6 +270,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
|
|
266
270
|
address: ALL_ADDRESS, // current only support on all address
|
267
271
|
network: options.network,
|
268
272
|
startCheckpoint: options.startCheckpoint,
|
273
|
+
endCheckpoint: options.endCheckpoint,
|
269
274
|
ownerType: MoveOwnerType.TYPE,
|
270
275
|
baseLabels: options.baseLabels
|
271
276
|
})
|
@@ -365,6 +370,7 @@ export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessorIn
|
|
365
370
|
address: options.objectId,
|
366
371
|
network: options.network,
|
367
372
|
startCheckpoint: options.startCheckpoint,
|
373
|
+
endCheckpoint: options.endCheckpoint,
|
368
374
|
ownerType: MoveOwnerType.WRAPPED_OBJECT,
|
369
375
|
baseLabels: options.baseLabels
|
370
376
|
})
|
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
|
|
@@ -64,6 +68,7 @@ export class SuiPlugin extends Plugin {
|
|
64
68
|
objectId: instance.contract?.address || '',
|
65
69
|
network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,
|
66
70
|
startCheckpoint: instance.startBlock || 0n,
|
71
|
+
endCheckpoint: instance.endBlock || 0n,
|
67
72
|
baseLabels: instance.baseLabels
|
68
73
|
},
|
69
74
|
NoopContext
|
@@ -88,10 +93,12 @@ export class SuiPlugin extends Plugin {
|
|
88
93
|
address: suiProcessor.config.address,
|
89
94
|
abi: ''
|
90
95
|
},
|
91
|
-
startBlock: suiProcessor.config.startCheckpoint
|
96
|
+
startBlock: suiProcessor.config.startCheckpoint,
|
97
|
+
endBlock: suiProcessor.config.endCheckpoint
|
92
98
|
})
|
93
99
|
for (const handler of suiProcessor.eventHandlers) {
|
94
100
|
const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1
|
101
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler)
|
95
102
|
const eventHandlerConfig: MoveEventHandlerConfig = {
|
96
103
|
filters: handler.filters.map((f) => {
|
97
104
|
return {
|
@@ -108,6 +115,7 @@ export class SuiPlugin extends Plugin {
|
|
108
115
|
}
|
109
116
|
for (const handler of suiProcessor.callHandlers) {
|
110
117
|
const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1
|
118
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler)
|
111
119
|
const functionHandlerConfig: MoveCallHandlerConfig = {
|
112
120
|
filters: handler.filters.map((filter) => {
|
113
121
|
return {
|
@@ -131,7 +139,8 @@ export class SuiPlugin extends Plugin {
|
|
131
139
|
const objectChangeHandler: MoveResourceChangeConfig = {
|
132
140
|
type: handler.type,
|
133
141
|
handlerId,
|
134
|
-
handlerName: handler.handlerName
|
142
|
+
handlerName: handler.handlerName,
|
143
|
+
includeDeleted: false
|
135
144
|
}
|
136
145
|
contractConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
137
146
|
}
|
@@ -142,7 +151,8 @@ export class SuiPlugin extends Plugin {
|
|
142
151
|
const accountConfig = AccountConfig.fromPartial({
|
143
152
|
address: processor.config.address,
|
144
153
|
chainId: processor.getChainId(),
|
145
|
-
startBlock: processor.config.startCheckpoint // TODO maybe use another field
|
154
|
+
startBlock: processor.config.startCheckpoint, // TODO maybe use another field
|
155
|
+
endBlock: processor.config.endCheckpoint
|
146
156
|
})
|
147
157
|
|
148
158
|
for (const handler of processor.objectChangeHandlers) {
|
@@ -150,7 +160,8 @@ export class SuiPlugin extends Plugin {
|
|
150
160
|
const objectChangeHandler: MoveResourceChangeConfig = {
|
151
161
|
type: handler.type,
|
152
162
|
handlerId,
|
153
|
-
handlerName: handler.handlerName
|
163
|
+
handlerName: handler.handlerName,
|
164
|
+
includeDeleted: false
|
154
165
|
}
|
155
166
|
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
156
167
|
}
|
@@ -202,6 +213,68 @@ export class SuiPlugin extends Plugin {
|
|
202
213
|
this.handlers = handlers
|
203
214
|
}
|
204
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
|
+
|
205
278
|
async processSuiEvent(binding: DataBinding): Promise<ProcessResult> {
|
206
279
|
if (!binding.data?.suiEvent) {
|
207
280
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
@@ -277,28 +350,6 @@ export class SuiPlugin extends Plugin {
|
|
277
350
|
}
|
278
351
|
return mergeProcessResults(await Promise.all(promises))
|
279
352
|
}
|
280
|
-
|
281
|
-
supportedHandlers = [
|
282
|
-
HandlerType.SUI_EVENT,
|
283
|
-
HandlerType.SUI_CALL,
|
284
|
-
HandlerType.SUI_OBJECT,
|
285
|
-
HandlerType.SUI_OBJECT_CHANGE
|
286
|
-
]
|
287
|
-
|
288
|
-
processBinding(request: DataBinding): Promise<ProcessResult> {
|
289
|
-
switch (request.handlerType) {
|
290
|
-
case HandlerType.SUI_EVENT:
|
291
|
-
return this.processSuiEvent(request)
|
292
|
-
case HandlerType.SUI_CALL:
|
293
|
-
return this.processSuiFunctionCall(request)
|
294
|
-
case HandlerType.SUI_OBJECT:
|
295
|
-
return this.processSuiObject(request)
|
296
|
-
case HandlerType.SUI_OBJECT_CHANGE:
|
297
|
-
return this.processSuiObjectChange(request)
|
298
|
-
default:
|
299
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
300
|
-
}
|
301
|
-
}
|
302
353
|
}
|
303
354
|
|
304
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,
|
@@ -31,6 +32,7 @@ export type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'netwo
|
|
31
32
|
export function configure(options: SuiBindOptions): IndexConfigure {
|
32
33
|
return {
|
33
34
|
startCheckpoint: options.startCheckpoint || 0n,
|
35
|
+
endCheckpoint: options.endCheckpoint,
|
34
36
|
address: options.address === ALL_ADDRESS ? ALL_ADDRESS : accountAddressString(options.address),
|
35
37
|
network: options.network || SuiNetwork.MAIN_NET,
|
36
38
|
baseLabels: options.baseLabels
|
@@ -41,6 +43,7 @@ export interface SuiBindOptions {
|
|
41
43
|
address: string
|
42
44
|
network?: SuiNetwork
|
43
45
|
startCheckpoint?: bigint
|
46
|
+
endCheckpoint?: bigint
|
44
47
|
baseLabels?: Labels
|
45
48
|
}
|
46
49
|
|
@@ -74,10 +77,10 @@ export class SuiBaseProcessor {
|
|
74
77
|
protected onMoveEvent(
|
75
78
|
handler: (event: SuiEvent, ctx: SuiContext) => PromiseOrVoid,
|
76
79
|
filter: EventFilter | EventFilter[],
|
77
|
-
|
80
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
|
78
81
|
): SuiBaseProcessor {
|
79
82
|
let _filters: EventFilter[] = []
|
80
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
83
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
81
84
|
|
82
85
|
if (Array.isArray(filter)) {
|
83
86
|
_filters = filter
|
@@ -121,7 +124,17 @@ export class SuiBaseProcessor {
|
|
121
124
|
return ctx.stopAndGetResult()
|
122
125
|
},
|
123
126
|
filters: _filters,
|
124
|
-
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
|
+
}
|
125
138
|
})
|
126
139
|
return this
|
127
140
|
}
|
@@ -129,10 +142,10 @@ export class SuiBaseProcessor {
|
|
129
142
|
protected onEntryFunctionCall(
|
130
143
|
handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => PromiseOrVoid,
|
131
144
|
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
|
132
|
-
|
145
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, MoveCallSuiTransaction>
|
133
146
|
): SuiBaseProcessor {
|
134
147
|
let _filters: FunctionNameAndCallFilter[] = []
|
135
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
148
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
136
149
|
|
137
150
|
if (Array.isArray(filter)) {
|
138
151
|
_filters = filter
|
@@ -186,22 +199,39 @@ export class SuiBaseProcessor {
|
|
186
199
|
return ctx.stopAndGetResult()
|
187
200
|
},
|
188
201
|
filters: _filters,
|
189
|
-
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
|
+
}
|
190
217
|
})
|
191
218
|
return this
|
192
219
|
}
|
193
220
|
|
194
|
-
onEvent(
|
195
|
-
|
221
|
+
onEvent(
|
222
|
+
handler: (event: SuiEvent, ctx: SuiContext) => void,
|
223
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiEvent>
|
224
|
+
): this {
|
225
|
+
this.onMoveEvent(handler, { type: '' }, handlerOptions)
|
196
226
|
return this
|
197
227
|
}
|
198
228
|
|
199
229
|
onTransactionBlock(
|
200
230
|
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
|
201
231
|
filter?: TransactionFilter,
|
202
|
-
|
232
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, SuiTransactionBlockResponse>
|
203
233
|
): this {
|
204
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
234
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
205
235
|
|
206
236
|
const processor = this
|
207
237
|
|
@@ -229,7 +259,16 @@ export class SuiBaseProcessor {
|
|
229
259
|
return ctx.stopAndGetResult()
|
230
260
|
},
|
231
261
|
filters: [{ ...filter, function: '' }],
|
232
|
-
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
|
+
}
|
233
272
|
})
|
234
273
|
return this
|
235
274
|
}
|
package/src/testing/eth-facet.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { TestProcessorServer } from './test-processor-server.js'
|
2
|
-
import {
|
2
|
+
import { HandlerType, ProcessBindingResponse } from '@sentio/protos'
|
3
|
+
import { DataBinding } from '@sentio/runtime'
|
3
4
|
import { Trace } from '../eth/eth.js'
|
4
5
|
import { BlockParams, LogParams, TransactionResponseParams } from 'ethers/providers'
|
5
6
|
import { ChainId, EthChainId } from '@sentio/chain'
|
package/src/utils/block.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { TimeOrBlock } from 'eth/bind-options.js'
|
1
2
|
import { Block, JsonRpcProvider, EthersError } from 'ethers'
|
2
3
|
|
3
4
|
async function getBlockSafely(provider: JsonRpcProvider, blockNumber: number | string): Promise<Block> {
|
@@ -81,3 +82,17 @@ export async function estimateBlockNumberAtDateSlow(
|
|
81
82
|
const closestBlock = await getBlockSafely(provider, high)
|
82
83
|
return closestBlock.number
|
83
84
|
}
|
85
|
+
|
86
|
+
export async function timeOrBlockToBlockNumber(provider: JsonRpcProvider, timeOrBlock: TimeOrBlock): Promise<bigint> {
|
87
|
+
if (timeOrBlock.block) {
|
88
|
+
return BigInt(timeOrBlock.block)
|
89
|
+
}
|
90
|
+
if (!timeOrBlock.time) {
|
91
|
+
return 0n
|
92
|
+
}
|
93
|
+
const block = await estimateBlockNumberAtDate(provider, timeOrBlock.time)
|
94
|
+
if (!block) {
|
95
|
+
throw new Error('Block not found')
|
96
|
+
}
|
97
|
+
return BigInt(block)
|
98
|
+
}
|