@rango-dev/ui 0.1.10-next.78 → 0.1.10-next.80

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 (39) hide show
  1. package/dist/components/Alert/Alert.d.ts +2 -2
  2. package/dist/components/Alert/Alert.stories.d.ts +2 -1
  3. package/dist/components/BestRoute/BestRoute.d.ts +4 -1
  4. package/dist/components/SecondaryPage/SecondaryPage.d.ts +3 -5
  5. package/dist/components/SelectableWalletList/SelectableWalletList.d.ts +1 -1
  6. package/dist/components/TextField/TextField.stories.d.ts +1 -1
  7. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +8 -4
  8. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +4 -2
  9. package/dist/containers/History/types.d.ts +1 -0
  10. package/dist/helper/index.d.ts +0 -5
  11. package/dist/types/wallet.d.ts +8 -0
  12. package/dist/ui.cjs.development.js +288 -262
  13. package/dist/ui.cjs.development.js.map +1 -1
  14. package/dist/ui.cjs.production.min.js +1 -1
  15. package/dist/ui.cjs.production.min.js.map +1 -1
  16. package/dist/ui.esm.js +288 -262
  17. package/dist/ui.esm.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/Alert/Alert.tsx +5 -9
  20. package/src/components/BestRoute/BestRoute.tsx +55 -21
  21. package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -11
  22. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +21 -20
  23. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +3 -2
  24. package/src/components/Radio/Radio.tsx +1 -0
  25. package/src/components/SecondaryPage/SecondaryPage.tsx +5 -6
  26. package/src/components/SelectableWalletList/SelectableWalletList.tsx +1 -1
  27. package/src/components/Settings/Settings.tsx +12 -13
  28. package/src/components/SwapContainer/SwapContainer.tsx +1 -0
  29. package/src/components/Switch/Switch.tsx +1 -0
  30. package/src/components/TokenSelector/TokenSelector.tsx +3 -2
  31. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +92 -54
  32. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +66 -62
  33. package/src/containers/History/History.tsx +3 -2
  34. package/src/containers/History/types.tsx +10 -1
  35. package/src/containers/SwapHistory/SwapHistory.tsx +87 -95
  36. package/src/helper/index.ts +1 -22
  37. package/src/types/wallet.ts +9 -0
  38. package/dist/containers/ConfirmWallets/types.d.ts +0 -9
  39. package/src/containers/ConfirmWallets/types.ts +0 -10
@@ -5,9 +5,8 @@ import { Button } from '../../components/Button';
5
5
  import { SecondaryPage } from '../../components/SecondaryPage/SecondaryPage';
6
6
  import { SelectableWalletList } from '../../components/SelectableWalletList';
7
7
  import { Typography } from '../../components/Typography';
8
- import { decimalNumber } from '../../helper';
9
8
  import { styled } from '../../theme';
10
- import { SelectableWallet } from './types';
9
+ import { SelectableWallet } from '../../types';
11
10
 
12
11
  const Footer = styled('div', {
13
12
  display: 'flex',
@@ -18,8 +17,14 @@ const AlertContainer = styled('div', {
18
17
  padding: '$16 0',
19
18
  });
20
19
 
20
+ const ConfirmButton = styled(Button, {
21
+ marginTop: '$16',
22
+ });
23
+
21
24
  export interface PropTypes {
22
25
  swap: BestRouteResponse;
26
+ fromAmount: string;
27
+ toAmount: string;
23
28
  onBack: () => void;
24
29
  onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
25
30
  confirmDisabled?: boolean;
@@ -30,24 +35,25 @@ export interface PropTypes {
30
35
  isExperimentalChain?: (wallet: string) => boolean;
31
36
  handleConnectChain?: (wallet: string) => void;
32
37
  }
33
- export function ConfirmWallets({
34
- onBack,
35
- loading,
36
- onConfirm,
37
- swap,
38
- requiredWallets,
39
- selectableWallets,
40
- onChange,
41
- confirmDisabled,
42
- isExperimentalChain,
43
- handleConnectChain,
44
- }: PropsWithChildren<PropTypes>) {
38
+ export function ConfirmWallets(props: PropsWithChildren<PropTypes>) {
39
+ const {
40
+ onBack,
41
+ loading,
42
+ onConfirm,
43
+ swap,
44
+ requiredWallets,
45
+ selectableWallets,
46
+ onChange,
47
+ confirmDisabled,
48
+ isExperimentalChain,
49
+ handleConnectChain,
50
+ fromAmount,
51
+ toAmount,
52
+ } = props;
53
+
45
54
  const firstStep = swap.result?.swaps[0];
46
55
  const lastStep = swap.result?.swaps[swap.result?.swaps.length - 1];
47
56
 
48
- const fromAmount = decimalNumber(firstStep?.fromAmount, 3);
49
- const toAmount = decimalNumber(lastStep?.toAmount, 3);
50
-
51
57
  return (
52
58
  <SecondaryPage
53
59
  textField={false}
@@ -55,7 +61,7 @@ export function ConfirmWallets({
55
61
  onBack={onBack}
56
62
  Footer={
57
63
  <Footer>
58
- <Button
64
+ <ConfirmButton
59
65
  fullWidth
60
66
  loading={loading}
61
67
  type="primary"
@@ -64,51 +70,49 @@ export function ConfirmWallets({
64
70
  disabled={confirmDisabled}
65
71
  >
66
72
  Confirm
67
- </Button>
73
+ </ConfirmButton>
68
74
  </Footer>
69
75
  }
70
- Content={
71
- <>
72
- <Typography variant="h6" mb={12}>
73
- Confirm swap {fromAmount} {lastStep?.from.symbol} (
74
- {firstStep?.from.blockchain}) to {toAmount} {lastStep?.to.symbol}{' '}
75
- (on {lastStep?.to.blockchain})
76
- </Typography>
77
- {requiredWallets.map((wallet, index) => {
78
- const list = selectableWallets.filter((w) => wallet === w.chain);
79
- return (
80
- <div key={index}>
81
- <Typography variant="body2" mb={12} mt={12}>
82
- {index + 1}) Your {wallet} Wallet
83
- </Typography>
84
- {list.length === 0 && (
85
- <>
86
- <AlertContainer>
87
- <Alert
88
- type="error"
89
- description={`You should connect a ${wallet} supported wallet`}
90
- />
91
- </AlertContainer>
92
- {isExperimentalChain?.(wallet) && (
93
- <Button
94
- variant="contained"
95
- type="primary"
96
- align="grow"
97
- onClick={() => handleConnectChain?.(wallet)}
98
- >
99
- {`Add ${wallet} chain to Cosmos wallets`}
100
- </Button>
101
- )}
102
- </>
103
- )}
104
- {list.length != 0 && (
105
- <SelectableWalletList list={list} onChange={onChange} />
106
- )}
107
- </div>
108
- );
109
- })}
110
- </>
111
- }
112
- />
76
+ >
77
+ <>
78
+ <Typography variant="h6" mb={12}>
79
+ Confirm swap {fromAmount} {firstStep?.from.symbol} (
80
+ {firstStep?.from.blockchain}) to {toAmount} {lastStep?.to.symbol} (on
81
+ {lastStep?.to.blockchain})
82
+ </Typography>
83
+ {requiredWallets.map((wallet, index) => {
84
+ const list = selectableWallets.filter((w) => wallet === w.chain);
85
+ return (
86
+ <div key={index}>
87
+ <Typography variant="body2" mb={12} mt={12}>
88
+ {index + 1}) Your {wallet} Wallet
89
+ </Typography>
90
+ {list.length === 0 && (
91
+ <>
92
+ <AlertContainer>
93
+ <Alert type="error">
94
+ <Typography variant="body2">{`You should connect a ${wallet} supported wallet`}</Typography>
95
+ </Alert>
96
+ </AlertContainer>
97
+ {isExperimentalChain?.(wallet) && (
98
+ <Button
99
+ variant="contained"
100
+ type="primary"
101
+ align="grow"
102
+ onClick={() => handleConnectChain?.(wallet)}
103
+ >
104
+ {`Add ${wallet} chain to Cosmos wallets`}
105
+ </Button>
106
+ )}
107
+ </>
108
+ )}
109
+ {list.length != 0 && (
110
+ <SelectableWalletList list={list} onChange={onChange} />
111
+ )}
112
+ </div>
113
+ );
114
+ })}
115
+ </>
116
+ </SecondaryPage>
113
117
  );
114
118
  }
@@ -79,7 +79,8 @@ export function History({
79
79
  textField={true}
80
80
  textFieldPlaceholder="Search By Blockchain Or Token"
81
81
  title="History"
82
- Content={({ searchedFor }) => {
82
+ >
83
+ {(searchedFor) => {
83
84
  const filterSwaps = filteredHistory(list, searchedFor);
84
85
  return filterSwaps.length ? (
85
86
  <SwapsGroup list={filterSwaps} onSwapClick={onSwapClick} />
@@ -89,6 +90,6 @@ export function History({
89
90
  </BodyError>
90
91
  );
91
92
  }}
92
- />
93
+ </SecondaryPage>
93
94
  );
94
95
  }
@@ -1,4 +1,12 @@
1
- import { CosmosTransaction, EvmTransaction, SimulationResult, SolanaTransaction, SwapExplorerUrl, SwapperStatusStep, Transfer } from 'rango-sdk';
1
+ import {
2
+ CosmosTransaction,
3
+ EvmTransaction,
4
+ SimulationResult,
5
+ SolanaTransaction,
6
+ SwapExplorerUrl,
7
+ SwapperStatusStep,
8
+ Transfer,
9
+ } from 'rango-sdk';
2
10
  import {
3
11
  MessageSeverity,
4
12
  PendingSwapNetworkStatus,
@@ -28,6 +36,7 @@ export type PendingSwapStep = {
28
36
  swapperId: string;
29
37
  swapperLogo: string;
30
38
  swapperType: string;
39
+ feeInUsd: string;
31
40
  expectedOutputAmountHumanReadable: string | null;
32
41
  startTransactionTime: number;
33
42
  outputAmount: string;
@@ -63,103 +63,95 @@ export function SwapHistory(props: PropTypes) {
63
63
  const { pendingSwap, onBack } = props;
64
64
 
65
65
  return (
66
- <SecondaryPage
67
- title="History"
68
- textField={false}
69
- onBack={onBack}
70
- Content={
71
- <>
72
- {pendingSwap?.steps.map((step, index) => (
73
- <Fragment key={index}>
74
- {index === 0 && (
75
- <RelativeContainer>
76
- <StepDetail
77
- logo={step.fromLogo}
78
- symbol={step.fromSymbol}
79
- chainLogo={step.fromBlockchainLogo}
80
- blockchain={step.fromBlockchain}
81
- amount={pendingSwap.inputAmount}
82
- />
83
- <Dot />
84
- </RelativeContainer>
85
- )}
86
- <Line />
87
- <SwapperContainer>
88
- <SwapperLogo src={step.swapperLogo} alt={step.swapperId} />
89
- <div>
66
+ <SecondaryPage title="History" textField={false} onBack={onBack}>
67
+ <>
68
+ {pendingSwap?.steps.map((step, index) => (
69
+ <Fragment key={index}>
70
+ {index === 0 && (
71
+ <RelativeContainer>
72
+ <StepDetail
73
+ logo={step.fromLogo}
74
+ symbol={step.fromSymbol}
75
+ chainLogo={step.fromBlockchainLogo}
76
+ blockchain={step.fromBlockchain}
77
+ amount={pendingSwap.inputAmount}
78
+ />
79
+ <Dot />
80
+ </RelativeContainer>
81
+ )}
82
+ <Line />
83
+ <SwapperContainer>
84
+ <SwapperLogo src={step.swapperLogo} alt={step.swapperId} />
85
+ <div>
86
+ <Typography ml={4} variant="caption">
87
+ {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
88
+ via {step.swapperId}
89
+ </Typography>
90
+ <Fee>
91
+ <GasIcon />
90
92
  <Typography ml={4} variant="caption">
91
- {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
92
- via {step.swapperId}
93
+ {step.feeInUsd} estimated gas fee
93
94
  </Typography>
94
- <Fee>
95
- <GasIcon />
96
- <Typography ml={4} variant="caption">
97
- {/* {parseFloat(step.fee[0].amount).toFixed(6)} estimated gas */}
98
- fee
99
- </Typography>
100
- </Fee>
101
- </div>
102
- </SwapperContainer>
103
- <div
104
- style={{
105
- display: 'flex',
106
- }}
107
- >
108
- <InternalDetailsContainer>
109
- <Line />
110
- {!!step.explorerUrl && (
111
- <div>
112
- {step.explorerUrl.map((item, index) => (
113
- <InternalDetail key={index}>
114
- <DescriptionContainer>
115
- <CheckCircleIcon color="success" />
116
- <Description variant="body2">
117
- {!item.description ? (
118
- <b>View transaction</b>
119
- ) : (
120
- <b>
121
- {item.description
122
- .substring(0, 1)
123
- .toUpperCase()}
124
- {item.description.substring(1)}
125
- </b>
126
- )}
127
- </Description>
128
- </DescriptionContainer>
129
- <StyledAnchor
130
- href={item.url}
131
- target="_blank"
132
- rel="noreferrer"
133
- key={index}
134
- >
135
- TX-Link
136
- </StyledAnchor>
137
- </InternalDetail>
138
- ))}
139
- {step.status === 'failed' && (
140
- <InternalDetail>
141
- <DescriptionContainer>
142
- <InfoCircleIcon color="error" />
143
- <Error variant="body2">Step failed</Error>
144
- </DescriptionContainer>
145
- </InternalDetail>
146
- )}
147
- </div>
148
- )}
149
- </InternalDetailsContainer>
95
+ </Fee>
150
96
  </div>
151
- {index + 1 === pendingSwap.steps.length && <ArrowDown />}
152
- <StepDetail
153
- logo={step.toLogo}
154
- symbol={step.toSymbol}
155
- chainLogo={step.toBlockchainLogo}
156
- blockchain={step.toBlockchain}
157
- amount={step.outputAmount}
158
- />
159
- </Fragment>
160
- ))}
161
- </>
162
- }
163
- />
97
+ </SwapperContainer>
98
+ <div
99
+ style={{
100
+ display: 'flex',
101
+ }}
102
+ >
103
+ <InternalDetailsContainer>
104
+ <Line />
105
+ {!!step.explorerUrl && (
106
+ <div>
107
+ {step.explorerUrl.map((item, index) => (
108
+ <InternalDetail key={index}>
109
+ <DescriptionContainer>
110
+ <CheckCircleIcon color="success" />
111
+ <Description variant="body2">
112
+ {!item.description ? (
113
+ <b>View transaction</b>
114
+ ) : (
115
+ <b>
116
+ {item.description.substring(0, 1).toUpperCase()}
117
+ {item.description.substring(1)}
118
+ </b>
119
+ )}
120
+ </Description>
121
+ </DescriptionContainer>
122
+ <StyledAnchor
123
+ href={item.url}
124
+ target="_blank"
125
+ rel="noreferrer"
126
+ key={index}
127
+ >
128
+ TX-Link
129
+ </StyledAnchor>
130
+ </InternalDetail>
131
+ ))}
132
+ {step.status === 'failed' && (
133
+ <InternalDetail>
134
+ <DescriptionContainer>
135
+ <InfoCircleIcon color="error" />
136
+ <Error variant="body2">Step failed</Error>
137
+ </DescriptionContainer>
138
+ </InternalDetail>
139
+ )}
140
+ </div>
141
+ )}
142
+ </InternalDetailsContainer>
143
+ </div>
144
+ {index + 1 === pendingSwap.steps.length && <ArrowDown />}
145
+ <StepDetail
146
+ logo={step.toLogo}
147
+ symbol={step.toSymbol}
148
+ chainLogo={step.toBlockchainLogo}
149
+ blockchain={step.toBlockchain}
150
+ amount={step.outputAmount}
151
+ />
152
+ </Fragment>
153
+ ))}
154
+ </>
155
+ </SecondaryPage>
164
156
  );
165
157
  }
@@ -1,23 +1,2 @@
1
- import { BestRouteResponse } from 'rango-sdk';
2
-
3
- export const secondsToString = (s: number): string => {
4
- const minutes = parseInt((s / 60).toString()).toString();
5
- return `${minutes}`;
6
- };
7
- export const totalArrivalTime = (data: BestRouteResponse) =>
8
- data?.result?.swaps?.reduce((a, b) => a + b.estimatedTimeInSeconds, 0) || 0;
9
-
10
- export const rawFees = (data: BestRouteResponse): string =>
11
- (
12
- data?.result?.swaps?.flatMap((s) =>
13
- s.fee.map((f) => ({ swapperId: s.swapperId, fee: f }))
14
- ) || []
15
- )
16
- .reduce((partialSum, a) => partialSum + parseFloat(a.fee.amount), 0)
17
- .toFixed(3);
18
-
19
- export const decimalNumber = (number = '0', toFixed: number) =>
20
- parseFloat(number).toFixed(toFixed);
21
-
22
1
  export const containsText = (text: string, searchText: string) =>
23
- text.toLowerCase().includes(searchText.toLowerCase());
2
+ text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
@@ -18,3 +18,12 @@ export type WalletInfo = {
18
18
  image: string;
19
19
  type: WalletType;
20
20
  };
21
+
22
+ export interface SelectableWallet {
23
+ chain: string;
24
+ walletType: WalletType;
25
+ address: string;
26
+ image: string;
27
+ selected: boolean;
28
+ name: string;
29
+ }
@@ -1,9 +0,0 @@
1
- import { WalletType } from '@rango-dev/wallets-shared';
2
- export interface SelectableWallet {
3
- chain: string;
4
- walletType: WalletType;
5
- address: string;
6
- image: string;
7
- selected: boolean;
8
- name: string;
9
- }
@@ -1,10 +0,0 @@
1
- import { WalletType } from '@rango-dev/wallets-shared';
2
-
3
- export interface SelectableWallet {
4
- chain: string;
5
- walletType: WalletType;
6
- address: string;
7
- image: string;
8
- selected: boolean;
9
- name: string;
10
- }