@rango-dev/ui 0.1.10-next.92 → 0.1.11-next.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 (112) hide show
  1. package/README.md +1 -181
  2. package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
  3. package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
  4. package/dist/components/Alert/index.d.ts +1 -0
  5. package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
  6. package/dist/components/Button/Button.d.ts +1 -1
  7. package/dist/components/Divider/Divider.d.ts +6 -0
  8. package/dist/components/Divider/index.d.ts +1 -0
  9. package/dist/components/Header/Header.d.ts +9 -0
  10. package/dist/components/Header/index.d.ts +1 -0
  11. package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
  12. package/dist/components/Icon/index.d.ts +1 -0
  13. package/dist/components/Icon/types.d.ts +1 -0
  14. package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  15. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  16. package/dist/components/Modal/Modal.d.ts +0 -1
  17. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  18. package/dist/components/Settings/Settings.d.ts +2 -1
  19. package/dist/components/StepDetail/StepDetail.d.ts +3 -1
  20. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  21. package/dist/components/SwapDetail/Token.d.ts +17 -0
  22. package/dist/components/TextField/TextField.d.ts +1 -1
  23. package/dist/components/TokenList/TokenList.d.ts +2 -2
  24. package/dist/components/TokenSelector/TokenSelector.d.ts +4 -3
  25. package/dist/components/Typography/Typography.d.ts +1 -1
  26. package/dist/components/common/Image.d.ts +6 -0
  27. package/dist/components/common/index.d.ts +1 -0
  28. package/dist/components/index.d.ts +2 -0
  29. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +14 -19
  30. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  31. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  32. package/dist/containers/History/History.d.ts +5 -7
  33. package/dist/containers/History/SwapsGroup.d.ts +13 -0
  34. package/dist/containers/History/index.d.ts +1 -0
  35. package/dist/containers/History/types.d.ts +3 -24
  36. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  37. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  38. package/dist/containers/index.d.ts +0 -1
  39. package/dist/helper/index.d.ts +3 -1
  40. package/dist/types/meta.d.ts +1 -0
  41. package/dist/ui.cjs.development.js +1137 -837
  42. package/dist/ui.cjs.development.js.map +1 -1
  43. package/dist/ui.cjs.production.min.js +1 -1
  44. package/dist/ui.cjs.production.min.js.map +1 -1
  45. package/dist/ui.esm.js +1134 -839
  46. package/dist/ui.esm.js.map +1 -1
  47. package/package.json +3 -2
  48. package/src/components/Alert/Alert.tsx +33 -12
  49. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  50. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  51. package/src/components/Alert/index.ts +1 -0
  52. package/src/components/BestRoute/BestRoute.tsx +2 -5
  53. package/src/components/BestRoute/mock.ts +10 -0
  54. package/src/components/BlockchainSelector/BlockchainSelector.tsx +31 -34
  55. package/src/components/BlockchainsList/BlockchainsList.tsx +8 -6
  56. package/src/components/Button/Button.tsx +2 -1
  57. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  58. package/src/components/Divider/Divider.tsx +41 -0
  59. package/src/components/Divider/index.ts +1 -0
  60. package/src/components/Drawer/Drawer.tsx +1 -1
  61. package/src/components/Header/Header.tsx +39 -0
  62. package/src/components/Header/index.ts +1 -0
  63. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  64. package/src/components/Icon/common.ts +10 -0
  65. package/src/components/Icon/index.ts +1 -0
  66. package/src/components/Icon/types.tsx +1 -0
  67. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +81 -27
  68. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
  69. package/src/components/Modal/Modal.tsx +1 -6
  70. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  71. package/src/components/SelectableWalletList/SelectableWalletList.tsx +7 -1
  72. package/src/components/SelectableWalletList/mock.ts +4 -3
  73. package/src/components/Settings/Settings.tsx +34 -14
  74. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  75. package/src/components/StepDetail/StepDetail.tsx +46 -12
  76. package/src/components/SwapContainer/SwapContainer.tsx +21 -17
  77. package/src/components/SwapDetail/SwapDetail.tsx +71 -117
  78. package/src/components/SwapDetail/Token.tsx +73 -0
  79. package/src/components/SwapDetail/mock.ts +1 -0
  80. package/src/components/TextField/TextField.tsx +9 -0
  81. package/src/components/TokenList/TokenItem.tsx +12 -6
  82. package/src/components/TokenList/TokenList.tsx +18 -21
  83. package/src/components/TokenSelector/TokenSelector.tsx +38 -25
  84. package/src/components/Typography/Typography.tsx +8 -0
  85. package/src/components/Wallet/Wallet.tsx +9 -6
  86. package/src/components/common/Image.tsx +27 -0
  87. package/src/components/common/index.ts +1 -0
  88. package/src/components/index.ts +2 -0
  89. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  90. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +111 -125
  91. package/src/containers/ConfirmSwap/mock.ts +79 -2
  92. package/src/containers/History/History.tsx +33 -57
  93. package/src/containers/History/SwapsGroup.tsx +59 -0
  94. package/src/containers/History/index.ts +1 -0
  95. package/src/containers/History/mock.ts +1 -0
  96. package/src/containers/History/types.tsx +2 -30
  97. package/src/containers/SwapHistory/SwapHistory.tsx +306 -177
  98. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  99. package/src/containers/SwapHistory/mock.ts +1 -0
  100. package/src/containers/index.ts +0 -1
  101. package/src/helper/index.ts +31 -2
  102. package/src/types/meta.ts +2 -0
  103. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
  104. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  105. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  106. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  107. package/dist/helper/swaps.d.ts +0 -5
  108. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  109. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
  110. package/src/containers/ConfirmWallets/index.ts +0 -1
  111. package/src/containers/ConfirmWallets/mock.ts +0 -222
  112. package/src/helper/swaps.ts +0 -23
@@ -1,125 +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
+
57
+ type Message = string | ReactNode
58
+
81
59
  export interface PropTypes {
82
- bestRoute: BestRouteWithFee | null;
83
- onRefresh?: React.MouseEventHandler<SVGElement>;
84
- confirmButtonTitle: string;
85
- confirmButtonDisabled: boolean;
86
60
  onBack: () => void;
87
61
  onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
62
+ confirmDisabled?: boolean;
88
63
  loading?: boolean;
89
- errors?: ReactNode[];
90
- warnings?: ReactNode[];
64
+ requiredWallets: string[];
65
+ selectableWallets: SelectableWallet[];
66
+ onChange: (w: SelectableWallet) => void;
67
+ isExperimentalChain?: (wallet: string) => boolean;
68
+ handleConnectChain?: (wallet: string) => void;
69
+ previewInputs?: ReactNode;
70
+ previewRoutes?: ReactNode;
71
+ confirmButtonTitle: string;
72
+ errors?: Message[];
73
+ warnings?: Message[];
91
74
  extraMessages?: ReactNode;
92
75
  }
93
76
  export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
94
77
  const {
95
- bestRoute,
96
78
  onBack,
97
- onConfirm,
98
79
  loading,
80
+ onConfirm,
81
+ requiredWallets,
82
+ selectableWallets,
83
+ onChange,
84
+ confirmDisabled,
85
+ isExperimentalChain,
86
+ handleConnectChain,
87
+ confirmButtonTitle,
99
88
  errors,
100
89
  warnings,
101
90
  extraMessages,
102
- confirmButtonTitle,
103
- confirmButtonDisabled,
104
91
  } = props;
105
92
 
106
93
  return (
107
94
  <SecondaryPage
108
95
  textField={false}
109
- title="Swap"
96
+ title="Confirm Swap"
110
97
  onBack={onBack}
111
98
  Footer={
112
99
  <Footer>
113
- <Button
114
- type="primary"
100
+ <ConfirmButton
115
101
  fullWidth
116
102
  loading={loading}
103
+ type="primary"
117
104
  variant="contained"
118
105
  onClick={onConfirm}
119
- disabled={confirmButtonDisabled}
106
+ disabled={confirmDisabled}
120
107
  >
121
108
  {confirmButtonTitle}
122
- </Button>
109
+ </ConfirmButton>
123
110
  </Footer>
124
111
  }
125
112
  >
@@ -130,64 +117,63 @@ export function ConfirmSwap(props: PropsWithChildren<PropTypes>) {
130
117
  {errors?.map((error, index) => (
131
118
  <>
132
119
  <Spacer direction="vertical" />
133
- <Alert type="error" key={index}>
134
- {error}
135
- </Alert>
120
+ <Alert type="error" key={index}
121
+ {...(typeof error === 'string') ? {title: error} : {children: error} }/>
136
122
  </>
137
123
  ))}
138
124
  {warnings?.map((warning, index) => (
139
125
  <>
140
126
  <Spacer direction="vertical" />
141
- <Alert type="warning" key={index}>
142
- {warning}
143
- </Alert>
127
+ <Alert type="warning" key={index}
128
+ {...(typeof warning === 'string') ? {title: warning} : {children: warning} }/>
144
129
  </>
145
130
  ))}
146
131
  </Alerts>
147
132
  </div>
148
- <BestRouteContainer>
149
- {bestRoute?.result?.swaps.map((swap, index) => (
150
- <Fragment key={index}>
151
- {index === 0 && (
152
- <RelativeContainer>
153
- <StepDetail
154
- logo={swap.from.logo}
155
- symbol={swap.from.symbol}
156
- chainLogo={swap.from.blockchainLogo}
157
- blockchain={swap.from.blockchain}
158
- amount={swap.fromAmount}
159
- />
160
- <Dot />
161
- </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} />
162
173
  )}
163
- <Line />
164
- <SwapperContainer>
165
- <SwapperLogo src={swap.swapperLogo} alt={swap.swapperId} />
166
- <div>
167
- <Typography ml={4} variant="caption">
168
- {swap.swapperType} from {swap.from.symbol} to{' '}
169
- {swap.to.symbol} via {swap.swapperId}{' '}
170
- </Typography>
171
- <Fee>
172
- <GasIcon />
173
- <Typography ml={4} variant="caption">
174
- ${swap.feeInUsd} estimated gas fee
175
- </Typography>
176
- </Fee>
177
- </div>
178
- </SwapperContainer>
179
- <Line />
180
- {index + 1 === bestRoute.result?.swaps.length && <ArrowDown />}
181
- <StepDetail
182
- logo={swap.to.logo}
183
- symbol={swap.to.symbol}
184
- chainLogo={swap.to.blockchainLogo}
185
- blockchain={swap.to.blockchain}
186
- amount={swap.toAmount}
187
- />
188
- </Fragment>
189
- ))}
190
- </BestRouteContainer>
174
+ </Container>
175
+ );
176
+ })}
191
177
  </MainContainer>
192
178
  </SecondaryPage>
193
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,15 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
+ import { Spinner } from '../../components';
2
3
  import { SecondaryPage } from '../../components/SecondaryPage';
3
- import { SwapDetail } from '../../components/SwapDetail';
4
- import { Typography } from '../../components/Typography';
5
4
  import { containsText } from '../../helper';
6
- import { groupingOfSwaps } from '../../helper/swaps';
7
5
  import { styled } from '../../theme';
8
6
  import { PendingSwap } from './types';
7
+ import { NotFoundAlert } from '../../components/Alert/NotFoundAlert';
8
+ import { LoaderContainer } from '../../components/TokenSelector/TokenSelector';
9
+ import { SwapsGroup, PropTypes as SwapsGroupPropTypes } from './SwapsGroup';
9
10
 
10
- const BodyError = styled('div', {
11
- height: '100%',
12
- display: 'flex',
13
- justifyContent: 'center',
14
- alignItems: 'center',
15
- });
16
- const ErrorMsg = styled(Typography, {
17
- color: '$error',
11
+ const Container = styled('div', {
12
+ overflowY: 'auto',
18
13
  });
19
14
  const filteredHistory = (
20
15
  list: PendingSwap[],
@@ -32,63 +27,44 @@ const filteredHistory = (
32
27
  );
33
28
  });
34
29
  };
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
30
 
44
- export interface PropTypes {
45
- list: PendingSwap[];
46
- onBack: () => void;
47
- onSwapClick: (requestId: string) => void;
48
- }
49
- const SwapsGroup = (props: Omit<PropTypes, 'onBack'>) => {
50
- const { list, onSwapClick } = props;
51
- const swapsInGroup = groupingOfSwaps(list);
31
+ export type PropTypes = SwapsGroupPropTypes & { loading: boolean };
52
32
 
53
- return (
54
- <>
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
- ))}
68
- </>
69
- );
70
- };
33
+ export function History(props: PropsWithChildren<PropTypes>) {
34
+ const { list = [], onBack, onSwapClick, groupBy, loading } = props;
71
35
 
72
- export function History({
73
- list = [],
74
- onBack,
75
- onSwapClick,
76
- }: PropsWithChildren<PropTypes>) {
77
36
  return (
78
37
  <SecondaryPage
79
38
  onBack={onBack}
80
39
  textField={true}
81
- textFieldPlaceholder="Search By Blockchain Or Token"
40
+ textFieldPlaceholder="Search by Network, Token or Request ID"
82
41
  title="Swaps"
83
42
  >
84
43
  {(searchedFor) => {
85
44
  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>
45
+ return (
46
+ <>
47
+ {loading && (
48
+ <LoaderContainer>
49
+ <Spinner size={24} />
50
+ </LoaderContainer>
51
+ )}
52
+ <Container>
53
+ {!loading && (
54
+ <>
55
+ {filterSwaps.length ? (
56
+ <SwapsGroup
57
+ list={filterSwaps}
58
+ onSwapClick={onSwapClick}
59
+ groupBy={groupBy}
60
+ />
61
+ ) : (
62
+ <NotFoundAlert catergory="Swap" />
63
+ )}
64
+ </>
65
+ )}
66
+ </Container>
67
+ </>
92
68
  );
93
69
  }}
94
70
  </SecondaryPage>
@@ -0,0 +1,59 @@
1
+ import { PendingSwap } from '@rango-dev/queue-manager-rango-preset';
2
+ import React from 'react';
3
+ import { Typography, SwapDetail, Divider } from '../../components';
4
+ import { styled } from '../../theme';
5
+
6
+ const Group = styled('div', {
7
+ '.group-title': {
8
+ textTransform: 'uppercase',
9
+ },
10
+ });
11
+
12
+ export type GroupBy = (list: PendingSwap[]) => {
13
+ title: string;
14
+ swaps: PendingSwap[];
15
+ }[];
16
+
17
+ export interface PropTypes {
18
+ list: PendingSwap[];
19
+ onBack: () => void;
20
+ onSwapClick: (requestId: string) => void;
21
+ groupBy?: GroupBy;
22
+ }
23
+
24
+ export function SwapsGroup(props: Omit<PropTypes, 'onBack'>) {
25
+ const { list, onSwapClick, groupBy } = props;
26
+ const groups = groupBy ? groupBy(list) : [{ title: 'History', swaps: list }];
27
+
28
+ return (
29
+ <>
30
+ {groups
31
+ .filter((group) => group.swaps.length > 0)
32
+ .map((group, index) => (
33
+ <>
34
+ <Group key={index}>
35
+ <Typography
36
+ variant="body2"
37
+ color="neutrals600"
38
+ className="group-title"
39
+ >
40
+ {group.title}
41
+ </Typography>
42
+ {group.swaps.map((swap: PendingSwap, index: number) => (
43
+ <>
44
+ <SwapDetail
45
+ key={index}
46
+ swap={swap}
47
+ status={swap.status}
48
+ onClick={onSwapClick}
49
+ />
50
+ <Divider size={12} />
51
+ </>
52
+ ))}
53
+ </Group>
54
+ <Divider size={24} />
55
+ </>
56
+ ))}
57
+ </>
58
+ );
59
+ }
@@ -1 +1,2 @@
1
1
  export { History } from './History';
2
+ export { SwapsGroup, GroupBy } from './SwapsGroup';
@@ -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
- };