@sentio/sdk 2.10.2 → 2.11.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.
Files changed (60) hide show
  1. package/lib/aptos/codegen/codegen.js +0 -1
  2. package/lib/aptos/codegen/codegen.js.map +1 -1
  3. package/lib/move/abstract-codegen.d.ts +2 -1
  4. package/lib/move/abstract-codegen.js +9 -8
  5. package/lib/move/abstract-codegen.js.map +1 -1
  6. package/lib/solana/builtin/types.d.ts +170 -170
  7. package/lib/solana/builtin/types.js +2 -1
  8. package/lib/solana/builtin/types.js.map +1 -1
  9. package/lib/sui/builtin/0x1.js +1 -1
  10. package/lib/sui/builtin/0x1.js.map +1 -1
  11. package/lib/sui/builtin/0x2.d.ts +235 -640
  12. package/lib/sui/builtin/0x2.js +294 -716
  13. package/lib/sui/builtin/0x2.js.map +1 -1
  14. package/lib/sui/builtin/0x3.d.ts +566 -0
  15. package/lib/sui/builtin/0x3.js +681 -0
  16. package/lib/sui/builtin/0x3.js.map +1 -0
  17. package/lib/sui/builtin/index.d.ts +1 -0
  18. package/lib/sui/builtin/index.js +1 -0
  19. package/lib/sui/builtin/index.js.map +1 -1
  20. package/lib/sui/codegen/codegen.js +4 -3
  21. package/lib/sui/codegen/codegen.js.map +1 -1
  22. package/lib/sui/context.d.ts +3 -3
  23. package/lib/sui/context.js +1 -1
  24. package/lib/sui/context.js.map +1 -1
  25. package/lib/sui/models.d.ts +4 -4
  26. package/lib/sui/models.js.map +1 -1
  27. package/lib/sui/move-coder.d.ts +5 -5
  28. package/lib/sui/move-coder.js +19 -7
  29. package/lib/sui/move-coder.js.map +1 -1
  30. package/lib/sui/move-types.js +7 -7
  31. package/lib/sui/move-types.js.map +1 -1
  32. package/lib/sui/sui-processor.d.ts +3 -3
  33. package/lib/sui/sui-processor.js +15 -9
  34. package/lib/sui/sui-processor.js.map +1 -1
  35. package/lib/sui/utils.d.ts +2 -2
  36. package/lib/sui/utils.js +13 -5
  37. package/lib/sui/utils.js.map +1 -1
  38. package/lib/testing/sui-facet.d.ts +4 -4
  39. package/lib/testing/sui-facet.js +7 -7
  40. package/lib/testing/sui-facet.js.map +1 -1
  41. package/package.json +7 -5
  42. package/src/aptos/codegen/codegen.ts +0 -1
  43. package/src/move/abstract-codegen.ts +9 -8
  44. package/src/solana/builtin/types.ts +2 -1
  45. package/src/sui/abis/0x1.json +357 -357
  46. package/src/sui/abis/0x2.json +5563 -8247
  47. package/src/sui/abis/0x3.json +8399 -0
  48. package/src/sui/builtin/0x1.ts +1 -1
  49. package/src/sui/builtin/0x2.ts +531 -1537
  50. package/src/sui/builtin/0x3.ts +1515 -0
  51. package/src/sui/builtin/index.ts +1 -0
  52. package/src/sui/codegen/codegen.ts +5 -3
  53. package/src/sui/context.ts +4 -4
  54. package/src/sui/models.ts +4 -4
  55. package/src/sui/move-coder.ts +24 -12
  56. package/src/sui/move-types.ts +7 -7
  57. package/src/sui/sui-processor.ts +28 -15
  58. package/src/sui/utils.ts +21 -5
  59. package/src/testing/sui-facet.ts +19 -15
  60. package/src/eth/codegen/tsconfig.json +0 -8
@@ -3,3 +3,4 @@
3
3
  /* eslint-disable */
4
4
  export * as _0x1 from './0x1.js'
5
5
  export * as _0x2 from './0x2.js'
6
+ export * as _0x3 from './0x3.js'
@@ -1,9 +1,10 @@
1
+ import { Connection, JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'
2
+
1
3
  import { SuiNetwork } from '../network.js'
2
4
  import * as fs from 'fs'
3
5
  import chalk from 'chalk'
4
6
  import { InternalMoveModule, InternalMoveStruct } from '../../move/internal-models.js'
5
7
  import { AbstractCodegen } from '../../move/abstract-codegen.js'
6
- import { JsonRpcProvider, SuiMoveNormalizedModules } from '@mysten/sui.js'
7
8
  import { toInternalModule } from '../move-types.js'
8
9
  import { moduleQname, SPLITTER, structQname, TypeDescriptor } from '../../move/index.js'
9
10
  import { getMeaningfulFunctionParams } from '../utils.js'
@@ -26,7 +27,7 @@ function getRpcEndpoint(network: SuiNetwork): string {
26
27
  }
27
28
 
28
29
  function getRpcClient(network: SuiNetwork): JsonRpcProvider {
29
- return new JsonRpcProvider(getRpcEndpoint(network))
30
+ return new JsonRpcProvider(new Connection({ fullnode: getRpcEndpoint(network) }))
30
31
  }
31
32
 
32
33
  class SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {
@@ -35,10 +36,11 @@ class SuiCodegen extends AbstractCodegen<SuiMoveNormalizedModules, SuiNetwork> {
35
36
  TEST_NET = SuiNetwork.TEST_NET
36
37
  PREFIX = 'Sui'
37
38
  STRUCT_FIELD_NAME = 'fields'
39
+ GENERATE_ON_ENTRY = true
38
40
 
39
41
  async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModules> {
40
42
  const client = getRpcClient(network)
41
- return await client.getNormalizedMoveModulesByPackage(account)
43
+ return await client.getNormalizedMoveModulesByPackage({ package: account })
42
44
  }
43
45
 
44
46
  getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
@@ -1,7 +1,7 @@
1
1
  import { RecordMetaData } from '@sentio/protos'
2
2
  import { type Labels, BaseContext, normalizeLabels } from '../index.js'
3
3
  import { SuiNetwork, getChainId } from './network.js'
4
- import { SuiTransactionResponse } from '@mysten/sui.js'
4
+ import { SuiTransactionBlockResponse } from '@mysten/sui.js'
5
5
 
6
6
  export class SuiContext extends BaseContext {
7
7
  address: string
@@ -9,7 +9,7 @@ export class SuiContext extends BaseContext {
9
9
  moduleName: string
10
10
  timestamp: Date
11
11
  slot: bigint
12
- transaction: SuiTransactionResponse
12
+ transaction: SuiTransactionBlockResponse
13
13
 
14
14
  constructor(
15
15
  moduleName: string,
@@ -17,7 +17,7 @@ export class SuiContext extends BaseContext {
17
17
  address: string,
18
18
  timestamp: Date,
19
19
  slot: bigint,
20
- transaction?: SuiTransactionResponse
20
+ transaction?: SuiTransactionBlockResponse
21
21
  ) {
22
22
  super()
23
23
  this.address = address.toLowerCase()
@@ -40,7 +40,7 @@ export class SuiContext extends BaseContext {
40
40
  contractName: this.moduleName,
41
41
  blockNumber: this.slot,
42
42
  transactionIndex: 0,
43
- transactionHash: this.transaction?.certificate.transactionDigest || '', // TODO
43
+ transactionHash: this.transaction?.digest || '', // TODO
44
44
  logIndex: 0,
45
45
  chainId: this.getChainId(),
46
46
  name: name,
package/src/sui/models.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { MoveEvent, MoveCall } from '@mysten/sui.js'
1
+ import { SuiEvent, MoveCallSuiTransaction } from '@mysten/sui.js'
2
2
 
3
- export type TypedEventInstance<T> = MoveEvent & {
3
+ export type TypedEventInstance<T> = SuiEvent & {
4
4
  /**
5
5
  * decoded data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
6
6
  */
7
- fields_decoded: T
7
+ data_decoded: T
8
8
 
9
9
  type_arguments: string[]
10
10
  }
11
11
 
12
- export type TypedFunctionPayload<T extends Array<any>> = MoveCall & {
12
+ export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction & {
13
13
  /**
14
14
  * decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
15
15
  */
@@ -1,11 +1,11 @@
1
1
  import { TypedEventInstance, TypedFunctionPayload } from './models.js'
2
2
  import { AbstractMoveCoder } from '../move/abstract-move-coder.js'
3
- import { MoveCall, MoveEvent, SuiMoveNormalizedModule } from '@mysten/sui.js'
3
+ import { MoveCallSuiTransaction, SuiEvent, SuiMoveNormalizedModule, SuiCallArg } from '@mysten/sui.js'
4
4
  import { toInternalModule } from './move-types.js'
5
5
  import { SPLITTER, TypeDescriptor } from '../move/index.js'
6
6
  import { getMeaningfulFunctionParams } from './utils.js'
7
7
 
8
- export class MoveCoder extends AbstractMoveCoder<MoveEvent> {
8
+ export class MoveCoder extends AbstractMoveCoder<SuiEvent> {
9
9
  load(module: SuiMoveNormalizedModule) {
10
10
  if (this.contains(module.address, module.name)) {
11
11
  return
@@ -25,32 +25,44 @@ export class MoveCoder extends AbstractMoveCoder<MoveEvent> {
25
25
  }
26
26
  }
27
27
 
28
- decodeEvent<T>(event: MoveEvent): TypedEventInstance<T> | undefined {
29
- const res = this.decodedInternal<T>({ ...event, data: event.fields })
30
- return { ...event, fields_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }
28
+ decodeEvent<T>(event: SuiEvent): TypedEventInstance<T> | undefined {
29
+ const res = this.decodedInternal<T>({ ...event, data: event.parsedJson })
30
+ return { ...event, data_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }
31
31
  }
32
- filterAndDecodeEvents<T>(typeQname: string, resources: MoveEvent[]): TypedEventInstance<T>[] {
32
+ filterAndDecodeEvents<T>(typeQname: string, resources: SuiEvent[]): TypedEventInstance<T>[] {
33
33
  const resp = this.filterAndDecodeInternal(
34
34
  typeQname,
35
35
  resources.map((event) => {
36
- return { ...event, data: event.fields, type: event.type }
36
+ return { ...event, data: event.parsedJson, type: event.type }
37
37
  })
38
38
  )
39
39
  return resp.map((res) => {
40
40
  delete res.data_decoded
41
- const event = res as MoveEvent
42
- return { ...event, fields_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }
41
+ const event = res as SuiEvent
42
+ return { ...event, data_decoded: res?.data_decoded as T, type_arguments: res?.type_arguments || [] }
43
43
  })
44
44
  }
45
45
  getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
46
46
  return getMeaningfulFunctionParams(params)
47
47
  }
48
48
 
49
- decodeFunctionPayload(payload: MoveCall): MoveCall {
50
- const functionType = [payload.package.objectId, payload.module, payload.function].join(SPLITTER)
49
+ decodeFunctionPayload(payload: MoveCallSuiTransaction, inputs: SuiCallArg[]): MoveCallSuiTransaction {
50
+ const functionType = [payload.package, payload.module, payload.function].join(SPLITTER)
51
51
  const func = this.getMoveFunction(functionType)
52
52
  const params = getMeaningfulFunctionParams(func.params)
53
- const argumentsTyped = this.decodeArray(payload.arguments || [], params)
53
+ const args = []
54
+ for (const value of payload.arguments || []) {
55
+ const argValue = value as any
56
+ if ('Input' in (argValue as any)) {
57
+ const idx = argValue.Input
58
+ const arg = inputs[idx]
59
+ args.push(arg) // TODO check why ts not work using arg.push(arg)
60
+ } else {
61
+ args.push(undefined)
62
+ }
63
+ }
64
+
65
+ const argumentsTyped = this.decodeArray(args, params)
54
66
  return {
55
67
  ...payload,
56
68
  arguments_decoded: argumentsTyped,
@@ -19,7 +19,7 @@ export type { SuiAddress } from '@mysten/sui.js'
19
19
  export function toInternalModule(module: SuiMoveNormalizedModule): InternalMoveModule {
20
20
  return {
21
21
  address: module.address,
22
- exposedFunctions: Object.entries(module.exposed_functions).map(([n, f]) => toInternalFunction(n, f)),
22
+ exposedFunctions: Object.entries(module.exposedFunctions).map(([n, f]) => toInternalFunction(n, f)),
23
23
  name: module.name,
24
24
  structs: Object.entries(module.structs).map(([n, s]) => toInternalStruct(n, s)),
25
25
  }
@@ -41,13 +41,13 @@ export function toInternalFunction(name: string, func: SuiMoveNormalizedFunction
41
41
  throw Error('No visibility for function' + name)
42
42
  }
43
43
  return {
44
- typeParams: func.type_parameters.map((p: any) => {
44
+ typeParams: func.typeParameters.map((p: any) => {
45
45
  return { constraints: p.abilities }
46
46
  }),
47
- isEntry: func.is_entry,
47
+ isEntry: func.isEntry,
48
48
  name: name,
49
49
  params: func.parameters.map(toTypeDescriptor),
50
- return: func.return_.map(toTypeDescriptor),
50
+ return: func.return.map(toTypeDescriptor),
51
51
  visibility: visibility,
52
52
  }
53
53
  }
@@ -56,7 +56,7 @@ export function toInternalStruct(name: string, struct: SuiMoveNormalizedStruct):
56
56
  return {
57
57
  abilities: struct.abilities.abilities,
58
58
  fields: struct.fields.map(toInternalField),
59
- typeParams: struct.type_parameters.map((p: any) => {
59
+ typeParams: struct.typeParameters.map((p: any) => {
60
60
  return { constraints: p.constraints.abilities }
61
61
  }),
62
62
  isNative: false,
@@ -67,7 +67,7 @@ export function toInternalStruct(name: string, struct: SuiMoveNormalizedStruct):
67
67
  export function toInternalField(module: SuiMoveNormalizedField): InternalMoveStructField {
68
68
  return {
69
69
  name: module.name,
70
- type: toTypeDescriptor(module.type_),
70
+ type: toTypeDescriptor(module.type),
71
71
  }
72
72
  }
73
73
 
@@ -81,7 +81,7 @@ export function toTypeDescriptor(normalizedType: SuiMoveNormalizedType): TypeDes
81
81
  SPLITTER
82
82
  )
83
83
 
84
- const args = normalizedType.Struct.type_arguments.map(toTypeDescriptor)
84
+ const args = normalizedType.Struct.typeArguments.map(toTypeDescriptor)
85
85
 
86
86
  return new TypeDescriptor(qname, args)
87
87
  }
@@ -11,7 +11,14 @@ import { ListStateStorage } from '@sentio/runtime'
11
11
  import { SuiNetwork, getChainId } from './network.js'
12
12
  import { ServerError, Status } from 'nice-grpc'
13
13
  import { SuiContext, SuiObjectsContext } from './context.js'
14
- import { MoveEvent, SuiTransactionResponse, MoveCall, SuiMoveObject } from '@mysten/sui.js'
14
+ import {
15
+ MoveCallSuiTransaction,
16
+ SuiEvent,
17
+ SuiMoveObject,
18
+ SuiTransactionBlockResponse,
19
+ getTransactionKind,
20
+ getProgrammableTransaction,
21
+ } from '@mysten/sui.js'
15
22
  import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'
16
23
  import { getMoveCalls } from './utils.js'
17
24
  import { defaultMoveCoder } from './move-coder.js'
@@ -50,7 +57,7 @@ export class SuiBaseProcessor {
50
57
  }
51
58
 
52
59
  public onMoveEvent(
53
- handler: (event: MoveEvent, ctx: SuiContext) => void,
60
+ handler: (event: SuiEvent, ctx: SuiContext) => void,
54
61
  filter: EventFilter | EventFilter[],
55
62
  fetchConfig?: MoveFetchConfig
56
63
  ): SuiBaseProcessor {
@@ -73,8 +80,8 @@ export class SuiBaseProcessor {
73
80
  if (!data.transaction) {
74
81
  throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
75
82
  }
76
- const txn = data.transaction as SuiTransactionResponse
77
- if (!txn.effects.events || !txn.effects.events.length) {
83
+ const txn = data.transaction as SuiTransactionBlockResponse
84
+ if (!txn.events || !txn.events.length) {
78
85
  throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
79
86
  }
80
87
 
@@ -87,14 +94,14 @@ export class SuiBaseProcessor {
87
94
  txn
88
95
  )
89
96
 
90
- const events = txn.effects.events
91
- txn.effects.events = []
97
+ const events = txn.events
98
+ txn.events = []
92
99
  for (const evt of events) {
93
- if ('moveEvent' in evt) {
94
- const eventInstance = evt.moveEvent as MoveEvent
95
- const decoded = defaultMoveCoder().decodeEvent<any>(eventInstance)
96
- await handler(decoded || eventInstance, ctx)
97
- }
100
+ // if ('moveEvent' in evt) {
101
+ // const eventInstance = evt.moveEvent as SuiEvent
102
+ const decoded = defaultMoveCoder().decodeEvent<any>(evt)
103
+ await handler(decoded || evt, ctx)
104
+ // }
98
105
  }
99
106
 
100
107
  return ctx.getProcessResult()
@@ -106,7 +113,7 @@ export class SuiBaseProcessor {
106
113
  }
107
114
 
108
115
  public onEntryFunctionCall(
109
- handler: (call: MoveCall, ctx: SuiContext) => void,
116
+ handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,
110
117
  filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
111
118
  fetchConfig?: MoveFetchConfig
112
119
  ): SuiBaseProcessor {
@@ -128,7 +135,7 @@ export class SuiBaseProcessor {
128
135
  if (!data.transaction) {
129
136
  throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
130
137
  }
131
- const tx = data.transaction as SuiTransactionResponse
138
+ const tx = data.transaction as SuiTransactionBlockResponse
132
139
 
133
140
  const ctx = new SuiContext(
134
141
  processor.moduleName,
@@ -139,12 +146,18 @@ export class SuiBaseProcessor {
139
146
  tx
140
147
  )
141
148
  if (tx) {
142
- const calls: MoveCall[] = getMoveCalls(tx)
149
+ const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)
143
150
  if (calls.length !== 1) {
144
151
  throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)
145
152
  }
153
+ const txKind = getTransactionKind(tx)
154
+ if (!txKind) {
155
+ throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')
156
+ }
157
+ const programmableTx = getProgrammableTransaction(txKind)
158
+
146
159
  const payload = calls[0]
147
- const decoded = defaultMoveCoder().decodeFunctionPayload(payload)
160
+ const decoded = defaultMoveCoder().decodeFunctionPayload(payload, programmableTx?.inputs || [])
148
161
  await handler(decoded, ctx)
149
162
  }
150
163
  return ctx.getProcessResult()
package/src/sui/utils.ts CHANGED
@@ -1,10 +1,26 @@
1
- import { SuiTransactionResponse, getMoveCallTransaction, SuiTransactionKind } from '@mysten/sui.js'
1
+ import {
2
+ SuiTransactionBlockResponse,
3
+ MoveCallSuiTransaction,
4
+ getTransactionKind,
5
+ getProgrammableTransaction,
6
+ ProgrammableTransaction,
7
+ SuiTransaction,
8
+ } from '@mysten/sui.js'
2
9
  import { TypeDescriptor } from '../move/index.js'
3
10
 
4
- export function getMoveCalls(tx: SuiTransactionResponse) {
5
- return tx.certificate.data.transactions.flatMap((tx: SuiTransactionKind) => {
6
- const call = getMoveCallTransaction(tx)
7
- if (call) {
11
+ export function getMoveCalls(txBlock: SuiTransactionBlockResponse) {
12
+ const txKind = getTransactionKind(txBlock)
13
+ if (!txKind) {
14
+ return []
15
+ }
16
+ const programmableTx: ProgrammableTransaction | undefined = getProgrammableTransaction(txKind)
17
+ if (!programmableTx) {
18
+ return []
19
+ }
20
+
21
+ return programmableTx.transactions.flatMap((tx: SuiTransaction) => {
22
+ if ('MoveCall' in tx) {
23
+ const call = tx.MoveCall as MoveCallSuiTransaction
8
24
  return [call]
9
25
  }
10
26
  return []
@@ -1,9 +1,9 @@
1
+ import { SuiEvent, SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'
1
2
  import { DataBinding, HandlerType } from '@sentio/protos'
2
3
  import { getChainId } from '../sui/network.js'
3
4
  import { TestProcessorServer } from './test-processor-server.js'
4
5
  import { parseMoveType } from '../move/types.js'
5
6
  import { SuiNetwork } from '../sui/index.js'
6
- import { MoveEvent, SuiTransactionResponse, MoveCall } from '@mysten/sui.js'
7
7
  import { getMoveCalls } from '../sui/utils.js'
8
8
  import { SPLITTER } from '../move/index.js'
9
9
 
@@ -13,11 +13,11 @@ export class SuiFacet {
13
13
  this.server = server
14
14
  }
15
15
 
16
- testEntryFunctionCall(transaction: SuiTransactionResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {
16
+ testEntryFunctionCall(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {
17
17
  return this.testEntryFunctionCalls([transaction], network)
18
18
  }
19
19
 
20
- testEntryFunctionCalls(transactions: SuiTransactionResponse[], network: SuiNetwork = SuiNetwork.MAIN_NET) {
20
+ testEntryFunctionCalls(transactions: SuiTransactionBlockResponse[], network: SuiNetwork = SuiNetwork.MAIN_NET) {
21
21
  const bindings = []
22
22
  for (const trans of transactions) {
23
23
  const binding = this.buildEntryFunctionCallBinding(trans, network)
@@ -32,14 +32,14 @@ export class SuiFacet {
32
32
  }
33
33
 
34
34
  private buildEntryFunctionCallBinding(
35
- transaction: SuiTransactionResponse,
35
+ transaction: SuiTransactionBlockResponse,
36
36
  network: SuiNetwork = SuiNetwork.MAIN_NET
37
37
  ): DataBinding | undefined {
38
- const calls: MoveCall[] = getMoveCalls(transaction)
38
+ const calls: MoveCallSuiTransaction[] = getMoveCalls(transaction)
39
39
  if (calls.length !== 1) {
40
40
  throw Error('Transaction has more than one calls')
41
41
  }
42
- const functionType = [calls[0].package.objectId, calls[0].module, calls[0].function].join(SPLITTER)
42
+ const functionType = [calls[0].package, calls[0].module, calls[0].function].join(SPLITTER)
43
43
 
44
44
  for (const config of this.server.contractConfigs) {
45
45
  if (config.contract?.chainId !== getChainId(network)) {
@@ -66,12 +66,16 @@ export class SuiFacet {
66
66
  return undefined
67
67
  }
68
68
 
69
- testEvent(transaction: SuiTransactionResponse, event: number | MoveEvent, network: SuiNetwork = SuiNetwork.MAIN_NET) {
69
+ testEvent(
70
+ transaction: SuiTransactionBlockResponse,
71
+ event: number | SuiEvent,
72
+ network: SuiNetwork = SuiNetwork.MAIN_NET
73
+ ) {
70
74
  if (typeof event !== 'number') {
71
- const transaction2: SuiTransactionResponse = {} as any
75
+ const transaction2: SuiTransactionBlockResponse = {} as any
72
76
  Object.assign(transaction2, transaction)
73
77
  transaction = transaction2
74
- transaction.effects.events = [event]
78
+ transaction.events = [event]
75
79
  event = 0
76
80
  }
77
81
  const binding = this.buildEventBinding(transaction, event, network)
@@ -82,13 +86,13 @@ export class SuiFacet {
82
86
  }
83
87
 
84
88
  private buildEventBinding(
85
- transaction: SuiTransactionResponse,
89
+ transaction: SuiTransactionBlockResponse,
86
90
  eventIdx: number,
87
91
  network: SuiNetwork = SuiNetwork.MAIN_NET
88
92
  ): DataBinding | undefined {
89
93
  // const allEvents = new Set(transaction.events.map(e => e.type))
90
- const event = transaction.effects.events?.[eventIdx]
91
- if (!event || !event.moveEvent) {
94
+ const event = transaction.events?.[eventIdx]
95
+ if (!event) {
92
96
  throw Error('Invaild test transaction, no event located')
93
97
  }
94
98
 
@@ -98,13 +102,13 @@ export class SuiFacet {
98
102
  }
99
103
  for (const eventConfig of config.moveEventConfigs) {
100
104
  for (const eventFilter of eventConfig.filters) {
101
- if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.moveEvent.type).qname) {
102
- transaction.effects.events = [event]
105
+ if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
106
+ transaction.events = [event]
103
107
  return {
104
108
  data: {
105
109
  suiEvent: {
106
110
  transaction,
107
- timestamp: new Date(transaction.timestamp_ms || 0),
111
+ timestamp: new Date(transaction.timestampMs || 0),
108
112
  slot: 10000n,
109
113
  },
110
114
  },
@@ -1,8 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "rootDir": "../..",
4
- "outDir": "../../../lib"
5
- },
6
- "extends": "../../../tsconfig.json",
7
- "include": ["./"]
8
- }