@sentio/sdk 2.13.0-rc.1 → 2.13.0-rc.11
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.
- package/lib/aptos/aptos-chain-adapter.d.ts +14 -0
- package/lib/aptos/aptos-chain-adapter.js +69 -0
- package/lib/aptos/aptos-chain-adapter.js.map +1 -0
- package/lib/aptos/aptos-plugin.js +5 -2
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +7 -7
- package/lib/aptos/aptos-processor.js +15 -22
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +1138 -493
- package/lib/aptos/builtin/0x1.js +1939 -1458
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +227 -104
- package/lib/aptos/builtin/0x3.js +373 -333
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/codegen/codegen.d.ts +1 -1
- package/lib/aptos/codegen/codegen.js +6 -47
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/codegen/run.js +1 -1
- package/lib/aptos/codegen/run.js.map +1 -1
- package/lib/aptos/context.d.ts +3 -0
- package/lib/aptos/context.js +5 -0
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/ext/aptos-dex.d.ts +2 -1
- package/lib/aptos/ext/aptos-dex.js +1 -2
- package/lib/aptos/ext/aptos-dex.js.map +1 -1
- package/lib/aptos/index.d.ts +2 -0
- package/lib/aptos/index.js +2 -0
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +3 -11
- package/lib/aptos/models.js.map +1 -1
- package/lib/aptos/module-client.js +1 -1
- package/lib/aptos/module-client.js.map +1 -1
- package/lib/aptos/move-coder.d.ts +10 -10
- package/lib/aptos/move-coder.js +37 -18
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/utils.d.ts +2 -2
- package/lib/aptos/utils.js +10 -7
- package/lib/aptos/utils.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +4 -3
- package/lib/eth/base-processor-template.js +7 -7
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +9 -8
- package/lib/eth/base-processor.js +13 -11
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.js +8 -5
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +9 -2
- package/lib/eth/eth.js +23 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +11 -11
- package/lib/move/abstract-codegen.js +59 -22
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/abstract-move-coder.d.ts +19 -25
- package/lib/move/abstract-move-coder.js +74 -51
- package/lib/move/abstract-move-coder.js.map +1 -1
- package/lib/move/chain-adapter.d.ts +11 -0
- package/lib/move/chain-adapter.js +3 -0
- package/lib/move/chain-adapter.js.map +1 -0
- package/lib/move/index.d.ts +1 -0
- package/lib/move/index.js +1 -0
- package/lib/move/index.js.map +1 -1
- package/lib/move/types.d.ts +31 -1
- package/lib/move/types.js +75 -16
- package/lib/move/types.js.map +1 -1
- package/lib/move/utils.js +6 -1
- package/lib/move/utils.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts +37 -18
- package/lib/sui/builtin/0x1.js +58 -32
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +275 -125
- package/lib/sui/builtin/0x2.js +463 -322
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +135 -60
- package/lib/sui/builtin/0x3.js +229 -272
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/codegen/codegen.d.ts +1 -1
- package/lib/sui/codegen/codegen.js +10 -36
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/codegen/run.js +1 -1
- package/lib/sui/codegen/run.js.map +1 -1
- package/lib/sui/context.d.ts +5 -1
- package/lib/sui/context.js +8 -1
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/index.d.ts +1 -0
- package/lib/sui/index.js +1 -0
- package/lib/sui/index.js.map +1 -1
- package/lib/sui/models.d.ts +3 -11
- package/lib/sui/models.js.map +1 -1
- package/lib/sui/move-coder.d.ts +15 -15
- package/lib/sui/move-coder.js +43 -39
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/sui-chain-adapter.d.ts +14 -0
- package/lib/sui/sui-chain-adapter.js +69 -0
- package/lib/sui/sui-chain-adapter.js.map +1 -0
- package/lib/sui/sui-plugin.js +4 -2
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +6 -3
- package/lib/sui/sui-processor.js +23 -14
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/utils.d.ts +3 -3
- package/lib/sui/utils.js +20 -5
- package/lib/sui/utils.js.map +1 -1
- package/lib/testing/sui-facet.d.ts +2 -2
- package/lib/testing/sui-facet.js +16 -26
- package/lib/testing/sui-facet.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/aptos-chain-adapter.ts +81 -0
- package/src/aptos/aptos-plugin.ts +5 -2
- package/src/aptos/aptos-processor.ts +35 -31
- package/src/aptos/builtin/0x1.ts +2742 -500
- package/src/aptos/builtin/0x3.ts +529 -106
- package/src/aptos/codegen/codegen.ts +13 -57
- package/src/aptos/codegen/run.ts +1 -1
- package/src/aptos/context.ts +5 -0
- package/src/aptos/ext/aptos-dex.ts +4 -12
- package/src/aptos/index.ts +4 -0
- package/src/aptos/models.ts +3 -13
- package/src/aptos/module-client.ts +1 -1
- package/src/aptos/move-coder.ts +48 -25
- package/src/aptos/utils.ts +11 -8
- package/src/eth/base-processor-template.ts +20 -10
- package/src/eth/base-processor.ts +45 -25
- package/src/eth/eth-plugin.ts +9 -6
- package/src/eth/eth.ts +31 -2
- package/src/move/abstract-codegen.ts +74 -37
- package/src/move/abstract-move-coder.ts +87 -75
- package/src/move/chain-adapter.ts +17 -0
- package/src/move/index.ts +1 -0
- package/src/move/types.ts +97 -17
- package/src/move/utils.ts +6 -1
- package/src/sui/builtin/0x1.ts +75 -20
- package/src/sui/builtin/0x2.ts +670 -126
- package/src/sui/builtin/0x3.ts +326 -61
- package/src/sui/codegen/codegen.ts +17 -43
- package/src/sui/codegen/run.ts +1 -1
- package/src/sui/context.ts +9 -1
- package/src/sui/index.ts +1 -0
- package/src/sui/models.ts +3 -13
- package/src/sui/move-coder.ts +58 -53
- package/src/sui/sui-chain-adapter.ts +86 -0
- package/src/sui/sui-plugin.ts +4 -2
- package/src/sui/sui-processor.ts +39 -26
- package/src/sui/utils.ts +25 -5
- package/src/testing/sui-facet.ts +15 -30
@@ -1,6 +1,6 @@
|
|
1
1
|
import { MoveResource, Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from './move-types.js'
|
2
2
|
|
3
|
-
import {
|
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.
|
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) =>
|
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 =
|
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 =
|
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 =
|
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) =>
|
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 =
|
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
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
}
|
205
|
-
|
206
|
-
protected loadTypesInternal(registry: MoveCoder) {
|
207
|
-
|
208
|
-
|
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) =>
|
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) =>
|
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) =>
|
286
|
+
handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid,
|
283
287
|
versionInterval = 100000,
|
284
288
|
backfillVersionInterval = 400000,
|
285
289
|
typePrefix?: string
|