@rango-dev/ui 0.1.10-next.92 → 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 (93) 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/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  14. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  15. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  16. package/dist/components/Settings/Settings.d.ts +2 -1
  17. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  18. package/dist/components/SwapDetail/Token.d.ts +16 -0
  19. package/dist/components/TokenSelector/TokenSelector.d.ts +3 -0
  20. package/dist/components/index.d.ts +2 -0
  21. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +10 -17
  22. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  23. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  24. package/dist/containers/History/History.d.ts +6 -1
  25. package/dist/containers/History/index.d.ts +1 -1
  26. package/dist/containers/History/types.d.ts +3 -24
  27. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  28. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  29. package/dist/containers/index.d.ts +0 -1
  30. package/dist/helper/index.d.ts +1 -0
  31. package/dist/types/meta.d.ts +1 -0
  32. package/dist/ui.cjs.development.js +1062 -838
  33. package/dist/ui.cjs.development.js.map +1 -1
  34. package/dist/ui.cjs.production.min.js +1 -1
  35. package/dist/ui.cjs.production.min.js.map +1 -1
  36. package/dist/ui.esm.js +1061 -840
  37. package/dist/ui.esm.js.map +1 -1
  38. package/package.json +3 -2
  39. package/src/components/Alert/Alert.tsx +33 -12
  40. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  41. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  42. package/src/components/Alert/index.ts +1 -0
  43. package/src/components/BestRoute/mock.ts +10 -0
  44. package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -19
  45. package/src/components/Button/Button.tsx +2 -1
  46. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  47. package/src/components/Divider/Divider.tsx +41 -0
  48. package/src/components/Divider/index.ts +1 -0
  49. package/src/components/Header/Header.tsx +39 -0
  50. package/src/components/Header/index.ts +1 -0
  51. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  52. package/src/components/Icon/index.ts +1 -0
  53. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +72 -22
  54. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
  55. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  56. package/src/components/SelectableWalletList/SelectableWalletList.tsx +5 -0
  57. package/src/components/SelectableWalletList/mock.ts +4 -3
  58. package/src/components/Settings/Settings.tsx +30 -11
  59. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  60. package/src/components/StepDetail/StepDetail.tsx +1 -0
  61. package/src/components/SwapContainer/SwapContainer.tsx +21 -16
  62. package/src/components/SwapDetail/SwapDetail.tsx +77 -115
  63. package/src/components/SwapDetail/Token.tsx +68 -0
  64. package/src/components/SwapDetail/mock.ts +1 -0
  65. package/src/components/TextField/TextField.tsx +1 -0
  66. package/src/components/TokenList/TokenItem.tsx +4 -1
  67. package/src/components/TokenList/TokenList.tsx +16 -18
  68. package/src/components/TokenSelector/TokenSelector.tsx +47 -10
  69. package/src/components/Wallet/Wallet.tsx +1 -1
  70. package/src/components/index.ts +2 -0
  71. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  72. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +103 -117
  73. package/src/containers/ConfirmSwap/mock.ts +79 -2
  74. package/src/containers/History/History.tsx +57 -38
  75. package/src/containers/History/index.ts +1 -1
  76. package/src/containers/History/mock.ts +1 -0
  77. package/src/containers/History/types.tsx +2 -30
  78. package/src/containers/SwapHistory/SwapHistory.tsx +309 -165
  79. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  80. package/src/containers/SwapHistory/mock.ts +1 -0
  81. package/src/containers/index.ts +0 -1
  82. package/src/helper/index.ts +14 -0
  83. package/src/types/meta.ts +2 -0
  84. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
  85. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  86. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  87. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  88. package/dist/helper/swaps.d.ts +0 -5
  89. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  90. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
  91. package/src/containers/ConfirmWallets/index.ts +0 -1
  92. package/src/containers/ConfirmWallets/mock.ts +0 -222
  93. package/src/helper/swaps.ts +0 -23
@@ -1,16 +0,0 @@
1
- import React, { PropsWithChildren, ReactNode } from 'react';
2
- import { SelectableWallet } from '../../types';
3
- export interface PropTypes {
4
- onBack: () => void;
5
- onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
6
- confirmDisabled?: boolean;
7
- loading?: boolean;
8
- requiredWallets: string[];
9
- selectableWallets: SelectableWallet[];
10
- onChange: (w: SelectableWallet) => void;
11
- isExperimentalChain?: (wallet: string) => boolean;
12
- handleConnectChain?: (wallet: string) => void;
13
- previewInputs?: ReactNode;
14
- previewRoutes?: ReactNode;
15
- }
16
- export declare function ConfirmWallets(props: PropsWithChildren<PropTypes>): JSX.Element;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { PropTypes } from './ConfirmWallets';
3
- declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, React.PropsWithChildren<PropTypes>>;
4
- export default _default;
5
- export declare const Main: (props: PropTypes) => JSX.Element;
6
- export declare const With5Wallets: (props: PropTypes) => JSX.Element;
@@ -1 +0,0 @@
1
- export { ConfirmWallets } from './ConfirmWallets';
@@ -1,5 +0,0 @@
1
- import { BestRouteType } from '../../types/swaps';
2
- import { SelectableWallet } from './types';
3
- export declare const bestRoute: BestRouteType;
4
- export declare const wallets: SelectableWallet[];
5
- export declare const exampleFor5Wallets: SelectableWallet[];
@@ -1,5 +0,0 @@
1
- import { PendingSwap } from '../containers/History/types';
2
- export declare function groupingOfSwaps(list: PendingSwap[]): {
3
- title: string;
4
- swaps: PendingSwap[];
5
- }[];
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
- import { ConfirmWallets, PropTypes } from './ConfirmWallets';
4
- import { bestRoute, exampleFor5Wallets, wallets } from './mock';
5
-
6
- export default {
7
- title: 'Containers/ConfirmWallets',
8
- component: ConfirmWallets,
9
- argTypes: {
10
- requiredWallets: {
11
- defaultValue: ['BSC', 'OSMOSIS'],
12
- },
13
- },
14
- } as ComponentMeta<typeof ConfirmWallets>;
15
-
16
- export const Main = (props: PropTypes) => (
17
- <ConfirmWallets {...props} swap={bestRoute} selectableWallets={wallets} />
18
- );
19
-
20
- export const With5Wallets = (props: PropTypes) => (
21
- <ConfirmWallets
22
- {...props}
23
- swap={bestRoute}
24
- selectableWallets={exampleFor5Wallets}
25
- />
26
- );
@@ -1,143 +0,0 @@
1
- import React, { PropsWithChildren, ReactNode } from 'react';
2
- import { Alert, Spacer } from '../../components';
3
- import { Button } from '../../components/Button';
4
- import { SecondaryPage } from '../../components/SecondaryPage/SecondaryPage';
5
- import { SelectableWalletList } from '../../components/SelectableWalletList';
6
- import { Typography } from '../../components/Typography';
7
- import { styled } from '../../theme';
8
- import { SelectableWallet } from '../../types';
9
-
10
- const Section = styled('div', {
11
- paddingBottom: '$32',
12
- marginBottom: '$32',
13
- borderBottom: '1px solid $neutrals400',
14
- });
15
-
16
- const Footer = styled('div', {
17
- display: 'flex',
18
- alignItems: 'center',
19
- });
20
-
21
- const AlertContainer = styled('div', {
22
- padding: '$16 0',
23
- });
24
-
25
- const ConfirmButton = styled(Button, {
26
- marginTop: '$16',
27
- });
28
-
29
- const Container = styled('div', {
30
- paddingBottom: '$24',
31
-
32
- '.title': {
33
- paddingBottom: '$8',
34
- display: 'flex',
35
- alignItems: 'center',
36
- },
37
- '.num': {
38
- backgroundColor: '$neutrals300',
39
- display: 'inline-flex',
40
- width: '24px',
41
- height: '24px',
42
- color: '$neutrals800',
43
- borderRadius: '50%',
44
- fontSize: '$14',
45
- border: '1px solid $neutrals400',
46
- justifyContent: 'center',
47
- alignItems: 'center',
48
- },
49
- });
50
-
51
- export interface PropTypes {
52
- onBack: () => void;
53
- onConfirm?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
54
- confirmDisabled?: boolean;
55
- loading?: boolean;
56
- requiredWallets: string[];
57
- selectableWallets: SelectableWallet[];
58
- onChange: (w: SelectableWallet) => void;
59
- isExperimentalChain?: (wallet: string) => boolean;
60
- handleConnectChain?: (wallet: string) => void;
61
- previewInputs?: ReactNode;
62
- previewRoutes?: ReactNode;
63
- }
64
- export function ConfirmWallets(props: PropsWithChildren<PropTypes>) {
65
- const {
66
- onBack,
67
- loading,
68
- onConfirm,
69
- requiredWallets,
70
- selectableWallets,
71
- onChange,
72
- confirmDisabled,
73
- isExperimentalChain,
74
- handleConnectChain,
75
- } = props;
76
-
77
- return (
78
- <SecondaryPage
79
- textField={false}
80
- title="Confirm Swap"
81
- onBack={onBack}
82
- Footer={
83
- <Footer>
84
- <ConfirmButton
85
- fullWidth
86
- loading={loading}
87
- type="primary"
88
- variant="contained"
89
- onClick={onConfirm}
90
- disabled={confirmDisabled}
91
- >
92
- Confirm Swap
93
- </ConfirmButton>
94
- </Footer>
95
- }
96
- >
97
- {props.previewInputs || props.previewRoutes ? (
98
- <Section>
99
- {props.previewInputs}
100
- {!!props.previewRoutes ? (
101
- <Spacer size={16} direction="vertical" />
102
- ) : null}
103
- {props.previewRoutes}
104
- </Section>
105
- ) : null}
106
-
107
- {requiredWallets.map((wallet, index) => {
108
- const list = selectableWallets.filter((w) => wallet === w.chain);
109
- return (
110
- <Container key={index}>
111
- <div className="title">
112
- <div className="num">{index + 1}</div>
113
- <Spacer size={8} />
114
- <Typography variant="body2">Your {wallet} Wallet</Typography>
115
- </div>
116
- {list.length === 0 && (
117
- <>
118
- <AlertContainer>
119
- <Alert type="error">
120
- You need to connect a compatible wallet with {wallet}
121
- </Alert>
122
- </AlertContainer>
123
- {isExperimentalChain?.(wallet) && (
124
- <Button
125
- variant="contained"
126
- type="primary"
127
- align="grow"
128
- onClick={() => handleConnectChain?.(wallet)}
129
- >
130
- {`Add ${wallet} chain to Cosmos wallets`}
131
- </Button>
132
- )}
133
- </>
134
- )}
135
- {list.length != 0 && (
136
- <SelectableWalletList list={list} onChange={onChange} />
137
- )}
138
- </Container>
139
- );
140
- })}
141
- </SecondaryPage>
142
- );
143
- }
@@ -1 +0,0 @@
1
- export { ConfirmWallets } from './ConfirmWallets';
@@ -1,222 +0,0 @@
1
- import { WalletType } from '@rango-dev/wallets-shared';
2
- import { RoutingResultType } from 'rango-sdk';
3
- import { BestRouteType } from '../../types/swaps';
4
- import { SelectableWallet } from './types';
5
-
6
- export const bestRoute: BestRouteType = {
7
- from: { blockchain: 'BSC', symbol: 'BNB', address: null },
8
- to: { blockchain: 'AVAX_CCHAIN', symbol: 'AVAX', address: null },
9
- requestAmount: '0.3',
10
- requestId: '228529e3-27d7-4fa9-ab84-bb2b90eade6f',
11
- result: {
12
- resultType: RoutingResultType.OK,
13
- outputAmount: '5.685715974132648891',
14
- swaps: [
15
- {
16
- swapperId: 'AnySwap Aggregator',
17
- swapperType: 'AGGREGATOR',
18
- swapperLogo: 'https://api.rango.exchange/swappers/multichain.png',
19
-
20
- from: {
21
- symbol: 'BNB',
22
- logo: 'https://api.rango.exchange/i/Y3v1KW',
23
- blockchainLogo: 'https://api.rango.exchange/blockchains/binance.svg',
24
-
25
- address: null,
26
- blockchain: 'BSC',
27
- decimals: 18,
28
- usdPrice: 279.2738558274085,
29
- },
30
- to: {
31
- symbol: 'WETH.E',
32
- logo: 'https://api.rango.exchange/i/j9xgdC',
33
- blockchainLogo:
34
- 'https://api.rango.exchange/blockchains/avax_cchain.svg',
35
-
36
- address: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
37
- blockchain: 'AVAX_CCHAIN',
38
- decimals: 18,
39
- usdPrice: 1329.24,
40
- },
41
- fromAmount: '0.300000000000000000',
42
- fromAmountPrecision: null,
43
- fromAmountMinValue: '0.047579322466294684272760',
44
- fromAmountMaxValue: '79302.26195302606417382090',
45
- fromAmountRestrictionType: 'INCLUSIVE',
46
- toAmount: '0.062064305934309070',
47
- fee: [
48
- {
49
- asset: { blockchain: 'BSC', symbol: 'BNB', address: null },
50
- expenseType: 'FROM_SOURCE_WALLET',
51
- amount: '0.001388002000000000',
52
- name: 'Network Fee',
53
- },
54
- ],
55
- estimatedTimeInSeconds: 300,
56
- swapChainType: 'INTRA_CHAIN',
57
- routes: null,
58
- recommendedSlippage: null,
59
- timeStat: { min: 162, avg: 260, max: 467 },
60
- includesDestinationTx: false,
61
- maxRequiredSign: 1,
62
- warnings: [],
63
- },
64
- {
65
- swapperId: 'PangolinSwap',
66
- swapperLogo: 'https://api.rango.exchange/swappers/pangolin.png',
67
- swapperType: 'DEX',
68
- from: {
69
- symbol: 'WETH.E',
70
- logo: 'https://api.rango.exchange/i/j9xgdC',
71
- address: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
72
- blockchain: 'AVAX_CCHAIN',
73
- decimals: 18,
74
- usdPrice: 1329.24,
75
- blockchainLogo:
76
- 'https://api.rango.exchange/blockchains/avax_cchain.svg',
77
- },
78
- to: {
79
- symbol: 'AVAX',
80
- logo: 'https://api.rango.exchange/i/kX4edQ',
81
- address: null,
82
- blockchain: 'AVAX_CCHAIN',
83
- decimals: 18,
84
- usdPrice: 12.5,
85
- blockchainLogo:
86
- 'https://api.rango.exchange/blockchains/avax_cchain.svg',
87
- },
88
- fromAmount: '0.062064305934309070',
89
- fromAmountPrecision: null,
90
- fromAmountMinValue: null,
91
- fromAmountMaxValue: null,
92
- fromAmountRestrictionType: 'EXCLUSIVE',
93
- toAmount: '5.685715974132648891',
94
- fee: [
95
- {
96
- asset: {
97
- blockchain: 'AVAX_CCHAIN',
98
- symbol: 'WETH.E',
99
- address: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
100
- },
101
- name: 'Network Fee',
102
- expenseType: 'DECREASE_FROM_OUTPUT',
103
- amount:
104
- '0.00018619291780292721387591870688029381530892436558133340440690517425537109375',
105
- },
106
- {
107
- asset: { blockchain: 'AVAX_CCHAIN', symbol: 'AVAX', address: null },
108
- expenseType: 'FROM_SOURCE_WALLET',
109
- amount: '0.005370022532678750',
110
- name: 'Network Fee',
111
- },
112
- ],
113
- estimatedTimeInSeconds: 45,
114
- swapChainType: 'INTER_CHAIN',
115
- routes: [
116
- {
117
- nodes: [
118
- {
119
- nodes: [
120
- {
121
- marketName: 'PangolinSwap',
122
- marketId: 'PangolinSwap',
123
- percent: 1.0,
124
- },
125
- ],
126
- from: 'WETH.e',
127
- fromLogo: '',
128
- fromAddress: '0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab',
129
- fromBlockchain: 'AVAX_CCHAIN',
130
- to: 'WAVAX',
131
- toLogo: '',
132
- toAddress: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7',
133
- toBlockchain: 'AVAX_CCHAIN',
134
- },
135
- ],
136
- },
137
- ],
138
- recommendedSlippage: null,
139
- timeStat: { min: 6, avg: 39, max: 317 },
140
- includesDestinationTx: false,
141
- maxRequiredSign: 1,
142
- warnings: [],
143
- },
144
- ],
145
- },
146
- validationStatus: null,
147
- missingBlockchains: [],
148
- diagnosisMessages: [],
149
- walletNotSupportingFromBlockchain: false,
150
- processingLimitReached: false,
151
- };
152
-
153
- export const wallets: SelectableWallet[] = [
154
- {
155
- walletType: WalletType.META_MASK,
156
- address: '0x5423e28219d6d568dcf62a8134d623e6f4a1c2df',
157
- image: 'https://app.rango.exchange/wallets/metamask.svg',
158
- chain: 'BSC',
159
- selected: false,
160
- },
161
- {
162
- walletType: WalletType.OKX,
163
- address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
164
- image: 'https://app.rango.exchange/wallets/okx.png',
165
- chain: 'BSC',
166
- selected: false,
167
- },
168
-
169
- {
170
- walletType: WalletType.KEPLR,
171
- address: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
172
- image: 'https://app.rango.exchange/wallets/keplr.png',
173
- chain: 'OSMOSIS',
174
- selected: false,
175
- },
176
- ];
177
-
178
- export const exampleFor5Wallets: SelectableWallet[] = [
179
- {
180
- walletType: WalletType.META_MASK,
181
- address: '0x5423e28219d6d568dcf62a8134d623e6f4a1c2df',
182
- image: 'https://app.rango.exchange/wallets/metamask.svg',
183
- selected: false,
184
- chain: 'BSC',
185
- },
186
- {
187
- walletType: WalletType.OKX,
188
- address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
189
- image: 'https://app.rango.exchange/wallets/okx.png',
190
- selected: false,
191
- chain: 'BSC',
192
- },
193
- {
194
- walletType: WalletType.EXODUS,
195
- address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
196
- image: 'https://app.rango.exchange/wallets/exodus.png',
197
- selected: false,
198
- chain: 'BSC',
199
- },
200
- {
201
- walletType: WalletType.MATH,
202
- address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
203
- image: 'https://app.rango.exchange/wallets/math-wallet.png',
204
- selected: false,
205
- chain: 'BSC',
206
- },
207
- {
208
- walletType: WalletType.CLOVER,
209
- address: '0x2702d89c1c8658b49c45dd460deebcc45faec03c',
210
- image: 'https://app.rango.exchange/wallets/clover.jpeg',
211
- selected: false,
212
- chain: 'BSC',
213
- },
214
-
215
- {
216
- walletType: WalletType.KEPLR,
217
- address: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
218
- image: 'https://app.rango.exchange/wallets/keplr.png',
219
- selected: false,
220
- chain: 'OSMOSIS',
221
- },
222
- ];
@@ -1,23 +0,0 @@
1
- import { PendingSwap } from '../containers/History/types';
2
-
3
- export function groupingOfSwaps(list: PendingSwap[]) {
4
- return list.reduce(
5
- (acc: Array<{ title: string; swaps: PendingSwap[] }>, swap) => {
6
- const categoryIndex = acc.findIndex(
7
- (item) =>
8
- (swap.status === 'running' && item.title == 'Active Swaps') ||
9
- (swap.status !== 'running' && item.title == 'Recent Swaps')
10
- );
11
- if (categoryIndex > -1) {
12
- acc[categoryIndex].swaps.push(swap);
13
- } else {
14
- acc.push({
15
- title: swap.status === 'running' ? 'Active Swaps' : 'Recent Swaps',
16
- swaps: [swap],
17
- });
18
- }
19
- return acc;
20
- },
21
- []
22
- );
23
- }