@typemove/move 1.0.0-rc.9 → 1.0.1-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.
Files changed (81) hide show
  1. package/dist/cjs/abstract-codegen.d.ts +49 -0
  2. package/dist/cjs/abstract-codegen.d.ts.map +1 -0
  3. package/dist/cjs/abstract-codegen.js +405 -0
  4. package/dist/cjs/abstract-codegen.js.map +1 -0
  5. package/dist/cjs/abstract-move-coder.d.ts +26 -0
  6. package/dist/cjs/abstract-move-coder.d.ts.map +1 -0
  7. package/dist/cjs/abstract-move-coder.js +253 -0
  8. package/dist/cjs/abstract-move-coder.js.map +1 -0
  9. package/dist/cjs/account.d.ts +16 -0
  10. package/dist/cjs/account.d.ts.map +1 -0
  11. package/dist/cjs/account.js +76 -0
  12. package/dist/cjs/account.js.map +1 -0
  13. package/dist/cjs/chain-adapter.d.ts +14 -0
  14. package/dist/cjs/chain-adapter.d.ts.map +1 -0
  15. package/dist/cjs/chain-adapter.js +11 -0
  16. package/dist/cjs/chain-adapter.js.map +1 -0
  17. package/dist/cjs/index.d.ts +8 -0
  18. package/dist/cjs/index.d.ts.map +1 -0
  19. package/dist/cjs/index.js +11 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/internal-models.d.ts +36 -0
  22. package/dist/cjs/internal-models.d.ts.map +1 -0
  23. package/dist/cjs/internal-models.js +10 -0
  24. package/dist/cjs/internal-models.js.map +1 -0
  25. package/dist/cjs/package.json +3 -0
  26. package/dist/cjs/ts-type.test.d.ts +2 -0
  27. package/dist/cjs/ts-type.test.d.ts.map +1 -0
  28. package/dist/cjs/ts-type.test.js.map +1 -0
  29. package/dist/cjs/types.d.ts +43 -0
  30. package/dist/cjs/types.d.ts.map +1 -0
  31. package/dist/cjs/types.js +218 -0
  32. package/dist/cjs/types.js.map +1 -0
  33. package/dist/cjs/utils.d.ts +17 -0
  34. package/dist/cjs/utils.d.ts.map +1 -0
  35. package/dist/cjs/utils.js +82 -0
  36. package/dist/cjs/utils.js.map +1 -0
  37. package/dist/cjs/utils.test.d.ts +2 -0
  38. package/dist/cjs/utils.test.d.ts.map +1 -0
  39. package/dist/cjs/utils.test.js.map +1 -0
  40. package/dist/esm/abstract-codegen.d.ts +49 -0
  41. package/dist/esm/abstract-codegen.d.ts.map +1 -0
  42. package/dist/esm/abstract-codegen.js +399 -0
  43. package/dist/esm/abstract-codegen.js.map +1 -0
  44. package/dist/esm/abstract-move-coder.d.ts +26 -0
  45. package/dist/esm/abstract-move-coder.d.ts.map +1 -0
  46. package/dist/esm/abstract-move-coder.js +249 -0
  47. package/dist/esm/abstract-move-coder.js.map +1 -0
  48. package/dist/esm/account.d.ts +16 -0
  49. package/dist/esm/account.d.ts.map +1 -0
  50. package/dist/esm/account.js +71 -0
  51. package/dist/esm/account.js.map +1 -0
  52. package/dist/esm/chain-adapter.d.ts +14 -0
  53. package/dist/esm/chain-adapter.d.ts.map +1 -0
  54. package/dist/esm/chain-adapter.js +7 -0
  55. package/dist/esm/chain-adapter.js.map +1 -0
  56. package/dist/esm/index.d.ts +8 -0
  57. package/dist/esm/index.d.ts.map +1 -0
  58. package/dist/esm/index.js.map +1 -0
  59. package/dist/esm/internal-models.d.ts +36 -0
  60. package/dist/esm/internal-models.d.ts.map +1 -0
  61. package/dist/esm/internal-models.js +7 -0
  62. package/dist/esm/internal-models.js.map +1 -0
  63. package/dist/esm/ts-type.test.d.ts +2 -0
  64. package/dist/esm/ts-type.test.d.ts.map +1 -0
  65. package/dist/esm/ts-type.test.js.map +1 -0
  66. package/dist/esm/types.d.ts +43 -0
  67. package/dist/esm/types.d.ts.map +1 -0
  68. package/dist/esm/types.js +211 -0
  69. package/dist/esm/types.js.map +1 -0
  70. package/dist/esm/utils.d.ts +17 -0
  71. package/dist/esm/utils.d.ts.map +1 -0
  72. package/dist/esm/utils.js +69 -0
  73. package/dist/esm/utils.js.map +1 -0
  74. package/dist/esm/utils.test.d.ts +2 -0
  75. package/dist/esm/utils.test.d.ts.map +1 -0
  76. package/dist/esm/utils.test.js.map +1 -0
  77. package/package.json +12 -7
  78. package/src/abstract-codegen.ts +60 -224
  79. package/src/abstract-move-coder.ts +35 -144
  80. package/src/internal-models.ts +1 -0
  81. /package/dist/{index.js → esm/index.js} +0 -0
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractMoveCoder = void 0;
4
+ const utils_js_1 = require("./utils.js");
5
+ const types_js_1 = require("./types.js");
6
+ class AbstractMoveCoder {
7
+ moduleMapping = new Map();
8
+ typeMapping = new Map();
9
+ funcMapping = new Map();
10
+ // network: string
11
+ adapter;
12
+ constructor(adapter) {
13
+ this.adapter = adapter;
14
+ }
15
+ contains(account, name) {
16
+ return this.moduleMapping.has((0, utils_js_1.moduleQname)({ address: account, name }));
17
+ }
18
+ loadInternal(module) {
19
+ const account = (0, utils_js_1.accountAddressString)(module.address);
20
+ if (this.contains(account, module.name)) {
21
+ return;
22
+ }
23
+ this.moduleMapping.set((0, utils_js_1.moduleQname)({ address: account, name: module.name }), module);
24
+ for (const struct of module.structs) {
25
+ // TODO move to util
26
+ const key = [account, module.name, struct.name].join(utils_js_1.SPLITTER);
27
+ this.typeMapping.set(key, struct);
28
+ }
29
+ for (const func of module.exposedFunctions) {
30
+ // if (!func.isEntry) {
31
+ // continue
32
+ // }
33
+ const key = [account, module.name, func.name].join(utils_js_1.SPLITTER);
34
+ this.funcMapping.set(key, func);
35
+ }
36
+ }
37
+ decodeBigInt(data) {
38
+ if (Array.isArray(data)) {
39
+ throw new Error('data is in byte array');
40
+ // Only sui function need this, strange
41
+ // const bytes = data as number[]
42
+ // return bytesToBigInt(new Uint8Array(bytes.slice().reverse()))
43
+ }
44
+ return BigInt(data);
45
+ }
46
+ requestMap = new Map();
47
+ async getMoveStruct(type) {
48
+ const [account_, module, typeName] = type.split(utils_js_1.SPLITTER);
49
+ const account = (0, utils_js_1.accountAddressString)(account_);
50
+ type = [account, module, typeName].join(utils_js_1.SPLITTER);
51
+ let struct = this.typeMapping.get(type);
52
+ if (struct) {
53
+ return struct;
54
+ }
55
+ const key = account + utils_js_1.SPLITTER + module;
56
+ let resp = this.requestMap.get(account + utils_js_1.SPLITTER + module);
57
+ if (!resp) {
58
+ resp = this.adapter.fetchModule(account, module).then((m) => {
59
+ return this.load(m);
60
+ });
61
+ this.requestMap.set(key, resp);
62
+ }
63
+ await resp;
64
+ struct = this.typeMapping.get(type);
65
+ if (struct) {
66
+ return struct;
67
+ }
68
+ throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
69
+ }
70
+ async getMoveFunction(type) {
71
+ const [account_, module, typeName] = type.split(utils_js_1.SPLITTER);
72
+ const account = (0, utils_js_1.accountAddressString)(account_);
73
+ type = [account, module, typeName].join(utils_js_1.SPLITTER);
74
+ let func = this.funcMapping.get(type);
75
+ if (func) {
76
+ return func;
77
+ }
78
+ const key = account + utils_js_1.SPLITTER + module;
79
+ let resp = this.requestMap.get(account + utils_js_1.SPLITTER + module);
80
+ if (!resp) {
81
+ resp = this.adapter.fetchModule(account, module).then((m) => {
82
+ return this.load(m);
83
+ });
84
+ this.requestMap.set(key, resp);
85
+ }
86
+ await resp;
87
+ func = this.funcMapping.get(type);
88
+ if (func) {
89
+ return func;
90
+ }
91
+ throw new Error('Failed to load function ' + type + ' type are not imported anywhere');
92
+ }
93
+ async decode(data, type) {
94
+ // process simple type
95
+ if (type.reference) {
96
+ return data;
97
+ }
98
+ switch (type.qname) {
99
+ case 'signer': // TODO check this, aptos only
100
+ case 'address':
101
+ case 'Address':
102
+ case '0x1::string::String':
103
+ case 'bool':
104
+ case 'Bool':
105
+ case 'u8':
106
+ case 'U8':
107
+ case 'u16':
108
+ case 'U16':
109
+ case 'u32':
110
+ case 'U32':
111
+ return data;
112
+ case 'u64':
113
+ case 'U64':
114
+ case 'u128':
115
+ case 'U128':
116
+ case 'u256':
117
+ case 'U256':
118
+ return this.decodeBigInt(data);
119
+ }
120
+ // process vector
121
+ if (type.qname.toLowerCase() === utils_js_1.VECTOR_STR) {
122
+ // vector<u8> as hex string
123
+ if (type.typeArgs[0].qname === 'u8' || type.typeArgs[0].qname === 'U8') {
124
+ return data;
125
+ }
126
+ const res = [];
127
+ for (const entry of data) {
128
+ res.push(await this.decode(entry, type.typeArgs[0]));
129
+ }
130
+ return res;
131
+ }
132
+ // Process complex type
133
+ const struct = await this.getMoveStruct(type.qname);
134
+ const typeCtx = new Map();
135
+ for (const [idx, typeArg] of type.typeArgs.entries()) {
136
+ typeCtx.set('T' + idx, typeArg);
137
+ }
138
+ const typedData = {};
139
+ for (const field of struct.fields) {
140
+ let filedType = field.type;
141
+ filedType = filedType.applyTypeArgs(typeCtx);
142
+ const fieldValue = this.adapter.getData(data)[field.name];
143
+ const value = await this.decode(fieldValue, filedType);
144
+ typedData[field.name] = value;
145
+ }
146
+ return typedData;
147
+ }
148
+ async decodeArray(entries, types, strict = true) {
149
+ const entriesDecoded = [];
150
+ for (const [idx, arg] of entries.entries()) {
151
+ // TODO consider apply payload.type_arguments, but this might be hard since we don't code gen for them
152
+ const argType = types[idx];
153
+ try {
154
+ if (!strict && arg === undefined) {
155
+ entriesDecoded.push(arg);
156
+ }
157
+ else {
158
+ entriesDecoded.push(await this.decode(arg, argType));
159
+ }
160
+ }
161
+ catch (e) {
162
+ throw Error('Decoding error for ' + JSON.stringify(arg) + 'using type' + argType + e.toString());
163
+ }
164
+ }
165
+ return entriesDecoded;
166
+ }
167
+ encode(data) {
168
+ if (!data) {
169
+ return undefined;
170
+ }
171
+ if (typeof data === 'bigint') {
172
+ return data.toString();
173
+ }
174
+ if (Array.isArray(data)) {
175
+ return this.encodeArray(data);
176
+ }
177
+ for (const [key, value] of Object.entries(data)) {
178
+ if (!value) {
179
+ continue;
180
+ }
181
+ if (typeof value === 'bigint') {
182
+ data[key] = value.toString();
183
+ }
184
+ }
185
+ return data;
186
+ }
187
+ encodeArray(entriesDecoded) {
188
+ const entries = [];
189
+ for (const [idx, arg] of entriesDecoded.entries()) {
190
+ entries.push(this.encode(arg));
191
+ }
192
+ return entries;
193
+ }
194
+ async decodeCallResult(res, func) {
195
+ const f = await this.getMoveFunction(func);
196
+ return this.decodeArray(res, f.return);
197
+ }
198
+ async filterAndDecodeStruct(typeMatcher, structsWithTags) {
199
+ if (!structsWithTags) {
200
+ return [];
201
+ }
202
+ // const typeMatcherDescriptor = parseMoveType(typeMatcher)
203
+ const results = [];
204
+ for (const resource of structsWithTags) {
205
+ const resourceType = this.adapter.getType(resource);
206
+ const resourceTypeDescriptor = (0, types_js_1.parseMoveType)(resourceType);
207
+ if (!(0, types_js_1.matchType)(typeMatcher, resourceTypeDescriptor)) {
208
+ continue;
209
+ }
210
+ const result = await this.decodedStruct(resource);
211
+ if (result) {
212
+ results.push(result);
213
+ }
214
+ else {
215
+ console.error('decoding error');
216
+ }
217
+ }
218
+ return results;
219
+ }
220
+ async decodedStruct(typeStruct) {
221
+ const typeDescriptor = (0, types_js_1.parseMoveType)(this.adapter.getType(typeStruct));
222
+ const typeArguments = typeDescriptor.typeArgs.map((t) => t.getSignature());
223
+ let dataTyped = undefined;
224
+ try {
225
+ dataTyped = await this.decode(typeStruct, typeDescriptor);
226
+ }
227
+ catch (e) {
228
+ throw Error('Decoding error for struct' + JSON.stringify(typeStruct) + e.toString());
229
+ // return undefined
230
+ }
231
+ return {
232
+ ...typeStruct,
233
+ data_decoded: dataTyped,
234
+ type_arguments: typeArguments,
235
+ };
236
+ }
237
+ async decodedType(typeStruct, type) {
238
+ if (typeStruct === null || typeStruct == undefined) {
239
+ return typeStruct;
240
+ }
241
+ if (typeof typeStruct === 'object') {
242
+ if ('type' in typeStruct) {
243
+ const typeInStruct = (0, types_js_1.parseMoveType)(typeStruct.type.toString() || '');
244
+ if (!(0, types_js_1.matchType)(type, typeInStruct)) {
245
+ return undefined;
246
+ }
247
+ }
248
+ }
249
+ return await this.decode(typeStruct, type);
250
+ }
251
+ }
252
+ exports.AbstractMoveCoder = AbstractMoveCoder;
253
+ //# 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,yCAAoF;AACpF,yCAAoF;AAKpF,MAAsB,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,IAAA,sBAAW,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;IACxE,CAAC;IAIS,YAAY,CAAC,MAA0B;QAC/C,MAAM,OAAO,GAAG,IAAA,+BAAoB,EAAC,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,IAAA,sBAAW,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;QAEpF,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;YACnC,oBAAoB;YACpB,MAAM,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mBAAQ,CAAC,CAAA;YAC9D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,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 @@
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,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountRegister = exports.AccountModulesImportInfo = void 0;
4
+ const utils_js_1 = require("./utils.js");
5
+ class AccountModulesImportInfo {
6
+ // account to module
7
+ imports;
8
+ account;
9
+ moduleName;
10
+ constructor(account, tsModuleName) {
11
+ this.account = account;
12
+ this.moduleName = tsModuleName;
13
+ this.imports = new Map();
14
+ }
15
+ addImport(account, module) {
16
+ if (account === this.account) {
17
+ return;
18
+ }
19
+ let accountModules = this.imports.get(account);
20
+ if (!accountModules) {
21
+ accountModules = new Set();
22
+ this.imports.set(account, accountModules);
23
+ }
24
+ accountModules.add(module);
25
+ }
26
+ }
27
+ exports.AccountModulesImportInfo = AccountModulesImportInfo;
28
+ class AccountRegister {
29
+ accountImports = new Map();
30
+ pendingAccounts = new Set();
31
+ register(module, tsModuleName) {
32
+ const currentModuleFqn = (0, utils_js_1.moduleQname)(module);
33
+ let accountModuleImports = this.accountImports.get(module.address);
34
+ if (!accountModuleImports) {
35
+ accountModuleImports = new AccountModulesImportInfo(module.address, tsModuleName);
36
+ this.accountImports.set(module.address, accountModuleImports);
37
+ // the account has already be processed, delete pending task
38
+ this.pendingAccounts.delete(module.address);
39
+ }
40
+ this.registerStruct(module, accountModuleImports);
41
+ this.registerFunctions(module, accountModuleImports);
42
+ this.accountImports.set(currentModuleFqn, accountModuleImports);
43
+ return accountModuleImports;
44
+ }
45
+ registerFunctions(module, accountModuleImports) {
46
+ for (const func of module.exposedFunctions) {
47
+ if (!func.isEntry) {
48
+ continue;
49
+ }
50
+ for (const param of func.params) {
51
+ for (const type of param.dependedTypes()) {
52
+ const [account, module] = (0, utils_js_1.moduleQnameForType)(type);
53
+ accountModuleImports.addImport(account, module);
54
+ if (!this.accountImports.has(account)) {
55
+ this.pendingAccounts.add(account);
56
+ }
57
+ }
58
+ }
59
+ }
60
+ }
61
+ registerStruct(module, accountModuleImports) {
62
+ for (const struct of module.structs) {
63
+ for (const field of struct.fields) {
64
+ for (const type of field.type.dependedTypes()) {
65
+ const [account, module] = (0, utils_js_1.moduleQnameForType)(type);
66
+ accountModuleImports.addImport(account, module);
67
+ if (!this.accountImports.has(account)) {
68
+ this.pendingAccounts.add(account);
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ exports.AccountRegister = AccountRegister;
76
+ //# sourceMappingURL=account.js.map
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MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,IAAA,6BAAkB,EAAC,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;AAhED,0CAgEC"}
@@ -0,0 +1,14 @@
1
+ import { InternalMoveModule, InternalMoveStruct } from './internal-models.js';
2
+ import { TypeDescriptor } from './types.js';
3
+ export declare abstract class ChainAdapter<ModuleType, StructType> {
4
+ endpoint: string;
5
+ constructor(endpoint: string);
6
+ abstract fetchModule(account: string, module: string): Promise<ModuleType>;
7
+ abstract fetchModules(account: string): Promise<ModuleType[]>;
8
+ abstract toInternalModules(modules: ModuleType[]): InternalMoveModule[];
9
+ abstract getAllEventStructs(module: InternalMoveModule[]): Map<string, InternalMoveStruct>;
10
+ abstract getMeaningfulFunctionParams(params: TypeDescriptor[]): TypeDescriptor[];
11
+ abstract getType(base: StructType): string;
12
+ abstract getData<T>(base: StructType): any;
13
+ }
14
+ //# 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;IACvD,QAAQ,EAAE,MAAM,CAAA;gBAEJ,QAAQ,EAAE,MAAM;IAI5B,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,CACzB,MAAM,EAAE,kBAAkB,EAAE,GAC3B,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAIlC,QAAQ,CAAC,2BAA2B,CAClC,MAAM,EAAE,cAAc,EAAE,GACvB,cAAc,EAAE;IAEnB,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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChainAdapter = void 0;
4
+ class ChainAdapter {
5
+ endpoint;
6
+ constructor(endpoint) {
7
+ this.endpoint = endpoint;
8
+ }
9
+ }
10
+ exports.ChainAdapter = ChainAdapter;
11
+ //# sourceMappingURL=chain-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-adapter.js","sourceRoot":"","sources":["../../src/chain-adapter.ts"],"names":[],"mappings":";;;AAGA,MAAsB,YAAY;IAChC,QAAQ,CAAQ;IAEhB,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CAoBF;AAzBD,oCAyBC"}
@@ -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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./types.js"), exports);
5
+ tslib_1.__exportStar(require("./utils.js"), exports);
6
+ tslib_1.__exportStar(require("./account.js"), exports);
7
+ tslib_1.__exportStar(require("./chain-adapter.js"), exports);
8
+ tslib_1.__exportStar(require("./abstract-codegen.js"), exports);
9
+ tslib_1.__exportStar(require("./abstract-move-coder.js"), exports);
10
+ tslib_1.__exportStar(require("./internal-models.js"), exports);
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,qDAA0B;AAC1B,uDAA4B;AAC5B,6DAAkC;AAClC,gEAAqC;AACrC,mEAAwC;AACxC,+DAAoC"}
@@ -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,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalMoveFunctionVisibility = void 0;
4
+ var InternalMoveFunctionVisibility;
5
+ (function (InternalMoveFunctionVisibility) {
6
+ InternalMoveFunctionVisibility["PRIVATE"] = "private";
7
+ InternalMoveFunctionVisibility["PUBLIC"] = "public";
8
+ InternalMoveFunctionVisibility["FRIEND"] = "friend";
9
+ })(InternalMoveFunctionVisibility || (exports.InternalMoveFunctionVisibility = InternalMoveFunctionVisibility = {}));
10
+ //# sourceMappingURL=internal-models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-models.js","sourceRoot":"","sources":["../../src/internal-models.ts"],"names":[],"mappings":";;;AAgCA,IAAY,8BAIX;AAJD,WAAY,8BAA8B;IACxC,qDAAmB,CAAA;IACnB,mDAAiB,CAAA;IACjB,mDAAiB,CAAA;AACnB,CAAC,EAJW,8BAA8B,8CAA9B,8BAA8B,QAIzC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ts-type.test.d.ts.map
@@ -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,+BAA6B;AAC7B,yCAA0C;AAE1C,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,IAAI,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACtC,MAAM,GAAG,GAAG,IAAA,wBAAa,EAAC,8BAA8B,CAAC,CAAA;QAEzD,IAAA,aAAM,EAAC,GAAG,CAAC,KAAK,KAAK,GAAG,CAAC,CAAA;QACzB,IAAA,aAAM,EAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,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AAU,CAAC,CAAA;QAErC,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,EAAE,CAAA;QAChC,IAAA,aAAM,EAAC,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,43 @@
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
+ applyTypeArgs(ctx: Map<string, TypeDescriptor>): TypeDescriptor;
19
+ dependedTypes(): string[];
20
+ isVector(): boolean;
21
+ }
22
+ export declare function parseMoveType(type: string): TypeDescriptor;
23
+ export declare const ANY_TYPE: TypeDescriptor<any>;
24
+ export declare function vectorType<T>(t?: TypeDescriptor<T>): TypeDescriptor<T[]>;
25
+ export declare const BUILTIN_TYPES: {
26
+ ADDRESS_TYPE: TypeDescriptor<string>;
27
+ VECTOR_TYPE_ANY: TypeDescriptor<any[]>;
28
+ VECTOR_TYPE: typeof vectorType;
29
+ BOOL_TYPE: TypeDescriptor<number>;
30
+ U8_TYPE: TypeDescriptor<number>;
31
+ U16_TYPE: TypeDescriptor<number>;
32
+ U32_TYPE: TypeDescriptor<number>;
33
+ U64_TYPE: TypeDescriptor<number>;
34
+ U128_TYPE: TypeDescriptor<number>;
35
+ U256_TYPE: TypeDescriptor<number>;
36
+ };
37
+ /**
38
+ *
39
+ * @param matcher
40
+ * @param type
41
+ */
42
+ export declare function matchType(matcher: TypeDescriptor, type: TypeDescriptor): boolean;
43
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACpC;;OAEG;IACH,YAAY,EAAE,CAAC,CAAA;IACf,cAAc,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,qBAAa,cAAc,CAAC,CAAC,GAAG,GAAG;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,cAAc,EAAE,CAAA;gBAEd,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,cAAc,EAAE;IAOzD,KAAK,CAAC,GAAG,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc;IAMpD,KAAK,IAAI,IAAI;IAQb,YAAY,CAAC,CAAC,EAAE,cAAc,GAAG,OAAO;IAYxC,YAAY,IAAI,MAAM;IAatB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,cAAc;IAsB/D,aAAa,IAAI,MAAM,EAAE;IAoCzB,QAAQ,IAAI,OAAO;CAGpB;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAiD1D;AAkBD,eAAO,MAAM,QAAQ,qBAAiC,CAAA;AAEtD,wBAAgB,UAAU,CAAC,CAAC,EAC1B,CAAC,GAAE,cAAc,CAAC,CAAC,CAAY,GAC9B,cAAc,CAAC,CAAC,EAAE,CAAC,CAErB;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;CAqBzB,CAAA;AAWD;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,cAAc,GACnB,OAAO,CAcT"}