@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.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from 'fs';
|
|
|
2
2
|
import fs__default from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import path__default from 'path';
|
|
5
|
-
import { Cell,
|
|
5
|
+
import { Cell, Address, SendMode, beginCell, contractAddress, Dictionary, toNano } from '@ton/core';
|
|
6
6
|
import { toBigIntBE, toBufferBE } from 'bigint-buffer';
|
|
7
7
|
import * as crc32 from 'crc-32';
|
|
8
8
|
import { extractEvents as extractEvents$1 } from '@ton/sandbox/dist/event/Event';
|
|
@@ -17,20 +17,6 @@ function getOpcodeCRC(input) {
|
|
|
17
17
|
var MASTER_CHAIN_ID = -1;
|
|
18
18
|
var BASE_CHAIN_ID = 0;
|
|
19
19
|
var MASTER_CHAIN_SHARD = "8000000000000000";
|
|
20
|
-
function randomQueryId() {
|
|
21
|
-
return Math.floor(Math.random() * 1e11);
|
|
22
|
-
}
|
|
23
|
-
function beginMessage(opcode, queryId) {
|
|
24
|
-
return beginCell().storeUint(opcode, 32).storeUint(queryId ?? randomQueryId(), 64);
|
|
25
|
-
}
|
|
26
|
-
async function sendRequest(provider, via, request) {
|
|
27
|
-
return provider.internal(via, {
|
|
28
|
-
value: request.value,
|
|
29
|
-
sendMode: request.sendMode ?? void 0,
|
|
30
|
-
body: request.body,
|
|
31
|
-
bounce: request.bounce
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
20
|
function bigintToAddress(value) {
|
|
35
21
|
const buf = to32ByteBuffer(value);
|
|
36
22
|
return Address.parse(`0:${buf.toString("hex")}`);
|
|
@@ -78,7 +64,7 @@ function findDeepestCell(cell) {
|
|
|
78
64
|
// src/sdk-tools.ts
|
|
79
65
|
var file_signature_header = `////// Generated by sdk/sdk-generator.ts`;
|
|
80
66
|
var ERRORCODE_MASK = 0x7ffn;
|
|
81
|
-
function tonTypeToTStype(tonType
|
|
67
|
+
function tonTypeToTStype(tonType) {
|
|
82
68
|
switch (tonType) {
|
|
83
69
|
case "int":
|
|
84
70
|
case "uint8":
|
|
@@ -90,19 +76,15 @@ function tonTypeToTStype(tonType, addr_type = "Slice", force_cell = false) {
|
|
|
90
76
|
case "bool":
|
|
91
77
|
case "address":
|
|
92
78
|
return "bigint";
|
|
93
|
-
case "slice":
|
|
94
|
-
return addr_type;
|
|
95
79
|
case "cell":
|
|
96
80
|
case "cellRef":
|
|
97
81
|
return "Cell";
|
|
98
82
|
case "tuple":
|
|
99
83
|
return "Tuple";
|
|
100
84
|
case "objRef":
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return "Tuple";
|
|
105
|
-
}
|
|
85
|
+
return "Cell";
|
|
86
|
+
case "slice":
|
|
87
|
+
return "Address";
|
|
106
88
|
case "dict256":
|
|
107
89
|
case "dictionary":
|
|
108
90
|
return "LzDict";
|
|
@@ -234,8 +216,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
234
216
|
{
|
|
235
217
|
constructorInputArgs: inputArgs,
|
|
236
218
|
attributes,
|
|
237
|
-
constructorIncomplete: incomplete,
|
|
238
|
-
dependencies,
|
|
239
219
|
constructorName: functionName,
|
|
240
220
|
tonName,
|
|
241
221
|
fieldMap,
|
|
@@ -245,8 +225,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
245
225
|
result[name] = {
|
|
246
226
|
constructorInputArgs: inputArgs,
|
|
247
227
|
attributes,
|
|
248
|
-
constructorIncomplete: incomplete,
|
|
249
|
-
dependencies,
|
|
250
228
|
constructorName: functionName,
|
|
251
229
|
tonName,
|
|
252
230
|
fieldMap,
|
|
@@ -256,12 +234,6 @@ function mergeConstructorDicts(result, added) {
|
|
|
256
234
|
);
|
|
257
235
|
return result;
|
|
258
236
|
}
|
|
259
|
-
function mergeInputArgs(result, added) {
|
|
260
|
-
Object.entries(added).forEach(([name, type]) => {
|
|
261
|
-
result[name] = type;
|
|
262
|
-
});
|
|
263
|
-
return result;
|
|
264
|
-
}
|
|
265
237
|
function parseDirectory(directoryPath) {
|
|
266
238
|
let result = {};
|
|
267
239
|
const items = fs.readdirSync(directoryPath);
|
|
@@ -281,58 +253,28 @@ function parseDirectory(directoryPath) {
|
|
|
281
253
|
function snakeToCamelCase(str2) {
|
|
282
254
|
return str2.replace(/::/g, "_").replace(/(_\w)/g, (match) => match[1].toUpperCase());
|
|
283
255
|
}
|
|
284
|
-
function
|
|
256
|
+
function parseDeclareLines(input, fieldMap) {
|
|
285
257
|
const psResult = [];
|
|
286
|
-
|
|
287
|
-
const setRegex = /\[\s*([a-zA-Z_][\w:]*),\s*((?:[^,\]]|\([^)]*\))*)\]/g;
|
|
288
|
-
const dependencies = [];
|
|
258
|
+
const declareLineRegex = /\[\s*([a-zA-Z_][\w:]*),\s*((?:[^,\]]|\([^)]*\))*)\]/g;
|
|
289
259
|
let key = 0;
|
|
290
260
|
let match;
|
|
291
|
-
while ((match =
|
|
261
|
+
while ((match = declareLineRegex.exec(input)) !== null && key < Object.keys(fieldMap).length) {
|
|
292
262
|
const [, argType, assignedValue] = match;
|
|
293
|
-
let depName = "";
|
|
294
|
-
const value = assignedValue.trim();
|
|
295
|
-
let which = "const";
|
|
296
|
-
if (value.includes("::New")) {
|
|
297
|
-
incomplete = true;
|
|
298
|
-
depName = value.slice(0, value.lastIndexOf("::New"));
|
|
299
|
-
dependencies.push(depName);
|
|
300
|
-
}
|
|
301
|
-
if (value.includes("::New()")) {
|
|
302
|
-
which = "constClass";
|
|
303
|
-
} else if (value.includes("::New")) {
|
|
304
|
-
which = "classWithArgs";
|
|
305
|
-
} else if (/^\d+$/.test(value)) {
|
|
306
|
-
which = "const";
|
|
307
|
-
} else {
|
|
308
|
-
switch (value) {
|
|
309
|
-
case "true":
|
|
310
|
-
case "false":
|
|
311
|
-
case "addr_none()":
|
|
312
|
-
case "new_dict()":
|
|
313
|
-
which = "const";
|
|
314
|
-
break;
|
|
315
|
-
default:
|
|
316
|
-
which = value in inputArgs && inputArgs[value].length > 0 ? "inputArg" : "const";
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
263
|
psResult.push({
|
|
320
264
|
name: key in fieldMap ? fieldMap[key].trim() : "",
|
|
321
265
|
type: argType.trim().split("::").pop() ?? "int",
|
|
322
|
-
value
|
|
323
|
-
metaType: which,
|
|
324
|
-
dependencyName: depName
|
|
266
|
+
value: assignedValue.trim()
|
|
325
267
|
});
|
|
326
268
|
key += 1;
|
|
327
269
|
}
|
|
328
|
-
return
|
|
270
|
+
return psResult;
|
|
329
271
|
}
|
|
330
|
-
function parseFieldNames(
|
|
272
|
+
function parseFieldNames(strInput) {
|
|
331
273
|
const fieldMap = {};
|
|
332
274
|
const inverseFieldMap = {};
|
|
333
275
|
const regex = /^const\s+int\s+(?:[A-Za-z]+::)?[A-Za-z]\w+::(\w+)\s*=\s*(\d+);/gm;
|
|
334
276
|
let match;
|
|
335
|
-
while ((match = regex.exec(
|
|
277
|
+
while ((match = regex.exec(strInput)) !== null) {
|
|
336
278
|
const [, fieldName, fieldIndexStr] = match;
|
|
337
279
|
const fieldIndex = parseInt(fieldIndexStr, 10);
|
|
338
280
|
fieldMap[fieldIndex] = fieldName;
|
|
@@ -340,14 +282,13 @@ function parseFieldNames(name, input) {
|
|
|
340
282
|
}
|
|
341
283
|
return [fieldMap, inverseFieldMap];
|
|
342
284
|
}
|
|
343
|
-
function parseClasses(
|
|
285
|
+
function parseClasses(strInput) {
|
|
344
286
|
const functionRegex = /(\w+(?:::\w+)*::New\w*)\s*\(([\w\s,$·]*)\)\s*·?\s*(impure)?\s*(inline\s*)?method_id\s*\{([^}]*)\}/g;
|
|
345
287
|
const results = {};
|
|
346
288
|
let match;
|
|
347
|
-
while ((match = functionRegex.exec(
|
|
289
|
+
while ((match = functionRegex.exec(strInput)) !== null) {
|
|
348
290
|
const [, rawName, argsString, , , body] = match;
|
|
349
291
|
const args = {};
|
|
350
|
-
if (rawName.includes("OFTSend")) ;
|
|
351
292
|
const argPairs = argsString.split(",").map((arg) => arg.trim());
|
|
352
293
|
for (const argPair of argPairs) {
|
|
353
294
|
const [argType, argName] = argPair.split(/\s+/);
|
|
@@ -357,17 +298,15 @@ function parseClasses(input) {
|
|
|
357
298
|
}
|
|
358
299
|
const name = rawName.replace(/::New$/, "");
|
|
359
300
|
const functionName = snakeToCamelCase("getnew_" + name);
|
|
360
|
-
const [fieldMap, inverseFieldMap] = parseFieldNames(
|
|
301
|
+
const [fieldMap, inverseFieldMap] = parseFieldNames(strInput);
|
|
361
302
|
console.log(`Parsing ${name}...`);
|
|
362
303
|
const tonNameRegex = /const int\s+(?:md::)?[\w:]+::NAME = "(.*?)"u;/;
|
|
363
|
-
const tonNameMatch =
|
|
304
|
+
const tonNameMatch = strInput.match(tonNameRegex);
|
|
364
305
|
const tonName = tonNameMatch ? tonNameMatch[1] : name;
|
|
365
|
-
const
|
|
306
|
+
const attributes = parseDeclareLines(body, fieldMap);
|
|
366
307
|
results[name] = {
|
|
367
308
|
constructorInputArgs: args,
|
|
368
309
|
attributes,
|
|
369
|
-
constructorIncomplete: incomplete,
|
|
370
|
-
dependencies,
|
|
371
310
|
constructorName: functionName,
|
|
372
311
|
tonName,
|
|
373
312
|
fieldMap,
|
|
@@ -376,8 +315,11 @@ function parseClasses(input) {
|
|
|
376
315
|
}
|
|
377
316
|
return results;
|
|
378
317
|
}
|
|
379
|
-
function saveTonContractWrapper(tonObjects, directory) {
|
|
380
|
-
const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.
|
|
318
|
+
function saveTonContractWrapper(tonObjects, directory, baseWrapper) {
|
|
319
|
+
const generatedMethods = Object.entries(tonObjects).map(([_, tonObject]) => tonObject.constructorCode ?? "").join("\n");
|
|
320
|
+
if (baseWrapper === void 0) {
|
|
321
|
+
baseWrapper = `import { BaseWrapper, SendRequestOptions } from '@layerzerolabs/ton-sdk-tools'`;
|
|
322
|
+
}
|
|
381
323
|
const savedCode = `${file_signature_header}
|
|
382
324
|
|
|
383
325
|
import {
|
|
@@ -392,8 +334,7 @@ import {
|
|
|
392
334
|
contractAddress,
|
|
393
335
|
} from '@ton/core'
|
|
394
336
|
|
|
395
|
-
|
|
396
|
-
import { beginMessage } from './utils'
|
|
337
|
+
${baseWrapper}
|
|
397
338
|
|
|
398
339
|
export type GetIntFnNames =
|
|
399
340
|
| 'cl::get<uint8>'
|
|
@@ -411,6 +352,33 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
411
352
|
return new TonContractWrapper(contractAddress(workchain, init), init)
|
|
412
353
|
}
|
|
413
354
|
|
|
355
|
+
buildRequest(
|
|
356
|
+
opCode: bigint,
|
|
357
|
+
data: Cell,
|
|
358
|
+
opts: SendRequestOptions,
|
|
359
|
+
balanceRefill = 0n,
|
|
360
|
+
queryId?: number | bigint
|
|
361
|
+
): SenderArguments {
|
|
362
|
+
const body = this.beginMessage(opCode, queryId).storeCoins(balanceRefill).storeRef(data).endCell()
|
|
363
|
+
return this.buildSenderArguments(body, opts)
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
async sendInternalMessage(
|
|
367
|
+
provider: ContractProvider,
|
|
368
|
+
via: Sender,
|
|
369
|
+
opCode: bigint,
|
|
370
|
+
md: Cell,
|
|
371
|
+
opts: SendRequestOptions,
|
|
372
|
+
balanceRefill = 0n,
|
|
373
|
+
queryId?: number | bigint
|
|
374
|
+
): Promise<void> {
|
|
375
|
+
if (via.address === undefined) {
|
|
376
|
+
throw new Error('Sender address is not defined')
|
|
377
|
+
}
|
|
378
|
+
const request = this.buildRequest(opCode, md, opts, balanceRefill, queryId)
|
|
379
|
+
return this.sendRequest(provider, via, request)
|
|
380
|
+
}
|
|
381
|
+
|
|
414
382
|
async getFieldStack(
|
|
415
383
|
provider: ContractProvider,
|
|
416
384
|
method: string,
|
|
@@ -429,11 +397,6 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
429
397
|
return provider.getState()
|
|
430
398
|
}
|
|
431
399
|
|
|
432
|
-
async getCurrentStorage(provider: ContractProvider): Promise<TupleReader> {
|
|
433
|
-
const ret = await provider.get('getContractStorage', [])
|
|
434
|
-
return ret.stack
|
|
435
|
-
}
|
|
436
|
-
|
|
437
400
|
async getCurrentStorageCell(provider: ContractProvider): Promise<Cell> {
|
|
438
401
|
const getResult = await provider.get('getContractStorage', [])
|
|
439
402
|
return getResult.stack.readCell()
|
|
@@ -497,33 +460,6 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
497
460
|
return ret.stack.readCell()
|
|
498
461
|
}
|
|
499
462
|
|
|
500
|
-
buildRequest(
|
|
501
|
-
opCode: bigint,
|
|
502
|
-
data: Cell,
|
|
503
|
-
opts: SendRequestOptions,
|
|
504
|
-
balanceRefill = 0n,
|
|
505
|
-
queryId?: number | bigint
|
|
506
|
-
): SenderArguments {
|
|
507
|
-
const body = beginMessage(opCode, queryId).storeCoins(balanceRefill).storeRef(data).endCell()
|
|
508
|
-
return this.buildSenderArguments(body, opts)
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
async sendInternalMessage(
|
|
512
|
-
provider: ContractProvider,
|
|
513
|
-
via: Sender,
|
|
514
|
-
opCode: bigint,
|
|
515
|
-
md: Cell,
|
|
516
|
-
opts: SendRequestOptions,
|
|
517
|
-
balanceRefill = 0n,
|
|
518
|
-
queryId?: number | bigint
|
|
519
|
-
): Promise<void> {
|
|
520
|
-
if (via.address === undefined) {
|
|
521
|
-
throw new Error('Sender address is not defined')
|
|
522
|
-
}
|
|
523
|
-
const request = this.buildRequest(opCode, md, opts, balanceRefill, queryId)
|
|
524
|
-
return this.sendRequest(provider, via, request)
|
|
525
|
-
}
|
|
526
|
-
|
|
527
463
|
${generatedMethods}
|
|
528
464
|
}
|
|
529
465
|
`;
|
|
@@ -838,57 +774,18 @@ ${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructor
|
|
|
838
774
|
`;
|
|
839
775
|
fs.writeFileSync(path.join(directory, "TonObjectUnwrapper.ts"), savedCode);
|
|
840
776
|
}
|
|
841
|
-
function
|
|
842
|
-
if (name in tonClasses) return tonClasses[name];
|
|
843
|
-
const lzName = "lz::" + name;
|
|
844
|
-
if (lzName in tonClasses) return tonClasses[lzName];
|
|
845
|
-
const mdName = "md::" + name;
|
|
846
|
-
if (mdName in tonClasses) return tonClasses[mdName];
|
|
847
|
-
const clName = "cl::" + name;
|
|
848
|
-
if (clName in tonClasses) return tonClasses[clName];
|
|
849
|
-
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
850
|
-
if (packetV1Key in tonClasses) return tonClasses[packetV1Key];
|
|
851
|
-
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
852
|
-
if (packetV1UnderscoreKey in tonClasses) return tonClasses[packetV1UnderscoreKey];
|
|
853
|
-
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
854
|
-
if (packetV2Key in tonClasses) return tonClasses[packetV2Key];
|
|
855
|
-
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
856
|
-
if (packetV2UnderscoreKey in tonClasses) return tonClasses[packetV2UnderscoreKey];
|
|
857
|
-
return void 0;
|
|
858
|
-
}
|
|
859
|
-
function findClassKey(tonClasses, name) {
|
|
860
|
-
if (name in tonClasses) return name;
|
|
861
|
-
const lzName = "lz::" + name;
|
|
862
|
-
if (lzName in tonClasses) return lzName;
|
|
863
|
-
const mdName = "md::" + name;
|
|
864
|
-
if (mdName in tonClasses) return mdName;
|
|
865
|
-
const clName = "cl::" + name;
|
|
866
|
-
if (clName in tonClasses) return clName;
|
|
867
|
-
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
868
|
-
if (packetV1Key in tonClasses) return packetV1Key;
|
|
869
|
-
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
870
|
-
if (packetV1UnderscoreKey in tonClasses) return packetV1UnderscoreKey;
|
|
871
|
-
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
872
|
-
if (packetV2Key in tonClasses) return packetV2Key;
|
|
873
|
-
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
874
|
-
if (packetV2UnderscoreKey in tonClasses) return packetV2UnderscoreKey;
|
|
875
|
-
return void 0;
|
|
876
|
-
}
|
|
877
|
-
function generateConstructorCodes(className, tonClasses) {
|
|
777
|
+
function generateConstructorCode(className, tonClasses) {
|
|
878
778
|
if (!(className in tonClasses)) {
|
|
879
779
|
return tonClasses;
|
|
880
780
|
}
|
|
881
781
|
const tonClass = tonClasses[className];
|
|
882
782
|
const { constructorInputArgs: inputArgs } = tonClass;
|
|
883
783
|
const fnName = snakeToCamelCase(`getNew_${className}`);
|
|
884
|
-
const scratchFnName = snakeToCamelCase(`getNew_${className}FromScratch`);
|
|
885
784
|
let methodIdName = `${className}::New`;
|
|
886
785
|
if (className.includes("::New")) {
|
|
887
786
|
methodIdName = className;
|
|
888
787
|
}
|
|
889
788
|
tonClass.constructorName = fnName;
|
|
890
|
-
tonClass.fromScratchConstructorName = scratchFnName;
|
|
891
|
-
tonClass.nonClassConstructorArgs = {};
|
|
892
789
|
tonClass.constructorCode = `
|
|
893
790
|
async ${fnName}(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
894
791
|
${Object.entries(inputArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
|
|
@@ -900,21 +797,6 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
900
797
|
]);
|
|
901
798
|
return getResult.stack.readCell()
|
|
902
799
|
}`;
|
|
903
|
-
const cellArgs = {};
|
|
904
|
-
Object.entries(inputArgs).forEach(([argName, argType]) => {
|
|
905
|
-
cellArgs[argName] = argType === "tuple" ? "cell" : argType;
|
|
906
|
-
});
|
|
907
|
-
tonClass.cellConstructorCode = `
|
|
908
|
-
async ${fnName}Cell(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
909
|
-
${Object.entries(cellArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType, "Slice", true)}`).join(",\n ")}
|
|
910
|
-
}` : ""}): Promise<Cell> {
|
|
911
|
-
const getResult = await provider.get('${methodIdName}', [
|
|
912
|
-
${Object.entries(cellArgs).map(
|
|
913
|
-
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
914
|
-
).join(",\n ")}
|
|
915
|
-
]);
|
|
916
|
-
return getResult.stack.readCell()
|
|
917
|
-
}`;
|
|
918
800
|
tonClass.constructorCodeCallGenerator = (callerArgs, _) => {
|
|
919
801
|
const missingArgs = Object.keys(inputArgs).filter((key) => !(key in callerArgs));
|
|
920
802
|
if (missingArgs.length > 0) {
|
|
@@ -925,119 +807,14 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
925
807
|
const filteredArgs = Object.entries(inputArgs).filter(([key, value]) => key in callerArgs);
|
|
926
808
|
return `await ${fnName}(provider.getSender()${filteredArgs.length > 0 ? `, { ${filteredArgs.map(([argName, argType]) => `${argName}: ${argName}`).join(", ")} }` : ""})`;
|
|
927
809
|
};
|
|
928
|
-
tonClass.flatConstructorArgs = { ...inputArgs };
|
|
929
|
-
Object.entries(tonClass.constructorInputArgs).map(([argName, argType]) => {
|
|
930
|
-
if (argType === "tuple") {
|
|
931
|
-
const tupleClass = findClass(tonClasses, argName);
|
|
932
|
-
if (tupleClass?.scratchConstructorCodeCallGenerator === void 0) {
|
|
933
|
-
const implicitDepName = findClassKey(tonClasses, argName);
|
|
934
|
-
if (implicitDepName !== void 0) {
|
|
935
|
-
generateConstructorCodes(implicitDepName, tonClasses);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
tonClass.flatConstructorArgs = mergeInputArgs(
|
|
939
|
-
tonClass.flatConstructorArgs ?? {},
|
|
940
|
-
tupleClass?.flatConstructorArgs ?? {}
|
|
941
|
-
);
|
|
942
|
-
}
|
|
943
|
-
});
|
|
944
|
-
const classArgs = {};
|
|
945
|
-
Object.entries(tonClass.flatConstructorArgs ?? {}).forEach(([argName, argType]) => {
|
|
946
|
-
if (argType === "tuple" && findClass(tonClasses, argName) !== void 0) {
|
|
947
|
-
classArgs[argName] = tonClass.flatConstructorArgs?.[argName] ?? "";
|
|
948
|
-
} else {
|
|
949
|
-
(tonClass.nonClassConstructorArgs ?? (tonClass.nonClassConstructorArgs = {}))[argName] = argType;
|
|
950
|
-
}
|
|
951
|
-
});
|
|
952
|
-
tonClass.scratchConstructorCodeCallGenerator = (parentArgs, _) => {
|
|
953
|
-
const missingArgs = Object.keys(tonClass.nonClassConstructorArgs ?? {}).filter((key) => !(key in parentArgs));
|
|
954
|
-
if (missingArgs.length > 0) {
|
|
955
|
-
console.warn(
|
|
956
|
-
`Argument(s) not provided: ${missingArgs.join(", ")}, make sure the TON constructor has default values for these arguments`
|
|
957
|
-
);
|
|
958
|
-
}
|
|
959
|
-
const filteredArgs = Object.entries(tonClass.nonClassConstructorArgs ?? {}).filter(
|
|
960
|
-
([key, value]) => key in parentArgs
|
|
961
|
-
);
|
|
962
|
-
return `await ${scratchFnName}(provider${filteredArgs.length > 0 ? `, { ${filteredArgs.map(([argName, argType]) => `${argName}: args.${argName}`).join(", ")} }` : ""})`;
|
|
963
|
-
};
|
|
964
|
-
const finalScratchArgs = { ...tonClass.nonClassConstructorArgs };
|
|
965
|
-
const insideTupleGenerationCode = Object.entries(classArgs).map(([argName, argType]) => {
|
|
966
|
-
const tupleInstanceName = argName;
|
|
967
|
-
const tupleClass = findClass(tonClasses, argName);
|
|
968
|
-
if (tupleClass !== void 0) {
|
|
969
|
-
finalScratchArgs[`${argName}INSIDE_FLAGGED`] = argType;
|
|
970
|
-
}
|
|
971
|
-
return `const ${tupleInstanceName} = ${tupleClass?.scratchConstructorCodeCallGenerator?.(tonClass.nonClassConstructorArgs ?? {}, "") ?? ""};`.replace(
|
|
972
|
-
"getNew",
|
|
973
|
-
"this.getNew"
|
|
974
|
-
);
|
|
975
|
-
}).join("\n");
|
|
976
|
-
tonClass.fromScratchConstructorCode = `
|
|
977
|
-
async ${scratchFnName}(provider: ContractProvider${Object.keys(tonClass.nonClassConstructorArgs ?? {}).length > 0 ? `, args: {
|
|
978
|
-
${Object.entries(tonClass.nonClassConstructorArgs ?? {}).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
|
|
979
|
-
}` : ""}): Promise<Tuple> {
|
|
980
|
-
${insideTupleGenerationCode}
|
|
981
|
-
const getResult = await provider.get('${className.toLowerCase()}::New', [
|
|
982
|
-
${Object.entries(finalScratchArgs).map(
|
|
983
|
-
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(tonClass.nonClassConstructorArgs ?? {}).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
984
|
-
).join(",\n ")}
|
|
985
|
-
])
|
|
986
|
-
return LzTuple(getResult.stack)
|
|
987
|
-
}`;
|
|
988
|
-
tonClass.constructorIncomplete = false;
|
|
989
810
|
tonClasses[className] = tonClass;
|
|
990
811
|
return tonClasses;
|
|
991
812
|
}
|
|
992
|
-
function
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
return classConstructors;
|
|
996
|
-
}
|
|
997
|
-
const current = classConstructors[key];
|
|
998
|
-
if (current.constructorIncomplete) {
|
|
999
|
-
current.dependencies.forEach((item) => {
|
|
1000
|
-
if (item in classConstructors) {
|
|
1001
|
-
if (classConstructors[item].constructorCode === void 0) {
|
|
1002
|
-
classConstructors = recursiveGenConstructorCode(classConstructors, item);
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
classConstructors = generateConstructorCodes(key, classConstructors);
|
|
1008
|
-
} else {
|
|
1009
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1010
|
-
if (value.constructorCode === void 0) {
|
|
1011
|
-
classConstructors = recursiveGenConstructorCode(classConstructors, key2);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
return classConstructors;
|
|
1016
|
-
}
|
|
1017
|
-
function recursiveGenTSTypes(classConstructors, key = "") {
|
|
1018
|
-
if (key != "") {
|
|
1019
|
-
if (!(key in classConstructors)) {
|
|
1020
|
-
return classConstructors;
|
|
1021
|
-
}
|
|
1022
|
-
const current = classConstructors[key];
|
|
1023
|
-
if (current.dependencies.length > 0) {
|
|
1024
|
-
current.dependencies.forEach((item) => {
|
|
1025
|
-
if (item in classConstructors) {
|
|
1026
|
-
if (classConstructors[item].tsTypeCode === void 0) {
|
|
1027
|
-
classConstructors = recursiveGenTSTypes(classConstructors, item);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
classConstructors = generateTonClassTypes(key, classConstructors);
|
|
1033
|
-
} else {
|
|
1034
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1035
|
-
if (value.tsTypeCode === void 0) {
|
|
1036
|
-
classConstructors = recursiveGenTSTypes(classConstructors, key2);
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
813
|
+
function generateAllConstructorCodes(tonClasses) {
|
|
814
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
815
|
+
generateConstructorCode(className, tonClasses);
|
|
1039
816
|
}
|
|
1040
|
-
return
|
|
817
|
+
return tonClasses;
|
|
1041
818
|
}
|
|
1042
819
|
function getTsAttributeName(name) {
|
|
1043
820
|
let modifiedName = name.replace(/::/g, "_");
|
|
@@ -1047,7 +824,7 @@ function getTsAttributeName(name) {
|
|
|
1047
824
|
}
|
|
1048
825
|
return modifiedName;
|
|
1049
826
|
}
|
|
1050
|
-
function
|
|
827
|
+
function generateTonClassType(name, tonClasses) {
|
|
1051
828
|
if (!(name in tonClasses)) {
|
|
1052
829
|
return tonClasses;
|
|
1053
830
|
}
|
|
@@ -1057,16 +834,8 @@ function generateTonClassTypes(name, tonClasses) {
|
|
|
1057
834
|
const typeName = tonClass.is_md ? "interface" : "type";
|
|
1058
835
|
const extension = tonClass.is_md ? "extends Md" : "=";
|
|
1059
836
|
tonClass.tsTypeCode = `${typeName} ${capitalizedName} ${extension} {
|
|
1060
|
-
${tonClass.attributes.map(({ name: name2, type
|
|
1061
|
-
|
|
1062
|
-
let attributeType = tonTypeToTStype(type, "Address", true);
|
|
1063
|
-
if (type === "obj_ref") {
|
|
1064
|
-
const dependantClass = findClass(tonClasses, modifiedName) ?? findClass(tonClasses, dependencyName);
|
|
1065
|
-
if (dependantClass) {
|
|
1066
|
-
attributeType = dependantClass.constructorName.replace("getNew", "");
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
return `${modifiedName}: ${attributeType};`;
|
|
837
|
+
${tonClass.attributes.map(({ name: name2, type }) => {
|
|
838
|
+
return `${getTsAttributeName(name2)}: ${tonTypeToTStype(type)};`;
|
|
1070
839
|
}).join("\n")}
|
|
1071
840
|
}
|
|
1072
841
|
|
|
@@ -1075,7 +844,13 @@ function generateTonClassTypes(name, tonClasses) {
|
|
|
1075
844
|
tonClasses[name] = tonClass;
|
|
1076
845
|
return tonClasses;
|
|
1077
846
|
}
|
|
1078
|
-
function
|
|
847
|
+
function generateAllTonClassTypes(tonClasses) {
|
|
848
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
849
|
+
generateTonClassType(className, tonClasses);
|
|
850
|
+
}
|
|
851
|
+
return tonClasses;
|
|
852
|
+
}
|
|
853
|
+
function generateDeconstructorCode(className, tonClasses) {
|
|
1079
854
|
if (!(className in tonClasses)) {
|
|
1080
855
|
return tonClasses;
|
|
1081
856
|
}
|
|
@@ -1085,18 +860,10 @@ function generateDeconstructorCodes(className, tonClasses) {
|
|
|
1085
860
|
tonClass.deconstructorName = fnName;
|
|
1086
861
|
tonClass.deconstructorCode = `
|
|
1087
862
|
static async ${fnName}(wrapper: ExtendedContract<TonContractWrapper>, cell: Cell): Promise<${tsTypeName}> {
|
|
1088
|
-
${attributes.map(({ name, type
|
|
863
|
+
${attributes.map(({ name, type }) => {
|
|
1089
864
|
const fieldTSName = getTsAttributeName(name);
|
|
1090
|
-
const tsGetterName = tsTypeToTSGetterName(tonTypeToTStype(type
|
|
865
|
+
const tsGetterName = tsTypeToTSGetterName(tonTypeToTStype(type), "wrapper");
|
|
1091
866
|
const fieldIndex = inverseFieldMap[name];
|
|
1092
|
-
if (type === "obj_ref") {
|
|
1093
|
-
const dependencyClassType = (findClass(tonClasses, dependencyName) ?? findClass(tonClasses, fieldTSName))?.tsTypeName;
|
|
1094
|
-
if (dependencyClassType !== void 0) {
|
|
1095
|
-
const depDeconstructorName = snakeToCamelCase(`get_${dependencyClassType}ToTS`);
|
|
1096
|
-
return `const ${fieldTSName}_obj = await ${tsGetterName}(cell, ${fieldIndex}n);
|
|
1097
|
-
const ${fieldTSName} = await TonObjectUnwrapper.${depDeconstructorName}(wrapper, ${fieldTSName}_obj)`;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
867
|
const tonGetterName = tonTypeToTonGetterName(type);
|
|
1101
868
|
if (tsGetterName === "getLzDict") {
|
|
1102
869
|
return `const ${fieldTSName} = await getLzDict(cell, ${fieldIndex}n, wrapper)`;
|
|
@@ -1116,34 +883,14 @@ function generateDeconstructorCodes(className, tonClasses) {
|
|
|
1116
883
|
tonClass.deconstructorCodeCallGenerator = (callerArgs, _) => {
|
|
1117
884
|
return `await ${fnName}(provider, obj)`;
|
|
1118
885
|
};
|
|
1119
|
-
tonClass.deconstructorIncomplete = false;
|
|
1120
886
|
tonClasses[className] = tonClass;
|
|
1121
887
|
return tonClasses;
|
|
1122
888
|
}
|
|
1123
|
-
function
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
return classConstructors;
|
|
1127
|
-
}
|
|
1128
|
-
const current = classConstructors[key];
|
|
1129
|
-
if (current.deconstructorIncomplete === void 0 || current.deconstructorIncomplete) {
|
|
1130
|
-
current.dependencies.forEach((item) => {
|
|
1131
|
-
if (item in classConstructors) {
|
|
1132
|
-
if (classConstructors[item].deconstructorCode === void 0) {
|
|
1133
|
-
classConstructors = recursiveGenDeconstructorCode(classConstructors, item);
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
}
|
|
1138
|
-
classConstructors = generateDeconstructorCodes(key, classConstructors);
|
|
1139
|
-
} else {
|
|
1140
|
-
for (const [key2, value] of Object.entries(classConstructors)) {
|
|
1141
|
-
if (value.deconstructorCode === void 0) {
|
|
1142
|
-
classConstructors = recursiveGenDeconstructorCode(classConstructors, key2);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
889
|
+
function generateAllDeconstructorCodes(tonClasses) {
|
|
890
|
+
for (const [className, tonClass] of Object.entries(tonClasses)) {
|
|
891
|
+
generateDeconstructorCode(className, tonClasses);
|
|
1145
892
|
}
|
|
1146
|
-
return
|
|
893
|
+
return tonClasses;
|
|
1147
894
|
}
|
|
1148
895
|
function getSpecificFiles(dirPath, includeName) {
|
|
1149
896
|
const files = [];
|
|
@@ -1325,11 +1072,11 @@ function generateAllViewFunctions(rootDir, nameWhitelist, blacklist) {
|
|
|
1325
1072
|
const [argType, argName] = argPair.split(/\s+/);
|
|
1326
1073
|
if (argName !== void 0) {
|
|
1327
1074
|
tonArgs[argName.replace("$", "")] = argType;
|
|
1328
|
-
tsArgs[argName.replace("$", "")] = tonTypeToTStype(argType
|
|
1075
|
+
tsArgs[argName.replace("$", "")] = tonTypeToTStype(argType);
|
|
1329
1076
|
}
|
|
1330
1077
|
}
|
|
1331
1078
|
const tonReturnTypes = returnType.split(",").map((type) => type.replace(/\(/g, "").replace(/\)/g, "").trim());
|
|
1332
|
-
const tsReturnTypes = tonReturnTypes.map((type) => tonTypeToTStype(type
|
|
1079
|
+
const tsReturnTypes = tonReturnTypes.map((type) => tonTypeToTStype(type));
|
|
1333
1080
|
if (!(contractName in viewFunctions)) {
|
|
1334
1081
|
viewFunctions[contractName] = [];
|
|
1335
1082
|
}
|
|
@@ -1388,6 +1135,18 @@ var BaseWrapper = class {
|
|
|
1388
1135
|
body: beginCell().endCell()
|
|
1389
1136
|
});
|
|
1390
1137
|
}
|
|
1138
|
+
async sendRequest(provider, via, request) {
|
|
1139
|
+
return provider.internal(via, {
|
|
1140
|
+
value: request.value,
|
|
1141
|
+
sendMode: request.sendMode ?? void 0,
|
|
1142
|
+
body: request.body,
|
|
1143
|
+
bounce: request.bounce
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
async getDeployed(provider) {
|
|
1147
|
+
const state = await provider.getState();
|
|
1148
|
+
return state.state.type !== "uninit";
|
|
1149
|
+
}
|
|
1391
1150
|
buildSenderArguments(body, opts) {
|
|
1392
1151
|
return {
|
|
1393
1152
|
value: BigInt(opts.value),
|
|
@@ -1398,19 +1157,9 @@ var BaseWrapper = class {
|
|
|
1398
1157
|
sendMode: opts.sendMode ?? SendMode.PAY_GAS_SEPARATELY
|
|
1399
1158
|
};
|
|
1400
1159
|
}
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
async sendArbitraryOp(provider, via, op_code, opts) {
|
|
1405
|
-
await provider.internal(via, {
|
|
1406
|
-
value: opts.value,
|
|
1407
|
-
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
1408
|
-
body: beginMessage(op_code, opts.queryId ?? randomQueryId()).endCell()
|
|
1409
|
-
});
|
|
1410
|
-
}
|
|
1411
|
-
async getDeployed(provider) {
|
|
1412
|
-
const state = await provider.getState();
|
|
1413
|
-
return state.state.type !== "uninit";
|
|
1160
|
+
beginMessage(opcode, queryId) {
|
|
1161
|
+
const randomQueryId = Math.floor(Math.random() * 1e11);
|
|
1162
|
+
return beginCell().storeUint(opcode, 32).storeUint(queryId ?? randomQueryId, 64);
|
|
1414
1163
|
}
|
|
1415
1164
|
};
|
|
1416
1165
|
function generateTestUtilsCode(directory, filename) {
|
|
@@ -1445,22 +1194,15 @@ import {
|
|
|
1445
1194
|
Order,
|
|
1446
1195
|
Profile,
|
|
1447
1196
|
TransferRequest,
|
|
1197
|
+
addressToBigInt,
|
|
1198
|
+
beginMessage,
|
|
1448
1199
|
buildOnchainMetadata,
|
|
1449
1200
|
cellFromArtifact,
|
|
1450
1201
|
getRandomInt,
|
|
1451
1202
|
printTransactionTrace,
|
|
1452
1203
|
} from '@layerzerolabs/ton-sdk-tools'
|
|
1453
1204
|
|
|
1454
|
-
import {
|
|
1455
|
-
LzDict,
|
|
1456
|
-
LzEventHandler,
|
|
1457
|
-
MdPacketSent,
|
|
1458
|
-
OPCODES,
|
|
1459
|
-
TonContractWrapper,
|
|
1460
|
-
TonObjectUnwrapper,
|
|
1461
|
-
addressToBigInt,
|
|
1462
|
-
beginMessage,
|
|
1463
|
-
} from '../src'
|
|
1205
|
+
import { LzDict, LzEventHandler, MdPacketSent, OPCODES, TonContractWrapper, TonObjectUnwrapper } from '../src'
|
|
1464
1206
|
|
|
1465
1207
|
const invertedOpcodes = Object.fromEntries(Object.entries(OPCODES).map(([key, value]) => [value.toString(), key]))
|
|
1466
1208
|
const SML_MANAGER_DEFAULT_VERSION = BigInt(1)
|
|
@@ -2063,7 +1805,7 @@ export async function commitVerificationAndExpect(
|
|
|
2063
1805
|
sender: deployer.getSender(),
|
|
2064
1806
|
contract: smlManager,
|
|
2065
1807
|
opCode: OPCODES.SmlManager_OP_SML_MANAGER_COMMIT_PACKET,
|
|
2066
|
-
md: await smlManager.
|
|
1808
|
+
md: await smlManager.getNewMdMdAddress({
|
|
2067
1809
|
md: lzPacketCell,
|
|
2068
1810
|
address: addressToBigInt(endpoint.address),
|
|
2069
1811
|
}),
|
|
@@ -2396,7 +2138,7 @@ export async function openAndDeployControllerViaMultiSig(
|
|
|
2396
2138
|
const controller: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2397
2139
|
TonContractWrapper.create(
|
|
2398
2140
|
cellFromArtifact(ControllerArtifact),
|
|
2399
|
-
await allStorages.
|
|
2141
|
+
await allStorages.getNewController({
|
|
2400
2142
|
owner: addressToBigInt(multiSigContract.address),
|
|
2401
2143
|
eid,
|
|
2402
2144
|
endpointCode: cellFromArtifact(EndpointArtifact),
|
|
@@ -2441,7 +2183,7 @@ export async function setControllerZroWalletViaMultisig(
|
|
|
2441
2183
|
multiSigContract,
|
|
2442
2184
|
messageBody: controller.buildRequest(
|
|
2443
2185
|
OPCODES.Controller_OP_SET_ZRO_WALLET,
|
|
2444
|
-
await controller.
|
|
2186
|
+
await controller.getNewMdSetAddress({
|
|
2445
2187
|
address: addressToBigInt(await zroMinter.getWalletAddress(multiSigContract.address)),
|
|
2446
2188
|
}),
|
|
2447
2189
|
{ value: toNano('1') },
|
|
@@ -2479,7 +2221,7 @@ export async function openAndDeployEndpoint(
|
|
|
2479
2221
|
const endpoint: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2480
2222
|
TonContractWrapper.create(
|
|
2481
2223
|
cellFromArtifact(EndpointArtifact),
|
|
2482
|
-
await controller.
|
|
2224
|
+
await controller.getNewEndpoint({
|
|
2483
2225
|
eid: srcEid,
|
|
2484
2226
|
dstEid: dstEid,
|
|
2485
2227
|
owner: addressToBigInt(controller.address),
|
|
@@ -2492,7 +2234,7 @@ export async function openAndDeployEndpoint(
|
|
|
2492
2234
|
multiSigContract,
|
|
2493
2235
|
messageBody: controller.buildRequest(
|
|
2494
2236
|
OPCODES.Controller_OP_DEPLOY_ENDPOINT,
|
|
2495
|
-
await controller.
|
|
2237
|
+
await controller.getNewMdDeploy({
|
|
2496
2238
|
dstEid: dstEid,
|
|
2497
2239
|
initialDeposit: toNano('1.0'),
|
|
2498
2240
|
dstOApp: BigInt(0), // the dstOApp is unused inside of the endpoint deploy call
|
|
@@ -2532,7 +2274,7 @@ export async function openAndDeployChannel(
|
|
|
2532
2274
|
const channel: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2533
2275
|
TonContractWrapper.create(
|
|
2534
2276
|
cellFromArtifact(ChannelArtifact),
|
|
2535
|
-
await srcFixture.controller.
|
|
2277
|
+
await srcFixture.controller.getNewChannel({
|
|
2536
2278
|
owner: addressToBigInt(srcFixture.controller.address),
|
|
2537
2279
|
path: srcFixture.path,
|
|
2538
2280
|
endpointAddress: addressToBigInt(srcFixture.endpoint.address),
|
|
@@ -2545,7 +2287,7 @@ export async function openAndDeployChannel(
|
|
|
2545
2287
|
sender: deployer.getSender(),
|
|
2546
2288
|
contract: srcFixture.oApp,
|
|
2547
2289
|
opCode: OPCODES.OP_DeployChannel,
|
|
2548
|
-
md: await srcFixture.controller.
|
|
2290
|
+
md: await srcFixture.controller.getNewMdDeploy({
|
|
2549
2291
|
dstEid: dstFixture.eid,
|
|
2550
2292
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2551
2293
|
initialDeposit: toNano('1'),
|
|
@@ -2585,7 +2327,7 @@ export async function openAndDeploySmlManager(
|
|
|
2585
2327
|
const smlManager: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2586
2328
|
TonContractWrapper.create(
|
|
2587
2329
|
cellFromArtifact(SmlManagerArtifact),
|
|
2588
|
-
await allStorages.
|
|
2330
|
+
await allStorages.getNewSmlManager({
|
|
2589
2331
|
owner: addressToBigInt(fixture.owner.address),
|
|
2590
2332
|
eid: fixture.eid,
|
|
2591
2333
|
version,
|
|
@@ -2626,7 +2368,7 @@ export async function openAndDeploySmlConnection(
|
|
|
2626
2368
|
const smlConnection: SandboxContract<TonContractWrapper> = blockchain.openContract(
|
|
2627
2369
|
TonContractWrapper.create(
|
|
2628
2370
|
cellFromArtifact(SmlConnectionArtifact),
|
|
2629
|
-
await allStorages.
|
|
2371
|
+
await allStorages.getNewSmlConnection({
|
|
2630
2372
|
owner: addressToBigInt(smlManager.address),
|
|
2631
2373
|
path: srcFixture.path,
|
|
2632
2374
|
})
|
|
@@ -2638,8 +2380,8 @@ export async function openAndDeploySmlConnection(
|
|
|
2638
2380
|
sender: srcFixture.owner.getSender(),
|
|
2639
2381
|
contract: srcFixture.oApp,
|
|
2640
2382
|
opCode: OPCODES.OP_DeployConnection,
|
|
2641
|
-
md: await allStorages.
|
|
2642
|
-
md: await allStorages.
|
|
2383
|
+
md: await allStorages.getNewMdMdAddress({
|
|
2384
|
+
md: await allStorages.getNewMdDeploy({
|
|
2643
2385
|
dstEid: dstFixture.eid,
|
|
2644
2386
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2645
2387
|
initialDeposit: toNano('1'),
|
|
@@ -2681,7 +2423,7 @@ export async function setDefaultEndpointConfig(
|
|
|
2681
2423
|
srcFixture: ProtocolFixture,
|
|
2682
2424
|
dstFixture: ProtocolFixture
|
|
2683
2425
|
): Promise<SendMessageResult> {
|
|
2684
|
-
const set_ep_config_md = await allStorages.
|
|
2426
|
+
const set_ep_config_md = await allStorages.getNewMdSetEpConfig({
|
|
2685
2427
|
useDefaults: BigInt(-1), // true
|
|
2686
2428
|
sendMsglibManager: addressToBigInt(sendMsglibManager.address),
|
|
2687
2429
|
receiveMsglibManager: addressToBigInt(receiveMsglibManager.address),
|
|
@@ -2694,7 +2436,7 @@ export async function setDefaultEndpointConfig(
|
|
|
2694
2436
|
multiSigContract: srcFixture.multisig,
|
|
2695
2437
|
messageBody: srcFixture.controller.buildRequest(
|
|
2696
2438
|
OPCODES.Controller_OP_SET_EP_CONFIG_DEFAULTS,
|
|
2697
|
-
await srcFixture.controller.
|
|
2439
|
+
await srcFixture.controller.getNewMdMdEid({
|
|
2698
2440
|
md: set_ep_config_md,
|
|
2699
2441
|
eid: dstFixture.eid,
|
|
2700
2442
|
}),
|
|
@@ -2740,7 +2482,7 @@ export async function addMsgLibToController(
|
|
|
2740
2482
|
multiSigContract: srcFixture.multisig,
|
|
2741
2483
|
messageBody: srcFixture.controller.buildRequest(
|
|
2742
2484
|
OPCODES.Controller_OP_ADD_MSGLIB,
|
|
2743
|
-
await srcFixture.controller.
|
|
2485
|
+
await srcFixture.controller.getNewMdAddMsglib({
|
|
2744
2486
|
msglibManagerAddress: addressToBigInt(msglibManager.address),
|
|
2745
2487
|
dstEid: dstFixture.eid,
|
|
2746
2488
|
}),
|
|
@@ -2943,14 +2685,14 @@ export async function wireChannels(
|
|
|
2943
2685
|
|
|
2944
2686
|
// ===================================generate path==================================================
|
|
2945
2687
|
|
|
2946
|
-
srcFixture.path = await allStorages.
|
|
2688
|
+
srcFixture.path = await allStorages.getNewLzPath({
|
|
2947
2689
|
srcEid: srcFixture.eid,
|
|
2948
2690
|
srcOApp: addressToBigInt(srcFixture.oApp.address),
|
|
2949
2691
|
dstEid: dstFixture.eid,
|
|
2950
2692
|
dstOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2951
2693
|
})
|
|
2952
2694
|
|
|
2953
|
-
dstFixture.path = await allStorages.
|
|
2695
|
+
dstFixture.path = await allStorages.getNewLzPath({
|
|
2954
2696
|
srcEid: dstFixture.eid,
|
|
2955
2697
|
srcOApp: addressToBigInt(dstFixture.oApp.address),
|
|
2956
2698
|
dstEid: srcFixture.eid,
|
|
@@ -3001,12 +2743,12 @@ export async function deployConfigAndRegisterSml(
|
|
|
3001
2743
|
|
|
3002
2744
|
// ===================================configure sml =====================================
|
|
3003
2745
|
|
|
3004
|
-
const set_sml_config_md = await msglibManager.
|
|
2746
|
+
const set_sml_config_md = await msglibManager.getNewMdSetSmlManagerConfig({
|
|
3005
2747
|
nativeFee,
|
|
3006
2748
|
zroFee,
|
|
3007
2749
|
})
|
|
3008
2750
|
|
|
3009
|
-
const set_sml_config_extended_md = await msglibManager.
|
|
2751
|
+
const set_sml_config_extended_md = await msglibManager.getNewMdExtendedMd({
|
|
3010
2752
|
md: set_sml_config_md,
|
|
3011
2753
|
obj: emptyObject,
|
|
3012
2754
|
forwardingAddress: BigInt(0),
|
|
@@ -3257,7 +2999,7 @@ var Multisig = class _Multisig {
|
|
|
3257
2999
|
throw new Error("Configuration is not set: use createFromConfig or loadConfiguration");
|
|
3258
3000
|
}
|
|
3259
3001
|
if (via.address !== void 0) {
|
|
3260
|
-
const addrCmp = (x) =>
|
|
3002
|
+
const addrCmp = (x) => x.equals(via.address);
|
|
3261
3003
|
addrIdx = this.configuration.signers.findIndex(addrCmp);
|
|
3262
3004
|
if (addrIdx >= 0) {
|
|
3263
3005
|
isSigner = true;
|
|
@@ -3269,7 +3011,7 @@ var Multisig = class _Multisig {
|
|
|
3269
3011
|
isSigner = false;
|
|
3270
3012
|
}
|
|
3271
3013
|
} else if (isSigner === void 0 || addrIdx == void 0) {
|
|
3272
|
-
throw new Error("If sender address is not known, addrIdx and isSigner
|
|
3014
|
+
throw new Error("If sender address is not known, addrIdx and isSigner parameres required");
|
|
3273
3015
|
}
|
|
3274
3016
|
let newActions;
|
|
3275
3017
|
if (actions instanceof Cell) {
|
|
@@ -3891,6 +3633,6 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3891
3633
|
if (profile?.profileGas) sortAndSave(filePath, gasInfo);
|
|
3892
3634
|
}
|
|
3893
3635
|
|
|
3894
|
-
export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt,
|
|
3636
|
+
export { BASE_CHAIN_ID, BaseWrapper, Errors, JettonMinter, JettonWallet, MASTER_CHAIN_ID, MASTER_CHAIN_SHARD, MultiSigErrors, MultiSigOpCodes, MultiSigParams, Multisig, Op, Order, Txiterator, addressToBigInt, bigintToAddress, buildOnchainMetadata, cellFromArtifact, computedGeneric, differentAddress, executeFrom, executeTill, extractConstants, extractEvents, findDeepestCell, findTransaction, formatCoinsPure, generateAllConstructorCodes, generateAllDeconstructorCodes, generateAllTonClassTypes, generateAllViewFunctions, generateConstructorCode, generateDeconstructorCode, generateTestUtilsCode, generateTonClassType, getMsgPrices, getOpcodeCRC, getRandom, getRandomInt, getSpecificFiles, jettonContentToCell, jettonMinterConfigToCell, jettonWalletConfigToCell, makeSnakeCell, mergeConstructorDicts, multisigConfigToCell, orderConfigToCell, parseDirectory, printTransactionTrace, saveAllTypes, saveConstantsFile, saveEventsFile, saveObjectsAsTS, saveTonContractWrapper, saveTonObjectUnwrapper, saveViewFunctions, storageCollected, to32ByteBuffer };
|
|
3895
3637
|
//# sourceMappingURL=index.mjs.map
|
|
3896
3638
|
//# sourceMappingURL=index.mjs.map
|