@layerzerolabs/ton-sdk-tools 3.0.81 → 3.0.83

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @layerzerolabs/ton-sdk-tools
2
2
 
3
+ ## 3.0.83
4
+
5
+ ### Patch Changes
6
+
7
+ - 6f36477: add flags for ton sdk to print tx log
8
+
9
+ ## 3.0.82
10
+
11
+ ### Patch Changes
12
+
13
+ - e0e402e: animechain
14
+
3
15
  ## 3.0.81
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -329,7 +329,6 @@ function parseClasses(strInput) {
329
329
  const name = rawName.replace(/::New$/, "");
330
330
  const functionName = snakeToCamelCase("getnew_" + name);
331
331
  const [fieldMap, inverseFieldMap] = parseFieldNames(strInput);
332
- console.log(`Parsing ${name}...`);
333
332
  const tonNameRegex = /const int\s+(?:md::)?[\w:]+::NAME = "(.*?)"u;/;
334
333
  const tonNameMatch = strInput.match(tonNameRegex);
335
334
  const tonName = tonNameMatch ? tonNameMatch[1] : name;
@@ -1373,8 +1372,6 @@ import {
1373
1372
  keyMap,
1374
1373
  } from '${options.relativeSrcPath}'
1375
1374
 
1376
- const RECURSIVE_DECODE = false
1377
-
1378
1375
  export const ActionTypes: { [key: string]: bigint } = {
1379
1376
  increment: BigInt(1),
1380
1377
  aba: BigInt(2),
@@ -5980,6 +5977,12 @@ var JettonWallet = class _JettonWallet {
5980
5977
  return res.balance;
5981
5978
  }
5982
5979
  };
5980
+ function setLzTonSdkWriteToConsole(enabled) {
5981
+ process.env.LZ_TON_SDK_WRITE_TO_CONSOLE = enabled.toString();
5982
+ }
5983
+ function setLzTonSdkSaveToJson(enabled) {
5984
+ process.env.LZ_TON_SDK_SAVE_TO_JSON = enabled.toString();
5985
+ }
5983
5986
  var decimalCount = 9;
5984
5987
  var decimal = pow10(decimalCount);
5985
5988
  var defaultPath = "gasInfo";
@@ -6031,58 +6034,62 @@ function formatCoins(value, precision = 6) {
6031
6034
  function printTransactionTrace(transactions, opcodeInfo, callerStack, profile) {
6032
6035
  const { stack } = new Error();
6033
6036
  callerStack ?? (callerStack = stack);
6034
- console.info(callerStack?.split("\n")[2].trim());
6035
6037
  let cumulativeFees = 0n;
6036
6038
  let gasInfo = {};
6037
6039
  let filePath = profile?.filePath ?? defaultPath;
6038
- if (profile?.profileGas) {
6040
+ const shouldProfileGas = profile?.profileGas ?? process.env.LZ_TON_SDK_SAVE_TO_JSON === "true";
6041
+ const shouldWriteToConsole = profile?.writeToConsole ?? process.env.LZ_TON_SDK_WRITE_TO_CONSOLE === "true";
6042
+ if (shouldProfileGas) {
6039
6043
  createDirectoryIfNotExist(filePath);
6040
- filePath = path__namespace.default.join(filePath, `${profile.fileName}.json`);
6044
+ filePath = path__namespace.default.join(filePath, `${profile?.fileName ?? "gasInfo"}.json`);
6041
6045
  gasInfo = readOrCreateJsonFile(filePath);
6042
6046
  }
6043
- console.table(
6044
- transactions.map((tx) => {
6045
- if (tx.description.type !== "generic") return void 0;
6046
- const body = tx.inMessage?.info.type === "internal" ? tx.inMessage.body.beginParse() : void 0;
6047
- const op = body === void 0 ? 0n : body.remainingBits >= 32 ? body.preloadUint(32) : 0n;
6048
- const totalFees = formatCoins(tx.totalFees.coins);
6049
- const computeFees = formatCoins(
6050
- tx.description.computePhase.type === "vm" ? tx.description.computePhase.gasFees : void 0
6051
- );
6052
- const totalFwdFees = formatCoins(tx.description.actionPhase?.totalFwdFees ?? void 0);
6053
- formatCoins(
6054
- tx.inMessage?.info.type === "internal" ? tx.inMessage.info.value.coins : void 0
6055
- );
6056
- formatCoins(
6057
- tx.outMessages.values().reduce(
6058
- (total, message) => total + (message.info.type === "internal" ? message.info.value.coins : 0n),
6059
- 0n
6060
- )
6061
- );
6062
- const forwardIn = formatCoins(
6063
- tx.inMessage?.info.type === "internal" ? tx.inMessage.info.forwardFee : void 0
6064
- );
6065
- const addressString = tx.address.toString(16).length != 64 ? "UNKNOWN" : core.Address.parseRaw("1:" + tx.address.toString(16));
6066
- const opString = op.toString() in opcodeInfo ? opcodeInfo[op.toString()] : op.toString();
6067
- cumulativeFees += tx.totalFees.coins + (tx.description.actionPhase?.totalFwdFees ?? 0n);
6068
- if (profile?.profileGas) gasInfo[opString] = formatCoins(cumulativeFees);
6069
- return {
6070
- address: addressString,
6071
- op: opString,
6072
- // valueIn,
6073
- // valueOut,
6074
- totalFees,
6075
- inForwardFee: forwardIn,
6076
- outForwardFee: totalFwdFees,
6077
- // outActions: tx.description.actionPhase?.totalActions ?? 'N/A',
6078
- computeFee: computeFees,
6079
- // exitCode: tx.description.computePhase.type === 'vm' ? tx.description.computePhase.exitCode : 'N/A',
6080
- // actionCode: tx.description.actionPhase?.resultCode ?? 'N/A',
6081
- cumulativeFee: formatCoins(cumulativeFees)
6082
- };
6083
- }).filter((v) => v !== void 0)
6084
- );
6085
- if (profile?.profileGas) sortAndSave(filePath, gasInfo);
6047
+ if (shouldWriteToConsole) {
6048
+ console.info(callerStack?.split("\n")[2].trim());
6049
+ console.table(
6050
+ transactions.map((tx) => {
6051
+ if (tx.description.type !== "generic") return void 0;
6052
+ const body = tx.inMessage?.info.type === "internal" ? tx.inMessage.body.beginParse() : void 0;
6053
+ const op = body === void 0 ? 0n : body.remainingBits >= 32 ? body.preloadUint(32) : 0n;
6054
+ const totalFees = formatCoins(tx.totalFees.coins);
6055
+ const computeFees = formatCoins(
6056
+ tx.description.computePhase.type === "vm" ? tx.description.computePhase.gasFees : void 0
6057
+ );
6058
+ const totalFwdFees = formatCoins(tx.description.actionPhase?.totalFwdFees ?? void 0);
6059
+ formatCoins(
6060
+ tx.inMessage?.info.type === "internal" ? tx.inMessage.info.value.coins : void 0
6061
+ );
6062
+ formatCoins(
6063
+ tx.outMessages.values().reduce(
6064
+ (total, message) => total + (message.info.type === "internal" ? message.info.value.coins : 0n),
6065
+ 0n
6066
+ )
6067
+ );
6068
+ const forwardIn = formatCoins(
6069
+ tx.inMessage?.info.type === "internal" ? tx.inMessage.info.forwardFee : void 0
6070
+ );
6071
+ const addressString = tx.address.toString(16).length != 64 ? "UNKNOWN" : core.Address.parseRaw("1:" + tx.address.toString(16));
6072
+ const opString = op.toString() in opcodeInfo ? opcodeInfo[op.toString()] : op.toString();
6073
+ cumulativeFees += tx.totalFees.coins + (tx.description.actionPhase?.totalFwdFees ?? 0n);
6074
+ if (shouldProfileGas) gasInfo[opString] = formatCoins(cumulativeFees);
6075
+ return {
6076
+ address: addressString,
6077
+ op: opString,
6078
+ // valueIn,
6079
+ // valueOut,
6080
+ totalFees,
6081
+ inForwardFee: forwardIn,
6082
+ outForwardFee: totalFwdFees,
6083
+ // outActions: tx.description.actionPhase?.totalActions ?? 'N/A',
6084
+ computeFee: computeFees,
6085
+ // exitCode: tx.description.computePhase.type === 'vm' ? tx.description.computePhase.exitCode : 'N/A',
6086
+ // actionCode: tx.description.actionPhase?.resultCode ?? 'N/A',
6087
+ cumulativeFee: formatCoins(cumulativeFees)
6088
+ };
6089
+ }).filter((v) => v !== void 0)
6090
+ );
6091
+ }
6092
+ if (shouldProfileGas) sortAndSave(filePath, gasInfo);
6086
6093
  }
6087
6094
  async function sendMessageViaMultisigAndExpect({
6088
6095
  blockchain,
@@ -6267,6 +6274,8 @@ exports.saveTonObjectUnwrapper = saveTonObjectUnwrapper;
6267
6274
  exports.saveViewFunctions = saveViewFunctions;
6268
6275
  exports.sendInternalMessageAndExpect = sendInternalMessageAndExpect;
6269
6276
  exports.sendMessageViaMultisigAndExpect = sendMessageViaMultisigAndExpect;
6277
+ exports.setLzTonSdkSaveToJson = setLzTonSdkSaveToJson;
6278
+ exports.setLzTonSdkWriteToConsole = setLzTonSdkWriteToConsole;
6270
6279
  exports.storageCollected = storageCollected;
6271
6280
  exports.to32ByteBuffer = to32ByteBuffer;
6272
6281
  exports.toHaveTransactions = toHaveTransactions;