@typemove/move 1.2.3 → 1.2.4-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/package.json +1 -1
- package/dist/cjs/abstract-codegen.d.ts +0 -50
- package/dist/cjs/abstract-codegen.d.ts.map +0 -1
- package/dist/cjs/abstract-codegen.js +0 -417
- package/dist/cjs/abstract-codegen.js.map +0 -1
- package/dist/cjs/abstract-move-coder.d.ts +0 -26
- package/dist/cjs/abstract-move-coder.d.ts.map +0 -1
- package/dist/cjs/abstract-move-coder.js +0 -260
- package/dist/cjs/abstract-move-coder.js.map +0 -1
- package/dist/cjs/account.d.ts +0 -16
- package/dist/cjs/account.d.ts.map +0 -1
- package/dist/cjs/account.js +0 -76
- package/dist/cjs/account.js.map +0 -1
- package/dist/cjs/chain-adapter.d.ts +0 -13
- package/dist/cjs/chain-adapter.d.ts.map +0 -1
- package/dist/cjs/chain-adapter.js +0 -7
- package/dist/cjs/chain-adapter.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -11
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/internal-models.d.ts +0 -36
- package/dist/cjs/internal-models.d.ts.map +0 -1
- package/dist/cjs/internal-models.js +0 -10
- package/dist/cjs/internal-models.js.map +0 -1
- package/dist/cjs/ts-type.test.d.ts +0 -2
- package/dist/cjs/ts-type.test.d.ts.map +0 -1
- package/dist/cjs/ts-type.test.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -46
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -250
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils.d.ts +0 -17
- package/dist/cjs/utils.d.ts.map +0 -1
- package/dist/cjs/utils.js +0 -82
- package/dist/cjs/utils.js.map +0 -1
- package/dist/cjs/utils.test.d.ts +0 -2
- package/dist/cjs/utils.test.d.ts.map +0 -1
- package/dist/cjs/utils.test.js.map +0 -1
- package/dist/esm/abstract-codegen.d.ts +0 -50
- package/dist/esm/abstract-codegen.d.ts.map +0 -1
- package/dist/esm/abstract-codegen.js +0 -411
- package/dist/esm/abstract-codegen.js.map +0 -1
- package/dist/esm/abstract-move-coder.d.ts +0 -26
- package/dist/esm/abstract-move-coder.d.ts.map +0 -1
- package/dist/esm/abstract-move-coder.js +0 -256
- package/dist/esm/abstract-move-coder.js.map +0 -1
- package/dist/esm/account.d.ts +0 -16
- package/dist/esm/account.d.ts.map +0 -1
- package/dist/esm/account.js +0 -71
- package/dist/esm/account.js.map +0 -1
- package/dist/esm/chain-adapter.d.ts +0 -13
- package/dist/esm/chain-adapter.d.ts.map +0 -1
- package/dist/esm/chain-adapter.js +0 -3
- package/dist/esm/chain-adapter.js.map +0 -1
- package/dist/esm/index.d.ts +0 -8
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -8
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internal-models.d.ts +0 -36
- package/dist/esm/internal-models.d.ts.map +0 -1
- package/dist/esm/internal-models.js +0 -7
- package/dist/esm/internal-models.js.map +0 -1
- package/dist/esm/ts-type.test.d.ts +0 -2
- package/dist/esm/ts-type.test.d.ts.map +0 -1
- package/dist/esm/ts-type.test.js.map +0 -1
- package/dist/esm/types.d.ts +0 -46
- package/dist/esm/types.d.ts.map +0 -1
- package/dist/esm/types.js +0 -243
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils.d.ts +0 -17
- package/dist/esm/utils.d.ts.map +0 -1
- package/dist/esm/utils.js +0 -69
- package/dist/esm/utils.js.map +0 -1
- package/dist/esm/utils.test.d.ts +0 -2
- package/dist/esm/utils.test.d.ts.map +0 -1
- package/dist/esm/utils.test.js.map +0 -1
- package/src/abstract-codegen.ts +0 -504
- package/src/abstract-move-coder.ts +0 -288
- package/src/account.ts +0 -93
- package/src/chain-adapter.ts +0 -26
- package/src/index.ts +0 -7
- package/src/internal-models.ts +0 -41
- package/src/types.ts +0 -284
- package/src/utils.ts +0 -91
package/package.json
CHANGED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { InternalMoveFunction, InternalMoveModule, InternalMoveStruct } from './internal-models.js';
|
|
2
|
-
import { AccountRegister } from './account.js';
|
|
3
|
-
import { TypeDescriptor } from './types.js';
|
|
4
|
-
import { ChainAdapter } from './chain-adapter.js';
|
|
5
|
-
interface OutputFile {
|
|
6
|
-
fileName: string;
|
|
7
|
-
fileContent: string;
|
|
8
|
-
}
|
|
9
|
-
interface Config {
|
|
10
|
-
fileName: string;
|
|
11
|
-
outputDir: string;
|
|
12
|
-
}
|
|
13
|
-
export declare abstract class AbstractCodegen<ModuleTypes, StructType> {
|
|
14
|
-
ADDRESS_TYPE: string;
|
|
15
|
-
SYSTEM_PACKAGE: string;
|
|
16
|
-
PREFIX: string;
|
|
17
|
-
STRUCT_FIELD_NAME: string;
|
|
18
|
-
PAYLOAD_OPTIONAL: boolean;
|
|
19
|
-
SYSTEM_MODULES: Set<string>;
|
|
20
|
-
ESM: boolean;
|
|
21
|
-
chainAdapter: ChainAdapter<ModuleTypes, StructType>;
|
|
22
|
-
protected constructor(chainAdapter: ChainAdapter<ModuleTypes, StructType>);
|
|
23
|
-
maybeEsmPrefix(): "" | ".js";
|
|
24
|
-
readModulesFile(fullPath: string): any;
|
|
25
|
-
protected defaultCoderPackage(): string;
|
|
26
|
-
generateLoadAll(isSystem: boolean): string;
|
|
27
|
-
generate(srcDir: string, outputDir: string, builtin?: boolean): Promise<number>;
|
|
28
|
-
protected generateExtra(module: InternalMoveModule): string;
|
|
29
|
-
generateModule(module: InternalMoveModule, allEventStructs: Map<string, InternalMoveStruct>): string;
|
|
30
|
-
generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>, typeOnly?: boolean): string;
|
|
31
|
-
generateFunctionTypeParameters(func: InternalMoveFunction): string;
|
|
32
|
-
generateFunctionReturnTypeParameters(func: InternalMoveFunction, currentAddress: string): string;
|
|
33
|
-
generateStructTypeParameters(struct: InternalMoveStruct, useAny?: boolean): string;
|
|
34
|
-
generateCallArgsStructs(module: InternalMoveModule, func: InternalMoveFunction): string;
|
|
35
|
-
generateForEvents(module: InternalMoveModule, struct: InternalMoveStruct): string;
|
|
36
|
-
generateTypeForDescriptor(type: TypeDescriptor, currentAddress: string): string;
|
|
37
|
-
generateSimpleType(type: string, currentAddress: string): string;
|
|
38
|
-
generateImports(): string;
|
|
39
|
-
}
|
|
40
|
-
export declare class AccountCodegen<ModuleType, StructType> {
|
|
41
|
-
modules: InternalMoveModule[];
|
|
42
|
-
config: Config;
|
|
43
|
-
abi: ModuleType[];
|
|
44
|
-
loader: AccountRegister;
|
|
45
|
-
moduleGen: AbstractCodegen<ModuleType, StructType>;
|
|
46
|
-
constructor(moduleGen: AbstractCodegen<ModuleType, StructType>, loader: AccountRegister, abi: ModuleType[], modules: InternalMoveModule[], config: Config);
|
|
47
|
-
generate(): OutputFile[];
|
|
48
|
-
}
|
|
49
|
-
export {};
|
|
50
|
-
//# sourceMappingURL=abstract-codegen.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-codegen.d.ts","sourceRoot":"","sources":["../../src/abstract-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAGnG,OAAO,EAA4B,eAAe,EAAE,MAAM,cAAc,CAAA;AAIxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,UAAU,UAAU;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,UAAU,MAAM;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAElB;AAGD,8BAAsB,eAAe,CAAC,WAAW,EAAE,UAAU;I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AAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAgBhE,eAAe;CAiBhB;AAED,qBAAa,cAAc,CAAC,UAAU,EAAE,UAAU;IAChD,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,UAAU,EAAE,CAAA;IACjB,MAAM,EAAE,eAAe,CAAA;IACvB,SAAS,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;gBAGhD,SAAS,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,EAClD,MAAM,EAAE,eAAe,EACvB,GAAG,EAAE,UAAU,EAAE,EACjB,OAAO,EAAE,kBAAkB,EAAE,EAC7B,MAAM,EAAE,MAAM;IAUhB,QAAQ,IAAI,UAAU,EAAE;CAwEzB"}
|
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AccountCodegen = exports.AbstractCodegen = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
7
|
-
const account_js_1 = require("./account.js");
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
-
const prettier_1 = require("prettier");
|
|
10
|
-
const utils_js_1 = require("./utils.js");
|
|
11
|
-
// TODO be able to generate cjs
|
|
12
|
-
class AbstractCodegen {
|
|
13
|
-
ADDRESS_TYPE;
|
|
14
|
-
SYSTEM_PACKAGE;
|
|
15
|
-
PREFIX;
|
|
16
|
-
STRUCT_FIELD_NAME = 'data';
|
|
17
|
-
PAYLOAD_OPTIONAL = false;
|
|
18
|
-
SYSTEM_MODULES = new Set(['0x1', '0x2', '0x3']);
|
|
19
|
-
ESM = true;
|
|
20
|
-
chainAdapter;
|
|
21
|
-
constructor(chainAdapter) {
|
|
22
|
-
this.chainAdapter = chainAdapter;
|
|
23
|
-
}
|
|
24
|
-
maybeEsmPrefix() {
|
|
25
|
-
return this.ESM ? '.js' : '';
|
|
26
|
-
}
|
|
27
|
-
readModulesFile(fullPath) {
|
|
28
|
-
return JSON.parse(fs_1.default.readFileSync(fullPath, 'utf-8'));
|
|
29
|
-
}
|
|
30
|
-
defaultCoderPackage() {
|
|
31
|
-
return `@typemove/${this.PREFIX.toLowerCase()}`;
|
|
32
|
-
}
|
|
33
|
-
generateLoadAll(isSystem) {
|
|
34
|
-
return 'loadAllTypes(defaultMoveCoder())';
|
|
35
|
-
}
|
|
36
|
-
async generate(srcDir, outputDir,
|
|
37
|
-
// network: NetworkType,
|
|
38
|
-
builtin = false) {
|
|
39
|
-
if (!fs_1.default.existsSync(srcDir)) {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
42
|
-
const files = fs_1.default.readdirSync(srcDir);
|
|
43
|
-
outputDir = path_1.default.resolve(outputDir);
|
|
44
|
-
const outputs = [];
|
|
45
|
-
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
46
|
-
const loader = new account_js_1.AccountRegister();
|
|
47
|
-
// when generating user code, don't need to generate framework account
|
|
48
|
-
for (const sysModule of this.SYSTEM_MODULES) {
|
|
49
|
-
loader.accountImports.set(sysModule, new account_js_1.AccountModulesImportInfo(sysModule, sysModule));
|
|
50
|
-
}
|
|
51
|
-
// const client = getRpcClient(network)
|
|
52
|
-
for (const file of files) {
|
|
53
|
-
if (!file.endsWith('.json')) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const fullPath = path_1.default.resolve(srcDir, file);
|
|
57
|
-
const abi = this.readModulesFile(fullPath);
|
|
58
|
-
const modules = this.chainAdapter.toInternalModules(abi);
|
|
59
|
-
for (const module of modules) {
|
|
60
|
-
loader.register(module, path_1.default.basename(file, '.json'));
|
|
61
|
-
}
|
|
62
|
-
const codeGen = new AccountCodegen(this, loader, abi, modules, {
|
|
63
|
-
fileName: path_1.default.basename(file, '.json'),
|
|
64
|
-
outputDir: outputDir
|
|
65
|
-
// network,
|
|
66
|
-
});
|
|
67
|
-
outputs.push(...codeGen.generate());
|
|
68
|
-
}
|
|
69
|
-
while (loader.pendingAccounts.size > 0) {
|
|
70
|
-
for (const account of loader.pendingAccounts) {
|
|
71
|
-
const id = await this.chainAdapter.getChainId();
|
|
72
|
-
console.log(`download dependent module for account ${account} at ${id}`);
|
|
73
|
-
try {
|
|
74
|
-
const rawModules = await this.chainAdapter.fetchModules(account
|
|
75
|
-
// network
|
|
76
|
-
);
|
|
77
|
-
const modules = this.chainAdapter.toInternalModules(rawModules);
|
|
78
|
-
fs_1.default.writeFileSync(path_1.default.resolve(srcDir, account + '.json'), JSON.stringify(rawModules, null, '\t'));
|
|
79
|
-
for (const module of modules) {
|
|
80
|
-
loader.register(module, account);
|
|
81
|
-
}
|
|
82
|
-
const codeGen = new AccountCodegen(this, loader, rawModules, modules, {
|
|
83
|
-
fileName: account,
|
|
84
|
-
outputDir: outputDir
|
|
85
|
-
// network,
|
|
86
|
-
});
|
|
87
|
-
outputs.push(...codeGen.generate());
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
console.error(chalk_1.default.red('Error downloading account module, check if you choose the right network,or download account modules manually into your director'));
|
|
91
|
-
console.error(e);
|
|
92
|
-
process.exit(1);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
for (const output of outputs) {
|
|
97
|
-
let content = output.fileContent;
|
|
98
|
-
content = await (0, prettier_1.format)(output.fileContent, { parser: 'typescript' });
|
|
99
|
-
fs_1.default.writeFileSync(path_1.default.join(outputDir, output.fileName), content);
|
|
100
|
-
}
|
|
101
|
-
const rootFile = path_1.default.join(outputDir, 'index.ts');
|
|
102
|
-
let rootFileContent = `/* Autogenerated file. Do not edit manually. */
|
|
103
|
-
/* tslint:disable */
|
|
104
|
-
/* eslint-disable */
|
|
105
|
-
`;
|
|
106
|
-
for (const output of outputs) {
|
|
107
|
-
const parsed = path_1.default.parse(output.fileName);
|
|
108
|
-
rootFileContent += `export * as _${parsed.name.replaceAll('-', '_')} from './${parsed.name}${this.maybeEsmPrefix()}'\n`;
|
|
109
|
-
}
|
|
110
|
-
fs_1.default.writeFileSync(rootFile, rootFileContent);
|
|
111
|
-
return outputs.length + 1;
|
|
112
|
-
}
|
|
113
|
-
generateExtra(module) {
|
|
114
|
-
return '';
|
|
115
|
-
}
|
|
116
|
-
generateModule(module, allEventStructs
|
|
117
|
-
// network: NetworkType
|
|
118
|
-
) {
|
|
119
|
-
const qname = (0, utils_js_1.moduleQname)(module);
|
|
120
|
-
const eventStructs = new Map();
|
|
121
|
-
for (const [type, struct] of allEventStructs.entries()) {
|
|
122
|
-
if (type.startsWith(qname + utils_js_1.SPLITTER)) {
|
|
123
|
-
eventStructs.set(type, struct);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const eventTypes = new Set(eventStructs.keys());
|
|
127
|
-
const events = Array.from(eventStructs.values())
|
|
128
|
-
.map((e) => this.generateForEvents(module, e))
|
|
129
|
-
.filter((s) => s !== '');
|
|
130
|
-
const structs = module.structs.map((s) => this.generateStructs(module, s, eventTypes));
|
|
131
|
-
const callArgs = module.exposedFunctions.map((f) => this.generateCallArgsStructs(module, f));
|
|
132
|
-
const moduleName = (0, utils_js_1.normalizeToJSName)(module.name);
|
|
133
|
-
return `
|
|
134
|
-
|
|
135
|
-
export namespace ${moduleName} {
|
|
136
|
-
${structs.join('\n')}
|
|
137
|
-
|
|
138
|
-
${this.generateExtra(module)}
|
|
139
|
-
|
|
140
|
-
${events.join('\n')}
|
|
141
|
-
|
|
142
|
-
${callArgs.join('\n')}
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
}
|
|
146
|
-
generateStructs(module, struct, events, typeOnly = false) {
|
|
147
|
-
const typeParams = struct.typeParams || [];
|
|
148
|
-
const genericString = this.generateStructTypeParameters(struct);
|
|
149
|
-
const genericStringAny = this.generateStructTypeParameters(struct, true);
|
|
150
|
-
const structName = (0, utils_js_1.normalizeToJSName)(struct.name);
|
|
151
|
-
const fields = struct.fields.map((field) => {
|
|
152
|
-
const type = this.generateTypeForDescriptor(field.type, module.address);
|
|
153
|
-
return `${field.name}: ${type}`;
|
|
154
|
-
});
|
|
155
|
-
const typeParamApplyArg = typeParams
|
|
156
|
-
.map((v, idx) => {
|
|
157
|
-
return `arg${idx}: TypeDescriptor<T${idx}> = ANY_TYPE`;
|
|
158
|
-
})
|
|
159
|
-
.join(',');
|
|
160
|
-
const typeParamApply = typeParams
|
|
161
|
-
.map((v, idx) => {
|
|
162
|
-
return `arg${idx}`;
|
|
163
|
-
})
|
|
164
|
-
.join(',');
|
|
165
|
-
const typeDescriptor = `
|
|
166
|
-
export namespace ${structName}{
|
|
167
|
-
export const TYPE_QNAME = '${module.address}::${module.name}::${struct.name}'
|
|
168
|
-
|
|
169
|
-
const TYPE = new TypeDescriptor<${structName}${genericStringAny}>(${structName}.TYPE_QNAME)
|
|
170
|
-
|
|
171
|
-
export function type${genericString}(${typeParamApplyArg}): TypeDescriptor<${structName}${genericString}> {
|
|
172
|
-
return TYPE.apply(${typeParamApply})
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
`;
|
|
176
|
-
if (typeOnly) {
|
|
177
|
-
return typeDescriptor;
|
|
178
|
-
}
|
|
179
|
-
let eventPayload = '';
|
|
180
|
-
if (events.has((0, utils_js_1.moduleQname)(module) + utils_js_1.SPLITTER + struct.name)) {
|
|
181
|
-
eventPayload = `
|
|
182
|
-
export interface ${structName}Instance extends
|
|
183
|
-
TypedEventInstance<${structName}${genericStringAny}> {
|
|
184
|
-
${this.STRUCT_FIELD_NAME}_decoded: ${structName}${genericStringAny}
|
|
185
|
-
type_arguments: [${struct.typeParams.map((_) => 'string').join(', ')}]
|
|
186
|
-
}
|
|
187
|
-
`;
|
|
188
|
-
}
|
|
189
|
-
return `
|
|
190
|
-
export interface ${structName}${genericString} {
|
|
191
|
-
${fields.join('\n')}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
${typeDescriptor}
|
|
195
|
-
|
|
196
|
-
${eventPayload}
|
|
197
|
-
`;
|
|
198
|
-
}
|
|
199
|
-
generateFunctionTypeParameters(func) {
|
|
200
|
-
let genericString = '';
|
|
201
|
-
if (func.typeParams && func.typeParams.length > 0) {
|
|
202
|
-
const params = func.typeParams
|
|
203
|
-
.map((v, idx) => {
|
|
204
|
-
return `T${idx}=any`;
|
|
205
|
-
})
|
|
206
|
-
.join(',');
|
|
207
|
-
genericString = `<${params}>`;
|
|
208
|
-
}
|
|
209
|
-
return genericString;
|
|
210
|
-
}
|
|
211
|
-
generateFunctionReturnTypeParameters(func, currentAddress) {
|
|
212
|
-
let returnType = '';
|
|
213
|
-
if (func.return && func.return.length > 0) {
|
|
214
|
-
returnType = func.return
|
|
215
|
-
.map((v, idx) => {
|
|
216
|
-
return this.generateTypeForDescriptor(v, currentAddress);
|
|
217
|
-
})
|
|
218
|
-
.join(',');
|
|
219
|
-
}
|
|
220
|
-
return '[' + returnType + ']';
|
|
221
|
-
}
|
|
222
|
-
generateStructTypeParameters(struct, useAny = false) {
|
|
223
|
-
let genericString = '';
|
|
224
|
-
if (struct.typeParams && struct.typeParams.length > 0) {
|
|
225
|
-
const params = struct.typeParams
|
|
226
|
-
.map((v, idx) => {
|
|
227
|
-
return useAny ? 'any' : 'T' + idx;
|
|
228
|
-
})
|
|
229
|
-
.join(',');
|
|
230
|
-
genericString = `<${params}>`;
|
|
231
|
-
}
|
|
232
|
-
return genericString;
|
|
233
|
-
}
|
|
234
|
-
// generateTypeParameters(struct: TypeDescriptor, useAny = false) {
|
|
235
|
-
// let genericString = ''
|
|
236
|
-
//
|
|
237
|
-
// if (struct.typeArgs && struct.typeArgs.length > 0) {
|
|
238
|
-
// const params = struct.typeArgs
|
|
239
|
-
// .map((_, idx) => {
|
|
240
|
-
// return useAny ? 'any' : 'T' + idx
|
|
241
|
-
// })
|
|
242
|
-
// .join(',')
|
|
243
|
-
// genericString = `<${params}>`
|
|
244
|
-
// }
|
|
245
|
-
// return genericString
|
|
246
|
-
// }
|
|
247
|
-
generateCallArgsStructs(module, func) {
|
|
248
|
-
return '';
|
|
249
|
-
}
|
|
250
|
-
generateForEvents(module, struct) {
|
|
251
|
-
return '';
|
|
252
|
-
}
|
|
253
|
-
generateTypeForDescriptor(type, currentAddress) {
|
|
254
|
-
if (type.reference) {
|
|
255
|
-
return this.ADDRESS_TYPE;
|
|
256
|
-
}
|
|
257
|
-
switch (type.qname) {
|
|
258
|
-
case 'signer': // TODO check this
|
|
259
|
-
case 'address':
|
|
260
|
-
case 'Address':
|
|
261
|
-
return this.ADDRESS_TYPE;
|
|
262
|
-
case '0x1::string::String':
|
|
263
|
-
return 'string';
|
|
264
|
-
case 'bool':
|
|
265
|
-
case 'Bool':
|
|
266
|
-
return 'Boolean';
|
|
267
|
-
case 'u8':
|
|
268
|
-
case 'U8':
|
|
269
|
-
case 'u16':
|
|
270
|
-
case 'U16':
|
|
271
|
-
case 'u32':
|
|
272
|
-
case 'U32':
|
|
273
|
-
return 'number';
|
|
274
|
-
case 'u64':
|
|
275
|
-
case 'U64':
|
|
276
|
-
case 'u128':
|
|
277
|
-
case 'U128':
|
|
278
|
-
case 'u256':
|
|
279
|
-
case 'U256':
|
|
280
|
-
return 'bigint';
|
|
281
|
-
}
|
|
282
|
-
if (type.qname.toLowerCase() === utils_js_1.VECTOR_STR) {
|
|
283
|
-
// vector<u8> as hex string
|
|
284
|
-
const elementTypeQname = type.typeArgs[0].qname;
|
|
285
|
-
if (elementTypeQname === 'u8') {
|
|
286
|
-
// only for aptos
|
|
287
|
-
return 'string';
|
|
288
|
-
}
|
|
289
|
-
if (elementTypeQname.startsWith('T') && !elementTypeQname.includes(utils_js_1.SPLITTER)) {
|
|
290
|
-
return `${elementTypeQname}[] | string`;
|
|
291
|
-
}
|
|
292
|
-
return this.generateTypeForDescriptor(type.typeArgs[0], currentAddress) + '[]';
|
|
293
|
-
}
|
|
294
|
-
const simpleName = this.generateSimpleType(type.qname, currentAddress);
|
|
295
|
-
if (simpleName.length === 0) {
|
|
296
|
-
console.error('unexpected error');
|
|
297
|
-
}
|
|
298
|
-
if (simpleName.toLowerCase() === utils_js_1.VECTOR_STR || simpleName.toLowerCase().startsWith(utils_js_1.VECTOR_STR + utils_js_1.SPLITTER)) {
|
|
299
|
-
console.error('unexpected vector type error');
|
|
300
|
-
}
|
|
301
|
-
if (type.typeArgs.length > 0) {
|
|
302
|
-
// return simpleName
|
|
303
|
-
return (simpleName + '<' + type.typeArgs.map((t) => this.generateTypeForDescriptor(t, currentAddress)).join(',') + '>');
|
|
304
|
-
}
|
|
305
|
-
return simpleName;
|
|
306
|
-
}
|
|
307
|
-
generateSimpleType(type, currentAddress) {
|
|
308
|
-
const parts = type.split(utils_js_1.SPLITTER);
|
|
309
|
-
for (let i = 0; i < parts.length; i++) {
|
|
310
|
-
parts[i] = (0, utils_js_1.normalizeToJSName)(parts[i]);
|
|
311
|
-
}
|
|
312
|
-
if (parts.length < 2) {
|
|
313
|
-
return parts[0];
|
|
314
|
-
}
|
|
315
|
-
if (parts[0] === currentAddress) {
|
|
316
|
-
return parts.slice(1).join('.');
|
|
317
|
-
}
|
|
318
|
-
return '_' + parts.join('.');
|
|
319
|
-
}
|
|
320
|
-
generateImports() {
|
|
321
|
-
let refImports = `import { ${this.ADDRESS_TYPE} } from "${this.SYSTEM_PACKAGE}"`;
|
|
322
|
-
if (this.ADDRESS_TYPE === 'string') {
|
|
323
|
-
refImports = '';
|
|
324
|
-
}
|
|
325
|
-
const imports = `
|
|
326
|
-
import { TypeDescriptor, ANY_TYPE } from "@typemove/move"
|
|
327
|
-
import {
|
|
328
|
-
MoveCoder, TypedEventInstance } from "@typemove/${this.PREFIX.toLowerCase()}"
|
|
329
|
-
|
|
330
|
-
import { defaultMoveCoder } from "${this.defaultCoderPackage()}"
|
|
331
|
-
|
|
332
|
-
${refImports}
|
|
333
|
-
`;
|
|
334
|
-
return imports;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
exports.AbstractCodegen = AbstractCodegen;
|
|
338
|
-
class AccountCodegen {
|
|
339
|
-
modules;
|
|
340
|
-
config;
|
|
341
|
-
abi;
|
|
342
|
-
loader;
|
|
343
|
-
moduleGen;
|
|
344
|
-
constructor(moduleGen, loader, abi, modules, config) {
|
|
345
|
-
// const json = fs.readFileSync(config.srcFile, 'utf-8')
|
|
346
|
-
this.moduleGen = moduleGen;
|
|
347
|
-
this.abi = abi;
|
|
348
|
-
this.modules = modules;
|
|
349
|
-
this.config = config;
|
|
350
|
-
this.loader = loader;
|
|
351
|
-
}
|
|
352
|
-
generate() {
|
|
353
|
-
if (!this.modules) {
|
|
354
|
-
return [];
|
|
355
|
-
}
|
|
356
|
-
// const baseName = path.basename(this.config.fileName, '.json')
|
|
357
|
-
let address;
|
|
358
|
-
for (const module of this.modules) {
|
|
359
|
-
address = module.address;
|
|
360
|
-
}
|
|
361
|
-
if (!address) {
|
|
362
|
-
return [];
|
|
363
|
-
}
|
|
364
|
-
const dependedAccounts = [];
|
|
365
|
-
const moduleImports = [];
|
|
366
|
-
const info = this.loader.accountImports.get(address);
|
|
367
|
-
if (info) {
|
|
368
|
-
for (const [account] of info.imports.entries()) {
|
|
369
|
-
// Remap to user's filename if possible, TODO codepath not well tested
|
|
370
|
-
const tsAccountModule = './' + (this.loader.accountImports.get(account)?.moduleName || account);
|
|
371
|
-
if ((0, utils_js_1.isFrameworkAccount)(account) && !(0, utils_js_1.isFrameworkAccount)(address)) {
|
|
372
|
-
// Decide where to find runtime library
|
|
373
|
-
moduleImports.push(`import { _${account} } from "@typemove/${this.moduleGen.PREFIX.toLowerCase()}/builtin"`
|
|
374
|
-
// `import _${account} = builtin._${account} `
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
moduleImports.push(`import * as _${account} from "${tsAccountModule}${this.moduleGen.maybeEsmPrefix()}"`);
|
|
379
|
-
}
|
|
380
|
-
dependedAccounts.push(account);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const eventsMap = this.moduleGen.chainAdapter.getAllEventStructs(this.modules);
|
|
384
|
-
const source = `
|
|
385
|
-
/* Autogenerated file. Do not edit manually. */
|
|
386
|
-
/* tslint:disable */
|
|
387
|
-
/* eslint-disable */
|
|
388
|
-
|
|
389
|
-
/* Generated modules for account ${address} */
|
|
390
|
-
|
|
391
|
-
${this.moduleGen.generateImports()}
|
|
392
|
-
|
|
393
|
-
${moduleImports.join('\n')}
|
|
394
|
-
|
|
395
|
-
${this.modules.map((m) => this.moduleGen.generateModule(m, eventsMap)).join('\n')}
|
|
396
|
-
|
|
397
|
-
const MODULES = JSON.parse('${JSON.stringify(this.abi)}')
|
|
398
|
-
|
|
399
|
-
export function loadAllTypes(coder: MoveCoder) {
|
|
400
|
-
${dependedAccounts.map((a) => `_${a}.loadAllTypes(coder)`).join('\n')}
|
|
401
|
-
for (const m of Object.values(MODULES)) {
|
|
402
|
-
coder.load(m as any)
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
${this.moduleGen.generateLoadAll(this.moduleGen.SYSTEM_MODULES.has(address))}
|
|
407
|
-
`; // source
|
|
408
|
-
return [
|
|
409
|
-
{
|
|
410
|
-
fileName: this.config.fileName + '.ts',
|
|
411
|
-
fileContent: source
|
|
412
|
-
}
|
|
413
|
-
];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
exports.AccountCodegen = AccountCodegen;
|
|
417
|
-
//# sourceMappingURL=abstract-codegen.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-codegen.js","sourceRoot":"","sources":["../../src/abstract-codegen.ts"],"names":[],"mappings":";;;;AACA,wDAAuB;AACvB,oDAAmB;AACnB,6CAAwE;AACxE,0DAAyB;AACzB,uCAAiC;AACjC,yCAAqG;AAerG,+BAA+B;AAC/B,MAAsB,eAAe;IACnC,YAAY,CAA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gBAAgB,OAAO,UAAU,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;iBAC1G;gBAED,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;aAC/B;SACF;QAED,MAAM,SAAS,GAAoC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAE/G,MAAM,MAAM,GAAG;;;;;uCAKoB,OAAO;;MAExC,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE;;MAEhC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;;MAExB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;kCAEnD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;;;QAGlD,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;MAMrE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;KAC3E,CAAA,CAAC,SAAS;QAEX,OAAO;YACL;gBACE,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,KAAK;gBACtC,WAAW,EAAE,MAAM;aACpB;SACF,CAAA;IACH,CAAC;CACF;AA9FD,wCA8FC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DecodedStruct, TypeDescriptor } from './types.js';
|
|
2
|
-
import { InternalMoveFunction, InternalMoveModule, InternalMoveStruct } from './internal-models.js';
|
|
3
|
-
import { ChainAdapter } from './chain-adapter.js';
|
|
4
|
-
export declare abstract class AbstractMoveCoder<ModuleType, StructType> {
|
|
5
|
-
protected moduleMapping: Map<string, InternalMoveModule>;
|
|
6
|
-
private typeMapping;
|
|
7
|
-
private funcMapping;
|
|
8
|
-
adapter: ChainAdapter<ModuleType, StructType>;
|
|
9
|
-
protected constructor(adapter: ChainAdapter<ModuleType, StructType>);
|
|
10
|
-
contains(account: string, name: string): boolean;
|
|
11
|
-
abstract load(module: ModuleType): InternalMoveModule;
|
|
12
|
-
protected loadInternal(module: InternalMoveModule): void;
|
|
13
|
-
protected decodeBigInt(data: any): bigint;
|
|
14
|
-
private requestMap;
|
|
15
|
-
getMoveStruct(type: string): Promise<InternalMoveStruct>;
|
|
16
|
-
getMoveFunction(type: string): Promise<InternalMoveFunction>;
|
|
17
|
-
protected decode<T>(data: any, type: TypeDescriptor<T>): Promise<T>;
|
|
18
|
-
decodeArray(entries: any[], types: TypeDescriptor[], strict?: boolean): Promise<any[]>;
|
|
19
|
-
encode(data: any): any;
|
|
20
|
-
encodeArray(entriesDecoded: any[]): any[];
|
|
21
|
-
decodeCallResult(res: any[], func: string): Promise<any[]>;
|
|
22
|
-
filterAndDecodeStruct<T, ST extends StructType>(typeMatcher: TypeDescriptor<T>, structsWithTags: ST[]): Promise<DecodedStruct<ST, T>[]>;
|
|
23
|
-
protected decodedStruct<T, ST extends StructType>(typeStruct: ST): Promise<DecodedStruct<ST, T> | undefined>;
|
|
24
|
-
decodedType<T, ST>(typeStruct: ST, type: TypeDescriptor<T>): Promise<T | undefined>;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=abstract-move-coder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"abstract-move-coder.d.ts","sourceRoot":"","sources":["../../src/abstract-move-coder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAA4B,cAAc,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAA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