@rhea-finance/cross-chain-sdk 0.1.11 → 0.1.12
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/index.cjs +33 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +33 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20660,12 +20660,35 @@ async function prepareBusinessDataOninnerWithdraw({
|
|
|
20660
20660
|
destinationAsset,
|
|
20661
20661
|
amountToken,
|
|
20662
20662
|
gas_token_id,
|
|
20663
|
-
gas_token_amount
|
|
20663
|
+
gas_token_amount,
|
|
20664
|
+
swapTokenId,
|
|
20665
|
+
swapAmountToken
|
|
20664
20666
|
}) {
|
|
20667
|
+
const needsSwap = swapTokenId && swapTokenId !== tokenId;
|
|
20668
|
+
let swap_txs = [];
|
|
20669
|
+
let register_receive_token_tx = [];
|
|
20670
|
+
let bridgeAmount = amountToken;
|
|
20671
|
+
if (needsSwap) {
|
|
20672
|
+
const swapResult = await swap_tx_query({
|
|
20673
|
+
tokenId: swapTokenId,
|
|
20674
|
+
amountToken: swapAmountToken || amountToken,
|
|
20675
|
+
tokenOutId: tokenId,
|
|
20676
|
+
receiverId: mca
|
|
20677
|
+
});
|
|
20678
|
+
if (swapResult.status === "error") {
|
|
20679
|
+
throw new Error(swapResult.message || "No path available to make a swap");
|
|
20680
|
+
}
|
|
20681
|
+
swap_txs = swapResult.swap_txs;
|
|
20682
|
+
bridgeAmount = new Big3__default.default(swapResult.amountOut).toFixed(0, Big3__default.default.roundDown);
|
|
20683
|
+
register_receive_token_tx = await query_account_register_token_tx({
|
|
20684
|
+
accountId: mca,
|
|
20685
|
+
tokenId
|
|
20686
|
+
});
|
|
20687
|
+
}
|
|
20665
20688
|
const quoteResult = await intentsQuotation({
|
|
20666
20689
|
originAsset,
|
|
20667
20690
|
destinationAsset,
|
|
20668
|
-
amount:
|
|
20691
|
+
amount: bridgeAmount,
|
|
20669
20692
|
refundTo: mca,
|
|
20670
20693
|
recipient
|
|
20671
20694
|
});
|
|
@@ -20673,21 +20696,21 @@ async function prepareBusinessDataOninnerWithdraw({
|
|
|
20673
20696
|
const intents_tansfer_txs = query_intents_tansfer_txs({
|
|
20674
20697
|
tokenId,
|
|
20675
20698
|
depositAddress,
|
|
20676
|
-
amountToken
|
|
20699
|
+
amountToken: bridgeAmount
|
|
20677
20700
|
});
|
|
20678
20701
|
const { nonce, deadline } = await get_nonce_deadline({ accountId: mca });
|
|
20679
20702
|
const businessMap = {
|
|
20680
20703
|
nonce,
|
|
20681
20704
|
deadline,
|
|
20682
20705
|
tx_requests: [
|
|
20683
|
-
|
|
20684
|
-
{
|
|
20685
|
-
|
|
20686
|
-
|
|
20687
|
-
amount: gas_token_amount
|
|
20688
|
-
}
|
|
20706
|
+
{
|
|
20707
|
+
GasPayment: {
|
|
20708
|
+
token_id: gas_token_id,
|
|
20709
|
+
amount: gas_token_amount
|
|
20689
20710
|
}
|
|
20690
|
-
|
|
20711
|
+
},
|
|
20712
|
+
...register_receive_token_tx,
|
|
20713
|
+
...swap_txs,
|
|
20691
20714
|
...intents_tansfer_txs
|
|
20692
20715
|
]
|
|
20693
20716
|
};
|