@rango-dev/ui 0.1.10-next.91 → 0.1.10

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 (116) hide show
  1. package/README.md +1 -181
  2. package/dist/components/Alert/Alert.d.ts +3 -2
  3. package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
  4. package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
  5. package/dist/components/Alert/index.d.ts +1 -0
  6. package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
  7. package/dist/components/Button/Button.d.ts +3 -3
  8. package/dist/components/Divider/Divider.d.ts +6 -0
  9. package/dist/components/Divider/index.d.ts +1 -0
  10. package/dist/components/Header/Header.d.ts +9 -0
  11. package/dist/components/Header/index.d.ts +1 -0
  12. package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
  13. package/dist/components/Icon/ChevronRightIcon.d.ts +3 -0
  14. package/dist/components/Icon/DisconnectIcon.d.ts +3 -0
  15. package/dist/components/Icon/index.d.ts +3 -0
  16. package/dist/components/Icon/types.d.ts +1 -1
  17. package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  18. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  19. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  20. package/dist/components/Settings/Settings.d.ts +2 -1
  21. package/dist/components/Spacer/Spacer.d.ts +1 -1
  22. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  23. package/dist/components/SwapDetail/Token.d.ts +16 -0
  24. package/dist/components/TextField/TextField.stories.d.ts +1 -1
  25. package/dist/components/TokenSelector/TokenSelector.d.ts +3 -0
  26. package/dist/components/Typography/Typography.d.ts +3 -2
  27. package/dist/components/index.d.ts +2 -0
  28. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +10 -17
  29. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  30. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  31. package/dist/containers/History/History.d.ts +6 -1
  32. package/dist/containers/History/index.d.ts +1 -1
  33. package/dist/containers/History/types.d.ts +3 -24
  34. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  35. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  36. package/dist/containers/index.d.ts +0 -1
  37. package/dist/helper/index.d.ts +1 -0
  38. package/dist/types/meta.d.ts +1 -0
  39. package/dist/ui.cjs.development.js +1455 -1033
  40. package/dist/ui.cjs.development.js.map +1 -1
  41. package/dist/ui.cjs.production.min.js +1 -1
  42. package/dist/ui.cjs.production.min.js.map +1 -1
  43. package/dist/ui.esm.js +1463 -1046
  44. package/dist/ui.esm.js.map +1 -1
  45. package/package.json +3 -2
  46. package/src/components/Alert/Alert.tsx +63 -39
  47. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  48. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  49. package/src/components/Alert/index.ts +1 -0
  50. package/src/components/BestRoute/BestRoute.tsx +28 -19
  51. package/src/components/BestRoute/mock.ts +10 -0
  52. package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -21
  53. package/src/components/Button/Button.stories.tsx +1 -1
  54. package/src/components/Button/Button.tsx +36 -23
  55. package/src/components/Chip/Chip.tsx +7 -4
  56. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  57. package/src/components/Divider/Divider.tsx +41 -0
  58. package/src/components/Divider/index.ts +1 -0
  59. package/src/components/Header/Header.tsx +39 -0
  60. package/src/components/Header/index.ts +1 -0
  61. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  62. package/src/components/Icon/ChevronRightIcon.tsx +29 -0
  63. package/src/components/Icon/DisconnectIcon.tsx +31 -0
  64. package/src/components/Icon/HistoryIcon.tsx +12 -18
  65. package/src/components/Icon/RetryIcon.tsx +13 -13
  66. package/src/components/Icon/SettingIcon.tsx +6 -14
  67. package/src/components/Icon/index.ts +3 -0
  68. package/src/components/Icon/types.tsx +1 -1
  69. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +104 -30
  70. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +16 -11
  71. package/src/components/Radio/Radio.tsx +5 -4
  72. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  73. package/src/components/SelectableWalletList/SelectableWalletList.tsx +5 -1
  74. package/src/components/SelectableWalletList/mock.ts +4 -3
  75. package/src/components/Settings/Settings.tsx +47 -12
  76. package/src/components/Spacer/Spacer.tsx +31 -1
  77. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  78. package/src/components/StepDetail/StepDetail.tsx +19 -7
  79. package/src/components/SwapContainer/SwapContainer.tsx +22 -17
  80. package/src/components/SwapDetail/SwapDetail.tsx +77 -115
  81. package/src/components/SwapDetail/Token.tsx +68 -0
  82. package/src/components/SwapDetail/mock.ts +1 -0
  83. package/src/components/Switch/Switch.tsx +7 -5
  84. package/src/components/TextField/TextField.tsx +3 -1
  85. package/src/components/TokenList/TokenItem.tsx +4 -1
  86. package/src/components/TokenList/TokenList.tsx +16 -18
  87. package/src/components/TokenSelector/TokenSelector.tsx +47 -10
  88. package/src/components/Typography/Typography.stories.tsx +4 -0
  89. package/src/components/Typography/Typography.tsx +20 -9
  90. package/src/components/Wallet/State.tsx +2 -3
  91. package/src/components/Wallet/Wallet.tsx +33 -6
  92. package/src/components/index.ts +2 -0
  93. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  94. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +103 -119
  95. package/src/containers/ConfirmSwap/mock.ts +79 -2
  96. package/src/containers/History/History.tsx +57 -38
  97. package/src/containers/History/index.ts +1 -1
  98. package/src/containers/History/mock.ts +1 -0
  99. package/src/containers/History/types.tsx +2 -30
  100. package/src/containers/SwapHistory/SwapHistory.tsx +309 -165
  101. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  102. package/src/containers/SwapHistory/mock.ts +1 -0
  103. package/src/containers/index.ts +0 -1
  104. package/src/helper/index.ts +14 -0
  105. package/src/theme.ts +4 -2
  106. package/src/types/meta.ts +2 -0
  107. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -18
  108. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  109. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  110. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  111. package/dist/helper/swaps.d.ts +0 -5
  112. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  113. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -118
  114. package/src/containers/ConfirmWallets/index.ts +0 -1
  115. package/src/containers/ConfirmWallets/mock.ts +0 -222
  116. package/src/helper/swaps.ts +0 -23
@@ -1,13 +1,22 @@
1
1
  import React from 'react';
2
2
  import { ComponentMeta } from '@storybook/react';
3
3
  import { ConfirmSwap, PropTypes } from './ConfirmSwap';
4
- import { bestRoute } from './mock';
4
+ import { exampleFor5Wallets, wallets } from './mock';
5
5
 
6
6
  export default {
7
7
  title: 'Containers/ConfirmSwap',
8
8
  component: ConfirmSwap,
9
+ argTypes: {
10
+ requiredWallets: {
11
+ defaultValue: ['BSC', 'OSMOSIS'],
12
+ },
13
+ },
9
14
  } as ComponentMeta<typeof ConfirmSwap>;
10
15
 
11
16
  export const Main = (props: PropTypes) => (
12
- <ConfirmSwap {...props} bestRoute={bestRoute} />
17
+ <ConfirmSwap {...props} selectableWallets={wallets} />
18
+ );
19
+
20
+ export const With5Wallets = (props: PropTypes) => (
21
+ <ConfirmSwap {...props} selectableWallets={exampleFor5Wallets} />
13
22
  );
@@ -1,129 +1,112 @@
1
- import React, { Fragment, PropsWithChildren, ReactNode } from 'react';
2
- import { Spacer } from '../../components';
3
- import { Alert } from '../../components/Alert';
1
+ import React, { PropsWithChildren, ReactNode } from 'react';
2
+ import { Alert, Spacer } from '../../components';
4
3
  import { Button } from '../../components/Button';
5
- import { RetryIcon, GasIcon } from '../../components/Icon';
6
- import { SecondaryPage } from '../../components/SecondaryPage/';
7
- import { StepDetail } from '../../components/StepDetail';
4
+ import { SecondaryPage } from '../../components/SecondaryPage/SecondaryPage';
5
+ import { SelectableWalletList } from '../../components/SelectableWalletList';
8
6
  import { Typography } from '../../components/Typography';
9
7
  import { styled } from '../../theme';
10
- import { BestRouteWithFee } from '../../types/swaps';
8
+ import { SelectableWallet } from '../../types';
11
9
 
12
10
  const MainContainer = styled('div', {
13
- overflow: 'hidden',
11
+ overflowY: 'auto',
14
12
  });
15
13
 
16
- export const Line = styled('div', {
17
- width: '0',
18
- marginLeft: '$12',
19
- height: '36px',
20
- border: '1px dashed $foreground',
21
- borderRadius: 'inherit',
22
- });
23
- export const SwapperContainer = styled('div', {
24
- display: 'flex',
25
- alignItems: 'center',
26
- marginLeft: '6px',
27
- });
28
- export const BodyError = styled('div', {
29
- height: '100%',
30
- display: 'flex',
31
- justifyContent: 'center',
32
- alignItems: 'center',
33
- });
34
- export const ErrorMsg = styled(Typography, {
35
- color: '$error',
36
- });
37
- export const Fee = styled('div', {
38
- display: 'flex',
39
- alignItems: 'center',
40
- });
41
- export const SwapperLogo = styled('img', {
42
- width: '$16',
43
- height: '$16',
44
- });
45
- export const RelativeContainer = styled('div', {
46
- position: 'relative',
14
+ const Section = styled('div', {
15
+ paddingBottom: '$32',
16
+ marginBottom: '$32',
17
+ borderBottom: '1px solid $neutrals400',
47
18
  });
48
19
 
49
- export const Footer = styled('div', {
20
+ const Footer = styled('div', {
50
21
  display: 'flex',
51
22
  alignItems: 'center',
52
23
  });
53
- export const Dot = styled('div', {
54
- width: '$8',
55
- height: '$8',
56
- backgroundColor: '$foreground',
57
- borderRadius: '4px',
58
- marginLeft: '$8',
59
- });
60
- export const ArrowDown = styled('div', {
61
- width: '0px',
62
- height: '0px',
63
- borderLeft: '5px solid transparent',
64
- borderRight: '5px solid transparent',
65
- borderTop: '5px solid $foreground',
66
- marginLeft: '$8',
67
- });
68
- export const UpdateIcon = styled(RetryIcon, {
69
- position: 'absolute',
70
- right: '0',
24
+
25
+ const AlertContainer = styled('div', {
26
+ padding: '$16 0',
71
27
  });
72
- export const StyledUpdateIcon = styled(UpdateIcon, {
73
- cursor: 'pointer',
28
+
29
+ const ConfirmButton = styled(Button, {
30
+ marginTop: '$16',
74
31
  });
75
32
 
76
- const BestRouteContainer = styled('div', {
77
- overflow: 'auto',
33
+ const Container = styled('div', {
34
+ paddingBottom: '$24',
35
+
36
+ '.title': {
37
+ paddingBottom: '$8',
38
+ display: 'flex',
39
+ alignItems: 'center',
40
+ },
41
+ '.num': {
42
+ backgroundColor: '$neutrals300',
43
+ display: 'inline-flex',
44
+ width: '24px',
45
+ height: '24px',
46
+ color: '$neutrals800',
47
+ borderRadius: '50%',
48
+ fontSize: '$14',
49
+ border: '1px solid $neutrals400',
50
+ justifyContent: 'center',
51
+ alignItems: 'center',
52
+ },
78
53
  });
79
54
 
80
55
  const Alerts = styled('div', { paddingBottom: '$16' });
56
+
81
57
  export interface PropTypes {
82
- bestRoute: BestRouteWithFee | null;
83
- onRefresh?: React.MouseEventHandler<SVGElement>;
84
- confirmButtonTitle: string;
85
- confirmButtonDisabled: boolean;
86
58
  onBack: () => void;
87
59
  onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
60
+ confirmDisabled?: boolean;
88
61
  loading?: boolean;
62
+ requiredWallets: string[];
63
+ selectableWallets: SelectableWallet[];
64
+ onChange: (w: SelectableWallet) => void;
65
+ isExperimentalChain?: (wallet: string) => boolean;
66
+ handleConnectChain?: (wallet: string) => void;
67
+ previewInputs?: ReactNode;
68
+ previewRoutes?: ReactNode;
69
+ confirmButtonTitle: string;
89
70
  errors?: ReactNode[];
90
71
  warnings?: ReactNode[];
91
72
  extraMessages?: ReactNode;
92
73
  }
93
74
  export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
94
75
  const {
95
- bestRoute,
96
- onRefresh,
97
76
  onBack,
98
- onConfirm,
99
77
  loading,
78
+ onConfirm,
79
+ requiredWallets,
80
+ selectableWallets,
81
+ onChange,
82
+ confirmDisabled,
83
+ isExperimentalChain,
84
+ handleConnectChain,
85
+ confirmButtonTitle,
100
86
  errors,
101
87
  warnings,
102
88
  extraMessages,
103
- confirmButtonTitle,
104
- confirmButtonDisabled,
105
89
  } = props;
106
90
 
107
91
  return (
108
92
  <SecondaryPage
109
93
  textField={false}
110
- title="Swap"
94
+ title="Confirm Swap"
111
95
  onBack={onBack}
112
96
  Footer={
113
97
  <Footer>
114
- <Button
115
- type="primary"
98
+ <ConfirmButton
116
99
  fullWidth
117
100
  loading={loading}
101
+ type="primary"
118
102
  variant="contained"
119
103
  onClick={onConfirm}
120
- disabled={confirmButtonDisabled}
104
+ disabled={confirmDisabled}
121
105
  >
122
106
  {confirmButtonTitle}
123
- </Button>
107
+ </ConfirmButton>
124
108
  </Footer>
125
109
  }
126
- TopButton={<StyledUpdateIcon size={24} onClick={onRefresh} />}
127
110
  >
128
111
  <MainContainer>
129
112
  <div>
@@ -147,49 +130,50 @@ export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
147
130
  ))}
148
131
  </Alerts>
149
132
  </div>
150
- <BestRouteContainer>
151
- {bestRoute?.result?.swaps.map((swap, index) => (
152
- <Fragment key={index}>
153
- {index === 0 && (
154
- <RelativeContainer>
155
- <StepDetail
156
- logo={swap.from.logo}
157
- symbol={swap.from.symbol}
158
- chainLogo={swap.from.blockchainLogo}
159
- blockchain={swap.from.blockchain}
160
- amount={swap.fromAmount}
161
- />
162
- <Dot />
163
- </RelativeContainer>
133
+ {props.previewInputs || props.previewRoutes ? (
134
+ <Section>
135
+ {props.previewInputs}
136
+ {!!props.previewRoutes ? (
137
+ <Spacer size={16} direction="vertical" />
138
+ ) : null}
139
+ {props.previewRoutes}
140
+ </Section>
141
+ ) : null}
142
+
143
+ {requiredWallets.map((wallet, index) => {
144
+ const list = selectableWallets.filter((w) => wallet === w.chain);
145
+ return (
146
+ <Container key={index}>
147
+ <div className="title">
148
+ <div className="num">{index + 1}</div>
149
+ <Spacer size={8} />
150
+ <Typography variant="body2">Your {wallet} Wallet</Typography>
151
+ </div>
152
+ {list.length === 0 && (
153
+ <>
154
+ <AlertContainer>
155
+ <Alert type="error">
156
+ You need to connect a compatible wallet with {wallet}
157
+ </Alert>
158
+ </AlertContainer>
159
+ {isExperimentalChain?.(wallet) && (
160
+ <Button
161
+ variant="contained"
162
+ type="primary"
163
+ align="grow"
164
+ onClick={() => handleConnectChain?.(wallet)}
165
+ >
166
+ {`Add ${wallet} chain to Cosmos wallets`}
167
+ </Button>
168
+ )}
169
+ </>
170
+ )}
171
+ {list.length != 0 && (
172
+ <SelectableWalletList list={list} onChange={onChange} />
164
173
  )}
165
- <Line />
166
- <SwapperContainer>
167
- <SwapperLogo src={swap.swapperLogo} alt={swap.swapperId} />
168
- <div>
169
- <Typography ml={4} variant="caption">
170
- {swap.swapperType} from {swap.from.symbol} to{' '}
171
- {swap.to.symbol} via {swap.swapperId}{' '}
172
- </Typography>
173
- <Fee>
174
- <GasIcon />
175
- <Typography ml={4} variant="caption">
176
- ${swap.feeInUsd} estimated gas fee
177
- </Typography>
178
- </Fee>
179
- </div>
180
- </SwapperContainer>
181
- <Line />
182
- {index + 1 === bestRoute.result?.swaps.length && <ArrowDown />}
183
- <StepDetail
184
- logo={swap.to.logo}
185
- symbol={swap.to.symbol}
186
- chainLogo={swap.to.blockchainLogo}
187
- blockchain={swap.to.blockchain}
188
- amount={swap.toAmount}
189
- />
190
- </Fragment>
191
- ))}
192
- </BestRouteContainer>
174
+ </Container>
175
+ );
176
+ })}
193
177
  </MainContainer>
194
178
  </SecondaryPage>
195
179
  );
@@ -1,5 +1,8 @@
1
+ // @ts-nocheck
2
+ import { WalletType } from '@rango-dev/wallets-shared';
1
3
  import { RoutingResultType } from 'rango-sdk';
2
4
  import { BestRouteType } from '../../types/swaps';
5
+ import { SelectableWallet } from '../../types';
3
6
 
4
7
  export const bestRoute: BestRouteType = {
5
8
  from: { blockchain: 'BSC', symbol: 'BNB', address: null },
@@ -14,10 +17,12 @@ export const bestRoute: BestRouteType = {
14
17
  swapperId: 'AnySwap Aggregator',
15
18
  swapperType: 'AGGREGATOR',
16
19
  swapperLogo: 'https://api.rango.exchange/swappers/multichain.png',
20
+
17
21
  from: {
18
22
  symbol: 'BNB',
19
23
  logo: 'https://api.rango.exchange/i/Y3v1KW',
20
24
  blockchainLogo: 'https://api.rango.exchange/blockchains/binance.svg',
25
+
21
26
  address: null,
22
27
  blockchain: 'BSC',
23
28
  decimals: 18,
@@ -28,6 +33,7 @@ export const bestRoute: BestRouteType = {
28
33
  logo: 'https://api.rango.exchange/i/j9xgdC',
29
34
  blockchainLogo:
30
35
  'https://api.rango.exchange/blockchains/avax_cchain.svg',
36
+
31
37
  address: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
32
38
  blockchain: 'AVAX_CCHAIN',
33
39
  decimals: 18,
@@ -93,8 +99,8 @@ export const bestRoute: BestRouteType = {
93
99
  symbol: 'WETH.E',
94
100
  address: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
95
101
  },
96
- expenseType: 'DECREASE_FROM_OUTPUT',
97
102
  name: 'Network Fee',
103
+ expenseType: 'DECREASE_FROM_OUTPUT',
98
104
  amount:
99
105
  '0.00018619291780292721387591870688029381530892436558133340440690517425537109375',
100
106
  },
@@ -141,6 +147,77 @@ export const bestRoute: BestRouteType = {
141
147
  validationStatus: null,
142
148
  missingBlockchains: [],
143
149
  diagnosisMessages: [],
144
- processingLimitReached: false,
145
150
  walletNotSupportingFromBlockchain: false,
151
+ processingLimitReached: false,
146
152
  };
153
+
154
+ export const wallets: SelectableWallet[] = [
155
+ {
156
+ walletType: WalletType.META_MASK,
157
+ address: '0x5423e28219d6d568dcf62a8134d623e6f4a1c2df',
158
+ image: 'https://app.rango.exchange/wallets/metamask.svg',
159
+ chain: 'BSC',
160
+ selected: false,
161
+ },
162
+ {
163
+ walletType: WalletType.OKX,
164
+ address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
165
+ image: 'https://app.rango.exchange/wallets/okx.png',
166
+ chain: 'BSC',
167
+ selected: false,
168
+ },
169
+
170
+ {
171
+ walletType: WalletType.KEPLR,
172
+ address: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
173
+ image: 'https://app.rango.exchange/wallets/keplr.png',
174
+ chain: 'OSMOSIS',
175
+ selected: false,
176
+ },
177
+ ];
178
+
179
+ export const exampleFor5Wallets: SelectableWallet[] = [
180
+ {
181
+ walletType: WalletType.META_MASK,
182
+ address: '0x5423e28219d6d568dcf62a8134d623e6f4a1c2df',
183
+ image: 'https://app.rango.exchange/wallets/metamask.svg',
184
+ selected: false,
185
+ chain: 'BSC',
186
+ },
187
+ {
188
+ walletType: WalletType.OKX,
189
+ address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
190
+ image: 'https://app.rango.exchange/wallets/okx.png',
191
+ selected: false,
192
+ chain: 'BSC',
193
+ },
194
+ {
195
+ walletType: WalletType.EXODUS,
196
+ address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
197
+ image: 'https://app.rango.exchange/wallets/exodus.png',
198
+ selected: false,
199
+ chain: 'BSC',
200
+ },
201
+ {
202
+ walletType: WalletType.MATH,
203
+ address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
204
+ image: 'https://app.rango.exchange/wallets/math-wallet.png',
205
+ selected: false,
206
+ chain: 'BSC',
207
+ },
208
+ {
209
+ walletType: WalletType.CLOVER,
210
+ address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
211
+ image: 'https://app.rango.exchange/wallets/clover.jpeg',
212
+ selected: false,
213
+ chain: 'BSC',
214
+ },
215
+
216
+ {
217
+ walletType: WalletType.KEPLR,
218
+ address: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
219
+ image: 'https://app.rango.exchange/wallets/keplr.png',
220
+ selected: false,
221
+ chain: 'OSMOSIS',
222
+ },
223
+ ];
@@ -1,20 +1,21 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
+ import { Divider } from '../../components';
2
3
  import { SecondaryPage } from '../../components/SecondaryPage';
3
4
  import { SwapDetail } from '../../components/SwapDetail';
4
5
  import { Typography } from '../../components/Typography';
5
6
  import { containsText } from '../../helper';
6
- import { groupingOfSwaps } from '../../helper/swaps';
7
7
  import { styled } from '../../theme';
8
8
  import { PendingSwap } from './types';
9
+ import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
9
10
 
10
- const BodyError = styled('div', {
11
- height: '100%',
12
- display: 'flex',
13
- justifyContent: 'center',
14
- alignItems: 'center',
11
+ const Group = styled('div', {
12
+ '.group-title': {
13
+ textTransform: 'uppercase',
14
+ },
15
15
  });
16
- const ErrorMsg = styled(Typography, {
17
- color: '$error',
16
+
17
+ const Container = styled('div', {
18
+ overflowY: 'auto',
18
19
  });
19
20
  const filteredHistory = (
20
21
  list: PendingSwap[],
@@ -32,39 +33,50 @@ const filteredHistory = (
32
33
  );
33
34
  });
34
35
  };
35
- const Group = styled('div', {
36
- marginBottom: '$24',
37
- paddingRight: '$8',
38
- maxHeight: '600px',
39
- });
40
- const GroupTitle = styled(Typography, {
41
- color: '$neutrals500',
42
- });
43
36
 
37
+ export type GroupBy = (list: PendingSwap[]) => {
38
+ title: string;
39
+ swaps: PendingSwap[];
40
+ }[];
44
41
  export interface PropTypes {
45
42
  list: PendingSwap[];
46
43
  onBack: () => void;
47
44
  onSwapClick: (requestId: string) => void;
45
+ groupBy?: GroupBy;
48
46
  }
49
47
  const SwapsGroup = (props: Omit<PropTypes, 'onBack'>) => {
50
- const { list, onSwapClick } = props;
51
- const swapsInGroup = groupingOfSwaps(list);
48
+ const { list, onSwapClick, groupBy } = props;
49
+ const groups = groupBy ? groupBy(list) : [{ title: 'History', swaps: list }];
52
50
 
53
51
  return (
54
52
  <>
55
- {swapsInGroup.map((group, index) => (
56
- <Group key={index}>
57
- <GroupTitle variant="body2">{group.title}</GroupTitle>
58
- {group.swaps.map((swap: PendingSwap, index: number) => (
59
- <SwapDetail
60
- key={index}
61
- swap={swap}
62
- status={swap.status}
63
- onClick={onSwapClick}
64
- />
65
- ))}
66
- </Group>
67
- ))}
53
+ {groups
54
+ .filter((group) => group.swaps.length > 0)
55
+ .map((group, index) => (
56
+ <>
57
+ <Group key={index}>
58
+ <Typography
59
+ variant="body2"
60
+ color="neutrals600"
61
+ className="group-title"
62
+ >
63
+ {group.title}
64
+ </Typography>
65
+ {group.swaps.map((swap: PendingSwap, index: number) => (
66
+ <>
67
+ <SwapDetail
68
+ key={index}
69
+ swap={swap}
70
+ status={swap.status}
71
+ onClick={onSwapClick}
72
+ />
73
+ <Divider size={12} />
74
+ </>
75
+ ))}
76
+ </Group>
77
+ <Divider size={24} />
78
+ </>
79
+ ))}
68
80
  </>
69
81
  );
70
82
  };
@@ -73,22 +85,29 @@ export function History({
73
85
  list = [],
74
86
  onBack,
75
87
  onSwapClick,
88
+ groupBy,
76
89
  }: PropsWithChildren<PropTypes>) {
77
90
  return (
78
91
  <SecondaryPage
79
92
  onBack={onBack}
80
93
  textField={true}
81
- textFieldPlaceholder="Search By Blockchain Or Token"
94
+ textFieldPlaceholder="Search By Blockchain Or Token Or Request ID"
82
95
  title="Swaps"
83
96
  >
84
97
  {(searchedFor) => {
85
98
  const filterSwaps = filteredHistory(list, searchedFor);
86
- return filterSwaps.length ? (
87
- <SwapsGroup list={filterSwaps} onSwapClick={onSwapClick} />
88
- ) : (
89
- <BodyError>
90
- <ErrorMsg variant="caption">Not Found</ErrorMsg>
91
- </BodyError>
99
+ return (
100
+ <Container>
101
+ {filterSwaps.length ? (
102
+ <SwapsGroup
103
+ list={filterSwaps}
104
+ onSwapClick={onSwapClick}
105
+ groupBy={groupBy}
106
+ />
107
+ ) : (
108
+ <NotFoundAlert catergory="Swap" />
109
+ )}
110
+ </Container>
92
111
  );
93
112
  }}
94
113
  </SecondaryPage>
@@ -1 +1 @@
1
- export { History } from './History';
1
+ export { History, GroupBy } from './History';
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import { RoutingResultType, TransactionType } from 'rango-sdk';
2
3
  import { PendingSwap } from './types';
3
4
 
@@ -1,20 +1,13 @@
1
1
  import {
2
2
  CosmosTransaction,
3
3
  EvmTransaction,
4
- SimulationResult,
5
4
  SolanaTransaction,
6
5
  SwapExplorerUrl,
7
6
  SwapperStatusStep,
8
7
  Transfer,
9
8
  } from 'rango-sdk';
10
- import {
11
- MessageSeverity,
12
- PendingSwapNetworkStatus,
13
- StepStatus,
14
- SwapSavedSettings,
15
- SwapStatus,
16
- WalletTypeAndAddress,
17
- } from '../../types/swaps';
9
+ import { PendingSwapNetworkStatus, StepStatus } from '../../types/swaps';
10
+ export { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
18
11
 
19
12
  export type PendingSwapStep = {
20
13
  id: number;
@@ -52,24 +45,3 @@ export type PendingSwapStep = {
52
45
  diagnosisUrl: string | null;
53
46
  internalSteps: SwapperStatusStep[] | null;
54
47
  };
55
-
56
- export type PendingSwap = {
57
- creationTime: string;
58
- finishTime: string | null;
59
- requestId: string;
60
- inputAmount: string;
61
- status: SwapStatus;
62
- isPaused: boolean;
63
- extraMessage: string | null;
64
- extraMessageSeverity: MessageSeverity | null;
65
- extraMessageErrorCode: string | null;
66
- extraMessageDetail: string | null | undefined;
67
- networkStatusExtraMessage: string | null;
68
- networkStatusExtraMessageDetail: string | null;
69
- lastNotificationTime: string | null;
70
- wallets: { [p: string]: WalletTypeAndAddress };
71
- settings: SwapSavedSettings;
72
- steps: PendingSwapStep[];
73
- simulationResult: SimulationResult;
74
- validateBalanceOrFee: boolean;
75
- };