@layerzerolabs/ton-sdk-tools 3.0.18-ton.2 → 3.0.19-ton.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/CHANGELOG.md +4 -46
- package/dist/index.cjs +116 -374
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +11 -28
- package/dist/index.d.ts +11 -28
- package/dist/index.mjs +112 -370
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -8
package/dist/index.cjs
CHANGED
|
@@ -39,20 +39,6 @@ function getOpcodeCRC(input) {
|
|
|
39
39
|
var MASTER_CHAIN_ID = -1;
|
|
40
40
|
var BASE_CHAIN_ID = 0;
|
|
41
41
|
var MASTER_CHAIN_SHARD = "8000000000000000";
|
|
42
|
-
function randomQueryId() {
|
|
43
|
-
return Math.floor(Math.random() * 1e11);
|
|
44
|
-
}
|
|
45
|
-
function beginMessage(opcode, queryId) {
|
|
46
|
-
return core.beginCell().storeUint(opcode, 32).storeUint(queryId ?? randomQueryId(), 64);
|
|
47
|
-
}
|
|
48
|
-
async function sendRequest(provider, via, request) {
|
|
49
|
-
return provider.internal(via, {
|
|
50
|
-
value: request.value,
|
|
51
|
-
sendMode: request.sendMode ?? void 0,
|
|
52
|
-
body: request.body,
|
|
53
|
-
bounce: request.bounce
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
42
|
function bigintToAddress(value) {
|
|
57
43
|
const buf = to32ByteBuffer(value);
|
|
58
44
|
return core.Address.parse(`0:${buf.toString("hex")}`);
|
|
@@ -100,7 +86,7 @@ function findDeepestCell(cell) {
|
|
|
100
86
|
// src/sdk-tools.ts
|
|
101
87
|
var file_signature_header = `////// Generated by sdk/sdk-generator.ts`;
|
|
102
88
|
var ERRORCODE_MASK = 0x7ffn;
|
|
103
|
-
function tonTypeToTStype(tonType
|
|
89
|
+
function tonTypeToTStype(tonType) {
|
|
104
90
|
switch (tonType) {
|
|
105
91
|
case "int":
|
|
106
92
|
case "uint8":
|
|
@@ -112,19 +98,15 @@ function tonTypeToTStype(tonType, addr_type = "Slice", force_cell = false) {
|
|
|
112
98
|
case "bool":
|
|
113
99
|
case "address":
|
|
114
100
|
return "bigint";
|
|
115
|
-
case "slice":
|
|
116
|
-
return addr_type;
|
|
117
101
|
case "cell":
|
|
118
102
|
case "cellRef":
|
|
119
103
|
return "Cell";
|
|
120
104
|
case "tuple":
|
|
121
105
|
return "Tuple";
|
|
122
106
|
case "objRef":
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return "Tuple";
|
|
127
|
-
}
|
|
107
|
+
return "Cell";
|
|
108
|
+
case "slice":
|
|
109
|
+
return "Address";
|
|
128
110
|
case "dict256":
|
|
129
111
|
case "dictionary":
|
|
130
112
|
return "LzDict";
|
|
@@ -256,8 +238,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
256
238
|
{
|
|
257
239
|
constructorInputArgs: inputArgs,
|
|
258
240
|
attributes,
|
|
259
|
-
constructorIncomplete: incomplete,
|
|
260
|
-
dependencies,
|
|
261
241
|
constructorName: functionName,
|
|
262
242
|
tonName,
|
|
263
243
|
fieldMap,
|
|
@@ -267,8 +247,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
267
247
|
result[name] = {
|
|
268
248
|
constructorInputArgs: inputArgs,
|
|
269
249
|
attributes,
|
|
270
|
-
constructorIncomplete: incomplete,
|
|
271
|
-
dependencies,
|
|
272
250
|
constructorName: functionName,
|
|
273
251
|
tonName,
|
|
274
252
|
fieldMap,
|
|
@@ -278,12 +256,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
278
256
|
);
|
|
279
257
|
return result;
|
|
280
258
|
}
|
|
281
|
-
function mergeInputArgs(result, added) {
|
|
282
|
-
Object.entries(added).forEach(([name, type]) => {
|
|
283
|
-
result[name] = type;
|
|
284
|
-
});
|
|
285
|
-
return result;
|
|
286
|
-
}
|
|
287
259
|
function parseDirectory(directoryPath) {
|
|
288
260
|
let result = {};
|
|
289
261
|
const items = fs__namespace.readdirSync(directoryPath);
|
|
@@ -303,58 +275,28 @@ function parseDirectory(directoryPath) {
|
|
|
303
275
|
function snakeToCamelCase(str2) {
|
|
304
276
|
return str2.replace(/::/g, "_").replace(/(_\w)/g, (match) => match[1].toUpperCase());
|
|
305
277
|
}
|
|
306
|
-
function
|
|
278
|
+
function parseDeclareLines(input, fieldMap) {
|
|
307
279
|
const psResult = [];
|
|
308
|
-
|
|
309
|
-
const setRegex = /\[\s*([a-zA-Z_][\w:]*),\s*((?:[^,\]]|\([^)]*\))*)\]/g;
|
|
310
|
-
const dependencies = [];
|
|
280
|
+
const declareLineRegex = /\[\s*([a-zA-Z_][\w:]*),\s*((?:[^,\]]|\([^)]*\))*)\]/g;
|
|
311
281
|
let key = 0;
|
|
312
282
|
let match;
|
|
313
|
-
while ((match =
|
|
283
|
+
while ((match = declareLineRegex.exec(input)) !== null && key < Object.keys(fieldMap).length) {
|
|
314
284
|
const [, argType, assignedValue] = match;
|
|
315
|
-
let depName = "";
|
|
316
|
-
const value = assignedValue.trim();
|
|
317
|
-
let which = "const";
|
|
318
|
-
if (value.includes("::New")) {
|
|
319
|
-
incomplete = true;
|
|
320
|
-
depName = value.slice(0, value.lastIndexOf("::New"));
|
|
321
|
-
dependencies.push(depName);
|
|
322
|
-
}
|
|
323
|
-
if (value.includes("::New()")) {
|
|
324
|
-
which = "constClass";
|
|
325
|
-
} else if (value.includes("::New")) {
|
|
326
|
-
which = "classWithArgs";
|
|
327
|
-
} else if (/^\d+$/.test(value)) {
|
|
328
|
-
which = "const";
|
|
329
|
-
} else {
|
|
330
|
-
switch (value) {
|
|
331
|
-
case "true":
|
|
332
|
-
case "false":
|
|
333
|
-
case "addr_none()":
|
|
334
|
-
case "new_dict()":
|
|
335
|
-
which = "const";
|
|
336
|
-
break;
|
|
337
|
-
default:
|
|
338
|
-
which = value in inputArgs && inputArgs[value].length > 0 ? "inputArg" : "const";
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
285
|
psResult.push({
|
|
342
286
|
name: key in fieldMap ? fieldMap[key].trim() : "",
|
|
343
287
|
type: argType.trim().split("::").pop() ?? "int",
|
|
344
|
-
value
|
|
345
|
-
metaType: which,
|
|
346
|
-
dependencyName: depName
|
|
288
|
+
value: assignedValue.trim()
|
|
347
289
|
});
|
|
348
290
|
key += 1;
|
|
349
291
|
}
|
|
350
|
-
return
|
|
292
|
+
return psResult;
|
|
351
293
|
}
|
|
352
|
-
function parseFieldNames(
|
|
294
|
+
function parseFieldNames(strInput) {
|
|
353
295
|
const fieldMap = {};
|
|
354
296
|
const inverseFieldMap = {};
|
|
355
297
|
const regex = /^const\s+int\s+(?:[A-Za-z]+::)?[A-Za-z]\w+::(\w+)\s*=\s*(\d+);/gm;
|
|
356
298
|
let match;
|
|
357
|
-
while ((match = regex.exec(
|
|
299
|
+
while ((match = regex.exec(strInput)) !== null) {
|
|
358
300
|
const [, fieldName, fieldIndexStr] = match;
|
|
359
301
|
const fieldIndex = parseInt(fieldIndexStr, 10);
|
|
360
302
|
fieldMap[fieldIndex] = fieldName;
|
|
@@ -362,14 +304,13 @@ function parseFieldNames(name, input) {
|
|
|
362
304
|
}
|
|
363
305
|
return [fieldMap, inverseFieldMap];
|
|
364
306
|
}
|
|
365
|
-
function parseClasses(
|
|
307
|
+
function parseClasses(strInput) {
|
|
366
308
|
const functionRegex = /(\w+(?:::\w+)*::New\w*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{([^}]*)\}/g;
|
|
367
309
|
const results = {};
|
|
368
310
|
let match;
|
|
369
|
-
while ((match = functionRegex.exec(
|
|
311
|
+
while ((match = functionRegex.exec(strInput)) !== null) {
|
|
370
312
|
const [, rawName, argsString, , , body] = match;
|
|
371
313
|
const args = {};
|
|
372
|
-
if (rawName.includes("OFTSend")) ;
|
|
373
314
|
const argPairs = argsString.split(",").map((arg) => arg.trim());
|
|
374
315
|
for (const argPair of argPairs) {
|
|
375
316
|
const [argType, argName] = argPair.split(/\s+/);
|
|
@@ -379,17 +320,15 @@ function parseClasses(input) {
|
|
|
379
320
|
}
|
|
380
321
|
const name = rawName.replace(/::New$/, "");
|
|
381
322
|
const functionName = snakeToCamelCase("getnew_" + name);
|
|
382
|
-
const [fieldMap, inverseFieldMap] = parseFieldNames(
|
|
323
|
+
const [fieldMap, inverseFieldMap] = parseFieldNames(strInput);
|
|
383
324
|
console.log(`Parsing ${name}...`);
|
|
384
325
|
const tonNameRegex = /const int\s+(?:md::)?[\w:]+::NAME = "(.*?)"u;/;
|
|
385
|
-
const tonNameMatch =
|
|
326
|
+
const tonNameMatch = strInput.match(tonNameRegex);
|
|
386
327
|
const tonName = tonNameMatch ? tonNameMatch[1] : name;
|
|
387
|
-
const
|
|
328
|
+
const attributes = parseDeclareLines(body, fieldMap);
|
|
388
329
|
results[name] = {
|
|
389
330
|
constructorInputArgs: args,
|
|
390
331
|
attributes,
|
|
391
|
-
constructorIncomplete: incomplete,
|
|
392
|
-
dependencies,
|
|
393
332
|
constructorName: functionName,
|
|
394
333
|
tonName,
|
|
395
334
|
fieldMap,
|
|
@@ -398,8 +337,11 @@ function parseClasses(input) {
|
|
|
398
337
|
}
|
|
399
338
|
return results;
|
|
400
339
|
}
|
|
401
|
-
function saveTonContractWrapper(tonObjects, directory) {
|
|
402
|
-
const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.
|
|
340
|
+
function saveTonContractWrapper(tonObjects, directory, baseWrapper) {
|
|
341
|
+
const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.constructorCode ?? "").join("\n");
|
|
342
|
+
if (baseWrapper === void 0) {
|
|
343
|
+
baseWrapper = `import { BaseWrapper, SendRequestOptions } from '@layerzerolabs/ton-sdk-tools'`;
|
|
344
|
+
}
|
|
403
345
|
const savedCode = `${file_signature_header}
|
|
404
346
|
|
|
405
347
|
import {
|
|
@@ -414,8 +356,7 @@ import {
|
|
|
414
356
|
contractAddress,
|
|
415
357
|
} from '@ton/core'
|
|
416
358
|
|
|
417
|
-
|
|
418
|
-
import { beginMessage } from './utils'
|
|
359
|
+
${baseWrapper}
|
|
419
360
|
|
|
420
361
|
export type GetIntFnNames =
|
|
421
362
|
| 'cl::get<uint8>'
|
|
@@ -433,6 +374,33 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
433
374
|
return new TonContractWrapper(contractAddress(workchain, init), init)
|
|
434
375
|
}
|
|
435
376
|
|
|
377
|
+
buildRequest(
|
|
378
|
+
opCode: bigint,
|
|
379
|
+
data: Cell,
|
|
380
|
+
opts: SendRequestOptions,
|
|
381
|
+
balanceRefill = 0n,
|
|
382
|
+
queryId?: number | bigint
|
|
383
|
+
): SenderArguments {
|
|
384
|
+
const body = this.beginMessage(opCode, queryId).storeCoins(balanceRefill).storeRef(data).endCell()
|
|
385
|
+
return this.buildSenderArguments(body, opts)
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async sendInternalMessage(
|
|
389
|
+
provider: ContractProvider,
|
|
390
|
+
via: Sender,
|
|
391
|
+
opCode: bigint,
|
|
392
|
+
md: Cell,
|
|
393
|
+
opts: SendRequestOptions,
|
|
394
|
+
balanceRefill = 0n,
|
|
395
|
+
queryId?: number | bigint
|
|
396
|
+
): Promise<void> {
|
|
397
|
+
if (via.address === undefined) {
|
|
398
|
+
throw new Error('Sender address is not defined')
|
|
399
|
+
}
|
|
400
|
+
const request = this.buildRequest(opCode, md, opts, balanceRefill, queryId)
|
|
401
|
+
return this.sendRequest(provider, via, request)
|
|
402
|
+
}
|
|
403
|
+
|
|
436
404
|
async getFieldStack(
|
|
437
405
|
provider: ContractProvider,
|
|
438
406
|
method: string,
|
|
@@ -451,11 +419,6 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
451
419
|
return provider.getState()
|
|
452
420
|
}
|
|
453
421
|
|
|
454
|
-
async getCurrentStorage(provider: ContractProvider): Promise<TupleReader> {
|
|
455
|
-
const ret = await provider.get('getContractStorage', [])
|
|
456
|
-
return ret.stack
|
|
457
|
-
}
|
|
458
|
-
|
|
459
422
|
async getCurrentStorageCell(provider: ContractProvider): Promise<Cell> {
|
|
460
423
|
const getResult = await provider.get('getContractStorage', [])
|
|
461
424
|
return getResult.stack.readCell()
|
|
@@ -519,33 +482,6 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
519
482
|
return ret.stack.readCell()
|
|
520
483
|
}
|
|
521
484
|
|
|
522
|
-
buildRequest(
|
|
523
|
-
opCode: bigint,
|
|
524
|
-
data: Cell,
|
|
525
|
-
opts: SendRequestOptions,
|
|
526
|
-
balanceRefill = 0n,
|
|
527
|
-
queryId?: number | bigint
|
|
528
|
-
): SenderArguments {
|
|
529
|
-
const body = beginMessage(opCode, queryId).storeCoins(balanceRefill).storeRef(data).endCell()
|
|
530
|
-
return this.buildSenderArguments(body, opts)
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
async sendInternalMessage(
|
|
534
|
-
provider: ContractProvider,
|
|
535
|
-
via: Sender,
|
|
536
|
-
opCode: bigint,
|
|
537
|
-
md: Cell,
|
|
538
|
-
opts: SendRequestOptions,
|
|
539
|
-
balanceRefill = 0n,
|
|
540
|
-
queryId?: number | bigint
|
|
541
|
-
): Promise<void> {
|
|
542
|
-
if (via.address === undefined) {
|
|
543
|
-
throw new Error('Sender address is not defined')
|
|
544
|
-
}
|
|
545
|
-
const request = this.buildRequest(opCode, md, opts, balanceRefill, queryId)
|
|
546
|
-
return this.sendRequest(provider, via, request)
|
|
547
|
-
}
|
|
548
|
-
|
|
549
485
|
${generatedMethods}
|
|
550
486
|
}
|
|
551
487
|
`;
|
|
@@ -860,57 +796,18 @@ ${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructor
|
|
|
860
796
|
`;
|
|
861
797
|
fs__namespace.writeFileSync(path__namespace.join(directory, "TonObjectUnwrapper.ts"), savedCode);
|
|
862
798
|
}
|
|
863
|
-
function
|
|
864
|
-
if (name in tonClasses) return tonClasses[name];
|
|
865
|
-
const lzName = "lz::" + name;
|
|
866
|
-
if (lzName in tonClasses) return tonClasses[lzName];
|
|
867
|
-
const mdName = "md::" + name;
|
|
868
|
-
if (mdName in tonClasses) return tonClasses[mdName];
|
|
869
|
-
const clName = "cl::" + name;
|
|
870
|
-
if (clName in tonClasses) return tonClasses[clName];
|
|
871
|
-
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
872
|
-
if (packetV1Key in tonClasses) return tonClasses[packetV1Key];
|
|
873
|
-
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
874
|
-
if (packetV1UnderscoreKey in tonClasses) return tonClasses[packetV1UnderscoreKey];
|
|
875
|
-
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
876
|
-
if (packetV2Key in tonClasses) return tonClasses[packetV2Key];
|
|
877
|
-
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
878
|
-
if (packetV2UnderscoreKey in tonClasses) return tonClasses[packetV2UnderscoreKey];
|
|
879
|
-
return void 0;
|
|
880
|
-
}
|
|
881
|
-
function findClassKey(tonClasses, name) {
|
|
882
|
-
if (name in tonClasses) return name;
|
|
883
|
-
const lzName = "lz::" + name;
|
|
884
|
-
if (lzName in tonClasses) return lzName;
|
|
885
|
-
const mdName = "md::" + name;
|
|
886
|
-
if (mdName in tonClasses) return mdName;
|
|
887
|
-
const clName = "cl::" + name;
|
|
888
|
-
if (clName in tonClasses) return clName;
|
|
889
|
-
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
890
|
-
if (packetV1Key in tonClasses) return packetV1Key;
|
|
891
|
-
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
892
|
-
if (packetV1UnderscoreKey in tonClasses) return packetV1UnderscoreKey;
|
|
893
|
-
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
894
|
-
if (packetV2Key in tonClasses) return packetV2Key;
|
|
895
|
-
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
896
|
-
if (packetV2UnderscoreKey in tonClasses) return packetV2UnderscoreKey;
|
|
897
|
-
return void 0;
|
|
898
|
-
}
|
|
899
|
-
function generateConstructorCodes(className, tonClasses) {
|
|
799
|
+
function generateConstructorCode(className, tonClasses) {
|
|
900
800
|
if (!(className in tonClasses)) {
|
|
901
801
|
return tonClasses;
|
|
902
802
|
}
|
|
903
803
|
const tonClass = tonClasses[className];
|
|
904
804
|
const { constructorInputArgs: inputArgs } = tonClass;
|
|
905
805
|
const fnName = snakeToCamelCase(`getNew_${className}`);
|
|
906
|
-
const scratchFnName = snakeToCamelCase(`getNew_${className}FromScratch`);
|
|
907
806
|
let methodIdName = `${className}::New`;
|
|
908
807
|
if (className.includes("::New")) {
|
|
909
808
|
methodIdName = className;
|
|
910
809
|
}
|
|
911
810
|
tonClass.constructorName = fnName;
|
|
912
|
-
tonClass.fromScratchConstructorName = scratchFnName;
|
|
913
|
-
tonClass.nonClassConstructorArgs = {};
|
|
914
811
|
tonClass.constructorCode = `
|
|
915
812
|
async ${fnName}(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
916
813
|
${Object.entries(inputArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
|
|
@@ -922,21 +819,6 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
922
819
|
]);
|
|
923
820
|
return getResult.stack.readCell()
|
|
924
821
|
}`;
|
|
925
|
-
const cellArgs = {};
|
|
926
|
-
Object.entries(inputArgs).forEach(([argName, argType]) => {
|
|
927
|
-
cellArgs[argName] = argType === "tuple" ? "cell" : argType;
|
|
928
|
-
});
|
|
929
|
-
tonClass.cellConstructorCode = `
|
|
930
|
-
async ${fnName}Cell(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
931
|
-
${Object.entries(cellArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType, "Slice", true)}`).join(",\n ")}
|
|
932
|
-
}` : ""}): Promise<Cell> {
|
|
933
|
-
const getResult = await provider.get('${methodIdName}', [
|
|
934
|
-
${Object.entries(cellArgs).map(
|
|
935
|
-
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
936
|
-
).join(",\n ")}
|
|
937
|
-
]);
|
|
938
|
-
return getResult.stack.readCell()
|
|
939
|
-
}`;
|
|
940
822
|
tonClass.constructorCodeCallGenerator = (callerArgs, _) => {
|
|
941
823
|
const missingArgs = Object.keys(inputArgs).filter((key) => !(key in callerArgs));
|
|
942
824
|
if (missingArgs.length > 0) {
|
|
@@ -947,119 +829,14 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
947
829
|
const filteredArgs = Object.entries(inputArgs).filter(([key, value]) => key in callerArgs);
|
|
948
830
|
return `await ${fnName}(provider.getSender()${filteredArgs.length > 0 ? `, { ${filteredArgs.map(([argName, argType]) => `${argName}: ${argName}`).join(", ")} }` : ""})`;
|
|
949
831
|
};
|
|
950
|
-
tonClass.flatConstructorArgs = { ...inputArgs };
|
|
951
|
-
Object.entries(tonClass.constructorInputArgs).map(([argName, argType]) => {
|
|
952
|
-
if (argType === "tuple") {
|
|
953
|
-
const tupleClass = findClass(tonClasses, argName);
|
|
954
|
-
if (tupleClass?.scratchConstructorCodeCallGenerator === void 0) {
|
|
955
|
-
const implicitDepName = findClassKey(tonClasses, argName);
|
|
956
|
-
if (implicitDepName !== void 0) {
|
|
957
|
-
generateConstructorCodes(implicitDepName, tonClasses);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
tonClass.flatConstructorArgs = mergeInputArgs(
|
|
961
|
-
tonClass.flatConstructorArgs ?? {},
|
|
962
|
-
tupleClass?.flatConstructorArgs ?? {}
|
|
963
|
-
);
|
|
964
|
-
}
|
|
965
|
-
});
|
|
966
|
-
const classArgs = {};
|
|
967
|
-
Object.entries(tonClass.flatConstructorArgs ?? {}).forEach(([argName, argType]) => {
|
|
968
|
-
if (argType === "tuple" && findClass(tonClasses, argName) !== void 0) {
|
|
969
|
-
classArgs[argName] = tonClass.flatConstructorArgs?.[argName] ?? "";
|
|
970
|
-
} else {
|
|
971
|
-
(tonClass.nonClassConstructorArgs ?? (tonClass.nonClassConstructorArgs = {}))[argName] = argType;
|
|
972
|
-
}
|
|
973
|
-
});
|
|
974
|
-
tonClass.scratchConstructorCodeCallGenerator = (parentArgs, _) => {
|
|
975
|
-
const missingArgs = Object.keys(tonClass.nonClassConstructorArgs ?? {}).filter((key) => !(key in parentArgs));
|
|
976
|
-
if (missingArgs.length > 0) {
|
|
977
|
-
console.warn(
|
|
978
|
-
`Argument(s) not provided: ${missingArgs.join(", ")}, make sure the TON constructor has default values for these arguments`
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
const filteredArgs = Object.entries(tonClass.nonClassConstructorArgs ?? {}).filter(
|
|
982
|
-
([key, value]) => key in parentArgs
|
|
983
|
-
);
|
|
984
|
-
return `await ${scratchFnName}(provider${filteredArgs.length > 0 ? `, { ${filteredArgs.map(([argName, argType]) => `${argName}: args.${argName}`).join(", ")} }` : ""})`;
|
|
985
|
-
};
|
|
986
|
-
const finalScratchArgs = { ...tonClass.nonClassConstructorArgs };
|
|
987
|
-
const insideTupleGenerationCode = Object.entries(classArgs).map(([argName, argType]) => {
|
|
988
|
-
const tupleInstanceName = argName;
|
|
989
|
-
const tupleClass = findClass(tonClasses, argName);
|
|
990
|
-
if (tupleClass !== void 0) {
|
|
991
|
-
finalScratchArgs[`${argName}INSIDE_FLAGGED`] = argType;
|
|
992
|
-
}
|
|
993
|
-
return `const ${tupleInstanceName} = ${tupleClass?.scratchConstructorCodeCallGenerator?.(tonClass.nonClassConstructorArgs ?? {}, "") ?? ""};`.replace(
|
|
994
|
-
"getNew",
|
|
995
|
-
"this.getNew"
|
|
996
|
-
);
|
|
997
|
-
}).join("\n");
|
|
998
|
-
tonClass.fromScratchConstructorCode = `
|
|
999
|
-
async ${scratchFnName}(provider: ContractProvider${Object.keys(tonClass.nonClassConstructorArgs ?? {}).length > 0 ? `, args: {
|
|
1000
|
-
${Object.entries(tonClass.nonClassConstructorArgs ?? {}).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
|
|
1001
|
-
}` : ""}): Promise<Tuple> {
|
|
1002
|
-
${insideTupleGenerationCode}
|
|
1003
|
-
const getResult = await provider.get('${className.toLowerCase()}::New', [
|
|
1004
|
-
${Object.entries(finalScratchArgs).map(
|
|
1005
|
-
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(tonClass.nonClassConstructorArgs ?? {}).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
1006
|
-
).join(",\n ")}
|
|
1007
|
-
])
|
|
1008
|
-
return LzTuple(getResult.stack)
|
|
1009
|
-
}`;
|
|
1010
|
-
tonClass.constructorIncomplete = false;
|
|
1011
832
|
tonClasses[className] = tonClass;
|
|
1012
833
|
return tonClasses;
|
|
1013
834
|
}
|
|
1014
|
-
function
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
return classConstructors;
|
|
1018
|
-
}
|
|
1019
|
-
const current = classConstructors[key];
|
|
1020
|
-
if (current.constructorIncomplete) {
|
|
1021
|
-
current.dependencies.forEach((item) => {
|
|
1022
|
-
if (item in classConstructors) {
|
|
1023
|
-
if (classConstructors[item].constructorCode === void 0) {
|
|
1024
|
-
classConstructors = recursiveGenConstructorCode(classConstructors, item);
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
classConstructors = generateConstructorCodes(key, classConstructors);
|
|
1030
|
-
} else {
|
|
1031
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1032
|
-
if (value.constructorCode === void 0) {
|
|
1033
|
-
classConstructors = recursiveGenConstructorCode(classConstructors, key2);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
return classConstructors;
|
|
1038
|
-
}
|
|
1039
|
-
function recursiveGenTSTypes(classConstructors, key = "") {
|
|
1040
|
-
if (key != "") {
|
|
1041
|
-
if (!(key in classConstructors)) {
|
|
1042
|
-
return classConstructors;
|
|
1043
|
-
}
|
|
1044
|
-
const current = classConstructors[key];
|
|
1045
|
-
if (current.dependencies.length > 0) {
|
|
1046
|
-
current.dependencies.forEach((item) => {
|
|
1047
|
-
if (item in classConstructors) {
|
|
1048
|
-
if (classConstructors[item].tsTypeCode === void 0) {
|
|
1049
|
-
classConstructors = recursiveGenTSTypes(classConstructors, item);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
});
|
|
1053
|
-
}
|
|
1054
|
-
classConstructors = generateTonClassTypes(key, classConstructors);
|
|
1055
|
-
} else {
|
|
1056
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1057
|
-
if (value.tsTypeCode === void 0) {
|
|
1058
|
-
classConstructors = recursiveGenTSTypes(classConstructors, key2);
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
835
|
+
function generateAllConstructorCodes(tonClasses) {
|
|
836
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
837
|
+
generateConstructorCode(className, tonClasses);
|
|
1061
838
|
}
|
|
1062
|
-
return
|
|
839
|
+
return tonClasses;
|
|
1063
840
|
}
|
|
1064
841
|
function getTsAttributeName(name) {
|
|
1065
842
|
let modifiedName = name.replace(/::/g, "_");
|
|
@@ -1069,7 +846,7 @@ function getTsAttributeName(name) {
|
|
|
1069
846
|
}
|
|
1070
847
|
return modifiedName;
|
|
1071
848
|
}
|
|
1072
|
-
function
|
|
849
|
+
function generateTonClassType(name, tonClasses) {
|
|
1073
850
|
if (!(name in tonClasses)) {
|
|
1074
851
|
return tonClasses;
|
|
1075
852
|
}
|
|
@@ -1079,16 +856,8 @@ function generateTonClassTypes(name, tonClasses) {
|
|
|
1079
856
|
const typeName = tonClass.is_md ? "interface" : "type";
|
|
1080
857
|
const extension = tonClass.is_md ? "extends Md" : "=";
|
|
1081
858
|
tonClass.tsTypeCode = `${typeName} ${capitalizedName} ${extension} {
|
|
1082
|
-
${tonClass.attributes.map(({ name: name2, type
|
|
1083
|
-
|
|
1084
|
-
let attributeType = tonTypeToTStype(type, "Address", true);
|
|
1085
|
-
if (type === "obj_ref") {
|
|
1086
|
-
const dependantClass = findClass(tonClasses, modifiedName) ?? findClass(tonClasses, dependencyName);
|
|
1087
|
-
if (dependantClass) {
|
|
1088
|
-
attributeType = dependantClass.constructorName.replace("getNew", "");
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
return `${modifiedName}: ${attributeType};`;
|
|
859
|
+
${tonClass.attributes.map(({ name: name2, type }) => {
|
|
860
|
+
return `${getTsAttributeName(name2)}: ${tonTypeToTStype(type)};`;
|
|
1092
861
|
}).join("\n")}
|
|
1093
862
|
}
|
|
1094
863
|
|
|
@@ -1097,7 +866,13 @@ function generateTonClassTypes(name, tonClasses) {
|
|
|
1097
866
|
tonClasses[name] = tonClass;
|
|
1098
867
|
return tonClasses;
|
|
1099
868
|
}
|
|
1100
|
-
function
|
|
869
|
+
function generateAllTonClassTypes(tonClasses) {
|
|
870
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
871
|
+
generateTonClassType(className, tonClasses);
|
|
872
|
+
}
|
|
873
|
+
return tonClasses;
|
|
874
|
+
}
|
|
875
|
+
function generateDeconstructorCode(className, tonClasses) {
|
|
1101
876
|
if (!(className in tonClasses)) {
|
|
1102
877
|
return tonClasses;
|
|
1103
878
|
}
|
|
@@ -1107,18 +882,10 @@ function generateDeconstructorCodes(className, tonClasses) {
|
|
|
1107
882
|
tonClass.deconstructorName = fnName;
|
|
1108
883
|
tonClass.deconstructorCode = `
|
|
1109
884
|
static async ${fnName}(wrapper: ExtendedContract<TonContractWrapper>, cell: Cell): Promise<${tsTypeName}> {
|
|
1110
|
-
${attributes.map(({ name, type
|
|
885
|
+
${attributes.map(({ name, type }) => {
|
|
1111
886
|
const fieldTSName = getTsAttributeName(name);
|
|
1112
|
-
const tsGetterName = tsTypeToTSGetterName(tonTypeToTStype(type
|
|
887
|
+
const tsGetterName = tsTypeToTSGetterName(tonTypeToTStype(type), "wrapper");
|
|
1113
888
|
const fieldIndex = inverseFieldMap[name];
|
|
1114
|
-
if (type === "obj_ref") {
|
|
1115
|
-
const dependencyClassType = (findClass(tonClasses, dependencyName) ?? findClass(tonClasses, fieldTSName))?.tsTypeName;
|
|
1116
|
-
if (dependencyClassType !== void 0) {
|
|
1117
|
-
const depDeconstructorName = snakeToCamelCase(`get_${dependencyClassType}ToTS`);
|
|
1118
|
-
return `const ${fieldTSName}_obj = await ${tsGetterName}(cell, ${fieldIndex}n);
|
|
1119
|
-
const ${fieldTSName} = await TonObjectUnwrapper.${depDeconstructorName}(wrapper, ${fieldTSName}_obj)`;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
889
|
const tonGetterName = tonTypeToTonGetterName(type);
|
|
1123
890
|
if (tsGetterName === "getLzDict") {
|
|
1124
891
|
return `const ${fieldTSName} = await getLzDict(cell, ${fieldIndex}n, wrapper)`;
|
|
@@ -1138,34 +905,14 @@ function generateDeconstructorCodes(className, tonClasses) {
|
|
|
1138
905
|
tonClass.deconstructorCodeCallGenerator = (callerArgs, _) => {
|
|
1139
906
|
return `await ${fnName}(provider, obj)`;
|
|
1140
907
|
};
|
|
1141
|
-
tonClass.deconstructorIncomplete = false;
|
|
1142
908
|
tonClasses[className] = tonClass;
|
|
1143
909
|
return tonClasses;
|
|
1144
910
|
}
|
|
1145
|
-
function
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
return classConstructors;
|
|
1149
|
-
}
|
|
1150
|
-
const current = classConstructors[key];
|
|
1151
|
-
if (current.deconstructorIncomplete === void 0 || current.deconstructorIncomplete) {
|
|
1152
|
-
current.dependencies.forEach((item) => {
|
|
1153
|
-
if (item in classConstructors) {
|
|
1154
|
-
if (classConstructors[item].deconstructorCode === void 0) {
|
|
1155
|
-
classConstructors = recursiveGenDeconstructorCode(classConstructors, item);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
classConstructors = generateDeconstructorCodes(key, classConstructors);
|
|
1161
|
-
} else {
|
|
1162
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1163
|
-
if (value.deconstructorCode === void 0) {
|
|
1164
|
-
classConstructors = recursiveGenDeconstructorCode(classConstructors, key2);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
911
|
+
function generateAllDeconstructorCodes(tonClasses) {
|
|
912
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
913
|
+
generateDeconstructorCode(className, tonClasses);
|
|
1167
914
|
}
|
|
1168
|
-
return
|
|
915
|
+
return tonClasses;
|
|
1169
916
|
}
|
|
1170
917
|
function getSpecificFiles(dirPath, includeName) {
|
|
1171
918
|
const files = [];
|
|
@@ -1347,11 +1094,11 @@ function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
|
|
|
1347
1094
|
const [argType, argName] = argPair.split(/\s+/);
|
|
1348
1095
|
if (argName !== void 0) {
|
|
1349
1096
|
tonArgs[argName.replace("$", "")] = argType;
|
|
1350
|
-
tsArgs[argName.replace("$", "")] = tonTypeToTStype(argType
|
|
1097
|
+
tsArgs[argName.replace("$", "")] = tonTypeToTStype(argType);
|
|
1351
1098
|
}
|
|
1352
1099
|
}
|
|
1353
1100
|
const tonReturnTypes = returnType.split(",").map((type) => type.replace(/\(/g, "").replace(/\)/g, "").trim());
|
|
1354
|
-
const tsReturnTypes = tonReturnTypes.map((type) => tonTypeToTStype(type
|
|
1101
|
+
const tsReturnTypes = tonReturnTypes.map((type) => tonTypeToTStype(type));
|
|
1355
1102
|
if (!(contractName in viewFunctions)) {
|
|
1356
1103
|
viewFunctions[contractName] = [];
|
|
1357
1104
|
}
|
|
@@ -1410,6 +1157,18 @@ var BaseWrapper = class {
|
|
|
1410
1157
|
body: core.beginCell().endCell()
|
|
1411
1158
|
});
|
|
1412
1159
|
}
|
|
1160
|
+
async sendRequest(provider, via, request) {
|
|
1161
|
+
return provider.internal(via, {
|
|
1162
|
+
value: request.value,
|
|
1163
|
+
sendMode: request.sendMode ?? void 0,
|
|
1164
|
+
body: request.body,
|
|
1165
|
+
bounce: request.bounce
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
async getDeployed(provider) {
|
|
1169
|
+
const state = await provider.getState();
|
|
1170
|
+
return state.state.type !== "uninit";
|
|
1171
|
+
}
|
|
1413
1172
|
buildSenderArguments(body, opts) {
|
|
1414
1173
|
return {
|
|
1415
1174
|
value: BigInt(opts.value),
|
|
@@ -1420,19 +1179,9 @@ var BaseWrapper = class {
|
|
|
1420
1179
|
sendMode: opts.sendMode ?? core.SendMode.PAY_GAS_SEPARATELY
|
|
1421
1180
|
};
|
|
1422
1181
|
}
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
async sendArbitraryOp(provider, via, op_code, opts) {
|
|
1427
|
-
await provider.internal(via, {
|
|
1428
|
-
value: opts.value,
|
|
1429
|
-
sendMode: core.SendMode.PAY_GAS_SEPARATELY,
|
|
1430
|
-
body: beginMessage(op_code, opts.queryId ?? randomQueryId()).endCell()
|
|
1431
|
-
});
|
|
1432
|
-
}
|
|
1433
|
-
async getDeployed(provider) {
|
|
1434
|
-
const state = await provider.getState();
|
|
1435
|
-
return state.state.type !== "uninit";
|
|
1182
|
+
beginMessage(opcode, queryId) {
|
|
1183
|
+
const randomQueryId = Math.floor(Math.random() * 1e11);
|
|
1184
|
+
return core.beginCell().storeUint(opcode, 32).storeUint(queryId ?? randomQueryId, 64);
|
|
1436
1185
|
}
|
|
1437
1186
|
};
|
|
1438
1187
|
function generateTestUtilsCode(directory, filename) {
|
|
@@ -1467,22 +1216,15 @@ import {
|
|
|
1467
1216
|
Order,
|
|
1468
1217
|
Profile,
|
|
1469
1218
|
TransferRequest,
|
|
1219
|
+
addressToBigInt,
|
|
1220
|
+
beginMessage,
|
|
1470
1221
|
buildOnchainMetadata,
|
|
1471
1222
|
cellFromArtifact,
|
|
1472
1223
|
getRandomInt,
|
|
1473
1224
|
printTransactionTrace,
|
|
1474
1225
|
} from '@layerzerolabs/ton-sdk-tools'
|
|
1475
1226
|
|
|
1476
|
-
import {
|
|
1477
|
-
LzDict,
|
|
1478
|
-
LzEventHandler,
|
|
1479
|
-
MdPacketSent,
|
|
1480
|
-
OPCODES,
|
|
1481
|
-
TonContractWrapper,
|
|
1482
|
-
TonObjectUnwrapper,
|
|
1483
|
-
addressToBigInt,
|
|
1484
|
-
beginMessage,
|
|
1485
|
-
} from '../src'
|
|
1227
|
+
import { LzDict, LzEventHandler, MdPacketSent, OPCODES, TonContractWrapper, TonObjectUnwrapper } from '../src'
|
|
1486
1228
|
|
|
1487
1229
|
const invertedOpcodes = Object.fromEntries(Object.entries(OPCODES).map(([key, value]) => [value.toString(), key]))
|
|
1488
1230
|
const SML_MANAGER_DEFAULT_VERSION = BigInt(1)
|
|
@@ -2085,7 +1827,7 @@ export async function commitVerificationAndExpect(
|
|
|
2085
1827
|
sender: deployer.getSender(),
|
|
2086
1828
|
contract: smlManager,
|
|
2087
1829
|
opCode: OPCODES.SmlManager_OP_SML_MANAGER_COMMIT_PACKET,
|
|
2088
|
-
md: await smlManager.
|
|
1830
|
+
md: await smlManager.getNewMdMdAddress({
|
|
2089
1831
|
md: lzPacketCell,
|
|
2090
1832
|
address: addressToBigInt(endpoint.address),
|
|
2091
1833
|
}),
|
|
@@ -2418,7 +2160,7 @@ export async function openAndDeployControllerViaMultiSig(
|
|
|
2418
2160
|
const controller: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2419
2161
|
TonContractWrapper.create(
|
|
2420
2162
|
cellFromArtifact(ControllerArtifact),
|
|
2421
|
-
await allStorages.
|
|
2163
|
+
await allStorages.getNewController({
|
|
2422
2164
|
owner: addressToBigInt(multiSigContract.address),
|
|
2423
2165
|
eid,
|
|
2424
2166
|
endpointCode: cellFromArtifact(EndpointArtifact),
|
|
@@ -2463,7 +2205,7 @@ export async function setControllerZroWalletViaMultisig(
|
|
|
2463
2205
|
multiSigContract,
|
|
2464
2206
|
messageBody: controller.buildRequest(
|
|
2465
2207
|
OPCODES.Controller_OP_SET_ZRO_WALLET,
|
|
2466
|
-
await controller.
|
|
2208
|
+
await controller.getNewMdSetAddress({
|
|
2467
2209
|
address: addressToBigInt(await zroMinter.getWalletAddress(multiSigContract.address)),
|
|
2468
2210
|
}),
|
|
2469
2211
|
{ value: toNano('1') },
|
|
@@ -2501,7 +2243,7 @@ export async function openAndDeployEndpoint(
|
|
|
2501
2243
|
const endpoint: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2502
2244
|
TonContractWrapper.create(
|
|
2503
2245
|
cellFromArtifact(EndpointArtifact),
|
|
2504
|
-
await controller.
|
|
2246
|
+
await controller.getNewEndpoint({
|
|
2505
2247
|
eid: srcEid,
|
|
2506
2248
|
dstEid: dstEid,
|
|
2507
2249
|
owner: addressToBigInt(controller.address),
|
|
@@ -2514,7 +2256,7 @@ export async function openAndDeployEndpoint(
|
|
|
2514
2256
|
multiSigContract,
|
|
2515
2257
|
messageBody: controller.buildRequest(
|
|
2516
2258
|
OPCODES.Controller_OP_DEPLOY_ENDPOINT,
|
|
2517
|
-
await controller.
|
|
2259
|
+
await controller.getNewMdDeploy({
|
|
2518
2260
|
dstEid: dstEid,
|
|
2519
2261
|
initialDeposit: toNano('1.0'),
|
|
2520
2262
|
dstOApp: BigInt(0), // the dstOApp is unused inside of the endpoint deploy call
|
|
@@ -2554,7 +2296,7 @@ export async function openAndDeployChannel(
|
|
|
2554
2296
|
const channel: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2555
2297
|
TonContractWrapper.create(
|
|
2556
2298
|
cellFromArtifact(ChannelArtifact),
|
|
2557
|
-
await srcFixture.controller.
|
|
2299
|
+
await srcFixture.controller.getNewChannel({
|
|
2558
2300
|
owner: addressToBigInt(srcFixture.controller.address),
|
|
2559
2301
|
path: srcFixture.path,
|
|
2560
2302
|
endpointAddress: addressToBigInt(srcFixture.endpoint.address),
|
|
@@ -2567,7 +2309,7 @@ export async function openAndDeployChannel(
|
|
|
2567
2309
|
sender: deployer.getSender(),
|
|
2568
2310
|
contract: srcFixture.oApp,
|
|
2569
2311
|
opCode: OPCODES.OP_DeployChannel,
|
|
2570
|
-
md: await srcFixture.controller.
|
|
2312
|
+
md: await srcFixture.controller.getNewMdDeploy({
|
|
2571
2313
|
dstEid: dstFixture.eid,
|
|
2572
2314
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2573
2315
|
initialDeposit: toNano('1'),
|
|
@@ -2607,7 +2349,7 @@ export async function openAndDeploySmlManager(
|
|
|
2607
2349
|
const smlManager: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2608
2350
|
TonContractWrapper.create(
|
|
2609
2351
|
cellFromArtifact(SmlManagerArtifact),
|
|
2610
|
-
await allStorages.
|
|
2352
|
+
await allStorages.getNewSmlManager({
|
|
2611
2353
|
owner: addressToBigInt(fixture.owner.address),
|
|
2612
2354
|
eid: fixture.eid,
|
|
2613
2355
|
version,
|
|
@@ -2648,7 +2390,7 @@ export async function openAndDeploySmlConnection(
|
|
|
2648
2390
|
const smlConnection: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2649
2391
|
TonContractWrapper.create(
|
|
2650
2392
|
cellFromArtifact(SmlConnectionArtifact),
|
|
2651
|
-
await allStorages.
|
|
2393
|
+
await allStorages.getNewSmlConnection({
|
|
2652
2394
|
owner: addressToBigInt(smlManager.address),
|
|
2653
2395
|
path: srcFixture.path,
|
|
2654
2396
|
})
|
|
@@ -2660,8 +2402,8 @@ export async function openAndDeploySmlConnection(
|
|
|
2660
2402
|
sender: srcFixture.owner.getSender(),
|
|
2661
2403
|
contract: srcFixture.oApp,
|
|
2662
2404
|
opCode: OPCODES.OP_DeployConnection,
|
|
2663
|
-
md: await allStorages.
|
|
2664
|
-
md: await allStorages.
|
|
2405
|
+
md: await allStorages.getNewMdMdAddress({
|
|
2406
|
+
md: await allStorages.getNewMdDeploy({
|
|
2665
2407
|
dstEid: dstFixture.eid,
|
|
2666
2408
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2667
2409
|
initialDeposit: toNano('1'),
|
|
@@ -2703,7 +2445,7 @@ export async function setDefaultEndpointConfig(
|
|
|
2703
2445
|
srcFixture: ProtocolFixture,
|
|
2704
2446
|
dstFixture: ProtocolFixture
|
|
2705
2447
|
): Promise<SendMessageResult> {
|
|
2706
|
-
const set_ep_config_md = await allStorages.
|
|
2448
|
+
const set_ep_config_md = await allStorages.getNewMdSetEpConfig({
|
|
2707
2449
|
useDefaults: BigInt(-1), // true
|
|
2708
2450
|
sendMsglibManager: addressToBigInt(sendMsglibManager.address),
|
|
2709
2451
|
receiveMsglibManager: addressToBigInt(receiveMsglibManager.address),
|
|
@@ -2716,7 +2458,7 @@ export async function setDefaultEndpointConfig(
|
|
|
2716
2458
|
multiSigContract: srcFixture.multisig,
|
|
2717
2459
|
messageBody: srcFixture.controller.buildRequest(
|
|
2718
2460
|
OPCODES.Controller_OP_SET_EP_CONFIG_DEFAULTS,
|
|
2719
|
-
await srcFixture.controller.
|
|
2461
|
+
await srcFixture.controller.getNewMdMdEid({
|
|
2720
2462
|
md: set_ep_config_md,
|
|
2721
2463
|
eid: dstFixture.eid,
|
|
2722
2464
|
}),
|
|
@@ -2762,7 +2504,7 @@ export async function addMsgLibToController(
|
|
|
2762
2504
|
multiSigContract: srcFixture.multisig,
|
|
2763
2505
|
messageBody: srcFixture.controller.buildRequest(
|
|
2764
2506
|
OPCODES.Controller_OP_ADD_MSGLIB,
|
|
2765
|
-
await srcFixture.controller.
|
|
2507
|
+
await srcFixture.controller.getNewMdAddMsglib({
|
|
2766
2508
|
msglibManagerAddress: addressToBigInt(msglibManager.address),
|
|
2767
2509
|
dstEid: dstFixture.eid,
|
|
2768
2510
|
}),
|
|
@@ -2965,14 +2707,14 @@ export async function wireChannels(
|
|
|
2965
2707
|
|
|
2966
2708
|
// ===================================generate path==================================================
|
|
2967
2709
|
|
|
2968
|
-
srcFixture.path = await allStorages.
|
|
2710
|
+
srcFixture.path = await allStorages.getNewLzPath({
|
|
2969
2711
|
srcEid: srcFixture.eid,
|
|
2970
2712
|
srcOApp: addressToBigInt(srcFixture.oApp.address),
|
|
2971
2713
|
dstEid: dstFixture.eid,
|
|
2972
2714
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2973
2715
|
})
|
|
2974
2716
|
|
|
2975
|
-
dstFixture.path = await allStorages.
|
|
2717
|
+
dstFixture.path = await allStorages.getNewLzPath({
|
|
2976
2718
|
srcEid: dstFixture.eid,
|
|
2977
2719
|
srcOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2978
2720
|
dstEid: srcFixture.eid,
|
|
@@ -3023,12 +2765,12 @@ export async function deployConfigAndRegisterSml(
|
|
|
3023
2765
|
|
|
3024
2766
|
// ===================================configure sml =====================================
|
|
3025
2767
|
|
|
3026
|
-
const set_sml_config_md = await msglibManager.
|
|
2768
|
+
const set_sml_config_md = await msglibManager.getNewMdSetSmlManagerConfig({
|
|
3027
2769
|
nativeFee,
|
|
3028
2770
|
zroFee,
|
|
3029
2771
|
})
|
|
3030
2772
|
|
|
3031
|
-
const set_sml_config_extended_md = await msglibManager.
|
|
2773
|
+
const set_sml_config_extended_md = await msglibManager.getNewMdExtendedMd({
|
|
3032
2774
|
md: set_sml_config_md,
|
|
3033
2775
|
obj: emptyObject,
|
|
3034
2776
|
forwardingAddress: BigInt(0),
|
|
@@ -3279,7 +3021,7 @@ var Multisig = class _Multisig {
|
|
|
3279
3021
|
throw new Error("Configuration is not set: use createFromConfig or loadConfiguration");
|
|
3280
3022
|
}
|
|
3281
3023
|
if (via.address !== void 0) {
|
|
3282
|
-
const addrCmp = (x) =>
|
|
3024
|
+
const addrCmp = (x) => x.equals(via.address);
|
|
3283
3025
|
addrIdx = this.configuration.signers.findIndex(addrCmp);
|
|
3284
3026
|
if (addrIdx >= 0) {
|
|
3285
3027
|
isSigner = true;
|
|
@@ -3291,7 +3033,7 @@ var Multisig = class _Multisig {
|
|
|
3291
3033
|
isSigner = false;
|
|
3292
3034
|
}
|
|
3293
3035
|
} else if (isSigner === void 0 || addrIdx == void 0) {
|
|
3294
|
-
throw new Error("If sender address is not known, addrIdx and isSigner
|
|
3036
|
+
throw new Error("If sender address is not known, addrIdx and isSigner parameres required");
|
|
3295
3037
|
}
|
|
3296
3038
|
let newActions;
|
|
3297
3039
|
if (actions instanceof core.Cell) {
|
|
@@ -3928,7 +3670,6 @@ exports.Op = Op;
|
|
|
3928
3670
|
exports.Order = Order;
|
|
3929
3671
|
exports.Txiterator = Txiterator;
|
|
3930
3672
|
exports.addressToBigInt = addressToBigInt;
|
|
3931
|
-
exports.beginMessage = beginMessage;
|
|
3932
3673
|
exports.bigintToAddress = bigintToAddress;
|
|
3933
3674
|
exports.buildOnchainMetadata = buildOnchainMetadata;
|
|
3934
3675
|
exports.cellFromArtifact = cellFromArtifact;
|
|
@@ -3941,8 +3682,14 @@ exports.extractEvents = extractEvents;
|
|
|
3941
3682
|
exports.findDeepestCell = findDeepestCell;
|
|
3942
3683
|
exports.findTransaction = findTransaction;
|
|
3943
3684
|
exports.formatCoinsPure = formatCoinsPure;
|
|
3685
|
+
exports.generateAllConstructorCodes = generateAllConstructorCodes;
|
|
3686
|
+
exports.generateAllDeconstructorCodes = generateAllDeconstructorCodes;
|
|
3687
|
+
exports.generateAllTonClassTypes = generateAllTonClassTypes;
|
|
3944
3688
|
exports.generateAllViewFunctions = generateAllViewFunctions;
|
|
3689
|
+
exports.generateConstructorCode = generateConstructorCode;
|
|
3690
|
+
exports.generateDeconstructorCode = generateDeconstructorCode;
|
|
3945
3691
|
exports.generateTestUtilsCode = generateTestUtilsCode;
|
|
3692
|
+
exports.generateTonClassType = generateTonClassType;
|
|
3946
3693
|
exports.getMsgPrices = getMsgPrices;
|
|
3947
3694
|
exports.getOpcodeCRC = getOpcodeCRC;
|
|
3948
3695
|
exports.getRandom = getRandom;
|
|
@@ -3957,10 +3704,6 @@ exports.multisigConfigToCell = multisigConfigToCell;
|
|
|
3957
3704
|
exports.orderConfigToCell = orderConfigToCell;
|
|
3958
3705
|
exports.parseDirectory = parseDirectory;
|
|
3959
3706
|
exports.printTransactionTrace = printTransactionTrace;
|
|
3960
|
-
exports.randomQueryId = randomQueryId;
|
|
3961
|
-
exports.recursiveGenConstructorCode = recursiveGenConstructorCode;
|
|
3962
|
-
exports.recursiveGenDeconstructorCode = recursiveGenDeconstructorCode;
|
|
3963
|
-
exports.recursiveGenTSTypes = recursiveGenTSTypes;
|
|
3964
3707
|
exports.saveAllTypes = saveAllTypes;
|
|
3965
3708
|
exports.saveConstantsFile = saveConstantsFile;
|
|
3966
3709
|
exports.saveEventsFile = saveEventsFile;
|
|
@@ -3968,7 +3711,6 @@ exports.saveObjectsAsTS = saveObjectsAsTS;
|
|
|
3968
3711
|
exports.saveTonContractWrapper = saveTonContractWrapper;
|
|
3969
3712
|
exports.saveTonObjectUnwrapper = saveTonObjectUnwrapper;
|
|
3970
3713
|
exports.saveViewFunctions = saveViewFunctions;
|
|
3971
|
-
exports.sendRequest = sendRequest;
|
|
3972
3714
|
exports.storageCollected = storageCollected;
|
|
3973
3715
|
exports.to32ByteBuffer = to32ByteBuffer;
|
|
3974
3716
|
//# sourceMappingURL=index.cjs.map
|