@rango-dev/widget-embedded 0.27.3-next.5 → 0.27.4-next.0
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/CHANGELOG.md +9 -0
- 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/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/hooks/useWalletList.d.ts +0 -2
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.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/WalletsPage.d.ts.map +1 -1
- package/dist/utils/providers.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 +2 -2
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +1 -19
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +22 -23
- package/src/components/ConfirmWalletsModal/WalletList.tsx +0 -2
- package/src/components/HeaderButtons/WalletButton.tsx +1 -4
- package/src/containers/Wallets/Wallets.tsx +1 -1
- package/src/hooks/useWalletList.ts +2 -3
- package/src/hooks/useWalletProviders.ts +4 -2
- package/src/pages/ConfirmSwapPage.tsx +0 -65
- package/src/pages/WalletsPage.tsx +1 -2
- package/src/utils/providers.ts +1 -0
- 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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAsBxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAsBxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,sBAyE1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/utils/providers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAIlE,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,YAAY,CAAC,wBAAwB,CAAC,CAAC;CACjE;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAClC,OAAO,CAAC,EAAE,gBAAgB,GACzB,iBAAiB,EAAE,CAqCrB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,EAC/B,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,EAAE,CAMV"}
|
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,MAAM,cAAc,CAAC;AAmBrC,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,GAAG,IAAI,EAC/B,cAAc,EAAE,SAAS,GAAG,IAAI,UAejC;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,SAAS,GAAG,IAAI,EAC/B,WAAW,EAAE,MAAM,GAClB,OAAO,CAQT;AAED,wB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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,IAAI,CAUlB;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,EAAE,MAAM,EAAE,EACxB,mBAAmB,EAAE,OAAO,EAAE,GAAG,IAAI,EACrC,gBAAgB,EAAE,OAAO,GACxB,MAAM,EAAE,CAkFV;AAED,wBAAgB,
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gB,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
|
+
"version": "0.27.4-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.2.1-next.1",
|
|
28
|
-
"@rango-dev/provider-all": "^0.32.2-next.
|
|
28
|
+
"@rango-dev/provider-all": "^0.32.2-next.2",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
30
30
|
"@rango-dev/queue-manager-rango-preset": "^0.32.1-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
@@ -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}>
|
|
@@ -44,7 +44,6 @@ import {
|
|
|
44
44
|
const ACCOUNT_ADDRESS_MAX_CHARACTERS = 7;
|
|
45
45
|
export function WalletList(props: PropTypes) {
|
|
46
46
|
const { chain, isSelected, selectWallet, limit, onShowMore } = props;
|
|
47
|
-
const { config } = useAppStore();
|
|
48
47
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
49
48
|
|
|
50
49
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
@@ -61,7 +60,6 @@ export function WalletList(props: PropTypes) {
|
|
|
61
60
|
let modalTimerId: ReturnType<typeof setTimeout> | null = null;
|
|
62
61
|
const { list, error, handleClick, disconnectConnectingWallets } =
|
|
63
62
|
useWalletList({
|
|
64
|
-
config,
|
|
65
63
|
chain,
|
|
66
64
|
onBeforeConnect: (type) => {
|
|
67
65
|
modalTimerId = setTimeout(() => {
|
|
@@ -5,7 +5,6 @@ import { Image, Tooltip, WalletIcon } from '@rango-dev/ui';
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
8
|
-
import { useAppStore } from '../../store/AppStore';
|
|
9
8
|
|
|
10
9
|
import {
|
|
11
10
|
ConnectedIcon,
|
|
@@ -15,9 +14,7 @@ import {
|
|
|
15
14
|
} from './HeaderButtons.styles';
|
|
16
15
|
|
|
17
16
|
function WalletButton(props: PropTypes) {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
const { list } = useWalletList({ config });
|
|
17
|
+
const { list } = useWalletList({});
|
|
21
18
|
const connectedWallets = list.filter(
|
|
22
19
|
(wallet) => wallet.state === 'connected'
|
|
23
20
|
);
|
|
@@ -39,7 +39,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
39
39
|
const walletOptions: ProvidersOptions = {
|
|
40
40
|
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
41
41
|
};
|
|
42
|
-
const { providers } = useWalletProviders(
|
|
42
|
+
const { providers } = useWalletProviders(config.wallets, walletOptions);
|
|
43
43
|
const { connectWallet, disconnectWallet } = useWalletsStore();
|
|
44
44
|
const onConnectWalletHandler = useRef<OnWalletConnectionChange>();
|
|
45
45
|
const onDisconnectWalletHandler = useRef<OnWalletConnectionChange>();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { WidgetConfig } from '../types';
|
|
2
1
|
import type { WalletInfo } from '@rango-dev/ui';
|
|
3
2
|
import type { BlockchainMeta } from 'rango-sdk';
|
|
4
3
|
|
|
@@ -25,7 +24,6 @@ import {
|
|
|
25
24
|
const ALL_SUPPORTED_WALLETS = Object.values(WalletTypes);
|
|
26
25
|
|
|
27
26
|
interface Params {
|
|
28
|
-
config?: WidgetConfig;
|
|
29
27
|
chain?: string;
|
|
30
28
|
onBeforeConnect?: (walletType: string) => void;
|
|
31
29
|
onConnect?: (walletType: string) => void;
|
|
@@ -37,7 +35,8 @@ interface Params {
|
|
|
37
35
|
* you can use this list whenever you need to show the list of wallets and needed callbacks
|
|
38
36
|
*/
|
|
39
37
|
export function useWalletList(params: Params) {
|
|
40
|
-
const {
|
|
38
|
+
const { chain, onBeforeConnect, onConnect } = params;
|
|
39
|
+
const { config } = useAppStore();
|
|
41
40
|
const { state, disconnect, getWalletInfo, connect } = useWallets();
|
|
42
41
|
const { connectedWallets } = useWalletsStore();
|
|
43
42
|
const blockchains = useAppStore().blockchains();
|
|
@@ -13,8 +13,10 @@ export function useWalletProviders(
|
|
|
13
13
|
) {
|
|
14
14
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
15
15
|
let generateProviders: ProviderInterface[] = matchAndGenerateProviders(
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
providers,
|
|
17
|
+
{
|
|
18
|
+
walletConnectProjectId: options?.walletConnectProjectId,
|
|
19
|
+
}
|
|
18
20
|
);
|
|
19
21
|
|
|
20
22
|
useEffect(() => {
|
|
@@ -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}`);
|
|
@@ -28,7 +28,7 @@ export const TIME_TO_CLOSE_MODAL = 3_000;
|
|
|
28
28
|
export const TIME_TO_IGNORE_MODAL = 300;
|
|
29
29
|
|
|
30
30
|
export function WalletsPage() {
|
|
31
|
-
const {
|
|
31
|
+
const { fetchStatus: fetchMetaStatus } = useAppStore();
|
|
32
32
|
const [openModal, setOpenModal] = useState(false);
|
|
33
33
|
const [selectedWalletType, setSelectedWalletType] = useState<WalletType>('');
|
|
34
34
|
let modalTimerId: ReturnType<typeof setTimeout> | null = null;
|
|
@@ -36,7 +36,6 @@ export function WalletsPage() {
|
|
|
36
36
|
|
|
37
37
|
const { list, handleClick, error, disconnectConnectingWallets } =
|
|
38
38
|
useWalletList({
|
|
39
|
-
config,
|
|
40
39
|
onBeforeConnect: (type) => {
|
|
41
40
|
modalTimerId = setTimeout(() => {
|
|
42
41
|
setOpenModal(true);
|
package/src/utils/providers.ts
CHANGED
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
|
|
package/src/utils/wallets.ts
CHANGED
|
@@ -199,34 +199,47 @@ export function prepareAccountsForWalletStore(
|
|
|
199
199
|
return result;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
export function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
export function getQuoteWallets(params: {
|
|
203
|
+
filter: 'all' | 'required';
|
|
204
|
+
quote: SelectedQuote | null;
|
|
205
|
+
}): string[] {
|
|
206
|
+
const { filter, quote } = params;
|
|
207
|
+
const wallets = new Set<string>();
|
|
208
|
+
|
|
209
|
+
quote?.swaps.forEach((swap, swapIndex) => {
|
|
206
210
|
const currentStepFromBlockchain = swap.from.blockchain;
|
|
207
211
|
const currentStepToBlockchain = swap.to.blockchain;
|
|
208
|
-
|
|
209
|
-
wallets.push(currentStepFromBlockchain);
|
|
210
|
-
}
|
|
211
|
-
if (!wallets.includes(currentStepToBlockchain)) {
|
|
212
|
-
wallets.push(currentStepToBlockchain);
|
|
213
|
-
}
|
|
212
|
+
wallets.add(currentStepFromBlockchain);
|
|
214
213
|
|
|
215
214
|
// Check if internalSwaps array exists
|
|
216
|
-
if (swap.internalSwaps
|
|
217
|
-
|
|
215
|
+
if (swap.internalSwaps) {
|
|
216
|
+
const { internalSwaps } = swap;
|
|
217
|
+
internalSwaps.forEach((internalSwap, internalSwapIndex) => {
|
|
218
218
|
const internalStepFromBlockchain = internalSwap.from.blockchain;
|
|
219
219
|
const internalStepToBlockchain = internalSwap.to.blockchain;
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
const isLastStep = swapIndex === quote.swaps.length - 1;
|
|
221
|
+
const isLastInternalStep =
|
|
222
|
+
internalSwapIndex === internalSwaps.length - 1;
|
|
223
|
+
|
|
224
|
+
if (
|
|
225
|
+
(!isLastStep && !isLastInternalStep) ||
|
|
226
|
+
(isLastStep &&
|
|
227
|
+
currentStepToBlockchain !== internalStepFromBlockchain) ||
|
|
228
|
+
filter === 'all'
|
|
229
|
+
) {
|
|
230
|
+
wallets.add(internalStepFromBlockchain);
|
|
222
231
|
}
|
|
223
|
-
if (
|
|
224
|
-
wallets.
|
|
232
|
+
if (filter === 'all') {
|
|
233
|
+
wallets.add(internalStepToBlockchain);
|
|
225
234
|
}
|
|
226
235
|
});
|
|
227
236
|
}
|
|
237
|
+
|
|
238
|
+
if (filter === 'all') {
|
|
239
|
+
wallets.add(currentStepToBlockchain);
|
|
240
|
+
}
|
|
228
241
|
});
|
|
229
|
-
return wallets;
|
|
242
|
+
return Array.from(wallets);
|
|
230
243
|
}
|
|
231
244
|
|
|
232
245
|
type Blockchain = { name: string; accounts: ConnectedWallet[] };
|