@sentio/sdk 2.13.0-rc.1 → 2.13.0-rc.3

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 (77) hide show
  1. package/lib/aptos/aptos-chain-adapter.d.ts +11 -0
  2. package/lib/aptos/aptos-chain-adapter.js +56 -0
  3. package/lib/aptos/aptos-chain-adapter.js.map +1 -0
  4. package/lib/aptos/aptos-processor.d.ts +2 -2
  5. package/lib/aptos/aptos-processor.js +4 -7
  6. package/lib/aptos/aptos-processor.js.map +1 -1
  7. package/lib/aptos/builtin/0x1.d.ts +62 -62
  8. package/lib/aptos/builtin/0x1.js.map +1 -1
  9. package/lib/aptos/builtin/0x3.d.ts +21 -21
  10. package/lib/aptos/builtin/0x3.js.map +1 -1
  11. package/lib/aptos/codegen/codegen.js +4 -45
  12. package/lib/aptos/codegen/codegen.js.map +1 -1
  13. package/lib/aptos/move-coder.d.ts +3 -3
  14. package/lib/aptos/move-coder.js +8 -6
  15. package/lib/aptos/move-coder.js.map +1 -1
  16. package/lib/move/abstract-codegen.d.ts +3 -4
  17. package/lib/move/abstract-codegen.js +11 -7
  18. package/lib/move/abstract-codegen.js.map +1 -1
  19. package/lib/move/abstract-move-coder.d.ts +5 -2
  20. package/lib/move/abstract-move-coder.js +7 -1
  21. package/lib/move/abstract-move-coder.js.map +1 -1
  22. package/lib/move/chain-adapter.d.ts +9 -0
  23. package/lib/move/chain-adapter.js +3 -0
  24. package/lib/move/chain-adapter.js.map +1 -0
  25. package/lib/move/index.d.ts +1 -0
  26. package/lib/move/index.js +1 -0
  27. package/lib/move/index.js.map +1 -1
  28. package/lib/sui/builtin/0x1.d.ts +6 -6
  29. package/lib/sui/builtin/0x1.js.map +1 -1
  30. package/lib/sui/builtin/0x2.d.ts +19 -19
  31. package/lib/sui/builtin/0x2.js.map +1 -1
  32. package/lib/sui/builtin/0x3.d.ts +9 -9
  33. package/lib/sui/builtin/0x3.js.map +1 -1
  34. package/lib/sui/codegen/codegen.js +4 -34
  35. package/lib/sui/codegen/codegen.js.map +1 -1
  36. package/lib/sui/context.d.ts +2 -1
  37. package/lib/sui/context.js +3 -1
  38. package/lib/sui/context.js.map +1 -1
  39. package/lib/sui/move-coder.d.ts +4 -3
  40. package/lib/sui/move-coder.js +8 -6
  41. package/lib/sui/move-coder.js.map +1 -1
  42. package/lib/sui/sui-chain-adapter.d.ts +11 -0
  43. package/lib/sui/sui-chain-adapter.js +43 -0
  44. package/lib/sui/sui-chain-adapter.js.map +1 -0
  45. package/lib/sui/sui-processor.js +13 -10
  46. package/lib/sui/sui-processor.js.map +1 -1
  47. package/lib/sui/utils.d.ts +0 -2
  48. package/lib/sui/utils.js +0 -6
  49. package/lib/sui/utils.js.map +1 -1
  50. package/lib/testing/sui-facet.d.ts +2 -2
  51. package/lib/testing/sui-facet.js +16 -26
  52. package/lib/testing/sui-facet.js.map +1 -1
  53. package/package.json +4 -4
  54. package/src/aptos/aptos-chain-adapter.ts +65 -0
  55. package/src/aptos/aptos-processor.ts +6 -10
  56. package/src/aptos/builtin/0x1.ts +62 -62
  57. package/src/aptos/builtin/0x3.ts +21 -21
  58. package/src/aptos/codegen/codegen.ts +5 -54
  59. package/src/aptos/move-coder.ts +11 -10
  60. package/src/move/abstract-codegen.ts +13 -14
  61. package/src/move/abstract-move-coder.ts +10 -3
  62. package/src/move/chain-adapter.ts +14 -0
  63. package/src/move/index.ts +1 -0
  64. package/src/sui/builtin/0x1.ts +6 -6
  65. package/src/sui/builtin/0x2.ts +19 -19
  66. package/src/sui/builtin/0x3.ts +9 -9
  67. package/src/sui/codegen/codegen.ts +5 -40
  68. package/src/sui/context.ts +4 -1
  69. package/src/sui/move-coder.ts +12 -9
  70. package/src/sui/sui-chain-adapter.ts +50 -0
  71. package/src/sui/sui-processor.ts +23 -18
  72. package/src/sui/utils.ts +0 -8
  73. package/src/testing/sui-facet.ts +15 -30
  74. package/lib/aptos/utils.d.ts +0 -2
  75. package/lib/aptos/utils.js +0 -10
  76. package/lib/aptos/utils.js.map +0 -1
  77. package/src/aptos/utils.ts +0 -11
@@ -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,
@@ -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,
@@ -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,
@@ -1,14 +1,13 @@
1
- import { Connection, JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'
1
+ import { SuiMoveNormalizedModules } from '@mysten/sui.js'
2
2
 
3
3
  import { SuiNetwork } from '../network.js'
4
4
  import * as fs from 'fs'
5
5
  import chalk from 'chalk'
6
6
  import { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'
7
7
  import { AbstractCodegen } from '../../move/abstract-codegen.js'
8
- import { toInternalModule } from '../move-types.js'
9
- import { moduleQname, SPLITTER, structQname, TypeDescriptor } from '../../move/index.js'
10
- import { getMeaningfulFunctionParams } from '../utils.js'
8
+ import { structQname } from '../../move/index.js'
11
9
  import { join } from 'path'
10
+ import { SuiChainAdapter } from '../sui-chain-adapter.js'
12
11
 
13
12
  export async function codegen(abisDir: string, outDir = join('src', 'types', 'sui'), genExample = false) {
14
13
  if (!fs.existsSync(abisDir)) {
@@ -19,18 +18,6 @@ export async function codegen(abisDir: string, outDir = join('src', 'types', 'su
19
18
  console.log(chalk.green(`Generated ${numFiles} for Sui`))
20
19
  }
21
20
 
22
- function getRpcEndpoint(network: SuiNetwork): string {
23
- switch (network) {
24
- case SuiNetwork.TEST_NET:
25
- return 'https://fullnode.testnet.sui.io/'
26
- }
27
- return 'https://fullnode.mainnet.sui.io/'
28
- }
29
-
30
- function getRpcClient(network: SuiNetwork): JsonRpcProvider {
31
- return new JsonRpcProvider(new Connection({ fullnode: getRpcEndpoint(network) }))
32
- }
33
-
34
21
  class SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {
35
22
  ADDRESS_TYPE = 'SuiAddress'
36
23
  MAIN_NET = SuiNetwork.MAIN_NET
@@ -40,30 +27,8 @@ class SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {
40
27
  // GENERATE_ON_ENTRY = true
41
28
  PAYLOAD_OPTIONAL = true
42
29
 
43
- async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModules> {
44
- const client = getRpcClient(network)
45
- return await client.getNormalizedMoveModulesByPackage({ package: account })
46
- }
47
-
48
- getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
49
- return getMeaningfulFunctionParams(params)
50
- }
51
-
52
- toInternalModules(modules: SuiMoveNormalizedModules): InternalMoveModule[] {
53
- return Object.values(modules).map(toInternalModule)
54
- }
55
-
56
- getEventStructs(module: InternalMoveModule) {
57
- const qname = moduleQname(module)
58
- const eventMap = new Map<string, InternalMoveStruct>()
59
-
60
- for (const struct of module.structs) {
61
- const abilities = new Set(struct.abilities)
62
- if (abilities.has('Drop') && abilities.has('Copy')) {
63
- eventMap.set(qname + SPLITTER + struct.name, struct)
64
- }
65
- }
66
- return eventMap
30
+ constructor() {
31
+ super(new SuiChainAdapter())
67
32
  }
68
33
 
69
34
  readModulesFile(fullPath: string) {
@@ -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
  }
@@ -2,18 +2,25 @@ import { TypedEventInstance, TypedFunctionPayload, TypedSuiMoveObject } from './
2
2
  import { AbstractMoveCoder, StructWithTag } from '../move/abstract-move-coder.js'
3
3
  import {
4
4
  MoveCallSuiTransaction,
5
+ SuiCallArg,
5
6
  SuiEvent,
6
7
  SuiMoveNormalizedModule,
7
- SuiCallArg,
8
8
  SuiMoveObject,
9
9
  SuiRawData,
10
+ SuiMoveNormalizedModules,
10
11
  } from '@mysten/sui.js'
11
12
  import { toInternalModule } from './move-types.js'
12
13
  import { SPLITTER, TypeDescriptor } from '../move/index.js'
13
- import { getMeaningfulFunctionParams } from './utils.js'
14
14
  import { dynamic_field } from './builtin/0x2.js'
15
+ import { SuiNetwork } from './network.js'
16
+ import { SuiChainAdapter } from './sui-chain-adapter.js'
17
+
18
+ export class MoveCoder extends AbstractMoveCoder<SuiNetwork, SuiMoveNormalizedModules, SuiEvent | SuiMoveObject> {
19
+ constructor(network: SuiNetwork) {
20
+ super(network)
21
+ this.adapter = new SuiChainAdapter()
22
+ }
15
23
 
16
- export class MoveCoder extends AbstractMoveCoder<SuiEvent | SuiMoveObject> {
17
24
  load(module: SuiMoveNormalizedModule) {
18
25
  if (this.contains(module.address, module.name)) {
19
26
  return
@@ -65,14 +72,10 @@ export class MoveCoder extends AbstractMoveCoder<SuiEvent | SuiMoveObject> {
65
72
  return this.filterAndDecodeStruct(typeQname, objects)
66
73
  }
67
74
 
68
- getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
69
- return getMeaningfulFunctionParams(params)
70
- }
71
-
72
75
  decodeFunctionPayload(payload: MoveCallSuiTransaction, inputs: SuiCallArg[]): MoveCallSuiTransaction {
73
76
  const functionType = [payload.package, payload.module, payload.function].join(SPLITTER)
74
77
  const func = this.getMoveFunction(functionType)
75
- const params = getMeaningfulFunctionParams(func.params)
78
+ const params = this.adapter.getMeaningfulFunctionParams(func.params)
76
79
  const args = []
77
80
  for (const value of payload.arguments || []) {
78
81
  const argValue = value as any
@@ -101,7 +104,7 @@ export class MoveCoder extends AbstractMoveCoder<SuiEvent | SuiMoveObject> {
101
104
  }
102
105
  }
103
106
 
104
- export const MOVE_CODER = new MoveCoder()
107
+ export const MOVE_CODER = new MoveCoder(SuiNetwork.MAIN_NET)
105
108
 
106
109
  export function defaultMoveCoder(): MoveCoder {
107
110
  return MOVE_CODER
@@ -0,0 +1,50 @@
1
+ import { ChainAdapter, moduleQname, SPLITTER, TypeDescriptor } from '../move/index.js'
2
+ import { toInternalModule } from './move-types.js'
3
+ import { SuiNetwork } from './network.js'
4
+ import { InternalMoveModule, InternalMoveStruct } from '../move/internal-models.js'
5
+ import { Connection, JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'
6
+
7
+ export class SuiChainAdapter extends ChainAdapter<SuiNetwork, SuiMoveNormalizedModules> {
8
+ static INSTANCE = new SuiChainAdapter()
9
+
10
+ async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModules> {
11
+ const client = getRpcClient(network)
12
+ return await client.getNormalizedMoveModulesByPackage({ package: account })
13
+ }
14
+
15
+ getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
16
+ if (params.length === 0) {
17
+ return params
18
+ }
19
+ return params.slice(0, params.length - 1)
20
+ }
21
+
22
+ toInternalModules(modules: SuiMoveNormalizedModules): InternalMoveModule[] {
23
+ return Object.values(modules).map(toInternalModule)
24
+ }
25
+
26
+ getEventStructs(module: InternalMoveModule) {
27
+ const qname = moduleQname(module)
28
+ const eventMap = new Map<string, InternalMoveStruct>()
29
+
30
+ for (const struct of module.structs) {
31
+ const abilities = new Set(struct.abilities)
32
+ if (abilities.has('Drop') && abilities.has('Copy')) {
33
+ eventMap.set(qname + SPLITTER + struct.name, struct)
34
+ }
35
+ }
36
+ return eventMap
37
+ }
38
+ }
39
+
40
+ function getRpcEndpoint(network: SuiNetwork): string {
41
+ switch (network) {
42
+ case SuiNetwork.TEST_NET:
43
+ return 'https://fullnode.testnet.sui.io/'
44
+ }
45
+ return 'https://fullnode.mainnet.sui.io/'
46
+ }
47
+
48
+ function getRpcClient(network: SuiNetwork): JsonRpcProvider {
49
+ return new JsonRpcProvider(new Connection({ fullnode: getRpcEndpoint(network) }))
50
+ }
@@ -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'
@@ -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,
@@ -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)
package/src/sui/utils.ts CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  ProgrammableTransaction,
7
7
  SuiTransaction,
8
8
  } from '@mysten/sui.js'
9
- import { TypeDescriptor } from '../move/index.js'
10
9
 
11
10
  export function getMoveCalls(txBlock: SuiTransactionBlockResponse) {
12
11
  const txKind = getTransactionKind(txBlock)
@@ -33,10 +32,3 @@ export function getMoveCalls(txBlock: SuiTransactionBlockResponse) {
33
32
  return []
34
33
  })
35
34
  }
36
-
37
- export function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
38
- if (params.length === 0) {
39
- return params
40
- }
41
- return params.slice(0, params.length - 1)
42
- }
@@ -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
  }
@@ -1,2 +0,0 @@
1
- import { TypeDescriptor } from '../move/index.js';
2
- export declare function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
@@ -1,10 +0,0 @@
1
- export function getMeaningfulFunctionParams(params) {
2
- if (params.length === 0) {
3
- return params;
4
- }
5
- if (params[0].qname === 'signer' && params[0].reference) {
6
- params = params.slice(1);
7
- }
8
- return params;
9
- }
10
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/aptos/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,2BAA2B,CAAC,MAAwB;IAClE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,MAAM,CAAA;KACd;IACD,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;QACvD,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;KACzB;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { TypeDescriptor } from '../move/index.js'\n\nexport function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {\n if (params.length === 0) {\n return params\n }\n if (params[0].qname === 'signer' && params[0].reference) {\n params = params.slice(1)\n }\n return params\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { TypeDescriptor } from '../move/index.js'
2
-
3
- export function getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
4
- if (params.length === 0) {
5
- return params
6
- }
7
- if (params[0].qname === 'signer' && params[0].reference) {
8
- params = params.slice(1)
9
- }
10
- return params
11
- }