@tonappchain/sdk 0.7.1 → 0.7.2-gas-price-0.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/LICENSE +20 -20
- package/README.md +198 -198
- package/dist/src/agnosticSdk/AbiHandler.js +1 -1
- package/dist/src/agnosticSdk/DebugHelpers.js +1 -1
- package/dist/src/agnosticSdk/HooksHandler.js +1 -1
- package/dist/src/agnosticSdk/ReplacementHelper.js +1 -3
- package/dist/src/assets/AssetFactory.js +2 -3
- package/dist/src/assets/TON.d.ts +0 -1
- package/dist/src/assets/TON.js +1 -5
- package/dist/src/errors/instances.d.ts +0 -2
- package/dist/src/errors/instances.js +2 -5
- package/dist/src/interfaces/ITONTransactionManager.d.ts +5 -4
- package/dist/src/interfaces/ITacSDK.d.ts +3 -3
- package/dist/src/sdk/Configuration.js +3 -9
- package/dist/src/sdk/LiteSequencerClient.js +4 -12
- package/dist/src/sdk/Logger.d.ts +4 -4
- package/dist/src/sdk/Logger.js +4 -12
- package/dist/src/sdk/OperationTracker.js +0 -4
- package/dist/src/sdk/Simulator.js +1 -1
- package/dist/src/sdk/TONTransactionManager.d.ts +4 -4
- package/dist/src/sdk/TONTransactionManager.js +19 -29
- package/dist/src/sdk/TacSdk.d.ts +3 -3
- package/dist/src/sdk/TacSdk.js +4 -4
- package/dist/src/sdk/TxFinalizer.js +1 -6
- package/dist/src/sdk/Utils.d.ts +2 -2
- package/dist/src/sdk/Utils.js +27 -28
- package/dist/src/sender/SenderFactory.js +1 -1
- package/dist/src/sender/TonConnectSender.js +1 -1
- package/dist/src/structs/InternalStruct.d.ts +0 -5
- package/dist/src/structs/Struct.d.ts +3 -19
- package/package.json +118 -118
|
@@ -78,7 +78,6 @@ class Configuration {
|
|
|
78
78
|
const artifacts = network === Struct_1.Network.MAINNET ? artifacts_1.mainnet : network === Struct_1.Network.TESTNET ? artifacts_1.testnet : artifacts_1.dev;
|
|
79
79
|
let provider;
|
|
80
80
|
let settingsAddress;
|
|
81
|
-
let saFactoryAddress;
|
|
82
81
|
if (network === Struct_1.Network.DEV) {
|
|
83
82
|
if (!TACParams || !TACParams.provider) {
|
|
84
83
|
throw new Error('For dev network, a custom provider must be provided in TACParams');
|
|
@@ -87,16 +86,11 @@ class Configuration {
|
|
|
87
86
|
if (!TACParams.settingsAddress) {
|
|
88
87
|
throw new Error('For dev network, a custom settings address must be provided in TACParams');
|
|
89
88
|
}
|
|
90
|
-
settingsAddress = TACParams.settingsAddress;
|
|
91
|
-
if (!TACParams.saFactoryAddress) {
|
|
92
|
-
throw new Error('For dev network, a custom smart account factory address must be provided in TACParams');
|
|
93
|
-
}
|
|
94
|
-
saFactoryAddress = TACParams.saFactoryAddress;
|
|
89
|
+
settingsAddress = TACParams.settingsAddress.toString();
|
|
95
90
|
}
|
|
96
91
|
else {
|
|
97
92
|
provider = TACParams?.provider ?? ethers_1.ethers.getDefaultProvider(artifacts.TAC_RPC_ENDPOINT);
|
|
98
|
-
settingsAddress = TACParams?.settingsAddress ?? artifacts.TAC_SETTINGS_ADDRESS;
|
|
99
|
-
saFactoryAddress = TACParams?.saFactoryAddress ?? artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS;
|
|
93
|
+
settingsAddress = TACParams?.settingsAddress?.toString() ?? artifacts.TAC_SETTINGS_ADDRESS;
|
|
100
94
|
}
|
|
101
95
|
Validator_1.Validator.validateEVMAddress(settingsAddress);
|
|
102
96
|
const settingsAbi = artifacts.tac.compilationArtifacts.ISettings.abi;
|
|
@@ -123,7 +117,7 @@ class Configuration {
|
|
|
123
117
|
const tokenUtilsAbi = artifacts.tac.compilationArtifacts.ITokenUtils.abi;
|
|
124
118
|
const tokenUtils = new ethers_1.ethers.Contract(tokenUtilsAddress, tokenUtilsAbi, provider);
|
|
125
119
|
const TacSAFactoryAbi = artifacts.tac.compilationArtifacts.ISAFactory.abi;
|
|
126
|
-
const smartAccountFactory = new ethers_1.ethers.Contract(
|
|
120
|
+
const smartAccountFactory = new ethers_1.ethers.Contract(artifacts.TAC_SMART_ACCOUNT_FACTORY_ADDRESS, TacSAFactoryAbi, provider);
|
|
127
121
|
return {
|
|
128
122
|
provider,
|
|
129
123
|
settings,
|
|
@@ -15,18 +15,10 @@ class LiteSequencerClient {
|
|
|
15
15
|
const isEthHash = /^0x[a-fA-F0-9]{64}$/.test(transactionHash);
|
|
16
16
|
const path = isEthHash ? 'tac/operation-id' : 'ton/operation-id';
|
|
17
17
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return response.data.response?.operationId || '';
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
26
|
-
params: { transactionHash },
|
|
27
|
-
});
|
|
28
|
-
return response.data.response || '';
|
|
29
|
-
}
|
|
18
|
+
const response = await this.httpClient.get(new URL(path, this.endpoint).toString(), {
|
|
19
|
+
params: { transactionHash },
|
|
20
|
+
});
|
|
21
|
+
return response.data.response || '';
|
|
30
22
|
}
|
|
31
23
|
catch (error) {
|
|
32
24
|
if (error?.response?.status === 404) {
|
package/dist/src/sdk/Logger.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ export declare class ConsoleLogger implements ILogger {
|
|
|
6
6
|
error(...arg: unknown[]): void;
|
|
7
7
|
}
|
|
8
8
|
export declare class NoopLogger implements ILogger {
|
|
9
|
-
debug(
|
|
10
|
-
info(
|
|
11
|
-
warn(
|
|
12
|
-
error(
|
|
9
|
+
debug(): void;
|
|
10
|
+
info(): void;
|
|
11
|
+
warn(): void;
|
|
12
|
+
error(): void;
|
|
13
13
|
}
|
package/dist/src/sdk/Logger.js
CHANGED
|
@@ -17,17 +17,9 @@ class ConsoleLogger {
|
|
|
17
17
|
}
|
|
18
18
|
exports.ConsoleLogger = ConsoleLogger;
|
|
19
19
|
class NoopLogger {
|
|
20
|
-
debug(
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
void _arg;
|
|
25
|
-
}
|
|
26
|
-
warn(..._arg) {
|
|
27
|
-
void _arg;
|
|
28
|
-
}
|
|
29
|
-
error(..._arg) {
|
|
30
|
-
void _arg;
|
|
31
|
-
}
|
|
20
|
+
debug() { }
|
|
21
|
+
info() { }
|
|
22
|
+
warn() { }
|
|
23
|
+
error() { }
|
|
32
24
|
}
|
|
33
25
|
exports.NoopLogger = NoopLogger;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OperationTracker = exports.DefaultLiteSequencerClientFactory = void 0;
|
|
4
4
|
const artifacts_1 = require("../../artifacts");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
|
-
const instances_1 = require("../errors/instances");
|
|
7
6
|
const Struct_1 = require("../structs/Struct");
|
|
8
7
|
const LiteSequencerClient_1 = require("./LiteSequencerClient");
|
|
9
8
|
const Logger_1 = require("./Logger");
|
|
@@ -240,9 +239,6 @@ class OperationTracker {
|
|
|
240
239
|
return Struct_1.SimplifiedStatuses.SUCCESSFUL;
|
|
241
240
|
}
|
|
242
241
|
async convertCurrency(params, waitOptions) {
|
|
243
|
-
if (params.value <= 0n) {
|
|
244
|
-
throw instances_1.convertCurrencyNegativeOrZeroValueError;
|
|
245
|
-
}
|
|
246
242
|
this.logger.debug(`Converting currency: ${(0, Utils_1.formatObjectForLogging)(params)}`);
|
|
247
243
|
const requestFn = async () => {
|
|
248
244
|
let lastError;
|
|
@@ -27,7 +27,7 @@ class Simulator {
|
|
|
27
27
|
Validator_1.Validator.validateEVMAddress(evmProxyMsg.evmTargetAddress);
|
|
28
28
|
Validator_1.Validator.validateEVMAddresses(evmValidExecutors);
|
|
29
29
|
Validator_1.Validator.validateTVMAddresses(tvmValidExecutors);
|
|
30
|
-
const aggregatedData = (0, Utils_1.aggregateTokens)(assets);
|
|
30
|
+
const aggregatedData = await (0, Utils_1.aggregateTokens)(assets);
|
|
31
31
|
const shardCount = aggregatedData.jettons.length || 1;
|
|
32
32
|
const transactionLinker = (0, Utils_1.generateTransactionLinker)(sender.getSenderAddress(), shardCount);
|
|
33
33
|
const tacSimulationParams = {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { IConfiguration, ILogger, IOperationTracker, ISimulator, ITONTransactionManager } from '../interfaces';
|
|
2
2
|
import type { SenderAbstraction } from '../sender';
|
|
3
|
-
import {
|
|
3
|
+
import { CrosschainTx, EvmProxyMsg, OperationIdsByShardsKey, TransactionLinkerWithOperationId, WaitOptions } from '../structs/Struct';
|
|
4
4
|
export declare class TONTransactionManager implements ITONTransactionManager {
|
|
5
5
|
private readonly config;
|
|
6
6
|
private readonly simulator;
|
|
7
7
|
private readonly operationTracker;
|
|
8
8
|
private readonly logger;
|
|
9
9
|
constructor(config: IConfiguration, simulator: ISimulator, operationTracker: IOperationTracker, logger?: ILogger);
|
|
10
|
-
|
|
10
|
+
private buildFeeParams;
|
|
11
11
|
private prepareCrossChainTransaction;
|
|
12
12
|
private generateCrossChainMessages;
|
|
13
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx): Promise<TransactionLinkerWithOperationId>;
|
|
14
|
-
sendCrossChainTransactions(sender: SenderAbstraction, txs:
|
|
13
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, tx: CrosschainTx, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
|
|
14
|
+
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTx[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
|
|
15
15
|
private prepareBatchTransactions;
|
|
16
16
|
private waitForOperationIds;
|
|
17
17
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TONTransactionManager = void 0;
|
|
4
4
|
const assets_1 = require("../assets");
|
|
5
5
|
const errors_1 = require("../errors");
|
|
6
|
-
const instances_1 = require("../errors/instances");
|
|
7
6
|
const Consts_1 = require("./Consts");
|
|
8
7
|
const Logger_1 = require("./Logger");
|
|
9
8
|
const Utils_1 = require("./Utils");
|
|
@@ -54,7 +53,7 @@ class TONTransactionManager {
|
|
|
54
53
|
const { allowSimulationError = false, isRoundTrip = undefined, calculateRollbackFee = true, validateAssetsBalance = true, } = options || {};
|
|
55
54
|
const { evmValidExecutors = [], tvmValidExecutors = [] } = options || {};
|
|
56
55
|
Validator_1.Validator.validateEVMAddress(evmProxyMsg.evmTargetAddress);
|
|
57
|
-
const aggregatedData = (0, Utils_1.aggregateTokens)(assets);
|
|
56
|
+
const aggregatedData = await (0, Utils_1.aggregateTokens)(assets);
|
|
58
57
|
Validator_1.Validator.validateEVMAddresses(evmValidExecutors);
|
|
59
58
|
Validator_1.Validator.validateTVMAddresses(tvmValidExecutors);
|
|
60
59
|
const shouldValidateAssets = validateAssetsBalance && !skipAssetsBalanceValidation;
|
|
@@ -137,44 +136,35 @@ class TONTransactionManager {
|
|
|
137
136
|
this.logger.debug('Cross-chain messages generated successfully');
|
|
138
137
|
return messages;
|
|
139
138
|
}
|
|
140
|
-
async sendCrossChainTransaction(evmProxyMsg, sender, tx) {
|
|
139
|
+
async sendCrossChainTransaction(evmProxyMsg, sender, tx, waitOptions) {
|
|
141
140
|
const { transaction, transactionLinker } = await this.prepareCrossChainTransaction(evmProxyMsg, sender, tx.assets, tx.options);
|
|
142
141
|
await assets_1.TON.checkBalance(sender, this.config, [transaction]);
|
|
143
142
|
this.logger.debug(`Sending transaction: ${(0, Utils_1.formatObjectForLogging)(transactionLinker)}`);
|
|
144
143
|
const sendTransactionResult = await sender.sendShardTransaction(transaction, this.config.network, this.config.TONParams.contractOpener);
|
|
145
|
-
if (!
|
|
146
|
-
throw (0, instances_1.sendCrossChainTransactionFailedError)(sendTransactionResult.error?.message ?? 'Transaction failed to send');
|
|
147
|
-
}
|
|
148
|
-
const shouldWaitForOperationId = tx.options?.waitOperationId ?? true;
|
|
149
|
-
if (!shouldWaitForOperationId) {
|
|
144
|
+
if (!waitOptions) {
|
|
150
145
|
return { sendTransactionResult, ...transactionLinker };
|
|
151
146
|
}
|
|
152
|
-
const waitOptions = tx.options?.waitOptions ?? {};
|
|
153
|
-
waitOptions.successCheck = waitOptions.successCheck ?? ((id) => !!id);
|
|
154
|
-
waitOptions.logger = waitOptions.logger ?? this.logger;
|
|
155
147
|
const operationId = await this.operationTracker
|
|
156
|
-
.getOperationId(transactionLinker,
|
|
148
|
+
.getOperationId(transactionLinker, {
|
|
149
|
+
...waitOptions,
|
|
150
|
+
successCheck: (id) => !!id,
|
|
151
|
+
logger: this.logger,
|
|
152
|
+
})
|
|
157
153
|
.catch((error) => {
|
|
158
154
|
this.logger.error(`Error while waiting for operation ID: ${error}`);
|
|
159
155
|
return undefined;
|
|
160
156
|
});
|
|
161
157
|
return { sendTransactionResult, operationId, ...transactionLinker };
|
|
162
158
|
}
|
|
163
|
-
async sendCrossChainTransactions(sender, txs,
|
|
159
|
+
async sendCrossChainTransactions(sender, txs, waitOptions) {
|
|
164
160
|
const caller = sender.getSenderAddress();
|
|
165
161
|
this.logger.debug(`Preparing ${txs.length} cross-chain transactions for ${caller}`);
|
|
166
162
|
const { transactions, transactionLinkers } = await this.prepareBatchTransactions(txs, sender);
|
|
167
163
|
await assets_1.TON.checkBalance(sender, this.config, transactions);
|
|
168
164
|
this.logger.debug(`Sending transactions: ${(0, Utils_1.formatObjectForLogging)(transactionLinkers)}`);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
throw (0, instances_1.sendCrossChainTransactionFailedError)(result.error?.message ?? 'Transaction failed to send');
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const shouldWaitForOperationIds = options?.waitOperationIds ?? true;
|
|
176
|
-
return shouldWaitForOperationIds
|
|
177
|
-
? await this.waitForOperationIds(transactionLinkers, caller, options?.waitOptions ?? {})
|
|
165
|
+
await sender.sendShardTransactions(transactions, this.config.network, this.config.TONParams.contractOpener);
|
|
166
|
+
return waitOptions
|
|
167
|
+
? await this.waitForOperationIds(transactionLinkers, caller, waitOptions)
|
|
178
168
|
: transactionLinkers;
|
|
179
169
|
}
|
|
180
170
|
async prepareBatchTransactions(txs, sender) {
|
|
@@ -183,7 +173,7 @@ class TONTransactionManager {
|
|
|
183
173
|
if (txsRequiringValidation.length) {
|
|
184
174
|
// Aggregate only assets from txs that require validation and validate once per unique asset
|
|
185
175
|
const assetsToValidate = txsRequiringValidation.flatMap((tx) => tx.assets ?? []);
|
|
186
|
-
const aggregatedData = (0, Utils_1.aggregateTokens)(assetsToValidate);
|
|
176
|
+
const aggregatedData = await (0, Utils_1.aggregateTokens)(assetsToValidate);
|
|
187
177
|
await Promise.all([
|
|
188
178
|
...aggregatedData.jettons.map((jetton) => jetton.checkCanBeTransferredBy(caller)),
|
|
189
179
|
...aggregatedData.nfts.map((nft) => nft.checkCanBeTransferredBy(caller)),
|
|
@@ -199,12 +189,12 @@ class TONTransactionManager {
|
|
|
199
189
|
async waitForOperationIds(transactionLinkers, caller, waitOptions) {
|
|
200
190
|
this.logger.debug(`Waiting for operation IDs`);
|
|
201
191
|
try {
|
|
202
|
-
|
|
203
|
-
waitOptions
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
const operationIds = await this.operationTracker.getOperationIdsByShardsKeys(transactionLinkers.map((linker) => linker.shardsKey), caller, {
|
|
193
|
+
...waitOptions,
|
|
194
|
+
logger: this.logger,
|
|
195
|
+
successCheck: (operationIds) => Object.keys(operationIds).length == transactionLinkers.length &&
|
|
196
|
+
Object.values(operationIds).every((ids) => ids.operationIds.length > 0),
|
|
197
|
+
});
|
|
208
198
|
this.logger.debug(`Operation IDs: ${(0, Utils_1.formatObjectForLogging)(operationIds)}`);
|
|
209
199
|
return transactionLinkers.map((linker) => ({
|
|
210
200
|
...linker,
|
package/dist/src/sdk/TacSdk.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JettonMinterData, NFTItemData } from '../../artifacts/tonTypes';
|
|
|
3
3
|
import { FT, NFT } from '../assets';
|
|
4
4
|
import { IConfiguration, ILogger, IOperationTracker, ITacSDK } from '../interfaces';
|
|
5
5
|
import type { SenderAbstraction } from '../sender';
|
|
6
|
-
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike,
|
|
6
|
+
import { AssetFromFTArg, AssetFromNFTCollectionArg, AssetFromNFTItemArg, AssetLike, CrossChainTransactionOptions, CrosschainTx, CrosschainTxWithAssetLike, EVMAddress, EvmProxyMsg, ExecutionFeeEstimationResult, NFTAddressType, OperationIdsByShardsKey, SDKParams, SuggestedTVMExecutorFee, TACSimulationParams, TACSimulationResult, TransactionLinkerWithOperationId, TVMAddress, UserWalletBalanceExtended, WaitOptions } from '../structs/Struct';
|
|
7
7
|
export declare class TacSdk implements ITacSDK {
|
|
8
8
|
readonly config: IConfiguration;
|
|
9
9
|
readonly operationTracker: IOperationTracker;
|
|
@@ -20,8 +20,8 @@ export declare class TacSdk implements ITacSDK {
|
|
|
20
20
|
get getTrustedTONExecutors(): string[];
|
|
21
21
|
getSimulationInfo(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<ExecutionFeeEstimationResult>;
|
|
22
22
|
getTVMExecutorFeeInfo(assets: AssetLike[], feeSymbol: string, tvmValidExecutors?: string[]): Promise<SuggestedTVMExecutorFee>;
|
|
23
|
-
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions): Promise<TransactionLinkerWithOperationId>;
|
|
24
|
-
sendCrossChainTransactions(sender: SenderAbstraction, txs:
|
|
23
|
+
sendCrossChainTransaction(evmProxyMsg: EvmProxyMsg, sender: SenderAbstraction, assets?: AssetLike[], options?: CrossChainTransactionOptions, waitOptions?: WaitOptions<string>): Promise<TransactionLinkerWithOperationId>;
|
|
24
|
+
sendCrossChainTransactions(sender: SenderAbstraction, txs: CrosschainTxWithAssetLike[], waitOptions?: WaitOptions<OperationIdsByShardsKey>): Promise<TransactionLinkerWithOperationId[]>;
|
|
25
25
|
bridgeTokensToTON(signer: Wallet, value: bigint, tonTarget: string, assets?: AssetLike[], tvmExecutorFee?: bigint, tvmValidExecutors?: string[]): Promise<string>;
|
|
26
26
|
isContractDeployedOnTVM(address: string): Promise<boolean>;
|
|
27
27
|
simulateTACMessage(req: TACSimulationParams): Promise<TACSimulationResult>;
|
package/dist/src/sdk/TacSdk.js
CHANGED
|
@@ -77,18 +77,18 @@ class TacSdk {
|
|
|
77
77
|
};
|
|
78
78
|
return this.operationTracker.getTVMExecutorFee(params);
|
|
79
79
|
}
|
|
80
|
-
async sendCrossChainTransaction(evmProxyMsg, sender, assets = [], options) {
|
|
80
|
+
async sendCrossChainTransaction(evmProxyMsg, sender, assets = [], options, waitOptions) {
|
|
81
81
|
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
82
82
|
const tx = { evmProxyMsg, assets: normalizedAssets, options };
|
|
83
|
-
return this.tonTransactionManager.sendCrossChainTransaction(evmProxyMsg, sender, tx);
|
|
83
|
+
return this.tonTransactionManager.sendCrossChainTransaction(evmProxyMsg, sender, tx, waitOptions);
|
|
84
84
|
}
|
|
85
|
-
async sendCrossChainTransactions(sender, txs,
|
|
85
|
+
async sendCrossChainTransactions(sender, txs, waitOptions) {
|
|
86
86
|
const normalizedTxs = await Promise.all(txs.map(async (tx) => ({
|
|
87
87
|
evmProxyMsg: tx.evmProxyMsg,
|
|
88
88
|
options: tx.options,
|
|
89
89
|
assets: await (0, Utils_1.normalizeAssets)(this.config, tx.assets),
|
|
90
90
|
})));
|
|
91
|
-
return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs,
|
|
91
|
+
return this.tonTransactionManager.sendCrossChainTransactions(sender, normalizedTxs, waitOptions);
|
|
92
92
|
}
|
|
93
93
|
async bridgeTokensToTON(signer, value, tonTarget, assets, tvmExecutorFee, tvmValidExecutors) {
|
|
94
94
|
const normalizedAssets = await (0, Utils_1.normalizeAssets)(this.config, assets);
|
|
@@ -46,9 +46,6 @@ class TonTxFinalizer {
|
|
|
46
46
|
const errorMessage = error.message;
|
|
47
47
|
// Rate limit error (429) - retry
|
|
48
48
|
if (errorMessage.includes('429')) {
|
|
49
|
-
if (i > 0) {
|
|
50
|
-
await (0, Utils_1.sleep)(delay);
|
|
51
|
-
}
|
|
52
49
|
continue;
|
|
53
50
|
}
|
|
54
51
|
// Log all errors except 404 Not Found
|
|
@@ -56,10 +53,8 @@ class TonTxFinalizer {
|
|
|
56
53
|
const logMessage = error instanceof Error ? error.message : error;
|
|
57
54
|
console.warn(`Failed to fetch adjacent transactions for ${hash}:`, logMessage);
|
|
58
55
|
}
|
|
59
|
-
if (i > 0) {
|
|
60
|
-
await (0, Utils_1.sleep)(delay);
|
|
61
|
-
}
|
|
62
56
|
}
|
|
57
|
+
await (0, Utils_1.sleep)(delay);
|
|
63
58
|
}
|
|
64
59
|
return [];
|
|
65
60
|
}
|
package/dist/src/sdk/Utils.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ export declare const generateFeeData: (feeParams?: FeeParams) => Cell | undefine
|
|
|
20
20
|
export declare function waitUntilSuccess<T, TContext = unknown, A extends unknown[] = unknown[]>(options: WaitOptions<T, TContext> | undefined, operation: (...args: A) => Promise<T>, operationDescription?: string, ...args: A): Promise<T>;
|
|
21
21
|
export declare function formatObjectForLogging(obj: unknown): string;
|
|
22
22
|
export declare function getBouncedAddress(tvmAddress: string): string;
|
|
23
|
-
export declare function aggregateTokens(assets?: Asset[]): {
|
|
23
|
+
export declare function aggregateTokens(assets?: Asset[]): Promise<{
|
|
24
24
|
jettons: FT[];
|
|
25
25
|
nfts: NFT[];
|
|
26
26
|
ton?: TON;
|
|
27
|
-
}
|
|
27
|
+
}>;
|
|
28
28
|
export declare function sha256toBigInt(ContractName: string): bigint;
|
|
29
29
|
export declare function mapAssetsToTonAssets(assets: Asset[]): TONAsset[];
|
|
30
30
|
export declare function normalizeAsset(config: IConfiguration, input: AssetLike): Promise<Asset>;
|
package/dist/src/sdk/Utils.js
CHANGED
|
@@ -199,30 +199,39 @@ function getBouncedAddress(tvmAddress) {
|
|
|
199
199
|
bounceable: true,
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
-
function aggregateTokens(assets) {
|
|
203
|
-
const
|
|
204
|
-
const nftsMap = new Map();
|
|
202
|
+
async function aggregateTokens(assets) {
|
|
203
|
+
const uniqueAssetsMap = new Map();
|
|
205
204
|
let ton;
|
|
206
|
-
for (const asset of assets ?? []) {
|
|
207
|
-
if (asset.
|
|
205
|
+
for await (const asset of assets ?? []) {
|
|
206
|
+
if (asset.type !== Struct_1.AssetType.FT)
|
|
207
|
+
continue;
|
|
208
|
+
if (asset.rawAmount === 0n) {
|
|
208
209
|
throw (0, errors_1.zeroRawAmountError)(asset.address || 'NATIVE TON');
|
|
209
210
|
}
|
|
210
|
-
if (asset.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
const existing = jettonsMap.get(asset.address);
|
|
216
|
-
jettonsMap.set(asset.address, (existing ? existing.addRawAmount(asset.rawAmount) : asset.clone));
|
|
217
|
-
}
|
|
211
|
+
if (!asset.address) {
|
|
212
|
+
ton = ton ? ton.addRawAmount(asset.rawAmount) : asset.clone;
|
|
213
|
+
continue;
|
|
218
214
|
}
|
|
219
|
-
|
|
220
|
-
|
|
215
|
+
let jetton = uniqueAssetsMap.get(asset.address);
|
|
216
|
+
if (!jetton) {
|
|
217
|
+
jetton = asset.clone;
|
|
221
218
|
}
|
|
219
|
+
else {
|
|
220
|
+
jetton = jetton.addRawAmount(asset.rawAmount);
|
|
221
|
+
}
|
|
222
|
+
uniqueAssetsMap.set(asset.address, jetton);
|
|
223
|
+
}
|
|
224
|
+
const jettons = Array.from(uniqueAssetsMap.values());
|
|
225
|
+
uniqueAssetsMap.clear();
|
|
226
|
+
for await (const asset of assets ?? []) {
|
|
227
|
+
if (asset.type !== Struct_1.AssetType.NFT)
|
|
228
|
+
continue;
|
|
229
|
+
uniqueAssetsMap.set(asset.address, asset.clone);
|
|
222
230
|
}
|
|
231
|
+
const nfts = Array.from(uniqueAssetsMap.values());
|
|
223
232
|
return {
|
|
224
|
-
jettons
|
|
225
|
-
nfts
|
|
233
|
+
jettons,
|
|
234
|
+
nfts,
|
|
226
235
|
ton,
|
|
227
236
|
};
|
|
228
237
|
}
|
|
@@ -231,11 +240,7 @@ function sha256toBigInt(ContractName) {
|
|
|
231
240
|
return BigInt('0x' + hash.toString('hex'));
|
|
232
241
|
}
|
|
233
242
|
function mapAssetsToTonAssets(assets) {
|
|
234
|
-
|
|
235
|
-
const result = [...jettons, ...nfts];
|
|
236
|
-
if (ton)
|
|
237
|
-
result.push(ton);
|
|
238
|
-
return result.map((asset) => ({
|
|
243
|
+
return assets.map((asset) => ({
|
|
239
244
|
amount: asset.rawAmount.toString(),
|
|
240
245
|
tokenAddress: asset.address || '',
|
|
241
246
|
assetType: asset.type,
|
|
@@ -263,15 +268,9 @@ async function normalizeAsset(config, input) {
|
|
|
263
268
|
const asset = await assets_1.AssetFactory.from(config, ftArgs);
|
|
264
269
|
const rawAmount = 'rawAmount' in input ? input.rawAmount : undefined;
|
|
265
270
|
const amount = 'amount' in input ? input.amount : 0;
|
|
266
|
-
if (!rawAmount && !amount && asset.type === Struct_1.AssetType.FT) {
|
|
267
|
-
throw (0, errors_1.zeroRawAmountError)(asset.address || 'NATIVE TON');
|
|
268
|
-
}
|
|
269
271
|
return rawAmount ? asset.withRawAmount(rawAmount) : asset.withAmount(amount);
|
|
270
272
|
}
|
|
271
273
|
catch (e) {
|
|
272
|
-
if (e instanceof errors_1.TokenError && e.errorCode === (0, errors_1.zeroRawAmountError)('').errorCode) {
|
|
273
|
-
throw e;
|
|
274
|
-
}
|
|
275
274
|
console.warn('Failed to normalize FT asset', e);
|
|
276
275
|
}
|
|
277
276
|
const itemArgs = {
|
|
@@ -38,7 +38,7 @@ class SenderFactory {
|
|
|
38
38
|
if (params.version === 'V5R1') {
|
|
39
39
|
// manual setup of wallet id required to support wallet w5 both on mainnet and testnet
|
|
40
40
|
config.walletId = {
|
|
41
|
-
networkGlobalId: params.network === Struct_1.Network.
|
|
41
|
+
networkGlobalId: params.network === Struct_1.Network.TESTNET ? -3 : -239,
|
|
42
42
|
context: {
|
|
43
43
|
walletVersion: 'v5r1',
|
|
44
44
|
workchain: 0,
|
|
@@ -28,7 +28,7 @@ class TonConnectSender {
|
|
|
28
28
|
const transaction = {
|
|
29
29
|
validUntil,
|
|
30
30
|
messages: chunk,
|
|
31
|
-
network: chain == Struct_1.Network.
|
|
31
|
+
network: chain == Struct_1.Network.TESTNET ? ui_1.CHAIN.TESTNET : ui_1.CHAIN.MAINNET,
|
|
32
32
|
};
|
|
33
33
|
try {
|
|
34
34
|
const response = await this.tonConnect.sendTransaction(transaction);
|
|
@@ -54,11 +54,6 @@ export type StageProfilingResponse = ResponseBase<ExecutionStagesByOperationId>;
|
|
|
54
54
|
export type TACSimulationResponse = ResponseBase<TACSimulationResult>;
|
|
55
55
|
export type SuggestedTVMExecutorFeeResponse = ResponseBase<SuggestedTVMExecutorFee>;
|
|
56
56
|
export type ConvertCurrencyResponse = ResponseBase<ConvertedCurrencyRawResult>;
|
|
57
|
-
export type OperationIdWithLogIndex = {
|
|
58
|
-
operationId: string;
|
|
59
|
-
logIndex: number;
|
|
60
|
-
};
|
|
61
|
-
export type OperationIdWithLogIndexResponse = ResponseBase<OperationIdWithLogIndex>;
|
|
62
57
|
export interface SendResult {
|
|
63
58
|
success: boolean;
|
|
64
59
|
result?: unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SandboxContract } from '@ton/sandbox';
|
|
2
2
|
import { OpenedContract } from '@ton/ton';
|
|
3
|
-
import { AbstractProvider } from 'ethers';
|
|
3
|
+
import { AbstractProvider, Addressable } from 'ethers';
|
|
4
4
|
import { JettonMinter, JettonMinterData } from '../../artifacts/tonTypes';
|
|
5
5
|
import type { FT, NFT } from '../assets';
|
|
6
6
|
import type { Asset, ContractOpener, ILogger } from '../interfaces';
|
|
@@ -44,11 +44,7 @@ export type TACParams = {
|
|
|
44
44
|
/**
|
|
45
45
|
* Address of TAC settings contract. Use only for tests.
|
|
46
46
|
*/
|
|
47
|
-
settingsAddress?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Address of TAC smart account factory contract. Use only for tests.
|
|
50
|
-
*/
|
|
51
|
-
saFactoryAddress?: string;
|
|
47
|
+
settingsAddress?: string | Addressable;
|
|
52
48
|
};
|
|
53
49
|
export type TONParams = {
|
|
54
50
|
/**
|
|
@@ -291,13 +287,6 @@ export type CrossChainTransactionOptions = {
|
|
|
291
287
|
calculateRollbackFee?: boolean;
|
|
292
288
|
withoutSimulation?: boolean;
|
|
293
289
|
validateAssetsBalance?: boolean;
|
|
294
|
-
waitOperationId?: boolean;
|
|
295
|
-
waitOptions?: WaitOptions<string>;
|
|
296
|
-
};
|
|
297
|
-
export type BatchCrossChainTransactionOptions = Omit<CrossChainTransactionOptions, 'waitOperationId' | 'waitOptions'>;
|
|
298
|
-
export type CrossChainTransactionsOptions = {
|
|
299
|
-
waitOperationIds?: boolean;
|
|
300
|
-
waitOptions?: WaitOptions<OperationIdsByShardsKey>;
|
|
301
290
|
};
|
|
302
291
|
export type ExecutionFeeEstimationResult = {
|
|
303
292
|
feeParams: FeeParams;
|
|
@@ -308,11 +297,6 @@ export type CrosschainTx = {
|
|
|
308
297
|
assets?: Asset[];
|
|
309
298
|
options?: CrossChainTransactionOptions;
|
|
310
299
|
};
|
|
311
|
-
export type BatchCrossChainTx = {
|
|
312
|
-
evmProxyMsg: EvmProxyMsg;
|
|
313
|
-
assets?: Asset[];
|
|
314
|
-
options?: BatchCrossChainTransactionOptions;
|
|
315
|
-
};
|
|
316
300
|
export type AssetLike = Asset | FT | NFT | {
|
|
317
301
|
rawAmount: bigint;
|
|
318
302
|
} | {
|
|
@@ -329,7 +313,7 @@ export type AssetLike = Asset | FT | NFT | {
|
|
|
329
313
|
address: TVMAddress | EVMAddress;
|
|
330
314
|
itemIndex: bigint;
|
|
331
315
|
};
|
|
332
|
-
export type
|
|
316
|
+
export type CrosschainTxWithAssetLike = Omit<CrosschainTx, 'assets'> & {
|
|
333
317
|
assets?: AssetLike[];
|
|
334
318
|
};
|
|
335
319
|
export interface WaitOptions<T = unknown, TContext = unknown> {
|