@rango-dev/widget-embedded 0.27.3-next.5 → 0.27.3
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/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useFetch.d.ts +1 -1
- package/dist/hooks/useFetch.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -3
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +4 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +1 -19
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +22 -23
- package/src/components/Quote/Quote.styles.ts +1 -19
- package/src/components/Quote/Quote.tsx +2 -12
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +3 -3
- package/src/hooks/useFetch.ts +2 -13
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +1 -1
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +1 -10
- package/src/pages/ConfirmSwapPage.tsx +0 -65
- package/src/pages/Home.tsx +2 -1
- package/src/utils/swap.ts +32 -32
- package/src/utils/wallets.ts +30 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAuD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmSwapPage.d.ts","sourceRoot":"","sources":["../../src/pages/ConfirmSwapPage.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAuD,MAAM,OAAO,CAAC;AA6C5E,wBAAgB,eAAe,sBA8P9B"}
|
package/dist/pages/Home.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA8B,MAAM,OAAO,CAAC;AA4BnD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,wBAAgB,IAAI,sBA0MnB"}
|
package/dist/utils/swap.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ export declare function getSwapButtonState(params: {
|
|
|
25
25
|
needsToWarnEthOnPath: boolean;
|
|
26
26
|
}): SwapButtonState;
|
|
27
27
|
export declare function canComputePriceImpact(quote: SelectedQuote | null, inputAmount: string, usdValue: BigNumber | null): boolean;
|
|
28
|
-
export declare function requiredWallets(quote: SelectedQuote | null): string[];
|
|
29
28
|
export declare const getUsdPrice: (blockchain: string, symbol: string, address: string | null, allTokens: Token[]) => number | null;
|
|
30
29
|
export declare function getUsdFeeOfStep(step: SwapResult, allTokens: Token[]): BigNumber;
|
|
31
30
|
export declare function getTotalFeeInUsd(swaps: SwapResult[], allTokens: Token[]): BigNumber;
|
|
@@ -79,9 +78,9 @@ export declare function getSwapMessages(pendingSwap: PendingSwap, currentStep: P
|
|
|
79
78
|
};
|
|
80
79
|
export declare function getLastConvertedTokenInFailedSwap(pendingSwap: PendingSwap): ConvertedToken;
|
|
81
80
|
export declare function shouldRetrySwap(pendingSwap: PendingSwap): boolean;
|
|
82
|
-
export declare function
|
|
81
|
+
export declare function isConfirmSwapDisabled(fetching: boolean, showCustomDestination: boolean, customDestination: string | null, quote: SelectedQuote | null, selectedWallets: {
|
|
83
82
|
walletType: string;
|
|
84
83
|
chain: string;
|
|
85
|
-
}[], lastStepToBlockchain
|
|
84
|
+
}[], lastStepToBlockchain: BlockchainMeta | undefined): boolean;
|
|
86
85
|
export declare function isTokensIdentical(tokenA: Token, tokenB: Token): boolean;
|
|
87
86
|
//# sourceMappingURL=swap.d.ts.map
|
package/dist/utils/swap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/utils/swap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,MAAM,EACP,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGhE,OAAO,SAAS,MA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AAE,MAAM,GAAG,IAAI,aAK3B;AAED,wBAAgB,6BAA6B,CAC3C,eAAe,EAAE,eAAe,GAAG,IAAI,GACtC,OAAO,CAMT;AAED,wBAAgB,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,eAAe,GAAG,IAAI,GAClC;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;CACrD,CAyCA;AAED,wBAAgB,iCAAiC,CAC/C,WAAW,EAAE,WAAW,GACvB,cAAc,CAkBhB;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,WAAW,WAEvD;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EACjB,qBAAqB,EAAE,OAAO,EAC9B,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,KAAK,EAAE,aAAa,GAAG,IAAI,EAC3B,eAAe,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EACxD,oBAAoB,EAAE,cAAc,GAAG,SAAS,GAC/C,OAAO,CA+BT;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAM7D"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -8,7 +8,10 @@ export declare function mapStatusToWalletState(state: WalletState): WalletStatus
|
|
|
8
8
|
export declare function mapWalletTypesToWalletInfo(getState: (type: WalletType) => WalletState, getWalletInfo: (type: WalletType) => WalletInfo, list: WalletType[], chain?: string): ModalWalletInfo[];
|
|
9
9
|
export declare function walletAndSupportedChainsNames(supportedBlockchains: BlockchainMeta[]): Network[] | null;
|
|
10
10
|
export declare function prepareAccountsForWalletStore(wallet: WalletType, accounts: string[], evmBasedChains: string[], supportedChainNames: Network[] | null, isContractWallet: boolean): Wallet[];
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function getQuoteWallets(params: {
|
|
12
|
+
filter: 'all' | 'required';
|
|
13
|
+
quote: SelectedQuote | null;
|
|
14
|
+
}): string[];
|
|
12
15
|
export declare function isAccountAndWalletMatched(account: Wallet, connectedWallet: ConnectedWallet): boolean;
|
|
13
16
|
export declare function makeBalanceFor(retrievedBalance: WalletDetail, tokens: Token[]): TokenBalance[];
|
|
14
17
|
export declare function resetConnectedWalletState(connectedWallet: ConnectedWallet): ConnectedWallet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,aAAa,EACb,MAAM,EACP,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EAEX,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAErE,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,eAAe,CAAC;AAuB5D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,WAAW,GAAG,YAAY,CAWvE;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,WAAW,EAC3C,aAAa,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,EAC/C,IAAI,EAAE,UAAU,EAAE,EAClB,KAAK,CAAC,EAAE,MAAM,GACb,eAAe,EAAE,CAmCnB;AAED,wBAAgB,6BAA6B,CAC3C,oBAAoB,EAAE,cAAc,EAAE,GACrC,OAAO,EAAE,GAAG,IAA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GAAG,SAAS,CAAC,GAAG,IAAI,WAOhE;AAED,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,eAAe,EAAE,GACzB,eAAe,EAAE,CAcnB;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EAEf,QAAQ,SAAI,EAEZ,cAAc,SAAI,GACjB,MAAM,CAOR;AAED,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,SAAS,CAMrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,eAAe,EAAE,iBAmCpE;AAED,eAAO,MAAM,iBAAiB,qBACV,eAAe,EAAE,cACvB,MAAM,YAIjB,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,eAAe,EAAE,UAE9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.27.3
|
|
3
|
+
"version": "0.27.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
|
-
"@rango-dev/logging-core": "^0.2.
|
|
28
|
-
"@rango-dev/provider-all": "^0.32.
|
|
27
|
+
"@rango-dev/logging-core": "^0.2.0",
|
|
28
|
+
"@rango-dev/provider-all": "^0.32.1",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.32.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.32.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
32
|
-
"@rango-dev/ui": "^0.33.
|
|
33
|
-
"@rango-dev/wallets-react": "^0.18.
|
|
34
|
-
"@rango-dev/wallets-shared": "^0.32.
|
|
32
|
+
"@rango-dev/ui": "^0.33.0",
|
|
33
|
+
"@rango-dev/wallets-react": "^0.18.0",
|
|
34
|
+
"@rango-dev/wallets-shared": "^0.32.0",
|
|
35
35
|
"bignumber.js": "^9.1.1",
|
|
36
36
|
"copy-to-clipboard": "^3.3.3",
|
|
37
37
|
"dayjs": "^1.11.7",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
import type { BlockchainMeta
|
|
2
|
-
|
|
3
|
-
export function getRequiredWallets(swaps: SwapResult[] | null): string[] {
|
|
4
|
-
const wallets: string[] = [];
|
|
5
|
-
|
|
6
|
-
swaps?.forEach((swap) => {
|
|
7
|
-
const currentStepFromBlockchain = swap.from.blockchain;
|
|
8
|
-
const currentStepToBlockchain = swap.to.blockchain;
|
|
9
|
-
let lastAddedWallet = wallets[wallets.length - 1];
|
|
10
|
-
if (currentStepFromBlockchain != lastAddedWallet) {
|
|
11
|
-
wallets.push(currentStepFromBlockchain);
|
|
12
|
-
}
|
|
13
|
-
lastAddedWallet = wallets[wallets.length - 1];
|
|
14
|
-
if (currentStepToBlockchain != lastAddedWallet) {
|
|
15
|
-
wallets.push(currentStepToBlockchain);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return wallets;
|
|
19
|
-
}
|
|
1
|
+
import type { BlockchainMeta } from 'rango-sdk';
|
|
20
2
|
|
|
21
3
|
export function isValidAddress(
|
|
22
4
|
chain: BlockchainMeta,
|
|
@@ -24,12 +24,13 @@ import { useAppStore } from '../../store/AppStore';
|
|
|
24
24
|
import { useQuoteStore } from '../../store/quote';
|
|
25
25
|
import { useWalletsStore } from '../../store/wallets';
|
|
26
26
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
27
|
-
import {
|
|
27
|
+
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
28
|
+
import { getQuoteWallets } from '../../utils/wallets';
|
|
28
29
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
29
30
|
import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
|
|
30
31
|
import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
|
|
31
32
|
|
|
32
|
-
import {
|
|
33
|
+
import { isValidAddress } from './ConfirmWallets.helpers';
|
|
33
34
|
import {
|
|
34
35
|
alarmsStyles,
|
|
35
36
|
ConfirmButton,
|
|
@@ -74,7 +75,15 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
74
75
|
!!customDestination
|
|
75
76
|
);
|
|
76
77
|
|
|
77
|
-
const
|
|
78
|
+
const quoteWallets = getQuoteWallets({
|
|
79
|
+
filter: 'all',
|
|
80
|
+
quote: selectedQuote,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const requiredWallets = getQuoteWallets({
|
|
84
|
+
filter: 'required',
|
|
85
|
+
quote: selectedQuote,
|
|
86
|
+
});
|
|
78
87
|
|
|
79
88
|
const lastStepToBlockchain = blockchains.find(
|
|
80
89
|
(blockchain) =>
|
|
@@ -82,22 +91,18 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
82
91
|
selectedQuote?.swaps[selectedQuote?.swaps.length - 1].to.blockchain
|
|
83
92
|
);
|
|
84
93
|
const isWalletRequiredFor = (blockchain: string) =>
|
|
85
|
-
|
|
94
|
+
requiredWallets.includes(blockchain);
|
|
86
95
|
|
|
87
96
|
const getInitialSelectableWallets = () =>
|
|
88
97
|
connectedWallets.filter((connectedWallet) => {
|
|
89
98
|
return (
|
|
90
|
-
connectedWallet.selected &&
|
|
91
|
-
requiredWallets.includes(connectedWallet.chain)
|
|
99
|
+
connectedWallet.selected && quoteWallets.includes(connectedWallet.chain)
|
|
92
100
|
);
|
|
93
101
|
});
|
|
94
102
|
|
|
95
103
|
const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
|
|
96
104
|
getInitialSelectableWallets()
|
|
97
105
|
);
|
|
98
|
-
const lastStepToBlockchainMeta = blockchains.find(
|
|
99
|
-
(chain) => chain.name === lastStepToBlockchain?.name
|
|
100
|
-
);
|
|
101
106
|
|
|
102
107
|
const isInsufficientBalanceModalOpen = balanceWarnings.length > 0;
|
|
103
108
|
|
|
@@ -114,8 +119,8 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
114
119
|
const isAddressMatched =
|
|
115
120
|
!!customDestination &&
|
|
116
121
|
showCustomDestination &&
|
|
117
|
-
|
|
118
|
-
!isValidAddress(
|
|
122
|
+
lastStepToBlockchain &&
|
|
123
|
+
!isValidAddress(lastStepToBlockchain, customDestination);
|
|
119
124
|
|
|
120
125
|
const resetCustomDestination = () => {
|
|
121
126
|
setShowCustomDestination(false);
|
|
@@ -182,15 +187,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
182
187
|
setBalanceWarnings([]);
|
|
183
188
|
setError('');
|
|
184
189
|
setQuoteWarning(null);
|
|
185
|
-
|
|
186
|
-
selectableWallets.find(
|
|
187
|
-
(selectableWallet) =>
|
|
188
|
-
selectableWallet.chain === connectedWallet.chain &&
|
|
189
|
-
selectableWallet.walletType === connectedWallet.walletType
|
|
190
|
-
)
|
|
191
|
-
);
|
|
190
|
+
|
|
192
191
|
const result = await onCheckBalance?.({
|
|
193
|
-
selectedWallets,
|
|
192
|
+
selectedWallets: selectableWallets.filter((wallet) => wallet.selected),
|
|
194
193
|
customDestination,
|
|
195
194
|
});
|
|
196
195
|
const warnings = result.warnings;
|
|
@@ -223,7 +222,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
223
222
|
return (
|
|
224
223
|
!anyWalletSelected &&
|
|
225
224
|
connectedWallet.selected &&
|
|
226
|
-
|
|
225
|
+
quoteWallets.includes(connectedWallet.chain)
|
|
227
226
|
);
|
|
228
227
|
})
|
|
229
228
|
)
|
|
@@ -253,7 +252,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
253
252
|
<ConfirmButton>
|
|
254
253
|
<Button
|
|
255
254
|
loading={loading}
|
|
256
|
-
disabled={
|
|
255
|
+
disabled={isConfirmSwapDisabled(
|
|
257
256
|
loading,
|
|
258
257
|
showCustomDestination,
|
|
259
258
|
customDestination,
|
|
@@ -344,13 +343,13 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
344
343
|
</>
|
|
345
344
|
)}
|
|
346
345
|
<Wallets>
|
|
347
|
-
{
|
|
346
|
+
{quoteWallets.map((requiredWallet, index) => {
|
|
348
347
|
const blockchain = blockchains.find(
|
|
349
348
|
(blockchain) => blockchain.name === requiredWallet
|
|
350
349
|
);
|
|
351
350
|
|
|
352
351
|
const key = `wallet-${index}`;
|
|
353
|
-
const isLastWallet = index ===
|
|
352
|
+
const isLastWallet = index === quoteWallets.length - 1;
|
|
354
353
|
|
|
355
354
|
return (
|
|
356
355
|
<div key={key}>
|
|
@@ -63,25 +63,7 @@ export const stepsDetailsStyles = css({
|
|
|
63
63
|
});
|
|
64
64
|
export const AllRoutesButton = styled(Button, {
|
|
65
65
|
backgroundColor: 'transparent',
|
|
66
|
-
border: '1px solid $
|
|
67
|
-
[`.${darkTheme} &`]: {
|
|
68
|
-
border: '1px solid $secondary',
|
|
69
|
-
},
|
|
70
|
-
transition: 'background-color 0.3s ease',
|
|
71
|
-
'&:hover': {
|
|
72
|
-
backgroundColor: '$secondary600',
|
|
73
|
-
[`.${darkTheme} &`]: {
|
|
74
|
-
backgroundColor: '$secondary',
|
|
75
|
-
},
|
|
76
|
-
'.allRoutesLabel': {
|
|
77
|
-
$$color: '$colors$background',
|
|
78
|
-
[`.${darkTheme} &`]: {
|
|
79
|
-
$$color: '$colors$foreground',
|
|
80
|
-
},
|
|
81
|
-
color: '$$color',
|
|
82
|
-
transition: 'color 0.3s ease',
|
|
83
|
-
},
|
|
84
|
-
},
|
|
66
|
+
border: '1px solid $secondary',
|
|
85
67
|
});
|
|
86
68
|
export const SummaryContainer = styled('div', {
|
|
87
69
|
borderRadius: '$xm',
|
|
@@ -381,18 +381,8 @@ export function Quote(props: QuoteProps) {
|
|
|
381
381
|
}}
|
|
382
382
|
size="xxsmall"
|
|
383
383
|
type="secondary"
|
|
384
|
-
variant="default"
|
|
385
|
-
|
|
386
|
-
paddingLeft: '$10',
|
|
387
|
-
paddingRight: '$10',
|
|
388
|
-
paddingTop: '$5',
|
|
389
|
-
paddingBottom: '$5',
|
|
390
|
-
}}>
|
|
391
|
-
<Typography
|
|
392
|
-
color="secondary"
|
|
393
|
-
variant="body"
|
|
394
|
-
size="xsmall"
|
|
395
|
-
className="allRoutesLabel">
|
|
384
|
+
variant="default">
|
|
385
|
+
<Typography color="secondary" variant="label" size="medium">
|
|
396
386
|
{i18n.t('See All Routes')}
|
|
397
387
|
</Typography>
|
|
398
388
|
</AllRoutesButton>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfirmSwap } from './useConfirmSwap.types';
|
|
1
|
+
import type { ConfirmSwap, Params } from './useConfirmSwap.types';
|
|
2
2
|
import type { PendingSwapSettings, SelectedQuote } from '../../types';
|
|
3
3
|
import type { ConfirmRouteRequest } from 'rango-sdk';
|
|
4
4
|
|
|
@@ -39,7 +39,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
39
39
|
|
|
40
40
|
useEffect(() => cancelFetch, []);
|
|
41
41
|
|
|
42
|
-
const fetch: ConfirmSwap['fetch'] = async (params) => {
|
|
42
|
+
const fetch: ConfirmSwap['fetch'] = async (params: Params) => {
|
|
43
43
|
const selectedWallets = params.selectedWallets;
|
|
44
44
|
const customDestination =
|
|
45
45
|
params?.customDestination ?? customDestinationFromStore;
|
|
@@ -67,7 +67,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
try {
|
|
70
|
-
return await fetchQuote(requestBody
|
|
70
|
+
return await fetchQuote(requestBody).then((response) => {
|
|
71
71
|
const { result } = response;
|
|
72
72
|
|
|
73
73
|
throwErrorIfResponseIsNotValid({
|
package/src/hooks/useFetch.ts
CHANGED
|
@@ -9,13 +9,11 @@ type UseFetchOptions<TRequest, TResponse> = {
|
|
|
9
9
|
) => Promise<TResponse>;
|
|
10
10
|
};
|
|
11
11
|
export type UseFetchResult<TRequest, TResponse> = {
|
|
12
|
-
fetch: (requestBody: TRequest
|
|
12
|
+
fetch: (requestBody: TRequest) => Promise<TResponse>;
|
|
13
13
|
cancelFetch: () => void;
|
|
14
14
|
loading: boolean;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const RETRY_DELAY = 2_000;
|
|
18
|
-
|
|
19
17
|
export function useFetch<TRequest, TResponse>({
|
|
20
18
|
request,
|
|
21
19
|
}: UseFetchOptions<TRequest, TResponse>): UseFetchResult<TRequest, TResponse> {
|
|
@@ -24,14 +22,8 @@ export function useFetch<TRequest, TResponse>({
|
|
|
24
22
|
|
|
25
23
|
const cancelFetch = () => abortController.current?.abort();
|
|
26
24
|
|
|
27
|
-
const retryFetch = async (requestBody: TRequest) => {
|
|
28
|
-
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
|
|
29
|
-
return await fetch(requestBody, false);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
25
|
const fetch: UseFetchResult<TRequest, TResponse>['fetch'] = async (
|
|
33
|
-
requestBody
|
|
34
|
-
retryOnFail = false
|
|
26
|
+
requestBody
|
|
35
27
|
) => {
|
|
36
28
|
cancelFetch();
|
|
37
29
|
abortController.current = new AbortController();
|
|
@@ -46,9 +38,6 @@ export function useFetch<TRequest, TResponse>({
|
|
|
46
38
|
return res;
|
|
47
39
|
// eslint-disable-next-line no-useless-catch
|
|
48
40
|
} catch (error) {
|
|
49
|
-
if (retryOnFail) {
|
|
50
|
-
return await retryFetch(requestBody);
|
|
51
|
-
}
|
|
52
41
|
throw error;
|
|
53
42
|
} finally {
|
|
54
43
|
setLoading(false);
|
|
@@ -271,7 +271,7 @@ describe('usePrepareBlockchainList', () => {
|
|
|
271
271
|
]);
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
it('Last item of the main list should be moved to front if it selected again.', () => {
|
|
274
|
+
it.only('Last item of the main list should be moved to front if it selected again.', () => {
|
|
275
275
|
const listLimit = 10;
|
|
276
276
|
const preferredBlockchains = ['AVAX_CCHAIN', 'BTC'];
|
|
277
277
|
const expected = [
|
|
@@ -38,13 +38,6 @@ export function useSyncUrlAndStore() {
|
|
|
38
38
|
const liquiditySourcesParamsRef = useRef<string>();
|
|
39
39
|
|
|
40
40
|
const getUrlSearchParams = () => {
|
|
41
|
-
const utmQueryParams: Record<string, string> = {};
|
|
42
|
-
|
|
43
|
-
for (const [key, value] of searchParams.entries()) {
|
|
44
|
-
if (key.startsWith('utm_')) {
|
|
45
|
-
utmQueryParams[key] = value;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
41
|
const fromAmount = searchParams.get(SearchParams.FROM_AMOUNT);
|
|
49
42
|
const fromBlockchain = searchParams.get(SearchParams.FROM_BLOCKCHAIN);
|
|
50
43
|
const fromToken = searchParams.get(SearchParams.FROM_TOKEN);
|
|
@@ -63,7 +56,6 @@ export function useSyncUrlAndStore() {
|
|
|
63
56
|
autoConnect,
|
|
64
57
|
clientUrl,
|
|
65
58
|
liquiditySources,
|
|
66
|
-
utmQueryParams,
|
|
67
59
|
};
|
|
68
60
|
};
|
|
69
61
|
|
|
@@ -79,7 +71,7 @@ export function useSyncUrlAndStore() {
|
|
|
79
71
|
};
|
|
80
72
|
|
|
81
73
|
useEffect(() => {
|
|
82
|
-
const { autoConnect, clientUrl
|
|
74
|
+
const { autoConnect, clientUrl } = getUrlSearchParams();
|
|
83
75
|
if (isInRouterContext && fetchMetaStatus === 'success') {
|
|
84
76
|
updateUrlSearchParams({
|
|
85
77
|
[SearchParams.FROM_BLOCKCHAIN]: fromBlockchain?.name,
|
|
@@ -92,7 +84,6 @@ export function useSyncUrlAndStore() {
|
|
|
92
84
|
[SearchParams.LIQUIDITY_SOURCES]: campaignMode
|
|
93
85
|
? liquiditySourcesParamsRef.current
|
|
94
86
|
: undefined,
|
|
95
|
-
...utmQueryParams,
|
|
96
87
|
});
|
|
97
88
|
}
|
|
98
89
|
}, [
|
|
@@ -17,10 +17,8 @@ import {
|
|
|
17
17
|
WalletIcon,
|
|
18
18
|
} from '@rango-dev/ui';
|
|
19
19
|
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
20
|
-
import { flushSync } from 'react-dom';
|
|
21
20
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
22
21
|
|
|
23
|
-
import { getRequiredWallets } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
|
|
24
22
|
import { ConfirmWalletsModal } from '../components/ConfirmWalletsModal/ConfirmWalletsModal';
|
|
25
23
|
import { RefreshButton } from '../components/HeaderButtons/RefreshButton';
|
|
26
24
|
import { Layout, PageContainer } from '../components/Layout';
|
|
@@ -32,8 +30,6 @@ import { useConfirmSwap } from '../hooks/useConfirmSwap';
|
|
|
32
30
|
import { useAppStore } from '../store/AppStore';
|
|
33
31
|
import { useQuoteStore } from '../store/quote';
|
|
34
32
|
import { useUiStore } from '../store/ui';
|
|
35
|
-
import { useWalletsStore } from '../store/wallets';
|
|
36
|
-
import { QuoteWarningType } from '../types';
|
|
37
33
|
import { joinList } from '../utils/ui';
|
|
38
34
|
|
|
39
35
|
const Buttons = styled('div', {
|
|
@@ -72,7 +68,6 @@ export function ConfirmSwapPage() {
|
|
|
72
68
|
setInputAmount,
|
|
73
69
|
selectedWallets,
|
|
74
70
|
quoteWalletsConfirmed,
|
|
75
|
-
setQuoteWalletConfirmed,
|
|
76
71
|
customDestination,
|
|
77
72
|
quoteWarningsConfirmed,
|
|
78
73
|
} = useQuoteStore();
|
|
@@ -80,7 +75,6 @@ export function ConfirmSwapPage() {
|
|
|
80
75
|
const location = useLocation();
|
|
81
76
|
const [dbErrorMessage, setDbErrorMessage] = useState<string>('');
|
|
82
77
|
|
|
83
|
-
const { connectedWallets } = useWalletsStore();
|
|
84
78
|
const showWalletsOnInit = !quoteWalletsConfirmed;
|
|
85
79
|
const [showWallets, setShowWallets] = useState(false);
|
|
86
80
|
const [isConfirming, setIsConfirming] = useState(false);
|
|
@@ -190,65 +184,6 @@ export function ConfirmSwapPage() {
|
|
|
190
184
|
}
|
|
191
185
|
}, []);
|
|
192
186
|
|
|
193
|
-
useEffect(() => {
|
|
194
|
-
const quoteChanged =
|
|
195
|
-
confirmSwapResult.warnings?.quote?.type &&
|
|
196
|
-
Object.values(QuoteWarningType).includes(
|
|
197
|
-
confirmSwapResult.warnings?.quote?.type
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const selectedWalletDisconnected =
|
|
201
|
-
selectedWallets.length < 1 ||
|
|
202
|
-
!selectedWallets.every((selectedWallet) =>
|
|
203
|
-
connectedWallets.find(
|
|
204
|
-
(connectedWallet) =>
|
|
205
|
-
selectedWallet.address === connectedWallet.address &&
|
|
206
|
-
selectedWallet.walletType === connectedWallet.walletType &&
|
|
207
|
-
selectedWallet.chain === connectedWallet.chain
|
|
208
|
-
)
|
|
209
|
-
);
|
|
210
|
-
|
|
211
|
-
let quoteWalletsChanged = false;
|
|
212
|
-
|
|
213
|
-
if (quoteChanged) {
|
|
214
|
-
let requiredWallets = getRequiredWallets(selectedQuote?.swaps || null);
|
|
215
|
-
|
|
216
|
-
const lastStepToBlockchain =
|
|
217
|
-
selectedQuote?.swaps[selectedQuote.swaps.length - 1].to.blockchain;
|
|
218
|
-
|
|
219
|
-
const isLastWalletRequired = !!selectedQuote?.swaps.find(
|
|
220
|
-
(swap) => swap.from.blockchain === lastStepToBlockchain
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
if (!isLastWalletRequired) {
|
|
224
|
-
requiredWallets = requiredWallets.slice(
|
|
225
|
-
-requiredWallets.length,
|
|
226
|
-
requiredWallets.length - 1
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const allRequiredWalletsSelected = requiredWallets.every(
|
|
231
|
-
(requiredWallet) =>
|
|
232
|
-
selectedWallets.find(
|
|
233
|
-
(selectedWallet) => selectedWallet.chain === requiredWallet
|
|
234
|
-
)
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
if (!allRequiredWalletsSelected) {
|
|
238
|
-
quoteWalletsChanged = true;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if (selectedQuote && (selectedWalletDisconnected || quoteWalletsChanged)) {
|
|
243
|
-
queueMicrotask(() => flushSync(setShowWallets.bind(null, true)));
|
|
244
|
-
setQuoteWalletConfirmed(false);
|
|
245
|
-
}
|
|
246
|
-
}, [
|
|
247
|
-
confirmSwapResult.warnings?.quote,
|
|
248
|
-
selectedWallets.length,
|
|
249
|
-
connectedWallets.length,
|
|
250
|
-
]);
|
|
251
|
-
|
|
252
187
|
useLayoutEffect(() => {
|
|
253
188
|
if (!selectedQuote) {
|
|
254
189
|
navigate(`../${location.search}`);
|
package/src/pages/Home.tsx
CHANGED
|
@@ -23,7 +23,8 @@ import { isVariantExpandable } from '../utils/configs';
|
|
|
23
23
|
import { getSwapButtonState, isTokensIdentical } from '../utils/swap';
|
|
24
24
|
|
|
25
25
|
const MainContainer = styled('div', {
|
|
26
|
-
display: '
|
|
26
|
+
display: 'grid',
|
|
27
|
+
gridTemplateColumns: 'auto auto',
|
|
27
28
|
alignItems: 'flex-start',
|
|
28
29
|
maxHeight: 700,
|
|
29
30
|
'& .footer__alert': {
|
package/src/utils/swap.ts
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
import { getBlockchainShortNameFor } from './meta';
|
|
41
41
|
import { numberToString } from './numbers';
|
|
42
42
|
import { getPriceImpact, getRequiredBalanceOfWallet } from './quote';
|
|
43
|
-
import {
|
|
43
|
+
import { getQuoteWallets } from './wallets';
|
|
44
44
|
|
|
45
45
|
export function getOutputRatio(
|
|
46
46
|
inputUsdValue: BigNumber | null,
|
|
@@ -255,24 +255,6 @@ export function canComputePriceImpact(
|
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
export function requiredWallets(quote: SelectedQuote | null) {
|
|
259
|
-
const wallets: string[] = [];
|
|
260
|
-
|
|
261
|
-
quote?.swaps.forEach((swap) => {
|
|
262
|
-
const currentStepFromBlockchain = swap.from.blockchain;
|
|
263
|
-
const currentStepToBlockchain = swap.to.blockchain;
|
|
264
|
-
let lastAddedWallet = wallets[wallets.length - 1];
|
|
265
|
-
if (currentStepFromBlockchain != lastAddedWallet) {
|
|
266
|
-
wallets.push(currentStepFromBlockchain);
|
|
267
|
-
}
|
|
268
|
-
lastAddedWallet = wallets[wallets.length - 1];
|
|
269
|
-
if (currentStepToBlockchain != lastAddedWallet) {
|
|
270
|
-
wallets.push(currentStepToBlockchain);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
return wallets;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
258
|
export const getUsdPrice = (
|
|
277
259
|
blockchain: string,
|
|
278
260
|
symbol: string,
|
|
@@ -606,7 +588,7 @@ export function generateBalanceWarnings(
|
|
|
606
588
|
blockchains: BlockchainMeta[]
|
|
607
589
|
) {
|
|
608
590
|
const fee = quote.validationStatus;
|
|
609
|
-
const requiredWallets =
|
|
591
|
+
const requiredWallets = getQuoteWallets({ filter: 'required', quote });
|
|
610
592
|
const walletsSortedByRequiredWallets = selectedWallets.sort(
|
|
611
593
|
(selectedWallet1, selectedWallet2) =>
|
|
612
594
|
requiredWallets.indexOf(selectedWallet1.chain) -
|
|
@@ -753,25 +735,43 @@ export function shouldRetrySwap(pendingSwap: PendingSwap) {
|
|
|
753
735
|
return pendingSwap.status === 'failed';
|
|
754
736
|
}
|
|
755
737
|
|
|
756
|
-
export function
|
|
738
|
+
export function isConfirmSwapDisabled(
|
|
757
739
|
fetching: boolean,
|
|
758
740
|
showCustomDestination: boolean,
|
|
759
741
|
customDestination: string | null,
|
|
760
742
|
quote: SelectedQuote | null,
|
|
761
743
|
selectedWallets: { walletType: string; chain: string }[],
|
|
762
|
-
lastStepToBlockchain
|
|
763
|
-
) {
|
|
744
|
+
lastStepToBlockchain: BlockchainMeta | undefined
|
|
745
|
+
): boolean {
|
|
746
|
+
if (!quote || fetching) {
|
|
747
|
+
return true;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
const allWallets = getQuoteWallets({ filter: 'all', quote });
|
|
751
|
+
|
|
752
|
+
const requiredWallets = getQuoteWallets({ filter: 'required', quote });
|
|
753
|
+
|
|
754
|
+
const everyWalletSelected = allWallets.every((blockchain) =>
|
|
755
|
+
selectedWallets.some(
|
|
756
|
+
(selectedWallet) => selectedWallet.chain === blockchain
|
|
757
|
+
)
|
|
758
|
+
);
|
|
759
|
+
|
|
760
|
+
const everyRequiredWalletSelected = requiredWallets.every((wallet) =>
|
|
761
|
+
selectedWallets.some((selectedWallet) => selectedWallet.chain === wallet)
|
|
762
|
+
);
|
|
763
|
+
|
|
764
|
+
const customDestinationIsValid =
|
|
765
|
+
customDestination && lastStepToBlockchain
|
|
766
|
+
? isValidAddress(lastStepToBlockchain, customDestination)
|
|
767
|
+
: false;
|
|
768
|
+
|
|
764
769
|
return (
|
|
765
|
-
|
|
766
|
-
(
|
|
767
|
-
|
|
768
|
-
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
769
|
-
)) ||
|
|
770
|
-
(!!showCustomDestination && !customDestination) ||
|
|
771
|
-
(!!showCustomDestination &&
|
|
770
|
+
(!showCustomDestination && !everyWalletSelected) ||
|
|
771
|
+
(showCustomDestination && !customDestination) ||
|
|
772
|
+
(showCustomDestination &&
|
|
772
773
|
!!customDestination &&
|
|
773
|
-
|
|
774
|
-
!isValidAddress(lastStepToBlockchain, customDestination))
|
|
774
|
+
(!customDestinationIsValid || !everyRequiredWalletSelected))
|
|
775
775
|
);
|
|
776
776
|
}
|
|
777
777
|
|