@sentio/sdk 2.13.0-rc.2 → 2.13.0-rc.4
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 +11 -0
- package/lib/aptos/aptos-chain-adapter.js +56 -0
- package/lib/aptos/aptos-chain-adapter.js.map +1 -0
- package/lib/aptos/aptos-processor.d.ts +1 -2
- package/lib/aptos/aptos-processor.js +6 -14
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.js +2 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +2 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +4 -45
- package/lib/aptos/codegen/codegen.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.js +1 -2
- package/lib/aptos/ext/aptos-dex.js.map +1 -1
- package/lib/aptos/move-coder.d.ts +4 -5
- package/lib/aptos/move-coder.js +14 -8
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +4 -4
- package/lib/move/abstract-codegen.js +22 -10
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/abstract-move-coder.d.ts +5 -2
- package/lib/move/abstract-move-coder.js +7 -1
- package/lib/move/abstract-move-coder.js.map +1 -1
- package/lib/move/chain-adapter.d.ts +9 -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/sui/builtin/0x1.js +2 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.js +2 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.js +2 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/codegen/codegen.js +4 -34
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/context.d.ts +2 -0
- package/lib/sui/context.js +3 -0
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/move-coder.d.ts +5 -5
- package/lib/sui/move-coder.js +14 -8
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/sui-chain-adapter.d.ts +11 -0
- package/lib/sui/sui-chain-adapter.js +43 -0
- package/lib/sui/sui-chain-adapter.js.map +1 -0
- package/lib/sui/sui-processor.d.ts +2 -0
- package/lib/sui/sui-processor.js +4 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/utils.d.ts +0 -2
- package/lib/sui/utils.js +0 -6
- package/lib/sui/utils.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/aptos-chain-adapter.ts +65 -0
- package/src/aptos/aptos-processor.ts +17 -15
- package/src/aptos/builtin/0x1.ts +2 -1
- package/src/aptos/builtin/0x3.ts +2 -1
- package/src/aptos/codegen/codegen.ts +5 -54
- package/src/aptos/context.ts +5 -0
- package/src/aptos/ext/aptos-dex.ts +2 -11
- package/src/aptos/move-coder.ts +17 -12
- package/src/move/abstract-codegen.ts +28 -17
- package/src/move/abstract-move-coder.ts +10 -3
- package/src/move/chain-adapter.ts +14 -0
- package/src/move/index.ts +1 -0
- package/src/sui/builtin/0x1.ts +2 -1
- package/src/sui/builtin/0x2.ts +2 -1
- package/src/sui/builtin/0x3.ts +2 -1
- package/src/sui/codegen/codegen.ts +5 -40
- package/src/sui/context.ts +3 -0
- package/src/sui/move-coder.ts +18 -11
- package/src/sui/sui-chain-adapter.ts +50 -0
- package/src/sui/sui-processor.ts +5 -3
- package/src/sui/utils.ts +0 -8
- package/lib/aptos/utils.d.ts +0 -2
- package/lib/aptos/utils.js +0 -10
- package/lib/aptos/utils.js.map +0 -1
- package/src/aptos/utils.ts +0 -11
@@ -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
|
+
}
|
package/src/sui/sui-processor.ts
CHANGED
@@ -21,7 +21,7 @@ import {
|
|
21
21
|
} from '@mysten/sui.js'
|
22
22
|
import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'
|
23
23
|
import { getMoveCalls } from './utils.js'
|
24
|
-
import { defaultMoveCoder } from './move-coder.js'
|
24
|
+
import { defaultMoveCoder, MoveCoder } from './move-coder.js'
|
25
25
|
// import { dynamic_field } from './builtin/0x2.js'
|
26
26
|
|
27
27
|
class IndexConfigure {
|
@@ -52,11 +52,13 @@ export class SuiBaseProcessor {
|
|
52
52
|
|
53
53
|
eventHandlers: EventHandler<Data_SuiEvent>[] = []
|
54
54
|
callHandlers: CallHandler<Data_SuiCall>[] = []
|
55
|
+
coder: MoveCoder
|
55
56
|
|
56
57
|
constructor(name: string, options: SuiBindOptions) {
|
57
58
|
this.moduleName = name
|
58
59
|
this.config = configure(options)
|
59
60
|
SuiProcessorState.INSTANCE.addValue(this)
|
61
|
+
this.coder = defaultMoveCoder(this.config.network)
|
60
62
|
}
|
61
63
|
|
62
64
|
getChainId(): string {
|
@@ -110,7 +112,7 @@ export class SuiBaseProcessor {
|
|
110
112
|
idx
|
111
113
|
)
|
112
114
|
|
113
|
-
const decoded =
|
115
|
+
const decoded = processor.coder.decodeEvent<any>(evt)
|
114
116
|
await handler(decoded || evt, ctx)
|
115
117
|
processResults.push(ctx.getProcessResult())
|
116
118
|
}
|
@@ -169,7 +171,7 @@ export class SuiBaseProcessor {
|
|
169
171
|
const programmableTx = getProgrammableTransaction(txKind)
|
170
172
|
|
171
173
|
const payload = calls[0]
|
172
|
-
const decoded =
|
174
|
+
const decoded = processor.coder.decodeFunctionPayload(payload, programmableTx?.inputs || [])
|
173
175
|
await handler(decoded, ctx)
|
174
176
|
}
|
175
177
|
return ctx.getProcessResult()
|
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
|
-
}
|
package/lib/aptos/utils.d.ts
DELETED
package/lib/aptos/utils.js
DELETED
package/lib/aptos/utils.js.map
DELETED
@@ -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"]}
|
package/src/aptos/utils.ts
DELETED
@@ -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
|
-
}
|