@sentio/sdk 2.12.3 → 2.13.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.
Files changed (43) hide show
  1. package/lib/aptos/aptos-processor.d.ts +3 -3
  2. package/lib/aptos/aptos-processor.js +17 -12
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/aptos/builtin/0x1.d.ts +168 -168
  5. package/lib/aptos/builtin/0x1.js.map +1 -1
  6. package/lib/aptos/builtin/0x3.d.ts +35 -35
  7. package/lib/aptos/builtin/0x3.js.map +1 -1
  8. package/lib/aptos/context.d.ts +2 -1
  9. package/lib/aptos/context.js +4 -2
  10. package/lib/aptos/context.js.map +1 -1
  11. package/lib/move/abstract-codegen.js +2 -2
  12. package/lib/move/abstract-codegen.js.map +1 -1
  13. package/lib/sui/builtin/0x1.d.ts +6 -6
  14. package/lib/sui/builtin/0x1.js.map +1 -1
  15. package/lib/sui/builtin/0x2.d.ts +43 -43
  16. package/lib/sui/builtin/0x2.js.map +1 -1
  17. package/lib/sui/builtin/0x3.d.ts +43 -43
  18. package/lib/sui/builtin/0x3.js.map +1 -1
  19. package/lib/sui/context.d.ts +2 -1
  20. package/lib/sui/context.js +3 -1
  21. package/lib/sui/context.js.map +1 -1
  22. package/lib/sui/sui-processor.d.ts +2 -2
  23. package/lib/sui/sui-processor.js +15 -12
  24. package/lib/sui/sui-processor.js.map +1 -1
  25. package/lib/testing/aptos-facet.d.ts +2 -2
  26. package/lib/testing/aptos-facet.js +14 -21
  27. package/lib/testing/aptos-facet.js.map +1 -1
  28. package/lib/testing/sui-facet.d.ts +2 -2
  29. package/lib/testing/sui-facet.js +16 -26
  30. package/lib/testing/sui-facet.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/aptos/aptos-processor.ts +30 -23
  33. package/src/aptos/builtin/0x1.ts +168 -168
  34. package/src/aptos/builtin/0x3.ts +35 -35
  35. package/src/aptos/context.ts +5 -2
  36. package/src/move/abstract-codegen.ts +2 -2
  37. package/src/sui/builtin/0x1.ts +6 -6
  38. package/src/sui/builtin/0x2.ts +43 -43
  39. package/src/sui/builtin/0x3.ts +43 -43
  40. package/src/sui/context.ts +4 -1
  41. package/src/sui/sui-processor.ts +27 -22
  42. package/src/testing/aptos-facet.ts +13 -27
  43. package/src/testing/sui-facet.ts +15 -30
@@ -39,7 +39,7 @@ export class genesis extends SuiBaseProcessor {
39
39
  event: genesis.GenesisChainParametersInstance,
40
40
  ctx: SuiContext
41
41
  ) => void,
42
- fetchConfig?: MoveFetchConfig
42
+ fetchConfig?: Partial<MoveFetchConfig>
43
43
  ): genesis {
44
44
  this.onMoveEvent(
45
45
  func,
@@ -56,7 +56,7 @@ export class genesis extends SuiBaseProcessor {
56
56
  event: genesis.GenesisValidatorMetadataInstance,
57
57
  ctx: SuiContext
58
58
  ) => void,
59
- fetchConfig?: MoveFetchConfig
59
+ fetchConfig?: Partial<MoveFetchConfig>
60
60
  ): genesis {
61
61
  this.onMoveEvent(
62
62
  func,
@@ -159,7 +159,7 @@ export class staking_pool extends SuiBaseProcessor {
159
159
  onEntryJoinStakedSui(
160
160
  func: (call: staking_pool.JoinStakedSuiPayload, ctx: SuiContext) => void,
161
161
  filter?: CallFilter,
162
- fetchConfig?: MoveFetchConfig
162
+ fetchConfig?: Partial<MoveFetchConfig>
163
163
  ): staking_pool {
164
164
  this.onEntryFunctionCall(
165
165
  func,
@@ -175,7 +175,7 @@ export class staking_pool extends SuiBaseProcessor {
175
175
  onEntrySplitStakedSui(
176
176
  func: (call: staking_pool.SplitStakedSuiPayload, ctx: SuiContext) => void,
177
177
  filter?: CallFilter,
178
- fetchConfig?: MoveFetchConfig
178
+ fetchConfig?: Partial<MoveFetchConfig>
179
179
  ): staking_pool {
180
180
  this.onEntryFunctionCall(
181
181
  func,
@@ -193,7 +193,7 @@ export class staking_pool extends SuiBaseProcessor {
193
193
  event: staking_pool.PoolTokenExchangeRateInstance,
194
194
  ctx: SuiContext
195
195
  ) => void,
196
- fetchConfig?: MoveFetchConfig
196
+ fetchConfig?: Partial<MoveFetchConfig>
197
197
  ): staking_pool {
198
198
  this.onMoveEvent(
199
199
  func,
@@ -282,7 +282,7 @@ export class sui_system extends SuiBaseProcessor {
282
282
  onEntryReportValidator(
283
283
  func: (call: sui_system.ReportValidatorPayload, ctx: SuiContext) => void,
284
284
  filter?: CallFilter,
285
- fetchConfig?: MoveFetchConfig
285
+ fetchConfig?: Partial<MoveFetchConfig>
286
286
  ): sui_system {
287
287
  this.onEntryFunctionCall(
288
288
  func,
@@ -298,7 +298,7 @@ export class sui_system extends SuiBaseProcessor {
298
298
  onEntryRequestAddStake(
299
299
  func: (call: sui_system.RequestAddStakePayload, ctx: SuiContext) => void,
300
300
  filter?: CallFilter,
301
- fetchConfig?: MoveFetchConfig
301
+ fetchConfig?: Partial<MoveFetchConfig>
302
302
  ): sui_system {
303
303
  this.onEntryFunctionCall(
304
304
  func,
@@ -317,7 +317,7 @@ export class sui_system extends SuiBaseProcessor {
317
317
  ctx: SuiContext
318
318
  ) => void,
319
319
  filter?: CallFilter,
320
- fetchConfig?: MoveFetchConfig
320
+ fetchConfig?: Partial<MoveFetchConfig>
321
321
  ): sui_system {
322
322
  this.onEntryFunctionCall(
323
323
  func,
@@ -336,7 +336,7 @@ export class sui_system extends SuiBaseProcessor {
336
336
  ctx: SuiContext
337
337
  ) => void,
338
338
  filter?: CallFilter,
339
- fetchConfig?: MoveFetchConfig
339
+ fetchConfig?: Partial<MoveFetchConfig>
340
340
  ): sui_system {
341
341
  this.onEntryFunctionCall(
342
342
  func,
@@ -355,7 +355,7 @@ export class sui_system extends SuiBaseProcessor {
355
355
  ctx: SuiContext
356
356
  ) => void,
357
357
  filter?: CallFilter,
358
- fetchConfig?: MoveFetchConfig
358
+ fetchConfig?: Partial<MoveFetchConfig>
359
359
  ): sui_system {
360
360
  this.onEntryFunctionCall(
361
361
  func,
@@ -374,7 +374,7 @@ export class sui_system extends SuiBaseProcessor {
374
374
  ctx: SuiContext
375
375
  ) => void,
376
376
  filter?: CallFilter,
377
- fetchConfig?: MoveFetchConfig
377
+ fetchConfig?: Partial<MoveFetchConfig>
378
378
  ): sui_system {
379
379
  this.onEntryFunctionCall(
380
380
  func,
@@ -393,7 +393,7 @@ export class sui_system extends SuiBaseProcessor {
393
393
  ctx: SuiContext
394
394
  ) => void,
395
395
  filter?: CallFilter,
396
- fetchConfig?: MoveFetchConfig
396
+ fetchConfig?: Partial<MoveFetchConfig>
397
397
  ): sui_system {
398
398
  this.onEntryFunctionCall(
399
399
  func,
@@ -412,7 +412,7 @@ export class sui_system extends SuiBaseProcessor {
412
412
  ctx: SuiContext
413
413
  ) => void,
414
414
  filter?: CallFilter,
415
- fetchConfig?: MoveFetchConfig
415
+ fetchConfig?: Partial<MoveFetchConfig>
416
416
  ): sui_system {
417
417
  this.onEntryFunctionCall(
418
418
  func,
@@ -428,7 +428,7 @@ export class sui_system extends SuiBaseProcessor {
428
428
  onEntryRequestSetGasPrice(
429
429
  func: (call: sui_system.RequestSetGasPricePayload, ctx: SuiContext) => void,
430
430
  filter?: CallFilter,
431
- fetchConfig?: MoveFetchConfig
431
+ fetchConfig?: Partial<MoveFetchConfig>
432
432
  ): sui_system {
433
433
  this.onEntryFunctionCall(
434
434
  func,
@@ -447,7 +447,7 @@ export class sui_system extends SuiBaseProcessor {
447
447
  ctx: SuiContext
448
448
  ) => void,
449
449
  filter?: CallFilter,
450
- fetchConfig?: MoveFetchConfig
450
+ fetchConfig?: Partial<MoveFetchConfig>
451
451
  ): sui_system {
452
452
  this.onEntryFunctionCall(
453
453
  func,
@@ -463,7 +463,7 @@ export class sui_system extends SuiBaseProcessor {
463
463
  onEntryRotateOperationCap(
464
464
  func: (call: sui_system.RotateOperationCapPayload, ctx: SuiContext) => void,
465
465
  filter?: CallFilter,
466
- fetchConfig?: MoveFetchConfig
466
+ fetchConfig?: Partial<MoveFetchConfig>
467
467
  ): sui_system {
468
468
  this.onEntryFunctionCall(
469
469
  func,
@@ -482,7 +482,7 @@ export class sui_system extends SuiBaseProcessor {
482
482
  ctx: SuiContext
483
483
  ) => void,
484
484
  filter?: CallFilter,
485
- fetchConfig?: MoveFetchConfig
485
+ fetchConfig?: Partial<MoveFetchConfig>
486
486
  ): sui_system {
487
487
  this.onEntryFunctionCall(
488
488
  func,
@@ -501,7 +501,7 @@ export class sui_system extends SuiBaseProcessor {
501
501
  ctx: SuiContext
502
502
  ) => void,
503
503
  filter?: CallFilter,
504
- fetchConfig?: MoveFetchConfig
504
+ fetchConfig?: Partial<MoveFetchConfig>
505
505
  ): sui_system {
506
506
  this.onEntryFunctionCall(
507
507
  func,
@@ -520,7 +520,7 @@ export class sui_system extends SuiBaseProcessor {
520
520
  ctx: SuiContext
521
521
  ) => void,
522
522
  filter?: CallFilter,
523
- fetchConfig?: MoveFetchConfig
523
+ fetchConfig?: Partial<MoveFetchConfig>
524
524
  ): sui_system {
525
525
  this.onEntryFunctionCall(
526
526
  func,
@@ -539,7 +539,7 @@ export class sui_system extends SuiBaseProcessor {
539
539
  ctx: SuiContext
540
540
  ) => void,
541
541
  filter?: CallFilter,
542
- fetchConfig?: MoveFetchConfig
542
+ fetchConfig?: Partial<MoveFetchConfig>
543
543
  ): sui_system {
544
544
  this.onEntryFunctionCall(
545
545
  func,
@@ -558,7 +558,7 @@ export class sui_system extends SuiBaseProcessor {
558
558
  ctx: SuiContext
559
559
  ) => void,
560
560
  filter?: CallFilter,
561
- fetchConfig?: MoveFetchConfig
561
+ fetchConfig?: Partial<MoveFetchConfig>
562
562
  ): sui_system {
563
563
  this.onEntryFunctionCall(
564
564
  func,
@@ -577,7 +577,7 @@ export class sui_system extends SuiBaseProcessor {
577
577
  ctx: SuiContext
578
578
  ) => void,
579
579
  filter?: CallFilter,
580
- fetchConfig?: MoveFetchConfig
580
+ fetchConfig?: Partial<MoveFetchConfig>
581
581
  ): sui_system {
582
582
  this.onEntryFunctionCall(
583
583
  func,
@@ -596,7 +596,7 @@ export class sui_system extends SuiBaseProcessor {
596
596
  ctx: SuiContext
597
597
  ) => void,
598
598
  filter?: CallFilter,
599
- fetchConfig?: MoveFetchConfig
599
+ fetchConfig?: Partial<MoveFetchConfig>
600
600
  ): sui_system {
601
601
  this.onEntryFunctionCall(
602
602
  func,
@@ -615,7 +615,7 @@ export class sui_system extends SuiBaseProcessor {
615
615
  ctx: SuiContext
616
616
  ) => void,
617
617
  filter?: CallFilter,
618
- fetchConfig?: MoveFetchConfig
618
+ fetchConfig?: Partial<MoveFetchConfig>
619
619
  ): sui_system {
620
620
  this.onEntryFunctionCall(
621
621
  func,
@@ -634,7 +634,7 @@ export class sui_system extends SuiBaseProcessor {
634
634
  ctx: SuiContext
635
635
  ) => void,
636
636
  filter?: CallFilter,
637
- fetchConfig?: MoveFetchConfig
637
+ fetchConfig?: Partial<MoveFetchConfig>
638
638
  ): sui_system {
639
639
  this.onEntryFunctionCall(
640
640
  func,
@@ -653,7 +653,7 @@ export class sui_system extends SuiBaseProcessor {
653
653
  ctx: SuiContext
654
654
  ) => void,
655
655
  filter?: CallFilter,
656
- fetchConfig?: MoveFetchConfig
656
+ fetchConfig?: Partial<MoveFetchConfig>
657
657
  ): sui_system {
658
658
  this.onEntryFunctionCall(
659
659
  func,
@@ -672,7 +672,7 @@ export class sui_system extends SuiBaseProcessor {
672
672
  ctx: SuiContext
673
673
  ) => void,
674
674
  filter?: CallFilter,
675
- fetchConfig?: MoveFetchConfig
675
+ fetchConfig?: Partial<MoveFetchConfig>
676
676
  ): sui_system {
677
677
  this.onEntryFunctionCall(
678
678
  func,
@@ -691,7 +691,7 @@ export class sui_system extends SuiBaseProcessor {
691
691
  ctx: SuiContext
692
692
  ) => void,
693
693
  filter?: CallFilter,
694
- fetchConfig?: MoveFetchConfig
694
+ fetchConfig?: Partial<MoveFetchConfig>
695
695
  ): sui_system {
696
696
  this.onEntryFunctionCall(
697
697
  func,
@@ -710,7 +710,7 @@ export class sui_system extends SuiBaseProcessor {
710
710
  ctx: SuiContext
711
711
  ) => void,
712
712
  filter?: CallFilter,
713
- fetchConfig?: MoveFetchConfig
713
+ fetchConfig?: Partial<MoveFetchConfig>
714
714
  ): sui_system {
715
715
  this.onEntryFunctionCall(
716
716
  func,
@@ -729,7 +729,7 @@ export class sui_system extends SuiBaseProcessor {
729
729
  ctx: SuiContext
730
730
  ) => void,
731
731
  filter?: CallFilter,
732
- fetchConfig?: MoveFetchConfig
732
+ fetchConfig?: Partial<MoveFetchConfig>
733
733
  ): sui_system {
734
734
  this.onEntryFunctionCall(
735
735
  func,
@@ -748,7 +748,7 @@ export class sui_system extends SuiBaseProcessor {
748
748
  ctx: SuiContext
749
749
  ) => void,
750
750
  filter?: CallFilter,
751
- fetchConfig?: MoveFetchConfig
751
+ fetchConfig?: Partial<MoveFetchConfig>
752
752
  ): sui_system {
753
753
  this.onEntryFunctionCall(
754
754
  func,
@@ -767,7 +767,7 @@ export class sui_system extends SuiBaseProcessor {
767
767
  ctx: SuiContext
768
768
  ) => void,
769
769
  filter?: CallFilter,
770
- fetchConfig?: MoveFetchConfig
770
+ fetchConfig?: Partial<MoveFetchConfig>
771
771
  ): sui_system {
772
772
  this.onEntryFunctionCall(
773
773
  func,
@@ -786,7 +786,7 @@ export class sui_system extends SuiBaseProcessor {
786
786
  ctx: SuiContext
787
787
  ) => void,
788
788
  filter?: CallFilter,
789
- fetchConfig?: MoveFetchConfig
789
+ fetchConfig?: Partial<MoveFetchConfig>
790
790
  ): sui_system {
791
791
  this.onEntryFunctionCall(
792
792
  func,
@@ -805,7 +805,7 @@ export class sui_system extends SuiBaseProcessor {
805
805
  ctx: SuiContext
806
806
  ) => void,
807
807
  filter?: CallFilter,
808
- fetchConfig?: MoveFetchConfig
808
+ fetchConfig?: Partial<MoveFetchConfig>
809
809
  ): sui_system {
810
810
  this.onEntryFunctionCall(
811
811
  func,
@@ -824,7 +824,7 @@ export class sui_system extends SuiBaseProcessor {
824
824
  ctx: SuiContext
825
825
  ) => void,
826
826
  filter?: CallFilter,
827
- fetchConfig?: MoveFetchConfig
827
+ fetchConfig?: Partial<MoveFetchConfig>
828
828
  ): sui_system {
829
829
  this.onEntryFunctionCall(
830
830
  func,
@@ -843,7 +843,7 @@ export class sui_system extends SuiBaseProcessor {
843
843
  ctx: SuiContext
844
844
  ) => void,
845
845
  filter?: CallFilter,
846
- fetchConfig?: MoveFetchConfig
846
+ fetchConfig?: Partial<MoveFetchConfig>
847
847
  ): sui_system {
848
848
  this.onEntryFunctionCall(
849
849
  func,
@@ -862,7 +862,7 @@ export class sui_system extends SuiBaseProcessor {
862
862
  ctx: SuiContext
863
863
  ) => void,
864
864
  filter?: CallFilter,
865
- fetchConfig?: MoveFetchConfig
865
+ fetchConfig?: Partial<MoveFetchConfig>
866
866
  ): sui_system {
867
867
  this.onEntryFunctionCall(
868
868
  func,
@@ -1210,7 +1210,7 @@ export class sui_system_state_inner extends SuiBaseProcessor {
1210
1210
  event: sui_system_state_inner.SystemEpochInfoEventInstance,
1211
1211
  ctx: SuiContext
1212
1212
  ) => void,
1213
- fetchConfig?: MoveFetchConfig
1213
+ fetchConfig?: Partial<MoveFetchConfig>
1214
1214
  ): sui_system_state_inner {
1215
1215
  this.onMoveEvent(
1216
1216
  func,
@@ -1300,7 +1300,7 @@ export class validator extends SuiBaseProcessor {
1300
1300
  event: validator.StakingRequestEventInstance,
1301
1301
  ctx: SuiContext
1302
1302
  ) => void,
1303
- fetchConfig?: MoveFetchConfig
1303
+ fetchConfig?: Partial<MoveFetchConfig>
1304
1304
  ): validator {
1305
1305
  this.onMoveEvent(
1306
1306
  func,
@@ -1317,7 +1317,7 @@ export class validator extends SuiBaseProcessor {
1317
1317
  event: validator.UnstakingRequestEventInstance,
1318
1318
  ctx: SuiContext
1319
1319
  ) => void,
1320
- fetchConfig?: MoveFetchConfig
1320
+ fetchConfig?: Partial<MoveFetchConfig>
1321
1321
  ): validator {
1322
1322
  this.onMoveEvent(
1323
1323
  func,
@@ -1435,7 +1435,7 @@ export class validator_set extends SuiBaseProcessor {
1435
1435
  event: validator_set.ValidatorEpochInfoEventInstance,
1436
1436
  ctx: SuiContext
1437
1437
  ) => void,
1438
- fetchConfig?: MoveFetchConfig
1438
+ fetchConfig?: Partial<MoveFetchConfig>
1439
1439
  ): validator_set {
1440
1440
  this.onMoveEvent(
1441
1441
  func,
@@ -1452,7 +1452,7 @@ export class validator_set extends SuiBaseProcessor {
1452
1452
  event: validator_set.ValidatorJoinEventInstance,
1453
1453
  ctx: SuiContext
1454
1454
  ) => void,
1455
- fetchConfig?: MoveFetchConfig
1455
+ fetchConfig?: Partial<MoveFetchConfig>
1456
1456
  ): validator_set {
1457
1457
  this.onMoveEvent(
1458
1458
  func,
@@ -1469,7 +1469,7 @@ export class validator_set extends SuiBaseProcessor {
1469
1469
  event: validator_set.ValidatorLeaveEventInstance,
1470
1470
  ctx: SuiContext
1471
1471
  ) => void,
1472
- fetchConfig?: MoveFetchConfig
1472
+ fetchConfig?: Partial<MoveFetchConfig>
1473
1473
  ): validator_set {
1474
1474
  this.onMoveEvent(
1475
1475
  func,
@@ -10,6 +10,7 @@ export class SuiContext extends BaseContext {
10
10
  timestamp: Date
11
11
  slot: bigint
12
12
  transaction: SuiTransactionBlockResponse
13
+ eventIndex: number
13
14
 
14
15
  constructor(
15
16
  moduleName: string,
@@ -17,7 +18,8 @@ export class SuiContext extends BaseContext {
17
18
  address: string,
18
19
  timestamp: Date,
19
20
  slot: bigint,
20
- transaction?: SuiTransactionBlockResponse
21
+ transaction: SuiTransactionBlockResponse,
22
+ eventIndex: number
21
23
  ) {
22
24
  super()
23
25
  this.address = address.toLowerCase()
@@ -25,6 +27,7 @@ export class SuiContext extends BaseContext {
25
27
  this.moduleName = moduleName
26
28
  this.timestamp = timestamp
27
29
  this.slot = slot
30
+ this.eventIndex = eventIndex
28
31
  if (transaction) {
29
32
  this.transaction = transaction
30
33
  }
@@ -7,7 +7,7 @@ import {
7
7
  MoveOnIntervalConfig_OwnerType,
8
8
  ProcessResult,
9
9
  } from '@sentio/protos'
10
- import { ListStateStorage } from '@sentio/runtime'
10
+ import { ListStateStorage, mergeProcessResults } from '@sentio/runtime'
11
11
  import { getChainId, SuiNetwork } from './network.js'
12
12
  import { ServerError, Status } from 'nice-grpc'
13
13
  import { SuiContext, SuiObjectsContext } from './context.js'
@@ -19,7 +19,7 @@ import {
19
19
  SuiMoveObject,
20
20
  SuiTransactionBlockResponse,
21
21
  } from '@mysten/sui.js'
22
- import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'
22
+ import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'
23
23
  import { getMoveCalls } from './utils.js'
24
24
  import { defaultMoveCoder } from './move-coder.js'
25
25
  // import { dynamic_field } from './builtin/0x2.js'
@@ -66,10 +66,10 @@ export class SuiBaseProcessor {
66
66
  public onMoveEvent(
67
67
  handler: (event: SuiEvent, ctx: SuiContext) => void,
68
68
  filter: EventFilter | EventFilter[],
69
- fetchConfig?: MoveFetchConfig
69
+ fetchConfig?: Partial<MoveFetchConfig>
70
70
  ): SuiBaseProcessor {
71
71
  let _filters: EventFilter[] = []
72
- const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})
72
+ const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
73
73
 
74
74
  if (Array.isArray(filter)) {
75
75
  _filters = filter
@@ -81,6 +81,7 @@ export class SuiBaseProcessor {
81
81
  // const moduleName = this.moduleName
82
82
 
83
83
  const processor = this
84
+ const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))
84
85
 
85
86
  this.eventHandlers.push({
86
87
  handler: async function (data) {
@@ -92,26 +93,29 @@ export class SuiBaseProcessor {
92
93
  throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
93
94
  }
94
95
 
95
- const ctx = new SuiContext(
96
- processor.moduleName,
97
- processor.config.network,
98
- processor.config.address,
99
- data.timestamp || new Date(0),
100
- data.slot,
101
- txn
102
- )
96
+ const processResults = []
97
+ for (const [idx, evt] of (txn.events as SuiEvent[]).entries()) {
98
+ const typeQname = parseMoveType(evt.type).qname
99
+ if (!allEventType.has(typeQname)) {
100
+ continue
101
+ }
102
+
103
+ const ctx = new SuiContext(
104
+ processor.moduleName,
105
+ processor.config.network,
106
+ processor.config.address,
107
+ data.timestamp || new Date(0),
108
+ data.slot,
109
+ txn,
110
+ idx
111
+ )
103
112
 
104
- const events = txn.events
105
- txn.events = []
106
- for (const evt of events) {
107
- // if ('moveEvent' in evt) {
108
- // const eventInstance = evt.moveEvent as SuiEvent
109
113
  const decoded = defaultMoveCoder().decodeEvent<any>(evt)
110
114
  await handler(decoded || evt, ctx)
111
- // }
115
+ processResults.push(ctx.getProcessResult())
112
116
  }
113
117
 
114
- return ctx.getProcessResult()
118
+ return mergeProcessResults(processResults)
115
119
  },
116
120
  filters: _filters,
117
121
  fetchConfig: _fetchConfig,
@@ -122,10 +126,10 @@ export class SuiBaseProcessor {
122
126
  public onEntryFunctionCall(
123
127
  handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,
124
128
  filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
125
- fetchConfig?: MoveFetchConfig
129
+ fetchConfig?: Partial<MoveFetchConfig>
126
130
  ): SuiBaseProcessor {
127
131
  let _filters: FunctionNameAndCallFilter[] = []
128
- const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})
132
+ const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
129
133
 
130
134
  if (Array.isArray(filter)) {
131
135
  _filters = filter
@@ -150,7 +154,8 @@ export class SuiBaseProcessor {
150
154
  processor.config.address,
151
155
  data.timestamp || new Date(0),
152
156
  data.slot,
153
- tx
157
+ tx,
158
+ 0
154
159
  )
155
160
  if (tx) {
156
161
  const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)
@@ -2,7 +2,7 @@ import { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload }
2
2
  import { DataBinding, HandlerType } from '@sentio/protos'
3
3
  import { getChainId } from '../aptos/network.js'
4
4
  import { TestProcessorServer } from './test-processor-server.js'
5
- import { AptosNetwork, Event } from '@sentio/sdk/aptos'
5
+ import { AptosNetwork } from '@sentio/sdk/aptos'
6
6
  import { parseMoveType } from '../move/types.js'
7
7
 
8
8
  export class AptosFacet {
@@ -57,19 +57,8 @@ export class AptosFacet {
57
57
  return undefined
58
58
  }
59
59
 
60
- testEvent(
61
- transaction: Transaction_UserTransaction,
62
- event: number | Event,
63
- network: AptosNetwork = AptosNetwork.MAIN_NET
64
- ) {
65
- if (typeof event !== 'number') {
66
- const transaction2: Transaction_UserTransaction = {} as any
67
- Object.assign(transaction2, transaction)
68
- transaction = transaction2
69
- transaction.events = [event]
70
- event = 0
71
- }
72
- const binding = this.buildEventBinding(transaction, event, network)
60
+ testEvent(transaction: Transaction_UserTransaction, network: AptosNetwork = AptosNetwork.MAIN_NET) {
61
+ const binding = this.buildEventBinding(transaction, network)
73
62
  if (!binding) {
74
63
  throw Error('Invalid test event: ' + JSON.stringify(transaction))
75
64
  }
@@ -78,7 +67,6 @@ export class AptosFacet {
78
67
 
79
68
  private buildEventBinding(
80
69
  transaction: Transaction_UserTransaction,
81
- eventIdx: number,
82
70
  network: AptosNetwork = AptosNetwork.MAIN_NET
83
71
  ): DataBinding | undefined {
84
72
  // const allEvents = new Set(transaction.events.map(e => e.type))
@@ -88,19 +76,17 @@ export class AptosFacet {
88
76
  }
89
77
  for (const eventConfig of config.moveEventConfigs) {
90
78
  for (const eventFilter of eventConfig.filters) {
91
- if (
92
- config.contract.address + '::' + eventFilter.type ===
93
- parseMoveType(transaction.events[eventIdx].type).qname
94
- ) {
95
- transaction.events = [transaction.events[eventIdx]]
96
- return {
97
- data: {
98
- aptEvent: {
99
- transaction,
79
+ for (const event of transaction.events) {
80
+ if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
81
+ return {
82
+ data: {
83
+ aptEvent: {
84
+ transaction,
85
+ },
100
86
  },
101
- },
102
- handlerIds: [eventConfig.handlerId],
103
- handlerType: HandlerType.APT_EVENT,
87
+ handlerIds: [eventConfig.handlerId],
88
+ handlerType: HandlerType.APT_EVENT,
89
+ }
104
90
  }
105
91
  }
106
92
  }
@@ -1,4 +1,4 @@
1
- import { SuiEvent, SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'
1
+ import { SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'
2
2
  import { DataBinding, HandlerType } from '@sentio/protos'
3
3
  import { getChainId } from '../sui/network.js'
4
4
  import { TestProcessorServer } from './test-processor-server.js'
@@ -66,19 +66,8 @@ export class SuiFacet {
66
66
  return undefined
67
67
  }
68
68
 
69
- testEvent(
70
- transaction: SuiTransactionBlockResponse,
71
- event: number | SuiEvent,
72
- network: SuiNetwork = SuiNetwork.MAIN_NET
73
- ) {
74
- if (typeof event !== 'number') {
75
- const transaction2: SuiTransactionBlockResponse = {} as any
76
- Object.assign(transaction2, transaction)
77
- transaction = transaction2
78
- transaction.events = [event]
79
- event = 0
80
- }
81
- const binding = this.buildEventBinding(transaction, event, network)
69
+ testEvent(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {
70
+ const binding = this.buildEventBinding(transaction, network)
82
71
  if (!binding) {
83
72
  throw Error('Invalid test event: ' + JSON.stringify(transaction))
84
73
  }
@@ -87,14 +76,9 @@ export class SuiFacet {
87
76
 
88
77
  private buildEventBinding(
89
78
  transaction: SuiTransactionBlockResponse,
90
- eventIdx: number,
91
79
  network: SuiNetwork = SuiNetwork.MAIN_NET
92
80
  ): DataBinding | undefined {
93
81
  // const allEvents = new Set(transaction.events.map(e => e.type))
94
- const event = transaction.events?.[eventIdx]
95
- if (!event) {
96
- throw Error('Invaild test transaction, no event located')
97
- }
98
82
 
99
83
  for (const config of this.server.contractConfigs) {
100
84
  if (config.contract?.chainId !== getChainId(network)) {
@@ -102,18 +86,19 @@ export class SuiFacet {
102
86
  }
103
87
  for (const eventConfig of config.moveEventConfigs) {
104
88
  for (const eventFilter of eventConfig.filters) {
105
- if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
106
- transaction.events = [event]
107
- return {
108
- data: {
109
- suiEvent: {
110
- transaction,
111
- timestamp: new Date(transaction.timestampMs || 0),
112
- slot: 10000n,
89
+ for (const event of transaction.events || []) {
90
+ if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
91
+ return {
92
+ data: {
93
+ suiEvent: {
94
+ transaction,
95
+ timestamp: new Date(transaction.timestampMs || 0),
96
+ slot: 10000n,
97
+ },
113
98
  },
114
- },
115
- handlerIds: [eventConfig.handlerId],
116
- handlerType: HandlerType.SUI_EVENT,
99
+ handlerIds: [eventConfig.handlerId],
100
+ handlerType: HandlerType.SUI_EVENT,
101
+ }
117
102
  }
118
103
  }
119
104
  }