@sentio/sdk 2.12.3 → 2.13.0-rc.1

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.
@@ -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
  }