@rango-dev/ui 0.1.10-next.69
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.
- package/README.md +181 -0
- package/dist/components/Alert/Alert.d.ts +6 -0
- package/dist/components/Alert/Alert.stories.d.ts +4 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/BestRoute/BestRoute.d.ts +8 -0
- package/dist/components/BestRoute/BestRoute.stories.d.ts +8 -0
- package/dist/components/BestRoute/index.d.ts +1 -0
- package/dist/components/BestRoute/mock.d.ts +4 -0
- package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +14 -0
- package/dist/components/BlockchainSelector/BlockchainSelector.stories.d.ts +4 -0
- package/dist/components/BlockchainSelector/index.d.ts +1 -0
- package/dist/components/BlockchainsList/BlockchainsList.d.ts +7 -0
- package/dist/components/BlockchainsList/BlockchainsList.stories.d.ts +4 -0
- package/dist/components/BlockchainsList/index.d.ts +1 -0
- package/dist/components/BlockchainsList/mockData.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +17 -0
- package/dist/components/Button/Button.stories.d.ts +8 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/components/Checkbox/Checkbox.stories.d.ts +5 -0
- package/dist/components/Checkbox/index.d.ts +1 -0
- package/dist/components/Chip/Chip.d.ts +12 -0
- package/dist/components/Chip/Chip.stories.d.ts +6 -0
- package/dist/components/Chip/index.d.ts +1 -0
- package/dist/components/ConnectWalletsModal/ConnectWallets.stories.d.ts +4 -0
- package/dist/components/ConnectWalletsModal/ConnectWalletsModal.d.ts +10 -0
- package/dist/components/ConnectWalletsModal/index.d.ts +1 -0
- package/dist/components/ConnectWalletsModal/mockData.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +12 -0
- package/dist/components/Drawer/Drawer.stories.d.ts +7 -0
- package/dist/components/Drawer/index.d.ts +1 -0
- package/dist/components/Icon/AddCircleIcon.d.ts +3 -0
- package/dist/components/Icon/AddIcon.d.ts +3 -0
- package/dist/components/Icon/AddWalletIcon.d.ts +3 -0
- package/dist/components/Icon/AngleDownIcon.d.ts +3 -0
- package/dist/components/Icon/AngleLeftIcon.d.ts +3 -0
- package/dist/components/Icon/AngleRightIcon.d.ts +3 -0
- package/dist/components/Icon/AngleUpIcon.d.ts +3 -0
- package/dist/components/Icon/BagIcon.d.ts +3 -0
- package/dist/components/Icon/BanIcon.d.ts +3 -0
- package/dist/components/Icon/CheckCircleIcon.d.ts +3 -0
- package/dist/components/Icon/CheckIcon.d.ts +3 -0
- package/dist/components/Icon/CheckSquareIcon.d.ts +3 -0
- package/dist/components/Icon/CheckWalletIcon.d.ts +3 -0
- package/dist/components/Icon/CloseIcon.d.ts +1 -0
- package/dist/components/Icon/DeleteCircleIcon.d.ts +3 -0
- package/dist/components/Icon/DeleteWalletIcon.d.ts +3 -0
- package/dist/components/Icon/DownloadIcon.d.ts +3 -0
- package/dist/components/Icon/GasIcon.d.ts +3 -0
- package/dist/components/Icon/HistoryIcon.d.ts +3 -0
- package/dist/components/Icon/HorizontalSwapIcon.d.ts +3 -0
- package/dist/components/Icon/Icons.stories.d.ts +5 -0
- package/dist/components/Icon/InfoCircleIcon.d.ts +3 -0
- package/dist/components/Icon/MinusCircleIcon.d.ts +3 -0
- package/dist/components/Icon/RetryIcon.d.ts +3 -0
- package/dist/components/Icon/RetryLeftIcon.d.ts +3 -0
- package/dist/components/Icon/RetryRightIcon.d.ts +3 -0
- package/dist/components/Icon/SearchIcon.d.ts +3 -0
- package/dist/components/Icon/SearchMinusIcon.d.ts +3 -0
- package/dist/components/Icon/SettingIcon.d.ts +3 -0
- package/dist/components/Icon/SignatureIcon.d.ts +3 -0
- package/dist/components/Icon/SwapWalletIcon.d.ts +3 -0
- package/dist/components/Icon/TimeIcon.d.ts +3 -0
- package/dist/components/Icon/TrashIcon.d.ts +3 -0
- package/dist/components/Icon/TryAgainIcon.d.ts +3 -0
- package/dist/components/Icon/VerticalSwapIcon.d.ts +3 -0
- package/dist/components/Icon/WalletIconIcon.d.ts +3 -0
- package/dist/components/Icon/WarningIcon.d.ts +3 -0
- package/dist/components/Icon/common.d.ts +2 -0
- package/dist/components/Icon/index.d.ts +36 -0
- package/dist/components/Icon/types.d.ts +6 -0
- package/dist/components/LiquiditySourceList/LiquiditySource.stories.d.ts +4 -0
- package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +8 -0
- package/dist/components/LiquiditySourceList/index.d.ts +1 -0
- package/dist/components/LiquiditySourceList/mockData.d.ts +2 -0
- package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +11 -0
- package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.stories.d.ts +4 -0
- package/dist/components/LiquiditySourcesSelector/index.d.ts +1 -0
- package/dist/components/Modal/Modal.d.ts +11 -0
- package/dist/components/Modal/Modal.stories.d.ts +4 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/Radio/Radio.d.ts +12 -0
- package/dist/components/Radio/Radio.stories.d.ts +4 -0
- package/dist/components/Radio/index.d.ts +1 -0
- package/dist/components/SecondaryPage/SecondaryPage.d.ts +18 -0
- package/dist/components/SecondaryPage/SecondaryPage.stories.d.ts +2 -0
- package/dist/components/SecondaryPage/index.d.ts +1 -0
- package/dist/components/SelectableWalletList/SelectableWalletList.d.ts +7 -0
- package/dist/components/SelectableWalletList/SelectableWalletList.stories.d.ts +5 -0
- package/dist/components/SelectableWalletList/index.d.ts +1 -0
- package/dist/components/SelectableWalletList/mock.d.ts +2 -0
- package/dist/components/Settings/Settings.d.ts +19 -0
- package/dist/components/Settings/Settings.stories.d.ts +4 -0
- package/dist/components/Settings/index.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +5 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts +4 -0
- package/dist/components/Skeleton/index.d.ts +1 -0
- package/dist/components/Spacer/Spacer.d.ts +5 -0
- package/dist/components/Spacer/Spacer.stories.d.ts +4 -0
- package/dist/components/Spacer/index.d.ts +1 -0
- package/dist/components/Spinner/Spinner.d.ts +5 -0
- package/dist/components/Spinner/Spinner.stories.d.ts +4 -0
- package/dist/components/Spinner/index.d.ts +1 -0
- package/dist/components/StatusDrawer/StatusDrawer.d.ts +11 -0
- package/dist/components/StatusDrawer/StatusDrawer.stories.d.ts +4 -0
- package/dist/components/StatusDrawer/index.d.ts +1 -0
- package/dist/components/StepDetail/StepDetail.d.ts +10 -0
- package/dist/components/StepDetail/StepDetail.stories.d.ts +5 -0
- package/dist/components/StepDetail/index.d.ts +1 -0
- package/dist/components/SwapContainer/SwapContainer.d.ts +6 -0
- package/dist/components/SwapContainer/SwapContainer.stories.d.ts +5 -0
- package/dist/components/SwapContainer/index.d.ts +1 -0
- package/dist/components/SwapDetail/SwapDetail.d.ts +8 -0
- package/dist/components/SwapDetail/SwapDetail.stories.d.ts +5 -0
- package/dist/components/SwapDetail/index.d.ts +1 -0
- package/dist/components/SwapDetail/mock.d.ts +2 -0
- package/dist/components/Switch/Switch.d.ts +5 -0
- package/dist/components/Switch/Switch.stories.d.ts +4 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/TextField/TextField.d.ts +10 -0
- package/dist/components/TextField/TextField.stories.d.ts +7 -0
- package/dist/components/TextField/index.d.ts +1 -0
- package/dist/components/TokenList/TokenList.d.ts +14 -0
- package/dist/components/TokenList/TokenList.stories.d.ts +4 -0
- package/dist/components/TokenList/index.d.ts +1 -0
- package/dist/components/TokenList/mockData.d.ts +2 -0
- package/dist/components/TokenSelector/TokenSelector.d.ts +10 -0
- package/dist/components/TokenSelector/TokenSelector.stories.d.ts +4 -0
- package/dist/components/TokenSelector/index.d.ts +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +7 -0
- package/dist/components/Tooltip/Tooltip.stories.d.ts +5 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Typography/Typography.d.ts +14 -0
- package/dist/components/Typography/Typography.stories.d.ts +5 -0
- package/dist/components/Typography/index.d.ts +1 -0
- package/dist/components/VirtualizedList/VirtualizedList.d.ts +18 -0
- package/dist/components/Wallet/State.d.ts +6 -0
- package/dist/components/Wallet/Wallet.d.ts +6 -0
- package/dist/components/Wallet/Wallet.stories.d.ts +4 -0
- package/dist/components/Wallet/index.d.ts +1 -0
- package/dist/components/common/FilledCircle.d.ts +1 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/components/index.d.ts +24 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +23 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +5 -0
- package/dist/containers/ConfirmSwap/index.d.ts +1 -0
- package/dist/containers/ConfirmSwap/mock.d.ts +2 -0
- package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +14 -0
- package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +6 -0
- package/dist/containers/ConfirmWallets/index.d.ts +1 -0
- package/dist/containers/ConfirmWallets/mock.d.ts +5 -0
- package/dist/containers/ConfirmWallets/types.d.ts +8 -0
- package/dist/containers/History/History.d.ts +8 -0
- package/dist/containers/History/History.stories.d.ts +5 -0
- package/dist/containers/History/index.d.ts +1 -0
- package/dist/containers/History/mock.d.ts +2 -0
- package/dist/containers/History/types.d.ts +59 -0
- package/dist/containers/SwapHistory/SwapHistory.d.ts +7 -0
- package/dist/containers/SwapHistory/SwapHistory.stories.d.ts +4 -0
- package/dist/containers/SwapHistory/index.d.ts +1 -0
- package/dist/containers/SwapHistory/mock.d.ts +2 -0
- package/dist/containers/index.d.ts +4 -0
- package/dist/helper/index.d.ts +6 -0
- package/dist/helper/swaps.d.ts +5 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/theme.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/meta.d.ts +22 -0
- package/dist/types/swaps.d.ts +22 -0
- package/dist/types/wallet.d.ts +14 -0
- package/dist/ui.cjs.development.js +4103 -0
- package/dist/ui.cjs.development.js.map +1 -0
- package/dist/ui.cjs.production.min.js +2 -0
- package/dist/ui.cjs.production.min.js.map +1 -0
- package/dist/ui.esm.js +4028 -0
- package/dist/ui.esm.js.map +1 -0
- package/package.json +89 -0
- package/src/components/Alert/Alert.stories.tsx +22 -0
- package/src/components/Alert/Alert.tsx +78 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/BestRoute/BestRoute.stories.tsx +31 -0
- package/src/components/BestRoute/BestRoute.tsx +189 -0
- package/src/components/BestRoute/index.ts +1 -0
- package/src/components/BestRoute/mock.ts +544 -0
- package/src/components/BlockchainSelector/BlockchainSelector.stories.tsx +25 -0
- package/src/components/BlockchainSelector/BlockchainSelector.tsx +93 -0
- package/src/components/BlockchainSelector/index.ts +1 -0
- package/src/components/BlockchainsList/BlockchainsList.stories.tsx +25 -0
- package/src/components/BlockchainsList/BlockchainsList.tsx +60 -0
- package/src/components/BlockchainsList/index.ts +1 -0
- package/src/components/BlockchainsList/mockData.ts +2972 -0
- package/src/components/Button/Button.stories.tsx +59 -0
- package/src/components/Button/Button.tsx +407 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +22 -0
- package/src/components/Checkbox/Checkbox.tsx +54 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Chip/Chip.stories.tsx +37 -0
- package/src/components/Chip/Chip.tsx +45 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/ConnectWalletsModal/ConnectWallets.stories.tsx +13 -0
- package/src/components/ConnectWalletsModal/ConnectWalletsModal.tsx +42 -0
- package/src/components/ConnectWalletsModal/index.ts +1 -0
- package/src/components/ConnectWalletsModal/mockData.ts +118 -0
- package/src/components/Drawer/Drawer.stories.tsx +86 -0
- package/src/components/Drawer/Drawer.tsx +128 -0
- package/src/components/Drawer/index.ts +1 -0
- package/src/components/Icon/AddCircleIcon.tsx +29 -0
- package/src/components/Icon/AddIcon.tsx +28 -0
- package/src/components/Icon/AddWalletIcon.tsx +48 -0
- package/src/components/Icon/AngleDownIcon.tsx +30 -0
- package/src/components/Icon/AngleLeftIcon.tsx +31 -0
- package/src/components/Icon/AngleRightIcon.tsx +30 -0
- package/src/components/Icon/AngleUpIcon.tsx +30 -0
- package/src/components/Icon/BagIcon.tsx +37 -0
- package/src/components/Icon/BanIcon.tsx +30 -0
- package/src/components/Icon/CheckCircleIcon.tsx +37 -0
- package/src/components/Icon/CheckIcon.tsx +28 -0
- package/src/components/Icon/CheckSquareIcon.tsx +35 -0
- package/src/components/Icon/CheckWalletIcon.tsx +43 -0
- package/src/components/Icon/CloseIcon.tsx +9 -0
- package/src/components/Icon/DeleteCircleIcon.tsx +29 -0
- package/src/components/Icon/DeleteWalletIcon.tsx +48 -0
- package/src/components/Icon/DownloadIcon.tsx +35 -0
- package/src/components/Icon/GasIcon.tsx +35 -0
- package/src/components/Icon/HistoryIcon.tsx +38 -0
- package/src/components/Icon/HorizontalSwapIcon.tsx +36 -0
- package/src/components/Icon/Icons.stories.tsx +44 -0
- package/src/components/Icon/InfoCircleIcon.tsx +37 -0
- package/src/components/Icon/MinusCircleIcon.tsx +29 -0
- package/src/components/Icon/RetryIcon.tsx +30 -0
- package/src/components/Icon/RetryLeftIcon.tsx +29 -0
- package/src/components/Icon/RetryRightIcon.tsx +29 -0
- package/src/components/Icon/SearchIcon.tsx +29 -0
- package/src/components/Icon/SearchMinusIcon.tsx +29 -0
- package/src/components/Icon/SettingIcon.tsx +37 -0
- package/src/components/Icon/SignatureIcon.tsx +30 -0
- package/src/components/Icon/SwapWalletIcon.tsx +48 -0
- package/src/components/Icon/TimeIcon.tsx +29 -0
- package/src/components/Icon/TrashIcon.tsx +29 -0
- package/src/components/Icon/TryAgainIcon.tsx +29 -0
- package/src/components/Icon/VerticalSwapIcon.tsx +36 -0
- package/src/components/Icon/WalletIconIcon.tsx +38 -0
- package/src/components/Icon/WarningIcon.tsx +35 -0
- package/src/components/Icon/common.ts +69 -0
- package/src/components/Icon/index.ts +44 -0
- package/src/components/Icon/types.tsx +44 -0
- package/src/components/LiquiditySourceList/LiquiditySource.stories.tsx +13 -0
- package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +114 -0
- package/src/components/LiquiditySourceList/index.ts +1 -0
- package/src/components/LiquiditySourceList/mockData.ts +316 -0
- package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.stories.tsx +16 -0
- package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +55 -0
- package/src/components/LiquiditySourcesSelector/index.ts +1 -0
- package/src/components/Modal/Modal.stories.tsx +22 -0
- package/src/components/Modal/Modal.tsx +76 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Radio/Radio.stories.tsx +23 -0
- package/src/components/Radio/Radio.tsx +95 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/SecondaryPage/SecondaryPage.stories.tsx +7 -0
- package/src/components/SecondaryPage/SecondaryPage.tsx +95 -0
- package/src/components/SecondaryPage/index.ts +1 -0
- package/src/components/SelectableWalletList/SelectableWalletList.stories.tsx +14 -0
- package/src/components/SelectableWalletList/SelectableWalletList.tsx +113 -0
- package/src/components/SelectableWalletList/index.ts +1 -0
- package/src/components/SelectableWalletList/mock.ts +12 -0
- package/src/components/Settings/Settings.stories.tsx +34 -0
- package/src/components/Settings/Settings.tsx +160 -0
- package/src/components/Settings/index.ts +1 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +24 -0
- package/src/components/Skeleton/Skeleton.tsx +66 -0
- package/src/components/Skeleton/index.ts +1 -0
- package/src/components/Spacer/Spacer.stories.tsx +18 -0
- package/src/components/Spacer/Spacer.tsx +98 -0
- package/src/components/Spacer/index.ts +1 -0
- package/src/components/Spinner/Spinner.stories.tsx +25 -0
- package/src/components/Spinner/Spinner.tsx +61 -0
- package/src/components/Spinner/index.ts +1 -0
- package/src/components/StatusDrawer/StatusDrawer.stories.tsx +38 -0
- package/src/components/StatusDrawer/StatusDrawer.tsx +81 -0
- package/src/components/StatusDrawer/index.ts +1 -0
- package/src/components/StepDetail/StepDetail.stories.tsx +37 -0
- package/src/components/StepDetail/StepDetail.tsx +97 -0
- package/src/components/StepDetail/index.ts +1 -0
- package/src/components/SwapContainer/SwapContainer.stories.tsx +13 -0
- package/src/components/SwapContainer/SwapContainer.tsx +35 -0
- package/src/components/SwapContainer/index.ts +1 -0
- package/src/components/SwapDetail/SwapDetail.stories.tsx +19 -0
- package/src/components/SwapDetail/SwapDetail.tsx +150 -0
- package/src/components/SwapDetail/index.ts +1 -0
- package/src/components/SwapDetail/mock.ts +275 -0
- package/src/components/Switch/Switch.stories.tsx +9 -0
- package/src/components/Switch/Switch.tsx +52 -0
- package/src/components/Switch/index.ts +1 -0
- package/src/components/TextField/TextField.stories.tsx +31 -0
- package/src/components/TextField/TextField.tsx +129 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/TokenList/TokenList.stories.tsx +18 -0
- package/src/components/TokenList/TokenList.tsx +180 -0
- package/src/components/TokenList/index.ts +1 -0
- package/src/components/TokenList/mockData.ts +1721 -0
- package/src/components/TokenSelector/TokenSelector.stories.tsx +18 -0
- package/src/components/TokenSelector/TokenSelector.tsx +35 -0
- package/src/components/TokenSelector/index.ts +1 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +52 -0
- package/src/components/Tooltip/Tooltip.tsx +110 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/Typography/Typography.stories.tsx +68 -0
- package/src/components/Typography/Typography.tsx +199 -0
- package/src/components/Typography/index.ts +1 -0
- package/src/components/VirtualizedList/VirtualizedList.tsx +78 -0
- package/src/components/Wallet/State.tsx +36 -0
- package/src/components/Wallet/Wallet.stories.tsx +36 -0
- package/src/components/Wallet/Wallet.tsx +42 -0
- package/src/components/Wallet/index.ts +1 -0
- package/src/components/common/FilledCircle.tsx +8 -0
- package/src/components/common/index.ts +1 -0
- package/src/components/index.ts +24 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +13 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.tsx +154 -0
- package/src/containers/ConfirmSwap/index.ts +1 -0
- package/src/containers/ConfirmSwap/mock.ts +146 -0
- package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +26 -0
- package/src/containers/ConfirmWallets/ConfirmWallets.tsx +98 -0
- package/src/containers/ConfirmWallets/index.ts +1 -0
- package/src/containers/ConfirmWallets/mock.ts +222 -0
- package/src/containers/ConfirmWallets/types.ts +9 -0
- package/src/containers/History/History.stories.tsx +14 -0
- package/src/containers/History/History.tsx +93 -0
- package/src/containers/History/index.ts +1 -0
- package/src/containers/History/mock.ts +825 -0
- package/src/containers/History/types.tsx +66 -0
- package/src/containers/SwapHistory/SwapHistory.stories.tsx +13 -0
- package/src/containers/SwapHistory/SwapHistory.tsx +165 -0
- package/src/containers/SwapHistory/index.ts +1 -0
- package/src/containers/SwapHistory/mock.ts +275 -0
- package/src/containers/index.ts +4 -0
- package/src/helper/index.ts +23 -0
- package/src/helper/swaps.ts +23 -0
- package/src/helpers.ts +2 -0
- package/src/index.ts +4 -0
- package/src/theme.ts +161 -0
- package/src/types/index.ts +1 -0
- package/src/types/meta.ts +20 -0
- package/src/types/swaps.tsx +36 -0
- package/src/types/wallet.ts +20 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { RoutingResultType, TransactionType } from 'rango-sdk';
|
|
2
|
+
import { PendingSwap } from '../../containers/History/types';
|
|
3
|
+
|
|
4
|
+
export const swap: PendingSwap = {
|
|
5
|
+
creationTime: '1673164511955',
|
|
6
|
+
finishTime: '1673164550137',
|
|
7
|
+
requestId: '51e211d9-d61c-45d2-a4d4-1f9f7f90ee85',
|
|
8
|
+
inputAmount: '1',
|
|
9
|
+
wallets: {
|
|
10
|
+
OSMOSIS: {
|
|
11
|
+
walletType: 'keplr',
|
|
12
|
+
address: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
status: 'running',
|
|
16
|
+
isPaused: false,
|
|
17
|
+
extraMessage: null,
|
|
18
|
+
extraMessageSeverity: 'info',
|
|
19
|
+
extraMessageDetail: '',
|
|
20
|
+
extraMessageErrorCode: null,
|
|
21
|
+
networkStatusExtraMessage: null,
|
|
22
|
+
networkStatusExtraMessageDetail: null,
|
|
23
|
+
lastNotificationTime: null,
|
|
24
|
+
settings: {
|
|
25
|
+
slippage: '1.0',
|
|
26
|
+
disabledSwappersIds: [],
|
|
27
|
+
disabledSwappersGroups: [],
|
|
28
|
+
},
|
|
29
|
+
simulationResult: {
|
|
30
|
+
resultType: RoutingResultType.OK,
|
|
31
|
+
outputAmount: '1.540670',
|
|
32
|
+
swaps: [
|
|
33
|
+
{
|
|
34
|
+
swapperId: 'Osmosis',
|
|
35
|
+
swapperType: 'DEX',
|
|
36
|
+
swapperLogo: '',
|
|
37
|
+
from: {
|
|
38
|
+
symbol: 'JUNO',
|
|
39
|
+
logo: 'https://api.rango.exchange/tokens/COSMOS/JUNO.png',
|
|
40
|
+
address:
|
|
41
|
+
'ibc/46b44899322f3cd854d2d46deef881958467cdd4b3b10086da49296bbed94bed',
|
|
42
|
+
blockchain: 'OSMOSIS',
|
|
43
|
+
blockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
|
|
44
|
+
decimals: 6,
|
|
45
|
+
usdPrice: 1.1091996179668873,
|
|
46
|
+
},
|
|
47
|
+
to: {
|
|
48
|
+
symbol: 'OSMO',
|
|
49
|
+
logo: 'https://api.rango.exchange/i/mJQPS2',
|
|
50
|
+
address: null,
|
|
51
|
+
blockchain: 'OSMOSIS',
|
|
52
|
+
decimals: 6,
|
|
53
|
+
blockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
|
|
54
|
+
usdPrice: 0.7192435454440882,
|
|
55
|
+
},
|
|
56
|
+
fromAmount: '1.000000',
|
|
57
|
+
fromAmountPrecision: null,
|
|
58
|
+
fromAmountMinValue: null,
|
|
59
|
+
fromAmountMaxValue: null,
|
|
60
|
+
fromAmountRestrictionType: 'EXCLUSIVE',
|
|
61
|
+
toAmount: '1.540670',
|
|
62
|
+
fee: [
|
|
63
|
+
{
|
|
64
|
+
asset: {
|
|
65
|
+
blockchain: 'OSMOSIS',
|
|
66
|
+
symbol: 'OSMO',
|
|
67
|
+
address: null,
|
|
68
|
+
},
|
|
69
|
+
expenseType: 'FROM_SOURCE_WALLET',
|
|
70
|
+
name: 'Network Fee',
|
|
71
|
+
amount: '0',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
estimatedTimeInSeconds: 45,
|
|
75
|
+
swapChainType: 'INTRA_CHAIN',
|
|
76
|
+
routes: [
|
|
77
|
+
{
|
|
78
|
+
nodes: [
|
|
79
|
+
{
|
|
80
|
+
nodes: [
|
|
81
|
+
{
|
|
82
|
+
marketName: 'pool#498',
|
|
83
|
+
marketId: null,
|
|
84
|
+
percent: 1,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
from: 'JUNO',
|
|
88
|
+
fromLogo: 'https://api.rango.exchange/tokens/COSMOS/JUNO.png',
|
|
89
|
+
fromAddress:
|
|
90
|
+
'ibc/46b44899322f3cd854d2d46deef881958467cdd4b3b10086da49296bbed94bed',
|
|
91
|
+
fromBlockchain: 'OSMOSIS',
|
|
92
|
+
to: 'ATOM',
|
|
93
|
+
toLogo: 'https://api.rango.exchange/tokens/COSMOS/ATOM.png',
|
|
94
|
+
toAddress:
|
|
95
|
+
'ibc/27394fb092d2eccd56123c74f36e4c1f926001ceada9ca97ea622b25f41e5eb2',
|
|
96
|
+
toBlockchain: 'OSMOSIS',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
nodes: [
|
|
100
|
+
{
|
|
101
|
+
marketName: 'pool#8',
|
|
102
|
+
marketId: null,
|
|
103
|
+
percent: 1,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
from: 'ATOM',
|
|
107
|
+
fromLogo: 'https://api.rango.exchange/tokens/COSMOS/ATOM.png',
|
|
108
|
+
fromAddress:
|
|
109
|
+
'ibc/27394fb092d2eccd56123c74f36e4c1f926001ceada9ca97ea622b25f41e5eb2',
|
|
110
|
+
fromBlockchain: 'OSMOSIS',
|
|
111
|
+
to: 'IRIS',
|
|
112
|
+
toLogo: 'https://api.rango.exchange/tokens/COSMOS/IRIS.png',
|
|
113
|
+
toAddress:
|
|
114
|
+
'ibc/7c4d60aa95e5a7558b0a364860979ca34b7ff8aaf255b87af9e879374470cec0',
|
|
115
|
+
toBlockchain: 'OSMOSIS',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
nodes: [
|
|
119
|
+
{
|
|
120
|
+
marketName: 'pool#7',
|
|
121
|
+
marketId: null,
|
|
122
|
+
percent: 1,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
from: 'IRIS',
|
|
126
|
+
fromLogo: 'https://api.rango.exchange/tokens/COSMOS/IRIS.png',
|
|
127
|
+
fromAddress:
|
|
128
|
+
'ibc/7c4d60aa95e5a7558b0a364860979ca34b7ff8aaf255b87af9e879374470cec0',
|
|
129
|
+
fromBlockchain: 'OSMOSIS',
|
|
130
|
+
to: 'OSMO',
|
|
131
|
+
toLogo: 'https://api.rango.exchange/tokens/COSMOS/OSMO.png',
|
|
132
|
+
toAddress: null,
|
|
133
|
+
toBlockchain: 'OSMOSIS',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
recommendedSlippage: null,
|
|
139
|
+
timeStat: {
|
|
140
|
+
min: 6,
|
|
141
|
+
avg: 40,
|
|
142
|
+
max: 241,
|
|
143
|
+
},
|
|
144
|
+
includesDestinationTx: false,
|
|
145
|
+
maxRequiredSign: 1,
|
|
146
|
+
warnings: [],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
},
|
|
150
|
+
validateBalanceOrFee: true,
|
|
151
|
+
steps: [
|
|
152
|
+
{
|
|
153
|
+
id: 1,
|
|
154
|
+
fromBlockchain: 'OSMOSIS',
|
|
155
|
+
fromSymbol: 'JUNO',
|
|
156
|
+
swapperType: 'test',
|
|
157
|
+
fromSymbolAddress:
|
|
158
|
+
'ibc/46b44899322f3cd854d2d46deef881958467cdd4b3b10086da49296bbed94bed',
|
|
159
|
+
fromDecimals: 6,
|
|
160
|
+
fromAmountPrecision: null,
|
|
161
|
+
fromAmountMinValue: null,
|
|
162
|
+
fromAmountMaxValue: null,
|
|
163
|
+
toBlockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
|
|
164
|
+
fromBlockchainLogo: 'https://api.rango.exchange/swappers/osmosis.png',
|
|
165
|
+
toBlockchain: 'OSMOSIS',
|
|
166
|
+
fromLogo: 'https://api.rango.exchange/tokens/COSMOS/JUNO.png',
|
|
167
|
+
toSymbol: 'OSMO',
|
|
168
|
+
toSymbolAddress: null,
|
|
169
|
+
toDecimals: 6,
|
|
170
|
+
toLogo: 'https://api.rango.exchange/i/mJQPS2',
|
|
171
|
+
startTransactionTime: 1673164519916,
|
|
172
|
+
swapperId: 'Osmosis',
|
|
173
|
+
swapperLogo: 'https://api.rango.exchange/swappers/osmosis.png',
|
|
174
|
+
expectedOutputAmountHumanReadable: '1.540670',
|
|
175
|
+
outputAmount: '1.540658',
|
|
176
|
+
status: 'running',
|
|
177
|
+
networkStatus: null,
|
|
178
|
+
executedTransactionId:
|
|
179
|
+
'0f8f17eecc863c2d6be65ef52cfe3128ff3cd7baeddf133160bea8ccdfbf876b',
|
|
180
|
+
explorerUrl: [
|
|
181
|
+
{
|
|
182
|
+
url: 'https://www.mintscan.io/osmosis/txs/0f8f17eecc863c2d6be65ef52cfe3128ff3cd7baeddf133160bea8ccdfbf876b',
|
|
183
|
+
description: null,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
cosmosTransaction: {
|
|
187
|
+
type: TransactionType.COSMOS,
|
|
188
|
+
fromWalletAddress: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
|
|
189
|
+
blockChain: 'OSMOSIS',
|
|
190
|
+
data: {
|
|
191
|
+
chainId: 'osmosis-1',
|
|
192
|
+
account_number: 102721,
|
|
193
|
+
sequence: '308',
|
|
194
|
+
msgs: [
|
|
195
|
+
{
|
|
196
|
+
__type: 'OsmosisSwapMessage',
|
|
197
|
+
type: 'osmosis/gamm/swap-exact-amount-in',
|
|
198
|
+
value: {
|
|
199
|
+
sender: 'osmo1unf2rcytjxfpz8x8ar63h4qeftadptg5t0nqcl',
|
|
200
|
+
routes: [
|
|
201
|
+
{
|
|
202
|
+
pool_id: '498',
|
|
203
|
+
token_out_denom:
|
|
204
|
+
'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
pool_id: '8',
|
|
208
|
+
token_out_denom:
|
|
209
|
+
'ibc/7C4D60AA95E5A7558B0A364860979CA34B7FF8AAF255B87AF9E879374470CEC0',
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
pool_id: '7',
|
|
213
|
+
token_out_denom: 'uosmo',
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
token_in: {
|
|
217
|
+
denom:
|
|
218
|
+
'ibc/46B44899322F3CD854D2D46DEEF881958467CDD4B3B10086DA49296BBED94BED',
|
|
219
|
+
amount: '1000000',
|
|
220
|
+
},
|
|
221
|
+
token_out_min_amount: '1525264',
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
protoMsgs: [
|
|
226
|
+
{
|
|
227
|
+
type_url: '/osmosis.gamm.v1beta1.MsgSwapExactAmountIn',
|
|
228
|
+
value: [
|
|
229
|
+
10, 43, 111, 115, 109, 111, 49, 117, 110, 102, 50, 114, 99, 121,
|
|
230
|
+
116, 106, 120, 102, 112, 122, 56, 120, 56, 97, 114, 54, 51, 104,
|
|
231
|
+
52, 113, 101, 102, 116, 97, 100, 112, 116, 103, 53, 116, 48,
|
|
232
|
+
110, 113, 99, 108, 18, 73, 8, -14, 3, 18, 68, 105, 98, 99, 47,
|
|
233
|
+
50, 55, 51, 57, 52, 70, 66, 48, 57, 50, 68, 50, 69, 67, 67, 68,
|
|
234
|
+
53, 54, 49, 50, 51, 67, 55, 52, 70, 51, 54, 69, 52, 67, 49, 70,
|
|
235
|
+
57, 50, 54, 48, 48, 49, 67, 69, 65, 68, 65, 57, 67, 65, 57, 55,
|
|
236
|
+
69, 65, 54, 50, 50, 66, 50, 53, 70, 52, 49, 69, 53, 69, 66, 50,
|
|
237
|
+
18, 72, 8, 8, 18, 68, 105, 98, 99, 47, 55, 67, 52, 68, 54, 48,
|
|
238
|
+
65, 65, 57, 53, 69, 53, 65, 55, 53, 53, 56, 66, 48, 65, 51, 54,
|
|
239
|
+
52, 56, 54, 48, 57, 55, 57, 67, 65, 51, 52, 66, 55, 70, 70, 56,
|
|
240
|
+
65, 65, 70, 50, 53, 53, 66, 56, 55, 65, 70, 57, 69, 56, 55, 57,
|
|
241
|
+
51, 55, 52, 52, 55, 48, 67, 69, 67, 48, 18, 9, 8, 7, 18, 5, 117,
|
|
242
|
+
111, 115, 109, 111, 26, 79, 10, 68, 105, 98, 99, 47, 52, 54, 66,
|
|
243
|
+
52, 52, 56, 57, 57, 51, 50, 50, 70, 51, 67, 68, 56, 53, 52, 68,
|
|
244
|
+
50, 68, 52, 54, 68, 69, 69, 70, 56, 56, 49, 57, 53, 56, 52, 54,
|
|
245
|
+
55, 67, 68, 68, 52, 66, 51, 66, 49, 48, 48, 56, 54, 68, 65, 52,
|
|
246
|
+
57, 50, 57, 54, 66, 66, 69, 68, 57, 52, 66, 69, 68, 18, 7, 49,
|
|
247
|
+
48, 48, 48, 48, 48, 48, 34, 7, 49, 53, 50, 53, 50, 54, 52,
|
|
248
|
+
],
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
memo: '',
|
|
252
|
+
source: null,
|
|
253
|
+
fee: {
|
|
254
|
+
gas: '900000',
|
|
255
|
+
amount: [
|
|
256
|
+
{
|
|
257
|
+
denom: 'uosmo',
|
|
258
|
+
amount: '0',
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
},
|
|
262
|
+
signType: 'AMINO',
|
|
263
|
+
rpcUrl: 'sample_rpc',
|
|
264
|
+
},
|
|
265
|
+
rawTransfer: null,
|
|
266
|
+
},
|
|
267
|
+
solanaTransaction: null,
|
|
268
|
+
evmTransaction: null,
|
|
269
|
+
evmApprovalTransaction: null,
|
|
270
|
+
transferTransaction: null,
|
|
271
|
+
diagnosisUrl: null,
|
|
272
|
+
internalSteps: null,
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentMeta } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Switch, PropTypes } from './Switch';
|
|
4
|
+
|
|
5
|
+
export default { title: 'Switch', component: Switch } as ComponentMeta<
|
|
6
|
+
typeof Switch
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export const Main = (args: PropTypes) => <Switch {...args} />;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as RadixSwitch from '@radix-ui/react-switch';
|
|
3
|
+
|
|
4
|
+
import { styled } from '../../theme';
|
|
5
|
+
|
|
6
|
+
const StyledSwitchRoot = styled(RadixSwitch.Root, {
|
|
7
|
+
boxSizing: 'border-box',
|
|
8
|
+
boxShadow: 'none',
|
|
9
|
+
borderStyle: 'solid',
|
|
10
|
+
width: '42px',
|
|
11
|
+
height: '22px',
|
|
12
|
+
backgroundColor: '$neutrals300',
|
|
13
|
+
borderColor: '$neutrals400',
|
|
14
|
+
borderRadius: '99999px',
|
|
15
|
+
position: 'relative',
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
'&[data-state="checked"]': {
|
|
18
|
+
backgroundColor: '$primary100',
|
|
19
|
+
},
|
|
20
|
+
'-webkit-tap-highlight-color': 'rgba(0, 0, 0, 0)',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const StyledSwitchThumb = styled(RadixSwitch.Thumb, {
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
top: '0',
|
|
26
|
+
boxSizing: 'border-box',
|
|
27
|
+
display: 'block',
|
|
28
|
+
width: '18px',
|
|
29
|
+
height: '18px',
|
|
30
|
+
backgroundColor: '$neutrals500',
|
|
31
|
+
transition: ' transform 100ms',
|
|
32
|
+
borderRadius: '999999px',
|
|
33
|
+
willChange: 'transform',
|
|
34
|
+
'&[data-state="checked"]': {
|
|
35
|
+
transform: 'translateX(20px)',
|
|
36
|
+
backgroundColor: '$primary500',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export interface PropTypes {
|
|
41
|
+
checked: boolean;
|
|
42
|
+
onChange?: (checked: boolean) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function Switch(props: PropTypes) {
|
|
46
|
+
const { checked, onChange } = props;
|
|
47
|
+
return (
|
|
48
|
+
<StyledSwitchRoot checked={checked} onCheckedChange={onChange}>
|
|
49
|
+
<StyledSwitchThumb />
|
|
50
|
+
</StyledSwitchRoot>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch } from './Switch';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentMeta } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { TextField, PropTypes } from './TextField';
|
|
5
|
+
import { SearchIcon } from '../Icon';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Text Field',
|
|
9
|
+
|
|
10
|
+
component: TextField,
|
|
11
|
+
argTypes: {
|
|
12
|
+
disabled: {
|
|
13
|
+
name: 'disabled',
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
},
|
|
16
|
+
placeholder: {
|
|
17
|
+
name: 'placeholder',
|
|
18
|
+
type: 'string',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
} as ComponentMeta<typeof TextField>;
|
|
22
|
+
|
|
23
|
+
export const Main = (args: PropTypes) => <TextField {...args} />;
|
|
24
|
+
|
|
25
|
+
export const WithPrefix = (args: PropTypes) => (
|
|
26
|
+
<TextField {...args} prefix={<SearchIcon size={20} />} />
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const WithSuffix = (args: PropTypes) => (
|
|
30
|
+
<TextField {...args} suffix={<SearchIcon size={20} />} />
|
|
31
|
+
);
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { PropsWithChildren, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
import { styled } from '../../theme';
|
|
4
|
+
|
|
5
|
+
const InputContainer = styled('div', {
|
|
6
|
+
backgroundColor: '$background',
|
|
7
|
+
boxSizing: 'border-box',
|
|
8
|
+
border: '1px solid $neutrals400',
|
|
9
|
+
borderRadius: '$5',
|
|
10
|
+
height: '$48',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexGrow: 1,
|
|
13
|
+
position: 'relative',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
color: '$foreground',
|
|
16
|
+
transition: 'border-color ease .3s',
|
|
17
|
+
'&:focus-within': {
|
|
18
|
+
borderColor: '$primary500',
|
|
19
|
+
},
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
small: {
|
|
23
|
+
height: '$32',
|
|
24
|
+
},
|
|
25
|
+
medium: {
|
|
26
|
+
height: '$40',
|
|
27
|
+
},
|
|
28
|
+
large: {
|
|
29
|
+
height: '$48',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
true: {
|
|
34
|
+
backgroundColor: '$neutrals300',
|
|
35
|
+
cursor: 'not-allowed',
|
|
36
|
+
filter: 'grayscale(100%)',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
prefix: {
|
|
40
|
+
true: {
|
|
41
|
+
paddingLeft: '$16',
|
|
42
|
+
},
|
|
43
|
+
false: {
|
|
44
|
+
paddingLeft: '$0',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
suffix: {
|
|
48
|
+
true: {
|
|
49
|
+
paddingRight: '$16',
|
|
50
|
+
},
|
|
51
|
+
false: {
|
|
52
|
+
paddingRight: '$0',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
size: 'medium',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const Input = styled('input', {
|
|
62
|
+
color: '$text',
|
|
63
|
+
paddingLeft: '$16',
|
|
64
|
+
paddingRight: '$16',
|
|
65
|
+
flexGrow: 1,
|
|
66
|
+
width: '100%',
|
|
67
|
+
border: 'none',
|
|
68
|
+
borderRadius: '$5',
|
|
69
|
+
outline: 'none',
|
|
70
|
+
fontSize: '$l',
|
|
71
|
+
backgroundColor: 'transparent',
|
|
72
|
+
'-webkit-appearance': 'none',
|
|
73
|
+
margin: 0,
|
|
74
|
+
'&:disabled': {
|
|
75
|
+
cursor: 'not-allowed',
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const Label = styled('label', {
|
|
79
|
+
display: 'inline-block',
|
|
80
|
+
fontSize: '$16',
|
|
81
|
+
marginBottom: '$4',
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export type PropTypes = {
|
|
85
|
+
label?: string;
|
|
86
|
+
prefix?: React.ReactNode;
|
|
87
|
+
suffix?: React.ReactNode;
|
|
88
|
+
size?: 'small' | 'medium' | 'large';
|
|
89
|
+
} & Omit<React.InputHTMLAttributes<HTMLInputElement>, 'prefix' | 'size'> & {
|
|
90
|
+
ref?:
|
|
91
|
+
| ((instance: HTMLInputElement | null) => void)
|
|
92
|
+
| React.RefObject<HTMLInputElement>
|
|
93
|
+
| null
|
|
94
|
+
| undefined;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const TextField = React.forwardRef(
|
|
98
|
+
(
|
|
99
|
+
props: PropsWithChildren<PropTypes>,
|
|
100
|
+
ref:
|
|
101
|
+
| RefObject<HTMLInputElement>
|
|
102
|
+
| ((instance: HTMLInputElement | null) => void)
|
|
103
|
+
| null
|
|
104
|
+
| undefined
|
|
105
|
+
) => {
|
|
106
|
+
const { label, prefix, suffix, children, size, style, ...inputAttributes } =
|
|
107
|
+
props;
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
{label && (
|
|
111
|
+
<Label {...(inputAttributes.id && { htmlFor: inputAttributes.id })}>
|
|
112
|
+
{label}
|
|
113
|
+
</Label>
|
|
114
|
+
)}
|
|
115
|
+
<InputContainer
|
|
116
|
+
disabled={inputAttributes.disabled}
|
|
117
|
+
prefix={!!prefix}
|
|
118
|
+
suffix={!!suffix}
|
|
119
|
+
size={size}
|
|
120
|
+
style={style}
|
|
121
|
+
>
|
|
122
|
+
{prefix || null}
|
|
123
|
+
<Input {...inputAttributes} spellCheck={false} ref={ref} />
|
|
124
|
+
{suffix || null}
|
|
125
|
+
</InputContainer>
|
|
126
|
+
</>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TextField } from './TextField';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentMeta } from '@storybook/react';
|
|
3
|
+
import { TokenList, PropTypes } from './TokenList';
|
|
4
|
+
import { tokensMeta } from './mockData';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Token List',
|
|
8
|
+
component: TokenList,
|
|
9
|
+
argTypes: {
|
|
10
|
+
searchedText: {
|
|
11
|
+
defaultValue: '',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
} as ComponentMeta<typeof TokenList>;
|
|
15
|
+
|
|
16
|
+
export const Main = (args: PropTypes) => (
|
|
17
|
+
<TokenList {...args} list={tokensMeta} selected={tokensMeta[0]} />
|
|
18
|
+
);
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useState } from 'react';
|
|
2
|
+
import { CommonProps } from 'react-window';
|
|
3
|
+
import { containsText } from '../../helpers';
|
|
4
|
+
import { styled } from '../../theme';
|
|
5
|
+
import { Token } from 'rango-sdk';
|
|
6
|
+
import { Button } from '../Button/Button';
|
|
7
|
+
import { Typography } from '../Typography';
|
|
8
|
+
import { VirtualizedList } from '../VirtualizedList/VirtualizedList';
|
|
9
|
+
import { CSSProperties } from '@stitches/react';
|
|
10
|
+
|
|
11
|
+
export interface TokenWithAmount extends Token {
|
|
12
|
+
balance?: {
|
|
13
|
+
amount: string;
|
|
14
|
+
usdValue: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PAGE_SIZE = 20;
|
|
19
|
+
export interface PropTypes {
|
|
20
|
+
list: TokenWithAmount[];
|
|
21
|
+
selected: TokenWithAmount | null;
|
|
22
|
+
searchedText: string;
|
|
23
|
+
onChange: (token: TokenWithAmount) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TokenImage = styled('img', {
|
|
27
|
+
width: '$32',
|
|
28
|
+
maxHeight: '$32',
|
|
29
|
+
marginRight: '$16',
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const TokenNameContainer = styled('div', {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const TokenAmountContainer = styled('div', {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
alignItems: 'flex-end',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const filterTokens = (
|
|
44
|
+
list: Token[],
|
|
45
|
+
searchedText: string,
|
|
46
|
+
outputCount?: number
|
|
47
|
+
) => {
|
|
48
|
+
if (searchedText)
|
|
49
|
+
return list
|
|
50
|
+
.filter(
|
|
51
|
+
(token) =>
|
|
52
|
+
containsText(token.symbol, searchedText) ||
|
|
53
|
+
containsText(token.address || '', searchedText) ||
|
|
54
|
+
containsText(token.name || '', searchedText)
|
|
55
|
+
)
|
|
56
|
+
.slice(0, outputCount);
|
|
57
|
+
else return list.slice(0, outputCount);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export function TokenList(props: PropTypes) {
|
|
61
|
+
const { list, searchedText, onChange } = props;
|
|
62
|
+
const [selected, setSelected] = useState(props.selected);
|
|
63
|
+
|
|
64
|
+
const changeSelected = (token: TokenWithAmount) => {
|
|
65
|
+
setSelected(token);
|
|
66
|
+
onChange(token);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const Token = ({
|
|
70
|
+
filteredTokens,
|
|
71
|
+
index,
|
|
72
|
+
style,
|
|
73
|
+
}: {
|
|
74
|
+
filteredTokens: TokenWithAmount[];
|
|
75
|
+
index: number;
|
|
76
|
+
style: CSSProperties | undefined;
|
|
77
|
+
}) => {
|
|
78
|
+
const currentToken = filteredTokens[index];
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
style={{
|
|
82
|
+
display: 'flex',
|
|
83
|
+
alignItems: 'center',
|
|
84
|
+
width: '100%',
|
|
85
|
+
...style,
|
|
86
|
+
height: '48px',
|
|
87
|
+
top: `${parseFloat(style?.top as string) + 0}px`,
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<Button
|
|
91
|
+
variant="outlined"
|
|
92
|
+
size="large"
|
|
93
|
+
align="start"
|
|
94
|
+
onClick={changeSelected.bind(null, currentToken)}
|
|
95
|
+
type={
|
|
96
|
+
selected?.symbol === currentToken.symbol &&
|
|
97
|
+
selected?.address === currentToken.address
|
|
98
|
+
? 'primary'
|
|
99
|
+
: undefined
|
|
100
|
+
}
|
|
101
|
+
prefix={<TokenImage src={currentToken.image} />}
|
|
102
|
+
suffix={
|
|
103
|
+
currentToken.balance?.amount && (
|
|
104
|
+
<TokenAmountContainer>
|
|
105
|
+
<Typography variant="body2">
|
|
106
|
+
{currentToken.balance.amount}
|
|
107
|
+
</Typography>
|
|
108
|
+
<Typography variant="caption">
|
|
109
|
+
{`${currentToken.balance.usdValue}$`}
|
|
110
|
+
</Typography>
|
|
111
|
+
</TokenAmountContainer>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
>
|
|
115
|
+
<TokenNameContainer>
|
|
116
|
+
<Typography variant="body1">{currentToken.symbol}</Typography>
|
|
117
|
+
<Typography variant="body2">{currentToken.name}</Typography>
|
|
118
|
+
</TokenNameContainer>
|
|
119
|
+
</Button>
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const [hasNextPage, setHasNextPage] = useState<boolean>(true);
|
|
125
|
+
const [isNextPageLoading, setIsNextPageLoading] = useState<boolean>(false);
|
|
126
|
+
const [filteredTokens, setFilteredTokens] = useState<TokenWithAmount[]>(list);
|
|
127
|
+
|
|
128
|
+
const loadNextPage = () => {
|
|
129
|
+
setIsNextPageLoading(true);
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
setIsNextPageLoading(false);
|
|
132
|
+
setFilteredTokens(
|
|
133
|
+
filterTokens(list, searchedText, filteredTokens.length + PAGE_SIZE)
|
|
134
|
+
);
|
|
135
|
+
}, 0);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
setFilteredTokens(filterTokens(list, searchedText, PAGE_SIZE));
|
|
140
|
+
}, [searchedText]);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
setHasNextPage(
|
|
144
|
+
filterTokens(list, searchedText).length > filterTokens.length
|
|
145
|
+
);
|
|
146
|
+
}, [filteredTokens.length]);
|
|
147
|
+
|
|
148
|
+
const innerElementType: React.FC<CommonProps> = forwardRef(
|
|
149
|
+
({ style, ...rest }, ref) => {
|
|
150
|
+
return (
|
|
151
|
+
<div
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
+
ref={ref as any}
|
|
154
|
+
style={{
|
|
155
|
+
...style,
|
|
156
|
+
// eslint-disable-next-line react/prop-types
|
|
157
|
+
height: `${parseFloat(style?.height as string) + 8 * 2}px`,
|
|
158
|
+
}}
|
|
159
|
+
{...rest}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<div style={{ height: '450px' }}>
|
|
167
|
+
<VirtualizedList
|
|
168
|
+
Item={({ index, style }) => (
|
|
169
|
+
<Token filteredTokens={filteredTokens} style={style} index={index} />
|
|
170
|
+
)}
|
|
171
|
+
hasNextPage={hasNextPage}
|
|
172
|
+
isNextPageLoading={isNextPageLoading}
|
|
173
|
+
itemCount={filteredTokens.length}
|
|
174
|
+
loadNextPage={loadNextPage}
|
|
175
|
+
innerElementType={innerElementType}
|
|
176
|
+
size={56}
|
|
177
|
+
/>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
}
|