@layerzerolabs/ton-sdk-tools 3.0.13-ton.0 → 3.0.18-ton.0
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 +12 -0
- package/dist/index.cjs +65 -58
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +65 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -84,6 +84,18 @@ function isValidHex(str2) {
|
|
|
84
84
|
const hexRegex = /^(0x)?[0-9A-Fa-f]+$/;
|
|
85
85
|
return hexRegex.test(str2);
|
|
86
86
|
}
|
|
87
|
+
function findDeepestCell(cell) {
|
|
88
|
+
const refs = Array.from({ length: cell.refs.length }, (_, i) => cell.refs.at(i));
|
|
89
|
+
if (refs.length === 0) {
|
|
90
|
+
return { subTreeCells: 1 };
|
|
91
|
+
}
|
|
92
|
+
let size = 0;
|
|
93
|
+
for (const ref of refs) {
|
|
94
|
+
if (!ref) continue;
|
|
95
|
+
size += findDeepestCell(ref).subTreeCells;
|
|
96
|
+
}
|
|
97
|
+
return { subTreeCells: size };
|
|
98
|
+
}
|
|
87
99
|
|
|
88
100
|
// src/sdk-tools.ts
|
|
89
101
|
var file_signature_header = `////// Generated by sdk/sdk-generator.ts`;
|
|
@@ -172,6 +184,7 @@ function tsTypeToTSGetterName(tsType, wrapperName = "platonic") {
|
|
|
172
184
|
return `${wrapperName}.getClCell`;
|
|
173
185
|
case "Tuple":
|
|
174
186
|
return `${wrapperName}.getClObj`;
|
|
187
|
+
// TODO: this will definitely bite me in the future
|
|
175
188
|
case "LzDict":
|
|
176
189
|
return "getLzDict";
|
|
177
190
|
default:
|
|
@@ -478,15 +491,24 @@ export class TonContractWrapper extends BaseWrapper {
|
|
|
478
491
|
return ret.stack.readCell()
|
|
479
492
|
}
|
|
480
493
|
|
|
481
|
-
async
|
|
494
|
+
async getDictCellItem(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<Cell> {
|
|
482
495
|
const args: TupleItem[] = [
|
|
483
496
|
{ type: 'cell', cell: dict_cell },
|
|
484
497
|
{ type: 'int', value: key },
|
|
485
498
|
]
|
|
486
|
-
const ret = await provider.get('cl::dict256::get', args)
|
|
499
|
+
const ret = await provider.get('cl::dict256::get<cellRef>', args)
|
|
487
500
|
return ret.stack.readCell()
|
|
488
501
|
}
|
|
489
502
|
|
|
503
|
+
async getDictUint256Item(provider: ContractProvider, dict_cell: Cell, key: bigint): Promise<bigint> {
|
|
504
|
+
const args: TupleItem[] = [
|
|
505
|
+
{ type: 'cell', cell: dict_cell },
|
|
506
|
+
{ type: 'int', value: key },
|
|
507
|
+
]
|
|
508
|
+
const ret = await provider.get('cl::dict256::get<uint256>', args)
|
|
509
|
+
return ret.stack.readBigNumber()
|
|
510
|
+
}
|
|
511
|
+
|
|
490
512
|
async getSetDictItem(provider: ContractProvider, dict_cell: Cell, key: bigint, value: Cell): Promise<Cell> {
|
|
491
513
|
const args: TupleItem[] = [
|
|
492
514
|
{ type: 'cell', cell: dict_cell },
|
|
@@ -565,8 +587,12 @@ export class LzDict {
|
|
|
565
587
|
return new LzDict(beginCell().endCell())
|
|
566
588
|
}
|
|
567
589
|
|
|
568
|
-
async
|
|
569
|
-
return wrapper.
|
|
590
|
+
async getCell(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<Cell> {
|
|
591
|
+
return wrapper.getDictCellItem(this._cell, key)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
async getBigInt(key: bigint, wrapper: ExtendedContract<TonContractWrapper>): Promise<bigint> {
|
|
595
|
+
return wrapper.getDictUint256Item(this._cell, key)
|
|
570
596
|
}
|
|
571
597
|
|
|
572
598
|
async set(key: bigint, value: Cell, wrapper: ExtendedContract<TonContractWrapper>): Promise<void> {
|
|
@@ -835,55 +861,39 @@ ${Object.entries(tonObjects).map(([_, constructor]) => constructor.deconstructor
|
|
|
835
861
|
fs__namespace.writeFileSync(path__namespace.join(directory, "TonObjectUnwrapper.ts"), savedCode);
|
|
836
862
|
}
|
|
837
863
|
function findClass(tonClasses, name) {
|
|
838
|
-
if (name in tonClasses)
|
|
839
|
-
return tonClasses[name];
|
|
864
|
+
if (name in tonClasses) return tonClasses[name];
|
|
840
865
|
const lzName = "lz::" + name;
|
|
841
|
-
if (lzName in tonClasses)
|
|
842
|
-
return tonClasses[lzName];
|
|
866
|
+
if (lzName in tonClasses) return tonClasses[lzName];
|
|
843
867
|
const mdName = "md::" + name;
|
|
844
|
-
if (mdName in tonClasses)
|
|
845
|
-
return tonClasses[mdName];
|
|
868
|
+
if (mdName in tonClasses) return tonClasses[mdName];
|
|
846
869
|
const clName = "cl::" + name;
|
|
847
|
-
if (clName in tonClasses)
|
|
848
|
-
return tonClasses[clName];
|
|
870
|
+
if (clName in tonClasses) return tonClasses[clName];
|
|
849
871
|
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
850
|
-
if (packetV1Key in tonClasses)
|
|
851
|
-
return tonClasses[packetV1Key];
|
|
872
|
+
if (packetV1Key in tonClasses) return tonClasses[packetV1Key];
|
|
852
873
|
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
853
|
-
if (packetV1UnderscoreKey in tonClasses)
|
|
854
|
-
return tonClasses[packetV1UnderscoreKey];
|
|
874
|
+
if (packetV1UnderscoreKey in tonClasses) return tonClasses[packetV1UnderscoreKey];
|
|
855
875
|
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
856
|
-
if (packetV2Key in tonClasses)
|
|
857
|
-
return tonClasses[packetV2Key];
|
|
876
|
+
if (packetV2Key in tonClasses) return tonClasses[packetV2Key];
|
|
858
877
|
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
859
|
-
if (packetV2UnderscoreKey in tonClasses)
|
|
860
|
-
return tonClasses[packetV2UnderscoreKey];
|
|
878
|
+
if (packetV2UnderscoreKey in tonClasses) return tonClasses[packetV2UnderscoreKey];
|
|
861
879
|
return void 0;
|
|
862
880
|
}
|
|
863
881
|
function findClassKey(tonClasses, name) {
|
|
864
|
-
if (name in tonClasses)
|
|
865
|
-
return name;
|
|
882
|
+
if (name in tonClasses) return name;
|
|
866
883
|
const lzName = "lz::" + name;
|
|
867
|
-
if (lzName in tonClasses)
|
|
868
|
-
return lzName;
|
|
884
|
+
if (lzName in tonClasses) return lzName;
|
|
869
885
|
const mdName = "md::" + name;
|
|
870
|
-
if (mdName in tonClasses)
|
|
871
|
-
return mdName;
|
|
886
|
+
if (mdName in tonClasses) return mdName;
|
|
872
887
|
const clName = "cl::" + name;
|
|
873
|
-
if (clName in tonClasses)
|
|
874
|
-
return clName;
|
|
888
|
+
if (clName in tonClasses) return clName;
|
|
875
889
|
const packetV1Key = "lz::" + name.replace("packet", "packet_v1");
|
|
876
|
-
if (packetV1Key in tonClasses)
|
|
877
|
-
return packetV1Key;
|
|
890
|
+
if (packetV1Key in tonClasses) return packetV1Key;
|
|
878
891
|
const packetV1UnderscoreKey = "lz::" + name.replace("packet", "packet_v1_");
|
|
879
|
-
if (packetV1UnderscoreKey in tonClasses)
|
|
880
|
-
return packetV1UnderscoreKey;
|
|
892
|
+
if (packetV1UnderscoreKey in tonClasses) return packetV1UnderscoreKey;
|
|
881
893
|
const packetV2Key = "lz::" + name.replace("packet", "packet_v2");
|
|
882
|
-
if (packetV2Key in tonClasses)
|
|
883
|
-
return packetV2Key;
|
|
894
|
+
if (packetV2Key in tonClasses) return packetV2Key;
|
|
884
895
|
const packetV2UnderscoreKey = "lz::" + name.replace("packet", "packet_v2_");
|
|
885
|
-
if (packetV2UnderscoreKey in tonClasses)
|
|
886
|
-
return packetV2UnderscoreKey;
|
|
896
|
+
if (packetV2UnderscoreKey in tonClasses) return packetV2UnderscoreKey;
|
|
887
897
|
return void 0;
|
|
888
898
|
}
|
|
889
899
|
function generateConstructorCodes(className, tonClasses) {
|
|
@@ -894,6 +904,10 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
894
904
|
const { constructorInputArgs: inputArgs } = tonClass;
|
|
895
905
|
const fnName = snakeToCamelCase(`getNew_${className}`);
|
|
896
906
|
const scratchFnName = snakeToCamelCase(`getNew_${className}FromScratch`);
|
|
907
|
+
let methodIdName = `${className}::New`;
|
|
908
|
+
if (className.includes("::New")) {
|
|
909
|
+
methodIdName = className;
|
|
910
|
+
}
|
|
897
911
|
tonClass.constructorName = fnName;
|
|
898
912
|
tonClass.fromScratchConstructorName = scratchFnName;
|
|
899
913
|
tonClass.nonClassConstructorArgs = {};
|
|
@@ -901,7 +915,7 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
901
915
|
async ${fnName}(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
902
916
|
${Object.entries(inputArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType)}`).join(",\n ")}
|
|
903
917
|
}` : ""}): Promise<Cell> {
|
|
904
|
-
const getResult = await provider.get('${
|
|
918
|
+
const getResult = await provider.get('${methodIdName}', [
|
|
905
919
|
${Object.entries(inputArgs).map(
|
|
906
920
|
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
907
921
|
).join(",\n ")}
|
|
@@ -916,7 +930,7 @@ function generateConstructorCodes(className, tonClasses) {
|
|
|
916
930
|
async ${fnName}Cell(provider: ContractProvider${Object.keys(inputArgs).length > 0 ? `, args: {
|
|
917
931
|
${Object.entries(cellArgs).map(([argName, argType]) => `${argName}: ${tonTypeToTStype(argType, "Slice", true)}`).join(",\n ")}
|
|
918
932
|
}` : ""}): Promise<Cell> {
|
|
919
|
-
const getResult = await provider.get('${
|
|
933
|
+
const getResult = await provider.get('${methodIdName}', [
|
|
920
934
|
${Object.entries(cellArgs).map(
|
|
921
935
|
([argName, argType]) => `{ type: '${tonTypeToTupleType(argType)}', ${tonTypeToTupleValueName(argType)}: ${tonTypeToTupleValue(Object.keys(inputArgs).length > 0 ? `args.${argName}` : argName, argType)} }`
|
|
922
936
|
).join(",\n ")}
|
|
@@ -1438,8 +1452,8 @@ import { FlatTransactionComparable } from '@ton/test-utils'
|
|
|
1438
1452
|
import ChannelArtifact from '@layerzerolabs/layerzero-v2-ton/build/Channel.compiled.json'
|
|
1439
1453
|
import ControllerArtifact from '@layerzerolabs/layerzero-v2-ton/build/Controller.compiled.json'
|
|
1440
1454
|
import EndpointArtifact from '@layerzerolabs/layerzero-v2-ton/build/Endpoint.compiled.json'
|
|
1441
|
-
import MultiSigArtifact from '@layerzerolabs/layerzero-v2-ton/
|
|
1442
|
-
import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/
|
|
1455
|
+
import MultiSigArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSig.compiled.json'
|
|
1456
|
+
import MultiSigOrderArtifact from '@layerzerolabs/layerzero-v2-ton/src/multisig/bocs/MultiSigOrder.compiled.json'
|
|
1443
1457
|
import SmlConnectionArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlConnection.compiled.json'
|
|
1444
1458
|
import SmlManagerArtifact from '@layerzerolabs/layerzero-v2-ton/build/SmlManager.compiled.json'
|
|
1445
1459
|
import ZroMinterArtifact from '@layerzerolabs/layerzero-v2-ton/build/ZroMinter.compiled.json'
|
|
@@ -2664,7 +2678,7 @@ export async function openAndDeploySmlConnection(
|
|
|
2664
2678
|
{
|
|
2665
2679
|
from: srcFixture.oApp.address,
|
|
2666
2680
|
to: smlManager.address,
|
|
2667
|
-
op: Number(OPCODES.
|
|
2681
|
+
op: Number(OPCODES.MsglibManager_OP_DEPLOY_CONNECTION),
|
|
2668
2682
|
success: true,
|
|
2669
2683
|
},
|
|
2670
2684
|
{
|
|
@@ -3437,15 +3451,12 @@ var getMsgPrices = (configRaw, workchain) => {
|
|
|
3437
3451
|
};
|
|
3438
3452
|
};
|
|
3439
3453
|
var storageCollected = (trans) => {
|
|
3440
|
-
if (trans.description.type !== "generic")
|
|
3441
|
-
throw new Error("Expected generic transaction");
|
|
3454
|
+
if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
|
|
3442
3455
|
return trans.description.storagePhase ? trans.description.storagePhase.storageFeesCollected : 0n;
|
|
3443
3456
|
};
|
|
3444
3457
|
var computedGeneric = (trans) => {
|
|
3445
|
-
if (trans.description.type !== "generic")
|
|
3446
|
-
|
|
3447
|
-
if (trans.description.computePhase.type !== "vm")
|
|
3448
|
-
throw new Error("Compute phase expected");
|
|
3458
|
+
if (trans.description.type !== "generic") throw new Error("Expected generic transaction");
|
|
3459
|
+
if (trans.description.computePhase.type !== "vm") throw new Error("Compute phase expected");
|
|
3449
3460
|
return trans.description.computePhase;
|
|
3450
3461
|
};
|
|
3451
3462
|
var Txiterator = class {
|
|
@@ -3462,8 +3473,7 @@ var Txiterator = class {
|
|
|
3462
3473
|
throw new Error("MsgQueued is undefined");
|
|
3463
3474
|
}
|
|
3464
3475
|
const inMsg = curMsg.msg;
|
|
3465
|
-
if (inMsg.info.type !== "internal")
|
|
3466
|
-
throw new Error("Internal only");
|
|
3476
|
+
if (inMsg.info.type !== "internal") throw new Error("Internal only");
|
|
3467
3477
|
const smc = await this.blockchain.getContract(inMsg.info.dest);
|
|
3468
3478
|
const res = await smc.receiveMessage(inMsg, { now: this.blockchain.now });
|
|
3469
3479
|
const bcRes = {
|
|
@@ -3843,8 +3853,7 @@ function formatCoinsPure(value, precision = 6) {
|
|
|
3843
3853
|
return `${whole.toString()}${frac !== 0n ? "." + frac.toString().padStart(precision, "0").replace(/0+$/, "") : ""}`;
|
|
3844
3854
|
}
|
|
3845
3855
|
function formatCoins(value, precision = 6) {
|
|
3846
|
-
if (value === void 0)
|
|
3847
|
-
return "N/A";
|
|
3856
|
+
if (value === void 0) return "N/A";
|
|
3848
3857
|
return formatCoinsPure(value, precision);
|
|
3849
3858
|
}
|
|
3850
3859
|
function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
@@ -3861,8 +3870,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3861
3870
|
}
|
|
3862
3871
|
console.table(
|
|
3863
3872
|
transactions.map((tx) => {
|
|
3864
|
-
if (tx.description.type !== "generic")
|
|
3865
|
-
return void 0;
|
|
3873
|
+
if (tx.description.type !== "generic") return void 0;
|
|
3866
3874
|
const body = tx.inMessage?.info.type === "internal" ? tx.inMessage.body.beginParse() : void 0;
|
|
3867
3875
|
const op = body === void 0 ? 0n : body.remainingBits >= 32 ? body.preloadUint(32) : 0n;
|
|
3868
3876
|
const totalFees = formatCoins(tx.totalFees.coins);
|
|
@@ -3885,8 +3893,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3885
3893
|
const addressString = tx.address.toString(16).length != 64 ? "UNKNOWN" : core.Address.parseRaw("1:" + tx.address.toString(16));
|
|
3886
3894
|
const opString = op.toString() in opcodeInfo ? opcodeInfo[op.toString()] : op.toString();
|
|
3887
3895
|
cumulativeFees += tx.totalFees.coins + (tx.description.actionPhase?.totalFwdFees ?? 0n);
|
|
3888
|
-
if (profile?.profileGas)
|
|
3889
|
-
gasInfo[opString] = formatCoins(cumulativeFees);
|
|
3896
|
+
if (profile?.profileGas) gasInfo[opString] = formatCoins(cumulativeFees);
|
|
3890
3897
|
return {
|
|
3891
3898
|
address: addressString,
|
|
3892
3899
|
op: opString,
|
|
@@ -3903,8 +3910,7 @@ function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
|
|
|
3903
3910
|
};
|
|
3904
3911
|
}).filter((v) => v !== void 0)
|
|
3905
3912
|
);
|
|
3906
|
-
if (profile?.profileGas)
|
|
3907
|
-
sortAndSave(filePath, gasInfo);
|
|
3913
|
+
if (profile?.profileGas) sortAndSave(filePath, gasInfo);
|
|
3908
3914
|
}
|
|
3909
3915
|
|
|
3910
3916
|
exports.BASE_CHAIN_ID = BASE_CHAIN_ID;
|
|
@@ -3932,6 +3938,7 @@ exports.executeFrom = executeFrom;
|
|
|
3932
3938
|
exports.executeTill = executeTill;
|
|
3933
3939
|
exports.extractConstants = extractConstants;
|
|
3934
3940
|
exports.extractEvents = extractEvents;
|
|
3941
|
+
exports.findDeepestCell = findDeepestCell;
|
|
3935
3942
|
exports.findTransaction = findTransaction;
|
|
3936
3943
|
exports.formatCoinsPure = formatCoinsPure;
|
|
3937
3944
|
exports.generateAllViewFunctions = generateAllViewFunctions;
|
|
@@ -3964,5 +3971,5 @@ exports.saveViewFunctions = saveViewFunctions;
|
|
|
3964
3971
|
exports.sendRequest = sendRequest;
|
|
3965
3972
|
exports.storageCollected = storageCollected;
|
|
3966
3973
|
exports.to32ByteBuffer = to32ByteBuffer;
|
|
3967
|
-
//# sourceMappingURL=
|
|
3974
|
+
//# sourceMappingURL=index.cjs.map
|
|
3968
3975
|
//# sourceMappingURL=index.cjs.map
|