@sentio/sdk 2.13.0-rc.4 → 2.13.0-rc.6
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 +5 -2
- package/lib/aptos/aptos-chain-adapter.js +13 -0
- package/lib/aptos/aptos-chain-adapter.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +5 -4
- package/lib/aptos/aptos-processor.js +2 -2
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/ext/aptos-dex.js +1 -1
- package/lib/aptos/ext/aptos-dex.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 +7 -7
- package/lib/aptos/move-coder.js +12 -6
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +7 -7
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/abstract-move-coder.d.ts +16 -21
- package/lib/move/abstract-move-coder.js +68 -51
- package/lib/move/abstract-move-coder.js.map +1 -1
- package/lib/move/chain-adapter.d.ts +6 -4
- package/lib/move/chain-adapter.js.map +1 -1
- package/lib/move/types.d.ts +6 -0
- package/lib/move/types.js +20 -0
- package/lib/move/types.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +1 -4
- package/lib/sui/builtin/0x2.js +0 -5
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/codegen/codegen.js +3 -0
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/context.d.ts +1 -0
- package/lib/sui/context.js +2 -0
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/move-coder.d.ts +11 -11
- package/lib/sui/move-coder.js +19 -28
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/sui-chain-adapter.d.ts +7 -4
- package/lib/sui/sui-chain-adapter.js +28 -2
- package/lib/sui/sui-chain-adapter.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +4 -3
- package/lib/sui/sui-processor.js +2 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/aptos-chain-adapter.ts +18 -2
- package/src/aptos/aptos-processor.ts +8 -7
- package/src/aptos/codegen/codegen.ts +2 -2
- package/src/aptos/ext/aptos-dex.ts +4 -1
- package/src/aptos/module-client.ts +1 -1
- package/src/aptos/move-coder.ts +21 -13
- package/src/move/abstract-codegen.ts +8 -8
- package/src/move/abstract-move-coder.ts +78 -68
- package/src/move/chain-adapter.ts +7 -4
- package/src/move/types.ts +21 -0
- package/src/sui/builtin/0x2.ts +1 -4
- package/src/sui/codegen/codegen.ts +5 -2
- package/src/sui/context.ts +2 -0
- package/src/sui/move-coder.ts +35 -44
- package/src/sui/sui-chain-adapter.ts +41 -5
- package/src/sui/sui-processor.ts +6 -5
@@ -2,14 +2,27 @@ import { ChainAdapter, moduleQname, SPLITTER, TypeDescriptor } from '../move/ind
|
|
2
2
|
import { toInternalModule } from './move-types.js'
|
3
3
|
import { SuiNetwork } from './network.js'
|
4
4
|
import { InternalMoveModule, InternalMoveStruct } from '../move/internal-models.js'
|
5
|
-
import {
|
5
|
+
import {
|
6
|
+
Connection,
|
7
|
+
JsonRpcProvider,
|
8
|
+
SuiMoveNormalizedModule,
|
9
|
+
SuiEvent,
|
10
|
+
SuiMoveObject,
|
11
|
+
SuiParsedData,
|
12
|
+
} from '@mysten/sui.js'
|
6
13
|
|
7
|
-
export class SuiChainAdapter extends ChainAdapter<SuiNetwork,
|
14
|
+
export class SuiChainAdapter extends ChainAdapter<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {
|
8
15
|
static INSTANCE = new SuiChainAdapter()
|
9
16
|
|
10
|
-
async
|
17
|
+
async fetchModule(account: string, module: string, network: SuiNetwork): Promise<SuiMoveNormalizedModule> {
|
11
18
|
const client = getRpcClient(network)
|
12
|
-
return await client.
|
19
|
+
return await client.getNormalizedMoveModule({ package: account, module })
|
20
|
+
}
|
21
|
+
|
22
|
+
async fetchModules(account: string, network: SuiNetwork): Promise<SuiMoveNormalizedModule[]> {
|
23
|
+
const client = getRpcClient(network)
|
24
|
+
const modules = await client.getNormalizedMoveModulesByPackage({ package: account })
|
25
|
+
return Object.values(modules)
|
13
26
|
}
|
14
27
|
|
15
28
|
getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[] {
|
@@ -19,7 +32,7 @@ export class SuiChainAdapter extends ChainAdapter<SuiNetwork, SuiMoveNormalizedM
|
|
19
32
|
return params.slice(0, params.length - 1)
|
20
33
|
}
|
21
34
|
|
22
|
-
toInternalModules(modules:
|
35
|
+
toInternalModules(modules: SuiMoveNormalizedModule[]): InternalMoveModule[] {
|
23
36
|
return Object.values(modules).map(toInternalModule)
|
24
37
|
}
|
25
38
|
|
@@ -35,6 +48,29 @@ export class SuiChainAdapter extends ChainAdapter<SuiNetwork, SuiMoveNormalizedM
|
|
35
48
|
}
|
36
49
|
return eventMap
|
37
50
|
}
|
51
|
+
|
52
|
+
getType(base: SuiEvent | SuiMoveObject): string {
|
53
|
+
return base.type
|
54
|
+
}
|
55
|
+
|
56
|
+
getData(val: SuiEvent | SuiMoveObject) {
|
57
|
+
if (SuiEvent.is(val)) {
|
58
|
+
return val.parsedJson as any
|
59
|
+
}
|
60
|
+
if (SuiParsedData.is(val)) {
|
61
|
+
return val.fields as any
|
62
|
+
}
|
63
|
+
// if (SuiMoveObject.is(val)) {
|
64
|
+
// return val.fields as any
|
65
|
+
// }
|
66
|
+
// This may not be perfect, just think everything has
|
67
|
+
if ('fields' in val) {
|
68
|
+
if ('type' in val && Object.keys(val).length === 2) {
|
69
|
+
return val.fields as any
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return val as any
|
73
|
+
}
|
38
74
|
}
|
39
75
|
|
40
76
|
function getRpcEndpoint(network: SuiNetwork): string {
|
package/src/sui/sui-processor.ts
CHANGED
@@ -22,6 +22,7 @@ import {
|
|
22
22
|
import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'
|
23
23
|
import { getMoveCalls } from './utils.js'
|
24
24
|
import { defaultMoveCoder, MoveCoder } from './move-coder.js'
|
25
|
+
import { PromiseOrVoid } from '../core/index.js'
|
25
26
|
// import { dynamic_field } from './builtin/0x2.js'
|
26
27
|
|
27
28
|
class IndexConfigure {
|
@@ -112,7 +113,7 @@ export class SuiBaseProcessor {
|
|
112
113
|
idx
|
113
114
|
)
|
114
115
|
|
115
|
-
const decoded = processor.coder.decodeEvent<any>(evt)
|
116
|
+
const decoded = await processor.coder.decodeEvent<any>(evt)
|
116
117
|
await handler(decoded || evt, ctx)
|
117
118
|
processResults.push(ctx.getProcessResult())
|
118
119
|
}
|
@@ -171,7 +172,7 @@ export class SuiBaseProcessor {
|
|
171
172
|
const programmableTx = getProgrammableTransaction(txKind)
|
172
173
|
|
173
174
|
const payload = calls[0]
|
174
|
-
const decoded = processor.coder.decodeFunctionPayload(payload, programmableTx?.inputs || [])
|
175
|
+
const decoded = await processor.coder.decodeFunctionPayload(payload, programmableTx?.inputs || [])
|
175
176
|
await handler(decoded, ctx)
|
176
177
|
}
|
177
178
|
return ctx.getProcessResult()
|
@@ -221,7 +222,7 @@ abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
221
222
|
protected abstract transformObjects(objects: SuiMoveObject[]): HandlerType[]
|
222
223
|
|
223
224
|
protected onInterval(
|
224
|
-
handler: (resources: HandlerType[], ctx: SuiObjectsContext) =>
|
225
|
+
handler: (resources: HandlerType[], ctx: SuiObjectsContext) => PromiseOrVoid,
|
225
226
|
timeInterval: HandleInterval | undefined,
|
226
227
|
versionInterval: HandleInterval | undefined,
|
227
228
|
type: string | undefined
|
@@ -246,7 +247,7 @@ abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
246
247
|
}
|
247
248
|
|
248
249
|
public onTimeInterval(
|
249
|
-
handler: (objects: HandlerType[], ctx: SuiObjectsContext) =>
|
250
|
+
handler: (objects: HandlerType[], ctx: SuiObjectsContext) => PromiseOrVoid,
|
250
251
|
timeIntervalInMinutes = 60,
|
251
252
|
backfillTimeIntervalInMinutes = 240,
|
252
253
|
type?: string
|
@@ -263,7 +264,7 @@ abstract class SuiBaseObjectsProcessor<HandlerType> {
|
|
263
264
|
}
|
264
265
|
|
265
266
|
public onSlotInterval(
|
266
|
-
handler: (objects: HandlerType[], ctx: SuiObjectsContext) =>
|
267
|
+
handler: (objects: HandlerType[], ctx: SuiObjectsContext) => PromiseOrVoid,
|
267
268
|
slotInterval = 100000,
|
268
269
|
backfillSlotInterval = 400000,
|
269
270
|
type?: string
|