@typemove/move 2.0.0 → 2.0.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.
Files changed (46) hide show
  1. package/dist/esm/abstract-move-coder.d.ts +30 -0
  2. package/dist/esm/abstract-move-coder.d.ts.map +1 -0
  3. package/dist/esm/abstract-move-coder.js +308 -0
  4. package/dist/esm/abstract-move-coder.js.map +1 -0
  5. package/dist/esm/account.d.ts +16 -0
  6. package/dist/esm/account.d.ts.map +1 -0
  7. package/dist/esm/account.js +71 -0
  8. package/dist/esm/account.js.map +1 -0
  9. package/dist/esm/chain-adapter.d.ts +13 -0
  10. package/dist/esm/chain-adapter.d.ts.map +1 -0
  11. package/dist/esm/chain-adapter.js +3 -0
  12. package/dist/esm/chain-adapter.js.map +1 -0
  13. package/dist/esm/codegen/abstract-codegen.d.ts +50 -0
  14. package/dist/esm/codegen/abstract-codegen.d.ts.map +1 -0
  15. package/dist/esm/codegen/abstract-codegen.js +463 -0
  16. package/dist/esm/codegen/abstract-codegen.js.map +1 -0
  17. package/dist/esm/codegen/index.d.ts +2 -0
  18. package/dist/esm/codegen/index.d.ts.map +1 -0
  19. package/dist/esm/codegen/index.js +2 -0
  20. package/dist/esm/codegen/index.js.map +1 -0
  21. package/dist/esm/index.d.ts +7 -0
  22. package/dist/esm/index.d.ts.map +1 -0
  23. package/dist/esm/index.js +7 -0
  24. package/dist/esm/index.js.map +1 -0
  25. package/dist/esm/internal-models.d.ts +46 -0
  26. package/dist/esm/internal-models.d.ts.map +1 -0
  27. package/dist/esm/internal-models.js +7 -0
  28. package/dist/esm/internal-models.js.map +1 -0
  29. package/dist/esm/types.d.ts +52 -0
  30. package/dist/esm/types.d.ts.map +1 -0
  31. package/dist/esm/types.js +317 -0
  32. package/dist/esm/types.js.map +1 -0
  33. package/dist/esm/utils.d.ts +17 -0
  34. package/dist/esm/utils.d.ts.map +1 -0
  35. package/dist/esm/utils.js +127 -0
  36. package/dist/esm/utils.js.map +1 -0
  37. package/package.json +5 -5
  38. package/src/abstract-move-coder.ts +347 -0
  39. package/src/account.ts +81 -0
  40. package/src/chain-adapter.ts +26 -0
  41. package/src/codegen/abstract-codegen.ts +574 -0
  42. package/src/codegen/index.ts +1 -0
  43. package/src/index.ts +6 -0
  44. package/src/internal-models.ts +52 -0
  45. package/src/types.ts +362 -0
  46. package/src/utils.ts +144 -0
@@ -0,0 +1,30 @@
1
+ import { DecodedStruct, TypeDescriptor } from './types.js';
2
+ import { InternalMoveEnum, 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
+ protected accounts: Set<string>;
7
+ private typeMapping;
8
+ private enumMapping;
9
+ private funcMapping;
10
+ adapter: ChainAdapter<ModuleType, StructType>;
11
+ protected constructor(adapter: ChainAdapter<ModuleType, StructType>);
12
+ contains(account: string, name: string): boolean;
13
+ abstract load(module: ModuleType, address: string): InternalMoveModule;
14
+ protected loadInternal(module: InternalMoveModule, address: string): void;
15
+ private _loadInternal;
16
+ protected decodeBigInt(data: any): bigint;
17
+ private requestMap;
18
+ getMoveStruct(type: string): Promise<InternalMoveStruct>;
19
+ maybeGetMoveEnum(type: string): Promise<InternalMoveEnum | undefined>;
20
+ getMoveFunction(type: string): Promise<InternalMoveFunction>;
21
+ protected decode<T>(data: any, type: TypeDescriptor<T>): Promise<T>;
22
+ decodeArray(entries: any[], types: TypeDescriptor[], strict?: boolean): Promise<any[]>;
23
+ encode(data: any): any;
24
+ encodeArray(entriesDecoded: any[]): any[];
25
+ decodeCallResult(res: any[], func: string): Promise<any[]>;
26
+ filterAndDecodeStruct<T, ST extends StructType>(typeMatcher: TypeDescriptor<T>, structsWithTags: ST[]): Promise<DecodedStruct<ST, T>[]>;
27
+ protected decodedStruct<T, ST extends StructType>(typeStruct: ST): Promise<DecodedStruct<ST, T> | undefined>;
28
+ decodeType<T, ST>(typeStruct: ST, type: TypeDescriptor<T>): Promise<T | undefined>;
29
+ }
30
+ //# sourceMappingURL=abstract-move-coder.d.ts.map
@@ -0,0 +1 @@
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,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAErH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,8BAAsB,iBAAiB,CAAC,UAAU,EAAE,UAAU;IAC5D,SAAS,CAAC,aAAa,kCAAwC;IAC/D,SAAS,CAAC,QAAQ,cAAoB;IACtC,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,WAAW,CAAsC;IAEzD,OAAO,CAAC,WAAW,CAA0C;IAE7D,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAE7C,SAAS,aAAa,OAAO,EAAE,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC;IAInE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAItC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB;IAEtE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM;IAUlE,OAAO,CAAC,aAAa;IAyBrB,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,GAAG,MAAM;IAWzC,OAAO,CAAC,UAAU,CAAmC;IAE/C,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6BxD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IA6BrE,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;cAkClD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAoEnE,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,MAAM,UAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAkBlF,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG;IAqB7B,WAAW,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE;IAQnC,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAK1D,qBAAqB,CAAC,CAAC,EAAE,EAAE,SAAS,UAAU,EAClD,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,EAC9B,eAAe,EAAE,EAAE,EAAE,GACpB,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;cAuBlB,aAAa,CAAC,CAAC,EAAE,EAAE,SAAS,UAAU,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAkBrG,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CAgBhG"}
@@ -0,0 +1,308 @@
1
+ import { accountTypeString, moduleQname, SPLITTER, VECTOR_STR } from './utils.js';
2
+ import { matchType, parseMoveType } from './types.js';
3
+ export class AbstractMoveCoder {
4
+ moduleMapping = new Map();
5
+ accounts = new Set();
6
+ typeMapping = new Map();
7
+ enumMapping = new Map();
8
+ funcMapping = new Map();
9
+ // network: string
10
+ adapter;
11
+ constructor(adapter) {
12
+ this.adapter = adapter;
13
+ }
14
+ contains(account, name) {
15
+ return this.moduleMapping.has(moduleQname({ address: account, name }));
16
+ }
17
+ loadInternal(module, address) {
18
+ const account = module.address;
19
+ const declareAccount = accountTypeString(address);
20
+ this._loadInternal(module, account);
21
+ if (account !== declareAccount) {
22
+ this._loadInternal(module, declareAccount);
23
+ }
24
+ }
25
+ _loadInternal(module, account) {
26
+ if (this.contains(account, module.name)) {
27
+ return;
28
+ }
29
+ this.moduleMapping.set(moduleQname({ address: account, name: module.name }), module);
30
+ for (const enumType of module.enums) {
31
+ const key = [account, module.name, enumType.name].join(SPLITTER);
32
+ this.enumMapping.set(key, enumType);
33
+ }
34
+ for (const struct of module.structs) {
35
+ // TODO move to util
36
+ const key = [account, module.name, struct.name].join(SPLITTER);
37
+ this.typeMapping.set(key, struct);
38
+ }
39
+ for (const func of module.exposedFunctions) {
40
+ // if (!func.isEntry) {
41
+ // continue
42
+ // }
43
+ const key = [account, module.name, func.name].join(SPLITTER);
44
+ this.funcMapping.set(key, func);
45
+ }
46
+ }
47
+ decodeBigInt(data) {
48
+ if (Array.isArray(data)) {
49
+ throw new Error('data is in byte array');
50
+ // Only sui function need this, strange
51
+ // const bytes = data as number[]
52
+ // return bytesToBigInt(new Uint8Array(bytes.slice().reverse()))
53
+ }
54
+ return BigInt(data);
55
+ }
56
+ requestMap = new Map();
57
+ async getMoveStruct(type) {
58
+ const [account_, module, typeName] = type.split(SPLITTER);
59
+ const account = accountTypeString(account_);
60
+ type = [account, module, typeName].join(SPLITTER);
61
+ let struct = this.typeMapping.get(type);
62
+ if (struct) {
63
+ return struct;
64
+ }
65
+ if (this.accounts.has(account)) {
66
+ throw new Error('Failed to load struct ' + type + ' for imported account');
67
+ }
68
+ let resp = this.requestMap.get(account);
69
+ if (!resp) {
70
+ resp = this.adapter.fetchModules(account).then((modules) => {
71
+ for (const m of modules) {
72
+ this.load(m, account);
73
+ }
74
+ });
75
+ this.requestMap.set(account, resp);
76
+ }
77
+ await resp;
78
+ struct = this.typeMapping.get(type);
79
+ if (struct) {
80
+ return struct;
81
+ }
82
+ throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
83
+ }
84
+ async maybeGetMoveEnum(type) {
85
+ const [account_, module, typeName] = type.split(SPLITTER);
86
+ const account = accountTypeString(account_);
87
+ type = [account, module, typeName].join(SPLITTER);
88
+ let enumType = this.enumMapping.get(type);
89
+ if (enumType) {
90
+ return enumType;
91
+ }
92
+ if (this.accounts.has(account)) {
93
+ return undefined;
94
+ }
95
+ let resp = this.requestMap.get(account);
96
+ if (!resp) {
97
+ resp = this.adapter.fetchModules(account).then((modules) => {
98
+ for (const m of modules) {
99
+ this.load(m, account);
100
+ }
101
+ });
102
+ this.requestMap.set(account, resp);
103
+ }
104
+ await resp;
105
+ enumType = this.enumMapping.get(type);
106
+ if (enumType) {
107
+ return enumType;
108
+ }
109
+ return undefined;
110
+ }
111
+ async getMoveFunction(type) {
112
+ const [account_, module, typeName] = type.split(SPLITTER);
113
+ const account = accountTypeString(account_);
114
+ type = [account, module, typeName].join(SPLITTER);
115
+ let func = this.funcMapping.get(type);
116
+ if (func) {
117
+ return func;
118
+ }
119
+ if (this.accounts.has(account)) {
120
+ throw new Error('Failed to load function ' + type + ' for imported account');
121
+ }
122
+ let resp = this.requestMap.get(account);
123
+ if (!resp) {
124
+ resp = this.adapter
125
+ .fetchModules(account)
126
+ .then((modules) => {
127
+ for (const m of modules) {
128
+ this.load(m, account);
129
+ }
130
+ })
131
+ .catch((e) => {
132
+ this.requestMap.delete(account);
133
+ });
134
+ this.requestMap.set(account, resp);
135
+ }
136
+ await resp;
137
+ func = this.funcMapping.get(type);
138
+ if (func) {
139
+ return func;
140
+ }
141
+ throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
142
+ }
143
+ async decode(data, type) {
144
+ // process simple type
145
+ if (type.reference) {
146
+ return data;
147
+ }
148
+ switch (type.qname) {
149
+ case 'signer': // TODO check this, aptos only
150
+ case 'address':
151
+ case 'Address':
152
+ case '0x1::string::String':
153
+ case 'bool':
154
+ case 'Bool':
155
+ case 'u8':
156
+ case 'U8':
157
+ case 'u16':
158
+ case 'U16':
159
+ case 'u32':
160
+ case 'U32':
161
+ return data;
162
+ case 'u64':
163
+ case 'U64':
164
+ case 'u128':
165
+ case 'U128':
166
+ case 'u256':
167
+ case 'U256':
168
+ return this.decodeBigInt(data);
169
+ }
170
+ // process vector
171
+ if (type.qname.toLowerCase() === VECTOR_STR) {
172
+ // vector<u8> as hex string
173
+ if (type.typeArgs[0].qname === 'u8' || type.typeArgs[0].qname === 'U8') {
174
+ return data;
175
+ }
176
+ const res = [];
177
+ for (const entry of data) {
178
+ res.push(await this.decode(entry, type.typeArgs[0]));
179
+ }
180
+ return res;
181
+ }
182
+ // try enum type first
183
+ const enumType = await this.maybeGetMoveEnum(type.qname);
184
+ if (enumType) {
185
+ return data;
186
+ }
187
+ // Process complex type
188
+ const struct = await this.getMoveStruct(type.qname);
189
+ const typeCtx = new Map();
190
+ for (const [idx, typeArg] of type.typeArgs.entries()) {
191
+ typeCtx.set('T' + idx, typeArg);
192
+ }
193
+ const typedData = {};
194
+ for (const field of struct.fields) {
195
+ let filedType = field.type;
196
+ filedType = filedType.applyTypeArgs(typeCtx);
197
+ const fieldValue = this.adapter.getData(data)[field.name];
198
+ const value = await this.decode(fieldValue, filedType);
199
+ typedData[field.name] = value;
200
+ }
201
+ return typedData;
202
+ }
203
+ async decodeArray(entries, types, strict = true) {
204
+ const entriesDecoded = [];
205
+ for (const [idx, arg] of entries.entries()) {
206
+ // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
207
+ const argType = types[idx];
208
+ try {
209
+ if (!strict && arg === undefined) {
210
+ entriesDecoded.push(arg);
211
+ }
212
+ else {
213
+ entriesDecoded.push(await this.decode(arg, argType));
214
+ }
215
+ }
216
+ catch (e) {
217
+ throw Error('Decoding error for ' + JSON.stringify(arg) + 'using type' + argType + String(e));
218
+ }
219
+ }
220
+ return entriesDecoded;
221
+ }
222
+ encode(data) {
223
+ if (data === undefined || data === null) {
224
+ return undefined;
225
+ }
226
+ if (typeof data === 'bigint') {
227
+ return data.toString();
228
+ }
229
+ if (Array.isArray(data)) {
230
+ return this.encodeArray(data);
231
+ }
232
+ for (const [key, value] of Object.entries(data)) {
233
+ if (!value) {
234
+ continue;
235
+ }
236
+ if (typeof value === 'bigint') {
237
+ data[key] = value.toString();
238
+ }
239
+ }
240
+ return data;
241
+ }
242
+ encodeArray(entriesDecoded) {
243
+ const entries = [];
244
+ for (const [idx, arg] of entriesDecoded.entries()) {
245
+ entries.push(this.encode(arg));
246
+ }
247
+ return entries;
248
+ }
249
+ async decodeCallResult(res, func) {
250
+ const f = await this.getMoveFunction(func);
251
+ return this.decodeArray(res, f.return);
252
+ }
253
+ async filterAndDecodeStruct(typeMatcher, structsWithTags) {
254
+ if (!structsWithTags) {
255
+ return [];
256
+ }
257
+ // const typeMatcherDescriptor = parseMoveType(typeMatcher)
258
+ const results = [];
259
+ for (const resource of structsWithTags) {
260
+ const resourceType = this.adapter.getType(resource);
261
+ const resourceTypeDescriptor = parseMoveType(resourceType);
262
+ if (!matchType(typeMatcher, resourceTypeDescriptor)) {
263
+ continue;
264
+ }
265
+ const result = await this.decodedStruct(resource);
266
+ if (result) {
267
+ results.push(result);
268
+ }
269
+ else {
270
+ console.error('decoding error');
271
+ }
272
+ }
273
+ return results;
274
+ }
275
+ async decodedStruct(typeStruct) {
276
+ const typeDescriptor = parseMoveType(this.adapter.getType(typeStruct));
277
+ const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature());
278
+ let dataTyped = undefined;
279
+ try {
280
+ dataTyped = await this.decode(typeStruct, typeDescriptor);
281
+ }
282
+ catch (e) {
283
+ throw Error('Decoding error for struct' + JSON.stringify(typeStruct) + String(e));
284
+ // return undefined
285
+ }
286
+ return {
287
+ ...typeStruct,
288
+ data_decoded: dataTyped,
289
+ type_arguments: typeArguments
290
+ };
291
+ }
292
+ async decodeType(typeStruct, type) {
293
+ if (typeStruct === null || typeStruct == undefined) {
294
+ return typeStruct;
295
+ }
296
+ if (typeof typeStruct === 'object') {
297
+ if ('type' in typeStruct) {
298
+ const typeInStruct = parseMoveType(typeStruct.type.toString() || '');
299
+ if (!matchType(type, typeInStruct)) {
300
+ return undefined;
301
+ }
302
+ type = typeInStruct;
303
+ }
304
+ }
305
+ return await this.decode(typeStruct, type);
306
+ }
307
+ }
308
+ //# 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,iBAAiB,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACjF,OAAO,EAAiB,SAAS,EAAE,aAAa,EAAkB,MAAM,YAAY,CAAA;AAKpF,MAAM,OAAgB,iBAAiB;IAC3B,aAAa,GAAG,IAAI,GAAG,EAA8B,CAAA;IACrD,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,WAAW,GAAG,IAAI,GAAG,EAA8B,CAAA;IACnD,WAAW,GAAG,IAAI,GAAG,EAA4B,CAAA;IAEjD,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,EAAE,OAAe;QAChE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA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IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;YACjF,mBAAmB;QACrB,CAAC;QACD,OAAO;YACL,GAAG,UAAU;YACb,YAAY,EAAE,SAAS;YACvB,cAAc,EAAE,aAAa;SAC9B,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAQ,UAAc,EAAE,IAAuB;QACpE,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;YACnD,OAAO,UAAiB,CAAA;QAC1B,CAAC;QACD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;YACnC,IAAI,MAAM,IAAI,UAAU,EAAE,CAAC;gBACzB,MAAM,YAAY,GAAG,aAAa,CAAE,UAAU,CAAC,IAAY,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;gBAC7E,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;oBACnC,OAAO,SAAS,CAAA;gBAClB,CAAC;gBACD,IAAI,GAAG,YAAY,CAAA;YACrB,CAAC;QACH,CAAC;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,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,GAAG,wBAAwB;IAkBpF,OAAO,CAAC,iBAAiB;IAiBzB,OAAO,CAAC,cAAc;CAavB"}
@@ -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.concat(func.return)) {
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,IAAI,CAAC,OAAO,EAAE,CAAC;YAC7B,OAAM;QACR,CAAC;QACD,IAAI,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,GA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AuB;YACvB,aAAa;YACb,IAAI;YACJ,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACpD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC;oBACzC,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,CAAC;wBACtC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;oBACnC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,cAAc,CAAC,MAA0B,EAAE,oBAA8C;QAC/F,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACpC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBAClC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;oBAC9C,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,CAAC;wBACtC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;oBACnC,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;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,3 @@
1
+ export class ChainAdapter {
2
+ }
3
+ //# sourceMappingURL=chain-adapter.js.map
@@ -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,50 @@
1
+ import { InternalMoveEnum, 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
+ chainAdapter: ChainAdapter<ModuleTypes, StructType>;
21
+ protected constructor(chainAdapter: ChainAdapter<ModuleTypes, StructType>);
22
+ readModulesFile(fullPath: string): any;
23
+ protected defaultCoderPackage(): string;
24
+ generateLoadAll(isSystem: boolean): string;
25
+ generate(srcDir: string, outputDir: string, builtin?: boolean): Promise<number>;
26
+ protected generateExtra(address: string | undefined, module: InternalMoveModule): string;
27
+ generateModule(module: InternalMoveModule, allEventStructs: Map<string, InternalMoveStruct>, addressOverride?: string): string;
28
+ generateEnum(module: InternalMoveModule, enumType: InternalMoveEnum): string;
29
+ generateStructs(module: InternalMoveModule, struct: InternalMoveStruct, events: Set<string>, typeOnly?: boolean): string;
30
+ generateFunctionTypeParameters(func: InternalMoveFunction): string;
31
+ generateFunctionReturnTypeParameters(func: InternalMoveFunction, currentAddress: string): string;
32
+ generateStructTypeParameters(struct: InternalMoveStruct | InternalMoveEnum, useAny?: boolean): string;
33
+ generateCallArgsStructs(module: InternalMoveModule, func: InternalMoveFunction): string;
34
+ generateForEvents(module: InternalMoveModule, struct: InternalMoveStruct): string;
35
+ generateTypeForDescriptor(type: TypeDescriptor, currentAddress: string): string;
36
+ generateSimpleType(type: string, currentAddress: string): string;
37
+ generateImports(): string;
38
+ }
39
+ export declare class AccountCodegen<ModuleType, StructType> {
40
+ modules: InternalMoveModule[];
41
+ config: Config;
42
+ abi: ModuleType[];
43
+ loader: AccountRegister;
44
+ moduleGen: AbstractCodegen<ModuleType, StructType>;
45
+ address?: string;
46
+ constructor(moduleGen: AbstractCodegen<ModuleType, StructType>, loader: AccountRegister, abi: ModuleType[], modules: InternalMoveModule[], config: Config, address: string | undefined);
47
+ generate(): OutputFile[];
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=abstract-codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abstract-codegen.d.ts","sourceRoot":"","sources":["../../../src/codegen/abstract-codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAGtH,OAAO,EAA4B,eAAe,EAAE,MAAM,eAAe,CAAA;AAGzE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,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;AAED,8BAAsB,eAAe,CAAC,WAAW,EAAE,UAAU;IAI3D,YAAY,EAAG,MAAM,CAAA;IACrB,cAAc,EAAG,MAAM,CAAA;IACvB,MAAM,EAAG,M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