@sentio/sdk 2.60.0-rc.4 → 2.60.0-rc.6
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/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.map +1 -1
- package/lib/eth/eth-plugin.js +37 -3
- package/lib/eth/eth-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/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 +4 -0
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +12 -159
- 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 +20 -8
- package/src/eth/base-processor.ts +43 -1
- package/src/eth/eth-plugin.ts +41 -3
- 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/sui/network.ts +0 -3
- package/src/sui/sui-plugin-part.ts +211 -0
- package/src/sui/sui-plugin.ts +12 -178
- package/src/testing/iota-facet.ts +143 -0
- package/src/testing/test-processor-server.ts +3 -0
@@ -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,13 +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
3
|
DataBinding,
|
6
4
|
HandlerType,
|
7
5
|
InitResponse,
|
8
|
-
MoveCallHandlerConfig,
|
9
|
-
MoveEventHandlerConfig,
|
10
|
-
MoveResourceChangeConfig,
|
11
6
|
ProcessConfigResponse,
|
12
7
|
ProcessResult,
|
13
8
|
ProcessStreamResponse_Partitions,
|
@@ -18,194 +13,33 @@ import { ServerError, Status } from 'nice-grpc'
|
|
18
13
|
import { PartitionHandlerManager } from '../core/index.js'
|
19
14
|
import { HandlerRegister } from '../core/handler-register.js'
|
20
15
|
|
21
|
-
import { SuiProcessorState } from './sui-processor.js'
|
22
|
-
import { SuiAccountProcessorState, SuiAddressProcessor } from './sui-object-processor.js'
|
23
|
-
import { initCoinList } from './ext/coin.js'
|
24
16
|
import { SuiChainId } from '@sentio/chain'
|
25
|
-
import {
|
26
|
-
SuiAccountProcessorTemplateState,
|
27
|
-
SuiObjectOrAddressProcessorTemplate
|
28
|
-
} from './sui-object-processor-template.js'
|
29
|
-
import { SuiNetwork } from './network.js'
|
30
17
|
import { SuiContext } from './context.js'
|
18
|
+
import { SuiPluginPart } from './sui-plugin-part.js'
|
19
|
+
import { IotaPluginPart } from '../iota/iota-plugin-part.js'
|
31
20
|
|
32
21
|
export class SuiPlugin extends Plugin {
|
33
22
|
name: string = 'SuiPlugin'
|
34
23
|
handlerRegister = new HandlerRegister()
|
35
24
|
partitionManager = new PartitionHandlerManager()
|
36
|
-
async start(request: StartRequest): Promise<void> {
|
37
|
-
await initCoinList()
|
38
|
-
|
39
|
-
console.log('total instances:', request.templateInstances.length)
|
40
|
-
const allowedChainIds = new Set<string>(Object.values(SuiChainId))
|
41
|
-
for (const instance of request.templateInstances) {
|
42
|
-
if (!allowedChainIds.has(instance.contract?.chainId || '')) {
|
43
|
-
continue
|
44
|
-
}
|
45
25
|
|
46
|
-
|
47
|
-
|
48
|
-
SuiAccountProcessorTemplateState.INSTANCE.getValues()[instance.templateId]
|
26
|
+
suiPart = new SuiPluginPart(this.handlerRegister, this.partitionManager)
|
27
|
+
iotaPart = new IotaPluginPart(this.handlerRegister, this.partitionManager)
|
49
28
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
objectId: instance.contract?.address || '',
|
54
|
-
network: <SuiNetwork>instance.contract?.chainId || SuiNetwork.MAIN_NET,
|
55
|
-
startCheckpoint: instance.startBlock || 0n,
|
56
|
-
endCheckpoint: instance.endBlock || 0n,
|
57
|
-
baseLabels: instance.baseLabels
|
58
|
-
},
|
59
|
-
NoopContext
|
60
|
-
)
|
61
|
-
}
|
29
|
+
async start(request: StartRequest): Promise<void> {
|
30
|
+
await this.suiPart.start(request)
|
31
|
+
await this.iotaPart.start(request)
|
62
32
|
}
|
63
33
|
|
64
34
|
async init(config: InitResponse) {
|
65
|
-
|
66
|
-
|
67
|
-
config.chainIds.push(suiProcessor.config.network)
|
68
|
-
}
|
69
|
-
}
|
35
|
+
await this.suiPart.init(config)
|
36
|
+
await this.iotaPart.init(config)
|
70
37
|
}
|
71
38
|
|
72
39
|
async configure(config: ProcessConfigResponse, forChainId?: string) {
|
73
40
|
this.handlerRegister.clear(forChainId as any)
|
74
|
-
|
75
|
-
|
76
|
-
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
77
|
-
continue
|
78
|
-
}
|
79
|
-
const contractConfig = ContractConfig.fromPartial({
|
80
|
-
transactionConfig: [],
|
81
|
-
processorType: USER_PROCESSOR,
|
82
|
-
contract: {
|
83
|
-
name: suiProcessor.moduleName,
|
84
|
-
chainId: suiProcessor.config.network,
|
85
|
-
address: suiProcessor.config.address,
|
86
|
-
abi: ''
|
87
|
-
},
|
88
|
-
startBlock: suiProcessor.config.startCheckpoint,
|
89
|
-
endBlock: suiProcessor.config.endCheckpoint
|
90
|
-
})
|
91
|
-
for (const handler of suiProcessor.eventHandlers) {
|
92
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
93
|
-
this.partitionManager.registerPartitionHandler(HandlerType.SUI_EVENT, handlerId, handler.partitionHandler)
|
94
|
-
const eventHandlerConfig: MoveEventHandlerConfig = {
|
95
|
-
filters: handler.filters.map((f) => {
|
96
|
-
return {
|
97
|
-
type: f.type,
|
98
|
-
account: f.account || '',
|
99
|
-
eventAccount: f.eventAccount || ''
|
100
|
-
}
|
101
|
-
}),
|
102
|
-
fetchConfig: handler.fetchConfig,
|
103
|
-
handlerId,
|
104
|
-
handlerName: handler.handlerName
|
105
|
-
}
|
106
|
-
contractConfig.moveEventConfigs.push(eventHandlerConfig)
|
107
|
-
}
|
108
|
-
for (const handler of suiProcessor.callHandlers) {
|
109
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
110
|
-
this.partitionManager.registerPartitionHandler(HandlerType.SUI_CALL, handlerId, handler.partitionHandler)
|
111
|
-
const functionHandlerConfig: MoveCallHandlerConfig = {
|
112
|
-
filters: handler.filters.map((filter) => {
|
113
|
-
return {
|
114
|
-
function: filter.function,
|
115
|
-
typeArguments: filter.typeArguments || [],
|
116
|
-
withTypeArguments: !!filter.typeArguments,
|
117
|
-
includeFailed: filter.includeFailed || false,
|
118
|
-
publicKeyPrefix: filter.publicKeyPrefix || '',
|
119
|
-
fromAndToAddress: filter.fromAndToAddress
|
120
|
-
}
|
121
|
-
}),
|
122
|
-
fetchConfig: handler.fetchConfig,
|
123
|
-
handlerId,
|
124
|
-
handlerName: handler.handlerName
|
125
|
-
}
|
126
|
-
contractConfig.moveCallConfigs.push(functionHandlerConfig)
|
127
|
-
}
|
128
|
-
// deprecated, use objectType processor instead
|
129
|
-
for (const handler of suiProcessor.objectChangeHandlers) {
|
130
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
131
|
-
const objectChangeHandler: MoveResourceChangeConfig = {
|
132
|
-
type: handler.type,
|
133
|
-
handlerId,
|
134
|
-
handlerName: handler.handlerName,
|
135
|
-
includeDeleted: false
|
136
|
-
}
|
137
|
-
contractConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
138
|
-
}
|
139
|
-
config.contractConfigs.push(contractConfig)
|
140
|
-
}
|
141
|
-
|
142
|
-
for (const processor of SuiAccountProcessorState.INSTANCE.getValues()) {
|
143
|
-
const chainId = processor.getChainId()
|
144
|
-
if (forChainId !== undefined && forChainId !== chainId.toString()) {
|
145
|
-
continue
|
146
|
-
}
|
147
|
-
const accountConfig = AccountConfig.fromPartial({
|
148
|
-
address: processor.config.address,
|
149
|
-
chainId: processor.getChainId(),
|
150
|
-
startBlock: processor.config.startCheckpoint, // TODO maybe use another field
|
151
|
-
endBlock: processor.config.endCheckpoint
|
152
|
-
})
|
153
|
-
|
154
|
-
for (const handler of processor.objectChangeHandlers) {
|
155
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
156
|
-
const objectChangeHandler: MoveResourceChangeConfig = {
|
157
|
-
type: handler.type,
|
158
|
-
handlerId,
|
159
|
-
handlerName: handler.handlerName,
|
160
|
-
includeDeleted: false
|
161
|
-
}
|
162
|
-
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
163
|
-
}
|
164
|
-
|
165
|
-
for (const handler of processor.objectHandlers) {
|
166
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
167
|
-
|
168
|
-
accountConfig.moveIntervalConfigs.push({
|
169
|
-
intervalConfig: {
|
170
|
-
handlerId: handlerId,
|
171
|
-
handlerName: handler.handlerName,
|
172
|
-
minutes: 0,
|
173
|
-
minutesInterval: handler.timeIntervalInMinutes,
|
174
|
-
slot: 0,
|
175
|
-
slotInterval: handler.checkPointInterval,
|
176
|
-
fetchConfig: undefined
|
177
|
-
},
|
178
|
-
type: handler.type || '',
|
179
|
-
ownerType: processor.ownerType,
|
180
|
-
resourceFetchConfig: handler.fetchConfig,
|
181
|
-
fetchConfig: undefined
|
182
|
-
})
|
183
|
-
}
|
184
|
-
|
185
|
-
if (processor instanceof SuiAddressProcessor) {
|
186
|
-
for (const handler of processor.callHandlers) {
|
187
|
-
const handlerId = this.handlerRegister.register(handler.handler, chainId)
|
188
|
-
const functionHandlerConfig: MoveCallHandlerConfig = {
|
189
|
-
filters: handler.filters.map((filter) => {
|
190
|
-
return {
|
191
|
-
function: filter.function,
|
192
|
-
typeArguments: filter.typeArguments || [],
|
193
|
-
withTypeArguments: !!filter.typeArguments,
|
194
|
-
includeFailed: filter.includeFailed || false,
|
195
|
-
publicKeyPrefix: filter.publicKeyPrefix || '',
|
196
|
-
fromAndToAddress: filter.fromAndToAddress
|
197
|
-
}
|
198
|
-
}),
|
199
|
-
fetchConfig: handler.fetchConfig,
|
200
|
-
handlerId,
|
201
|
-
handlerName: handler.handlerName
|
202
|
-
}
|
203
|
-
accountConfig.moveCallConfigs.push(functionHandlerConfig)
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
config.accountConfigs.push(accountConfig)
|
208
|
-
}
|
41
|
+
await this.suiPart.configure(config)
|
42
|
+
await this.iotaPart.configure(config)
|
209
43
|
}
|
210
44
|
|
211
45
|
supportedHandlers = [
|
@@ -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
|
+
}
|
@@ -31,6 +31,7 @@ import { BTCFacet } from './btc-facet.js'
|
|
31
31
|
import { Subject } from 'rxjs'
|
32
32
|
import { MemoryDatabase } from './memory-database.js'
|
33
33
|
import { DatabaseSchemaState } from '../core/database-schema.js'
|
34
|
+
import { IotaFacet } from './iota-facet.js'
|
34
35
|
|
35
36
|
export const TEST_CONTEXT: CallContext = <CallContext>{}
|
36
37
|
|
@@ -51,6 +52,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
51
52
|
eth: EthFacet
|
52
53
|
solana: SolanaFacet
|
53
54
|
sui: SuiFacet
|
55
|
+
iota: IotaFacet
|
54
56
|
fuel: FuelFacet
|
55
57
|
cosmos: CosmosFacet
|
56
58
|
starknet: StarknetFacet
|
@@ -65,6 +67,7 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
65
67
|
this.solana = new SolanaFacet(this)
|
66
68
|
this.eth = new EthFacet(this)
|
67
69
|
this.sui = new SuiFacet(this)
|
70
|
+
this.iota = new IotaFacet(this)
|
68
71
|
this.fuel = new FuelFacet(this)
|
69
72
|
this.cosmos = new CosmosFacet(this)
|
70
73
|
this.starknet = new StarknetFacet(this)
|