@typemove/move 1.2.4 → 1.2.5-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/dist/cjs/abstract-codegen.d.ts +50 -0
- package/dist/cjs/abstract-codegen.d.ts.map +1 -0
- package/dist/cjs/abstract-codegen.js +417 -0
- package/dist/cjs/abstract-codegen.js.map +1 -0
- package/dist/cjs/abstract-move-coder.d.ts +26 -0
- package/dist/cjs/abstract-move-coder.d.ts.map +1 -0
- package/dist/cjs/abstract-move-coder.js +260 -0
- package/dist/cjs/abstract-move-coder.js.map +1 -0
- package/dist/cjs/account.d.ts +16 -0
- package/dist/cjs/account.d.ts.map +1 -0
- package/dist/cjs/account.js +76 -0
- package/dist/cjs/account.js.map +1 -0
- package/dist/cjs/chain-adapter.d.ts +13 -0
- package/dist/cjs/chain-adapter.d.ts.map +1 -0
- package/dist/cjs/chain-adapter.js +7 -0
- package/dist/cjs/chain-adapter.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/internal-models.d.ts +36 -0
- package/dist/cjs/internal-models.d.ts.map +1 -0
- package/dist/cjs/internal-models.js +10 -0
- package/dist/cjs/internal-models.js.map +1 -0
- package/dist/cjs/ts-type.test.d.ts +2 -0
- package/dist/cjs/ts-type.test.d.ts.map +1 -0
- package/dist/cjs/ts-type.test.js.map +1 -0
- package/dist/cjs/types.d.ts +46 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +250 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.d.ts +17 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +82 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/utils.test.d.ts +2 -0
- package/dist/cjs/utils.test.d.ts.map +1 -0
- package/dist/cjs/utils.test.js.map +1 -0
- package/dist/esm/abstract-codegen.d.ts +50 -0
- package/dist/esm/abstract-codegen.d.ts.map +1 -0
- package/dist/esm/abstract-codegen.js +411 -0
- package/dist/esm/abstract-codegen.js.map +1 -0
- package/dist/esm/abstract-move-coder.d.ts +26 -0
- package/dist/esm/abstract-move-coder.d.ts.map +1 -0
- package/dist/esm/abstract-move-coder.js +256 -0
- package/dist/esm/abstract-move-coder.js.map +1 -0
- package/dist/esm/account.d.ts +16 -0
- package/dist/esm/account.d.ts.map +1 -0
- package/dist/esm/account.js +71 -0
- package/dist/esm/account.js.map +1 -0
- package/dist/esm/chain-adapter.d.ts +13 -0
- package/dist/esm/chain-adapter.d.ts.map +1 -0
- package/dist/esm/chain-adapter.js +3 -0
- package/dist/esm/chain-adapter.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal-models.d.ts +36 -0
- package/dist/esm/internal-models.d.ts.map +1 -0
- package/dist/esm/internal-models.js +7 -0
- package/dist/esm/internal-models.js.map +1 -0
- package/dist/esm/ts-type.test.d.ts +2 -0
- package/dist/esm/ts-type.test.d.ts.map +1 -0
- package/dist/esm/ts-type.test.js.map +1 -0
- package/dist/esm/types.d.ts +46 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +243 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +17 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +69 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/utils.test.d.ts +2 -0
- package/dist/esm/utils.test.d.ts.map +1 -0
- package/dist/esm/utils.test.js.map +1 -0
- package/package.json +1 -1
- package/src/abstract-codegen.ts +504 -0
- package/src/abstract-move-coder.ts +288 -0
- package/src/account.ts +93 -0
- package/src/chain-adapter.ts +26 -0
- package/src/index.ts +7 -0
- package/src/internal-models.ts +41 -0
- package/src/types.ts +284 -0
- package/src/utils.ts +91 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { accountAddressString, moduleQname, SPLITTER, VECTOR_STR } from './utils.js';
|
|
2
|
+
import { matchType, parseMoveType } from './types.js';
|
|
3
|
+
export class AbstractMoveCoder {
|
|
4
|
+
moduleMapping = new Map();
|
|
5
|
+
typeMapping = new Map();
|
|
6
|
+
funcMapping = new Map();
|
|
7
|
+
// network: string
|
|
8
|
+
adapter;
|
|
9
|
+
constructor(adapter) {
|
|
10
|
+
this.adapter = adapter;
|
|
11
|
+
}
|
|
12
|
+
contains(account, name) {
|
|
13
|
+
return this.moduleMapping.has(moduleQname({ address: account, name }));
|
|
14
|
+
}
|
|
15
|
+
loadInternal(module) {
|
|
16
|
+
const account = accountAddressString(module.address);
|
|
17
|
+
if (this.contains(account, module.name)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.moduleMapping.set(moduleQname({ address: account, name: module.name }), module);
|
|
21
|
+
for (const struct of module.structs) {
|
|
22
|
+
// TODO move to util
|
|
23
|
+
const key = [account, module.name, struct.name].join(SPLITTER);
|
|
24
|
+
this.typeMapping.set(key, struct);
|
|
25
|
+
}
|
|
26
|
+
for (const func of module.exposedFunctions) {
|
|
27
|
+
// if (!func.isEntry) {
|
|
28
|
+
// continue
|
|
29
|
+
// }
|
|
30
|
+
const key = [account, module.name, func.name].join(SPLITTER);
|
|
31
|
+
this.funcMapping.set(key, func);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
decodeBigInt(data) {
|
|
35
|
+
if (Array.isArray(data)) {
|
|
36
|
+
throw new Error('data is in byte array');
|
|
37
|
+
// Only sui function need this, strange
|
|
38
|
+
// const bytes = data as number[]
|
|
39
|
+
// return bytesToBigInt(new Uint8Array(bytes.slice().reverse()))
|
|
40
|
+
}
|
|
41
|
+
return BigInt(data);
|
|
42
|
+
}
|
|
43
|
+
requestMap = new Map();
|
|
44
|
+
async getMoveStruct(type) {
|
|
45
|
+
const [account_, module, typeName] = type.split(SPLITTER);
|
|
46
|
+
const account = accountAddressString(account_);
|
|
47
|
+
type = [account, module, typeName].join(SPLITTER);
|
|
48
|
+
let struct = this.typeMapping.get(type);
|
|
49
|
+
if (struct) {
|
|
50
|
+
return struct;
|
|
51
|
+
}
|
|
52
|
+
let resp = this.requestMap.get(account);
|
|
53
|
+
if (!resp) {
|
|
54
|
+
resp = this.adapter.fetchModules(account).then((modules) => {
|
|
55
|
+
for (const m of modules) {
|
|
56
|
+
this.load(m);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
this.requestMap.set(account, resp);
|
|
60
|
+
}
|
|
61
|
+
await resp;
|
|
62
|
+
struct = this.typeMapping.get(type);
|
|
63
|
+
if (struct) {
|
|
64
|
+
return struct;
|
|
65
|
+
}
|
|
66
|
+
throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
|
|
67
|
+
}
|
|
68
|
+
async getMoveFunction(type) {
|
|
69
|
+
const [account_, module, typeName] = type.split(SPLITTER);
|
|
70
|
+
const account = accountAddressString(account_);
|
|
71
|
+
type = [account, module, typeName].join(SPLITTER);
|
|
72
|
+
let func = this.funcMapping.get(type);
|
|
73
|
+
if (func) {
|
|
74
|
+
return func;
|
|
75
|
+
}
|
|
76
|
+
let resp = this.requestMap.get(account);
|
|
77
|
+
if (!resp) {
|
|
78
|
+
resp = this.adapter
|
|
79
|
+
.fetchModules(account)
|
|
80
|
+
.then((modules) => {
|
|
81
|
+
for (const m of modules) {
|
|
82
|
+
this.load(m);
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.catch((e) => {
|
|
86
|
+
this.requestMap.delete(account);
|
|
87
|
+
});
|
|
88
|
+
this.requestMap.set(account, resp);
|
|
89
|
+
}
|
|
90
|
+
await resp;
|
|
91
|
+
func = this.funcMapping.get(type);
|
|
92
|
+
if (func) {
|
|
93
|
+
return func;
|
|
94
|
+
}
|
|
95
|
+
throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
|
|
96
|
+
}
|
|
97
|
+
async decode(data, type) {
|
|
98
|
+
// process simple type
|
|
99
|
+
if (type.reference) {
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
switch (type.qname) {
|
|
103
|
+
case 'signer': // TODO check this, aptos only
|
|
104
|
+
case 'address':
|
|
105
|
+
case 'Address':
|
|
106
|
+
case '0x1::string::String':
|
|
107
|
+
case 'bool':
|
|
108
|
+
case 'Bool':
|
|
109
|
+
case 'u8':
|
|
110
|
+
case 'U8':
|
|
111
|
+
case 'u16':
|
|
112
|
+
case 'U16':
|
|
113
|
+
case 'u32':
|
|
114
|
+
case 'U32':
|
|
115
|
+
return data;
|
|
116
|
+
case 'u64':
|
|
117
|
+
case 'U64':
|
|
118
|
+
case 'u128':
|
|
119
|
+
case 'U128':
|
|
120
|
+
case 'u256':
|
|
121
|
+
case 'U256':
|
|
122
|
+
return this.decodeBigInt(data);
|
|
123
|
+
}
|
|
124
|
+
// process vector
|
|
125
|
+
if (type.qname.toLowerCase() === VECTOR_STR) {
|
|
126
|
+
// vector<u8> as hex string
|
|
127
|
+
if (type.typeArgs[0].qname === 'u8' || type.typeArgs[0].qname === 'U8') {
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
130
|
+
const res = [];
|
|
131
|
+
for (const entry of data) {
|
|
132
|
+
res.push(await this.decode(entry, type.typeArgs[0]));
|
|
133
|
+
}
|
|
134
|
+
return res;
|
|
135
|
+
}
|
|
136
|
+
// Process complex type
|
|
137
|
+
const struct = await this.getMoveStruct(type.qname);
|
|
138
|
+
const typeCtx = new Map();
|
|
139
|
+
for (const [idx, typeArg] of type.typeArgs.entries()) {
|
|
140
|
+
typeCtx.set('T' + idx, typeArg);
|
|
141
|
+
}
|
|
142
|
+
const typedData = {};
|
|
143
|
+
for (const field of struct.fields) {
|
|
144
|
+
let filedType = field.type;
|
|
145
|
+
filedType = filedType.applyTypeArgs(typeCtx);
|
|
146
|
+
const fieldValue = this.adapter.getData(data)[field.name];
|
|
147
|
+
const value = await this.decode(fieldValue, filedType);
|
|
148
|
+
typedData[field.name] = value;
|
|
149
|
+
}
|
|
150
|
+
return typedData;
|
|
151
|
+
}
|
|
152
|
+
async decodeArray(entries, types, strict = true) {
|
|
153
|
+
const entriesDecoded = [];
|
|
154
|
+
for (const [idx, arg] of entries.entries()) {
|
|
155
|
+
// TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
|
|
156
|
+
const argType = types[idx];
|
|
157
|
+
try {
|
|
158
|
+
if (!strict && arg === undefined) {
|
|
159
|
+
entriesDecoded.push(arg);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
entriesDecoded.push(await this.decode(arg, argType));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
throw Error('Decoding error for ' + JSON.stringify(arg) + 'using type' + argType + e.toString());
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return entriesDecoded;
|
|
170
|
+
}
|
|
171
|
+
encode(data) {
|
|
172
|
+
if (!data) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
if (typeof data === 'bigint') {
|
|
176
|
+
return data.toString();
|
|
177
|
+
}
|
|
178
|
+
if (Array.isArray(data)) {
|
|
179
|
+
return this.encodeArray(data);
|
|
180
|
+
}
|
|
181
|
+
for (const [key, value] of Object.entries(data)) {
|
|
182
|
+
if (!value) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (typeof value === 'bigint') {
|
|
186
|
+
data[key] = value.toString();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return data;
|
|
190
|
+
}
|
|
191
|
+
encodeArray(entriesDecoded) {
|
|
192
|
+
const entries = [];
|
|
193
|
+
for (const [idx, arg] of entriesDecoded.entries()) {
|
|
194
|
+
entries.push(this.encode(arg));
|
|
195
|
+
}
|
|
196
|
+
return entries;
|
|
197
|
+
}
|
|
198
|
+
async decodeCallResult(res, func) {
|
|
199
|
+
const f = await this.getMoveFunction(func);
|
|
200
|
+
return this.decodeArray(res, f.return);
|
|
201
|
+
}
|
|
202
|
+
async filterAndDecodeStruct(typeMatcher, structsWithTags) {
|
|
203
|
+
if (!structsWithTags) {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
// const typeMatcherDescriptor = parseMoveType(typeMatcher)
|
|
207
|
+
const results = [];
|
|
208
|
+
for (const resource of structsWithTags) {
|
|
209
|
+
const resourceType = this.adapter.getType(resource);
|
|
210
|
+
const resourceTypeDescriptor = parseMoveType(resourceType);
|
|
211
|
+
if (!matchType(typeMatcher, resourceTypeDescriptor)) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
const result = await this.decodedStruct(resource);
|
|
215
|
+
if (result) {
|
|
216
|
+
results.push(result);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
console.error('decoding error');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return results;
|
|
223
|
+
}
|
|
224
|
+
async decodedStruct(typeStruct) {
|
|
225
|
+
const typeDescriptor = parseMoveType(this.adapter.getType(typeStruct));
|
|
226
|
+
const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature());
|
|
227
|
+
let dataTyped = undefined;
|
|
228
|
+
try {
|
|
229
|
+
dataTyped = await this.decode(typeStruct, typeDescriptor);
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
throw Error('Decoding error for struct' + JSON.stringify(typeStruct) + e.toString());
|
|
233
|
+
// return undefined
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
...typeStruct,
|
|
237
|
+
data_decoded: dataTyped,
|
|
238
|
+
type_arguments: typeArguments
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
async decodedType(typeStruct, type) {
|
|
242
|
+
if (typeStruct === null || typeStruct == undefined) {
|
|
243
|
+
return typeStruct;
|
|
244
|
+
}
|
|
245
|
+
if (typeof typeStruct === 'object') {
|
|
246
|
+
if ('type' in typeStruct) {
|
|
247
|
+
const typeInStruct = parseMoveType(typeStruct.type.toString() || '');
|
|
248
|
+
if (!matchType(type, typeInStruct)) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return await this.decode(typeStruct, type);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=abstract-move-coder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-move-coder.js","sourceRoot":"","sources":["../../src/abstract-move-coder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACpF,OAAO,EAAiB,SAAS,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAA;AAKpF,MAAM,OAAgB,iBAAiB;IAC3B,aAAa,GAAG,IAAI,GAAG,EAA8B,CAAA;IACvD,WAAW,GAAG,IAAI,GAAG,EAA8B,CAAA;IACnD,WAAW,GAAG,IAAI,GAAG,EAAgC,CAAA;IAC7D,kBAAkB;IAClB,OAAO,CAAsC;IAE7C,YAAsB,OAA6C;QACjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ,CAAC,OAAe,EAAE,IAAY;QACpC,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACxE,CAAC;IAIS,YAAY,CAAC,MAA0B;QAC/C,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE;YACvC,OAAM;SACP;QACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE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AAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;gBAC7E,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE;oBAClC,OAAO,SAAS,CAAA;iBACjB;aACF;SACF;QAED,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InternalMoveModule } from './internal-models.js';
|
|
2
|
+
export declare class AccountModulesImportInfo {
|
|
3
|
+
imports: Map<string, Set<string>>;
|
|
4
|
+
account: string;
|
|
5
|
+
moduleName: string;
|
|
6
|
+
constructor(account: string, tsModuleName: string);
|
|
7
|
+
addImport(account: string, module: string): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class AccountRegister {
|
|
10
|
+
accountImports: Map<string, AccountModulesImportInfo>;
|
|
11
|
+
pendingAccounts: Set<string>;
|
|
12
|
+
register(module: InternalMoveModule, tsModuleName: string): AccountModulesImportInfo;
|
|
13
|
+
private registerFunctions;
|
|
14
|
+
private registerStruct;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,qBAAa,wBAAwB;IAEnC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;gBAEN,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAMjD,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAW1C;AAED,qBAAa,eAAe;IAC1B,cAAc,wCAA8C;IAC5D,eAAe,cAAoB;IAEnC,QAAQ,CACN,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,MAAM,GACnB,wBAAwB;IAqB3B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,cAAc;CAgBvB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { moduleQname, moduleQnameForType } from './utils.js';
|
|
2
|
+
export class AccountModulesImportInfo {
|
|
3
|
+
// account to module
|
|
4
|
+
imports;
|
|
5
|
+
account;
|
|
6
|
+
moduleName;
|
|
7
|
+
constructor(account, tsModuleName) {
|
|
8
|
+
this.account = account;
|
|
9
|
+
this.moduleName = tsModuleName;
|
|
10
|
+
this.imports = new Map();
|
|
11
|
+
}
|
|
12
|
+
addImport(account, module) {
|
|
13
|
+
if (account === this.account) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let accountModules = this.imports.get(account);
|
|
17
|
+
if (!accountModules) {
|
|
18
|
+
accountModules = new Set();
|
|
19
|
+
this.imports.set(account, accountModules);
|
|
20
|
+
}
|
|
21
|
+
accountModules.add(module);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class AccountRegister {
|
|
25
|
+
accountImports = new Map();
|
|
26
|
+
pendingAccounts = new Set();
|
|
27
|
+
register(module, tsModuleName) {
|
|
28
|
+
const currentModuleFqn = moduleQname(module);
|
|
29
|
+
let accountModuleImports = this.accountImports.get(module.address);
|
|
30
|
+
if (!accountModuleImports) {
|
|
31
|
+
accountModuleImports = new AccountModulesImportInfo(module.address, tsModuleName);
|
|
32
|
+
this.accountImports.set(module.address, accountModuleImports);
|
|
33
|
+
// the account has already be processed, delete pending task
|
|
34
|
+
this.pendingAccounts.delete(module.address);
|
|
35
|
+
}
|
|
36
|
+
this.registerStruct(module, accountModuleImports);
|
|
37
|
+
this.registerFunctions(module, accountModuleImports);
|
|
38
|
+
this.accountImports.set(currentModuleFqn, accountModuleImports);
|
|
39
|
+
return accountModuleImports;
|
|
40
|
+
}
|
|
41
|
+
registerFunctions(module, accountModuleImports) {
|
|
42
|
+
for (const func of module.exposedFunctions) {
|
|
43
|
+
if (!func.isEntry) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
for (const param of func.params) {
|
|
47
|
+
for (const type of param.dependedTypes()) {
|
|
48
|
+
const [account, module] = moduleQnameForType(type);
|
|
49
|
+
accountModuleImports.addImport(account, module);
|
|
50
|
+
if (!this.accountImports.has(account)) {
|
|
51
|
+
this.pendingAccounts.add(account);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
registerStruct(module, accountModuleImports) {
|
|
58
|
+
for (const struct of module.structs) {
|
|
59
|
+
for (const field of struct.fields) {
|
|
60
|
+
for (const type of field.type.dependedTypes()) {
|
|
61
|
+
const [account, module] = moduleQnameForType(type);
|
|
62
|
+
accountModuleImports.addImport(account, module);
|
|
63
|
+
if (!this.accountImports.has(account)) {
|
|
64
|
+
this.pendingAccounts.add(account);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAG5D,MAAM,OAAO,wBAAwB;IACnC,oBAAoB;IACpB,OAAO,CAA0B;IACjC,OAAO,CAAQ;IACf,UAAU,CAAQ;IAElB,YAAY,OAAe,EAAE,YAAoB;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,YAAY,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC/C,CAAC;IAED,SAAS,CAAC,OAAe,EAAE,MAAc;QACvC,IAAI,OAAO,KAAK,IA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K,MAAM,IAAI,IAAI,MAAM,CAAC,gBAAgB,EAAE;YAC1C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,SAAQ;aACT;YACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,aAAa,EAAE,EAAE;oBACxC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;oBAClD,oBAAoB,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;oBAC/C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;wBACrC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;qBAClC;iBACF;aACF;SACF;IACH,CAAC;IAEO,cAAc,CACpB,MAA0B,EAC1B,oBAA8C;QAE9C,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;gBACjC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE;oBAC7C,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAA;oBAClD,oBAAoB,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;oBAC/C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;wBACrC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;qBAClC;iBACF;aACF;SACF;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InternalMoveModule, InternalMoveStruct } from './internal-models.js';
|
|
2
|
+
import { TypeDescriptor } from './types.js';
|
|
3
|
+
export declare abstract class ChainAdapter<ModuleType, StructType> {
|
|
4
|
+
abstract getChainId(): Promise<string>;
|
|
5
|
+
abstract fetchModule(account: string, module: string): Promise<ModuleType>;
|
|
6
|
+
abstract fetchModules(account: string): Promise<ModuleType[]>;
|
|
7
|
+
abstract toInternalModules(modules: ModuleType[]): InternalMoveModule[];
|
|
8
|
+
abstract getAllEventStructs(module: InternalMoveModule[]): Map<string, InternalMoveStruct>;
|
|
9
|
+
abstract getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
|
|
10
|
+
abstract getType(base: StructType): string;
|
|
11
|
+
abstract getData<T>(base: StructType): any;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=chain-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-adapter.d.ts","sourceRoot":"","sources":["../../src/chain-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,8BAAsB,YAAY,CAAC,UAAU,EAAE,UAAU;IAMvD,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAEtC,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAE1E,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAC7D,QAAQ,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,kBAAkB,EAAE;IAGvE,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAI1F,QAAQ,CAAC,2BAA2B,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAEhF,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;IAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,GAAG,GAAG;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-adapter.js","sourceRoot":"","sources":["../../src/chain-adapter.ts"],"names":[],"mappings":"AAGA,MAAM,OAAgB,YAAY;CAsBjC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export * from './account.js';
|
|
4
|
+
export * from './chain-adapter.js';
|
|
5
|
+
export * from './abstract-codegen.js';
|
|
6
|
+
export * from './abstract-move-coder.js';
|
|
7
|
+
export * from './internal-models.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './utils.js';
|
|
3
|
+
export * from './account.js';
|
|
4
|
+
export * from './chain-adapter.js';
|
|
5
|
+
export * from './abstract-codegen.js';
|
|
6
|
+
export * from './abstract-move-coder.js';
|
|
7
|
+
export * from './internal-models.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,cAAc,CAAA;AAC5B,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TypeDescriptor } from './types.js';
|
|
2
|
+
export interface InternalMoveModule {
|
|
3
|
+
address: string;
|
|
4
|
+
name: string;
|
|
5
|
+
exposedFunctions: InternalMoveFunction[];
|
|
6
|
+
structs: InternalMoveStruct[];
|
|
7
|
+
}
|
|
8
|
+
export interface InternalMoveFunction {
|
|
9
|
+
name: string;
|
|
10
|
+
visibility: InternalMoveFunctionVisibility;
|
|
11
|
+
isEntry: boolean;
|
|
12
|
+
isView?: boolean;
|
|
13
|
+
typeParams: InternalMoveTypeParam[];
|
|
14
|
+
params: TypeDescriptor[];
|
|
15
|
+
return: TypeDescriptor[];
|
|
16
|
+
}
|
|
17
|
+
export interface InternalMoveStruct {
|
|
18
|
+
name: string;
|
|
19
|
+
isNative: boolean;
|
|
20
|
+
abilities: string[];
|
|
21
|
+
typeParams: InternalMoveTypeParam[];
|
|
22
|
+
fields: InternalMoveStructField[];
|
|
23
|
+
}
|
|
24
|
+
export interface InternalMoveStructField {
|
|
25
|
+
name: string;
|
|
26
|
+
type: TypeDescriptor;
|
|
27
|
+
}
|
|
28
|
+
export declare enum InternalMoveFunctionVisibility {
|
|
29
|
+
PRIVATE = "private",
|
|
30
|
+
PUBLIC = "public",
|
|
31
|
+
FRIEND = "friend"
|
|
32
|
+
}
|
|
33
|
+
export type InternalMoveTypeParam = {
|
|
34
|
+
constraints: string[];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=internal-models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-models.d.ts","sourceRoot":"","sources":["../../src/internal-models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,oBAAoB,EAAE,CAAA;IACxC,OAAO,EAAE,kBAAkB,EAAE,CAAA;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,8BAA8B,CAAA;IAC1C,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,qBAAqB,EAAE,CAAA;IACnC,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,UAAU,EAAE,qBAAqB,EAAE,CAAA;IACnC,MAAM,EAAE,uBAAuB,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,cAAc,CAAA;CACrB;AAED,oBAAY,8BAA8B;IACxC,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var InternalMoveFunctionVisibility;
|
|
2
|
+
(function (InternalMoveFunctionVisibility) {
|
|
3
|
+
InternalMoveFunctionVisibility["PRIVATE"] = "private";
|
|
4
|
+
InternalMoveFunctionVisibility["PUBLIC"] = "public";
|
|
5
|
+
InternalMoveFunctionVisibility["FRIEND"] = "friend";
|
|
6
|
+
})(InternalMoveFunctionVisibility || (InternalMoveFunctionVisibility = {}));
|
|
7
|
+
//# sourceMappingURL=internal-models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-models.js","sourceRoot":"","sources":["../../src/internal-models.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAN,IAAY,8BAIX;AAJD,WAAY,8BAA8B;IACxC,qDAAmB,CAAA;IACnB,mDAAiB,CAAA;IACjB,mDAAiB,CAAA;AACnB,CAAC,EAJW,8BAA8B,KAA9B,8BAA8B,QAIzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-type.test.d.ts","sourceRoot":"","sources":["../../src/ts-type.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-type.test.js","sourceRoot":"","sources":["../../src/ts-type.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE1C,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,GAAG,GAAG,aAAa,CAAC,8BAA8B,CAAC,CAAA;QAEzD,MAAM,CAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAA;QACzB,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAA;QAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;QAEhC,MAAM,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QAC3B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,UAAU,GACd,wJAAwJ,CAAA;QAC1J,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;QAErC,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,EAAE,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;QACzB,MAAM,CACJ,IAAI,CAAC,CAAC,CAAC;YACL,mGAAmG,CACtG,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,yCAAyC,CAAC,CAAA;QAE7D,MAAM,kBAAkB,GAAG,GAAG,CAAC,YAAY,EAAE,CAAA;QAC7C,MAAM,CAAC,kBAAkB,KAAK,UAAU,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC3C,MAAM,UAAU,GAAG,kDAAkD,CAAA;QACrE,MAAM,GAAG,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;QAErC,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,EAAE,CAAA;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;IACF,sCAAsC;IACtC,EAAE;IACF,iEAAiE;IACjE,qBAAqB;IACrB,EAAE;IACF,+BAA+B;IAC/B,4DAA4D;IAC5D,yEAAyE;IACzE,KAAK;AACP,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type DecodedStruct<B, T> = B & {
|
|
2
|
+
/**
|
|
3
|
+
* decoded data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
|
|
4
|
+
*/
|
|
5
|
+
data_decoded: T;
|
|
6
|
+
type_arguments: string[];
|
|
7
|
+
};
|
|
8
|
+
export declare class TypeDescriptor<T = any> {
|
|
9
|
+
qname: string;
|
|
10
|
+
reference: boolean;
|
|
11
|
+
mutable: boolean;
|
|
12
|
+
typeArgs: TypeDescriptor[];
|
|
13
|
+
constructor(symbol: string, typeParams?: TypeDescriptor[]);
|
|
14
|
+
apply(...typeArgs: TypeDescriptor[]): TypeDescriptor;
|
|
15
|
+
clone(): this;
|
|
16
|
+
compareQname(t: TypeDescriptor): boolean;
|
|
17
|
+
getSignature(): string;
|
|
18
|
+
getNormalizedSignature(): string;
|
|
19
|
+
applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor;
|
|
20
|
+
dependedTypes(): string[];
|
|
21
|
+
isVector(): boolean;
|
|
22
|
+
existAnyType(): boolean;
|
|
23
|
+
name(): string;
|
|
24
|
+
}
|
|
25
|
+
export declare function parseMoveType(type: string): TypeDescriptor;
|
|
26
|
+
export declare const ANY_TYPE: TypeDescriptor<any>;
|
|
27
|
+
export declare function vectorType<T>(t?: TypeDescriptor<T>): TypeDescriptor<T[]>;
|
|
28
|
+
export declare const BUILTIN_TYPES: {
|
|
29
|
+
ADDRESS_TYPE: TypeDescriptor<string>;
|
|
30
|
+
VECTOR_TYPE_ANY: TypeDescriptor<any[]>;
|
|
31
|
+
VECTOR_TYPE: typeof vectorType;
|
|
32
|
+
BOOL_TYPE: TypeDescriptor<number>;
|
|
33
|
+
U8_TYPE: TypeDescriptor<number>;
|
|
34
|
+
U16_TYPE: TypeDescriptor<number>;
|
|
35
|
+
U32_TYPE: TypeDescriptor<number>;
|
|
36
|
+
U64_TYPE: TypeDescriptor<number>;
|
|
37
|
+
U128_TYPE: TypeDescriptor<number>;
|
|
38
|
+
U256_TYPE: TypeDescriptor<number>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param matcher
|
|
43
|
+
* @param type
|
|
44
|
+
*/
|
|
45
|
+
export declare function matchType(matcher: TypeDescriptor, type: TypeDescriptor):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