@rango-dev/widget-embedded 0.29.1-next.2 → 0.29.1-next.21

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.
Files changed (142) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +6 -0
  3. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  5. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  6. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  7. package/dist/components/Quote/Quote.d.ts.map +1 -1
  8. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  9. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  10. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  11. package/dist/components/SearchInput/SearchInput.types.d.ts +2 -0
  12. package/dist/components/SearchInput/SearchInput.types.d.ts.map +1 -1
  13. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  14. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  15. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts +4 -0
  16. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts.map +1 -0
  17. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts +325 -0
  18. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts.map +1 -0
  19. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts +10 -0
  20. package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts.map +1 -0
  21. package/dist/components/WalletDerivationPathModal/index.d.ts +2 -0
  22. package/dist/components/WalletDerivationPathModal/index.d.ts.map +1 -0
  23. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +0 -2
  24. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -1
  25. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts +1 -1
  26. package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts.map +1 -1
  27. package/dist/constants/namespaces.d.ts +8 -0
  28. package/dist/constants/namespaces.d.ts.map +1 -0
  29. package/dist/constants/quote.d.ts +2 -1
  30. package/dist/constants/quote.d.ts.map +1 -1
  31. package/dist/constants/routing.d.ts +0 -1
  32. package/dist/constants/routing.d.ts.map +1 -1
  33. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  34. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  35. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -1
  36. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  37. package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
  38. package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
  39. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  40. package/dist/hooks/useWalletList.d.ts +4 -3
  41. package/dist/hooks/useWalletList.d.ts.map +1 -1
  42. package/dist/hooks/useWalletProviders/index.d.ts +2 -0
  43. package/dist/hooks/useWalletProviders/index.d.ts.map +1 -0
  44. package/dist/hooks/{useWalletProviders.d.ts → useWalletProviders/useWalletProviders.d.ts} +2 -2
  45. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -0
  46. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +3 -0
  47. package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -0
  48. package/dist/hooks/useWidgetEvents/index.d.ts +2 -0
  49. package/dist/hooks/useWidgetEvents/index.d.ts.map +1 -0
  50. package/dist/hooks/useWidgetEvents/useWidgetEvents.d.ts +3 -0
  51. package/dist/hooks/useWidgetEvents/useWidgetEvents.d.ts.map +1 -0
  52. package/dist/index.d.ts +16 -4
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +2 -2
  55. package/dist/index.js.map +4 -4
  56. package/dist/pages/WalletsPage.d.ts.map +1 -1
  57. package/dist/services/eventEmitter.d.ts +4 -0
  58. package/dist/services/eventEmitter.d.ts.map +1 -0
  59. package/dist/store/notification.d.ts.map +1 -1
  60. package/dist/store/quote.d.ts +2 -1
  61. package/dist/store/quote.d.ts.map +1 -1
  62. package/dist/store/slices/config.d.ts.map +1 -1
  63. package/dist/store/slices/settings.d.ts.map +1 -1
  64. package/dist/store/wallets.d.ts.map +1 -1
  65. package/dist/types/config.d.ts +8 -0
  66. package/dist/types/config.d.ts.map +1 -1
  67. package/dist/types/event.d.ts +68 -0
  68. package/dist/types/event.d.ts.map +1 -0
  69. package/dist/types/index.d.ts +1 -0
  70. package/dist/types/index.d.ts.map +1 -1
  71. package/dist/types/wallets.d.ts +2 -1
  72. package/dist/types/wallets.d.ts.map +1 -1
  73. package/dist/utils/common.d.ts +2 -0
  74. package/dist/utils/common.d.ts.map +1 -1
  75. package/dist/utils/meta.d.ts +1 -0
  76. package/dist/utils/meta.d.ts.map +1 -1
  77. package/dist/utils/numbers.d.ts +0 -1
  78. package/dist/utils/numbers.d.ts.map +1 -1
  79. package/dist/utils/providers.d.ts +1 -0
  80. package/dist/utils/providers.d.ts.map +1 -1
  81. package/dist/utils/wallets.d.ts +4 -4
  82. package/dist/utils/wallets.d.ts.map +1 -1
  83. package/dist/widget-embedded.build.json +1 -1
  84. package/package.json +7 -7
  85. package/src/QueueManager.tsx +4 -0
  86. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +19 -9
  87. package/src/components/ConfirmWalletsModal/WalletList.tsx +81 -14
  88. package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +5 -5
  89. package/src/components/NotificationContent/NotificationContent.tsx +12 -113
  90. package/src/components/Quote/Quote.tsx +18 -25
  91. package/src/components/Quote/QuoteCostDetails.tsx +10 -9
  92. package/src/components/SearchInput/SearchInput.types.ts +2 -0
  93. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  94. package/src/components/SwapDetails/SwapDetails.tsx +9 -10
  95. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +77 -11
  96. package/src/components/TokenList/TokenList.tsx +5 -5
  97. package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.ts +17 -0
  98. package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.tsx +154 -0
  99. package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.types.tsx +10 -0
  100. package/src/components/WalletDerivationPathModal/index.ts +1 -0
  101. package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +10 -15
  102. package/src/components/WalletNamespacesModal/WalletNamespacesModal.types.tsx +1 -1
  103. package/src/constants/namespaces.ts +62 -0
  104. package/src/constants/quote.ts +11 -9
  105. package/src/constants/routing.ts +0 -2
  106. package/src/containers/Inputs/Inputs.tsx +4 -4
  107. package/src/containers/Wallets/Wallets.tsx +2 -1
  108. package/src/containers/WidgetInfo/WidgetInfo.tsx +3 -0
  109. package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -1
  110. package/src/hooks/useBootstrap/useBootstrap.ts +4 -0
  111. package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +8 -10
  112. package/src/hooks/useSyncStoresWithConfig.ts +3 -1
  113. package/src/hooks/useWalletList.ts +14 -9
  114. package/src/hooks/useWalletProviders/index.ts +1 -0
  115. package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +14 -0
  116. package/src/hooks/{useWalletProviders.ts → useWalletProviders/useWalletProviders.ts} +11 -5
  117. package/src/hooks/useWidgetEvents/index.ts +1 -0
  118. package/src/hooks/useWidgetEvents/useWidgetEvents.ts +9 -0
  119. package/src/index.ts +26 -2
  120. package/src/pages/WalletsPage.tsx +99 -26
  121. package/src/services/eventEmitter.ts +11 -0
  122. package/src/store/notification.ts +3 -1
  123. package/src/store/quote.ts +63 -1
  124. package/src/store/slices/config.ts +4 -0
  125. package/src/store/slices/settings.ts +6 -0
  126. package/src/store/wallets.ts +194 -173
  127. package/src/types/config.ts +9 -0
  128. package/src/types/event.ts +89 -0
  129. package/src/types/index.ts +1 -0
  130. package/src/types/wallets.ts +2 -1
  131. package/src/utils/common.ts +12 -1
  132. package/src/utils/meta.ts +8 -0
  133. package/src/utils/numbers.ts +0 -12
  134. package/src/utils/providers.ts +4 -0
  135. package/src/utils/wallets.ts +7 -5
  136. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +0 -1559
  137. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +0 -1
  138. package/dist/components/NotificationContent/NotificationNotFound.d.ts +0 -3
  139. package/dist/components/NotificationContent/NotificationNotFound.d.ts.map +0 -1
  140. package/dist/hooks/useWalletProviders.d.ts.map +0 -1
  141. package/src/components/NotificationContent/NotificationContent.styles.ts +0 -63
  142. package/src/components/NotificationContent/NotificationNotFound.tsx +0 -17
@@ -42,7 +42,6 @@ import { useQuoteStore } from '../../store/quote';
42
42
  import { useUiStore } from '../../store/ui';
43
43
  import { getContainer } from '../../utils/common';
44
44
  import {
45
- formatTooltipNumbers,
46
45
  numberToString,
47
46
  roundedSecondsToString,
48
47
  totalArrivalTime,
@@ -206,14 +205,14 @@ export function SwapDetails(props: SwapDetailsProps) {
206
205
  );
207
206
 
208
207
  const realOutputUsdValue = outputAmount
209
- ? formatTooltipNumbers(
210
- new BigNumber(outputAmount).multipliedBy(lastStep.toUsdPrice || 0)
211
- )
208
+ ? new BigNumber(outputAmount)
209
+ .multipliedBy(lastStep.toUsdPrice || 0)
210
+ .toString()
212
211
  : '';
213
212
 
214
- const realInputUsdValue = formatTooltipNumbers(
215
- new BigNumber(swap.inputAmount).multipliedBy(firstStep.fromUsdPrice || 0)
216
- );
213
+ const realInputUsdValue = new BigNumber(swap.inputAmount)
214
+ .multipliedBy(firstStep.fromUsdPrice || 0)
215
+ .toString();
217
216
 
218
217
  const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
219
218
 
@@ -272,7 +271,7 @@ export function SwapDetails(props: SwapDetailsProps) {
272
271
  return (
273
272
  <Layout
274
273
  header={{
275
- title: i18n.t('Swap and Bridge'),
274
+ title: i18n.t('Swap Details'),
276
275
  onCancel:
277
276
  swap.status === 'running' ? () => setModalState('cancel') : undefined,
278
277
  suffix: swap.status !== 'running' && (
@@ -338,7 +337,7 @@ export function SwapDetails(props: SwapDetailsProps) {
338
337
  </div>
339
338
  <div className={rowStyles()}>
340
339
  <Typography variant="label" size="large" color="neutral700">
341
- {`${i18n.t(swap.finishTime ? 'Finished at' : 'Created at')}:`}
340
+ {swap.finishTime ? i18n.t('Finished at') : i18n.t('Created at')}
342
341
  </Typography>
343
342
  <Typography variant="label" size="small" color="neutral700">
344
343
  {swapDate}
@@ -458,7 +457,7 @@ export function SwapDetails(props: SwapDetailsProps) {
458
457
  )}
459
458
  usdValue={outputUsdValue}
460
459
  realUsdValue={realOutputUsdValue}
461
- realValue={formatTooltipNumbers(outputAmount)}
460
+ realValue={outputAmount || ''}
462
461
  percentageChange={numberToString(
463
462
  percentageChange,
464
463
  PERCENTAGE_CHANGE_MIN_DECIMALS,
@@ -8,17 +8,26 @@ import React, { useState } from 'react';
8
8
 
9
9
  import { getContainer } from '../../utils/common';
10
10
  import { mapStatusToWalletState } from '../../utils/wallets';
11
+ import { WalletDerivationPathModal } from '../WalletDerivationPathModal';
11
12
  import { WalletNamespacesModal } from '../WalletNamespacesModal';
12
13
 
13
14
  import { WalletContainer } from './SwapDetailsModal.styles';
14
15
 
15
16
  interface NamespacesModalState {
17
+ open: boolean;
16
18
  providerType: string;
17
19
  providerImage: string;
18
20
  availableNamespaces?: Namespace[];
19
21
  singleNamespace?: boolean;
20
22
  }
21
23
 
24
+ interface DerivationPathModalState {
25
+ open: boolean;
26
+ providerType: string;
27
+ providerImage: string;
28
+ namespace: Namespace;
29
+ }
30
+
22
31
  export const WalletStateContent = (props: WalletStateContentProps) => {
23
32
  const {
24
33
  type,
@@ -31,6 +40,8 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
31
40
  const { connect, getWalletInfo, state } = useWallets();
32
41
  const [namespacesModalState, setNamespacesModalState] =
33
42
  useState<NamespacesModalState | null>(null);
43
+ const [derivationPathModalState, setDerivationPathModalState] =
44
+ useState<DerivationPathModalState | null>(null);
34
45
  const walletType = currentStepWallet?.walletType;
35
46
  const walletState = walletType
36
47
  ? mapStatusToWalletState(state(walletType))
@@ -39,6 +50,59 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
39
50
  const shouldShowWallet =
40
51
  showWalletButton && !!walletType && !!walletState && !!walletInfo;
41
52
 
53
+ const handleCloseNamespaceModal = () => {
54
+ if (namespacesModalState) {
55
+ setNamespacesModalState({
56
+ ...namespacesModalState,
57
+ open: false,
58
+ });
59
+ }
60
+ };
61
+
62
+ const handleCloseDerivationPathModal = () => {
63
+ if (derivationPathModalState) {
64
+ setDerivationPathModalState({
65
+ ...derivationPathModalState,
66
+ open: false,
67
+ });
68
+ }
69
+ };
70
+
71
+ const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
72
+ if (
73
+ !!walletInfo?.needsDerivationPath &&
74
+ walletInfo?.singleNamespace &&
75
+ selectedNamespaces[0] &&
76
+ walletType
77
+ ) {
78
+ setDerivationPathModalState({
79
+ open: true,
80
+ providerType: walletType,
81
+ providerImage: walletInfo.img,
82
+ namespace: selectedNamespaces[0],
83
+ });
84
+ } else {
85
+ connect(
86
+ namespacesModalState?.providerType as string,
87
+ undefined,
88
+ selectedNamespaces.map((namespace) => ({
89
+ namespace,
90
+ }))
91
+ ).catch((error) => debug(error));
92
+ }
93
+ handleCloseNamespaceModal();
94
+ };
95
+
96
+ const handleDerivationPathConfirm = (derivationPath: string) => {
97
+ if (derivationPath && derivationPathModalState?.namespace) {
98
+ connect(derivationPathModalState?.providerType, undefined, [
99
+ { namespace: derivationPathModalState.namespace, derivationPath },
100
+ ]).catch((error) => debug(error));
101
+ }
102
+
103
+ handleCloseDerivationPathModal();
104
+ };
105
+
42
106
  return (
43
107
  <>
44
108
  <MessageBox type={type} title={title} description={message} />
@@ -56,6 +120,7 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
56
120
  onClick={async () => {
57
121
  if (walletInfo.namespaces) {
58
122
  setNamespacesModalState({
123
+ open: true,
59
124
  providerType: walletType,
60
125
  providerImage: walletInfo.img,
61
126
  availableNamespaces: walletInfo.namespaces,
@@ -69,20 +134,21 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
69
134
  </WalletContainer>
70
135
  )}
71
136
  <WalletNamespacesModal
72
- open={!!namespacesModalState}
73
- onClose={() => setNamespacesModalState(null)}
74
- onConfirm={(namespaces) => {
75
- connect(
76
- namespacesModalState?.providerType as string,
77
- undefined,
78
- namespaces
79
- ).catch((error) => debug(error));
80
- setNamespacesModalState(null);
81
- }}
137
+ open={!!namespacesModalState?.open}
138
+ onClose={handleCloseNamespaceModal}
139
+ onConfirm={handleConfirmNamespaces}
82
140
  image={namespacesModalState?.providerImage}
83
- namespaces={namespacesModalState?.availableNamespaces}
141
+ availableNamespaces={namespacesModalState?.availableNamespaces}
84
142
  singleNamespace={namespacesModalState?.singleNamespace}
85
143
  />
144
+ <WalletDerivationPathModal
145
+ open={!!derivationPathModalState?.open}
146
+ selectedNamespace={derivationPathModalState?.namespace}
147
+ type={derivationPathModalState?.providerType}
148
+ image={derivationPathModalState?.providerImage}
149
+ onClose={handleCloseDerivationPathModal}
150
+ onConfirm={handleDerivationPathConfirm}
151
+ />
86
152
  </>
87
153
  );
88
154
  };
@@ -110,7 +110,7 @@ export function TokenList(props: PropTypes) {
110
110
 
111
111
  useEffect(() => {
112
112
  setTokens(list.slice(0, PAGE_SIZE));
113
- }, [list.length]);
113
+ }, [list.length, selectedBlockchain]);
114
114
 
115
115
  const renderList = () => {
116
116
  if (!tokens.length && !!searchedFor) {
@@ -136,17 +136,17 @@ export function TokenList(props: PropTypes) {
136
136
  ) as BlockchainMeta;
137
137
  const colors = createTintsAndShades(blockchain.color, 'main');
138
138
  const customCssForTag = {
139
- $$color: colors.main250,
139
+ $$color: colors.main150,
140
140
  [`.${darkTheme} &`]: {
141
- $$color: colors.main850,
141
+ $$color: colors.main750,
142
142
  },
143
143
  backgroundColor: '$$color',
144
144
  };
145
145
 
146
146
  const customCssForTagTitle = {
147
- $$color: colors.main600,
147
+ $$color: colors.main750,
148
148
  [`.${darkTheme} &`]: {
149
- $$color: colors.main200,
149
+ $$color: colors.main150,
150
150
  },
151
151
  color: '$$color',
152
152
  };
@@ -0,0 +1,17 @@
1
+ import { styled, Typography } from '@rango-dev/ui';
2
+
3
+ export const InputsContainer = styled('div', {
4
+ paddingTop: '$30',
5
+ paddingBottom: '$30',
6
+ zIndex: 10, // This property is added to solve inconsistency between Select child of this component and subsequent button
7
+ });
8
+
9
+ export const InputLabel = styled(Typography, {
10
+ paddingLeft: '$10',
11
+ });
12
+
13
+ export const derivationPathInputStyles = {
14
+ height: '$40',
15
+ backgroundColor: '$neutral200',
16
+ borderRadius: '$sm',
17
+ };
@@ -0,0 +1,154 @@
1
+ import type { PropTypes } from './WalletDerivationPathModal.types';
2
+ import type { DerivationPath, Namespace } from '@rango-dev/wallets-shared';
3
+
4
+ import { i18n } from '@lingui/core';
5
+ import {
6
+ Button,
7
+ Divider,
8
+ Image,
9
+ MessageBox,
10
+ Select,
11
+ TextField,
12
+ } from '@rango-dev/ui';
13
+ import React, { useEffect, useState } from 'react';
14
+
15
+ import { WIDGET_UI_ID } from '../../constants';
16
+ import { namespaces } from '../../constants/namespaces';
17
+ import { WatermarkedModal } from '../common/WatermarkedModal';
18
+ import {
19
+ LogoContainer,
20
+ Spinner,
21
+ WalletImageContainer,
22
+ } from '../WalletModal/WalletModalContent.styles';
23
+
24
+ import {
25
+ derivationPathInputStyles,
26
+ InputLabel,
27
+ InputsContainer,
28
+ } from './WalletDerivationPathModal.styles';
29
+
30
+ const customDerivationPath: DerivationPath = {
31
+ id: 'custom',
32
+ label: 'Custom',
33
+ generateDerivationPath: (index: string) => index,
34
+ };
35
+
36
+ function getDerivationPaths(selectedNamespace?: Namespace) {
37
+ const selectedNamespaceDerivationPaths = selectedNamespace
38
+ ? namespaces[selectedNamespace].derivationPaths
39
+ : null;
40
+
41
+ const derivationPaths: DerivationPath[] = !!selectedNamespaceDerivationPaths
42
+ ? [...selectedNamespaceDerivationPaths, customDerivationPath]
43
+ : [];
44
+
45
+ return derivationPaths;
46
+ }
47
+
48
+ export function WalletDerivationPathModal(props: PropTypes) {
49
+ const { onClose, onConfirm, selectedNamespace, image, type, open } = props;
50
+
51
+ const [selectedDerivationPathId, setSelectedDerivationPathId] = useState<
52
+ string | null
53
+ >(null);
54
+ const [derivationPathIndex, setDerivationPathIndex] = useState('0');
55
+
56
+ const isCustomOptionSelected =
57
+ selectedDerivationPathId === customDerivationPath.id;
58
+
59
+ const derivationPaths = getDerivationPaths(selectedNamespace);
60
+
61
+ const handleDerivationPathItemClick = ({ value }: { value: string }) => {
62
+ const selectedDerivationPath = derivationPaths?.find(
63
+ (derivationPath) => derivationPath.id === value
64
+ );
65
+
66
+ if (selectedDerivationPath) {
67
+ setSelectedDerivationPathId(selectedDerivationPath.id);
68
+ }
69
+ };
70
+
71
+ const handleConfirm = () => {
72
+ const selectedDerivationPath = derivationPaths.find(
73
+ (derivationPath) => derivationPath.id === selectedDerivationPathId
74
+ );
75
+ if (selectedDerivationPath) {
76
+ onConfirm(
77
+ selectedDerivationPath.generateDerivationPath(derivationPathIndex)
78
+ );
79
+ } else {
80
+ // Unreachable code
81
+ throw new Error('selectedDerivationPath can not be undefined');
82
+ }
83
+ };
84
+
85
+ useEffect(() => {
86
+ setSelectedDerivationPathId(
87
+ getDerivationPaths(selectedNamespace)[0]?.id || null
88
+ );
89
+ }, [selectedNamespace]);
90
+
91
+ return (
92
+ <WatermarkedModal
93
+ open={open}
94
+ onClose={onClose}
95
+ container={
96
+ document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
97
+ }>
98
+ <Divider size={20} />
99
+ <MessageBox
100
+ type="info"
101
+ title={i18n.t('Select Derivation Path')}
102
+ description={i18n.t(
103
+ `In order to connect to ${type}, you must first select a Derivation Path`
104
+ )}
105
+ icon={
106
+ <LogoContainer>
107
+ <WalletImageContainer>
108
+ <Image src={image} size={45} />
109
+ </WalletImageContainer>
110
+ <Spinner />
111
+ </LogoContainer>
112
+ }
113
+ />
114
+
115
+ <InputsContainer>
116
+ <InputLabel variant="body" size="xsmall" color="$neutral600">
117
+ {i18n.t('Choose Derivation Path Template')}
118
+ </InputLabel>
119
+ <Select
120
+ value={selectedDerivationPathId || ''}
121
+ options={derivationPaths.map((derivationPath) => ({
122
+ value: derivationPath.id,
123
+ label: derivationPath.label,
124
+ }))}
125
+ variant="filled"
126
+ handleItemClick={handleDerivationPathItemClick}
127
+ styles={{ trigger: derivationPathInputStyles }}
128
+ />
129
+ <Divider size={20} />
130
+ <InputLabel variant="body" size="xsmall" color="$neutral600">
131
+ {isCustomOptionSelected
132
+ ? i18n.t('Enter Path')
133
+ : i18n.t('Enter Index')}
134
+ </InputLabel>
135
+ <TextField
136
+ type={isCustomOptionSelected ? 'text' : 'number'}
137
+ variant="contained"
138
+ value={derivationPathIndex}
139
+ onChange={(event) => setDerivationPathIndex(event.target.value)}
140
+ style={derivationPathInputStyles}
141
+ />
142
+ </InputsContainer>
143
+
144
+ <Button
145
+ type="primary"
146
+ onClick={handleConfirm}
147
+ disabled={
148
+ !derivationPaths || !selectedDerivationPathId || !derivationPathIndex
149
+ }>
150
+ {i18n.t('Confirm')}
151
+ </Button>
152
+ </WatermarkedModal>
153
+ );
154
+ }
@@ -0,0 +1,10 @@
1
+ import type { Namespace } from '@rango-dev/wallets-shared';
2
+
3
+ export interface PropTypes {
4
+ open: boolean;
5
+ selectedNamespace?: Namespace;
6
+ type?: string;
7
+ image?: string;
8
+ onClose: () => void;
9
+ onConfirm: (path: string) => void;
10
+ }
@@ -0,0 +1 @@
1
+ export { WalletDerivationPathModal } from './WalletDerivationPathModal';
@@ -1,20 +1,22 @@
1
1
  import type { PropTypes } from './WalletNamespacesModal.types';
2
+ import type { Namespace } from '@rango-dev/wallets-shared';
2
3
  import type { BlockchainMeta } from 'rango-sdk';
3
4
 
4
5
  import { i18n } from '@lingui/core';
5
6
  import {
6
7
  Button,
7
8
  Checkbox,
9
+ Divider,
8
10
  Image,
9
11
  ListItemButton,
10
12
  MessageBox,
11
13
  Radio,
12
14
  RadioRoot,
13
15
  } from '@rango-dev/ui';
14
- import { Namespace } from '@rango-dev/wallets-shared';
15
16
  import React, { useMemo, useState } from 'react';
16
17
 
17
18
  import { WIDGET_UI_ID } from '../../constants';
19
+ import { namespaces } from '../../constants/namespaces';
18
20
  import { useAppStore } from '../../store/AppStore';
19
21
  import { WatermarkedModal } from '../common/WatermarkedModal';
20
22
  import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles';
@@ -25,15 +27,6 @@ import {
25
27
 
26
28
  import { NamespaceList } from './WalletNamespacesModal.styles';
27
29
 
28
- export const namespaceMainBlockchain: Record<Namespace, string> = {
29
- [Namespace.Evm]: 'ETH',
30
- [Namespace.Solana]: 'SOLANA',
31
- [Namespace.Cosmos]: 'COSMOS',
32
- [Namespace.Utxo]: 'BTC',
33
- [Namespace.Starknet]: 'STARKNET',
34
- [Namespace.Tron]: 'TRON',
35
- };
36
-
37
30
  const getBlockchainLogo = (
38
31
  blockchains: BlockchainMeta[],
39
32
  blockchainName: string
@@ -43,7 +36,7 @@ const getBlockchainLogo = (
43
36
  };
44
37
 
45
38
  export function WalletNamespacesModal(props: PropTypes) {
46
- const { singleNamespace, namespaces } = props;
39
+ const { singleNamespace, availableNamespaces } = props;
47
40
 
48
41
  const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
49
42
 
@@ -51,14 +44,15 @@ export function WalletNamespacesModal(props: PropTypes) {
51
44
 
52
45
  const namespacesInfo = useMemo(
53
46
  () =>
54
- namespaces?.map((namespace) => ({
47
+ availableNamespaces?.map((namespace) => ({
55
48
  name: namespace,
56
49
  logo: getBlockchainLogo(
57
50
  blockchains,
58
- namespaceMainBlockchain[namespace]
51
+ namespaces[namespace].mainBlockchain
59
52
  ),
53
+ title: namespaces[namespace].title,
60
54
  })),
61
- [namespaces]
55
+ [availableNamespaces]
62
56
  );
63
57
 
64
58
  const onSelect = (namespace: Namespace) => {
@@ -88,6 +82,7 @@ export function WalletNamespacesModal(props: PropTypes) {
88
82
  container={
89
83
  document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
90
84
  }>
85
+ <Divider size={20} />
91
86
  <MessageBox
92
87
  type="info"
93
88
  title={i18n.t('Select chain types')}
@@ -110,7 +105,7 @@ export function WalletNamespacesModal(props: PropTypes) {
110
105
  <ListItemButton
111
106
  key={namespaceInfoItem.name}
112
107
  id={namespaceInfoItem.name}
113
- title={namespaceInfoItem.name}
108
+ title={namespaceInfoItem.title}
114
109
  hasDivider
115
110
  style={{ height: 60 }}
116
111
  onClick={() => onSelect(namespaceInfoItem.name)}
@@ -5,6 +5,6 @@ export interface PropTypes {
5
5
  image?: string;
6
6
  onClose: () => void;
7
7
  onConfirm: (namespaces: Namespace[]) => void;
8
- namespaces?: Namespace[];
8
+ availableNamespaces?: Namespace[];
9
9
  singleNamespace?: boolean;
10
10
  }
@@ -0,0 +1,62 @@
1
+ import type { DerivationPath } from '@rango-dev/wallets-shared';
2
+
3
+ import { Namespace } from '@rango-dev/wallets-shared';
4
+
5
+ export const namespaces: Record<
6
+ Namespace,
7
+ { mainBlockchain: string; title: string; derivationPaths?: DerivationPath[] }
8
+ > = {
9
+ [Namespace.Evm]: {
10
+ mainBlockchain: 'ETH',
11
+ title: 'Ethereum',
12
+ derivationPaths: [
13
+ {
14
+ id: 'metamask',
15
+ label: `Metamask (m/44'/60'/0'/0/index)`,
16
+ generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,
17
+ },
18
+ {
19
+ id: 'ledgerLive',
20
+ label: `LedgerLive (m/44'/60'/index'/0/0)`,
21
+ generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,
22
+ },
23
+ {
24
+ id: 'legacy',
25
+ label: `Legacy (m/44'/60'/0'/index)`,
26
+ generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,
27
+ },
28
+ ],
29
+ },
30
+ [Namespace.Solana]: {
31
+ mainBlockchain: 'SOLANA',
32
+ title: 'Solana',
33
+ derivationPaths: [
34
+ {
35
+ id: `(m/44'/501'/index')`,
36
+ label: `(m/44'/501'/index')`,
37
+ generateDerivationPath: (index: string) => `44'/501'/${index}'`,
38
+ },
39
+ {
40
+ id: `(m/44'/501'/0'/index)`,
41
+ label: `(m/44'/501'/0'/index)`,
42
+ generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,
43
+ },
44
+ ],
45
+ },
46
+ [Namespace.Cosmos]: {
47
+ mainBlockchain: 'COSMOS',
48
+ title: 'Cosmos',
49
+ },
50
+ [Namespace.Utxo]: {
51
+ mainBlockchain: 'BTC',
52
+ title: 'Utxo',
53
+ },
54
+ [Namespace.Starknet]: {
55
+ title: 'Starknet',
56
+ mainBlockchain: 'STARKNET',
57
+ },
58
+ [Namespace.Tron]: {
59
+ title: 'Tron',
60
+ mainBlockchain: 'TRON',
61
+ },
62
+ };
@@ -1,7 +1,6 @@
1
+ import type { I18n } from '@lingui/core';
1
2
  import type { SwapFee, TagValue } from 'rango-sdk';
2
3
 
3
- import { i18n } from '@lingui/core';
4
-
5
4
  export type NameOfFees =
6
5
  | 'Swapper Fee'
7
6
  | 'Affiliate Fee'
@@ -9,13 +8,16 @@ export type NameOfFees =
9
8
  | 'Rango Fee'
10
9
  | 'Network Fee';
11
10
 
12
- export const NAME_OF_FEES: Record<NameOfFees, string> = {
13
- 'Network Fee': i18n.t('Network Fee'),
14
- 'Swapper Fee': i18n.t('Protocol Fee'),
15
- 'Affiliate Fee': i18n.t('Affiliate Fee'),
16
- 'Outbound network fee': i18n.t('Outbound Fee'),
17
- 'Rango Fee': i18n.t('Rango Fee'),
18
- };
11
+ export function getFeeLabel(fee: NameOfFees, t: I18n['t']): string {
12
+ const data: Record<NameOfFees, string> = {
13
+ 'Network Fee': t('Network Fee'),
14
+ 'Swapper Fee': t('Protocol Fee'),
15
+ 'Affiliate Fee': t('Affiliate Fee'),
16
+ 'Outbound network fee': t('Outbound Fee'),
17
+ 'Rango Fee': t('Rango Fee'),
18
+ };
19
+ return data[fee];
20
+ }
19
21
 
20
22
  export type FeesGroup = {
21
23
  payable: { [key in NameOfFees]?: SwapFee[] };
@@ -15,5 +15,3 @@ export const PERCENTAGE_CHANGE_MAX_DECIMALS = 2;
15
15
 
16
16
  export const BALANCE_MIN_DECIMALS = 8;
17
17
  export const BALANCE_MAX_DECIMALS = 8;
18
-
19
- export const TOOLTIP_DECIMALS = 12;
@@ -17,7 +17,7 @@ import {
17
17
  import { useQuoteStore } from '../../store/quote';
18
18
  import { useWalletsStore } from '../../store/wallets';
19
19
  import { getContainer } from '../../utils/common';
20
- import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
20
+ import { numberToString } from '../../utils/numbers';
21
21
  import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
22
22
  import { canComputePriceImpact } from '../../utils/swap';
23
23
  import { formatBalance, isFetchingBalance } from '../../utils/wallets';
@@ -97,7 +97,7 @@ export function Inputs(props: PropTypes) {
97
97
  ),
98
98
  realUsdValue: priceImpactInputCanNotBeComputed
99
99
  ? undefined
100
- : formatTooltipNumbers(inputUsdValue),
100
+ : inputUsdValue?.toString(),
101
101
  error: priceImpactInputCanNotBeComputed
102
102
  ? errorMessages().unknownPriceError.impactTitle
103
103
  : undefined,
@@ -144,10 +144,10 @@ export function Inputs(props: PropTypes) {
144
144
  USD_VALUE_MIN_DECIMALS,
145
145
  USD_VALUE_MAX_DECIMALS
146
146
  ),
147
- realValue: formatTooltipNumbers(outputAmount),
147
+ realValue: outputAmount?.toString(),
148
148
  realUsdValue: priceImpactOutputCanNotBeComputed
149
149
  ? undefined
150
- : formatTooltipNumbers(outputUsdValue),
150
+ : outputUsdValue?.toString(),
151
151
  error: priceImpactOutputCanNotBeComputed
152
152
  ? errorMessages().unknownPriceError.impactTitle
153
153
  : undefined,
@@ -37,7 +37,8 @@ function Main(props: PropsWithChildren<PropTypes>) {
37
37
  const config = useAppStore().config;
38
38
 
39
39
  const walletOptions: ProvidersOptions = {
40
- walletConnectProjectId: props.config?.walletConnectProjectId,
40
+ walletConnectProjectId: config?.walletConnectProjectId,
41
+ trezorManifest: config?.trezorManifest,
41
42
  walletConnectListedDesktopWalletLink:
42
43
  props.config.__UNSTABLE_OR_INTERNAL__
43
44
  ?.walletConnectListedDesktopWalletLink,
@@ -34,6 +34,7 @@ export function WidgetInfo(props: React.PropsWithChildren) {
34
34
  const loadingStatus = useAppStore().fetchStatus;
35
35
  const resetLanguage = useLanguage().resetLanguage;
36
36
  const notifications = useNotificationStore().getNotifications();
37
+ const clearNotifications = useNotificationStore().clearNotifications;
37
38
 
38
39
  // eslint-disable-next-line react/jsx-no-constructed-context-values
39
40
  const value: WidgetInfoContextInterface = {
@@ -51,10 +52,12 @@ export function WidgetInfo(props: React.PropsWithChildren) {
51
52
  tokens,
52
53
  swappers,
53
54
  loadingStatus,
55
+ findToken,
54
56
  },
55
57
  resetLanguage,
56
58
  notifications: {
57
59
  list: notifications,
60
+ clearAll: clearNotifications,
58
61
  },
59
62
  };
60
63