@rango-dev/queue-manager-rango-preset 0.1.10-next.95 → 0.1.10-next.98
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/actions/executeTransaction.d.ts.map +1 -1
- package/dist/helpers.d.ts +5 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.development.js +47 -20
- package/dist/queue-manager-rango-preset.cjs.development.js.map +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js +1 -1
- package/dist/queue-manager-rango-preset.cjs.production.min.js.map +1 -1
- package/dist/queue-manager-rango-preset.esm.js +47 -21
- package/dist/queue-manager-rango-preset.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/actions/executeTransaction.ts +7 -3
- package/src/helpers.ts +40 -6
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -57,9 +57,13 @@ export async function executeTransaction(
|
|
|
57
57
|
const isWrongAddress = !isRequiredWalletConnected(swap, context.state);
|
|
58
58
|
if (isWrongAddress) {
|
|
59
59
|
const { type, address } = getRequiredWallet(swap);
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const isWalletInCompatible = wallets?.blockchains?.find(
|
|
61
|
+
(w) => !w.accounts?.find((account) => account.walletType === type)
|
|
62
|
+
);
|
|
63
|
+
const description =
|
|
64
|
+
!wallets || isWalletInCompatible
|
|
65
|
+
? ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION(type)
|
|
66
|
+
: ERROR_MESSAGE_WAIT_FOR_WALLET_DESCRIPTION_WRONG_WALLET(type, address);
|
|
63
67
|
|
|
64
68
|
const blockedFor = {
|
|
65
69
|
reason: BlockReason.WAIT_FOR_CONNECT_WALLET,
|
package/src/helpers.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ExecuterActions,
|
|
3
|
+
QueueInfo,
|
|
4
|
+
QueueType,
|
|
5
|
+
} from '@rango-dev/queue-manager-core';
|
|
2
6
|
import {
|
|
3
7
|
BlockReason,
|
|
4
8
|
SwapActionTypes,
|
|
@@ -87,6 +91,16 @@ function claimQueue() {
|
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* Returns "wallet and network" separately, even if the wallet is dashed inside.
|
|
97
|
+
*
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
function splitWalletNetwork(input: string): string[] {
|
|
101
|
+
return input?.split(/-(?=[^-]*$)/);
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
/**
|
|
91
105
|
*
|
|
92
106
|
* Returns `steps`, if it's a `running` swap.
|
|
@@ -1521,8 +1535,7 @@ export function checkWaitingForConnectWalletChange(params: {
|
|
|
1521
1535
|
evmChains: EvmBlockchainMeta[];
|
|
1522
1536
|
}): void {
|
|
1523
1537
|
const { wallet_network, evmChains, manager } = params;
|
|
1524
|
-
const [wallet, network] = wallet_network
|
|
1525
|
-
|
|
1538
|
+
const [wallet, network] = splitWalletNetwork(wallet_network);
|
|
1526
1539
|
// We only need change network for EVM chains.
|
|
1527
1540
|
if (!evmChains.some((chain) => chain.name == network)) return;
|
|
1528
1541
|
|
|
@@ -1547,7 +1560,11 @@ export function checkWaitingForConnectWalletChange(params: {
|
|
|
1547
1560
|
}
|
|
1548
1561
|
);
|
|
1549
1562
|
|
|
1550
|
-
if (
|
|
1563
|
+
if (
|
|
1564
|
+
currentStepRequiredWallet === wallet &&
|
|
1565
|
+
hasWaitingForConnect &&
|
|
1566
|
+
getCurrentBlockchainOfOrNull(swap, currentStep) != network
|
|
1567
|
+
) {
|
|
1551
1568
|
const queueInstance = q.list;
|
|
1552
1569
|
const { type } = getRequiredWallet(swap);
|
|
1553
1570
|
const description = ERROR_MESSAGE_WAIT_FOR_CHANGE_NETWORK(type);
|
|
@@ -1620,7 +1637,7 @@ export function retryOn(
|
|
|
1620
1637
|
manager?: Manager,
|
|
1621
1638
|
options = { fallbackToOnlyWallet: true }
|
|
1622
1639
|
): void {
|
|
1623
|
-
const [wallet, network] = wallet_network
|
|
1640
|
+
const [wallet, network] = splitWalletNetwork(wallet_network);
|
|
1624
1641
|
if (!wallet || !network) {
|
|
1625
1642
|
return;
|
|
1626
1643
|
}
|
|
@@ -1638,7 +1655,7 @@ export function retryOn(
|
|
|
1638
1655
|
const currentStep = getCurrentStep(swap);
|
|
1639
1656
|
if (currentStep) {
|
|
1640
1657
|
if (
|
|
1641
|
-
currentStep
|
|
1658
|
+
getCurrentBlockchainOfOrNull(swap, currentStep) == network &&
|
|
1642
1659
|
queueStorage?.swapDetails.wallets[network]?.walletType === wallet
|
|
1643
1660
|
) {
|
|
1644
1661
|
walletAndNetworkMatched.push(q.list);
|
|
@@ -1706,3 +1723,20 @@ export async function throwOnOK(
|
|
|
1706
1723
|
throw e;
|
|
1707
1724
|
}
|
|
1708
1725
|
}
|
|
1726
|
+
|
|
1727
|
+
export function cancelSwap(swap: QueueInfo): {
|
|
1728
|
+
swap: PendingSwap;
|
|
1729
|
+
step: PendingSwapStep | null;
|
|
1730
|
+
} {
|
|
1731
|
+
swap.actions.cancel();
|
|
1732
|
+
return updateSwapStatus({
|
|
1733
|
+
getStorage: swap.actions.getStorage,
|
|
1734
|
+
setStorage: swap.actions.setStorage,
|
|
1735
|
+
message: 'Swap canceled by user.',
|
|
1736
|
+
details:
|
|
1737
|
+
"Warning: If you've already signed and sent a transaction, it won't be affected, but next swap steps will not be executed.",
|
|
1738
|
+
nextStatus: 'failed',
|
|
1739
|
+
nextStepStatus: 'failed',
|
|
1740
|
+
errorCode: 'USER_CANCEL',
|
|
1741
|
+
});
|
|
1742
|
+
}
|