@sentio/sdk 2.54.3-rc.1 → 2.55.0-rc.2
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-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +22 -27
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/fuel/asset-processor.d.ts +1 -1
- package/lib/fuel/asset-processor.d.ts.map +1 -1
- package/lib/fuel/asset-processor.js +2 -2
- package/lib/fuel/asset-processor.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +2 -2
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +7 -8
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +1 -1
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +3 -3
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/global-processor.d.ts +1 -1
- package/lib/fuel/global-processor.d.ts.map +1 -1
- package/lib/fuel/global-processor.js +2 -2
- package/lib/fuel/global-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +2 -2
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +2 -2
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +10 -10
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +5 -5
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +15 -27
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js +5 -5
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +2 -13
- package/lib/testing/fuel-facet.js.map +1 -1
- package/lib/testing/sui-facet.d.ts.map +1 -1
- package/lib/testing/sui-facet.js +4 -3
- package/lib/testing/sui-facet.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/aptos-processor.ts +38 -37
- package/src/fuel/asset-processor.ts +2 -2
- package/src/fuel/fuel-plugin.ts +9 -10
- package/src/fuel/fuel-processor.ts +3 -3
- package/src/fuel/global-processor.ts +2 -2
- package/src/fuel/types.ts +2 -2
- package/src/sui/sui-object-processor.ts +16 -12
- package/src/sui/sui-processor.ts +29 -42
- package/src/testing/aptos-facet.ts +5 -5
- package/src/testing/fuel-facet.ts +2 -12
- package/src/testing/sui-facet.ts +4 -3
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
|
11
11
|
import { AptosBindOptions, AptosNetwork } from './network.js'
|
12
12
|
import { AptosContext, AptosResourcesContext, AptosTransactionContext } from './context.js'
|
13
|
-
import { ListStateStorage
|
13
|
+
import { ListStateStorage } from '@sentio/runtime'
|
14
14
|
import {
|
15
15
|
MoveFetchConfig,
|
16
16
|
Data_AptResource,
|
@@ -81,7 +81,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
81
81
|
}
|
82
82
|
|
83
83
|
protected onMoveEvent(
|
84
|
-
handler: (event: Event, ctx: AptosContext) =>
|
84
|
+
handler: (event: Event, ctx: AptosContext) => PromiseOrVoid,
|
85
85
|
filter: EventFilter | EventFilter[],
|
86
86
|
fetchConfig?: Partial<MoveFetchConfig>
|
87
87
|
): this {
|
@@ -97,42 +97,34 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
97
97
|
// const moduleName = this.moduleName
|
98
98
|
|
99
99
|
const processor = this
|
100
|
-
const allEventType = new Set(_filters.map((f) => accountTypeString(processor.config.address) + '::' + f.type))
|
101
100
|
|
102
101
|
this.eventHandlers.push({
|
103
102
|
handlerName: getHandlerName(),
|
104
103
|
handler: async function (data) {
|
105
|
-
if (!data.
|
104
|
+
if (!data.rawTransaction) {
|
106
105
|
throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
|
107
106
|
}
|
108
|
-
const txn = data.
|
107
|
+
const txn = JSON.parse(data.rawTransaction) as UserTransactionResponse
|
109
108
|
if (!txn.events.length) {
|
110
109
|
throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
|
111
110
|
}
|
112
111
|
|
113
|
-
const
|
114
|
-
for (const [idx, evt] of txn.events.entries()) {
|
115
|
-
const typeQname = parseMoveType(evt.type).qname
|
116
|
-
if (!allEventType.has(typeQname)) {
|
117
|
-
continue
|
118
|
-
}
|
112
|
+
const evt = JSON.parse(data.rawEvent)
|
119
113
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
processResults.push(ctx.stopAndGetResult())
|
133
|
-
}
|
114
|
+
const ctx = new AptosContext(
|
115
|
+
processor.moduleName,
|
116
|
+
processor.config.network,
|
117
|
+
processor.config.address,
|
118
|
+
BigInt(txn.version),
|
119
|
+
txn,
|
120
|
+
data.eventIndex,
|
121
|
+
processor.config.baseLabels
|
122
|
+
)
|
123
|
+
|
124
|
+
const decoded = await processor.coder.decodeEvent<any>(evt)
|
125
|
+
await handler(decoded || evt, ctx)
|
134
126
|
|
135
|
-
return
|
127
|
+
return ctx.stopAndGetResult()
|
136
128
|
},
|
137
129
|
filters: _filters,
|
138
130
|
fetchConfig: _fetchConfig
|
@@ -161,10 +153,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
161
153
|
this.callHandlers.push({
|
162
154
|
handlerName: getHandlerName(),
|
163
155
|
handler: async function (data) {
|
164
|
-
if (!data.
|
156
|
+
if (!data.rawTransaction) {
|
165
157
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
166
158
|
}
|
167
|
-
const tx = data.
|
159
|
+
const tx = JSON.parse(data.rawTransaction) as UserTransactionResponse
|
168
160
|
|
169
161
|
const ctx = new AptosContext(
|
170
162
|
processor.moduleName,
|
@@ -203,15 +195,15 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
203
195
|
this.callHandlers.push({
|
204
196
|
handlerName: getHandlerName(),
|
205
197
|
handler: async function (data) {
|
206
|
-
if (!data.
|
198
|
+
if (!data.rawTransaction) {
|
207
199
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
208
200
|
}
|
209
|
-
const call = data.
|
201
|
+
const call = JSON.parse(data.rawTransaction) as UserTransactionResponse
|
210
202
|
const ctx = new AptosContext(
|
211
203
|
processor.moduleName,
|
212
204
|
processor.config.network,
|
213
205
|
processor.config.address,
|
214
|
-
BigInt(
|
206
|
+
BigInt(call.version),
|
215
207
|
call,
|
216
208
|
0,
|
217
209
|
processor.config.baseLabels
|
@@ -244,7 +236,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
244
236
|
this.resourceChangeHandlers.push({
|
245
237
|
handlerName: getHandlerName(),
|
246
238
|
handler: async function (data) {
|
247
|
-
if (!data.
|
239
|
+
if (!data.rawResources || !data.version) {
|
248
240
|
throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
|
249
241
|
}
|
250
242
|
const timestamp = Number(data.timestampMicros)
|
@@ -255,7 +247,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
255
247
|
timestamp,
|
256
248
|
processor.config.baseLabels
|
257
249
|
)
|
258
|
-
let resources = await decodeResourceChange<T>(
|
250
|
+
let resources = await decodeResourceChange<T>(
|
251
|
+
data.rawResources.map((r) => JSON.parse(r)),
|
252
|
+
ctx.coder
|
253
|
+
)
|
259
254
|
|
260
255
|
if (hasAny) {
|
261
256
|
resources = resources.filter((r) => {
|
@@ -284,7 +279,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
284
279
|
this.transactionIntervalHandlers.push({
|
285
280
|
handlerName: getHandlerName(),
|
286
281
|
handler: async function (data) {
|
287
|
-
|
282
|
+
if (!data.rawTransaction) {
|
283
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
284
|
+
}
|
285
|
+
const transaction = JSON.parse(data.rawTransaction) as T
|
288
286
|
const timestampMicros = BigInt(transaction.timestamp)
|
289
287
|
if (timestampMicros > Number.MAX_SAFE_INTEGER) {
|
290
288
|
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
@@ -455,7 +453,7 @@ export class AptosResourcesProcessor {
|
|
455
453
|
timestamp,
|
456
454
|
processor.config.baseLabels
|
457
455
|
)
|
458
|
-
await handler(data.
|
456
|
+
await handler(data.rawResources.map((r) => JSON.parse(r)) as MoveResource[], ctx)
|
459
457
|
return ctx.stopAndGetResult()
|
460
458
|
},
|
461
459
|
timeIntervalInMinutes: timeInterval,
|
@@ -518,7 +516,7 @@ export class AptosResourcesProcessor {
|
|
518
516
|
handler: async function (data) {
|
519
517
|
const timestamp = Number(data.timestampMicros)
|
520
518
|
|
521
|
-
if (!data.
|
519
|
+
if (!data.rawResources || !data.version) {
|
522
520
|
throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
|
523
521
|
}
|
524
522
|
const ctx = new AptosResourcesContext(
|
@@ -529,7 +527,10 @@ export class AptosResourcesProcessor {
|
|
529
527
|
processor.config.baseLabels
|
530
528
|
)
|
531
529
|
|
532
|
-
let resources = (await decodeResourceChange(
|
530
|
+
let resources = (await decodeResourceChange(
|
531
|
+
data.rawResources.map((r) => JSON.parse(r)),
|
532
|
+
ctx.coder
|
533
|
+
)) as ResourceChange<T>[]
|
533
534
|
|
534
535
|
if (hasAny) {
|
535
536
|
resources = resources.filter((r) => {
|
@@ -8,7 +8,7 @@ import { getOptionsSignature } from './fuel-processor.js'
|
|
8
8
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
9
9
|
|
10
10
|
export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
|
11
|
-
|
11
|
+
txHandlers: CallHandler<Data_FuelCall>[] = []
|
12
12
|
blockHandlers = []
|
13
13
|
private provider: Provider
|
14
14
|
|
@@ -99,7 +99,7 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
|
|
99
99
|
filters
|
100
100
|
}
|
101
101
|
}
|
102
|
-
this.
|
102
|
+
this.txHandlers.push(callHandler)
|
103
103
|
return this
|
104
104
|
}
|
105
105
|
}
|
package/src/fuel/fuel-plugin.ts
CHANGED
@@ -2,8 +2,8 @@ import { errorString, GLOBAL_CONFIG, mergeProcessResults, Plugin, PluginManager,
|
|
2
2
|
import {
|
3
3
|
ContractConfig,
|
4
4
|
Data_FuelBlock,
|
5
|
-
Data_FuelCall,
|
6
5
|
Data_FuelReceipt,
|
6
|
+
Data_FuelTransaction,
|
7
7
|
DataBinding,
|
8
8
|
HandlerType,
|
9
9
|
ProcessConfigResponse,
|
@@ -19,7 +19,7 @@ import { FuelProcessor } from './fuel-processor.js'
|
|
19
19
|
import { FuelGlobalProcessor } from './global-processor.js'
|
20
20
|
|
21
21
|
interface Handlers {
|
22
|
-
transactionHandlers: ((trace:
|
22
|
+
transactionHandlers: ((trace: Data_FuelTransaction) => Promise<ProcessResult>)[]
|
23
23
|
blockHandlers: ((block: Data_FuelBlock) => Promise<ProcessResult>)[]
|
24
24
|
logHandlers: ((log: Data_FuelReceipt) => Promise<ProcessResult>)[]
|
25
25
|
}
|
@@ -51,19 +51,18 @@ export class FuelPlugin extends Plugin {
|
|
51
51
|
startBlock: processor.config.startBlock,
|
52
52
|
endBlock: processor.config.endBlock
|
53
53
|
})
|
54
|
-
for (const
|
55
|
-
const handlerId = handlers.transactionHandlers.push(
|
56
|
-
const handlerName =
|
54
|
+
for (const txHandler of processor.txHandlers) {
|
55
|
+
const handlerId = handlers.transactionHandlers.push(txHandler.handler) - 1
|
56
|
+
const handlerName = txHandler.handlerName
|
57
57
|
if (processor instanceof FuelProcessor) {
|
58
58
|
// on transaction
|
59
59
|
const fetchConfig = {
|
60
60
|
handlerId,
|
61
|
-
handlerName
|
62
|
-
filters: callHandler.fetchConfig?.filters || []
|
61
|
+
handlerName
|
63
62
|
}
|
64
|
-
contractConfig.
|
63
|
+
contractConfig.fuelTransactionConfigs.push(fetchConfig)
|
65
64
|
} else if (processor instanceof FuelAssetProcessor) {
|
66
|
-
const assetConfig =
|
65
|
+
const assetConfig = txHandler.assetConfig
|
67
66
|
contractConfig.assetConfigs.push({
|
68
67
|
filters: assetConfig?.filters || [],
|
69
68
|
handlerId,
|
@@ -75,7 +74,7 @@ export class FuelPlugin extends Plugin {
|
|
75
74
|
handlerName,
|
76
75
|
filters: []
|
77
76
|
}
|
78
|
-
contractConfig.
|
77
|
+
contractConfig.fuelTransactionConfigs.push(fetchConfig)
|
79
78
|
contractConfig.contract!.address = '*'
|
80
79
|
}
|
81
80
|
}
|
@@ -31,7 +31,7 @@ import { ServerError, Status } from 'nice-grpc'
|
|
31
31
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
32
32
|
|
33
33
|
export class FuelProcessor<TContract extends Contract> implements FuelBaseProcessor<FuelProcessorConfig> {
|
34
|
-
|
34
|
+
txHandlers: CallHandler<Data_FuelCall>[] = []
|
35
35
|
blockHandlers: BlockHandler[] = []
|
36
36
|
logHandlers: LogHandler<Data_FuelReceipt>[] = []
|
37
37
|
|
@@ -96,7 +96,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
96
96
|
...config
|
97
97
|
}
|
98
98
|
}
|
99
|
-
this.
|
99
|
+
this.txHandlers.push(callHandler)
|
100
100
|
return this
|
101
101
|
}
|
102
102
|
|
@@ -174,7 +174,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
174
174
|
filters: Object.values(filters)
|
175
175
|
}
|
176
176
|
}
|
177
|
-
this.
|
177
|
+
this.txHandlers.push(callHandler)
|
178
178
|
return this
|
179
179
|
}
|
180
180
|
|
@@ -12,7 +12,7 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
12
12
|
type GlobalFuelProcessorConfig = Omit<FuelProcessorConfig, 'address' | 'abi'>
|
13
13
|
|
14
14
|
export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcessorConfig> {
|
15
|
-
|
15
|
+
txHandlers: CallHandler<Data_FuelCall>[] = []
|
16
16
|
blockHandlers = []
|
17
17
|
|
18
18
|
private provider: Provider
|
@@ -67,7 +67,7 @@ export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcesso
|
|
67
67
|
...config
|
68
68
|
}
|
69
69
|
}
|
70
|
-
this.
|
70
|
+
this.txHandlers.push(callHandler)
|
71
71
|
return this
|
72
72
|
}
|
73
73
|
}
|
package/src/fuel/types.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { MapStateStorage } from '@sentio/runtime'
|
2
2
|
import {
|
3
3
|
Data_FuelBlock,
|
4
|
-
Data_FuelCall,
|
5
4
|
Data_FuelReceipt,
|
5
|
+
Data_FuelTransaction,
|
6
6
|
FuelAssetHandlerConfig,
|
7
7
|
FuelCallHandlerConfig,
|
8
8
|
HandleInterval,
|
@@ -14,7 +14,7 @@ import { Block, TransactionSummary } from 'fuels'
|
|
14
14
|
export interface FuelBaseProcessor<T> {
|
15
15
|
configure(): Promise<void>
|
16
16
|
config: T
|
17
|
-
|
17
|
+
txHandlers: CallHandler<Data_FuelTransaction>[]
|
18
18
|
blockHandlers: BlockHandler[]
|
19
19
|
logHandlers?: LogHandler<Data_FuelReceipt>[]
|
20
20
|
}
|
@@ -176,11 +176,11 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
|
|
176
176
|
data: Data_SuiObject,
|
177
177
|
ctx: SuiObjectContext
|
178
178
|
) {
|
179
|
-
return handler(data.
|
179
|
+
return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
|
180
180
|
}
|
181
181
|
|
182
182
|
onTransactionBlock(
|
183
|
-
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) =>
|
183
|
+
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
|
184
184
|
filter?: TransactionFilter,
|
185
185
|
fetchConfig?: Partial<MoveFetchConfig>
|
186
186
|
) {
|
@@ -198,10 +198,10 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
|
|
198
198
|
this.callHandlers.push({
|
199
199
|
handlerName: getHandlerName(),
|
200
200
|
handler: async function (data) {
|
201
|
-
if (!data.
|
201
|
+
if (!data.rawTransaction) {
|
202
202
|
throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
|
203
203
|
}
|
204
|
-
const tx = data.
|
204
|
+
const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
205
205
|
|
206
206
|
const ctx = new SuiContext(
|
207
207
|
'object',
|
@@ -243,11 +243,15 @@ export class SuiObjectProcessor extends SuiBaseObjectOrAddressProcessorInternal<
|
|
243
243
|
data: Data_SuiObject,
|
244
244
|
ctx: SuiObjectContext
|
245
245
|
) {
|
246
|
-
if (!data.
|
246
|
+
if (!data.rawSelf) {
|
247
247
|
console.log(`Sui object not existed in ${ctx.checkpoint}, please specific a start time`)
|
248
248
|
return
|
249
249
|
}
|
250
|
-
return handler(
|
250
|
+
return handler(
|
251
|
+
JSON.parse(data.rawSelf) as SuiMoveObject,
|
252
|
+
data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[],
|
253
|
+
ctx
|
254
|
+
)
|
251
255
|
}
|
252
256
|
}
|
253
257
|
|
@@ -277,15 +281,15 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
|
|
277
281
|
data: Data_SuiObject,
|
278
282
|
ctx: SuiObjectContext
|
279
283
|
) {
|
280
|
-
if (!data.
|
284
|
+
if (!data.rawSelf) {
|
281
285
|
console.log(`Sui object not existed in ${ctx.checkpoint}, please specific a start time`)
|
282
286
|
return
|
283
287
|
}
|
284
|
-
const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [data.
|
285
|
-
return handler(object[0], data.
|
288
|
+
const object = await ctx.coder.filterAndDecodeObjects(this.objectType, [JSON.parse(data.rawSelf) as SuiMoveObject])
|
289
|
+
return handler(object[0], data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
|
286
290
|
}
|
287
291
|
|
288
|
-
public onObjectChange(handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) =>
|
292
|
+
public onObjectChange(handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) => PromiseOrVoid): this {
|
289
293
|
if (this.config.network === SuiNetwork.TEST_NET) {
|
290
294
|
throw new ServerError(Status.INVALID_ARGUMENT, 'object change not supported in testnet')
|
291
295
|
}
|
@@ -301,7 +305,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
|
|
301
305
|
data.txDigest,
|
302
306
|
processor.config.baseLabels
|
303
307
|
)
|
304
|
-
await handler(data.
|
308
|
+
await handler(data.rawChanges.map((r) => JSON.parse(r)) as SuiObjectChange[], ctx)
|
305
309
|
return ctx.stopAndGetResult()
|
306
310
|
},
|
307
311
|
type: this.objectType.qname
|
@@ -370,6 +374,6 @@ export class SuiWrappedObjectProcessor extends SuiBaseObjectOrAddressProcessorIn
|
|
370
374
|
data: Data_SuiObject,
|
371
375
|
ctx: SuiObjectContext
|
372
376
|
) {
|
373
|
-
return handler(data.
|
377
|
+
return handler(data.rawObjects.map((o) => JSON.parse(o)) as SuiMoveObject[], ctx)
|
374
378
|
}
|
375
379
|
}
|
package/src/sui/sui-processor.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Data_SuiCall, Data_SuiEvent, Data_SuiObjectChange, MoveFetchConfig } from '@sentio/protos'
|
2
|
-
import { ListStateStorage
|
2
|
+
import { ListStateStorage } from '@sentio/runtime'
|
3
3
|
import { SuiNetwork } from './network.js'
|
4
4
|
import { ServerError, Status } from 'nice-grpc'
|
5
5
|
import { SuiContext, SuiObjectChangeContext } from './context.js'
|
@@ -11,13 +11,12 @@ import {
|
|
11
11
|
EventHandler,
|
12
12
|
FunctionNameAndCallFilter,
|
13
13
|
ObjectChangeHandler,
|
14
|
-
parseMoveType,
|
15
14
|
SPLITTER,
|
16
15
|
TransactionFilter
|
17
16
|
} from '../move/index.js'
|
18
17
|
import { getMoveCalls } from './utils.js'
|
19
18
|
import { defaultMoveCoder, MoveCoder } from './index.js'
|
20
|
-
import { ALL_ADDRESS, Labels } from '../core/index.js'
|
19
|
+
import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
|
21
20
|
import { Required } from 'utility-types'
|
22
21
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
23
22
|
|
@@ -73,7 +72,7 @@ export class SuiBaseProcessor {
|
|
73
72
|
}
|
74
73
|
|
75
74
|
protected onMoveEvent(
|
76
|
-
handler: (event: SuiEvent, ctx: SuiContext) =>
|
75
|
+
handler: (event: SuiEvent, ctx: SuiContext) => PromiseOrVoid,
|
77
76
|
filter: EventFilter | EventFilter[],
|
78
77
|
fetchConfig?: Partial<MoveFetchConfig>
|
79
78
|
): SuiBaseProcessor {
|
@@ -90,48 +89,36 @@ export class SuiBaseProcessor {
|
|
90
89
|
// const moduleName = this.moduleName
|
91
90
|
|
92
91
|
const processor = this
|
93
|
-
const allEventType = new Set(_filters.map((f) => f.type))
|
94
92
|
|
95
93
|
this.eventHandlers.push({
|
96
94
|
handlerName: getHandlerName(),
|
97
95
|
handler: async function (data) {
|
98
|
-
if (!data.
|
96
|
+
if (!data.rawTransaction) {
|
99
97
|
throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
|
100
98
|
}
|
101
|
-
const txn = data.
|
99
|
+
const txn = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
102
100
|
if (!txn.events || !txn.events.length) {
|
103
101
|
throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
|
104
102
|
}
|
105
103
|
|
106
|
-
const
|
107
|
-
|
108
|
-
const idx = Number(evt.id.eventSeq) || 0
|
109
|
-
const [_, module, type] = parseMoveType(evt.type).qname.split(SPLITTER)
|
110
|
-
if (!allEventType.has([module, type].join(SPLITTER))) {
|
111
|
-
continue
|
112
|
-
}
|
104
|
+
const evt = JSON.parse(data.rawEvent) as SuiEvent
|
105
|
+
const idx = Number(evt.id.eventSeq) || 0
|
113
106
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
// evt.type = evt.type.replace(parts[0], evt.packageId)
|
128
|
-
// }
|
129
|
-
const decoded = await processor.coder.decodeEvent<any>(evt)
|
130
|
-
await handler(decoded || evt, ctx)
|
131
|
-
processResults.push(ctx.stopAndGetResult())
|
132
|
-
}
|
107
|
+
const ctx = new SuiContext(
|
108
|
+
processor.moduleName,
|
109
|
+
processor.config.network,
|
110
|
+
processor.config.address,
|
111
|
+
data.timestamp || new Date(0),
|
112
|
+
data.slot,
|
113
|
+
txn,
|
114
|
+
idx,
|
115
|
+
processor.config.baseLabels
|
116
|
+
)
|
117
|
+
|
118
|
+
const decoded = await processor.coder.decodeEvent<any>(evt)
|
119
|
+
await handler(decoded || evt, ctx)
|
133
120
|
|
134
|
-
return
|
121
|
+
return ctx.stopAndGetResult()
|
135
122
|
},
|
136
123
|
filters: _filters,
|
137
124
|
fetchConfig: _fetchConfig
|
@@ -140,7 +127,7 @@ export class SuiBaseProcessor {
|
|
140
127
|
}
|
141
128
|
|
142
129
|
protected onEntryFunctionCall(
|
143
|
-
handler: (call: MoveCallSuiTransaction, ctx: SuiContext) =>
|
130
|
+
handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => PromiseOrVoid,
|
144
131
|
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
|
145
132
|
fetchConfig?: Partial<MoveFetchConfig>
|
146
133
|
): SuiBaseProcessor {
|
@@ -159,10 +146,10 @@ export class SuiBaseProcessor {
|
|
159
146
|
this.callHandlers.push({
|
160
147
|
handlerName: getHandlerName(),
|
161
148
|
handler: async function (data) {
|
162
|
-
if (!data.
|
149
|
+
if (!data.rawTransaction) {
|
163
150
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
164
151
|
}
|
165
|
-
const tx = data.
|
152
|
+
const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
166
153
|
|
167
154
|
const ctx = new SuiContext(
|
168
155
|
processor.moduleName,
|
@@ -210,7 +197,7 @@ export class SuiBaseProcessor {
|
|
210
197
|
}
|
211
198
|
|
212
199
|
onTransactionBlock(
|
213
|
-
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) =>
|
200
|
+
handler: (transaction: SuiTransactionBlockResponse, ctx: SuiContext) => PromiseOrVoid,
|
214
201
|
filter?: TransactionFilter,
|
215
202
|
fetchConfig?: Partial<MoveFetchConfig>
|
216
203
|
): this {
|
@@ -221,10 +208,10 @@ export class SuiBaseProcessor {
|
|
221
208
|
this.callHandlers.push({
|
222
209
|
handlerName: getHandlerName(),
|
223
210
|
handler: async function (data) {
|
224
|
-
if (!data.
|
211
|
+
if (!data.rawTransaction) {
|
225
212
|
throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
|
226
213
|
}
|
227
|
-
const tx = data.
|
214
|
+
const tx = JSON.parse(data.rawTransaction) as SuiTransactionBlockResponse
|
228
215
|
|
229
216
|
const ctx = new SuiContext(
|
230
217
|
processor.moduleName,
|
@@ -248,7 +235,7 @@ export class SuiBaseProcessor {
|
|
248
235
|
}
|
249
236
|
|
250
237
|
protected onObjectChange(
|
251
|
-
handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) =>
|
238
|
+
handler: (changes: SuiObjectChange[], ctx: SuiObjectChangeContext) => PromiseOrVoid,
|
252
239
|
type: string
|
253
240
|
): this {
|
254
241
|
if (this.config.network === SuiNetwork.TEST_NET) {
|
@@ -266,7 +253,7 @@ export class SuiBaseProcessor {
|
|
266
253
|
data.txDigest,
|
267
254
|
processor.config.baseLabels
|
268
255
|
)
|
269
|
-
await handler(data.
|
256
|
+
await handler(data.rawChanges.map((r) => JSON.parse(r)) as SuiObjectChange[], ctx)
|
270
257
|
return ctx.stopAndGetResult()
|
271
258
|
},
|
272
259
|
type
|
@@ -43,8 +43,7 @@ export class AptosFacet {
|
|
43
43
|
return {
|
44
44
|
data: {
|
45
45
|
aptCall: {
|
46
|
-
rawTransaction:
|
47
|
-
transaction
|
46
|
+
rawTransaction: JSON.stringify(transaction)
|
48
47
|
}
|
49
48
|
},
|
50
49
|
handlerIds: [callConfig.handlerId],
|
@@ -76,7 +75,7 @@ export class AptosFacet {
|
|
76
75
|
}
|
77
76
|
for (const eventConfig of config.moveEventConfigs) {
|
78
77
|
for (const eventFilter of eventConfig.filters) {
|
79
|
-
for (const event of transaction.events) {
|
78
|
+
for (const [idx, event] of transaction.events.entries()) {
|
80
79
|
if (
|
81
80
|
accountTypeString(config.contract.address) + '::' + eventFilter.type ===
|
82
81
|
parseMoveType(event.type).qname
|
@@ -84,8 +83,9 @@ export class AptosFacet {
|
|
84
83
|
return {
|
85
84
|
data: {
|
86
85
|
aptEvent: {
|
87
|
-
|
88
|
-
|
86
|
+
rawEvent: JSON.stringify(event),
|
87
|
+
eventIndex: idx,
|
88
|
+
rawTransaction: JSON.stringify(transaction)
|
89
89
|
}
|
90
90
|
},
|
91
91
|
handlerIds: [eventConfig.handlerId],
|
@@ -27,7 +27,7 @@ export class FuelFacet {
|
|
27
27
|
if (config.contract?.chainId !== network) {
|
28
28
|
continue
|
29
29
|
}
|
30
|
-
for (const callConfig of config.
|
30
|
+
for (const callConfig of config.fuelTransactionConfigs) {
|
31
31
|
const binding = {
|
32
32
|
data: {
|
33
33
|
fuelTransaction: {
|
@@ -39,17 +39,7 @@ export class FuelFacet {
|
|
39
39
|
handlerType: HandlerType.FUEL_TRANSACTION
|
40
40
|
}
|
41
41
|
|
42
|
-
|
43
|
-
if (filter) {
|
44
|
-
// filter out by tx receipt
|
45
|
-
for (const receipt of transaction.status.receipts || []) {
|
46
|
-
if (receipt.receiptType == 'CALL' && receipt.param1 == filter) {
|
47
|
-
res.push(binding)
|
48
|
-
}
|
49
|
-
}
|
50
|
-
} else {
|
51
|
-
res.push(binding)
|
52
|
-
}
|
42
|
+
res.push(binding)
|
53
43
|
}
|
54
44
|
|
55
45
|
for (const logConfig of config.fuelLogConfigs) {
|
package/src/testing/sui-facet.ts
CHANGED
@@ -50,7 +50,7 @@ export class SuiFacet {
|
|
50
50
|
return {
|
51
51
|
data: {
|
52
52
|
suiCall: {
|
53
|
-
transaction,
|
53
|
+
rawTransaction: JSON.stringify(transaction),
|
54
54
|
timestamp: new Date(),
|
55
55
|
slot: 10000n
|
56
56
|
}
|
@@ -95,7 +95,7 @@ export class SuiFacet {
|
|
95
95
|
handlerType: HandlerType.SUI_CALL,
|
96
96
|
data: {
|
97
97
|
suiCall: {
|
98
|
-
transaction,
|
98
|
+
rawTransaction: JSON.stringify(transaction),
|
99
99
|
timestamp: transaction.timestampMs ? new Date(transaction.timestampMs) : new Date(),
|
100
100
|
slot: BigInt(transaction.checkpoint || 0)
|
101
101
|
}
|
@@ -124,7 +124,8 @@ export class SuiFacet {
|
|
124
124
|
return {
|
125
125
|
data: {
|
126
126
|
suiEvent: {
|
127
|
-
|
127
|
+
rawEvent: JSON.stringify(event),
|
128
|
+
rawTransaction: JSON.stringify(transaction),
|
128
129
|
timestamp: new Date(transaction.timestampMs || 0),
|
129
130
|
slot: 10000n
|
130
131
|
}
|