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

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 (141) hide show
  1. package/lib/aptos/aptos-chain-adapter.d.ts +14 -0
  2. package/lib/aptos/aptos-chain-adapter.js +69 -0
  3. package/lib/aptos/aptos-chain-adapter.js.map +1 -0
  4. package/lib/aptos/aptos-plugin.js +2 -0
  5. package/lib/aptos/aptos-plugin.js.map +1 -1
  6. package/lib/aptos/aptos-processor.d.ts +7 -7
  7. package/lib/aptos/aptos-processor.js +15 -22
  8. package/lib/aptos/aptos-processor.js.map +1 -1
  9. package/lib/aptos/builtin/0x1.d.ts +1138 -493
  10. package/lib/aptos/builtin/0x1.js +1939 -1458
  11. package/lib/aptos/builtin/0x1.js.map +1 -1
  12. package/lib/aptos/builtin/0x3.d.ts +227 -104
  13. package/lib/aptos/builtin/0x3.js +373 -333
  14. package/lib/aptos/builtin/0x3.js.map +1 -1
  15. package/lib/aptos/codegen/codegen.d.ts +1 -1
  16. package/lib/aptos/codegen/codegen.js +6 -47
  17. package/lib/aptos/codegen/codegen.js.map +1 -1
  18. package/lib/aptos/codegen/run.js +1 -1
  19. package/lib/aptos/codegen/run.js.map +1 -1
  20. package/lib/aptos/context.d.ts +3 -0
  21. package/lib/aptos/context.js +5 -0
  22. package/lib/aptos/context.js.map +1 -1
  23. package/lib/aptos/ext/aptos-dex.d.ts +2 -1
  24. package/lib/aptos/ext/aptos-dex.js +1 -2
  25. package/lib/aptos/ext/aptos-dex.js.map +1 -1
  26. package/lib/aptos/index.d.ts +1 -0
  27. package/lib/aptos/index.js +1 -0
  28. package/lib/aptos/index.js.map +1 -1
  29. package/lib/aptos/models.d.ts +3 -11
  30. package/lib/aptos/models.js.map +1 -1
  31. package/lib/aptos/module-client.js +1 -1
  32. package/lib/aptos/module-client.js.map +1 -1
  33. package/lib/aptos/move-coder.d.ts +10 -10
  34. package/lib/aptos/move-coder.js +37 -18
  35. package/lib/aptos/move-coder.js.map +1 -1
  36. package/lib/eth/base-processor-template.d.ts +4 -3
  37. package/lib/eth/base-processor-template.js +7 -7
  38. package/lib/eth/base-processor-template.js.map +1 -1
  39. package/lib/eth/base-processor.d.ts +9 -8
  40. package/lib/eth/base-processor.js +13 -11
  41. package/lib/eth/base-processor.js.map +1 -1
  42. package/lib/eth/eth-plugin.js +2 -0
  43. package/lib/eth/eth-plugin.js.map +1 -1
  44. package/lib/eth/eth.d.ts +7 -2
  45. package/lib/eth/eth.js +8 -1
  46. package/lib/eth/eth.js.map +1 -1
  47. package/lib/move/abstract-codegen.d.ts +11 -11
  48. package/lib/move/abstract-codegen.js +59 -22
  49. package/lib/move/abstract-codegen.js.map +1 -1
  50. package/lib/move/abstract-move-coder.d.ts +19 -25
  51. package/lib/move/abstract-move-coder.js +74 -51
  52. package/lib/move/abstract-move-coder.js.map +1 -1
  53. package/lib/move/chain-adapter.d.ts +11 -0
  54. package/lib/move/chain-adapter.js +3 -0
  55. package/lib/move/chain-adapter.js.map +1 -0
  56. package/lib/move/index.d.ts +1 -0
  57. package/lib/move/index.js +1 -0
  58. package/lib/move/index.js.map +1 -1
  59. package/lib/move/types.d.ts +28 -1
  60. package/lib/move/types.js +65 -16
  61. package/lib/move/types.js.map +1 -1
  62. package/lib/sui/builtin/0x1.d.ts +37 -18
  63. package/lib/sui/builtin/0x1.js +58 -32
  64. package/lib/sui/builtin/0x1.js.map +1 -1
  65. package/lib/sui/builtin/0x2.d.ts +275 -125
  66. package/lib/sui/builtin/0x2.js +463 -322
  67. package/lib/sui/builtin/0x2.js.map +1 -1
  68. package/lib/sui/builtin/0x3.d.ts +135 -60
  69. package/lib/sui/builtin/0x3.js +229 -272
  70. package/lib/sui/builtin/0x3.js.map +1 -1
  71. package/lib/sui/codegen/codegen.d.ts +1 -1
  72. package/lib/sui/codegen/codegen.js +10 -36
  73. package/lib/sui/codegen/codegen.js.map +1 -1
  74. package/lib/sui/codegen/run.js +1 -1
  75. package/lib/sui/codegen/run.js.map +1 -1
  76. package/lib/sui/context.d.ts +5 -1
  77. package/lib/sui/context.js +8 -1
  78. package/lib/sui/context.js.map +1 -1
  79. package/lib/sui/index.d.ts +1 -0
  80. package/lib/sui/index.js +1 -0
  81. package/lib/sui/index.js.map +1 -1
  82. package/lib/sui/models.d.ts +3 -11
  83. package/lib/sui/models.js.map +1 -1
  84. package/lib/sui/move-coder.d.ts +15 -15
  85. package/lib/sui/move-coder.js +43 -39
  86. package/lib/sui/move-coder.js.map +1 -1
  87. package/lib/sui/sui-chain-adapter.d.ts +14 -0
  88. package/lib/sui/sui-chain-adapter.js +69 -0
  89. package/lib/sui/sui-chain-adapter.js.map +1 -0
  90. package/lib/sui/sui-plugin.js +1 -0
  91. package/lib/sui/sui-plugin.js.map +1 -1
  92. package/lib/sui/sui-processor.d.ts +6 -3
  93. package/lib/sui/sui-processor.js +23 -14
  94. package/lib/sui/sui-processor.js.map +1 -1
  95. package/lib/sui/utils.d.ts +0 -2
  96. package/lib/sui/utils.js +0 -6
  97. package/lib/sui/utils.js.map +1 -1
  98. package/lib/testing/sui-facet.d.ts +2 -2
  99. package/lib/testing/sui-facet.js +16 -26
  100. package/lib/testing/sui-facet.js.map +1 -1
  101. package/package.json +4 -4
  102. package/src/aptos/aptos-chain-adapter.ts +81 -0
  103. package/src/aptos/aptos-plugin.ts +2 -0
  104. package/src/aptos/aptos-processor.ts +35 -31
  105. package/src/aptos/builtin/0x1.ts +2742 -500
  106. package/src/aptos/builtin/0x3.ts +529 -106
  107. package/src/aptos/codegen/codegen.ts +13 -57
  108. package/src/aptos/codegen/run.ts +1 -1
  109. package/src/aptos/context.ts +5 -0
  110. package/src/aptos/ext/aptos-dex.ts +4 -12
  111. package/src/aptos/index.ts +2 -0
  112. package/src/aptos/models.ts +3 -13
  113. package/src/aptos/module-client.ts +1 -1
  114. package/src/aptos/move-coder.ts +48 -25
  115. package/src/eth/base-processor-template.ts +20 -10
  116. package/src/eth/base-processor.ts +45 -25
  117. package/src/eth/eth-plugin.ts +2 -0
  118. package/src/eth/eth.ts +15 -2
  119. package/src/move/abstract-codegen.ts +74 -37
  120. package/src/move/abstract-move-coder.ts +87 -75
  121. package/src/move/chain-adapter.ts +17 -0
  122. package/src/move/index.ts +1 -0
  123. package/src/move/types.ts +83 -17
  124. package/src/sui/builtin/0x1.ts +75 -20
  125. package/src/sui/builtin/0x2.ts +670 -126
  126. package/src/sui/builtin/0x3.ts +326 -61
  127. package/src/sui/codegen/codegen.ts +17 -43
  128. package/src/sui/codegen/run.ts +1 -1
  129. package/src/sui/context.ts +9 -1
  130. package/src/sui/index.ts +1 -0
  131. package/src/sui/models.ts +3 -13
  132. package/src/sui/move-coder.ts +58 -53
  133. package/src/sui/sui-chain-adapter.ts +86 -0
  134. package/src/sui/sui-plugin.ts +1 -0
  135. package/src/sui/sui-processor.ts +39 -26
  136. package/src/sui/utils.ts +0 -8
  137. package/src/testing/sui-facet.ts +15 -30
  138. package/lib/aptos/utils.d.ts +0 -2
  139. package/lib/aptos/utils.js +0 -10
  140. package/lib/aptos/utils.js.map +0 -1
  141. package/src/aptos/utils.ts +0 -11
@@ -1,6 +1,6 @@
1
1
  import { MoveResource, Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from './move-types.js'
2
2
 
3
- import { MOVE_CODER, MoveCoder } from './move-coder.js'
3
+ import { defaultMoveCoder, MoveCoder } from './move-coder.js'
4
4
  import { AptosBindOptions, AptosNetwork, getChainId } from './network.js'
5
5
  import { AptosContext, AptosResourcesContext } from './context.js'
6
6
  import { EventInstance } from './models.js'
@@ -15,6 +15,12 @@ import {
15
15
  } from '@sentio/protos'
16
16
  import { ServerError, Status } from 'nice-grpc'
17
17
  import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'
18
+ import { PromiseOrVoid } from '../core/index.js'
19
+
20
+ const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
21
+ resourceChanges: false,
22
+ allEvents: true,
23
+ }
18
24
 
19
25
  type IndexConfigure = {
20
26
  address: string
@@ -39,12 +45,14 @@ export class AptosBaseProcessor {
39
45
  config: IndexConfigure
40
46
  eventHandlers: EventHandler<Data_AptEvent>[] = []
41
47
  callHandlers: CallHandler<Data_AptCall>[] = []
48
+ coder: MoveCoder
42
49
 
43
50
  constructor(moduleName: string, options: AptosBindOptions) {
44
51
  this.moduleName = moduleName
45
52
  this.config = configure(options)
46
53
  AptosProcessorState.INSTANCE.addValue(this)
47
- this.loadTypes(MOVE_CODER)
54
+ this.coder = defaultMoveCoder(this.config.network)
55
+ // this.loadTypes(this.coder)
48
56
  }
49
57
 
50
58
  // getABI(): MoveModule | undefined {
@@ -52,11 +60,11 @@ export class AptosBaseProcessor {
52
60
  // }
53
61
 
54
62
  public onTransaction(
55
- handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void,
63
+ handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid,
56
64
  includedFailed = false,
57
- fetchConfig?: MoveFetchConfig
65
+ fetchConfig?: Partial<MoveFetchConfig>
58
66
  ): this {
59
- const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})
67
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
60
68
 
61
69
  // const address = this.config.address
62
70
  // const moduleName = this.moduleName
@@ -87,10 +95,10 @@ export class AptosBaseProcessor {
87
95
  public onMoveEvent(
88
96
  handler: (event: EventInstance, ctx: AptosContext) => void,
89
97
  filter: EventFilter | EventFilter[],
90
- fetchConfig?: MoveFetchConfig
98
+ fetchConfig?: Partial<MoveFetchConfig>
91
99
  ): this {
92
100
  let _filters: EventFilter[] = []
93
- const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})
101
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
94
102
 
95
103
  if (Array.isArray(filter)) {
96
104
  _filters = filter
@@ -98,11 +106,10 @@ export class AptosBaseProcessor {
98
106
  _filters.push(filter)
99
107
  }
100
108
 
101
- const address = this.config.address
102
109
  // const moduleName = this.moduleName
103
110
 
104
111
  const processor = this
105
- const allEventType = new Set(_filters.map((f) => address + '::' + f.type))
112
+ const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))
106
113
 
107
114
  this.eventHandlers.push({
108
115
  handler: async function (data) {
@@ -114,11 +121,8 @@ export class AptosBaseProcessor {
114
121
  throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
115
122
  }
116
123
 
117
- const events = txn.events
118
- txn.events = []
119
124
  const processResults = []
120
-
121
- for (const [idx, evt] of events.entries()) {
125
+ for (const [idx, evt] of txn.events.entries()) {
122
126
  const typeQname = parseMoveType(evt.type).qname
123
127
  if (!allEventType.has(typeQname)) {
124
128
  continue
@@ -133,7 +137,7 @@ export class AptosBaseProcessor {
133
137
  idx
134
138
  )
135
139
  const eventInstance = evt as EventInstance
136
- const decoded = MOVE_CODER.decodeEvent<any>(eventInstance)
140
+ const decoded = await processor.coder.decodeEvent<any>(eventInstance)
137
141
  await handler(decoded || eventInstance, ctx)
138
142
  processResults.push(ctx.getProcessResult())
139
143
  }
@@ -147,12 +151,12 @@ export class AptosBaseProcessor {
147
151
  }
148
152
 
149
153
  public onEntryFunctionCall(
150
- handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,
154
+ handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid,
151
155
  filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
152
156
  fetchConfig?: Partial<MoveFetchConfig>
153
157
  ): this {
154
158
  let _filters: FunctionNameAndCallFilter[] = []
155
- const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
159
+ const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
156
160
 
157
161
  if (Array.isArray(filter)) {
158
162
  _filters = filter
@@ -181,7 +185,7 @@ export class AptosBaseProcessor {
181
185
  )
182
186
  if (tx) {
183
187
  const payload = tx.payload as TransactionPayload_EntryFunctionPayload
184
- const decoded = MOVE_CODER.decodeFunctionPayload(payload)
188
+ const decoded = await processor.coder.decodeFunctionPayload(payload)
185
189
  await handler(decoded, ctx)
186
190
  }
187
191
  return ctx.getProcessResult()
@@ -196,17 +200,17 @@ export class AptosBaseProcessor {
196
200
  return getChainId(this.config.network)
197
201
  }
198
202
 
199
- loadTypes(registry: MoveCoder) {
200
- if (registry.contains(this.config.address, this.moduleName)) {
201
- return
202
- }
203
- this.loadTypesInternal(registry)
204
- }
205
-
206
- protected loadTypesInternal(registry: MoveCoder) {
207
- // should be override by subclass
208
- console.log('')
209
- }
203
+ // loadTypes(registry: MoveCoder) {
204
+ // if (registry.contains(this.config.address, this.moduleName)) {
205
+ // return
206
+ // }
207
+ // this.loadTypesInternal(registry)
208
+ // }
209
+ //
210
+ // protected loadTypesInternal(registry: MoveCoder) {
211
+ // // should be override by subclass
212
+ // console.log('')
213
+ // }
210
214
  }
211
215
 
212
216
  export class AptosAccountProcessorState extends ListStateStorage<AptosResourcesProcessor> {
@@ -232,7 +236,7 @@ export class AptosResourcesProcessor {
232
236
  }
233
237
 
234
238
  private onInterval(
235
- handler: (resources: MoveResource[], ctx: AptosResourcesContext) => void,
239
+ handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,
236
240
  timeInterval: HandleInterval | undefined,
237
241
  versionInterval: HandleInterval | undefined,
238
242
  type: string | undefined
@@ -262,7 +266,7 @@ export class AptosResourcesProcessor {
262
266
  }
263
267
 
264
268
  public onTimeInterval(
265
- handler: (resources: MoveResource[], ctx: AptosResourcesContext) => void,
269
+ handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,
266
270
  timeIntervalInMinutes = 60,
267
271
  backfillTimeIntervalInMinutes = 240,
268
272
  type?: string
@@ -279,7 +283,7 @@ export class AptosResourcesProcessor {
279
283
  }
280
284
 
281
285
  public onVersionInterval(
282
- handler: (resources: MoveResource[], ctx: AptosResourcesContext) => void,
286
+ handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,
283
287
  versionInterval = 100000,
284
288
  backfillVersionInterval = 400000,
285
289
  typePrefix?: string