@tonappchain/sdk 0.7.3-rc2 → 0.7.3-rc4
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/src/assets/FT.d.ts +3 -2
- package/dist/src/assets/FT.js +29 -13
- package/dist/src/assets/NFT.d.ts +4 -2
- package/dist/src/assets/NFT.js +6 -2
- package/dist/src/assets/TAC.d.ts +2 -1
- package/dist/src/assets/TAC.js +1 -0
- package/dist/src/assets/TON.d.ts +2 -1
- package/dist/src/assets/TON.js +1 -0
- package/dist/src/interfaces/Asset.d.ts +2 -1
- package/dist/src/interfaces/ILiteSequencerClient.d.ts +3 -1
- package/dist/src/interfaces/IOperationTracker.d.ts +7 -1
- package/dist/src/sdk/Consts.d.ts +15 -0
- package/dist/src/sdk/Consts.js +18 -1
- package/dist/src/sdk/Fees.d.ts +0 -1
- package/dist/src/sdk/Fees.js +1 -2
- package/dist/src/sdk/LiteSequencerClient.d.ts +2 -1
- package/dist/src/sdk/LiteSequencerClient.js +15 -20
- package/dist/src/sdk/OperationTracker.d.ts +2 -1
- package/dist/src/sdk/OperationTracker.js +18 -0
- package/dist/src/sdk/Simulator.d.ts +5 -0
- package/dist/src/sdk/Simulator.js +51 -5
- package/dist/src/structs/InternalStruct.d.ts +1 -5
- package/dist/src/structs/Struct.d.ts +9 -0
- package/dist/src/structs/Struct.js +7 -1
- package/package.json +1 -1
package/dist/src/assets/FT.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ import { Cell, OpenedContract } from '@ton/ton';
|
|
|
3
3
|
import { JettonMinterData, JettonWallet } from '../../artifacts/tonTypes';
|
|
4
4
|
import { Asset, IConfiguration } from '../interfaces';
|
|
5
5
|
import { AssetOpType } from '../structs/InternalStruct';
|
|
6
|
-
import { AssetType, BlockchainType, EVMAddress, FeeParams, FTOriginAndData, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
|
|
7
|
-
import { Origin } from '../structs/Struct';
|
|
6
|
+
import { AssetFeeMode, AssetType, BlockchainType, EVMAddress, FeeParams, FTOriginAndData, Origin, TVMAddress, UserWalletBalanceExtended } from '../structs/Struct';
|
|
8
7
|
export declare class FT implements Asset {
|
|
9
8
|
private _tvmAddress;
|
|
10
9
|
readonly type: AssetType;
|
|
11
10
|
readonly origin: Origin;
|
|
11
|
+
readonly feeMode: AssetFeeMode;
|
|
12
12
|
private _configuration;
|
|
13
13
|
private _jettonMinter;
|
|
14
14
|
private _decimals;
|
|
@@ -26,6 +26,7 @@ export declare class FT implements Asset {
|
|
|
26
26
|
static getTVMAddress(configuration: IConfiguration, address: EVMAddress): Promise<string>;
|
|
27
27
|
static getEVMAddress(configuration: IConfiguration, address: TVMAddress): Promise<string>;
|
|
28
28
|
private constructor();
|
|
29
|
+
private static resolveFeeMode;
|
|
29
30
|
private static getTACDecimals;
|
|
30
31
|
static fromAddress(configuration: IConfiguration, address: TVMAddress | EVMAddress): Promise<FT>;
|
|
31
32
|
get rawAmount(): bigint;
|
package/dist/src/assets/FT.js
CHANGED
|
@@ -9,7 +9,6 @@ const Utils_1 = require("../sdk/Utils");
|
|
|
9
9
|
const Validator_1 = require("../sdk/Validator");
|
|
10
10
|
const InternalStruct_1 = require("../structs/InternalStruct");
|
|
11
11
|
const Struct_1 = require("../structs/Struct");
|
|
12
|
-
const Struct_2 = require("../structs/Struct");
|
|
13
12
|
const ContentUtils_1 = require("../wrappers/ContentUtils");
|
|
14
13
|
class FT {
|
|
15
14
|
get address() {
|
|
@@ -37,7 +36,7 @@ class FT {
|
|
|
37
36
|
const jettonMinter = configuration.TONParams.contractOpener.open(configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(ton_1.Address.parse(address)));
|
|
38
37
|
if (!jettonMinterCode.equals(thisCode)) {
|
|
39
38
|
const jettonData = await jettonMinter.getJettonData();
|
|
40
|
-
return { origin:
|
|
39
|
+
return { origin: Struct_1.Origin.TON, jettonMinter, jettonData };
|
|
41
40
|
}
|
|
42
41
|
const evmAddress = await jettonMinter.getEVMTokenAddress();
|
|
43
42
|
const expectedMinterAddress = await (0, Utils_1.calculateContractAddress)(jettonMinterCode, (0, ton_1.beginCell)()
|
|
@@ -50,9 +49,9 @@ class FT {
|
|
|
50
49
|
.endCell());
|
|
51
50
|
if (!expectedMinterAddress.equals(ton_1.Address.parse(address))) {
|
|
52
51
|
const jettonData = await jettonMinter.getJettonData();
|
|
53
|
-
return { origin:
|
|
52
|
+
return { origin: Struct_1.Origin.TON, jettonMinter, jettonData };
|
|
54
53
|
}
|
|
55
|
-
return { origin:
|
|
54
|
+
return { origin: Struct_1.Origin.TAC, jettonMinter, evmAddress };
|
|
56
55
|
}
|
|
57
56
|
static async getTVMAddress(configuration, address) {
|
|
58
57
|
Validator_1.Validator.validateEVMAddress(address);
|
|
@@ -75,7 +74,7 @@ class FT {
|
|
|
75
74
|
static async getEVMAddress(configuration, address) {
|
|
76
75
|
const tokenAddressString = ton_1.Address.parse(address).toString({ bounceable: true });
|
|
77
76
|
const origin = await FT.getOrigin(configuration, address);
|
|
78
|
-
if (origin ===
|
|
77
|
+
if (origin === Struct_1.Origin.TON) {
|
|
79
78
|
return configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
|
|
80
79
|
}
|
|
81
80
|
else {
|
|
@@ -83,7 +82,7 @@ class FT {
|
|
|
83
82
|
return givenMinter.getEVMTokenAddress();
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
|
-
constructor(address, origin, configuration, decimals) {
|
|
85
|
+
constructor(address, origin, configuration, decimals, feeMode) {
|
|
87
86
|
this.type = Struct_1.AssetType.FT;
|
|
88
87
|
this._displayMultiplierNumerator = 1n;
|
|
89
88
|
this._displayMultiplierDenominator = 1n;
|
|
@@ -93,9 +92,25 @@ class FT {
|
|
|
93
92
|
this._configuration = configuration;
|
|
94
93
|
this._jettonMinter = this._configuration.TONParams.contractOpener.open(configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(this._tvmAddress));
|
|
95
94
|
this.origin = origin;
|
|
95
|
+
this.feeMode = feeMode;
|
|
96
96
|
this._transferAmount = 0n;
|
|
97
97
|
this._decimals = decimals;
|
|
98
98
|
}
|
|
99
|
+
static resolveFeeMode(origin, jettonData) {
|
|
100
|
+
if (origin === Struct_1.Origin.TAC) {
|
|
101
|
+
return Struct_1.AssetFeeMode.TAC_ORIGINAL;
|
|
102
|
+
}
|
|
103
|
+
if (!jettonData) {
|
|
104
|
+
return Struct_1.AssetFeeMode.LEGACY;
|
|
105
|
+
}
|
|
106
|
+
const walletCodeHash = jettonData.walletCode.hash().toString('hex').toLowerCase();
|
|
107
|
+
for (const hash of Consts_1.DYNAMIC_JETTON_WALLET_CODE_HASHES) {
|
|
108
|
+
if (hash.toLowerCase() === walletCodeHash) {
|
|
109
|
+
return Struct_1.AssetFeeMode.DYNAMIC;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Struct_1.AssetFeeMode.LEGACY;
|
|
113
|
+
}
|
|
99
114
|
static async getTACDecimals(configuration, evmAddress) {
|
|
100
115
|
const nativeTACAddress = await configuration.nativeTACAddress();
|
|
101
116
|
if (evmAddress === nativeTACAddress) {
|
|
@@ -111,13 +126,13 @@ class FT {
|
|
|
111
126
|
const { origin, jettonMinter, evmAddress: cachedEvmAddress, jettonData, } = await this.getOriginAndData(configuration, tvmAddress).catch((e) => {
|
|
112
127
|
if (e instanceof errors_1.ContractError) {
|
|
113
128
|
const jettonMinter = configuration.TONParams.contractOpener.open(configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(ton_1.Address.parse(tvmAddress)));
|
|
114
|
-
return { origin:
|
|
129
|
+
return { origin: Struct_1.Origin.TAC, jettonMinter, evmAddress: undefined, jettonData: undefined };
|
|
115
130
|
}
|
|
116
131
|
throw e;
|
|
117
132
|
});
|
|
118
133
|
let decimals;
|
|
119
134
|
let finalEvmAddress;
|
|
120
|
-
if (origin ===
|
|
135
|
+
if (origin === Struct_1.Origin.TON) {
|
|
121
136
|
if (!jettonData) {
|
|
122
137
|
throw errors_1.missingJettonDataError;
|
|
123
138
|
}
|
|
@@ -135,7 +150,8 @@ class FT {
|
|
|
135
150
|
finalEvmAddress = resolvedEvmAddress;
|
|
136
151
|
decimals = await this.getTACDecimals(configuration, resolvedEvmAddress);
|
|
137
152
|
}
|
|
138
|
-
const
|
|
153
|
+
const feeMode = FT.resolveFeeMode(origin, jettonData);
|
|
154
|
+
const token = new FT(tvmAddress, origin, configuration, decimals, feeMode);
|
|
139
155
|
if (finalEvmAddress || (0, ethers_1.isAddress)(address)) {
|
|
140
156
|
token._evmAddress = finalEvmAddress || address;
|
|
141
157
|
}
|
|
@@ -147,7 +163,7 @@ class FT {
|
|
|
147
163
|
return this._transferAmount;
|
|
148
164
|
}
|
|
149
165
|
get clone() {
|
|
150
|
-
const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration, this._decimals);
|
|
166
|
+
const ft = new FT(this._tvmAddress.toString(), this.origin, this._configuration, this._decimals, this.feeMode);
|
|
151
167
|
ft._transferAmount = this._transferAmount;
|
|
152
168
|
ft._evmAddress = this._evmAddress;
|
|
153
169
|
ft._displayMultiplierNumerator = this._displayMultiplierNumerator;
|
|
@@ -223,10 +239,10 @@ class FT {
|
|
|
223
239
|
}
|
|
224
240
|
const tokenAddressString = this._tvmAddress.toString({ bounceable: true });
|
|
225
241
|
let evmAddress;
|
|
226
|
-
if (this.origin ===
|
|
242
|
+
if (this.origin === Struct_1.Origin.TON) {
|
|
227
243
|
evmAddress = await this._configuration.TACParams.tokenUtils.computeAddress(tokenAddressString);
|
|
228
244
|
}
|
|
229
|
-
else if (this.origin ===
|
|
245
|
+
else if (this.origin === Struct_1.Origin.TAC) {
|
|
230
246
|
const givenMinter = this._configuration.TONParams.contractOpener.open(this._configuration.artifacts.ton.wrappers.JettonMinter.createFromAddress(ton_1.Address.parse(tokenAddressString)));
|
|
231
247
|
evmAddress = await givenMinter.getEVMTokenAddress();
|
|
232
248
|
}
|
|
@@ -254,7 +270,7 @@ class FT {
|
|
|
254
270
|
return payload;
|
|
255
271
|
}
|
|
256
272
|
get opType() {
|
|
257
|
-
return this.origin ===
|
|
273
|
+
return this.origin === Struct_1.Origin.TAC ? InternalStruct_1.AssetOpType.JETTON_BURN : InternalStruct_1.AssetOpType.JETTON_TRANSFER;
|
|
258
274
|
}
|
|
259
275
|
async getWallet(userAddress) {
|
|
260
276
|
const walletAddress = await this.getUserWalletAddress(userAddress);
|
package/dist/src/assets/NFT.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Cell } from '@ton/ton';
|
|
2
2
|
import { NFTCollectionData, NFTItemData } from '../../artifacts/tonTypes';
|
|
3
3
|
import { Asset, IConfiguration } from '../interfaces';
|
|
4
|
-
import { AssetType, BlockchainType, EVMAddress, FeeParams, Origin, TVMAddress } from '../structs/Struct';
|
|
4
|
+
import { AssetFeeMode, AssetType, BlockchainType, EVMAddress, FeeParams, Origin, TVMAddress } from '../structs/Struct';
|
|
5
5
|
export declare class NFT implements Asset {
|
|
6
6
|
private readonly _addresses;
|
|
7
7
|
readonly origin: Origin;
|
|
8
|
+
readonly feeMode: AssetFeeMode;
|
|
8
9
|
readonly type: AssetType;
|
|
9
10
|
private _nftCollection;
|
|
10
11
|
private _configuration;
|
|
@@ -37,7 +38,7 @@ export declare class NFT implements Asset {
|
|
|
37
38
|
collection: TVMAddress;
|
|
38
39
|
index: bigint;
|
|
39
40
|
evmAddress?: EVMAddress;
|
|
40
|
-
}, origin: Origin, configuration: IConfiguration);
|
|
41
|
+
}, origin: Origin, configuration: IConfiguration, feeMode?: AssetFeeMode);
|
|
41
42
|
get addresses(): {
|
|
42
43
|
item: string;
|
|
43
44
|
collection: string;
|
|
@@ -47,6 +48,7 @@ export declare class NFT implements Asset {
|
|
|
47
48
|
get address(): string;
|
|
48
49
|
get rawAmount(): bigint;
|
|
49
50
|
get clone(): NFT;
|
|
51
|
+
private static resolveFeeMode;
|
|
50
52
|
withAmount(_amount?: number): NFT;
|
|
51
53
|
withRawAmount(_rawAmount?: bigint): NFT;
|
|
52
54
|
addAmount(_amount?: number): NFT;
|
package/dist/src/assets/NFT.js
CHANGED
|
@@ -128,11 +128,12 @@ class NFT {
|
|
|
128
128
|
}, configuration.TONParams.nftItemCode).address.toString();
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
constructor(nftAddress, origin, configuration) {
|
|
131
|
+
constructor(nftAddress, origin, configuration, feeMode = NFT.resolveFeeMode(origin)) {
|
|
132
132
|
this.type = Struct_1.AssetType.NFT;
|
|
133
133
|
this._addresses = nftAddress;
|
|
134
134
|
this._configuration = configuration;
|
|
135
135
|
this.origin = origin;
|
|
136
|
+
this.feeMode = feeMode;
|
|
136
137
|
const NFTCollectionC = configuration.artifacts.ton.wrappers.NFTCollection;
|
|
137
138
|
this._nftCollection = configuration.TONParams.contractOpener.open(NFTCollectionC.createFromAddress(ton_1.Address.parse(this._addresses.collection)));
|
|
138
139
|
}
|
|
@@ -146,7 +147,10 @@ class NFT {
|
|
|
146
147
|
return 1n;
|
|
147
148
|
}
|
|
148
149
|
get clone() {
|
|
149
|
-
return new NFT(this._addresses, this.origin, this._configuration);
|
|
150
|
+
return new NFT(this._addresses, this.origin, this._configuration, this.feeMode);
|
|
151
|
+
}
|
|
152
|
+
static resolveFeeMode(origin) {
|
|
153
|
+
return origin === Struct_1.Origin.TAC ? Struct_1.AssetFeeMode.TAC_ORIGINAL : Struct_1.AssetFeeMode.LEGACY;
|
|
150
154
|
}
|
|
151
155
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
152
156
|
withAmount(_amount) {
|
package/dist/src/assets/TAC.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { Cell } from '@ton/ton';
|
|
2
2
|
import { Asset, IConfiguration } from '../interfaces';
|
|
3
|
-
import { AssetType, BlockchainType, GeneratePayloadParams, Origin } from '../structs/Struct';
|
|
3
|
+
import { AssetFeeMode, AssetType, BlockchainType, GeneratePayloadParams, Origin } from '../structs/Struct';
|
|
4
4
|
export declare class TAC implements Asset {
|
|
5
5
|
private readonly _configuration;
|
|
6
6
|
private readonly _evmAddress;
|
|
7
7
|
private _wrappedAsset;
|
|
8
8
|
readonly type: AssetType;
|
|
9
9
|
readonly origin: Origin;
|
|
10
|
+
readonly feeMode: AssetFeeMode;
|
|
10
11
|
private constructor();
|
|
11
12
|
static create(configuration: IConfiguration): Promise<TAC>;
|
|
12
13
|
get address(): string;
|
package/dist/src/assets/TAC.js
CHANGED
|
@@ -12,6 +12,7 @@ class TAC {
|
|
|
12
12
|
this._wrappedAsset = _wrappedAsset;
|
|
13
13
|
this.type = Struct_1.AssetType.FT;
|
|
14
14
|
this.origin = Struct_1.Origin.TAC;
|
|
15
|
+
this.feeMode = Struct_1.AssetFeeMode.TAC_ORIGINAL;
|
|
15
16
|
}
|
|
16
17
|
static async create(configuration) {
|
|
17
18
|
const evmAddress = await configuration.nativeTACAddress();
|
package/dist/src/assets/TON.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import { Cell } from '@ton/ton';
|
|
|
2
2
|
import { Asset, IConfiguration } from '../interfaces';
|
|
3
3
|
import type { SenderAbstraction } from '../sender';
|
|
4
4
|
import type { ShardTransaction } from '../structs/InternalStruct';
|
|
5
|
-
import { AssetType, BlockchainType, FeeParams, Origin } from '../structs/Struct';
|
|
5
|
+
import { AssetFeeMode, AssetType, BlockchainType, FeeParams, Origin } from '../structs/Struct';
|
|
6
6
|
export declare class TON implements Asset {
|
|
7
7
|
readonly address: string;
|
|
8
8
|
readonly type: AssetType;
|
|
9
|
+
readonly feeMode: AssetFeeMode;
|
|
9
10
|
private evmAddress;
|
|
10
11
|
private _rawAmount;
|
|
11
12
|
private _config;
|
package/dist/src/assets/TON.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Cell } from '@ton/ton';
|
|
2
|
-
import { AssetType, BlockchainType, GeneratePayloadParams, Origin } from '../structs/Struct';
|
|
2
|
+
import { AssetFeeMode, AssetType, BlockchainType, GeneratePayloadParams, Origin } from '../structs/Struct';
|
|
3
3
|
export interface Asset {
|
|
4
4
|
address: string;
|
|
5
5
|
type: AssetType;
|
|
6
6
|
rawAmount: bigint;
|
|
7
7
|
clone: Asset;
|
|
8
8
|
origin: Origin;
|
|
9
|
+
feeMode: AssetFeeMode;
|
|
9
10
|
/**
|
|
10
11
|
* Returns a new asset instance with the specified transfer amount in human-readable units.
|
|
11
12
|
* Does not mutate the current asset instance.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
|
|
1
|
+
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
|
|
2
2
|
export interface ILiteSequencerClient {
|
|
3
3
|
/** Base URL of the lite sequencer endpoint used by this client. */
|
|
4
4
|
readonly endpoint: string;
|
|
@@ -8,6 +8,8 @@ export interface ILiteSequencerClient {
|
|
|
8
8
|
getOperationTypeV2(operationId: string): Promise<OperationTypeV2Info>;
|
|
9
9
|
/** Resolves operation id by a transaction linker. */
|
|
10
10
|
getOperationId(transactionLinker: TransactionLinker): Promise<string>;
|
|
11
|
+
/** Resolves TAC operation ids with log indexes by TAC transaction hash. */
|
|
12
|
+
getOperationIdByTacTransactionHash(transactionHash: string): Promise<OperationIdWithLogIndex[]>;
|
|
11
13
|
/** Resolves operation id by the originating transaction hash (from ccl event in TON and TAC). */
|
|
12
14
|
getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
|
|
13
15
|
/** Resolves operation id by the originating transaction hash (from ccl event in TON). */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
|
|
1
|
+
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
|
|
2
2
|
export interface IOperationTracker {
|
|
3
3
|
/**
|
|
4
4
|
* Returns the operation type for the given id, optionally waiting according to the provided policy.
|
|
@@ -18,6 +18,12 @@ export interface IOperationTracker {
|
|
|
18
18
|
* @param waitOptions Optional waiting settings. Pass `null` to disable retries and use a single attempt.
|
|
19
19
|
*/
|
|
20
20
|
getOperationId(transactionLinker: TransactionLinker, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves TAC operation ids with log indexes by TAC transaction hash, optionally waiting until available.
|
|
23
|
+
* @param transactionHash Hash of the originating TAC transaction.
|
|
24
|
+
* @param waitOptions Optional waiting settings. Pass `null` to disable retries and use a single attempt.
|
|
25
|
+
*/
|
|
26
|
+
getOperationIdByTacTransactionHash(transactionHash: string, waitOptions?: WaitOptions<OperationIdWithLogIndex[]> | null): Promise<OperationIdWithLogIndex[]>;
|
|
21
27
|
/**
|
|
22
28
|
* Resolves an operation id by a transaction hash, optionally waiting until available.
|
|
23
29
|
* @param transactionHash Hash of the originating transaction.
|
package/dist/src/sdk/Consts.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
export declare const JETTON_TRANSFER_FORWARD_TON_AMOUNT: bigint;
|
|
2
2
|
export declare const NFT_TRANSFER_FORWARD_TON_AMOUNT: bigint;
|
|
3
|
+
export declare const LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = 3n;
|
|
4
|
+
export declare const LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = 2n;
|
|
5
|
+
export declare const LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = 1n;
|
|
6
|
+
export declare const LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = 10000000n;
|
|
7
|
+
export declare const LEGACY_JETTON_WALLET_GAS_CONSUMPTION = 15000000n;
|
|
8
|
+
export declare const LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = 2n;
|
|
9
|
+
export declare const LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
10
|
+
export declare const LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
11
|
+
export declare const LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE: bigint;
|
|
12
|
+
export declare const LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = 50000000n;
|
|
13
|
+
export declare const LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
14
|
+
export declare const LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
15
|
+
export declare const USDT_JETTON_WALLET_CODE_HASH = "89468f02c78e570802e39979c8516fc38df07ea76a48357e0536f2ba7b3ee37b";
|
|
16
|
+
export declare const DYNAMIC_JETTON_WALLET_CODE_HASHES: string[];
|
|
17
|
+
export declare const FIXED_POINT_SHIFT: number;
|
|
3
18
|
export declare const MAX_ITERATION_COUNT = 120;
|
|
4
19
|
export declare const DEFAULT_DELAY = 0;
|
|
5
20
|
export declare const SOLIDITY_SIGNATURE_REGEX: RegExp;
|
package/dist/src/sdk/Consts.js
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.CROSS_CHAIN_MESSAGE_VERSION_V1 = exports.IGNORE_MSG_VALUE_1_NANO = exports.DEFAULT_RETRY_ON_NOT_FOUND_DELAY_MS = exports.DEFAULT_RETRY_ON_NOT_FOUND_RETRIES = exports.DEFAULT_RETRY_ON_NOT_FOUND = exports.DEFAULT_FIND_TX_MAX_DEPTH = exports.DEFAULT_FIND_TX_ARCHIVAL = exports.DEFAULT_MAX_SCANNED_TRANSACTIONS = exports.DEFAULT_FIND_TX_LIMIT = exports.DEFAULT_WAIT_DELAY_MS = exports.DEFAULT_WAIT_MAX_ATTEMPTS = exports.DEFAULT_WAIT_TIMEOUT_MS = exports.DEFAULT_RETRY_BACKOFF_MULTIPLIER = exports.DEFAULT_RETRY_MAX_DELAY_MS = exports.DEFAULT_RETRY_DELAY_MS = exports.DEFAULT_RETRY_MAX_COUNT = exports.DEFAULT_HTTP_CLIENT_TIMEOUT_MS = exports.TON_BURN_ADDRESS = exports.MINUTE = exports.FIVE_MINUTES = 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.FIXED_POINT_SHIFT = exports.DYNAMIC_JETTON_WALLET_CODE_HASHES = exports.USDT_JETTON_WALLET_CODE_HASH = exports.LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = exports.LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE = exports.LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION = exports.LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = exports.LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = exports.LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = exports.LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = void 0;
|
|
4
|
+
exports.IGNORE_OPCODE = exports.SHARDS_KEY_RANDOM_RANGE = exports.DEFAULT_EIP1559_PRIORITY_FEE = exports.NFT_BRIDGE_AMOUNT = void 0;
|
|
4
5
|
const ton_1 = require("@ton/ton");
|
|
5
6
|
exports.JETTON_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.2);
|
|
6
7
|
exports.NFT_TRANSFER_FORWARD_TON_AMOUNT = (0, ton_1.toNano)(0.3);
|
|
8
|
+
exports.LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR = 3n;
|
|
9
|
+
exports.LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR = 2n;
|
|
10
|
+
exports.LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON = 1n;
|
|
11
|
+
exports.LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE = 10000000n;
|
|
12
|
+
exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION = 15000000n;
|
|
13
|
+
exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT = 2n;
|
|
14
|
+
exports.LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
15
|
+
exports.LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
16
|
+
exports.LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE = exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION_COUNT * exports.LEGACY_JETTON_WALLET_GAS_CONSUMPTION +
|
|
17
|
+
exports.LEGACY_JETTON_WALLET_MIN_TONS_FOR_STORAGE;
|
|
18
|
+
exports.LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE = 50000000n;
|
|
19
|
+
exports.LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT = 1n;
|
|
20
|
+
exports.LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT = 2n;
|
|
21
|
+
exports.USDT_JETTON_WALLET_CODE_HASH = '89468f02c78e570802e39979c8516fc38df07ea76a48357e0536f2ba7b3ee37b';
|
|
22
|
+
exports.DYNAMIC_JETTON_WALLET_CODE_HASHES = [exports.USDT_JETTON_WALLET_CODE_HASH];
|
|
23
|
+
exports.FIXED_POINT_SHIFT = 2 ** 16;
|
|
7
24
|
exports.MAX_ITERATION_COUNT = 120;
|
|
8
25
|
exports.DEFAULT_DELAY = 0;
|
|
9
26
|
exports.SOLIDITY_SIGNATURE_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]*(\((bytes,bytes)\))?$/;
|
package/dist/src/sdk/Fees.d.ts
CHANGED
package/dist/src/sdk/Fees.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNftItemErrorNotificationStep = exports.createNftProxyErrorNotificationStep = exports.createMintAfterErrorGasStep = exports.createEstimatedReceiveTransferGasStep = exports.createEstimatedSendTransferGasStep = exports.createErrorNotificationGasStep = exports.createNftProxyOwnershipAssignedStep = exports.createNftItemBurnStep = exports.createNftItemSendStep = exports.createJettonMinterBurnNotificationStep = exports.createJettonProxyOwnershipAssignedStep = exports.createJettonWalletBurnStep = exports.createJettonWalletReceiveStep = exports.createJettonWalletInternalTransferStep = exports.createCrossChainLayerTvmMsgToEvmStep = exports.DEFAULT_CONTRACT_FEE_USAGE_PARAMS =
|
|
3
|
+
exports.createNftItemErrorNotificationStep = exports.createNftProxyErrorNotificationStep = exports.createMintAfterErrorGasStep = exports.createEstimatedReceiveTransferGasStep = exports.createEstimatedSendTransferGasStep = exports.createErrorNotificationGasStep = exports.createNftProxyOwnershipAssignedStep = exports.createNftItemBurnStep = exports.createNftItemSendStep = exports.createJettonMinterBurnNotificationStep = exports.createJettonProxyOwnershipAssignedStep = exports.createJettonWalletBurnStep = exports.createJettonWalletReceiveStep = exports.createJettonWalletInternalTransferStep = exports.createCrossChainLayerTvmMsgToEvmStep = exports.DEFAULT_CONTRACT_FEE_USAGE_PARAMS = void 0;
|
|
4
4
|
const Consts_1 = require("./Consts");
|
|
5
|
-
exports.FIXED_POINT_SHIFT = 2 ** 16;
|
|
6
5
|
/**
|
|
7
6
|
* Default contract fee usage parameters used as fallback.
|
|
8
7
|
*/
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IHttpClient, ILiteSequencerClient } from '../interfaces';
|
|
2
|
-
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
|
|
2
|
+
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker } from '../structs/Struct';
|
|
3
3
|
export declare class LiteSequencerClient implements ILiteSequencerClient {
|
|
4
4
|
readonly endpoint: string;
|
|
5
5
|
private readonly maxChunkSize;
|
|
6
6
|
private readonly httpClient;
|
|
7
7
|
constructor(endpoint: string, maxChunkSize?: number, httpClient?: IHttpClient);
|
|
8
8
|
private getRequestLabel;
|
|
9
|
+
getOperationIdByTacTransactionHash(transactionHash: string): Promise<OperationIdWithLogIndex[]>;
|
|
9
10
|
getOperationIdByTransactionHash(transactionHash: string): Promise<string>;
|
|
10
11
|
getOperationIdByTonTransactionHash(transactionHash: string): Promise<string>;
|
|
11
12
|
getOperationType(operationId: string): Promise<OperationType>;
|
|
@@ -14,36 +14,31 @@ class LiteSequencerClient {
|
|
|
14
14
|
getRequestLabel(method, path) {
|
|
15
15
|
return `${method} ${new URL(path, this.endpoint).toString()}`;
|
|
16
16
|
}
|
|
17
|
-
async
|
|
18
|
-
const
|
|
19
|
-
const path = isEthHash ? 'tac/operation-id' : 'ton/operation-id';
|
|
17
|
+
async getOperationIdByTacTransactionHash(transactionHash) {
|
|
18
|
+
const path = 'tac/operation-id';
|
|
20
19
|
const requestLabel = this.getRequestLabel('GET', path);
|
|
21
20
|
try {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const operationResponse = response.data.response;
|
|
27
|
-
if (operationResponse.length > 0) {
|
|
28
|
-
return operationResponse[0].operationId;
|
|
29
|
-
}
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
34
|
-
params: { transactionHash },
|
|
35
|
-
});
|
|
36
|
-
return response.data.response || '';
|
|
37
|
-
}
|
|
21
|
+
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
22
|
+
params: { transactionHash },
|
|
23
|
+
});
|
|
24
|
+
return response.data.response || [];
|
|
38
25
|
}
|
|
39
26
|
catch (error) {
|
|
40
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
28
|
if (error?.response?.status === 404) {
|
|
42
|
-
return
|
|
29
|
+
return [];
|
|
43
30
|
}
|
|
44
31
|
throw (0, errors_1.operationFetchError)(`request ${requestLabel} failed to complete request`, error);
|
|
45
32
|
}
|
|
46
33
|
}
|
|
34
|
+
async getOperationIdByTransactionHash(transactionHash) {
|
|
35
|
+
const isEthHash = /^0x[a-fA-F0-9]{64}$/.test(transactionHash);
|
|
36
|
+
if (isEthHash) {
|
|
37
|
+
const operationResponse = await this.getOperationIdByTacTransactionHash(transactionHash);
|
|
38
|
+
return operationResponse[0]?.operationId || '';
|
|
39
|
+
}
|
|
40
|
+
return this.getOperationIdByTonTransactionHash(transactionHash);
|
|
41
|
+
}
|
|
47
42
|
async getOperationIdByTonTransactionHash(transactionHash) {
|
|
48
43
|
const path = 'ton/operation-id';
|
|
49
44
|
const requestLabel = this.getRequestLabel('GET', path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ILiteSequencerClient, ILiteSequencerClientFactory, ILogger, IOperationTracker } from '../interfaces';
|
|
2
|
-
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, Network, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
|
|
2
|
+
import { ConvertCurrencyParams, ConvertedCurrencyResult, ExecutionStages, ExecutionStagesByOperationId, ExecutionStagesV2, ExecutionStagesV2ByOperationId, GetTVMExecutorFeeParams, Network, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, SimplifiedStatuses, StatusInfo, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinker, WaitOptions } from '../structs/Struct';
|
|
3
3
|
export declare class DefaultLiteSequencerClientFactory implements ILiteSequencerClientFactory {
|
|
4
4
|
createClients(endpoints: string[]): ILiteSequencerClient[];
|
|
5
5
|
}
|
|
@@ -8,6 +8,7 @@ export declare class OperationTracker implements IOperationTracker {
|
|
|
8
8
|
private readonly logger;
|
|
9
9
|
constructor(network: Network, customLiteSequencerEndpoints?: string[], logger?: ILogger, clientFactory?: ILiteSequencerClientFactory);
|
|
10
10
|
getOperationIdByTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
11
|
+
getOperationIdByTacTransactionHash(transactionHash: string, waitOptions?: WaitOptions<OperationIdWithLogIndex[]> | null): Promise<OperationIdWithLogIndex[]>;
|
|
11
12
|
getOperationIdByTonTransactionHash(transactionHash: string, waitOptions?: WaitOptions<string> | null): Promise<string>;
|
|
12
13
|
getOperationType(operationId: string, waitOptions?: WaitOptions<OperationType> | null): Promise<OperationType>;
|
|
13
14
|
getOperationTypeV2(operationId: string, waitOptions?: WaitOptions<OperationTypeV2Info> | null): Promise<OperationTypeV2Info>;
|
|
@@ -52,6 +52,24 @@ class OperationTracker {
|
|
|
52
52
|
? await requestFn()
|
|
53
53
|
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, `OperationTracker: Getting operation ID by transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
54
54
|
}
|
|
55
|
+
async getOperationIdByTacTransactionHash(transactionHash, waitOptions) {
|
|
56
|
+
const requestFn = async () => {
|
|
57
|
+
let lastError;
|
|
58
|
+
for (const client of this.clients) {
|
|
59
|
+
try {
|
|
60
|
+
const ids = await client.getOperationIdByTacTransactionHash(transactionHash);
|
|
61
|
+
return ids;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
lastError = error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw (0, errors_1.allEndpointsFailedError)(lastError, waitOptions?.includeErrorTrace ?? false);
|
|
68
|
+
};
|
|
69
|
+
return waitOptions === null
|
|
70
|
+
? await requestFn()
|
|
71
|
+
: await (0, Utils_1.waitUntilSuccess)({ logger: this.logger, ...waitOptions }, requestFn, `OperationTracker: Getting operation IDs by TAC transaction hash ${(0, Utils_1.formatObjectForLogging)(transactionHash)}`);
|
|
72
|
+
}
|
|
55
73
|
async getOperationIdByTonTransactionHash(transactionHash, waitOptions) {
|
|
56
74
|
const requestFn = async () => {
|
|
57
75
|
let lastError;
|
|
@@ -10,8 +10,13 @@ export declare class Simulator implements ISimulator {
|
|
|
10
10
|
getSimulationInfo(sender: SenderAbstraction, tx: CrosschainTx): Promise<ExecutionFeeEstimationResult>;
|
|
11
11
|
private calculateTONFees;
|
|
12
12
|
private calculateTransactionPipeline;
|
|
13
|
+
private calculateMessageForwardFee;
|
|
14
|
+
private calculateLegacyJettonTransferNetworkFee;
|
|
13
15
|
private calculateTONCrosschainFee;
|
|
14
16
|
private calculateJettonTransferCrosschainFee;
|
|
17
|
+
private calculateLegacyJettonTransferCrosschainFee;
|
|
18
|
+
private calculateLegacyNftTransferNetworkFee;
|
|
19
|
+
private calculateLegacyNftTransferCrosschainFee;
|
|
15
20
|
private calculateJettonBurnCrosschainFee;
|
|
16
21
|
private calculateNftTransferCrosschainFee;
|
|
17
22
|
private calculateNftBurnCrosschainFee;
|
|
@@ -6,6 +6,7 @@ const assets_1 = require("../assets");
|
|
|
6
6
|
const errors_1 = require("../errors");
|
|
7
7
|
const instances_1 = require("../errors/instances");
|
|
8
8
|
const Struct_1 = require("../structs/Struct");
|
|
9
|
+
const Consts_1 = require("./Consts");
|
|
9
10
|
const Fees_1 = require("./Fees");
|
|
10
11
|
const Logger_1 = require("./Logger");
|
|
11
12
|
const Utils_1 = require("./Utils");
|
|
@@ -79,15 +80,15 @@ class Simulator {
|
|
|
79
80
|
// Gas and computation
|
|
80
81
|
gasUsed, accountBitPrice, accountCellPrice, lumpPrice, gasPrice, firstFrac, ihrPriceFactor, msgBitPrice, msgCellPrice, }) {
|
|
81
82
|
// Storage Fee (nanotons)
|
|
82
|
-
const storageFee = Math.ceil(((accountBits * accountBitPrice + accountCells * accountCellPrice) * timeDelta) /
|
|
83
|
+
const storageFee = Math.ceil(((accountBits * accountBitPrice + accountCells * accountCellPrice) * timeDelta) / Consts_1.FIXED_POINT_SHIFT);
|
|
83
84
|
// Computation Fee (nanotons)
|
|
84
|
-
const computeFee = (gasUsed * gasPrice) /
|
|
85
|
+
const computeFee = (gasUsed * gasPrice) / Consts_1.FIXED_POINT_SHIFT;
|
|
85
86
|
// Forwarding Fee (nanotons)
|
|
86
|
-
const msgFwdFees = lumpPrice + Math.ceil((msgBitPrice * msgBits + msgCellPrice * msgCells) /
|
|
87
|
-
const ihrFwdFees = Math.ceil((msgFwdFees * ihrPriceFactor) /
|
|
87
|
+
const msgFwdFees = lumpPrice + Math.ceil((msgBitPrice * msgBits + msgCellPrice * msgCells) / Consts_1.FIXED_POINT_SHIFT);
|
|
88
|
+
const ihrFwdFees = Math.ceil((msgFwdFees * ihrPriceFactor) / Consts_1.FIXED_POINT_SHIFT);
|
|
88
89
|
const totalFwdFees = msgFwdFees + ihrFwdFees;
|
|
89
90
|
// Action Fee (nanotons)
|
|
90
|
-
const actionFee = Math.floor((msgFwdFees * firstFrac) /
|
|
91
|
+
const actionFee = Math.floor((msgFwdFees * firstFrac) / Consts_1.FIXED_POINT_SHIFT);
|
|
91
92
|
// Combine all fees
|
|
92
93
|
const totalFees = storageFee + computeFee + actionFee + totalFwdFees;
|
|
93
94
|
return BigInt(Math.ceil(totalFees));
|
|
@@ -95,6 +96,24 @@ class Simulator {
|
|
|
95
96
|
calculateTransactionPipeline(steps) {
|
|
96
97
|
return steps.reduce((total, step) => total + this.calculateTONFees({ ...step, ...this.config.TONParams.feesParams }), 0n);
|
|
97
98
|
}
|
|
99
|
+
calculateMessageForwardFee(msgBits, msgCells) {
|
|
100
|
+
const { lumpPrice, msgBitPrice, msgCellPrice } = this.config.TONParams.feesParams;
|
|
101
|
+
const msgFwdFees = lumpPrice + Math.ceil((msgBitPrice * msgBits + msgCellPrice * msgCells) / Consts_1.FIXED_POINT_SHIFT);
|
|
102
|
+
return BigInt(msgFwdFees);
|
|
103
|
+
}
|
|
104
|
+
calculateLegacyJettonTransferNetworkFee(params, msgBits, msgCells) {
|
|
105
|
+
const forwardTonAmount = Consts_1.JETTON_TRANSFER_FORWARD_TON_AMOUNT +
|
|
106
|
+
(params.forwardFeeTonAmount ?? 0n) +
|
|
107
|
+
(params.crossChainTonAmount ?? 0n);
|
|
108
|
+
const outboundMessageCount = forwardTonAmount > 0n
|
|
109
|
+
? Consts_1.LEGACY_JETTON_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT
|
|
110
|
+
: Consts_1.LEGACY_JETTON_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT;
|
|
111
|
+
const inboundForwardFee = (this.calculateMessageForwardFee(msgBits, msgCells) * Consts_1.LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR) /
|
|
112
|
+
Consts_1.LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR;
|
|
113
|
+
return (outboundMessageCount * inboundForwardFee +
|
|
114
|
+
Consts_1.LEGACY_JETTON_WALLET_TRANSFER_GAS_AND_STORAGE +
|
|
115
|
+
Consts_1.LEGACY_STRICTLY_GREATER_THAN_FEE_EPSILON);
|
|
116
|
+
}
|
|
98
117
|
calculateTONCrosschainFee(msgBits, msgCells) {
|
|
99
118
|
return this.calculateTransactionPipeline([
|
|
100
119
|
(0, Fees_1.createCrossChainLayerTvmMsgToEvmStep)(this.config.TONParams.contractFeeUsageParams, msgBits, msgCells),
|
|
@@ -111,6 +130,27 @@ class Simulator {
|
|
|
111
130
|
(0, Fees_1.createEstimatedReceiveTransferGasStep)(this.config.TONParams.contractFeeUsageParams, msgBits, msgCells),
|
|
112
131
|
]);
|
|
113
132
|
}
|
|
133
|
+
calculateLegacyJettonTransferCrosschainFee(params, msgBits, msgCells) {
|
|
134
|
+
const dynamicFee = this.calculateJettonTransferCrosschainFee(msgBits, msgCells);
|
|
135
|
+
const legacyNetworkFee = this.calculateLegacyJettonTransferNetworkFee(params, msgBits, msgCells);
|
|
136
|
+
return dynamicFee > legacyNetworkFee ? dynamicFee : legacyNetworkFee;
|
|
137
|
+
}
|
|
138
|
+
calculateLegacyNftTransferNetworkFee(params, msgBits, msgCells) {
|
|
139
|
+
const forwardTonAmount = Consts_1.NFT_TRANSFER_FORWARD_TON_AMOUNT +
|
|
140
|
+
(params.forwardFeeTonAmount ?? 0n) +
|
|
141
|
+
(params.crossChainTonAmount ?? 0n);
|
|
142
|
+
const outboundMessageCount = forwardTonAmount > 0n
|
|
143
|
+
? Consts_1.LEGACY_NFT_TRANSFER_WITH_FORWARD_OUTBOUND_MESSAGE_COUNT
|
|
144
|
+
: Consts_1.LEGACY_NFT_TRANSFER_BASE_OUTBOUND_MESSAGE_COUNT;
|
|
145
|
+
const inboundForwardFee = (this.calculateMessageForwardFee(msgBits, msgCells) * Consts_1.LEGACY_FORWARD_FEE_ESTIMATE_NUMERATOR) /
|
|
146
|
+
Consts_1.LEGACY_FORWARD_FEE_ESTIMATE_DENOMINATOR;
|
|
147
|
+
return outboundMessageCount * inboundForwardFee + Consts_1.LEGACY_NFT_ITEM_MIN_TONS_FOR_STORAGE;
|
|
148
|
+
}
|
|
149
|
+
calculateLegacyNftTransferCrosschainFee(params, msgBits, msgCells) {
|
|
150
|
+
const dynamicFee = this.calculateNftTransferCrosschainFee(msgBits, msgCells);
|
|
151
|
+
const legacyNetworkFee = this.calculateLegacyNftTransferNetworkFee(params, msgBits, msgCells);
|
|
152
|
+
return dynamicFee > legacyNetworkFee ? dynamicFee : legacyNetworkFee;
|
|
153
|
+
}
|
|
114
154
|
calculateJettonBurnCrosschainFee(msgBits, msgCells) {
|
|
115
155
|
return this.calculateTransactionPipeline([
|
|
116
156
|
(0, Fees_1.createJettonWalletBurnStep)(this.config.TONParams.contractFeeUsageParams, msgBits, msgCells),
|
|
@@ -147,6 +187,9 @@ class Simulator {
|
|
|
147
187
|
}
|
|
148
188
|
if (asset.origin === Struct_1.Origin.TON) {
|
|
149
189
|
// Pipeline: wallet -> jetton wallet -> jetton wallet -> jetton proxy -> ccl -> log
|
|
190
|
+
if (asset.feeMode === Struct_1.AssetFeeMode.LEGACY) {
|
|
191
|
+
return this.calculateLegacyJettonTransferCrosschainFee(params, msgBits, msgCells);
|
|
192
|
+
}
|
|
150
193
|
return this.calculateJettonTransferCrosschainFee(msgBits, msgCells);
|
|
151
194
|
}
|
|
152
195
|
if (asset.origin === Struct_1.Origin.TAC) {
|
|
@@ -157,6 +200,9 @@ class Simulator {
|
|
|
157
200
|
case Struct_1.AssetType.NFT:
|
|
158
201
|
if (asset.origin === Struct_1.Origin.TON) {
|
|
159
202
|
// Pipeline: wallet -> nft item -> nft proxy -> ccl -> log
|
|
203
|
+
if (asset.feeMode === Struct_1.AssetFeeMode.LEGACY) {
|
|
204
|
+
return this.calculateLegacyNftTransferCrosschainFee(params, msgBits, msgCells);
|
|
205
|
+
}
|
|
160
206
|
return this.calculateNftTransferCrosschainFee(msgBits, msgCells);
|
|
161
207
|
}
|
|
162
208
|
if (asset.origin === Struct_1.Origin.TAC) {
|
|
@@ -2,7 +2,7 @@ import { Address, Cell } from '@ton/ton';
|
|
|
2
2
|
import { AbstractProvider, ethers } from 'ethers';
|
|
3
3
|
import { ICrossChainLayer, ISAFactory, ISettings, ITokenUtils } from '../../artifacts/tacTypes';
|
|
4
4
|
import { ContractOpener } from '../interfaces';
|
|
5
|
-
import { CurrencyType, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, ToncenterV3IndexedTransaction, TransactionLinker } from './Struct';
|
|
5
|
+
import { CurrencyType, ExecutionStagesByOperationId, ExecutionStagesV2ByOperationId, Network, OperationIdsByShardsKey, OperationIdWithLogIndex, OperationType, OperationTypeV2Info, StatusInfosByOperationId, SuggestedTVMExecutorFee, TACSimulationResult, ToncenterV3IndexedTransaction, TransactionLinker } from './Struct';
|
|
6
6
|
export type ShardMessage = {
|
|
7
7
|
address: string;
|
|
8
8
|
value: bigint;
|
|
@@ -70,10 +70,6 @@ export type StageProfilingV2Response = ResponseBase<ExecutionStagesV2ByOperation
|
|
|
70
70
|
export type TACSimulationResponse = ResponseBase<TACSimulationResult>;
|
|
71
71
|
export type SuggestedTVMExecutorFeeResponse = ResponseBase<SuggestedTVMExecutorFee>;
|
|
72
72
|
export type ConvertCurrencyResponse = ResponseBase<ConvertedCurrencyRawResult>;
|
|
73
|
-
export type OperationIdWithLogIndex = {
|
|
74
|
-
operationId: string;
|
|
75
|
-
logIndex: number;
|
|
76
|
-
};
|
|
77
73
|
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex[]>;
|
|
78
74
|
export interface SendResult {
|
|
79
75
|
success: boolean;
|
|
@@ -310,6 +310,10 @@ export type StatusInfosByOperationId = Record<string, StatusInfo>;
|
|
|
310
310
|
export type OperationIds = {
|
|
311
311
|
operationIds: string[];
|
|
312
312
|
};
|
|
313
|
+
export type OperationIdWithLogIndex = {
|
|
314
|
+
operationId: string;
|
|
315
|
+
logIndex: number;
|
|
316
|
+
};
|
|
313
317
|
export type OperationIdsByShardsKey = Record<string, OperationIds>;
|
|
314
318
|
export type TACSimulationResult = {
|
|
315
319
|
estimatedGas: bigint;
|
|
@@ -594,6 +598,11 @@ export declare enum Origin {
|
|
|
594
598
|
TON = "TON",
|
|
595
599
|
TAC = "TAC"
|
|
596
600
|
}
|
|
601
|
+
export declare enum AssetFeeMode {
|
|
602
|
+
TAC_ORIGINAL = "TAC_ORIGINAL",
|
|
603
|
+
LEGACY = "LEGACY",
|
|
604
|
+
DYNAMIC = "DYNAMIC"
|
|
605
|
+
}
|
|
597
606
|
export type TVMAddress = string;
|
|
598
607
|
export type EVMAddress = string;
|
|
599
608
|
export type AssetFromFTArg = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionTreeDirection = exports.Origin = exports.defaultWaitOptions = exports.TokenSymbol = exports.StageName = exports.NFTAddressType = exports.AssetType = exports.OperationExecutionStatus = exports.OperationType = exports.CurrencyType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
|
|
3
|
+
exports.TransactionTreeDirection = exports.AssetFeeMode = exports.Origin = exports.defaultWaitOptions = exports.TokenSymbol = exports.StageName = exports.NFTAddressType = exports.AssetType = exports.OperationExecutionStatus = exports.OperationType = exports.CurrencyType = exports.BlockchainType = exports.Network = exports.SimplifiedStatuses = void 0;
|
|
4
4
|
const Consts_1 = require("../sdk/Consts");
|
|
5
5
|
var SimplifiedStatuses;
|
|
6
6
|
(function (SimplifiedStatuses) {
|
|
@@ -73,6 +73,12 @@ var Origin;
|
|
|
73
73
|
Origin["TON"] = "TON";
|
|
74
74
|
Origin["TAC"] = "TAC";
|
|
75
75
|
})(Origin || (exports.Origin = Origin = {}));
|
|
76
|
+
var AssetFeeMode;
|
|
77
|
+
(function (AssetFeeMode) {
|
|
78
|
+
AssetFeeMode["TAC_ORIGINAL"] = "TAC_ORIGINAL";
|
|
79
|
+
AssetFeeMode["LEGACY"] = "LEGACY";
|
|
80
|
+
AssetFeeMode["DYNAMIC"] = "DYNAMIC";
|
|
81
|
+
})(AssetFeeMode || (exports.AssetFeeMode = AssetFeeMode = {}));
|
|
76
82
|
var TransactionTreeDirection;
|
|
77
83
|
(function (TransactionTreeDirection) {
|
|
78
84
|
TransactionTreeDirection["FORWARD"] = "forward";
|