@typemove/sui 1.13.4-rc.1 → 1.13.4
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/esm/builtin/0x1.d.ts +269 -269
- package/dist/esm/builtin/0x1.d.ts.map +1 -1
- package/dist/esm/builtin/0x1.js.map +1 -1
- package/dist/esm/builtin/0x2.d.ts +684 -684
- package/dist/esm/builtin/0x2.d.ts.map +1 -1
- package/dist/esm/builtin/0x2.js.map +1 -1
- package/dist/esm/builtin/0x3.d.ts +272 -272
- package/dist/esm/builtin/0x3.d.ts.map +1 -1
- package/dist/esm/builtin/0x3.js.map +1 -1
- package/dist/esm/codegen/codegen.d.ts +1 -1
- package/dist/esm/codegen/codegen.d.ts.map +1 -1
- package/dist/esm/codegen/codegen.js +5 -5
- package/dist/esm/codegen/codegen.js.map +1 -1
- package/dist/esm/codegen/run.js +3 -2
- package/dist/esm/codegen/run.js.map +1 -1
- package/dist/esm/models.d.ts +1 -1
- package/dist/esm/models.d.ts.map +1 -1
- package/dist/esm/move-coder.d.ts +3 -3
- package/dist/esm/move-coder.d.ts.map +1 -1
- package/dist/esm/move-coder.js +3 -3
- package/dist/esm/move-coder.js.map +1 -1
- package/dist/esm/move-coder.test.js.map +1 -1
- package/dist/esm/sui-chain-adapter.d.ts +4 -3
- package/dist/esm/sui-chain-adapter.d.ts.map +1 -1
- package/dist/esm/sui-chain-adapter.js +13 -2
- package/dist/esm/sui-chain-adapter.js.map +1 -1
- package/dist/esm/to-internal.d.ts +1 -1
- package/dist/esm/to-internal.d.ts.map +1 -1
- package/package.json +11 -32
- package/src/builtin/0x1.ts +269 -269
- package/src/builtin/0x2.ts +684 -684
- package/src/builtin/0x3.ts +272 -272
- package/src/codegen/codegen.ts +5 -5
- package/src/codegen/run.ts +3 -2
- package/src/models.ts +1 -1
- package/src/move-coder.ts +7 -7
- package/src/sui-chain-adapter.ts +13 -5
- package/src/tests/types/testnet/0x1e2b124f746a339b3cf99b9f969393a96594519aafb1d06517aacfeeae20e7a5.ts +5 -5
- package/src/tests/types/testnet/0x6c4a21e3e7e6b6d51c4604021633e1d97e24e37a696f8c082cd48f37503e602a.ts +49 -49
- package/src/tests/types/testnet/0x7f7a37c826c88bcfe9aecc042453395ddfa9df6f29cb7c97590bf86cf2b0a75e.ts +32 -32
- package/src/tests/types/testnet/0xdee9.ts +91 -91
- package/src/tests/types/testnet/0xebaa2ad3eacc230f309cd933958cc52684df0a41ae7ac214d186b80f830867d2.ts +156 -156
- package/src/tests/types/testnet/enum.ts +119 -119
- package/src/to-internal.ts +1 -1
- package/builtin/0x1/package.json +0 -5
- package/builtin/0x2/package.json +0 -5
- package/builtin/0x3/package.json +0 -5
- package/builtin/package.json +0 -5
- package/codegen/package.json +0 -5
- package/dist/cjs/builtin/0x1.d.ts +0 -918
- package/dist/cjs/builtin/0x1.d.ts.map +0 -1
- package/dist/cjs/builtin/0x1.js +0 -6037
- package/dist/cjs/builtin/0x1.js.map +0 -1
- package/dist/cjs/builtin/0x2.d.ts +0 -4502
- package/dist/cjs/builtin/0x2.d.ts.map +0 -1
- package/dist/cjs/builtin/0x2.js +0 -18415
- package/dist/cjs/builtin/0x2.js.map +0 -1
- package/dist/cjs/builtin/0x3.d.ts +0 -1964
- package/dist/cjs/builtin/0x3.d.ts.map +0 -1
- package/dist/cjs/builtin/0x3.js +0 -6151
- package/dist/cjs/builtin/0x3.js.map +0 -1
- package/dist/cjs/builtin/index.d.ts +0 -4
- package/dist/cjs/builtin/index.d.ts.map +0 -1
- package/dist/cjs/builtin/index.js +0 -11
- package/dist/cjs/builtin/index.js.map +0 -1
- package/dist/cjs/codegen/codegen.d.ts +0 -20
- package/dist/cjs/codegen/codegen.d.ts.map +0 -1
- package/dist/cjs/codegen/codegen.js +0 -251
- package/dist/cjs/codegen/codegen.js.map +0 -1
- package/dist/cjs/codegen/index.d.ts +0 -2
- package/dist/cjs/codegen/index.d.ts.map +0 -1
- package/dist/cjs/codegen/index.js +0 -5
- package/dist/cjs/codegen/index.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -4
- 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/models.d.ts +0 -18
- package/dist/cjs/models.d.ts.map +0 -1
- package/dist/cjs/models.js +0 -5
- package/dist/cjs/models.js.map +0 -1
- package/dist/cjs/move-coder.d.ts +0 -26
- package/dist/cjs/move-coder.d.ts.map +0 -1
- package/dist/cjs/move-coder.js +0 -272
- package/dist/cjs/move-coder.js.map +0 -1
- package/dist/cjs/move-coder.test.d.ts +0 -2
- package/dist/cjs/move-coder.test.d.ts.map +0 -1
- package/dist/cjs/move-coder.test.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/sui-chain-adapter.d.ts +0 -15
- package/dist/cjs/sui-chain-adapter.d.ts.map +0 -1
- package/dist/cjs/sui-chain-adapter.js +0 -88
- package/dist/cjs/sui-chain-adapter.js.map +0 -1
- package/dist/cjs/to-internal.d.ts +0 -4
- package/dist/cjs/to-internal.d.ts.map +0 -1
- package/dist/cjs/to-internal.js +0 -99
- package/dist/cjs/to-internal.js.map +0 -1
- package/dist/cjs/transaction.d.ts +0 -15
- package/dist/cjs/transaction.d.ts.map +0 -1
- package/dist/cjs/transaction.js +0 -98
- package/dist/cjs/transaction.js.map +0 -1
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SuiCodegen = void 0;
|
|
4
|
-
exports.codegen = codegen;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const client_1 = require("@mysten/sui/client");
|
|
7
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
8
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
|
-
const move_1 = require("@typemove/move");
|
|
10
|
-
const codegen_1 = require("@typemove/move/codegen");
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const sui_chain_adapter_js_1 = require("../sui-chain-adapter.js");
|
|
13
|
-
async function codegen(abisDir, outDir = (0, path_1.join)('src', 'types', 'sui'), endpoint, genExample = false, builtin = false) {
|
|
14
|
-
if (!fs.existsSync(abisDir)) {
|
|
15
|
-
console.error(chalk_1.default.red(`ABIs directory ${abisDir} does not exist`));
|
|
16
|
-
return 0;
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const gen = new SuiCodegen(endpoint);
|
|
20
|
-
const numFiles = await gen.generate(abisDir, outDir, builtin);
|
|
21
|
-
if (numFiles > 0) {
|
|
22
|
-
console.log(chalk_1.default.green(`Generated for ${numFiles} accounts for Sui to ${outDir}`));
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
console.error(chalk_1.default.red(`No account found`));
|
|
26
|
-
}
|
|
27
|
-
return numFiles;
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
console.error(chalk_1.default.red(`Failed to generate for ${abisDir}, please check if ABI json files are valid`));
|
|
31
|
-
console.log(e);
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class SuiCodegen extends codegen_1.AbstractCodegen {
|
|
36
|
-
ADDRESS_TYPE = 'string';
|
|
37
|
-
SYSTEM_PACKAGE = '@typemove/sui';
|
|
38
|
-
// ADDRESS_TYPE = 'string'
|
|
39
|
-
// MAIN_NET = SuiNetwork.MAIN_NET
|
|
40
|
-
// TEST_NET = SuiNetwork.TEST_NET
|
|
41
|
-
PREFIX = 'Sui';
|
|
42
|
-
// STRUCT_FIELD_NAME = 'fields'
|
|
43
|
-
// GENERATE_ON_ENTRY = true
|
|
44
|
-
PAYLOAD_OPTIONAL = true;
|
|
45
|
-
constructor(endpoint) {
|
|
46
|
-
super(new sui_chain_adapter_js_1.SuiChainAdapter(new client_1.SuiClient({ url: endpoint })));
|
|
47
|
-
}
|
|
48
|
-
readModulesFile(fullPath) {
|
|
49
|
-
const res = super.readModulesFile(fullPath);
|
|
50
|
-
if (res.result) {
|
|
51
|
-
return res.result;
|
|
52
|
-
}
|
|
53
|
-
return res;
|
|
54
|
-
}
|
|
55
|
-
generateStructs(module, struct, events) {
|
|
56
|
-
let content = '';
|
|
57
|
-
switch ((0, move_1.structQname)(module, struct)) {
|
|
58
|
-
// TODO they should still have module code generated
|
|
59
|
-
case '0x1::ascii::Char':
|
|
60
|
-
case '0x1::ascii::String':
|
|
61
|
-
case '0x2::object::ID':
|
|
62
|
-
content += `export type ${struct.name} = string`;
|
|
63
|
-
break;
|
|
64
|
-
case '0x2::coin::Coin':
|
|
65
|
-
content += `export type ${struct.name}<T> = string`;
|
|
66
|
-
break;
|
|
67
|
-
case '0x2::balance::Balance':
|
|
68
|
-
content += `export type ${struct.name}<T> = bigint`;
|
|
69
|
-
break;
|
|
70
|
-
case '0x1::option::Option':
|
|
71
|
-
content += `export type Option<T> = T | undefined`;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
return content + super.generateStructs(module, struct, events, content !== '');
|
|
75
|
-
}
|
|
76
|
-
generateForEvents(module, struct) {
|
|
77
|
-
switch ((0, move_1.structQname)(module, struct)) {
|
|
78
|
-
case '0x1::ascii::Char':
|
|
79
|
-
case '0x1::ascii::String':
|
|
80
|
-
case '0x2::object::ID':
|
|
81
|
-
case '0x2::coin::Coin':
|
|
82
|
-
case '0x1::option::Option':
|
|
83
|
-
case '0x2::balance::Balance':
|
|
84
|
-
return '';
|
|
85
|
-
}
|
|
86
|
-
return super.generateForEvents(module, struct);
|
|
87
|
-
}
|
|
88
|
-
generateExtra(address, module) {
|
|
89
|
-
const funcs = module.exposedFunctions.map((f) => this.generateBuilderForFunction(address || module.address, module, f));
|
|
90
|
-
const viewFuncs = module.exposedFunctions.map((f) => this.generateViewFunction(module, f));
|
|
91
|
-
return `
|
|
92
|
-
export namespace builder {
|
|
93
|
-
${funcs.join('\n')}
|
|
94
|
-
}
|
|
95
|
-
export namespace view {
|
|
96
|
-
${viewFuncs.join('\n')}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
}
|
|
100
|
-
generateArgs(module, func, isView) {
|
|
101
|
-
const args = [];
|
|
102
|
-
const argsLen = func.params.length;
|
|
103
|
-
for (const [idx, arg] of func.params.entries()) {
|
|
104
|
-
if (idx === argsLen - 1 && arg.qname === '0x2::tx_context::TxContext') {
|
|
105
|
-
// no op
|
|
106
|
-
}
|
|
107
|
-
else if (arg.reference) {
|
|
108
|
-
args.push({
|
|
109
|
-
paramType: isView ? this.ADDRESS_TYPE : `${this.ADDRESS_TYPE} | TransactionObjectArgument`,
|
|
110
|
-
callValue: `_args.push(transactionArgumentOrObject(args[${idx}], tx))`
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else if (arg.isVector()) {
|
|
114
|
-
// TODO fix pure vector
|
|
115
|
-
args.push({
|
|
116
|
-
paramType: isView
|
|
117
|
-
? `${this.ADDRESS_TYPE}[]`
|
|
118
|
-
: `(${this.ADDRESS_TYPE} | TransactionObjectArgument)[] | TransactionArgument`,
|
|
119
|
-
callValue: `_args.push(transactionArgumentOrVec(args[${idx}], tx))`
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// Handle pure type
|
|
124
|
-
let pureFunction = '';
|
|
125
|
-
const paramType = isView
|
|
126
|
-
? this.generateTypeForDescriptor(arg, module.address)
|
|
127
|
-
: `${this.generateTypeForDescriptor(arg, module.address)} | TransactionArgument`;
|
|
128
|
-
switch (arg.qname.toLowerCase()) {
|
|
129
|
-
case 'u8':
|
|
130
|
-
pureFunction = `transactionArgumentOrPureU8`;
|
|
131
|
-
break;
|
|
132
|
-
case 'u16':
|
|
133
|
-
pureFunction = `transactionArgumentOrPureU16`;
|
|
134
|
-
break;
|
|
135
|
-
case 'u32':
|
|
136
|
-
pureFunction = `transactionArgumentOrPureU32`;
|
|
137
|
-
break;
|
|
138
|
-
case 'u64':
|
|
139
|
-
pureFunction = `transactionArgumentOrPureU64`;
|
|
140
|
-
break;
|
|
141
|
-
case 'u128':
|
|
142
|
-
pureFunction = `transactionArgumentOrPureU128`;
|
|
143
|
-
break;
|
|
144
|
-
case 'u256':
|
|
145
|
-
pureFunction = `transactionArgumentOrPureU256`;
|
|
146
|
-
break;
|
|
147
|
-
case 'bool':
|
|
148
|
-
pureFunction = `transactionArgumentOrPureBool`;
|
|
149
|
-
break;
|
|
150
|
-
case 'string':
|
|
151
|
-
pureFunction = `transactionArgumentOrPureString`;
|
|
152
|
-
break;
|
|
153
|
-
case 'address':
|
|
154
|
-
pureFunction = `transactionArgumentOrPureAddress`;
|
|
155
|
-
break;
|
|
156
|
-
// case 'vector':
|
|
157
|
-
// case 'option':
|
|
158
|
-
default:
|
|
159
|
-
pureFunction = `transactionArgumentOrPure`;
|
|
160
|
-
// paramType = 'TransactionArgument'
|
|
161
|
-
}
|
|
162
|
-
const callValue = pureFunction ? `_args.push(${pureFunction}(args[${idx}], tx))` : `_args.push(args[${idx}])`;
|
|
163
|
-
args.push({
|
|
164
|
-
paramType,
|
|
165
|
-
callValue
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return args;
|
|
170
|
-
}
|
|
171
|
-
generateViewFunction(module, func) {
|
|
172
|
-
if (func.visibility === move_1.InternalMoveFunctionVisibility.PRIVATE) {
|
|
173
|
-
return '';
|
|
174
|
-
}
|
|
175
|
-
const genericString = this.generateFunctionTypeParameters(func);
|
|
176
|
-
const typeParamArg = func.typeParams
|
|
177
|
-
.map((v, idx) => {
|
|
178
|
-
return `TypeDescriptor<T${idx}> | string`;
|
|
179
|
-
})
|
|
180
|
-
.join(',');
|
|
181
|
-
const args = this.generateArgs(module, func, true);
|
|
182
|
-
const returnType = `${this.generateFunctionReturnTypeParameters(func, module.address)}`;
|
|
183
|
-
return `export async function ${(0, move_1.camel)((0, move_1.normalizeToJSName)(func.name))}${genericString}(
|
|
184
|
-
client: SuiClient,
|
|
185
|
-
args: [${args.map((a) => a.paramType).join(',')}],
|
|
186
|
-
${typeParamArg.length > 0 ? `typeArguments: [${typeParamArg}]` : ``} ): Promise<TypedDevInspectResults<${returnType}>> {
|
|
187
|
-
const tx = new Transaction()
|
|
188
|
-
builder.${(0, move_1.camel)((0, move_1.normalizeToJSName)(func.name))}(tx, args ${typeParamArg.length > 0 ? `, typeArguments` : ''})
|
|
189
|
-
const inspectRes = await client.devInspectTransactionBlock({
|
|
190
|
-
transactionBlock: tx,
|
|
191
|
-
sender: ZERO_ADDRESS
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
return (await getMoveCoder(client)).decodeDevInspectResult<${returnType}>(inspectRes)
|
|
195
|
-
}`;
|
|
196
|
-
}
|
|
197
|
-
generateBuilderForFunction(address, module, func) {
|
|
198
|
-
if (func.visibility === move_1.InternalMoveFunctionVisibility.PRIVATE && func.isEntry !== true) {
|
|
199
|
-
return '';
|
|
200
|
-
}
|
|
201
|
-
const args = this.generateArgs(module, func, false);
|
|
202
|
-
const genericString = this.generateFunctionTypeParameters(func);
|
|
203
|
-
const typeParamArg = func.typeParams
|
|
204
|
-
.map((v, idx) => {
|
|
205
|
-
return `TypeDescriptor<T${idx}> | string`;
|
|
206
|
-
})
|
|
207
|
-
.join(',');
|
|
208
|
-
const typeParamToString = func.typeParams
|
|
209
|
-
.map((v, idx) => {
|
|
210
|
-
return `typeof typeArguments[${idx}] === 'string' ? typeArguments[${idx}] : typeArguments[${idx}].getSignature()`;
|
|
211
|
-
})
|
|
212
|
-
.join(',');
|
|
213
|
-
return `export function ${(0, move_1.camel)((0, move_1.normalizeToJSName)(func.name))}${genericString}(tx: Transaction,
|
|
214
|
-
args: [${args.map((a) => a.paramType).join(',')}],
|
|
215
|
-
${typeParamArg.length > 0 ? `typeArguments: [${typeParamArg}]` : ``} ):
|
|
216
|
-
TransactionArgument & [ ${'TransactionArgument,'.repeat(args.length)} ] {
|
|
217
|
-
const _args: any[] = []
|
|
218
|
-
${args.map((a) => a.callValue).join('\n')}
|
|
219
|
-
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
return tx.moveCall({
|
|
222
|
-
target: "${address}::${module.name}::${func.name}",
|
|
223
|
-
arguments: _args,
|
|
224
|
-
${typeParamArg.length > 0 ? `typeArguments: [${typeParamToString}]` : ``}
|
|
225
|
-
})
|
|
226
|
-
}`;
|
|
227
|
-
}
|
|
228
|
-
generateImports() {
|
|
229
|
-
return `
|
|
230
|
-
${super.generateImports()}
|
|
231
|
-
import { ZERO_ADDRESS, TypedDevInspectResults, getMoveCoder } from '@typemove/sui'
|
|
232
|
-
import { Transaction, TransactionArgument, TransactionObjectArgument } from '@mysten/sui/transactions'
|
|
233
|
-
import { SuiClient } from '@mysten/sui/client'
|
|
234
|
-
import { transactionArgumentOrObject,
|
|
235
|
-
transactionArgumentOrVec,
|
|
236
|
-
transactionArgumentOrPure,
|
|
237
|
-
transactionArgumentOrPureU8,
|
|
238
|
-
transactionArgumentOrPureU16,
|
|
239
|
-
transactionArgumentOrPureU32,
|
|
240
|
-
transactionArgumentOrPureU64,
|
|
241
|
-
transactionArgumentOrPureU128,
|
|
242
|
-
transactionArgumentOrPureU256,
|
|
243
|
-
transactionArgumentOrPureBool,
|
|
244
|
-
transactionArgumentOrPureString,
|
|
245
|
-
transactionArgumentOrPureAddress,
|
|
246
|
-
} from '@typemove/sui'
|
|
247
|
-
`;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
exports.SuiCodegen = SuiCodegen;
|
|
251
|
-
//# sourceMappingURL=codegen.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../../src/codegen/codegen.ts"],"names":[],"mappings":";;;AAiBA,0BAyBC;;AA1CD,+CAAgG;AAEhG,+CAAwB;AACxB,0DAAyB;AACzB,yCAQuB;AACvB,oDAAwD;AACxD,+BAA2B;AAC3B,kEAAyD;AAElD,KAAK,UAAU,OAAO,CAC3B,OAAe,EACf,MAAM,GAAG,IAAA,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,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC7C,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE;iCACxC,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;;QAEnE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;mBAI5B,OAAO,KAAK,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;;UAE9C,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,mBAAmB,iBAAiB,GAAG,CAAC,CAAC,CAAC,EAAE;;MAE1E,CAAA;IACJ,CAAC;IAED,eAAe;QACb,OAAO;QACH,KAAK,CAAC,eAAe,EAAE;;;;;;;;;;;;;;;;;KAiB1B,CAAA;IACH,CAAC;CACF;AAnPD,gCAmPC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B"}
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMoveCoder = exports.defaultMoveCoder = exports.MoveCoder = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./models.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./transaction.js"), exports);
|
|
7
|
-
var move_coder_js_1 = require("./move-coder.js");
|
|
8
|
-
Object.defineProperty(exports, "MoveCoder", { enumerable: true, get: function () { return move_coder_js_1.MoveCoder; } });
|
|
9
|
-
Object.defineProperty(exports, "defaultMoveCoder", { enumerable: true, get: function () { return move_coder_js_1.defaultMoveCoder; } });
|
|
10
|
-
Object.defineProperty(exports, "getMoveCoder", { enumerable: true, get: function () { return move_coder_js_1.getMoveCoder; } });
|
|
11
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,sDAA2B;AAC3B,2DAAgC;AAEhC,iDAA2E;AAAlE,0GAAA,SAAS,OAAA;AAAE,iHAAA,gBAAgB,OAAA;AAAE,6GAAA,YAAY,OAAA"}
|
package/dist/cjs/models.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { SuiEvent, MoveCallSuiTransaction, SuiMoveObject, DevInspectResults } from '@mysten/sui/client';
|
|
2
|
-
import { DecodedStruct } from '@typemove/move';
|
|
3
|
-
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
4
|
-
export type TypedEventInstance<T> = DecodedStruct<SuiEvent, T>;
|
|
5
|
-
export type TypedSuiMoveObject<T> = DecodedStruct<SuiMoveObject, T>;
|
|
6
|
-
export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction & {
|
|
7
|
-
/**
|
|
8
|
-
* decoded argument data using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
|
|
9
|
-
*/
|
|
10
|
-
arguments_decoded: T;
|
|
11
|
-
};
|
|
12
|
-
export type TypedDevInspectResults<T extends Array<any>> = DevInspectResults & {
|
|
13
|
-
/**
|
|
14
|
-
* Decoded return values using ABI, undefined if there is decoding error, usually because the ABI/data mismatch
|
|
15
|
-
*/
|
|
16
|
-
results_decoded?: T;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=models.d.ts.map
|
package/dist/cjs/models.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC5G,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,eAAO,MAAM,YAAY,uEAAuE,CAAA;AAEhG,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC9D,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AAEnE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,sBAAsB,GAAG;IAChF;;OAEG;IACH,iBAAiB,EAAE,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,iBAAiB,GAAG;IAC7E;;OAEG;IACH,eAAe,CAAC,EAAE,CAAC,CAAA;CACpB,CAAA"}
|
package/dist/cjs/models.js
DELETED
package/dist/cjs/models.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":";;;AAGa,QAAA,YAAY,GAAG,oEAAoE,CAAA"}
|
package/dist/cjs/move-coder.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TypedDevInspectResults, TypedEventInstance } from './models.js';
|
|
2
|
-
import { AbstractMoveCoder, DecodedStruct, TypeDescriptor, InternalMoveModule } from '@typemove/move';
|
|
3
|
-
import { MoveCallSuiTransaction, SuiCallArg, SuiEvent, SuiMoveNormalizedModule, SuiMoveObject, DevInspectResults, SuiClient } from '@mysten/sui/client';
|
|
4
|
-
import { dynamic_field } from './builtin/0x2.js';
|
|
5
|
-
import { BcsType } from '@mysten/sui/bcs';
|
|
6
|
-
export type Encoding = 'base58' | 'base64' | 'hex';
|
|
7
|
-
export declare class MoveCoder extends AbstractMoveCoder<SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {
|
|
8
|
-
constructor(client: SuiClient);
|
|
9
|
-
load(module: SuiMoveNormalizedModule, address: string): InternalMoveModule;
|
|
10
|
-
protected decode(data: any, type: TypeDescriptor): Promise<any>;
|
|
11
|
-
decodeEvent<T>(event: SuiEvent): Promise<TypedEventInstance<T> | undefined>;
|
|
12
|
-
filterAndDecodeEvents<T>(type: TypeDescriptor<T> | string, resources: SuiEvent[]): Promise<TypedEventInstance<T>[]>;
|
|
13
|
-
getDynamicFields<T1, T2>(objects: SuiMoveObject[], keyType?: TypeDescriptor<T1>, valueType?: TypeDescriptor<T2>): Promise<dynamic_field.Field<T1, T2>[]>;
|
|
14
|
-
filterAndDecodeObjects<T>(type: TypeDescriptor<T>, objects: SuiMoveObject[]): Promise<DecodedStruct<SuiMoveObject, T>[]>;
|
|
15
|
-
decodeFunctionPayload(payload: MoveCallSuiTransaction, inputs: SuiCallArg[]): Promise<MoveCallSuiTransaction>;
|
|
16
|
-
private bcsRegistered;
|
|
17
|
-
private bcsRegistry;
|
|
18
|
-
private getBCSTypeWithArgs;
|
|
19
|
-
getBCSType(type: TypeDescriptor): Promise<BcsType<any>>;
|
|
20
|
-
registerBCSTypes(type: TypeDescriptor): Promise<void>;
|
|
21
|
-
decodeBCS(type: TypeDescriptor, data: Uint8Array | string, encoding?: Encoding): Promise<any>;
|
|
22
|
-
decodeDevInspectResult<T extends any[]>(inspectRes: DevInspectResults): Promise<TypedDevInspectResults<T>>;
|
|
23
|
-
}
|
|
24
|
-
export declare function defaultMoveCoder(endpoint?: string): MoveCoder;
|
|
25
|
-
export declare function getMoveCoder(client: SuiClient): Promise<MoveCoder>;
|
|
26
|
-
//# sourceMappingURL=move-coder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"move-coder.d.ts","sourceRoot":"","sources":["../../src/move-coder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAwB,MAAM,aAAa,CAAA;AAC9F,OAAO,EACL,iBAAiB,EAEjB,aAAa,EAIb,cAAc,EACd,kBAAkB,EACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,QAAQ,EACR,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,SAAS,EACV,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAO,MAAM,iBAAiB,CAAA;AAG9C,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAA;AAIlD,qBAAa,SAAU,SAAQ,iBAAiB,CAE9C,uBAAuB,EACvB,QAAQ,GAAG,aAAa,CACzB;gBACa,MAAM,EAAE,SAAS;IAI7B,IAAI,CAAC,MAAM,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB;cAa1D,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC;IAkErE,WAAW,CAAC,C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AsB,CAAC,CAAC,CAAC,CAAC;CAkBjH;AAMD,wBAAgB,gBAAgB,CAAC,QAAQ,GAAE,MAAyB,GAAG,SAAS,CAO/E;AAMD,wBAAsB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAiBxE"}
|
package/dist/cjs/move-coder.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MoveCoder = void 0;
|
|
4
|
-
exports.defaultMoveCoder = defaultMoveCoder;
|
|
5
|
-
exports.getMoveCoder = getMoveCoder;
|
|
6
|
-
const move_1 = require("@typemove/move");
|
|
7
|
-
const client_1 = require("@mysten/sui/client");
|
|
8
|
-
const to_internal_js_1 = require("./to-internal.js");
|
|
9
|
-
const sui_chain_adapter_js_1 = require("./sui-chain-adapter.js");
|
|
10
|
-
const bcs_1 = require("@mysten/sui/bcs");
|
|
11
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
12
|
-
class MoveCoder extends move_1.AbstractMoveCoder {
|
|
13
|
-
constructor(client) {
|
|
14
|
-
super(new sui_chain_adapter_js_1.SuiChainAdapter(client));
|
|
15
|
-
}
|
|
16
|
-
load(module, address) {
|
|
17
|
-
address = (0, move_1.accountTypeString)(address);
|
|
18
|
-
let m = this.moduleMapping.get(module.address + '::' + module.name);
|
|
19
|
-
const mDeclared = this.moduleMapping.get(address + '::' + module.name);
|
|
20
|
-
if (m && mDeclared) {
|
|
21
|
-
return m;
|
|
22
|
-
}
|
|
23
|
-
this.accounts.add(module.address);
|
|
24
|
-
m = (0, to_internal_js_1.toInternalModule)(module);
|
|
25
|
-
this.loadInternal(m, address);
|
|
26
|
-
return m;
|
|
27
|
-
}
|
|
28
|
-
async decode(data, type) {
|
|
29
|
-
switch (type.qname) {
|
|
30
|
-
case '0x1::ascii::Char':
|
|
31
|
-
if (data !== undefined && typeof data !== 'string') {
|
|
32
|
-
// bcs
|
|
33
|
-
const byte = (await super.decode(data, type)).byte;
|
|
34
|
-
return String.fromCharCode(byte);
|
|
35
|
-
}
|
|
36
|
-
case '0x1::ascii::String':
|
|
37
|
-
if (data !== undefined && typeof data !== 'string') {
|
|
38
|
-
// bcs verified
|
|
39
|
-
const bytes = (await super.decode(data, type)).bytes;
|
|
40
|
-
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
41
|
-
}
|
|
42
|
-
case '0x2::object::ID':
|
|
43
|
-
if (data !== undefined && typeof data !== 'string') {
|
|
44
|
-
// bcs verified
|
|
45
|
-
const bytes = (await super.decode(data, type)).bytes;
|
|
46
|
-
return (0, utils_1.normalizeSuiObjectId)(bytes);
|
|
47
|
-
}
|
|
48
|
-
case '0x2::url::Url':
|
|
49
|
-
if (data !== undefined && typeof data !== 'string') {
|
|
50
|
-
// bcs
|
|
51
|
-
return (await super.decode(data, type)).url;
|
|
52
|
-
}
|
|
53
|
-
case '0x2::coin::Coin':
|
|
54
|
-
if (data !== undefined && typeof data !== 'string') {
|
|
55
|
-
// bcs
|
|
56
|
-
const bytes = (await super.decode(data, type)).id.id.bytes;
|
|
57
|
-
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
case '0x2::balance::Balance':
|
|
61
|
-
if (data.value) {
|
|
62
|
-
// bcs verfied
|
|
63
|
-
const balance = await super.decode(data, type);
|
|
64
|
-
return balance.value;
|
|
65
|
-
}
|
|
66
|
-
return BigInt(data);
|
|
67
|
-
case '0x1::option::Option':
|
|
68
|
-
if (data === null) {
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
|
-
if (data.vec) {
|
|
72
|
-
// bcs verifed
|
|
73
|
-
let vec = await super.decode(data, type);
|
|
74
|
-
vec = vec.vec;
|
|
75
|
-
if (vec.length === 0) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
return vec[0];
|
|
79
|
-
}
|
|
80
|
-
return this.decode(data, type.typeArgs[0]);
|
|
81
|
-
case 'Address':
|
|
82
|
-
const str = data;
|
|
83
|
-
return (0, utils_1.normalizeSuiAddress)(str);
|
|
84
|
-
case '0x1::string::String':
|
|
85
|
-
if (typeof data !== 'string') {
|
|
86
|
-
// bcs
|
|
87
|
-
return new TextDecoder().decode(new Uint8Array(data.bytes));
|
|
88
|
-
}
|
|
89
|
-
default:
|
|
90
|
-
return super.decode(data, type);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
decodeEvent(event) {
|
|
94
|
-
return this.decodedStruct(event);
|
|
95
|
-
}
|
|
96
|
-
filterAndDecodeEvents(type, resources) {
|
|
97
|
-
if (typeof type === 'string') {
|
|
98
|
-
type = (0, move_1.parseMoveType)(type);
|
|
99
|
-
}
|
|
100
|
-
return this.filterAndDecodeStruct(type, resources);
|
|
101
|
-
}
|
|
102
|
-
async getDynamicFields(objects, keyType = move_1.ANY_TYPE, valueType = move_1.ANY_TYPE) {
|
|
103
|
-
// const type = dynamic_field.Field.TYPE
|
|
104
|
-
// Not using the code above to avoid cycle initialize failed
|
|
105
|
-
const type = new move_1.TypeDescriptor('0x2::dynamic_field::Field');
|
|
106
|
-
type.typeArgs = [keyType, valueType];
|
|
107
|
-
const res = await this.filterAndDecodeObjects(type, objects);
|
|
108
|
-
return res.map((o) => o.data_decoded);
|
|
109
|
-
}
|
|
110
|
-
filterAndDecodeObjects(type, objects) {
|
|
111
|
-
return this.filterAndDecodeStruct(type, objects);
|
|
112
|
-
}
|
|
113
|
-
async decodeFunctionPayload(payload, inputs) {
|
|
114
|
-
const functionType = [payload.package, payload.module, payload.function].join(move_1.SPLITTER);
|
|
115
|
-
const func = await this.getMoveFunction(functionType);
|
|
116
|
-
const params = this.adapter.getMeaningfulFunctionParams(func.params);
|
|
117
|
-
const args = [];
|
|
118
|
-
for (const value of payload.arguments || []) {
|
|
119
|
-
const argValue = value;
|
|
120
|
-
if ('Input' in argValue) {
|
|
121
|
-
const idx = argValue.Input;
|
|
122
|
-
const arg = inputs[idx];
|
|
123
|
-
if (arg.type === 'pure') {
|
|
124
|
-
args.push(arg.value);
|
|
125
|
-
}
|
|
126
|
-
else if (arg.type === 'object') {
|
|
127
|
-
// object is not there
|
|
128
|
-
args.push(undefined);
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
console.error('unexpected function arg value');
|
|
132
|
-
args.push(undefined);
|
|
133
|
-
}
|
|
134
|
-
// args.push(arg) // TODO check why ts not work using arg.push(arg)
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
args.push(undefined);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const argumentsTyped = await this.decodeArray(args, params, false);
|
|
141
|
-
return {
|
|
142
|
-
...payload,
|
|
143
|
-
arguments_decoded: argumentsTyped
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
bcsRegistered = new Set();
|
|
147
|
-
bcsRegistry = new Map();
|
|
148
|
-
async getBCSTypeWithArgs(type, args = []) {
|
|
149
|
-
const qname = type.qname;
|
|
150
|
-
const sig = type.getNormalizedSignature();
|
|
151
|
-
const cached = this.bcsRegistry.get(sig);
|
|
152
|
-
if (cached) {
|
|
153
|
-
return cached;
|
|
154
|
-
}
|
|
155
|
-
const lowerQname = qname.toLowerCase();
|
|
156
|
-
switch (lowerQname) {
|
|
157
|
-
case 'u8':
|
|
158
|
-
case 'u16':
|
|
159
|
-
case 'u32':
|
|
160
|
-
case 'u64':
|
|
161
|
-
case 'u128':
|
|
162
|
-
case 'u256':
|
|
163
|
-
case 'bool':
|
|
164
|
-
return bcs_1.bcs[lowerQname]();
|
|
165
|
-
case 'address':
|
|
166
|
-
return bcs_1.bcs.Address;
|
|
167
|
-
case 'vector':
|
|
168
|
-
return bcs_1.bcs.vector(args[0]);
|
|
169
|
-
default:
|
|
170
|
-
if (!qname.includes('::')) {
|
|
171
|
-
throw `Unimplemented builtin type ${qname}`;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
let moveStruct;
|
|
175
|
-
try {
|
|
176
|
-
moveStruct = await this.getMoveStruct(qname);
|
|
177
|
-
}
|
|
178
|
-
catch (e) {
|
|
179
|
-
console.error('Invalid move address', qname);
|
|
180
|
-
throw e;
|
|
181
|
-
}
|
|
182
|
-
const structDef = {};
|
|
183
|
-
for (const field of moveStruct.fields) {
|
|
184
|
-
if (field.type.qname.startsWith('T') && args.length) {
|
|
185
|
-
const index = +field.type.qname.slice(1);
|
|
186
|
-
structDef[field.name] = args[index];
|
|
187
|
-
}
|
|
188
|
-
else if (field.type.typeArgs.length && args.length) {
|
|
189
|
-
structDef[field.name] = await this.getBCSTypeWithArgs(field.type, args);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
structDef[field.name] = await this.getBCSType(field.type);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return bcs_1.bcs.struct(qname, structDef);
|
|
196
|
-
}
|
|
197
|
-
async getBCSType(type) {
|
|
198
|
-
const args = await Promise.all(type.typeArgs.map((x) => this.getBCSType(x)));
|
|
199
|
-
const bcsType = await this.getBCSTypeWithArgs(type, args);
|
|
200
|
-
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
201
|
-
return bcsType;
|
|
202
|
-
}
|
|
203
|
-
async registerBCSTypes(type) {
|
|
204
|
-
const sig = type.getNormalizedSignature();
|
|
205
|
-
if (this.bcsRegistered.has(sig)) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
this.bcsRegistered.add(sig);
|
|
209
|
-
const bcsType = await this.getBCSType(type);
|
|
210
|
-
this.bcsRegistry.set(type.getNormalizedSignature(), bcsType);
|
|
211
|
-
}
|
|
212
|
-
async decodeBCS(type, data, encoding) {
|
|
213
|
-
await this.registerBCSTypes(type);
|
|
214
|
-
if (typeof data == 'string') {
|
|
215
|
-
const buf = Buffer.from(data, encoding);
|
|
216
|
-
data = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
217
|
-
}
|
|
218
|
-
const bcsType = this.bcsRegistry.get(type.getNormalizedSignature());
|
|
219
|
-
return bcsType?.parse(data);
|
|
220
|
-
}
|
|
221
|
-
async decodeDevInspectResult(inspectRes) {
|
|
222
|
-
const returnValues = [];
|
|
223
|
-
if (inspectRes.results != null) {
|
|
224
|
-
for (const r of inspectRes.results) {
|
|
225
|
-
if (r.returnValues) {
|
|
226
|
-
for (const returnValue of r.returnValues) {
|
|
227
|
-
const type = (0, move_1.parseMoveType)(returnValue[1]);
|
|
228
|
-
const bcsDecoded = await this.decodeBCS(type, new Uint8Array(returnValue[0]));
|
|
229
|
-
const decoded = await this.decodeType(bcsDecoded, type);
|
|
230
|
-
returnValues.push(decoded);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
returnValues.push(null);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return { ...inspectRes, results_decoded: returnValues };
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
exports.MoveCoder = MoveCoder;
|
|
242
|
-
const DEFAULT_ENDPOINT = 'https://fullnode.mainnet.sui.io/';
|
|
243
|
-
const CODER_MAP = new Map();
|
|
244
|
-
const CHAIN_ID_CODER_MAP = new Map();
|
|
245
|
-
function defaultMoveCoder(endpoint = DEFAULT_ENDPOINT) {
|
|
246
|
-
let coder = CODER_MAP.get(endpoint);
|
|
247
|
-
if (!coder) {
|
|
248
|
-
coder = new MoveCoder(new client_1.SuiClient({ url: endpoint }));
|
|
249
|
-
CODER_MAP.set(endpoint, coder);
|
|
250
|
-
}
|
|
251
|
-
return coder;
|
|
252
|
-
}
|
|
253
|
-
const PROVIDER_CODER_MAP = new Map();
|
|
254
|
-
let DEFAULT_CHAIN_ID;
|
|
255
|
-
async function getMoveCoder(client) {
|
|
256
|
-
let coder = PROVIDER_CODER_MAP.get(client);
|
|
257
|
-
if (!coder) {
|
|
258
|
-
coder = new MoveCoder(client);
|
|
259
|
-
// TODO how to dedup
|
|
260
|
-
const id = await client.getChainIdentifier();
|
|
261
|
-
const defaultCoder = defaultMoveCoder();
|
|
262
|
-
if (!DEFAULT_CHAIN_ID) {
|
|
263
|
-
DEFAULT_CHAIN_ID = await defaultCoder.adapter.getChainId();
|
|
264
|
-
}
|
|
265
|
-
if (id === DEFAULT_CHAIN_ID) {
|
|
266
|
-
coder = defaultCoder;
|
|
267
|
-
}
|
|
268
|
-
PROVIDER_CODER_MAP.set(client, coder);
|
|
269
|
-
}
|
|
270
|
-
return coder;
|
|
271
|
-
}
|
|
272
|
-
//# sourceMappingURL=move-coder.js.map
|