@rango-dev/widget-embedded 0.41.2-next.1 → 0.41.2-next.2
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/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -0
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +3 -0
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +3 -9
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts +4 -0
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +647 -0
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +21 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts +4 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts +323 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts +5 -0
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +1 -0
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -0
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +13 -11
- package/src/components/ConfirmWalletsModal/WalletList.tsx +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -0
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
- package/src/components/SwapDetails/SwapDetails.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +17 -8
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +3 -8
- package/src/components/WalletStatefulConnect/DerivationPath.tsx +1 -13
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +64 -0
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +55 -3
- package/src/components/WalletStatefulConnect/Namespaces.tsx +97 -50
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +29 -1
- package/src/components/WalletStatefulConnect/SupportedChainsList.styles.ts +25 -0
- package/src/components/WalletStatefulConnect/SupportedChainsList.tsx +58 -0
- package/src/components/WalletStatefulConnect/SupportedChainsList.types.ts +5 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +2 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +2 -0
- package/src/utils/swap.ts +8 -10
- package/src/utils/wallets.ts +8 -12
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { styled } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export const SupportedChainsContainer = styled('div', {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
padding: 0,
|
|
7
|
+
margin: 0,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const SupportedChainItem = styled('div', {
|
|
11
|
+
marginLeft: '-5px',
|
|
12
|
+
listStyleType: 'none',
|
|
13
|
+
backgroundColor: '$background',
|
|
14
|
+
borderRadius: '$lg',
|
|
15
|
+
minWidth: '15px',
|
|
16
|
+
height: '15px',
|
|
17
|
+
variants: {
|
|
18
|
+
firstItem: {
|
|
19
|
+
true: { marginLeft: 0 },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { PropTypes } from './SupportedChainsList.types';
|
|
2
|
+
|
|
3
|
+
import { Image, Tooltip, Typography } from '@rango-dev/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { getContainer } from '../../utils/common';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
SupportedChainItem,
|
|
10
|
+
SupportedChainsContainer,
|
|
11
|
+
} from './SupportedChainsList.styles';
|
|
12
|
+
|
|
13
|
+
const SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER = 3;
|
|
14
|
+
|
|
15
|
+
export function SupportedChainsList(props: PropTypes) {
|
|
16
|
+
const { chains } = props;
|
|
17
|
+
return (
|
|
18
|
+
<SupportedChainsContainer>
|
|
19
|
+
{chains
|
|
20
|
+
.slice(0, SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER)
|
|
21
|
+
.map((chain, index) => (
|
|
22
|
+
<Tooltip
|
|
23
|
+
key={chain.name}
|
|
24
|
+
container={getContainer()}
|
|
25
|
+
side="bottom"
|
|
26
|
+
align="start"
|
|
27
|
+
content={chain.name}
|
|
28
|
+
sideOffset={4}>
|
|
29
|
+
<SupportedChainItem firstItem={index === 0}>
|
|
30
|
+
<Image src={chain.logo} size={15} />
|
|
31
|
+
</SupportedChainItem>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
))}
|
|
34
|
+
{chains.length > SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER && (
|
|
35
|
+
<Tooltip
|
|
36
|
+
container={getContainer()}
|
|
37
|
+
side="bottom"
|
|
38
|
+
align="start"
|
|
39
|
+
sideOffset={4}
|
|
40
|
+
content={
|
|
41
|
+
<SupportedChainsContainer>
|
|
42
|
+
{chains.map((chain, index) => (
|
|
43
|
+
<SupportedChainItem key={chain.name} firstItem={index === 0}>
|
|
44
|
+
<Image src={chain.logo} size={15} />
|
|
45
|
+
</SupportedChainItem>
|
|
46
|
+
))}
|
|
47
|
+
</SupportedChainsContainer>
|
|
48
|
+
}>
|
|
49
|
+
<SupportedChainItem>
|
|
50
|
+
<Typography variant="body" size="xsmall">
|
|
51
|
+
+{chains.length - SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER}
|
|
52
|
+
</Typography>
|
|
53
|
+
</SupportedChainItem>
|
|
54
|
+
</Tooltip>
|
|
55
|
+
)}
|
|
56
|
+
</SupportedChainsContainer>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -101,6 +101,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
101
101
|
type: 'needsNamespace',
|
|
102
102
|
payload: {
|
|
103
103
|
targetWallet: wallet,
|
|
104
|
+
defaultSelectedChains: options?.defaultSelectedChains,
|
|
104
105
|
},
|
|
105
106
|
});
|
|
106
107
|
return { status: ResultStatus.Namespace };
|
|
@@ -127,6 +128,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
127
128
|
type: 'needsNamespace',
|
|
128
129
|
payload: {
|
|
129
130
|
targetWallet: wallet,
|
|
131
|
+
defaultSelectedChains: options?.defaultSelectedChains,
|
|
130
132
|
},
|
|
131
133
|
});
|
|
132
134
|
return { status: ResultStatus.Namespace };
|
|
@@ -4,10 +4,12 @@ import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
|
4
4
|
export interface HandleConnectOptions {
|
|
5
5
|
// To have a switch between connect and disconnect when user is clicking on a button, this option can be helpful.
|
|
6
6
|
disconnectIfConnected?: boolean;
|
|
7
|
+
defaultSelectedChains?: string[];
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export interface NeedsNamespacesState {
|
|
10
11
|
targetWallet: ExtendedModalWalletInfo;
|
|
12
|
+
defaultSelectedChains?: string[];
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export interface NeedsDerivationPathState {
|
package/src/utils/swap.ts
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
import { getBlockchainShortNameFor, isValidTokenAddress } from './meta';
|
|
51
51
|
import { numberToString } from './numbers';
|
|
52
52
|
import { getRequiredBalanceOfWallet } from './quote';
|
|
53
|
-
import {
|
|
53
|
+
import { getQuoteChains } from './wallets';
|
|
54
54
|
|
|
55
55
|
export function getOutputRatio(
|
|
56
56
|
inputUsdValue: BigNumber | null,
|
|
@@ -601,7 +601,7 @@ export function generateBalanceWarnings(
|
|
|
601
601
|
blockchains: BlockchainMeta[]
|
|
602
602
|
) {
|
|
603
603
|
const fee = quote.validationStatus;
|
|
604
|
-
const requiredWallets =
|
|
604
|
+
const requiredWallets = getQuoteChains({ filter: 'required', quote });
|
|
605
605
|
const walletsSortedByRequiredWallets = selectedWallets.sort(
|
|
606
606
|
(selectedWallet1, selectedWallet2) =>
|
|
607
607
|
requiredWallets.indexOf(selectedWallet1.chain) -
|
|
@@ -751,18 +751,16 @@ export function isConfirmSwapDisabled(
|
|
|
751
751
|
return true;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
-
const
|
|
754
|
+
const allChains = getQuoteChains({ filter: 'all', quote });
|
|
755
755
|
|
|
756
|
-
const
|
|
756
|
+
const requiredChains = getQuoteChains({ filter: 'required', quote });
|
|
757
757
|
|
|
758
|
-
const everyWalletSelected =
|
|
759
|
-
selectedWallets.some(
|
|
760
|
-
(selectedWallet) => selectedWallet.chain === blockchain
|
|
761
|
-
)
|
|
758
|
+
const everyWalletSelected = allChains.every((chain) =>
|
|
759
|
+
selectedWallets.some((selectedWallet) => selectedWallet.chain === chain)
|
|
762
760
|
);
|
|
763
761
|
|
|
764
|
-
const everyRequiredWalletSelected =
|
|
765
|
-
selectedWallets.some((selectedWallet) => selectedWallet.chain ===
|
|
762
|
+
const everyRequiredWalletSelected = requiredChains.every((chain) =>
|
|
763
|
+
selectedWallets.some((selectedWallet) => selectedWallet.chain === chain)
|
|
766
764
|
);
|
|
767
765
|
|
|
768
766
|
const customDestinationIsValid =
|
package/src/utils/wallets.ts
CHANGED
|
@@ -45,18 +45,14 @@ export type ExtendedModalWalletInfo = WalletInfoWithExtra &
|
|
|
45
45
|
Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
|
|
46
46
|
|
|
47
47
|
export function mapStatusToWalletState(state: WalletState): WalletStatus {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return WalletStatus.CONNECTING;
|
|
55
|
-
case !state.installed:
|
|
56
|
-
return WalletStatus.NOT_INSTALLED;
|
|
57
|
-
default:
|
|
58
|
-
return WalletStatus.DISCONNECTED;
|
|
48
|
+
if (state.connected) {
|
|
49
|
+
return WalletStatus.CONNECTED;
|
|
50
|
+
} else if (state.connecting) {
|
|
51
|
+
return WalletStatus.CONNECTING;
|
|
52
|
+
} else if (!state.installed) {
|
|
53
|
+
return WalletStatus.NOT_INSTALLED;
|
|
59
54
|
}
|
|
55
|
+
return WalletStatus.DISCONNECTED;
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
export function mapWalletTypesToWalletInfo(
|
|
@@ -225,7 +221,7 @@ export function prepareAccountsForWalletStore(
|
|
|
225
221
|
return result;
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
export function
|
|
224
|
+
export function getQuoteChains(params: {
|
|
229
225
|
filter: 'all' | 'required';
|
|
230
226
|
quote: SelectedQuote | null;
|
|
231
227
|
}): string[] {
|