@sentio/sdk 2.59.5-rc.1 → 2.60.0-rc.10
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 +5 -11
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +38 -23
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +1 -0
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +11 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +211 -0
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +328 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.js +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/btc/btc-plugin.d.ts +5 -8
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +22 -14
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/core/core-plugin.d.ts +3 -1
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +13 -0
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/handler-options.d.ts +6 -0
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-options.js.map +1 -1
- package/lib/core/handler-register.d.ts +18 -0
- package/lib/core/handler-register.d.ts.map +1 -0
- package/lib/core/handler-register.js +62 -0
- package/lib/core/handler-register.js.map +1 -0
- package/lib/cosmos/cosmos-plugin.d.ts +5 -7
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +18 -10
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +26 -0
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +5 -40
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +86 -120
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +30 -24
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +5 -9
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +26 -18
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/iota/builtin/0x1.d.ts +817 -0
- package/lib/iota/builtin/0x1.d.ts.map +1 -0
- package/lib/iota/builtin/0x1.js +4385 -0
- package/lib/iota/builtin/0x1.js.map +1 -0
- package/lib/iota/builtin/0x2.d.ts +4529 -0
- package/lib/iota/builtin/0x2.d.ts.map +1 -0
- package/lib/iota/builtin/0x2.js +17109 -0
- package/lib/iota/builtin/0x2.js.map +1 -0
- package/lib/iota/builtin/0x3.d.ts +2293 -0
- package/lib/iota/builtin/0x3.d.ts.map +1 -0
- package/lib/iota/builtin/0x3.js +6522 -0
- package/lib/iota/builtin/0x3.js.map +1 -0
- package/lib/iota/builtin/index.d.ts +4 -0
- package/lib/iota/builtin/index.d.ts.map +1 -0
- package/lib/iota/builtin/index.js +7 -0
- package/lib/iota/builtin/index.js.map +1 -0
- package/lib/iota/codegen/codegen.d.ts +2 -0
- package/lib/iota/codegen/codegen.d.ts.map +1 -0
- package/lib/iota/codegen/codegen.js +94 -0
- package/lib/iota/codegen/codegen.js.map +1 -0
- package/lib/iota/codegen/index.d.ts +2 -0
- package/lib/iota/codegen/index.d.ts.map +1 -0
- package/lib/iota/codegen/index.js +2 -0
- package/lib/iota/codegen/index.js.map +1 -0
- package/lib/iota/codegen/run.d.ts +2 -0
- package/lib/iota/codegen/run.d.ts.map +1 -0
- package/lib/iota/codegen/run.js +12 -0
- package/lib/iota/codegen/run.js.map +1 -0
- package/lib/iota/context.d.ts +50 -0
- package/lib/iota/context.d.ts.map +1 -0
- package/lib/iota/context.js +134 -0
- package/lib/iota/context.js.map +1 -0
- package/lib/iota/ext/coin.d.ts +17 -0
- package/lib/iota/ext/coin.d.ts.map +1 -0
- package/lib/iota/ext/coin.js +532 -0
- package/lib/iota/ext/coin.js.map +1 -0
- package/lib/iota/ext/index.d.ts +3 -0
- package/lib/iota/ext/index.d.ts.map +1 -0
- package/lib/iota/ext/index.js +3 -0
- package/lib/iota/ext/index.js.map +1 -0
- package/lib/iota/ext/move-dex.d.ts +19 -0
- package/lib/iota/ext/move-dex.d.ts.map +1 -0
- package/lib/iota/ext/move-dex.js +24 -0
- package/lib/iota/ext/move-dex.js.map +1 -0
- package/lib/iota/index.d.ts +11 -0
- package/lib/iota/index.d.ts.map +1 -0
- package/lib/iota/index.js +12 -0
- package/lib/iota/index.js.map +1 -0
- package/lib/iota/iota-object-processor-template.d.ts +44 -0
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -0
- package/lib/iota/iota-object-processor-template.js +171 -0
- package/lib/iota/iota-object-processor-template.js.map +1 -0
- package/lib/iota/iota-object-processor.d.ts +83 -0
- package/lib/iota/iota-object-processor.d.ts.map +1 -0
- package/lib/iota/iota-object-processor.js +193 -0
- package/lib/iota/iota-object-processor.js.map +1 -0
- package/lib/iota/iota-plugin-part.d.ts +12 -0
- package/lib/iota/iota-plugin-part.d.ts.map +1 -0
- package/lib/iota/iota-plugin-part.js +178 -0
- package/lib/iota/iota-plugin-part.js.map +1 -0
- package/lib/iota/iota-plugin.d.ts +3 -0
- package/lib/iota/iota-plugin.d.ts.map +1 -0
- package/lib/iota/iota-plugin.js +4 -0
- package/lib/iota/iota-plugin.js.map +1 -0
- package/lib/iota/iota-processor.d.ts +47 -0
- package/lib/iota/iota-processor.d.ts.map +1 -0
- package/lib/iota/iota-processor.js +223 -0
- package/lib/iota/iota-processor.js.map +1 -0
- package/lib/iota/models.d.ts +12 -0
- package/lib/iota/models.d.ts.map +1 -0
- package/lib/iota/models.js +2 -0
- package/lib/iota/models.js.map +1 -0
- package/lib/iota/move-coder.d.ts +4 -0
- package/lib/iota/move-coder.d.ts.map +1 -0
- package/lib/iota/move-coder.js +12 -0
- package/lib/iota/move-coder.js.map +1 -0
- package/lib/iota/network.d.ts +10 -0
- package/lib/iota/network.d.ts.map +1 -0
- package/lib/iota/network.js +24 -0
- package/lib/iota/network.js.map +1 -0
- package/lib/iota/utils.d.ts +3 -0
- package/lib/iota/utils.d.ts.map +1 -0
- package/lib/iota/utils.js +41 -0
- package/lib/iota/utils.js.map +1 -0
- package/lib/solana/solana-plugin.d.ts +3 -2
- package/lib/solana/solana-plugin.d.ts.map +1 -1
- package/lib/solana/solana-plugin.js +11 -1
- package/lib/solana/solana-plugin.js.map +1 -1
- package/lib/stark/starknet-plugin.d.ts +5 -7
- package/lib/stark/starknet-plugin.d.ts.map +1 -1
- package/lib/stark/starknet-plugin.js +18 -10
- package/lib/stark/starknet-plugin.js.map +1 -1
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +1 -0
- package/lib/store/schema.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +73 -0
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +237 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +2 -0
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +21 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/network.d.ts.map +1 -1
- package/lib/sui/network.js +0 -3
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +12 -0
- package/lib/sui/sui-plugin-part.d.ts.map +1 -0
- package/lib/sui/sui-plugin-part.js +178 -0
- package/lib/sui/sui-plugin-part.js.map +1 -0
- package/lib/sui/sui-plugin.d.ts +9 -10
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +30 -164
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/testing/iota-facet.d.ts +14 -0
- package/lib/testing/iota-facet.d.ts.map +1 -0
- package/lib/testing/iota-facet.js +124 -0
- package/lib/testing/iota-facet.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +2 -0
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +3 -0
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +21 -9
- package/src/aptos/abis/0x1.json +1040 -45
- package/src/aptos/abis/0x3.json +2 -2
- package/src/aptos/abis/0x4.json +17 -17
- package/src/aptos/aptos-plugin.ts +55 -44
- package/src/aptos/aptos-processor.ts +15 -3
- package/src/aptos/builtin/0x1.ts +615 -1
- package/src/aptos/builtin/0x3.ts +1 -1
- package/src/aptos/builtin/0x4.ts +1 -1
- package/src/btc/btc-plugin.ts +33 -32
- package/src/core/core-plugin.ts +16 -2
- package/src/core/handler-options.ts +7 -0
- package/src/core/handler-register.ts +79 -0
- package/src/cosmos/cosmos-plugin.ts +24 -20
- package/src/eth/base-processor.ts +43 -1
- package/src/eth/eth-plugin.ts +111 -185
- package/src/eth/eth.ts +31 -26
- package/src/fuel/fuel-plugin.ts +43 -44
- package/src/iota/abis/0x1.json +4213 -0
- package/src/iota/abis/0x2.json +26692 -0
- package/src/iota/abis/0x3.json +10598 -0
- package/src/iota/builtin/0x1.ts +6292 -0
- package/src/iota/builtin/0x2.ts +26198 -0
- package/src/iota/builtin/0x3.ts +11144 -0
- package/src/iota/builtin/index.ts +6 -0
- package/src/iota/codegen/codegen.ts +118 -0
- package/src/iota/codegen/index.ts +1 -0
- package/src/iota/codegen/run.ts +13 -0
- package/src/iota/context.ts +200 -0
- package/src/iota/ext/coin.ts +565 -0
- package/src/iota/ext/index.ts +2 -0
- package/src/iota/ext/move-dex.ts +52 -0
- package/src/iota/index.ts +29 -0
- package/src/iota/iota-object-processor-template.ts +277 -0
- package/src/iota/iota-object-processor.ts +386 -0
- package/src/iota/iota-plugin-part.ts +211 -0
- package/src/iota/iota-plugin.ts +2 -0
- package/src/iota/iota-processor.ts +339 -0
- package/src/iota/models.ts +14 -0
- package/src/iota/move-coder.ts +15 -0
- package/src/iota/network.ts +27 -0
- package/src/iota/utils.ts +52 -0
- package/src/solana/solana-plugin.ts +20 -2
- package/src/stark/starknet-plugin.ts +24 -20
- package/src/store/schema.ts +1 -0
- package/src/sui/abis/0x2.json +269 -0
- package/src/sui/abis/0x3.json +29 -0
- package/src/sui/builtin/0x2.ts +367 -1
- package/src/sui/builtin/0x3.ts +29 -1
- package/src/sui/network.ts +0 -3
- package/src/sui/sui-plugin-part.ts +211 -0
- package/src/sui/sui-plugin.ts +51 -211
- package/src/testing/iota-facet.ts +143 -0
- package/src/testing/test-processor-server.ts +3 -0
package/src/sui/network.ts
CHANGED
@@ -7,9 +7,6 @@ export type SuiNetwork = SuiChainId
|
|
7
7
|
export const SuiNetwork = <const>{
|
8
8
|
MAIN_NET: SuiChainId.SUI_MAINNET,
|
9
9
|
TEST_NET: SuiChainId.SUI_TESTNET
|
10
|
-
// DEV_NET: SuiChainId.SUI_DEVNET,
|
11
|
-
// MOVEMENT_MAIN_NET: SuiChainId.SUI_MOVEMENT_MAINNET,
|
12
|
-
// MOVEMENT_TEST_NET: SuiChainId.SUI_MOVEMENT_TESTNET
|
13
10
|
}
|
14
11
|
|
15
12
|
export function getClient(network: SuiNetwork): SuiClient {
|
@@ -0,0 +1,211 @@
|
|
1
|
+
import { USER_PROCESSOR } from '@sentio/runtime'
|
2
|
+
import {
|
3
|
+
AccountConfig,
|
4
|
+
ContractConfig,
|
5
|
+
HandlerType,
|
6
|
+
InitResponse,
|
7
|
+
MoveCallHandlerConfig,
|
8
|
+
MoveEventHandlerConfig,
|
9
|
+
MoveResourceChangeConfig,
|
10
|
+
ProcessConfigResponse,
|
11
|
+
StartRequest
|
12
|
+
} from '@sentio/protos'
|
13
|
+
|
14
|
+
import { PartitionHandlerManager } from '../core/index.js'
|
15
|
+
import { HandlerRegister } from '../core/handler-register.js'
|
16
|
+
|
17
|
+
import { SuiProcessorState } from './sui-processor.js'
|
18
|
+
import { SuiAccountProcessorState, SuiAddressProcessor } from './sui-object-processor.js'
|
19
|
+
import { initCoinList } from './ext/coin.js'
|
20
|
+
import { SuiChainId } from '@sentio/chain'
|
21
|
+
import {
|
22
|
+
SuiAccountProcessorTemplateState,
|
23
|
+
SuiObjectOrAddressProcessorTemplate
|
24
|
+
} from './sui-object-processor-template.js'
|
25
|
+
import { SuiNetwork } from './network.js'
|
26
|
+
import { SuiContext } from './context.js'
|
27
|
+
|
28
|
+
export class SuiPluginPart {
|
29
|
+
constructor(
|
30
|
+
private handlerRegister: HandlerRegister,
|
31
|
+
private partitionManager: PartitionHandlerManager
|
32
|
+
) {}
|
33
|
+
|
34
|
+
async start(request: StartRequest): Promise<void> {
|
35
|
+
await initCoinList()
|
36
|
+
|
37
|
+
console.log('total instances:', request.templateInstances.length)
|
38
|
+
const allowedChainIds = new Set<string>([SuiChainId.SUI_MAINNET, SuiChainId.SUI_TESTNET])
|
39
|
+
for (const instance of request.templateInstances) {
|
40
|
+
if (!allowedChainIds.has(instance.contract?.chainId || '')) {
|
41
|
+
continue
|
42
|
+
}
|
43
|
+
|
44
|
+
console.log('start template instance', instance.templateId)
|
45
|
+
const template: SuiObjectOrAddressProcessorTemplate<any, any, any> =
|
46
|
+
SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId]
|
47
|
+
|
48
|
+
template.bind(
|
49
|
+
{
|
50
|
+
address: instance.contract?.address || '',
|
51
|
+
objectId: instance.contract?.address || '',
|
52
|
+
network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,
|
53
|
+
startCheckpoint: instance.startBlock || 0n,
|
54
|
+
endCheckpoint: instance.endBlock || 0n,
|
55
|
+
baseLabels: instance.baseLabels
|
56
|
+
},
|
57
|
+
NoopContext
|
58
|
+
)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
async init(config: InitResponse) {
|
63
|
+
for (const state of [SuiProcessorState.INSTANCE, SuiAccountProcessorState.INSTANCE]) {
|
64
|
+
for (const suiProcessor of state.getValues()) {
|
65
|
+
config.chainIds.push(suiProcessor.config.network)
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
async configure(config: ProcessConfigResponse, forChainId?: string) {
|
71
|
+
// this.handlerRegister.clear(forChainId as any)
|
72
|
+
|
73
|
+
for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {
|
74
|
+
const chainId = suiProcessor.config.network
|
75
|
+
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
76
|
+
continue
|
77
|
+
}
|
78
|
+
const contractConfig = ContractConfig.fromPartial({
|
79
|
+
transactionConfig: [],
|
80
|
+
processorType: USER_PROCESSOR,
|
81
|
+
contract: {
|
82
|
+
name: suiProcessor.moduleName,
|
83
|
+
chainId: suiProcessor.config.network,
|
84
|
+
address: suiProcessor.config.address,
|
85
|
+
abi: ''
|
86
|
+
},
|
87
|
+
startBlock: suiProcessor.config.startCheckpoint,
|
88
|
+
endBlock: suiProcessor.config.endCheckpoint
|
89
|
+
})
|
90
|
+
for (const handler of suiProcessor.eventHandlers) {
|
91
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
92
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler)
|
93
|
+
const eventHandlerConfig: MoveEventHandlerConfig = {
|
94
|
+
filters: handler.filters.map((f) => {
|
95
|
+
return {
|
96
|
+
type: f.type,
|
97
|
+
account: f.account || '',
|
98
|
+
eventAccount: f.eventAccount || ''
|
99
|
+
}
|
100
|
+
}),
|
101
|
+
fetchConfig: handler.fetchConfig,
|
102
|
+
handlerId,
|
103
|
+
handlerName: handler.handlerName
|
104
|
+
}
|
105
|
+
contractConfig.moveEventConfigs.push(eventHandlerConfig)
|
106
|
+
}
|
107
|
+
for (const handler of suiProcessor.callHandlers) {
|
108
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
109
|
+
this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler)
|
110
|
+
const functionHandlerConfig: MoveCallHandlerConfig = {
|
111
|
+
filters: handler.filters.map((filter) => {
|
112
|
+
return {
|
113
|
+
function: filter.function,
|
114
|
+
typeArguments: filter.typeArguments || [],
|
115
|
+
withTypeArguments: !!filter.typeArguments,
|
116
|
+
includeFailed: filter.includeFailed || false,
|
117
|
+
publicKeyPrefix: filter.publicKeyPrefix || '',
|
118
|
+
fromAndToAddress: filter.fromAndToAddress
|
119
|
+
}
|
120
|
+
}),
|
121
|
+
fetchConfig: handler.fetchConfig,
|
122
|
+
handlerId,
|
123
|
+
handlerName: handler.handlerName
|
124
|
+
}
|
125
|
+
contractConfig.moveCallConfigs.push(functionHandlerConfig)
|
126
|
+
}
|
127
|
+
// deprecated, use objectType processor instead
|
128
|
+
for (const handler of suiProcessor.objectChangeHandlers) {
|
129
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
130
|
+
const objectChangeHandler: MoveResourceChangeConfig = {
|
131
|
+
type: handler.type,
|
132
|
+
handlerId,
|
133
|
+
handlerName: handler.handlerName,
|
134
|
+
includeDeleted: false
|
135
|
+
}
|
136
|
+
contractConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
137
|
+
}
|
138
|
+
config.contractConfigs.push(contractConfig)
|
139
|
+
}
|
140
|
+
|
141
|
+
for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {
|
142
|
+
const chainId = processor.getChainId()
|
143
|
+
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
144
|
+
continue
|
145
|
+
}
|
146
|
+
const accountConfig = AccountConfig.fromPartial({
|
147
|
+
address: processor.config.address,
|
148
|
+
chainId: processor.getChainId(),
|
149
|
+
startBlock: processor.config.startCheckpoint, // TODO maybe use another field
|
150
|
+
endBlock: processor.config.endCheckpoint
|
151
|
+
})
|
152
|
+
|
153
|
+
for (const handler of processor.objectChangeHandlers) {
|
154
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
155
|
+
const objectChangeHandler: MoveResourceChangeConfig = {
|
156
|
+
type: handler.type,
|
157
|
+
handlerId,
|
158
|
+
handlerName: handler.handlerName,
|
159
|
+
includeDeleted: false
|
160
|
+
}
|
161
|
+
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
162
|
+
}
|
163
|
+
|
164
|
+
for (const handler of processor.objectHandlers) {
|
165
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
166
|
+
|
167
|
+
accountConfig.moveIntervalConfigs.push({
|
168
|
+
intervalConfig: {
|
169
|
+
handlerId: handlerId,
|
170
|
+
handlerName: handler.handlerName,
|
171
|
+
minutes: 0,
|
172
|
+
minutesInterval: handler.timeIntervalInMinutes,
|
173
|
+
slot: 0,
|
174
|
+
slotInterval: handler.checkPointInterval,
|
175
|
+
fetchConfig: undefined
|
176
|
+
},
|
177
|
+
type: handler.type || '',
|
178
|
+
ownerType: processor.ownerType,
|
179
|
+
resourceFetchConfig: handler.fetchConfig,
|
180
|
+
fetchConfig: undefined
|
181
|
+
})
|
182
|
+
}
|
183
|
+
|
184
|
+
if (processor instanceof SuiAddressProcessor) {
|
185
|
+
for (const handler of processor.callHandlers) {
|
186
|
+
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
187
|
+
const functionHandlerConfig: MoveCallHandlerConfig = {
|
188
|
+
filters: handler.filters.map((filter) => {
|
189
|
+
return {
|
190
|
+
function: filter.function,
|
191
|
+
typeArguments: filter.typeArguments || [],
|
192
|
+
withTypeArguments: !!filter.typeArguments,
|
193
|
+
includeFailed: filter.includeFailed || false,
|
194
|
+
publicKeyPrefix: filter.publicKeyPrefix || '',
|
195
|
+
fromAndToAddress: filter.fromAndToAddress
|
196
|
+
}
|
197
|
+
}),
|
198
|
+
fetchConfig: handler.fetchConfig,
|
199
|
+
handlerId,
|
200
|
+
handlerName: handler.handlerName
|
201
|
+
}
|
202
|
+
accountConfig.moveCallConfigs.push(functionHandlerConfig)
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
config.accountConfigs.push(accountConfig)
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
const NoopContext = new SuiContext('', SuiChainId.SUI_MAINNET, '', new Date(), 0n, {} as any, 0, {})
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -1,16 +1,8 @@
|
|
1
|
-
import { errorString, mergeProcessResults, Plugin, PluginManager
|
1
|
+
import { errorString, mergeProcessResults, Plugin, PluginManager } from '@sentio/runtime'
|
2
2
|
import {
|
3
|
-
AccountConfig,
|
4
|
-
ContractConfig,
|
5
|
-
Data_SuiCall,
|
6
|
-
Data_SuiEvent,
|
7
|
-
Data_SuiObject,
|
8
|
-
Data_SuiObjectChange,
|
9
3
|
DataBinding,
|
10
4
|
HandlerType,
|
11
|
-
|
12
|
-
MoveEventHandlerConfig,
|
13
|
-
MoveResourceChangeConfig,
|
5
|
+
InitResponse,
|
14
6
|
ProcessConfigResponse,
|
15
7
|
ProcessResult,
|
16
8
|
ProcessStreamResponse_Partitions,
|
@@ -19,198 +11,35 @@ import {
|
|
19
11
|
|
20
12
|
import { ServerError, Status } from 'nice-grpc'
|
21
13
|
import { PartitionHandlerManager } from '../core/index.js'
|
14
|
+
import { HandlerRegister } from '../core/handler-register.js'
|
22
15
|
|
23
|
-
import { SuiProcessorState } from './sui-processor.js'
|
24
|
-
import { SuiAccountProcessorState, SuiAddressProcessor } from './sui-object-processor.js'
|
25
|
-
import { initCoinList } from './ext/coin.js'
|
26
16
|
import { SuiChainId } from '@sentio/chain'
|
27
|
-
import {
|
28
|
-
SuiAccountProcessorTemplateState,
|
29
|
-
SuiObjectOrAddressProcessorTemplate
|
30
|
-
} from './sui-object-processor-template.js'
|
31
|
-
import { SuiNetwork } from './network.js'
|
32
17
|
import { SuiContext } from './context.js'
|
33
|
-
|
34
|
-
|
35
|
-
suiEventHandlers: ((event: Data_SuiEvent) => Promise<ProcessResult>)[]
|
36
|
-
suiCallHandlers: ((func: Data_SuiCall) => Promise<ProcessResult>)[]
|
37
|
-
suiObjectHandlers: ((object: Data_SuiObject) => Promise<ProcessResult>)[]
|
38
|
-
suiObjectChangeHandlers: ((object: Data_SuiObjectChange) => Promise<ProcessResult>)[]
|
39
|
-
}
|
18
|
+
import { SuiPluginPart } from './sui-plugin-part.js'
|
19
|
+
import { IotaPluginPart } from '../iota/iota-plugin-part.js'
|
40
20
|
|
41
21
|
export class SuiPlugin extends Plugin {
|
42
22
|
name: string = 'SuiPlugin'
|
43
|
-
|
44
|
-
suiCallHandlers: [],
|
45
|
-
suiEventHandlers: [],
|
46
|
-
suiObjectHandlers: [],
|
47
|
-
suiObjectChangeHandlers: []
|
48
|
-
}
|
49
|
-
|
23
|
+
handlerRegister = new HandlerRegister()
|
50
24
|
partitionManager = new PartitionHandlerManager()
|
51
|
-
async start(request: StartRequest): Promise<void> {
|
52
|
-
await initCoinList()
|
53
25
|
|
54
|
-
|
55
|
-
|
56
|
-
for (const instance of request.templateInstances) {
|
57
|
-
if (!allowedChainIds.has(instance.contract?.chainId || '')) {
|
58
|
-
continue
|
59
|
-
}
|
26
|
+
suiPart = new SuiPluginPart(this.handlerRegister, this.partitionManager)
|
27
|
+
iotaPart = new IotaPluginPart(this.handlerRegister, this.partitionManager)
|
60
28
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
template.bind(
|
66
|
-
{
|
67
|
-
address: instance.contract?.address || '',
|
68
|
-
objectId: instance.contract?.address || '',
|
69
|
-
network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,
|
70
|
-
startCheckpoint: instance.startBlock || 0n,
|
71
|
-
endCheckpoint: instance.endBlock || 0n,
|
72
|
-
baseLabels: instance.baseLabels
|
73
|
-
},
|
74
|
-
NoopContext
|
75
|
-
)
|
76
|
-
}
|
29
|
+
async start(request: StartRequest): Promise<void> {
|
30
|
+
await this.suiPart.start(request)
|
31
|
+
await this.iotaPart.start(request)
|
77
32
|
}
|
78
33
|
|
79
|
-
async
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
suiObjectHandlers: [],
|
84
|
-
suiObjectChangeHandlers: []
|
85
|
-
}
|
86
|
-
for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {
|
87
|
-
const contractConfig = ContractConfig.fromPartial({
|
88
|
-
transactionConfig: [],
|
89
|
-
processorType: USER_PROCESSOR,
|
90
|
-
contract: {
|
91
|
-
name: suiProcessor.moduleName,
|
92
|
-
chainId: suiProcessor.config.network,
|
93
|
-
address: suiProcessor.config.address,
|
94
|
-
abi: ''
|
95
|
-
},
|
96
|
-
startBlock: suiProcessor.config.startCheckpoint,
|
97
|
-
endBlock: suiProcessor.config.endCheckpoint
|
98
|
-
})
|
99
|
-
for (const handler of suiProcessor.eventHandlers) {
|
100
|
-
const handlerId = handlers.suiEventHandlers.push(handler.handler) - 1
|
101
|
-
this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler)
|
102
|
-
const eventHandlerConfig: MoveEventHandlerConfig = {
|
103
|
-
filters: handler.filters.map((f) => {
|
104
|
-
return {
|
105
|
-
type: f.type,
|
106
|
-
account: f.account || '',
|
107
|
-
eventAccount: f.eventAccount || ''
|
108
|
-
}
|
109
|
-
}),
|
110
|
-
fetchConfig: handler.fetchConfig,
|
111
|
-
handlerId,
|
112
|
-
handlerName: handler.handlerName
|
113
|
-
}
|
114
|
-
contractConfig.moveEventConfigs.push(eventHandlerConfig)
|
115
|
-
}
|
116
|
-
for (const handler of suiProcessor.callHandlers) {
|
117
|
-
const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1
|
118
|
-
this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler)
|
119
|
-
const functionHandlerConfig: MoveCallHandlerConfig = {
|
120
|
-
filters: handler.filters.map((filter) => {
|
121
|
-
return {
|
122
|
-
function: filter.function,
|
123
|
-
typeArguments: filter.typeArguments || [],
|
124
|
-
withTypeArguments: !!filter.typeArguments,
|
125
|
-
includeFailed: filter.includeFailed || false,
|
126
|
-
publicKeyPrefix: filter.publicKeyPrefix || '',
|
127
|
-
fromAndToAddress: filter.fromAndToAddress
|
128
|
-
}
|
129
|
-
}),
|
130
|
-
fetchConfig: handler.fetchConfig,
|
131
|
-
handlerId,
|
132
|
-
handlerName: handler.handlerName
|
133
|
-
}
|
134
|
-
contractConfig.moveCallConfigs.push(functionHandlerConfig)
|
135
|
-
}
|
136
|
-
// deprecated, use objectType processor instead
|
137
|
-
for (const handler of suiProcessor.objectChangeHandlers) {
|
138
|
-
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
|
139
|
-
const objectChangeHandler: MoveResourceChangeConfig = {
|
140
|
-
type: handler.type,
|
141
|
-
handlerId,
|
142
|
-
handlerName: handler.handlerName,
|
143
|
-
includeDeleted: false
|
144
|
-
}
|
145
|
-
contractConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
146
|
-
}
|
147
|
-
config.contractConfigs.push(contractConfig)
|
148
|
-
}
|
149
|
-
|
150
|
-
for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {
|
151
|
-
const accountConfig = AccountConfig.fromPartial({
|
152
|
-
address: processor.config.address,
|
153
|
-
chainId: processor.getChainId(),
|
154
|
-
startBlock: processor.config.startCheckpoint, // TODO maybe use another field
|
155
|
-
endBlock: processor.config.endCheckpoint
|
156
|
-
})
|
157
|
-
|
158
|
-
for (const handler of processor.objectChangeHandlers) {
|
159
|
-
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
|
160
|
-
const objectChangeHandler: MoveResourceChangeConfig = {
|
161
|
-
type: handler.type,
|
162
|
-
handlerId,
|
163
|
-
handlerName: handler.handlerName,
|
164
|
-
includeDeleted: false
|
165
|
-
}
|
166
|
-
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
167
|
-
}
|
168
|
-
|
169
|
-
for (const handler of processor.objectHandlers) {
|
170
|
-
const handlerId = handlers.suiObjectHandlers.push(handler.handler) - 1
|
171
|
-
|
172
|
-
accountConfig.moveIntervalConfigs.push({
|
173
|
-
intervalConfig: {
|
174
|
-
handlerId: handlerId,
|
175
|
-
handlerName: handler.handlerName,
|
176
|
-
minutes: 0,
|
177
|
-
minutesInterval: handler.timeIntervalInMinutes,
|
178
|
-
slot: 0,
|
179
|
-
slotInterval: handler.checkPointInterval,
|
180
|
-
fetchConfig: undefined
|
181
|
-
},
|
182
|
-
type: handler.type || '',
|
183
|
-
ownerType: processor.ownerType,
|
184
|
-
resourceFetchConfig: handler.fetchConfig,
|
185
|
-
fetchConfig: undefined
|
186
|
-
})
|
187
|
-
}
|
188
|
-
|
189
|
-
if (processor instanceof SuiAddressProcessor) {
|
190
|
-
for (const handler of processor.callHandlers) {
|
191
|
-
const handlerId = handlers.suiCallHandlers.push(handler.handler) - 1
|
192
|
-
const functionHandlerConfig: MoveCallHandlerConfig = {
|
193
|
-
filters: handler.filters.map((filter) => {
|
194
|
-
return {
|
195
|
-
function: filter.function,
|
196
|
-
typeArguments: filter.typeArguments || [],
|
197
|
-
withTypeArguments: !!filter.typeArguments,
|
198
|
-
includeFailed: filter.includeFailed || false,
|
199
|
-
publicKeyPrefix: filter.publicKeyPrefix || '',
|
200
|
-
fromAndToAddress: filter.fromAndToAddress
|
201
|
-
}
|
202
|
-
}),
|
203
|
-
fetchConfig: handler.fetchConfig,
|
204
|
-
handlerId,
|
205
|
-
handlerName: handler.handlerName
|
206
|
-
}
|
207
|
-
accountConfig.moveCallConfigs.push(functionHandlerConfig)
|
208
|
-
}
|
209
|
-
}
|
34
|
+
async init(config: InitResponse) {
|
35
|
+
await this.suiPart.init(config)
|
36
|
+
await this.iotaPart.init(config)
|
37
|
+
}
|
210
38
|
|
211
|
-
|
212
|
-
|
213
|
-
this.
|
39
|
+
async configure(config: ProcessConfigResponse, forChainId?: string) {
|
40
|
+
this.handlerRegister.clear(forChainId as any)
|
41
|
+
await this.suiPart.configure(config)
|
42
|
+
await this.iotaPart.configure(config)
|
214
43
|
}
|
215
44
|
|
216
45
|
supportedHandlers = [
|
@@ -284,12 +113,14 @@ export class SuiPlugin extends Plugin {
|
|
284
113
|
|
285
114
|
for (const handlerId of binding.handlerIds) {
|
286
115
|
promises.push(
|
287
|
-
this.
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
116
|
+
this.handlerRegister
|
117
|
+
.getHandlerById(handlerId)(event)
|
118
|
+
.catch((e: any) => {
|
119
|
+
throw new ServerError(
|
120
|
+
Status.INTERNAL,
|
121
|
+
'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
|
122
|
+
)
|
123
|
+
})
|
293
124
|
)
|
294
125
|
}
|
295
126
|
return mergeProcessResults(await Promise.all(promises))
|
@@ -303,9 +134,14 @@ export class SuiPlugin extends Plugin {
|
|
303
134
|
|
304
135
|
const promises: Promise<ProcessResult>[] = []
|
305
136
|
for (const handlerId of binding.handlerIds) {
|
306
|
-
const promise = this.
|
307
|
-
|
308
|
-
|
137
|
+
const promise = this.handlerRegister
|
138
|
+
.getHandlerById(handlerId)(call)
|
139
|
+
.catch((e: any) => {
|
140
|
+
throw new ServerError(
|
141
|
+
Status.INTERNAL,
|
142
|
+
'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e)
|
143
|
+
)
|
144
|
+
})
|
309
145
|
promises.push(promise)
|
310
146
|
}
|
311
147
|
return mergeProcessResults(await Promise.all(promises))
|
@@ -320,12 +156,14 @@ export class SuiPlugin extends Plugin {
|
|
320
156
|
const promises: Promise<ProcessResult>[] = []
|
321
157
|
for (const handlerId of binding.handlerIds) {
|
322
158
|
promises.push(
|
323
|
-
this.
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
159
|
+
this.handlerRegister
|
160
|
+
.getHandlerById(handlerId)(object)
|
161
|
+
.catch((e: any) => {
|
162
|
+
throw new ServerError(
|
163
|
+
Status.INTERNAL,
|
164
|
+
'error processing object: ' + JSON.stringify(object) + '\n' + errorString(e)
|
165
|
+
)
|
166
|
+
})
|
329
167
|
)
|
330
168
|
}
|
331
169
|
return mergeProcessResults(await Promise.all(promises))
|
@@ -340,12 +178,14 @@ export class SuiPlugin extends Plugin {
|
|
340
178
|
const promises: Promise<ProcessResult>[] = []
|
341
179
|
for (const handlerId of binding.handlerIds) {
|
342
180
|
promises.push(
|
343
|
-
this.
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
181
|
+
this.handlerRegister
|
182
|
+
.getHandlerById(handlerId)(objectChange)
|
183
|
+
.catch((e: any) => {
|
184
|
+
throw new ServerError(
|
185
|
+
Status.INTERNAL,
|
186
|
+
'error processing object change: ' + JSON.stringify(objectChange) + '\n' + errorString(e)
|
187
|
+
)
|
188
|
+
})
|
349
189
|
)
|
350
190
|
}
|
351
191
|
return mergeProcessResults(await Promise.all(promises))
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import { MoveCallIotaTransaction, IotaTransactionBlockResponse } from '@iota/iota-sdk/client'
|
2
|
+
import { DataBinding, HandlerType } from '@sentio/protos'
|
3
|
+
import { TestProcessorServer } from './test-processor-server.js'
|
4
|
+
import { accountTypeString, parseMoveType, SPLITTER } from '../move/index.js'
|
5
|
+
import { IotaNetwork } from '../iota/index.js'
|
6
|
+
import { getMoveCalls } from '../iota/utils.js'
|
7
|
+
|
8
|
+
export class IotaFacet {
|
9
|
+
server: TestProcessorServer
|
10
|
+
constructor(server: TestProcessorServer) {
|
11
|
+
this.server = server
|
12
|
+
}
|
13
|
+
|
14
|
+
testEntryFunctionCall(transaction: IotaTransactionBlockResponse, network: IotaNetwork = IotaNetwork.MAIN_NET) {
|
15
|
+
return this.testEntryFunctionCalls([transaction], network)
|
16
|
+
}
|
17
|
+
|
18
|
+
testEntryFunctionCalls(transactions: IotaTransactionBlockResponse[], network: IotaNetwork = IotaNetwork.MAIN_NET) {
|
19
|
+
const bindings = []
|
20
|
+
for (const trans of transactions) {
|
21
|
+
const binding = this.buildEntryFunctionCallBinding(trans, network)
|
22
|
+
if (!binding) {
|
23
|
+
throw Error('Invalid test transaction: ' + JSON.stringify(trans))
|
24
|
+
}
|
25
|
+
bindings.push(binding)
|
26
|
+
}
|
27
|
+
return this.server.processBindings({
|
28
|
+
bindings: bindings
|
29
|
+
})
|
30
|
+
}
|
31
|
+
|
32
|
+
private buildEntryFunctionCallBinding(
|
33
|
+
transaction: IotaTransactionBlockResponse,
|
34
|
+
network: IotaNetwork = IotaNetwork.MAIN_NET
|
35
|
+
): DataBinding | undefined {
|
36
|
+
const calls: MoveCallIotaTransaction[] = getMoveCalls(transaction)
|
37
|
+
// if (calls.length !== 1) {
|
38
|
+
// throw Error('Transaction has more than one calls')
|
39
|
+
// }
|
40
|
+
for (const call of calls) {
|
41
|
+
const functionType = [accountTypeString(call.package), call.module, call.function].join(SPLITTER)
|
42
|
+
|
43
|
+
for (const config of this.server.contractConfigs) {
|
44
|
+
if (config.contract?.chainId !== network) {
|
45
|
+
continue
|
46
|
+
}
|
47
|
+
for (const callConfig of config.moveCallConfigs) {
|
48
|
+
for (const callFilter of callConfig.filters) {
|
49
|
+
if (accountTypeString(config.contract.address) + '::' + callFilter.function === functionType) {
|
50
|
+
return {
|
51
|
+
data: {
|
52
|
+
suiCall: {
|
53
|
+
rawTransaction: JSON.stringify(transaction),
|
54
|
+
timestamp: new Date(),
|
55
|
+
slot: 10000n
|
56
|
+
}
|
57
|
+
},
|
58
|
+
handlerIds: [callConfig.handlerId],
|
59
|
+
handlerType: HandlerType.SUI_CALL
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
return undefined
|
67
|
+
}
|
68
|
+
|
69
|
+
testEvent(transaction: IotaTransactionBlockResponse, network: IotaNetwork = IotaNetwork.MAIN_NET) {
|
70
|
+
const binding = this.buildEventBinding(transaction, network)
|
71
|
+
if (!binding) {
|
72
|
+
throw Error('Invalid test event: ' + JSON.stringify(transaction))
|
73
|
+
}
|
74
|
+
return this.server.processBinding(binding)
|
75
|
+
}
|
76
|
+
|
77
|
+
// limitation, can't really do filter logic
|
78
|
+
testGlobalTransaction(transaction: IotaTransactionBlockResponse, network: IotaNetwork = IotaNetwork.MAIN_NET) {
|
79
|
+
const handlerIds = []
|
80
|
+
for (const config of this.server.contractConfigs) {
|
81
|
+
if (config.contract?.address === '*') {
|
82
|
+
for (const callConfig of config.moveCallConfigs) {
|
83
|
+
if (callConfig.filters.length === 1 && callConfig.filters[0].function === '') {
|
84
|
+
handlerIds.push(callConfig.handlerId)
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
if (handlerIds.length === 0) {
|
90
|
+
throw Error('Invalid test global transaction: ' + JSON.stringify(transaction))
|
91
|
+
}
|
92
|
+
|
93
|
+
const binding: DataBinding = {
|
94
|
+
handlerIds,
|
95
|
+
handlerType: HandlerType.SUI_CALL,
|
96
|
+
data: {
|
97
|
+
suiCall: {
|
98
|
+
rawTransaction: JSON.stringify(transaction),
|
99
|
+
timestamp: transaction.timestampMs ? new Date(transaction.timestampMs) : new Date(),
|
100
|
+
slot: BigInt(transaction.checkpoint || 0)
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return this.server.processBinding(binding)
|
105
|
+
}
|
106
|
+
|
107
|
+
private buildEventBinding(
|
108
|
+
transaction: IotaTransactionBlockResponse,
|
109
|
+
network: IotaNetwork = IotaNetwork.MAIN_NET
|
110
|
+
): DataBinding | undefined {
|
111
|
+
// const allEvents = new Set(transaction.events.map(e => e.type))
|
112
|
+
|
113
|
+
for (const config of this.server.contractConfigs) {
|
114
|
+
if (config.contract?.chainId !== network) {
|
115
|
+
continue
|
116
|
+
}
|
117
|
+
for (const eventConfig of config.moveEventConfigs) {
|
118
|
+
for (const eventFilter of eventConfig.filters) {
|
119
|
+
for (const event of transaction.events || []) {
|
120
|
+
if (
|
121
|
+
accountTypeString(config.contract.address) + '::' + eventFilter.type ===
|
122
|
+
parseMoveType(event.type).qname
|
123
|
+
) {
|
124
|
+
return {
|
125
|
+
data: {
|
126
|
+
suiEvent: {
|
127
|
+
rawEvent: JSON.stringify(event),
|
128
|
+
rawTransaction: JSON.stringify(transaction),
|
129
|
+
timestamp: new Date(transaction.timestampMs || 0),
|
130
|
+
slot: 10000n
|
131
|
+
}
|
132
|
+
},
|
133
|
+
handlerIds: [eventConfig.handlerId],
|
134
|
+
handlerType: HandlerType.SUI_EVENT
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
return undefined
|
142
|
+
}
|
143
|
+
}
|