@tonappchain/sdk 0.7.1-frost-test-1 → 0.7.2-alpha-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/dist/artifacts/dev/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/JettonMinter.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/JettonProxy.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/JettonWallet.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/NFTItem.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/build/NFTProxy.compiled.json +1 -1
- package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.d.ts +1 -0
- package/dist/artifacts/dev/ton/internal/wrappers/CrossChainLayer.js +15 -5
- package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.d.ts +2 -2
- package/dist/artifacts/dev/ton/internal/wrappers/JettonMinter.js +2 -2
- package/dist/artifacts/testnet/ton/internal/build/CrossChainLayer.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/Executor.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonMinter.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonProxy.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/JettonWallet.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/NFTItem.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/build/NFTProxy.compiled.json +1 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.d.ts +13 -1
- package/dist/artifacts/testnet/ton/internal/wrappers/CrossChainLayer.js +45 -7
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.d.ts +2 -2
- package/dist/artifacts/testnet/ton/internal/wrappers/JettonMinter.js +2 -2
- package/dist/src/adapters/contractOpener.d.ts +4 -0
- package/dist/src/adapters/contractOpener.js +165 -1
- package/dist/src/adapters/retryableContractOpener.d.ts +5 -1
- package/dist/src/adapters/retryableContractOpener.js +36 -7
- package/dist/src/assets/AssetFactory.js +8 -2
- package/dist/src/assets/FT.d.ts +1 -1
- package/dist/src/assets/FT.js +1 -1
- package/dist/src/assets/NFT.d.ts +1 -1
- package/dist/src/assets/NFT.js +1 -1
- package/dist/src/assets/TON.d.ts +3 -2
- package/dist/src/assets/TON.js +2 -1
- package/dist/src/errors/instances.d.ts +2 -0
- package/dist/src/errors/instances.js +3 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +2 -4
- package/dist/src/interfaces/Asset.d.ts +4 -9
- package/dist/src/interfaces/ContractOpener.d.ts +5 -1
- package/dist/src/interfaces/ISimulator.d.ts +15 -1
- package/dist/src/interfaces/ITONTransactionManager.d.ts +20 -1
- package/dist/src/interfaces/ITacSDK.d.ts +10 -1
- package/dist/src/interfaces/ITxFinalizer.d.ts +5 -0
- package/dist/src/interfaces/ITxFinalizer.js +2 -0
- package/dist/src/interfaces/WalletInstanse.d.ts +4 -8
- package/dist/src/sdk/Consts.d.ts +50 -1
- package/dist/src/sdk/Consts.js +52 -2
- package/dist/src/sdk/Simulator.d.ts +11 -2
- package/dist/src/sdk/Simulator.js +190 -0
- package/dist/src/sdk/StartTracking.d.ts +5 -3
- package/dist/src/sdk/StartTracking.js +60 -40
- package/dist/src/sdk/TONTransactionManager.d.ts +8 -5
- package/dist/src/sdk/TONTransactionManager.js +49 -6
- package/dist/src/sdk/TacSdk.d.ts +2 -1
- package/dist/src/sdk/TacSdk.js +7 -1
- package/dist/src/sdk/TxFinalizer.d.ts +15 -4
- package/dist/src/sdk/TxFinalizer.js +102 -23
- package/dist/src/sdk/Utils.d.ts +10 -1
- package/dist/src/sdk/Utils.js +48 -0
- package/dist/src/sender/BatchSender.js +19 -0
- package/dist/src/sender/MockSender.d.ts +2 -0
- package/dist/src/sender/MockSender.js +13 -0
- package/dist/src/sender/RawSender.js +34 -1
- package/dist/src/sender/SenderFactory.js +1 -1
- package/dist/src/sender/TonConnectSender.js +2 -0
- package/dist/src/sender/index.d.ts +1 -0
- package/dist/src/sender/index.js +1 -0
- package/dist/src/structs/InternalStruct.d.ts +45 -1
- package/dist/src/structs/Struct.d.ts +29 -2
- package/dist/src/wrappers/HighloadWalletV3.d.ts +5 -3
- package/dist/src/wrappers/HighloadWalletV3.js +14 -3
- package/package.json +3 -4
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import type { Contract, ContractProvider, MessageRelaxed, SendMode } from '@ton/ton';
|
|
1
|
+
import type { Cell, Contract, ContractProvider, MessageRelaxed, SendMode } from '@ton/ton';
|
|
2
2
|
export interface WalletInstanse extends Contract {
|
|
3
3
|
/**
|
|
4
4
|
* Returns current wallet seqno, used for nonce/ordering.
|
|
5
5
|
* @param provider Contract provider to query the wallet.
|
|
6
6
|
*/
|
|
7
7
|
getSeqno(provider: ContractProvider): Promise<number>;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* @param provider Contract provider used to send the transfer.
|
|
11
|
-
* @param args Transfer arguments including seqno, secretKey, messages and sendMode.
|
|
12
|
-
*/
|
|
13
|
-
sendTransfer(provider: ContractProvider, args: {
|
|
8
|
+
send(provider: ContractProvider, msg: Cell): Promise<string | void>;
|
|
9
|
+
createTransfer(args: {
|
|
14
10
|
seqno: number;
|
|
15
11
|
secretKey: Buffer;
|
|
16
12
|
messages: MessageRelaxed[];
|
|
17
13
|
sendMode: SendMode;
|
|
18
14
|
timeout?: number;
|
|
19
|
-
}):
|
|
15
|
+
}): Cell;
|
|
20
16
|
}
|
package/dist/src/sdk/Consts.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const TRANSACTION_TON_AMOUNT: bigint;
|
|
2
1
|
export declare const JETTON_TRANSFER_FORWARD_TON_AMOUNT: bigint;
|
|
3
2
|
export declare const NFT_TRANSFER_FORWARD_TON_AMOUNT: bigint;
|
|
4
3
|
export declare const MAX_ITERATION_COUNT = 120;
|
|
@@ -11,5 +10,55 @@ export declare const MAX_MSG_DEPTH = 512;
|
|
|
11
10
|
export declare const TON_SYMBOL = "TON";
|
|
12
11
|
export declare const TAC_SYMBOL = "TAC";
|
|
13
12
|
export declare const FIFTEEN_MINUTES: number;
|
|
13
|
+
export declare const ONE_YEAR_SECONDS: number;
|
|
14
14
|
export declare const TON_DECIMALS = 9;
|
|
15
15
|
export declare const TAC_DECIMALS = 18;
|
|
16
|
+
export declare const TON_BURN_ADDRESS = "EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c";
|
|
17
|
+
export declare const FIXED_POINT_SHIFT: number;
|
|
18
|
+
export declare const CONTRACT_FEE_USAGE_PARAMS: {
|
|
19
|
+
crossChainLayer: {
|
|
20
|
+
accountBits: number;
|
|
21
|
+
accountCells: number;
|
|
22
|
+
gas: {
|
|
23
|
+
tvmMsgToEvm: number;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
jettonWallet: {
|
|
27
|
+
accountBits: number;
|
|
28
|
+
accountCells: number;
|
|
29
|
+
gas: {
|
|
30
|
+
internalTransfer: number;
|
|
31
|
+
receive: number;
|
|
32
|
+
burn: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
jettonProxy: {
|
|
36
|
+
accountbits: number;
|
|
37
|
+
accountCells: number;
|
|
38
|
+
gas: {
|
|
39
|
+
ownershipAssigned: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
jettonMinter: {
|
|
43
|
+
accountBits: number;
|
|
44
|
+
accountCells: number;
|
|
45
|
+
gas: {
|
|
46
|
+
burnNotification: number;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
nftItem: {
|
|
50
|
+
accountBits: number;
|
|
51
|
+
accountCells: number;
|
|
52
|
+
gas: {
|
|
53
|
+
send: number;
|
|
54
|
+
burn: number;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
nftProxy: {
|
|
58
|
+
accountBits: number;
|
|
59
|
+
accountCells: number;
|
|
60
|
+
gas: {
|
|
61
|
+
ownershipAssigned: number;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
package/dist/src/sdk/Consts.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TAC_DECIMALS = exports.TON_DECIMALS = exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT =
|
|
3
|
+
exports.CONTRACT_FEE_USAGE_PARAMS = exports.FIXED_POINT_SHIFT = exports.TON_BURN_ADDRESS = exports.TAC_DECIMALS = exports.TON_DECIMALS = exports.ONE_YEAR_SECONDS = exports.FIFTEEN_MINUTES = exports.TAC_SYMBOL = exports.TON_SYMBOL = exports.MAX_MSG_DEPTH = exports.MAX_HIGHLOAD_GROUP_MSG_NUM = exports.MAX_EXT_MSG_SIZE = exports.SOLIDITY_METHOD_NAME_REGEX = exports.SOLIDITY_SIGNATURE_REGEX = exports.DEFAULT_DELAY = exports.MAX_ITERATION_COUNT = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
|
-
exports.TRANSACTION_TON_AMOUNT = (0, ton_1.toNano)(0.55);
|
|
6
5
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
7
6
|
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
|
|
8
7
|
exports.MAX_ITERATION_COUNT = 120;
|
|
@@ -15,5 +14,56 @@ exports.MAX_MSG_DEPTH = 512;
|
|
|
15
14
|
exports.TON_SYMBOL = 'TON';
|
|
16
15
|
exports.TAC_SYMBOL = 'TAC';
|
|
17
16
|
exports.FIFTEEN_MINUTES = 15 * 60 * 1000;
|
|
17
|
+
exports.ONE_YEAR_SECONDS = 365 * 24 * 3600;
|
|
18
18
|
exports.TON_DECIMALS = 9;
|
|
19
19
|
exports.TAC_DECIMALS = 18;
|
|
20
|
+
exports.TON_BURN_ADDRESS = 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c';
|
|
21
|
+
// FEES
|
|
22
|
+
exports.FIXED_POINT_SHIFT = 2 ** 16;
|
|
23
|
+
exports.CONTRACT_FEE_USAGE_PARAMS = {
|
|
24
|
+
crossChainLayer: {
|
|
25
|
+
accountBits: 43514,
|
|
26
|
+
accountCells: 100,
|
|
27
|
+
gas: {
|
|
28
|
+
tvmMsgToEvm: 14619,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
jettonWallet: {
|
|
32
|
+
accountBits: 949,
|
|
33
|
+
accountCells: 3,
|
|
34
|
+
gas: {
|
|
35
|
+
internalTransfer: 10669,
|
|
36
|
+
receive: 11427,
|
|
37
|
+
burn: 8653,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
jettonProxy: {
|
|
41
|
+
accountbits: 7760,
|
|
42
|
+
accountCells: 16,
|
|
43
|
+
gas: {
|
|
44
|
+
ownershipAssigned: 8515,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
jettonMinter: {
|
|
48
|
+
accountBits: 10208,
|
|
49
|
+
accountCells: 28,
|
|
50
|
+
gas: {
|
|
51
|
+
burnNotification: 10357,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
nftItem: {
|
|
55
|
+
accountBits: 1422,
|
|
56
|
+
accountCells: 5,
|
|
57
|
+
gas: {
|
|
58
|
+
send: 11722,
|
|
59
|
+
burn: 11552,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
nftProxy: {
|
|
63
|
+
accountBits: 7512,
|
|
64
|
+
accountCells: 15,
|
|
65
|
+
gas: {
|
|
66
|
+
ownershipAssigned: 7688,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IConfiguration, ILogger, IOperationTracker, ISimulator } from '../interfaces';
|
|
1
|
+
import { Asset, IConfiguration, ILogger, IOperationTracker, ISimulator } from '../interfaces';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import { CrosschainTx, ExecutionFeeEstimationResult } from '../structs/Struct';
|
|
3
|
+
import { CrosschainTx, ExecutionFeeEstimationResult, GeneratePayloadParams } from '../structs/Struct';
|
|
4
4
|
export declare class Simulator implements ISimulator {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly operationTracker;
|
|
@@ -8,4 +8,13 @@ export declare class Simulator implements ISimulator {
|
|
|
8
8
|
constructor(config: IConfiguration, operationTracker: IOperationTracker, logger?: ILogger);
|
|
9
9
|
getSimulationsInfo(sender: SenderAbstraction, txs: CrosschainTx[]): Promise<ExecutionFeeEstimationResult[]>;
|
|
10
10
|
getSimulationInfo(sender: SenderAbstraction, tx: CrosschainTx): Promise<ExecutionFeeEstimationResult>;
|
|
11
|
+
private calculateTONFees;
|
|
12
|
+
private calculateTransactionPipeline;
|
|
13
|
+
private calculateTONCrosschainFee;
|
|
14
|
+
private calculateJettonTransferCrosschainFee;
|
|
15
|
+
private calculateJettonBurnCrosschainFee;
|
|
16
|
+
private calculateNftTransferCrosschainFee;
|
|
17
|
+
private calculateNftBurnCrosschainFee;
|
|
18
|
+
estimateTONFees(assets: Asset[], params: GeneratePayloadParams): bigint;
|
|
19
|
+
estimateTONFee(asset: Asset, params: GeneratePayloadParams): bigint;
|
|
11
20
|
}
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Simulator = void 0;
|
|
4
4
|
const ton_1 = require("@ton/ton");
|
|
5
|
+
const assets_1 = require("../assets");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const instances_1 = require("../errors/instances");
|
|
8
|
+
const Struct_1 = require("../structs/Struct");
|
|
9
|
+
const Consts_1 = require("./Consts");
|
|
5
10
|
const Logger_1 = require("./Logger");
|
|
6
11
|
const Utils_1 = require("./Utils");
|
|
7
12
|
const Validator_1 = require("./Validator");
|
|
@@ -66,5 +71,190 @@ class Simulator {
|
|
|
66
71
|
}
|
|
67
72
|
return { feeParams, simulation };
|
|
68
73
|
}
|
|
74
|
+
calculateTONFees({
|
|
75
|
+
// Contract usage
|
|
76
|
+
accountBits, accountCells, timeDelta,
|
|
77
|
+
// Message size
|
|
78
|
+
msgBits, msgCells,
|
|
79
|
+
// Gas and computation
|
|
80
|
+
gasUsed,
|
|
81
|
+
// Config values (defaults for BaseChain)
|
|
82
|
+
bitPricePs = 1, cellPricePs = 500, lumpPrice = 400000, gasPrice = 400, firstFrac = 21845, ihrPriceFactor = 0, }) {
|
|
83
|
+
// Storage Fee (nanotons)
|
|
84
|
+
const storageFee = Math.ceil(((accountBits * bitPricePs + accountCells * cellPricePs) * timeDelta) / Consts_1.FIXED_POINT_SHIFT);
|
|
85
|
+
// Computation Fee (nanotons)
|
|
86
|
+
const computeFee = gasUsed * gasPrice;
|
|
87
|
+
// Forwarding Fee (nanotons)
|
|
88
|
+
const msgFwdFees = lumpPrice + Math.ceil((bitPricePs * msgBits + cellPricePs * msgCells) / Consts_1.FIXED_POINT_SHIFT);
|
|
89
|
+
const ihrFwdFees = Math.ceil((msgFwdFees * ihrPriceFactor) / Consts_1.FIXED_POINT_SHIFT);
|
|
90
|
+
const totalFwdFees = msgFwdFees + ihrFwdFees;
|
|
91
|
+
// Action Fee (nanotons)
|
|
92
|
+
const actionFee = Math.floor((msgFwdFees * firstFrac) / Consts_1.FIXED_POINT_SHIFT);
|
|
93
|
+
// Combine all fees
|
|
94
|
+
const totalFees = BigInt(storageFee) + BigInt(computeFee) + BigInt(actionFee) + BigInt(totalFwdFees);
|
|
95
|
+
return totalFees;
|
|
96
|
+
}
|
|
97
|
+
calculateTransactionPipeline(steps) {
|
|
98
|
+
return steps.reduce((total, step) => total + this.calculateTONFees(step), 0n);
|
|
99
|
+
}
|
|
100
|
+
calculateTONCrosschainFee(msgBits, msgCells) {
|
|
101
|
+
return this.calculateTransactionPipeline([
|
|
102
|
+
{
|
|
103
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountBits,
|
|
104
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountCells,
|
|
105
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.gas.tvmMsgToEvm,
|
|
106
|
+
msgBits,
|
|
107
|
+
msgCells,
|
|
108
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
}
|
|
112
|
+
calculateJettonTransferCrosschainFee(msgBits, msgCells) {
|
|
113
|
+
return this.calculateTransactionPipeline([
|
|
114
|
+
{
|
|
115
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountBits,
|
|
116
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountCells,
|
|
117
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.gas.internalTransfer,
|
|
118
|
+
msgBits,
|
|
119
|
+
msgCells,
|
|
120
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountBits,
|
|
124
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountCells,
|
|
125
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.gas.receive,
|
|
126
|
+
msgBits,
|
|
127
|
+
msgCells,
|
|
128
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonProxy.accountbits,
|
|
132
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonProxy.accountCells,
|
|
133
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonProxy.gas.ownershipAssigned,
|
|
134
|
+
msgBits,
|
|
135
|
+
msgCells,
|
|
136
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountBits,
|
|
140
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountCells,
|
|
141
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.gas.tvmMsgToEvm,
|
|
142
|
+
msgBits,
|
|
143
|
+
msgCells,
|
|
144
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
calculateJettonBurnCrosschainFee(msgBits, msgCells) {
|
|
149
|
+
return this.calculateTransactionPipeline([
|
|
150
|
+
{
|
|
151
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountBits,
|
|
152
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.accountCells,
|
|
153
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonWallet.gas.burn,
|
|
154
|
+
msgBits,
|
|
155
|
+
msgCells,
|
|
156
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonMinter.accountBits,
|
|
160
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonMinter.accountCells,
|
|
161
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.jettonMinter.gas.burnNotification,
|
|
162
|
+
msgBits,
|
|
163
|
+
msgCells,
|
|
164
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountBits,
|
|
168
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountCells,
|
|
169
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.gas.tvmMsgToEvm,
|
|
170
|
+
msgBits,
|
|
171
|
+
msgCells,
|
|
172
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
calculateNftTransferCrosschainFee(msgBits, msgCells) {
|
|
177
|
+
return this.calculateTransactionPipeline([
|
|
178
|
+
{
|
|
179
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.accountBits,
|
|
180
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.accountCells,
|
|
181
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.gas.send,
|
|
182
|
+
msgBits,
|
|
183
|
+
msgCells,
|
|
184
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftProxy.accountBits,
|
|
188
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftProxy.accountCells,
|
|
189
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftProxy.gas.ownershipAssigned,
|
|
190
|
+
msgBits,
|
|
191
|
+
msgCells,
|
|
192
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountBits,
|
|
196
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountCells,
|
|
197
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.gas.tvmMsgToEvm,
|
|
198
|
+
msgBits,
|
|
199
|
+
msgCells,
|
|
200
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
201
|
+
},
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
calculateNftBurnCrosschainFee(msgBits, msgCells) {
|
|
205
|
+
return this.calculateTransactionPipeline([
|
|
206
|
+
{
|
|
207
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.accountBits,
|
|
208
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.accountCells,
|
|
209
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.nftItem.gas.burn,
|
|
210
|
+
msgBits,
|
|
211
|
+
msgCells,
|
|
212
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
accountBits: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountBits,
|
|
216
|
+
accountCells: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.accountCells,
|
|
217
|
+
gasUsed: Consts_1.CONTRACT_FEE_USAGE_PARAMS.crossChainLayer.gas.tvmMsgToEvm,
|
|
218
|
+
msgBits,
|
|
219
|
+
msgCells,
|
|
220
|
+
timeDelta: Consts_1.ONE_YEAR_SECONDS,
|
|
221
|
+
},
|
|
222
|
+
]);
|
|
223
|
+
}
|
|
224
|
+
estimateTONFees(assets, params) {
|
|
225
|
+
return assets.reduce((totalFees, asset) => totalFees + this.estimateTONFee(asset, params), 0n);
|
|
226
|
+
}
|
|
227
|
+
estimateTONFee(asset, params) {
|
|
228
|
+
const payload = asset.generatePayload(params);
|
|
229
|
+
const { bits: msgBits, cells: msgCells } = (0, Utils_1.recurisivelyCollectCellStats)(payload);
|
|
230
|
+
switch (asset.type) {
|
|
231
|
+
case Struct_1.AssetType.FT:
|
|
232
|
+
if (asset instanceof assets_1.TON) {
|
|
233
|
+
// Pipeline: wallet -> ccl -> log
|
|
234
|
+
return this.calculateTONCrosschainFee(msgBits, msgCells);
|
|
235
|
+
}
|
|
236
|
+
if (asset.origin === Struct_1.Origin.TON) {
|
|
237
|
+
// Pipeline: wallet -> jetton wallet -> jetton wallet -> jetton proxy -> ccl -> log
|
|
238
|
+
return this.calculateJettonTransferCrosschainFee(msgBits, msgCells);
|
|
239
|
+
}
|
|
240
|
+
if (asset.origin === Struct_1.Origin.TAC) {
|
|
241
|
+
// Pipeline: wallet -> jetton wallet -> jetton minter -> ccl -> log
|
|
242
|
+
return this.calculateJettonBurnCrosschainFee(msgBits, msgCells);
|
|
243
|
+
}
|
|
244
|
+
throw (0, instances_1.unknownAssetOriginError)(asset.origin);
|
|
245
|
+
case Struct_1.AssetType.NFT:
|
|
246
|
+
if (asset.origin === Struct_1.Origin.TON) {
|
|
247
|
+
// Pipeline: wallet -> nft item -> nft proxy -> ccl -> log
|
|
248
|
+
return this.calculateNftTransferCrosschainFee(msgBits, msgCells);
|
|
249
|
+
}
|
|
250
|
+
if (asset.origin === Struct_1.Origin.TAC) {
|
|
251
|
+
// Pipeline: wallet -> nft item -> ccl -> log
|
|
252
|
+
return this.calculateNftBurnCrosschainFee(msgBits, msgCells);
|
|
253
|
+
}
|
|
254
|
+
throw (0, instances_1.unknownAssetOriginError)(asset.origin);
|
|
255
|
+
default:
|
|
256
|
+
throw (0, errors_1.unknownTokenTypeError)(asset.type);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
69
259
|
}
|
|
70
260
|
exports.Simulator = Simulator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILogger } from '../interfaces';
|
|
2
|
-
import {
|
|
2
|
+
import { ITxFinalizer } from '../interfaces/ITxFinalizer';
|
|
3
3
|
import { ExecutionStages, Network, TransactionLinker } from '../structs/Struct';
|
|
4
4
|
export declare function startTracking(transactionLinker: TransactionLinker, network: Network, options?: {
|
|
5
5
|
customLiteSequencerEndpoints?: string[];
|
|
@@ -7,8 +7,9 @@ export declare function startTracking(transactionLinker: TransactionLinker, netw
|
|
|
7
7
|
maxIterationCount?: number;
|
|
8
8
|
returnValue?: boolean;
|
|
9
9
|
tableView?: boolean;
|
|
10
|
-
txFinalizerConfig?: TxFinalizerConfig;
|
|
11
10
|
logger?: ILogger;
|
|
11
|
+
txFinalizer?: ITxFinalizer;
|
|
12
|
+
cclAddress?: string;
|
|
12
13
|
}): Promise<void | ExecutionStages>;
|
|
13
14
|
export declare function startTrackingMultiple(transactionLinkers: TransactionLinker[], network: Network, options?: {
|
|
14
15
|
customLiteSequencerEndpoints?: string[];
|
|
@@ -16,6 +17,7 @@ export declare function startTrackingMultiple(transactionLinkers: TransactionLin
|
|
|
16
17
|
maxIterationCount?: number;
|
|
17
18
|
returnValue?: boolean;
|
|
18
19
|
tableView?: boolean;
|
|
19
|
-
txFinalizerConfig?: TxFinalizerConfig;
|
|
20
20
|
logger?: ILogger;
|
|
21
|
+
txFinalizer?: ITxFinalizer;
|
|
21
22
|
}): Promise<void | ExecutionStages[]>;
|
|
23
|
+
export declare function printExecutionStagesTable(stages: ExecutionStages, logger: ILogger): void;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.startTracking = startTracking;
|
|
7
4
|
exports.startTrackingMultiple = startTrackingMultiple;
|
|
8
|
-
|
|
5
|
+
exports.printExecutionStagesTable = printExecutionStagesTable;
|
|
9
6
|
const Struct_1 = require("../structs/Struct");
|
|
10
7
|
const Consts_1 = require("./Consts");
|
|
11
8
|
const Logger_1 = require("./Logger");
|
|
12
9
|
const OperationTracker_1 = require("./OperationTracker");
|
|
13
|
-
const TxFinalizer_1 = require("./TxFinalizer");
|
|
14
10
|
const Utils_1 = require("./Utils");
|
|
15
11
|
async function startTracking(transactionLinker, network, options) {
|
|
16
|
-
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true,
|
|
12
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, logger = new Logger_1.NoopLogger(), txFinalizer, cclAddress, } = options || {};
|
|
17
13
|
const tracker = new OperationTracker_1.OperationTracker(network, customLiteSequencerEndpoints, logger);
|
|
18
14
|
logger.debug('Start tracking operation');
|
|
19
15
|
logger.debug('caller: ' + transactionLinker.caller);
|
|
@@ -70,13 +66,12 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
70
66
|
// Check if EXECUTED_IN_TON stage exists and use TxFinalizer to verify transaction success
|
|
71
67
|
if (profilingData.executedInTON.exists && profilingData.executedInTON.stageData?.transactions) {
|
|
72
68
|
logger.debug('EXECUTED_IN_TON stage found, verifying transaction success in TON...');
|
|
73
|
-
if (
|
|
74
|
-
const txFinalizer = new TxFinalizer_1.TonTxFinalizer(txFinalizerConfig, logger);
|
|
69
|
+
if (txFinalizer && cclAddress) {
|
|
75
70
|
const transactions = profilingData.executedInTON.stageData.transactions;
|
|
76
71
|
for (const tx of transactions) {
|
|
77
72
|
try {
|
|
78
73
|
logger.debug(`Verifying transaction: ${tx.hash}`);
|
|
79
|
-
await txFinalizer.trackTransactionTree(tx.hash);
|
|
74
|
+
await txFinalizer.trackTransactionTree(cclAddress, tx.hash, { maxDepth: 10 });
|
|
80
75
|
logger.debug(`Transaction ${tx.hash} verified successfully in TON`);
|
|
81
76
|
}
|
|
82
77
|
catch (error) {
|
|
@@ -104,7 +99,7 @@ async function startTracking(transactionLinker, network, options) {
|
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
107
|
-
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true,
|
|
102
|
+
const { customLiteSequencerEndpoints, delay = 10, maxIterationCount = Consts_1.MAX_ITERATION_COUNT, returnValue = false, tableView = true, txFinalizer, logger = new Logger_1.NoopLogger(), } = options || {};
|
|
108
103
|
logger.debug(`Start tracking ${transactionLinkers.length} operations`);
|
|
109
104
|
const results = await Promise.all(transactionLinkers.map((linker, index) => {
|
|
110
105
|
logger.debug(`\nProcessing operation ${index + 1}/${transactionLinkers.length}`);
|
|
@@ -114,7 +109,7 @@ async function startTrackingMultiple(transactionLinkers, network, options) {
|
|
|
114
109
|
maxIterationCount,
|
|
115
110
|
returnValue: true,
|
|
116
111
|
tableView: false,
|
|
117
|
-
|
|
112
|
+
txFinalizer,
|
|
118
113
|
logger,
|
|
119
114
|
});
|
|
120
115
|
}));
|
|
@@ -160,35 +155,60 @@ function formatExecutionStages(stages) {
|
|
|
160
155
|
bytesError: data.exists && data.stageData && data.stageData.note != null ? data.stageData.note.internalBytesError : '-',
|
|
161
156
|
}));
|
|
162
157
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
'
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Simple table formatter that works in both browser and Node.js without external dependencies
|
|
160
|
+
*/
|
|
161
|
+
function createSimpleTable(headers, rows, colWidths) {
|
|
162
|
+
const lines = [];
|
|
163
|
+
// Helper to truncate and pad text to fit column width
|
|
164
|
+
const fitToWidth = (text, width) => {
|
|
165
|
+
// Handle multi-line text by taking only the first line for table cell
|
|
166
|
+
const firstLine = text.split('\n')[0];
|
|
167
|
+
if (firstLine.length > width - 2) {
|
|
168
|
+
return firstLine.substring(0, width - 5) + '...';
|
|
169
|
+
}
|
|
170
|
+
return firstLine.padEnd(width, ' ');
|
|
171
|
+
};
|
|
172
|
+
// Create separator line
|
|
173
|
+
const separator = '+' + colWidths.map((w) => '-'.repeat(w)).join('+') + '+';
|
|
174
|
+
// Create header row
|
|
175
|
+
const headerRow = '|' + headers.map((h, i) => fitToWidth(h, colWidths[i])).join('|') + '|';
|
|
176
|
+
lines.push(separator);
|
|
177
|
+
lines.push(headerRow);
|
|
178
|
+
lines.push(separator);
|
|
179
|
+
// Create data rows
|
|
180
|
+
rows.forEach((row) => {
|
|
181
|
+
const dataRow = '|' + row.map((cell, i) => fitToWidth(cell, colWidths[i])).join('|') + '|';
|
|
182
|
+
lines.push(dataRow);
|
|
178
183
|
});
|
|
184
|
+
lines.push(separator);
|
|
185
|
+
return lines.join('\n');
|
|
186
|
+
}
|
|
187
|
+
function printExecutionStagesTable(stages, logger) {
|
|
188
|
+
const headers = [
|
|
189
|
+
'Stage',
|
|
190
|
+
'Exists',
|
|
191
|
+
'Success',
|
|
192
|
+
'Timestamp',
|
|
193
|
+
'Transactions',
|
|
194
|
+
'NoteContent',
|
|
195
|
+
'ErrorName',
|
|
196
|
+
'InternalMsg',
|
|
197
|
+
'BytesError',
|
|
198
|
+
];
|
|
199
|
+
const colWidths = [30, 8, 9, 13, 70, 13, 13, 13, 13];
|
|
179
200
|
const tableData = formatExecutionStages(stages);
|
|
180
|
-
tableData.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
logger.debug(table.toString());
|
|
201
|
+
const rows = tableData.map((row) => [
|
|
202
|
+
row.stage,
|
|
203
|
+
row.exists,
|
|
204
|
+
row.success,
|
|
205
|
+
row.timestamp,
|
|
206
|
+
row.transactions,
|
|
207
|
+
row.noteContent,
|
|
208
|
+
row.errorName,
|
|
209
|
+
row.internalMsg,
|
|
210
|
+
row.bytesError,
|
|
211
|
+
]);
|
|
212
|
+
const table = createSimpleTable(headers, rows, colWidths);
|
|
213
|
+
logger.debug(table);
|
|
194
214
|
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { IConfiguration, ILogger, IOperationTracker, ISimulator, ITONTransactionManager } from '../interfaces';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { Asset, IConfiguration, ILogger, IOperationTracker, ISimulator, ITONTransactionManager } from '../interfaces';
|
|
2
|
+
import { ITxFinalizer } from '../interfaces/ITxFinalizer';
|
|
3
|
+
import { type SenderAbstraction } from '../sender';
|
|
4
|
+
import { BatchCrossChainTx, CrossChainPayloadResult, CrossChainTransactionOptions, CrossChainTransactionsOptions, CrosschainTx, EvmProxyMsg, FeeParams, TransactionLinkerWithOperationId } from '../structs/Struct';
|
|
4
5
|
export declare class TONTransactionManager implements ITONTransactionManager {
|
|
5
6
|
private readonly config;
|
|
6
7
|
private readonly simulator;
|
|
7
8
|
private readonly operationTracker;
|
|
8
9
|
private readonly logger;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
private readonly txFinalizer;
|
|
11
|
+
constructor(config: IConfiguration, simulator: ISimulator, operationTracker: IOperationTracker, logger: ILogger | undefined, txFinalizer: ITxFinalizer);
|
|
12
|
+
buildFeeParams(options: CrossChainTransactionOptions, evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<FeeParams>;
|
|
11
13
|
private prepareCrossChainTransaction;
|
|
12
14
|
private generateCrossChainMessages;
|
|
13
15
|
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<TransactionLinkerWithOperationId>;
|
|
14
16
|
sendCrossChainTransactions(sender: SenderAbstraction, txs: BatchCrossChainTx[], options?: CrossChainTransactionsOptions): Promise<TransactionLinkerWithOperationId[]>;
|
|
15
17
|
private prepareBatchTransactions;
|
|
16
18
|
private waitForOperationIds;
|
|
19
|
+
prepareCrossChainTransactionPayload(evmProxyMsg: EvmProxyMsg, senderAddress: string, assets?: Asset[], options?: CrossChainTransactionOptions): Promise<CrossChainPayloadResult[]>;
|
|
17
20
|
}
|