@sentio/sdk 2.23.0-rc.1 → 2.24.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.
- package/lib/aptos/aptos-processor.d.ts +1 -2
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +11 -11
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +6 -6
- package/lib/aptos/builtin/0x1.d.ts +342 -339
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +65 -188
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +73 -54
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +24 -65
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/codegen/codegen.d.ts.map +1 -1
- package/lib/aptos/codegen/codegen.js +40 -10
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/context.d.ts +1 -2
- package/lib/aptos/context.d.ts.map +1 -1
- package/lib/aptos/context.js +2 -2
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/ext/coin-event.js +1 -1
- package/lib/aptos/ext/coin.js +193 -193
- package/lib/aptos/ext/coin.js.map +1 -1
- package/lib/aptos/index.d.ts +4 -4
- package/lib/aptos/index.d.ts.map +1 -1
- package/lib/aptos/index.js +3 -4
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +2 -2
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/aptos/move-coder.d.ts +1 -13
- package/lib/aptos/move-coder.d.ts.map +1 -1
- package/lib/aptos/move-coder.js +4 -55
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/network.d.ts +1 -0
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +8 -1
- package/lib/aptos/network.js.map +1 -1
- package/lib/eth/codegen/codegen.d.ts.map +1 -1
- package/lib/eth/codegen/codegen.js +4 -3
- package/lib/eth/codegen/codegen.js.map +1 -1
- package/lib/move/ext/move-dex.d.ts +1 -1
- package/lib/move/ext/move-dex.d.ts.map +1 -1
- package/lib/move/ext/move-dex.js +4 -4
- package/lib/move/index.d.ts +1 -4
- package/lib/move/index.d.ts.map +1 -1
- package/lib/move/index.js +1 -4
- package/lib/move/index.js.map +1 -1
- package/lib/move/move-context.d.ts +3 -3
- package/lib/move/move-context.d.ts.map +1 -1
- package/lib/move/move-context.js.map +1 -1
- package/lib/move/shared-network-codegen.d.ts +14 -0
- package/lib/move/shared-network-codegen.d.ts.map +1 -0
- package/lib/move/shared-network-codegen.js +116 -0
- package/lib/move/shared-network-codegen.js.map +1 -0
- package/lib/sui/builtin/0x1.d.ts +4 -2
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +7 -14
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +52 -168
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +24 -65
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +113 -331
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +13 -32
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/codegen/codegen.d.ts.map +1 -1
- package/lib/sui/codegen/codegen.js +72 -51
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/context.d.ts +4 -4
- package/lib/sui/context.d.ts.map +1 -1
- package/lib/sui/context.js +2 -2
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/ext/coin.js +74 -74
- package/lib/sui/ext/move-dex.d.ts +2 -3
- package/lib/sui/ext/move-dex.d.ts.map +1 -1
- package/lib/sui/index.d.ts +4 -4
- package/lib/sui/index.d.ts.map +1 -1
- package/lib/sui/index.js +4 -4
- package/lib/sui/index.js.map +1 -1
- package/lib/sui/models.d.ts +2 -2
- package/lib/sui/models.d.ts.map +1 -1
- package/lib/sui/move-coder.d.ts +1 -16
- package/lib/sui/move-coder.d.ts.map +1 -1
- package/lib/sui/move-coder.js +4 -93
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/network.d.ts +3 -2
- package/lib/sui/network.d.ts.map +1 -1
- package/lib/sui/network.js +10 -3
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +1 -1
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +7 -7
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +5 -5
- package/lib/sui/sui-processor.d.ts +2 -2
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +10 -10
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/utils.d.ts +2 -2
- package/lib/sui/utils.d.ts.map +1 -1
- package/lib/sui/utils.js +3 -4
- package/lib/sui/utils.js.map +1 -1
- package/lib/testing/aptos-facet.d.ts.map +1 -1
- package/lib/testing/aptos-facet.js +8 -9
- package/lib/testing/aptos-facet.js.map +1 -1
- package/lib/testing/sui-facet.d.ts +1 -1
- package/lib/testing/sui-facet.d.ts.map +1 -1
- package/lib/testing/sui-facet.js +8 -9
- package/lib/testing/sui-facet.js.map +1 -1
- package/package.json +10 -7
- package/src/aptos/aptos-processor.ts +13 -12
- package/src/aptos/aptos-resource-processor-template.ts +7 -7
- package/src/aptos/builtin/0x1.ts +970 -1168
- package/src/aptos/builtin/0x3.ts +205 -249
- package/src/aptos/codegen/codegen.ts +50 -11
- package/src/aptos/context.ts +4 -4
- package/src/aptos/ext/coin-event.ts +2 -2
- package/src/aptos/ext/coin.ts +193 -193
- package/src/aptos/index.ts +15 -4
- package/src/aptos/models.ts +2 -2
- package/src/aptos/move-coder.ts +4 -73
- package/src/aptos/network.ts +9 -1
- package/src/eth/codegen/codegen.ts +5 -4
- package/src/move/ext/move-dex.ts +5 -5
- package/src/move/index.ts +2 -4
- package/src/move/move-context.ts +3 -3
- package/src/move/shared-network-codegen.ts +160 -0
- package/src/sui/builtin/0x1.ts +17 -41
- package/src/sui/builtin/0x2.ts +196 -410
- package/src/sui/builtin/0x3.ts +271 -479
- package/src/sui/codegen/codegen.ts +80 -54
- package/src/sui/context.ts +8 -7
- package/src/sui/ext/coin.ts +75 -75
- package/src/sui/ext/move-dex.ts +3 -3
- package/src/sui/index.ts +5 -5
- package/src/sui/models.ts +2 -2
- package/src/sui/move-coder.ts +4 -108
- package/src/sui/network.ts +12 -4
- package/src/sui/sui-object-processor-template.ts +8 -8
- package/src/sui/sui-object-processor.ts +6 -6
- package/src/sui/sui-processor.ts +12 -16
- package/src/sui/utils.ts +6 -7
- package/src/testing/aptos-facet.ts +8 -9
- package/src/testing/sui-facet.ts +9 -10
- package/lib/aptos/aptos-chain-adapter.d.ts +0 -15
- package/lib/aptos/aptos-chain-adapter.d.ts.map +0 -1
- package/lib/aptos/aptos-chain-adapter.js +0 -72
- package/lib/aptos/aptos-chain-adapter.js.map +0 -1
- package/lib/aptos/module-client.d.ts +0 -7
- package/lib/aptos/module-client.d.ts.map +0 -1
- package/lib/aptos/module-client.js +0 -25
- package/lib/aptos/module-client.js.map +0 -1
- package/lib/aptos/module-client.test.d.ts +0 -2
- package/lib/aptos/module-client.test.d.ts.map +0 -1
- package/lib/aptos/module-client.test.js.map +0 -1
- package/lib/aptos/move-types.d.ts +0 -17
- package/lib/aptos/move-types.d.ts.map +0 -1
- package/lib/aptos/move-types.js +0 -53
- package/lib/aptos/move-types.js.map +0 -1
- package/lib/aptos/utils.d.ts +0 -2
- package/lib/aptos/utils.d.ts.map +0 -1
- package/lib/aptos/utils.js +0 -16
- package/lib/aptos/utils.js.map +0 -1
- package/lib/move/abstract-codegen.d.ts +0 -50
- package/lib/move/abstract-codegen.d.ts.map +0 -1
- package/lib/move/abstract-codegen.js +0 -489
- package/lib/move/abstract-codegen.js.map +0 -1
- package/lib/move/abstract-move-coder.d.ts +0 -29
- package/lib/move/abstract-move-coder.d.ts.map +0 -1
- package/lib/move/abstract-move-coder.js +0 -301
- package/lib/move/abstract-move-coder.js.map +0 -1
- package/lib/move/account.d.ts +0 -16
- package/lib/move/account.d.ts.map +0 -1
- package/lib/move/account.js +0 -71
- package/lib/move/account.js.map +0 -1
- package/lib/move/chain-adapter.d.ts +0 -13
- package/lib/move/chain-adapter.d.ts.map +0 -1
- package/lib/move/chain-adapter.js +0 -7
- package/lib/move/chain-adapter.js.map +0 -1
- package/lib/move/internal-models.d.ts +0 -35
- package/lib/move/internal-models.d.ts.map +0 -1
- package/lib/move/internal-models.js +0 -7
- package/lib/move/internal-models.js.map +0 -1
- package/lib/move/ts-type.test.d.ts +0 -2
- package/lib/move/ts-type.test.d.ts.map +0 -1
- package/lib/move/ts-type.test.js.map +0 -1
- package/lib/move/types.d.ts +0 -42
- package/lib/move/types.d.ts.map +0 -1
- package/lib/move/types.js +0 -205
- package/lib/move/types.js.map +0 -1
- package/lib/move/utils.d.ts +0 -16
- package/lib/move/utils.d.ts.map +0 -1
- package/lib/move/utils.js +0 -53
- package/lib/move/utils.js.map +0 -1
- package/lib/move/utils.test.d.ts +0 -2
- package/lib/move/utils.test.d.ts.map +0 -1
- package/lib/move/utils.test.js.map +0 -1
- package/lib/sui/module-client.d.ts +0 -4
- package/lib/sui/module-client.d.ts.map +0 -1
- package/lib/sui/module-client.js +0 -7
- package/lib/sui/module-client.js.map +0 -1
- package/lib/sui/move-types.d.ts +0 -9
- package/lib/sui/move-types.d.ts.map +0 -1
- package/lib/sui/move-types.js +0 -82
- package/lib/sui/move-types.js.map +0 -1
- package/lib/sui/sui-chain-adapter.d.ts +0 -15
- package/lib/sui/sui-chain-adapter.d.ts.map +0 -1
- package/lib/sui/sui-chain-adapter.js +0 -71
- package/lib/sui/sui-chain-adapter.js.map +0 -1
- package/src/aptos/aptos-chain-adapter.ts +0 -86
- package/src/aptos/module-client.ts +0 -30
- package/src/aptos/move-types.ts +0 -73
- package/src/aptos/utils.ts +0 -15
- package/src/move/abstract-codegen.ts +0 -596
- package/src/move/abstract-move-coder.ts +0 -337
- package/src/move/account.ts +0 -81
- package/src/move/chain-adapter.ts +0 -24
- package/src/move/internal-models.ts +0 -40
- package/src/move/types.ts +0 -241
- package/src/move/utils.ts +0 -69
- package/src/sui/module-client.ts +0 -7
- package/src/sui/move-types.ts +0 -108
- package/src/sui/sui-chain-adapter.ts +0 -93
package/src/aptos/index.ts
CHANGED
@@ -1,15 +1,26 @@
|
|
1
|
-
export * from './move-types.js'
|
2
1
|
export type { TypedEventInstance, TypedFunctionPayload, TypedMoveResource } from './models.js'
|
3
|
-
export { defaultMoveCoder, MoveCoder } from './move-coder.js'
|
4
2
|
export { AptosBaseProcessor, AptosResourcesProcessor, AptosModulesProcessor } from './aptos-processor.js'
|
5
3
|
export { AptosResourceProcessorTemplate } from './aptos-resource-processor-template.js'
|
6
4
|
export { AptosContext, AptosResourcesContext } from './context.js'
|
7
5
|
export { AptosBindOptions, AptosNetwork } from './network.js'
|
8
6
|
export * from './api.js'
|
9
|
-
export { ModuleClient } from './module-client.js'
|
10
7
|
|
11
8
|
export { AptosPlugin } from './aptos-plugin.js'
|
12
9
|
|
13
|
-
export {
|
10
|
+
export { defaultMoveCoder } from './move-coder.js'
|
11
|
+
|
12
|
+
export type {
|
13
|
+
Event,
|
14
|
+
Transaction_UserTransaction,
|
15
|
+
Address,
|
16
|
+
MoveResource,
|
17
|
+
MoveFunction,
|
18
|
+
MoveStruct,
|
19
|
+
MoveModuleBytecode,
|
20
|
+
TransactionPayload_EntryFunctionPayload
|
21
|
+
} from '@typemove/aptos'
|
22
|
+
export { MoveCoder } from '@typemove/aptos'
|
23
|
+
|
24
|
+
export { BUILTIN_TYPES } from '@typemove/move'
|
14
25
|
|
15
26
|
// export * from './utils.js'
|
package/src/aptos/models.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Event, MoveResource, TransactionPayload_EntryFunctionPayload } from '
|
2
|
-
import { DecodedStruct } from '
|
1
|
+
import { Event, MoveResource, TransactionPayload_EntryFunctionPayload } from '@typemove/aptos'
|
2
|
+
import { DecodedStruct } from '@typemove/move'
|
3
3
|
|
4
4
|
export type TypedEventInstance<T> = DecodedStruct<Event, T>
|
5
5
|
export type TypedMoveResource<T> = DecodedStruct<MoveResource, T>
|
package/src/aptos/move-coder.ts
CHANGED
@@ -1,77 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
MoveModuleBytecode,
|
4
|
-
MoveResource,
|
5
|
-
toInternalModule,
|
6
|
-
TransactionPayload_EntryFunctionPayload,
|
7
|
-
} from './move-types.js'
|
1
|
+
import { AptosNetwork, getRpcEndpoint } from './network.js'
|
2
|
+
import { MoveCoder } from '@typemove/aptos'
|
8
3
|
|
9
|
-
|
10
|
-
|
11
|
-
import { AptosNetwork } from './network.js'
|
12
|
-
import { AptosChainAdapter } from './aptos-chain-adapter.js'
|
13
|
-
import { parseMoveType, TypeDescriptor } from '../move/index.js'
|
14
|
-
|
15
|
-
export class MoveCoder extends AbstractMoveCoder<AptosNetwork, MoveModuleBytecode, Event | MoveResource> {
|
16
|
-
constructor(network: AptosNetwork) {
|
17
|
-
super(network)
|
18
|
-
this.adapter = new AptosChainAdapter()
|
19
|
-
}
|
20
|
-
|
21
|
-
load(module: MoveModuleBytecode) {
|
22
|
-
if (!module.abi) {
|
23
|
-
throw Error('Module without abi')
|
24
|
-
}
|
25
|
-
let m = this.moduleMapping.get(module.abi.address + '::' + module.abi.name)
|
26
|
-
// if (this.contains(module.abi.address, module.abi.name)) {
|
27
|
-
// return
|
28
|
-
// }
|
29
|
-
if (m) {
|
30
|
-
return m
|
31
|
-
}
|
32
|
-
m = toInternalModule(module)
|
33
|
-
this.loadInternal(m)
|
34
|
-
return m
|
35
|
-
}
|
36
|
-
|
37
|
-
decodeEvent<T>(event: Event): Promise<TypedEventInstance<T> | undefined> {
|
38
|
-
return this.decodedStruct(event)
|
39
|
-
}
|
40
|
-
filterAndDecodeEvents<T>(type: string | TypeDescriptor<T>, resources: Event[]): Promise<TypedEventInstance<T>[]> {
|
41
|
-
if (typeof type === 'string') {
|
42
|
-
type = parseMoveType(type)
|
43
|
-
}
|
44
|
-
return this.filterAndDecodeStruct(type, resources)
|
45
|
-
}
|
46
|
-
decodeResource<T>(res: MoveResource): Promise<TypedMoveResource<T> | undefined> {
|
47
|
-
return this.decodedStruct(res)
|
48
|
-
}
|
49
|
-
filterAndDecodeResources<T>(
|
50
|
-
type: string | TypeDescriptor<T>,
|
51
|
-
resources: MoveResource[]
|
52
|
-
): Promise<TypedMoveResource<T>[]> {
|
53
|
-
if (typeof type === 'string') {
|
54
|
-
type = parseMoveType(type)
|
55
|
-
}
|
56
|
-
return this.filterAndDecodeStruct(type, resources)
|
57
|
-
}
|
58
|
-
|
59
|
-
async decodeFunctionPayload(
|
60
|
-
payload: TransactionPayload_EntryFunctionPayload
|
61
|
-
): Promise<TransactionPayload_EntryFunctionPayload> {
|
62
|
-
const func = await this.getMoveFunction(payload.function)
|
63
|
-
const params = this.adapter.getMeaningfulFunctionParams(func.params)
|
64
|
-
const argumentsDecoded = await this.decodeArray(payload.arguments, params)
|
65
|
-
|
66
|
-
return {
|
67
|
-
...payload,
|
68
|
-
arguments_decoded: argumentsDecoded,
|
69
|
-
} as TypedFunctionPayload<any>
|
70
|
-
}
|
71
|
-
}
|
72
|
-
|
73
|
-
const MOVE_CODER = new MoveCoder(AptosNetwork.MAIN_NET)
|
74
|
-
const TESTNET_MOVE_CODER = new MoveCoder(AptosNetwork.TEST_NET)
|
4
|
+
const MOVE_CODER = new MoveCoder(getRpcEndpoint(AptosNetwork.MAIN_NET))
|
5
|
+
const TESTNET_MOVE_CODER = new MoveCoder(getRpcEndpoint(AptosNetwork.TEST_NET))
|
75
6
|
|
76
7
|
export function defaultMoveCoder(network: AptosNetwork = AptosNetwork.MAIN_NET): MoveCoder {
|
77
8
|
if (network == AptosNetwork.MAIN_NET) {
|
package/src/aptos/network.ts
CHANGED
@@ -6,7 +6,7 @@ export type AptosNetwork = AptosChainId
|
|
6
6
|
export const AptosNetwork = <const>{
|
7
7
|
MAIN_NET: AptosChainId.APTOS_MAINNET,
|
8
8
|
TEST_NET: AptosChainId.APTOS_TESTNET,
|
9
|
-
DEV_NET: AptosChainId.APTOS_DEVNET
|
9
|
+
DEV_NET: AptosChainId.APTOS_DEVNET
|
10
10
|
}
|
11
11
|
|
12
12
|
export class AptosBindOptions {
|
@@ -16,3 +16,11 @@ export class AptosBindOptions {
|
|
16
16
|
startVersion?: bigint | number
|
17
17
|
baseLabels?: Labels
|
18
18
|
}
|
19
|
+
|
20
|
+
export function getRpcEndpoint(network: AptosNetwork): string {
|
21
|
+
switch (network) {
|
22
|
+
case AptosNetwork.TEST_NET:
|
23
|
+
return 'https://testnet.aptoslabs.com/'
|
24
|
+
}
|
25
|
+
return 'https://mainnet.aptoslabs.com/'
|
26
|
+
}
|
@@ -2,7 +2,8 @@ import { loadFileDescriptions, processOutput, skipEmptyAbis } from 'typechain/di
|
|
2
2
|
import * as fs from 'fs'
|
3
3
|
import { DEFAULT_FLAGS, Services } from 'typechain'
|
4
4
|
import EthersSentio, { SentioEthersConfig } from './ethers-sentio.js'
|
5
|
-
|
5
|
+
// @ts-ignore - no types
|
6
|
+
import * as prettier from 'prettier2'
|
6
7
|
import path from 'path'
|
7
8
|
import mkdirp from 'mkdirp'
|
8
9
|
import { YamlContractConfig } from '../../core/yaml-contract-config.js'
|
@@ -20,7 +21,7 @@ export async function codegen(abisDir: string, outDir: string, contractsToGenExa
|
|
20
21
|
async function codegenInternal(
|
21
22
|
abisDir: string,
|
22
23
|
outDir: string,
|
23
|
-
contractsToGenExample: YamlContractConfig[]
|
24
|
+
contractsToGenExample: YamlContractConfig[]
|
24
25
|
): Promise<number> {
|
25
26
|
const allFiles = fs.readdirSync(abisDir)
|
26
27
|
if (allFiles.length === 0) {
|
@@ -51,14 +52,14 @@ async function codegenInternal(
|
|
51
52
|
outDir: outInternal,
|
52
53
|
allFiles: allABIFiles,
|
53
54
|
filesToProcess: allABIFiles,
|
54
|
-
contractsToGenExample: contractsToGenExample
|
55
|
+
contractsToGenExample: contractsToGenExample
|
55
56
|
}
|
56
57
|
const services: Services = {
|
57
58
|
fs,
|
58
59
|
// @ts-ignore for test
|
59
60
|
// prettier: { format: (s) => s },
|
60
61
|
prettier: prettier,
|
61
|
-
mkdirp: mkdirp.sync
|
62
|
+
mkdirp: mkdirp.sync
|
62
63
|
}
|
63
64
|
let filesGenerated = 0
|
64
65
|
|
package/src/move/ext/move-dex.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { DecodedStruct, TypeDescriptor } from '
|
1
|
+
import { DecodedStruct, TypeDescriptor } from '@typemove/move'
|
2
2
|
import { BigDecimal } from '@sentio/bigdecimal'
|
3
3
|
import { Gauge } from '../../core/index.js'
|
4
4
|
import { MoveAccountContext, MoveContext } from '../move-context.js'
|
@@ -92,21 +92,21 @@ export class MoveDex<
|
|
92
92
|
if (total.gt(0)) {
|
93
93
|
this.volume.record(ctx, total, {
|
94
94
|
...baseLabels,
|
95
|
-
bridge: coinXInfo.bridge
|
95
|
+
bridge: coinXInfo.bridge
|
96
96
|
})
|
97
97
|
}
|
98
98
|
if (resultX.gt(0)) {
|
99
99
|
this.volumeByCoin.record(ctx, resultX, {
|
100
100
|
coin: coinXInfo.symbol,
|
101
101
|
bridge: coinXInfo.bridge,
|
102
|
-
type: coinXInfo.token_type.type
|
102
|
+
type: coinXInfo.token_type.type
|
103
103
|
})
|
104
104
|
}
|
105
105
|
if (resultY.gt(0)) {
|
106
106
|
this.volumeByCoin.record(ctx, resultY, {
|
107
107
|
coin: coinYInfo.symbol,
|
108
108
|
bridge: coinYInfo.bridge,
|
109
|
-
type: coinYInfo.token_type.type
|
109
|
+
type: coinYInfo.token_type.type
|
110
110
|
})
|
111
111
|
}
|
112
112
|
result = resultX.plus(resultY).div(2)
|
@@ -201,7 +201,7 @@ export class MoveDex<
|
|
201
201
|
this.tvlByCoin.record(ctx, v, {
|
202
202
|
coin: coinInfo.symbol,
|
203
203
|
bridge: coinInfo.bridge,
|
204
|
-
type: coinInfo.token_type.type
|
204
|
+
type: coinInfo.token_type.type
|
205
205
|
})
|
206
206
|
}
|
207
207
|
}
|
package/src/move/index.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
export * from './filter.js'
|
2
|
-
export * from './types.js'
|
3
|
-
export * from './utils.js'
|
4
|
-
export * from './account.js'
|
5
|
-
export * from './chain-adapter.js'
|
6
2
|
export * from './move-context.js'
|
7
3
|
|
4
|
+
export * from '@typemove/move'
|
5
|
+
|
8
6
|
export { MoveFetchConfig } from '@sentio/protos'
|
package/src/move/move-context.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { BaseContext } from '../core/index.js'
|
2
|
-
import { AbstractMoveCoder } from '
|
2
|
+
import { AbstractMoveCoder } from '@typemove/move'
|
3
3
|
|
4
4
|
export abstract class MoveContext<Network, ModuleType, StructType> extends BaseContext {
|
5
5
|
address: string
|
6
|
-
coder: AbstractMoveCoder<
|
6
|
+
coder: AbstractMoveCoder<ModuleType, StructType>
|
7
7
|
network: Network
|
8
8
|
|
9
9
|
abstract getTimestamp(): number
|
@@ -11,7 +11,7 @@ export abstract class MoveContext<Network, ModuleType, StructType> extends BaseC
|
|
11
11
|
|
12
12
|
export abstract class MoveAccountContext<Network, ModuleType, StructType> extends BaseContext {
|
13
13
|
address: string
|
14
|
-
coder: AbstractMoveCoder<
|
14
|
+
coder: AbstractMoveCoder<ModuleType, StructType>
|
15
15
|
network: Network
|
16
16
|
|
17
17
|
abstract getTimestamp(): number
|
@@ -0,0 +1,160 @@
|
|
1
|
+
import {
|
2
|
+
AbstractCodegen,
|
3
|
+
ChainAdapter,
|
4
|
+
InternalMoveFunction,
|
5
|
+
InternalMoveModule,
|
6
|
+
InternalMoveStruct,
|
7
|
+
moduleQname,
|
8
|
+
SPLITTER,
|
9
|
+
normalizeToJSName,
|
10
|
+
upperFirst
|
11
|
+
} from '@typemove/move'
|
12
|
+
import { camel } from 'radash'
|
13
|
+
|
14
|
+
export abstract class SharedNetworkCodegen<NetworkType, ModuleTypes, StructType> extends AbstractCodegen<
|
15
|
+
ModuleTypes,
|
16
|
+
StructType
|
17
|
+
> {
|
18
|
+
network: NetworkType
|
19
|
+
constructor(network: NetworkType, chainAdapter: ChainAdapter<ModuleTypes, StructType>) {
|
20
|
+
super(chainAdapter)
|
21
|
+
this.network = network
|
22
|
+
}
|
23
|
+
generateModule(module: InternalMoveModule, allEventStructs: Map<string, InternalMoveStruct>) {
|
24
|
+
const functions = module.exposedFunctions
|
25
|
+
.map((f) => this.generateForEntryFunctions(module, f))
|
26
|
+
.filter((s) => s !== '')
|
27
|
+
|
28
|
+
const qname = moduleQname(module)
|
29
|
+
const eventStructs = new Map<string, InternalMoveStruct>()
|
30
|
+
for (const [type, struct] of allEventStructs.entries()) {
|
31
|
+
if (type.startsWith(qname + SPLITTER)) {
|
32
|
+
eventStructs.set(type, struct)
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
const events = Array.from(eventStructs.values())
|
37
|
+
.map((e) => this.generateForOnEvents(module, e))
|
38
|
+
.filter((s) => s !== '')
|
39
|
+
|
40
|
+
const moduleName = normalizeToJSName(module.name)
|
41
|
+
|
42
|
+
let processor = ''
|
43
|
+
if (functions.length > 0 || events.length > 0) {
|
44
|
+
processor = `export class ${moduleName} extends ${this.PREFIX}BaseProcessor {
|
45
|
+
|
46
|
+
constructor(options: ${this.PREFIX}BindOptions) {
|
47
|
+
super("${module.name}", options)
|
48
|
+
}
|
49
|
+
static DEFAULT_OPTIONS: ${this.PREFIX}BindOptions = {
|
50
|
+
address: "${module.address}",
|
51
|
+
network: ${this.PREFIX}Network.${this.generateNetworkOption(this.network)}
|
52
|
+
}
|
53
|
+
|
54
|
+
static bind(options: Partial<${this.PREFIX}BindOptions> = {}): ${moduleName} {
|
55
|
+
return new ${moduleName}({ ...${moduleName}.DEFAULT_OPTIONS, ...options })
|
56
|
+
}
|
57
|
+
|
58
|
+
${functions.join('\n')}
|
59
|
+
|
60
|
+
${events.join('\n')}
|
61
|
+
}
|
62
|
+
`
|
63
|
+
}
|
64
|
+
|
65
|
+
return processor + super.generateModule(module, allEventStructs)
|
66
|
+
}
|
67
|
+
|
68
|
+
// protected generateExtra(module: InternalMoveModule): string {
|
69
|
+
// const callArgs = module.exposedFunctions.map((f: InternalMoveFunction) => this.generateCallArgsStructs(module, f))
|
70
|
+
//
|
71
|
+
// return `
|
72
|
+
// ${callArgs.join('\n')}
|
73
|
+
// `
|
74
|
+
// }
|
75
|
+
|
76
|
+
abstract generateNetworkOption(network: NetworkType): string
|
77
|
+
|
78
|
+
generateForEntryFunctions(module: InternalMoveModule, func: InternalMoveFunction) {
|
79
|
+
if (!func.isEntry) {
|
80
|
+
return ''
|
81
|
+
}
|
82
|
+
|
83
|
+
// const genericString = generateFunctionTypeParameters(func)
|
84
|
+
const moduleName = normalizeToJSName(module.name)
|
85
|
+
|
86
|
+
const camelFuncName = upperFirst(camel(func.name))
|
87
|
+
const source = `
|
88
|
+
onEntry${camelFuncName}(func: (call: ${moduleName}.${camelFuncName}Payload, ctx: ${this.PREFIX}Context) => void, filter?: CallFilter, fetchConfig?: Partial<MoveFetchConfig>): ${moduleName} {
|
89
|
+
this.onEntryFunctionCall(func, {
|
90
|
+
...filter,
|
91
|
+
function: '${module.name}::${func.name}'
|
92
|
+
},
|
93
|
+
fetchConfig)
|
94
|
+
return this
|
95
|
+
}`
|
96
|
+
|
97
|
+
return source
|
98
|
+
}
|
99
|
+
|
100
|
+
generateForOnEvents(module: InternalMoveModule, struct: InternalMoveStruct): string {
|
101
|
+
const moduleName = normalizeToJSName(module.name)
|
102
|
+
const source = `
|
103
|
+
onEvent${struct.name}(func: (event: ${moduleName}.${normalizeToJSName(struct.name)}Instance, ctx: ${
|
104
|
+
this.PREFIX
|
105
|
+
}Context) => void, fetchConfig?: Partial<MoveFetchConfig>): ${moduleName} {
|
106
|
+
this.onMoveEvent(func, { type: '${module.name}::${struct.name}' }, fetchConfig)
|
107
|
+
return this
|
108
|
+
}`
|
109
|
+
return source
|
110
|
+
}
|
111
|
+
|
112
|
+
generateImports() {
|
113
|
+
return (
|
114
|
+
super.generateImports() +
|
115
|
+
`
|
116
|
+
import { CallFilter, MoveFetchConfig } from "@sentio/sdk/move"
|
117
|
+
import {
|
118
|
+
${this.PREFIX}BindOptions, ${this.PREFIX}BaseProcessor,
|
119
|
+
${this.PREFIX}Network, TypedFunctionPayload,
|
120
|
+
${this.PREFIX}Context } from "@sentio/sdk/${this.PREFIX.toLowerCase()}"
|
121
|
+
`
|
122
|
+
)
|
123
|
+
}
|
124
|
+
|
125
|
+
protected defaultCoderPackage(): string {
|
126
|
+
return `@sentio/sdk/${this.PREFIX.toLowerCase()}`
|
127
|
+
}
|
128
|
+
|
129
|
+
generateLoadAll(isSystem: boolean): string {
|
130
|
+
let source = `loadAllTypes(defaultMoveCoder(${this.PREFIX}Network.${this.generateNetworkOption(this.network)}))`
|
131
|
+
if (isSystem) {
|
132
|
+
source = `
|
133
|
+
loadAllTypes(defaultMoveCoder(${this.PREFIX}Network.MAIN_NET))
|
134
|
+
loadAllTypes(defaultMoveCoder(${this.PREFIX}Network.TEST_NET))
|
135
|
+
`
|
136
|
+
}
|
137
|
+
return source
|
138
|
+
}
|
139
|
+
|
140
|
+
generateCallArgsStructs(module: InternalMoveModule, func: InternalMoveFunction) {
|
141
|
+
if (!func.isEntry) {
|
142
|
+
return ''
|
143
|
+
}
|
144
|
+
|
145
|
+
const fields = this.chainAdapter.getMeaningfulFunctionParams(func.params).map((param) => {
|
146
|
+
return this.generateTypeForDescriptor(param, module.address) + (this.PAYLOAD_OPTIONAL ? ' | undefined' : '')
|
147
|
+
})
|
148
|
+
|
149
|
+
const camelFuncName = upperFirst(camel(func.name))
|
150
|
+
|
151
|
+
const genericString = this.generateFunctionTypeParameters(func)
|
152
|
+
return `
|
153
|
+
export interface ${camelFuncName}Payload${genericString}
|
154
|
+
extends TypedFunctionPayload<[${fields.join(',')}]> {
|
155
|
+
arguments_decoded: [${fields.join(',')}],
|
156
|
+
type_arguments: [${func.typeParams.map((_) => 'string').join(', ')}]
|
157
|
+
}
|
158
|
+
`
|
159
|
+
}
|
160
|
+
}
|