@layerswap/widget 1.0.6 → 1.1.0
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/dist/esm/Models/LayerSwapSettings.js +0 -1
- package/dist/esm/Models/Theme.js +39 -0
- package/dist/esm/components/Buttons/submitButton.js +2 -1
- package/dist/esm/components/Common/ConnectWalletButton.js +9 -3
- package/dist/esm/components/Common/CountDownTimer.js +0 -1
- package/dist/esm/components/Common/WarningMessage.js +4 -2
- package/dist/esm/components/Common/guideLink.js +4 -6
- package/dist/esm/components/ErrorFallback.js +11 -11
- package/dist/esm/components/HeaderWithMenu.js +1 -1
- package/dist/esm/components/Icons/Wallets/Xverse.js +3 -0
- package/dist/esm/components/Icons/Wallets/index.js +1 -0
- package/dist/esm/components/Input/Address/AddressPicker/index.js +15 -12
- package/dist/esm/components/Input/Amount/Balance.js +1 -1
- package/dist/esm/components/Input/Amount/ExchangeReceiveAmount.js +8 -0
- package/dist/esm/components/Input/Amount/MinMax.js +1 -1
- package/dist/esm/components/Input/Amount/PriceImpact.js +5 -38
- package/dist/esm/components/Input/Amount/ReceiveAmount.js +2 -2
- package/dist/esm/components/Input/Amount/index.js +3 -3
- package/dist/esm/components/Input/DestinationPicker.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Content.js +2 -2
- package/dist/esm/components/Input/RoutePicker/RouterPickerWalletConnect.js +5 -5
- package/dist/esm/components/Input/RoutePicker/Routes.js +18 -18
- package/dist/esm/components/Input/RoutePicker/Rows/CollapsableHeader.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Rows/CollapsibleRow.js +3 -3
- package/dist/esm/components/Input/RoutePicker/Rows/StickyHeader.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Rows/SuggestionsHeader.js +55 -0
- package/dist/esm/components/Input/RoutePicker/Rows/TitleRow.js +11 -0
- package/dist/esm/components/Input/RoutePicker/Rows/index.js +5 -6
- package/dist/esm/components/Input/RoutePicker/index.js +2 -2
- package/dist/esm/components/Input/SourceWalletPicker.js +6 -4
- package/dist/esm/components/Menu/index.js +1 -1
- package/dist/esm/components/Pages/Campaigns/Details/Leaderboard.js +2 -2
- package/dist/esm/components/Pages/Campaigns/Details/Rewards.js +2 -2
- package/dist/esm/components/Pages/Campaigns/Details/index.js +2 -3
- package/dist/esm/components/Pages/Campaigns/index.js +3 -4
- package/dist/esm/components/Pages/Swap/Form/ExchangeForm.js +21 -19
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Rate.js +5 -4
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Refuel.js +2 -2
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.js +51 -14
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.js +1 -1
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.js +3 -3
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/index.js +8 -9
- package/dist/esm/components/Pages/Swap/Form/Form.js +27 -3
- package/dist/esm/components/Pages/Swap/Form/FormWrapper.js +6 -8
- package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +11 -21
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
- package/dist/esm/components/Pages/Swap/Withdraw/Failed.js +12 -8
- package/dist/esm/components/Pages/Swap/Withdraw/ManualWithdraw.js +28 -9
- package/dist/esm/components/Pages/Swap/Withdraw/NotFound.js +15 -4
- package/dist/esm/components/Pages/Swap/Withdraw/Processing/Processing.js +36 -41
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/Summary.js +1 -1
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/index.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/SwapDetails.js +9 -7
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.js +43 -0
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/buttons.js +118 -71
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/index.js +56 -65
- package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferButton.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferContent.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/Withdraw.js +3 -3
- package/dist/esm/components/Pages/Swap/Withdraw/index.js +5 -4
- package/dist/esm/components/Pages/Swap/Withdraw/messages/TransactionMessages.js +14 -15
- package/dist/esm/components/Pages/SwapHistory/History.js +1 -1
- package/dist/esm/components/Pages/SwapHistory/index.js +4 -4
- package/dist/esm/components/Wallet/WalletComponents/WalletsList.js +1 -1
- package/dist/esm/components/Wallet/WalletModal/Connector.js +2 -2
- package/dist/esm/components/Wallet/WalletModal/ConnectorsList.js +5 -1
- package/dist/esm/components/Wallet/WalletModal/index.js +3 -1
- package/dist/esm/components/Wallet/WalletProviders/index.js +4 -2
- package/dist/esm/components/Widget/Content.js +2 -2
- package/dist/esm/components/Widget/Footer.js +1 -1
- package/dist/esm/components/Widget/Index.js +1 -1
- package/dist/esm/components/WidgetLoading.js +9 -2
- package/dist/esm/context/ErrorProvider.js +14 -0
- package/dist/esm/context/LayerswapProvider.js +6 -5
- package/dist/esm/context/callbackProvider.js +54 -52
- package/dist/esm/context/resolverContext.js +7 -2
- package/dist/esm/context/swap.js +10 -13
- package/dist/esm/context/{balanceAccounts.js → swapAccounts.js} +17 -17
- package/dist/esm/context/validationContext.js +1 -1
- package/dist/esm/context/walletProviders.js +7 -1
- package/dist/esm/context/withdrawalContext.js +2 -2
- package/dist/esm/exports/internal.js +4 -3
- package/dist/esm/helpers/filterSourceNetworks.js +23 -0
- package/dist/esm/helpers/getSettings/getSettings.js +18 -13
- package/dist/esm/helpers/routes.js +4 -1
- package/dist/esm/hooks/useAllWithdrawalBalances.js +6 -5
- package/dist/esm/hooks/useFormRoutes.js +16 -8
- package/dist/esm/hooks/useFormValidation.js +5 -4
- package/dist/esm/hooks/useRouteValidation.js +1 -1
- package/dist/esm/hooks/useSwrSwaps.js +1 -1
- package/dist/esm/hooks/useTransfer.js +9 -0
- package/dist/esm/hooks/useWallet.js +7 -7
- package/dist/esm/lib/AppSettings.js +27 -16
- package/dist/esm/lib/ErrorHandler.js +6 -0
- package/dist/esm/lib/apiClients/layerSwapApiClient.js +12 -35
- package/dist/esm/lib/balances/balanceResolver.js +9 -13
- package/dist/esm/lib/fees.js +50 -0
- package/dist/esm/lib/resolvers/resolverService.js +10 -1
- package/dist/esm/lib/transfers/index.js +1 -0
- package/dist/esm/lib/transfers/transferResolver.js +14 -0
- package/dist/esm/stores/balanceStore.js +0 -1
- package/dist/esm/stores/logStore.js +11 -0
- package/dist/esm/types/balance.js +8 -9
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/logEvents.js +1 -0
- package/dist/index.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/Models/Balance.d.ts +1 -1
- package/dist/types/Models/LayerSwapSettings.d.ts +7 -0
- package/dist/types/Models/LayerSwapSettings.d.ts.map +1 -1
- package/dist/types/Models/Theme.d.ts.map +1 -1
- package/dist/types/components/Buttons/submitButton.d.ts +1 -1
- package/dist/types/components/Buttons/submitButton.d.ts.map +1 -1
- package/dist/types/components/Common/ConnectWalletButton.d.ts +1 -1
- package/dist/types/components/Common/ConnectWalletButton.d.ts.map +1 -1
- package/dist/types/components/Common/CountDownTimer.d.ts.map +1 -1
- package/dist/types/components/Common/WarningMessage.d.ts.map +1 -1
- package/dist/types/components/Common/guideLink.d.ts.map +1 -1
- package/dist/types/components/ErrorFallback.d.ts.map +1 -1
- package/dist/types/components/HeaderWithMenu.d.ts.map +1 -1
- package/dist/types/components/Icons/Wallets/Xverse.d.ts +4 -0
- package/dist/types/components/Icons/Wallets/Xverse.d.ts.map +1 -0
- package/dist/types/components/Icons/Wallets/index.d.ts +1 -0
- package/dist/types/components/Icons/Wallets/index.d.ts.map +1 -1
- package/dist/types/components/Input/Address/AddressNote.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/AddressBook.d.ts +3 -3
- package/dist/types/components/Input/Address/AddressPicker/AddressButton.d.ts +3 -3
- package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/ConnectedWallets.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/ManualAddressInput.d.ts +4 -4
- package/dist/types/components/Input/Address/AddressPicker/index.d.ts +4 -4
- package/dist/types/components/Input/Address/AddressPicker/index.d.ts.map +1 -1
- package/dist/types/components/Input/Address/index.d.ts +1 -1
- package/dist/types/components/Input/Amount/Balance.d.ts +1 -1
- package/dist/types/components/Input/Amount/Balance.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts +11 -0
- package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts.map +1 -0
- package/dist/types/components/Input/Amount/MinMax.d.ts +1 -1
- package/dist/types/components/Input/Amount/PriceImpact.d.ts +2 -6
- package/dist/types/components/Input/Amount/PriceImpact.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/ReceiveAmount.d.ts +2 -3
- package/dist/types/components/Input/Amount/ReceiveAmount.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/helpers.d.ts +2 -2
- package/dist/types/components/Input/Amount/index.d.ts +1 -1
- package/dist/types/components/Input/CexPicker.d.ts +1 -1
- package/dist/types/components/Input/DestinationPicker.d.ts +1 -1
- package/dist/types/components/Input/DestinationPicker.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Content.d.ts +5 -5
- package/dist/types/components/Input/RoutePicker/Content.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/RouterPickerWalletConnect.d.ts +1 -1
- package/dist/types/components/Input/RoutePicker/Routes.d.ts +4 -8
- package/dist/types/components/Input/RoutePicker/Routes.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts +3 -4
- package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts +6 -5
- package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts +3 -4
- package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts +7 -0
- package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts.map +1 -0
- package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts +7 -0
- package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts.map +1 -0
- package/dist/types/components/Input/RoutePicker/Rows/index.d.ts +5 -5
- package/dist/types/components/Input/RoutePicker/Rows/index.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/index.d.ts +1 -1
- package/dist/types/components/Input/RoutePicker/index.d.ts.map +1 -1
- package/dist/types/components/Input/SourcePicker.d.ts +1 -1
- package/dist/types/components/Input/SourceWalletPicker.d.ts.map +1 -1
- package/dist/types/components/Pages/Campaigns/Details/Leaderboard.d.ts +1 -1
- package/dist/types/components/Pages/Campaigns/Details/Rewards.d.ts +1 -1
- package/dist/types/components/Pages/Campaigns/Details/index.d.ts +1 -2
- package/dist/types/components/Pages/Campaigns/Details/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Campaigns/index.d.ts +2 -3
- package/dist/types/components/Pages/Campaigns/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts +3 -1
- package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts +7 -6
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/ReceiveAmounts.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/RefuelModal.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Slippage.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts +3 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.d.ts +4 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts +4 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/utils.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts +7 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/Form.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/FormButton.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/SwapFormValues.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Withdraw/Failed.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts +4 -3
- package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/NotFound.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/QuoteUpdate.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Summary/Summary.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapQuoteDetails.d.ts +3 -3
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts +6 -0
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts.map +1 -0
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts +4 -3
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferContent.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/index.d.ts +1 -2
- package/dist/types/components/Pages/Swap/Withdraw/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts +3 -4
- package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts.map +1 -1
- package/dist/types/components/Pages/SwapHistory/HistorySummary.d.ts +2 -2
- package/dist/types/components/Pages/SwapHistory/StatusIcons.d.ts +1 -1
- package/dist/types/components/Pages/SwapHistory/SwapDetailsComponent.d.ts +1 -1
- package/dist/types/components/Pages/SwapHistory/index.d.ts +3 -1
- package/dist/types/components/Pages/SwapHistory/index.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts +3 -3
- package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/Connector.d.ts +2 -1
- package/dist/types/components/Wallet/WalletModal/Connector.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts +1 -1
- package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/index.d.ts +1 -1
- package/dist/types/components/Wallet/WalletModal/index.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletProviders/index.d.ts +3 -1
- package/dist/types/components/Wallet/WalletProviders/index.d.ts.map +1 -1
- package/dist/types/components/Widget/Content.d.ts +2 -1
- package/dist/types/components/Widget/Content.d.ts.map +1 -1
- package/dist/types/components/Widget/Footer.d.ts +2 -1
- package/dist/types/components/Widget/Footer.d.ts.map +1 -1
- package/dist/types/components/Widget/Index.d.ts +3 -2
- package/dist/types/components/Widget/Index.d.ts.map +1 -1
- package/dist/types/components/WidgetLoading.d.ts.map +1 -1
- package/dist/types/components/shadcn/command.d.ts +9 -52
- package/dist/types/components/shadcn/command.d.ts.map +1 -1
- package/dist/types/context/ErrorProvider.d.ts +3 -0
- package/dist/types/context/ErrorProvider.d.ts.map +1 -0
- package/dist/types/context/LayerswapProvider.d.ts +22 -4
- package/dist/types/context/LayerswapProvider.d.ts.map +1 -1
- package/dist/types/context/callbackProvider.d.ts +6 -10
- package/dist/types/context/callbackProvider.d.ts.map +1 -1
- package/dist/types/context/resolverContext.d.ts.map +1 -1
- package/dist/types/context/swap.d.ts +7 -7
- package/dist/types/context/swap.d.ts.map +1 -1
- package/dist/types/context/{balanceAccounts.d.ts → swapAccounts.d.ts} +9 -9
- package/dist/types/context/swapAccounts.d.ts.map +1 -0
- package/dist/types/context/walletProviders.d.ts.map +1 -1
- package/dist/types/context/withdrawalContext.d.ts +2 -0
- package/dist/types/context/withdrawalContext.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +9 -7
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/helpers/accountSelectHelper.d.ts +1 -1
- package/dist/types/helpers/balanceHelper.d.ts +2 -2
- package/dist/types/helpers/filterSourceNetworks.d.ts +4 -0
- package/dist/types/helpers/filterSourceNetworks.d.ts.map +1 -0
- package/dist/types/helpers/getSettings/getSettings.d.ts +1 -1
- package/dist/types/helpers/getSettings/getSettings.d.ts.map +1 -1
- package/dist/types/helpers/routes.d.ts +1 -1
- package/dist/types/helpers/routes.d.ts.map +1 -1
- package/dist/types/helpers/tokenHelper.d.ts +2 -2
- package/dist/types/hooks/useAllWithdrawalBalances.d.ts +2 -1
- package/dist/types/hooks/useAllWithdrawalBalances.d.ts.map +1 -1
- package/dist/types/hooks/useFee.d.ts +1 -1
- package/dist/types/hooks/useFormRoutes.d.ts +2 -3
- package/dist/types/hooks/useFormRoutes.d.ts.map +1 -1
- package/dist/types/hooks/useFormValidation.d.ts +2 -1
- package/dist/types/hooks/useFormValidation.d.ts.map +1 -1
- package/dist/types/hooks/useSwapHistoryData.d.ts +2 -2
- package/dist/types/hooks/useTransfer.d.ts +5 -0
- package/dist/types/hooks/useTransfer.d.ts.map +1 -0
- package/dist/types/hooks/useWallet.d.ts +3 -3
- package/dist/types/hooks/useWallet.d.ts.map +1 -1
- package/dist/types/lib/AppSettings.d.ts +25 -16
- package/dist/types/lib/AppSettings.d.ts.map +1 -1
- package/dist/types/lib/ErrorHandler.d.ts +3 -0
- package/dist/types/lib/ErrorHandler.d.ts.map +1 -0
- package/dist/types/lib/apiClients/layerSwapApiClient.d.ts +1 -9
- package/dist/types/lib/apiClients/layerSwapApiClient.d.ts.map +1 -1
- package/dist/types/lib/balances/balanceResolver.d.ts +3 -3
- package/dist/types/lib/balances/balanceResolver.d.ts.map +1 -1
- package/dist/types/lib/balances/helpers.d.ts +1 -1
- package/dist/types/lib/balances/useBalance.d.ts +1 -1
- package/dist/types/lib/fees.d.ts +16 -0
- package/dist/types/lib/fees.d.ts.map +1 -1
- package/dist/types/lib/gases/gasResolver.d.ts +2 -2
- package/dist/types/lib/gases/useSWRGas.d.ts +3 -3
- package/dist/types/lib/generateSwapInitialValues.d.ts +1 -1
- package/dist/types/lib/nft/nftBalanceResolver.d.ts +1 -1
- package/dist/types/lib/resolvers/resolverService.d.ts +8 -5
- package/dist/types/lib/resolvers/resolverService.d.ts.map +1 -1
- package/dist/types/lib/sorting.d.ts +1 -1
- package/dist/types/lib/transfers/index.d.ts +2 -0
- package/dist/types/lib/transfers/index.d.ts.map +1 -0
- package/dist/types/lib/transfers/transferResolver.d.ts +7 -0
- package/dist/types/lib/transfers/transferResolver.d.ts.map +1 -0
- package/dist/types/stores/balanceStore.d.ts.map +1 -1
- package/dist/types/stores/logStore.d.ts +8 -0
- package/dist/types/stores/logStore.d.ts.map +1 -0
- package/dist/types/stores/walletStore.d.ts +1 -1
- package/dist/types/types/balance.d.ts +2 -2
- package/dist/types/types/balance.d.ts.map +1 -1
- package/dist/types/types/gas.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/logEvents.d.ts +41 -0
- package/dist/types/types/logEvents.d.ts.map +1 -0
- package/dist/types/types/nft.d.ts +1 -1
- package/dist/types/types/transfer.d.ts +7 -2
- package/dist/types/types/transfer.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +23 -5
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/esm/helpers/querryHelper.js +0 -13
- package/dist/esm/lib/logError.js +0 -17
- package/dist/types/context/balanceAccounts.d.ts.map +0 -1
- package/dist/types/helpers/querryHelper.d.ts +0 -3
- package/dist/types/helpers/querryHelper.d.ts.map +0 -1
- package/dist/types/lib/logError.d.ts +0 -3
- package/dist/types/lib/logError.d.ts.map +0 -1
package/dist/esm/Models/Theme.js
CHANGED
|
@@ -209,5 +209,44 @@ export const THEME_COLORS = {
|
|
|
209
209
|
'900': '0, 0, 0',
|
|
210
210
|
'text': '182, 182, 182',
|
|
211
211
|
},
|
|
212
|
+
},
|
|
213
|
+
"immutablePlay": {
|
|
214
|
+
tertiary: '182, 182, 182',
|
|
215
|
+
buttonTextColor: '19, 19, 19',
|
|
216
|
+
logo: '187, 187, 187',
|
|
217
|
+
header: {
|
|
218
|
+
hideMenu: true,
|
|
219
|
+
hideTabs: true,
|
|
220
|
+
hideWallets: true,
|
|
221
|
+
},
|
|
222
|
+
cardBackgroundStyle: {
|
|
223
|
+
backgroundColor: 'transparent',
|
|
224
|
+
},
|
|
225
|
+
primary: {
|
|
226
|
+
DEFAULT: '243, 243, 243',
|
|
227
|
+
'100': '255, 255, 255',
|
|
228
|
+
'200': '255, 255, 255',
|
|
229
|
+
'300': '255, 255, 255',
|
|
230
|
+
'400': '255, 255, 255',
|
|
231
|
+
'500': '243, 243, 243',
|
|
232
|
+
'600': '215, 215, 215',
|
|
233
|
+
'700': '187, 187, 187',
|
|
234
|
+
'800': '159, 159, 159',
|
|
235
|
+
'900': '131, 131, 131',
|
|
236
|
+
'text': '243, 243, 243',
|
|
237
|
+
},
|
|
238
|
+
secondary: {
|
|
239
|
+
DEFAULT: '37, 37, 37',
|
|
240
|
+
'100': '119, 119, 119',
|
|
241
|
+
'200': '98, 98, 98',
|
|
242
|
+
'300': '78, 78, 78',
|
|
243
|
+
'400': '57, 57, 57',
|
|
244
|
+
'500': '37, 37, 37',
|
|
245
|
+
'600': '13, 13, 13',
|
|
246
|
+
'700': '13, 13, 13',
|
|
247
|
+
'800': '13, 13, 13',
|
|
248
|
+
'900': '0, 0, 0',
|
|
249
|
+
'text': '182, 182, 182',
|
|
250
|
+
},
|
|
212
251
|
}
|
|
213
252
|
};
|
|
@@ -13,9 +13,10 @@ const SubmitButton = ({ isDisabled, isSubmitting, icon, children, type, onClick,
|
|
|
13
13
|
return (_jsxs("button", { disabled: isDisabled || isSubmitting, type: type, onClick: onClick, style: style, className: clsx('enabled:active:animate-press-down text-primary focus:outline-none focus:ring-0 items-center space-x-1 disabled:bg-secondary-300 disabled:text-secondary-text/50 disabled:cursor-not-allowed relative w-full flex justify-center font-medium rounded-xl transform hover:brightness-125 transition duration-200 ease-in-out', {
|
|
14
14
|
className,
|
|
15
15
|
'text-primary-buttonTextColor bg-primary-500': buttonStyle === 'filled',
|
|
16
|
+
'text-primary-text bg-secondary-300 hover:bg-secondary-400': buttonStyle === 'secondary',
|
|
16
17
|
'py-4 px-4': size === 'large',
|
|
17
18
|
'py-3 px-2 md:px-3': size === 'medium',
|
|
18
|
-
'py-
|
|
19
|
+
'py-2.5 px-2.5 text-sm': size === 'small',
|
|
19
20
|
}), children: [_jsxs("span", { className: `${button_align === "right" ? 'order-last' : 'order-first'} ${text_align === 'center' ? "absolute left-0 inset-y-0 flex items-center pl-3" : "relative"}`, children: [(!isDisabled && !isSubmitting) && icon, isSubmitting ?
|
|
20
21
|
_jsx(SpinIcon, { className: "animate-spin h-5 w-5" })
|
|
21
22
|
: null] }), _jsx("span", { className: `grow ${text_align === 'left' ? 'text-left' : 'text-center'}`, children: children })] }));
|
|
@@ -7,16 +7,22 @@ import { classNames } from "../../components/utils/classNames";
|
|
|
7
7
|
const ConnectWalletButton = ({ provider, onConnect, descriptionText, ...rest }) => {
|
|
8
8
|
const [isLoading, setIsLoading] = useState(false);
|
|
9
9
|
const { connect } = useConnectModal();
|
|
10
|
+
const isProviderReady = typeof provider?.ready === 'boolean' ? provider.ready : true;
|
|
10
11
|
const handleConnect = async () => {
|
|
12
|
+
if (!isProviderReady)
|
|
13
|
+
return;
|
|
11
14
|
setIsLoading(true);
|
|
12
15
|
const result = await connect(provider);
|
|
13
16
|
if (onConnect && result)
|
|
14
17
|
onConnect(result);
|
|
15
18
|
setIsLoading(false);
|
|
16
19
|
};
|
|
17
|
-
return _jsx("button", { ...rest, type: "button", onClick: handleConnect, className: classNames(`py-5 px-6 bg-secondary-500 hover:bg-secondary-400 transition-colors duration-200 rounded-xl ${isLoading && 'cursor-progress opacity-80'}`, rest.className), children: _jsxs("div", { className: "flex flex-row justify-between gap-9 items-stretch", children: [_jsx(ResolveConnectorIcon, { connector: provider?.name, iconClassName: "w-10 h-10 p-0.5 rounded-lg bg-secondary-800 border border-secondary-400", className: "grid grid-cols-2 gap-1 min-w-fit" }), _jsxs("div", { className: "h-full space-y-2", children: [_jsx("p", { className: "text-sm font-medium text-secondary-text text-start", children: descriptionText ?? 'Connect your wallet to browse and select from your addresses' }), _jsx("div", { className: "bg-primary-700/30 border-none text-primary! py-2 rounded-lg text-base font-semibold", children:
|
|
18
|
-
_jsxs("div", { className: "flex items-center gap-1 justify-center", children: [_jsx(RefreshCw, { className: "h-3 w-auto animate-spin" }), _jsx("span", { className: "ml-1", children: "
|
|
20
|
+
return _jsx("button", { ...rest, type: "button", onClick: handleConnect, disabled: !isProviderReady || rest.disabled, className: classNames(`py-5 px-6 bg-secondary-500 hover:bg-secondary-400 transition-colors duration-200 rounded-xl ${(isLoading || !isProviderReady) && 'cursor-progress opacity-80'} disabled:opacity-50 disabled:cursor-not-allowed`, rest.className), children: _jsxs("div", { className: "flex flex-row justify-between gap-9 items-stretch", children: [_jsx(ResolveConnectorIcon, { connector: provider?.name, iconClassName: "w-10 h-10 p-0.5 rounded-lg bg-secondary-800 border border-secondary-400", className: "grid grid-cols-2 gap-1 min-w-fit" }), _jsxs("div", { className: "h-full space-y-2", children: [_jsx("p", { className: "text-sm font-medium text-secondary-text text-start", children: descriptionText ?? 'Connect your wallet to browse and select from your addresses' }), _jsx("div", { className: "bg-primary-700/30 border-none text-primary! py-2 rounded-lg text-base font-semibold", children: !isProviderReady ?
|
|
21
|
+
_jsxs("div", { className: "flex items-center gap-1 justify-center", children: [_jsx(RefreshCw, { className: "h-3 w-auto animate-spin" }), _jsx("span", { className: "ml-1", children: "Initializing..." })] })
|
|
19
22
|
:
|
|
20
|
-
|
|
23
|
+
isLoading ?
|
|
24
|
+
_jsxs("div", { className: "flex items-center gap-1 justify-center", children: [_jsx(RefreshCw, { className: "h-3 w-auto animate-spin" }), _jsx("span", { className: "ml-1", children: "Connecting..." })] })
|
|
25
|
+
:
|
|
26
|
+
_jsx(_Fragment, { children: "Connect Now" }) })] })] }) });
|
|
21
27
|
};
|
|
22
28
|
export default ConnectWalletButton;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { SwapStatus } from "../../Models/SwapStatus";
|
|
4
4
|
import { TransactionType } from "../../lib/apiClients/layerSwapApiClient";
|
|
5
|
-
// import posthog from "posthog-js";
|
|
6
5
|
const CountdownTimer = ({ initialTime, swapDetails, onThresholdChange }) => {
|
|
7
6
|
const [elapsedTimer, setElapsedTimer] = useState(0);
|
|
8
7
|
const [thresholdElapsed, setThresholdElapsed] = useState(false);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Scroll } from "lucide-react";
|
|
3
|
+
import InfoIcon from "../../components/Icons/InfoIcon";
|
|
4
|
+
import { ICON_CLASSES_WARNING } from "../../components/Pages/Swap/Form/SecondaryComponents/validationError/constants";
|
|
3
5
|
function constructIcons(messageType) {
|
|
4
6
|
let iconStyle;
|
|
5
7
|
switch (messageType) {
|
|
6
8
|
case 'warning':
|
|
7
|
-
iconStyle = _jsx(
|
|
9
|
+
iconStyle = _jsx(InfoIcon, { className: ICON_CLASSES_WARNING });
|
|
8
10
|
break;
|
|
9
11
|
case 'informing':
|
|
10
12
|
iconStyle = _jsx(Scroll, { className: "sm:h-5 h-4 text-primary-text inline sm:block" });
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import SecondaryButton from "../Buttons/secondaryButton";
|
|
4
|
-
import { DocIframe } from "./docInIframe";
|
|
5
|
-
import Modal from "../Modal/modal";
|
|
6
4
|
export default function GuideLink({ userGuideUrl, text, button, buttonClassNames }) {
|
|
7
5
|
const [showGuide, setShowGuide] = useState(false);
|
|
8
|
-
return (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
return (_jsx(_Fragment, { children: button ?
|
|
7
|
+
_jsx(SecondaryButton, { onClick: () => setShowGuide(true), className: buttonClassNames, children: button })
|
|
8
|
+
:
|
|
9
|
+
_jsxs("a", { target: "_blank", href: userGuideUrl, className: 'text-primary cursor-pointer hover:text-primary-400', children: ["\u00A0", _jsx("span", { children: text })] }) }));
|
|
12
10
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback } from "react";
|
|
2
|
+
import { useCallback, useEffect } from "react";
|
|
3
3
|
import { useIntercom } from "react-use-intercom";
|
|
4
4
|
import { Home, RotateCcw } from "lucide-react";
|
|
5
|
-
// import posthog from "posthog-js";
|
|
6
5
|
import MessageComponent from "./Common/MessageComponent";
|
|
7
6
|
import NotFoundIcon from "./Icons/NotFoundIcon";
|
|
8
7
|
import SubmitButton from "./Buttons/submitButton";
|
|
8
|
+
import { ErrorHandler } from "../lib/ErrorHandler";
|
|
9
9
|
export default function ErrorFallback({ error, resetErrorBoundary }) {
|
|
10
10
|
const { boot, show } = useIntercom();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
ErrorHandler({
|
|
13
|
+
type: "ErrorFallback",
|
|
14
|
+
message: error.message,
|
|
15
|
+
name: error.name,
|
|
16
|
+
stack: error.stack,
|
|
17
|
+
cause: error.cause
|
|
18
|
+
});
|
|
19
|
+
}, [error]);
|
|
20
20
|
const startIntercom = useCallback(() => {
|
|
21
21
|
boot();
|
|
22
22
|
show();
|
|
@@ -13,7 +13,7 @@ function HeaderWithMenu({ goBack, contextualMenu }) {
|
|
|
13
13
|
LayerSwapApiClient.apiKey !== AppSettings.LayerswapApiKeys['testnet'];
|
|
14
14
|
const headerConfigs = AppSettings.ThemeData?.header;
|
|
15
15
|
return (_jsxs("div", { className: "items-center justify-between sm:flex sm:items-center grid grid-cols-5 w-full sm:grid-cols-none sm:grid-none mt-2 pb-2 px-4", children: [_jsx("div", { className: "self-center col-start-1 md:col-start-2 md:col-span-3 justify-self-start md:justify-self-center flex items-center gap-2", children: goBack ?
|
|
16
|
-
_jsx(IconButton, { onClick: goBack, "aria-label": "Go back",
|
|
16
|
+
_jsx("div", { className: "ml-0", children: _jsx(IconButton, { onClick: goBack, "aria-label": "Go back", icon: _jsx(ArrowLeft, { strokeWidth: "2" }) }) })
|
|
17
17
|
:
|
|
18
18
|
headerConfigs?.hideTabs ? null :
|
|
19
19
|
AppSettings.ThemeData?.enableWideVersion == true ?
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
const Xverse = (props) => _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "300", height: "300", viewBox: "0 0 300 300", fill: "none", ...props, children: [_jsx("rect", { width: "300", height: "300", fill: "#0F0F0F" }), _jsx("path", { d: "M266 265.11V221.791C266 220.073 265.329 218.435 264.132 217.218L82.9028 32.8997C81.7061 31.6825 80.0952 31 78.4064 31H35.8141C33.7113 31 32 32.7405 32 34.8791V75.1258C32 76.8435 32.6711 78.4815 33.8679 79.6987L98.9197 145.859C100.407 147.372 100.407 149.829 98.9197 151.342L33.1185 218.264C32.4027 218.992 32 219.982 32 221.006V265.11C32 267.246 33.7113 268.989 35.8141 268.989H106.984C109.087 268.989 110.798 267.246 110.798 265.11V239.127C110.798 238.103 111.201 237.114 111.917 236.386L147.216 200.484C148.704 198.971 151.12 198.971 152.608 200.484L218.107 267.1C219.303 268.317 220.914 269 222.603 269H262.175C264.278 269 265.989 267.258 265.989 265.121L266 265.11Z", fill: "white" }), _jsx("path", { d: "M170.853 88.6326H206.533C208.648 88.6326 210.372 90.3964 210.372 92.5611V129.062C210.372 132.567 214.515 134.32 216.933 131.834L265.879 81.6807C266.595 80.9475 267 79.9512 267 78.9089V34.9857C267 32.8211 265.285 31.0573 263.159 31.0573L219.586 31C218.568 31 217.594 31.4123 216.866 32.1453L168.132 81.9211C165.714 84.395 167.427 88.6326 170.842 88.6326H170.853Z", fill: "#EE7A30" })] });
|
|
3
|
+
export default Xverse;
|
|
@@ -10,7 +10,7 @@ import AddressBook from "./AddressBook";
|
|
|
10
10
|
import AddressButton from "./AddressButton";
|
|
11
11
|
import { useInitialSettings } from "../../../../context/settings";
|
|
12
12
|
import ConnectedWallets from "./ConnectedWallets";
|
|
13
|
-
import { useSelectedAccount,
|
|
13
|
+
import { useSelectedAccount, useSelectSwapAccount } from "../../../../context/swapAccounts";
|
|
14
14
|
import VaulDrawer from "../../../../components/Modal/vaulModal";
|
|
15
15
|
export var AddressGroup;
|
|
16
16
|
(function (AddressGroup) {
|
|
@@ -22,14 +22,15 @@ export var AddressGroup;
|
|
|
22
22
|
const AddressPicker = forwardRef(function Address({ showAddressModal, setShowAddressModal, name, canFocus, close, address_book, partner, children }, ref) {
|
|
23
23
|
const { values, setFieldValue } = useFormikContext();
|
|
24
24
|
const initialSettings = useInitialSettings();
|
|
25
|
-
const { destination_address, to: destination } = values;
|
|
26
|
-
const selectDestinationAccount =
|
|
27
|
-
const { provider, unAvailableWallets } = useWallet(destination, '
|
|
25
|
+
const { destination_address, to: destination, toExchange } = values;
|
|
26
|
+
const selectDestinationAccount = useSelectSwapAccount("to");
|
|
27
|
+
const { provider, unAvailableWallets } = useWallet(destination, 'autofill');
|
|
28
28
|
const connectedWallets = provider?.connectedWallets?.filter(w => !w.isNotAvailable) || [];
|
|
29
29
|
const defaultAccount = useSelectedAccount("to", values.to?.name);
|
|
30
30
|
const connectedWalletskey = connectedWallets?.map(w => w.addresses.join('')).join('');
|
|
31
31
|
const [manualAddress, setManualAddress] = useState('');
|
|
32
|
-
|
|
32
|
+
// Get manually added address from context (shared across all AddressPicker instances)
|
|
33
|
+
const manualAddressFromContext = defaultAccount?.id === 'manually_added' ? defaultAccount.address : undefined;
|
|
33
34
|
useEffect(() => {
|
|
34
35
|
if (destination_address && destination && !isValidAddress(destination_address, destination)) {
|
|
35
36
|
updateDestAddress('');
|
|
@@ -42,10 +43,11 @@ const AddressPicker = forwardRef(function Address({ showAddressModal, setShowAdd
|
|
|
42
43
|
address_book,
|
|
43
44
|
destination,
|
|
44
45
|
wallets: connectedWallets,
|
|
45
|
-
|
|
46
|
-
addressFromQuery: initialSettings.destination_address
|
|
46
|
+
manualAddressFromContext,
|
|
47
|
+
addressFromQuery: initialSettings.destination_address,
|
|
48
|
+
destination_address
|
|
47
49
|
});
|
|
48
|
-
}, [address_book, destination, connectedWallets,
|
|
50
|
+
}, [address_book, destination, connectedWallets, manualAddressFromContext, initialSettings.destination_address, connectedWalletskey]);
|
|
49
51
|
const destinationAddressItem = destination && destination_address ?
|
|
50
52
|
groupedAddresses?.find(a => a.address.toLowerCase() === destination_address.toLowerCase())
|
|
51
53
|
: undefined;
|
|
@@ -102,13 +104,13 @@ const AddressPicker = forwardRef(function Address({ showAddressModal, setShowAdd
|
|
|
102
104
|
return (_jsxs(_Fragment, { children: [_jsx(AddressButton, { addressItem: destinationAddressItem, openAddressModal: () => setShowAddressModal(true), connectedWallet: connectedWallet, partner: partner, destination: destination, children: children({ destination, addressItem: destinationAddressItem, connectedWallet: connectedWallet, partner }) }), _jsx(VaulDrawer, { header: 'Send To', show: showAddressModal, setShow: setShowAddressModal, modalId: "address", children: _jsx(VaulDrawer.Snap, { id: "item-1", children: _jsx("div", { className: 'w-full flex flex-col justify-between h-full text-primary-text min-h-[200px]', children: _jsxs("div", { className: 'flex flex-col self-center grow w-full space-y-5 h-full', children: [destination
|
|
103
105
|
&& provider
|
|
104
106
|
&& !connectedWallets.length &&
|
|
105
|
-
_jsx(ConnectWalletButton, { provider: provider, onConnect: onConnect }), _jsx(ManualAddressInput, { manualAddress: manualAddress, setManualAddress: setManualAddress, setNewAddress: (props) =>
|
|
107
|
+
_jsx(ConnectWalletButton, { provider: provider, onConnect: onConnect }), _jsx(ManualAddressInput, { manualAddress: manualAddress, setManualAddress: setManualAddress, setNewAddress: (props) => updateDestAddress(props?.address), values: values, partner: partner, name: name, inputReference: inputReference, setFieldValue: setFieldValue, close: close, addresses: groupedAddresses, connectedWallet: connectedWallet }), destination
|
|
106
108
|
&& provider
|
|
107
109
|
&& !manualAddress &&
|
|
108
110
|
_jsx(ConnectedWallets, { provider: provider, notCompatibleWallets: unAvailableWallets, onClick: (props) => handleSelectAddress(props.address), onConnect: onConnect, destination: destination, destination_address: destination_address }), addressBookAddresses && addressBookAddresses?.length > 0 && !manualAddress && destination &&
|
|
109
111
|
_jsx(AddressBook, { addressBook: addressBookAddresses, onSelectAddress: handleSelectAddress, destination: destination, destination_address: destination_address, partner: partner })] }) }) }) })] }));
|
|
110
112
|
});
|
|
111
|
-
const resolveAddressGroups = ({ address_book, destination, wallets,
|
|
113
|
+
const resolveAddressGroups = ({ address_book, destination, wallets, manualAddressFromContext, addressFromQuery, destination_address, }) => {
|
|
112
114
|
if (!destination)
|
|
113
115
|
return;
|
|
114
116
|
const filteredAddressBook = address_book?.filter(a => a.networks?.some(n => destination?.name === n) && isValidAddress(a.address, destination)) || [];
|
|
@@ -125,8 +127,9 @@ const resolveAddressGroups = ({ address_book, destination, wallets, newAddress,
|
|
|
125
127
|
if (recentlyUsedAddresses.length > 0) {
|
|
126
128
|
addresses = [...addresses, ...recentlyUsedAddresses];
|
|
127
129
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
// Include manually added address from context (shared across all instances)
|
|
131
|
+
if (manualAddressFromContext && isValidAddress(manualAddressFromContext, destination)) {
|
|
132
|
+
addresses.push({ address: manualAddressFromContext, group: AddressGroup.ManualAdded });
|
|
130
133
|
}
|
|
131
134
|
const uniqueAddresses = addresses.filter((a, index, self) => self.findIndex(t => addressFormat(t.address, destination) === addressFormat(a.address, destination)) === index);
|
|
132
135
|
return uniqueAddresses;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { truncateDecimals } from "../../../components/utils/RoundDecimals";
|
|
3
|
-
import { useSelectedAccount } from "../../../context/
|
|
3
|
+
import { useSelectedAccount } from "../../../context/swapAccounts";
|
|
4
4
|
import { useBalance } from "../../../lib/balances/useBalance";
|
|
5
5
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../../components/shadcn/tooltip";
|
|
6
6
|
import InfoIcon from "../../../components/Icons/InfoIcon";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import NumberFlow from "@number-flow/react";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
export const ExchangeReceiveAmount = ({ destination_token, fee, isFeeLoading }) => {
|
|
5
|
+
const receive_amount = fee?.quote.receive_amount;
|
|
6
|
+
const receiveAmountInUsd = receive_amount && destination_token && fee.quote?.destination_token?.price_in_usd ? (receive_amount * fee.quote.destination_token.price_in_usd).toFixed(2) : undefined;
|
|
7
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "w-full flex min-w-0 font-normal border-0 text-xl text-primary-text relative truncate items-baseline flex-row", children: [_jsx("div", { className: "flex items-center justify-start relative w-fit", children: _jsxs("div", { className: clsx("w-full flex items-center py-[3px] pr-2", { "animate-pulse-stronger": isFeeLoading }, { "text-secondary-text": !receive_amount }), children: [_jsx(NumberFlow, { value: receive_amount || 0, trend: 0, format: { maximumFractionDigits: fee?.quote.destination_token?.decimals || 2 } }), _jsx("span", { className: "ml-1", children: destination_token?.symbol })] }) }), _jsx("div", { className: "flex items-baseline space-x-2 mt-1.5", children: _jsx("span", { className: "text-sm leading-4 font-medium text-secondary-text h-5", children: _jsx(NumberFlow, { className: "p-0", value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD', maximumFractionDigits: receiveAmountInUsd ? 2 : 0 }, trend: 0 }) }) })] }) }));
|
|
8
|
+
};
|
|
@@ -4,7 +4,7 @@ import useSWRGas from "../../../lib/gases/useSWRGas";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { resolveMaxAllowedAmount } from "./helpers";
|
|
6
6
|
import { Tooltip, TooltipContent, TooltipTrigger } from "../../../components/shadcn/tooltip";
|
|
7
|
-
import { useSelectedAccount } from "../../../context/
|
|
7
|
+
import { useSelectedAccount } from "../../../context/swapAccounts";
|
|
8
8
|
import { useBalance } from "../../../lib/balances/useBalance";
|
|
9
9
|
import useWallet from "../../../hooks/useWallet";
|
|
10
10
|
const MinMax = (props) => {
|
|
@@ -3,45 +3,12 @@ import { useMemo } from "react";
|
|
|
3
3
|
import { Triangle } from "lucide-react";
|
|
4
4
|
import { Tooltip, TooltipArrow, TooltipContent, TooltipTrigger } from "../../../components/shadcn/tooltip";
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return receiveAmount * destinationTokenPriceUsd;
|
|
11
|
-
}, [receiveAmount, destinationTokenPriceUsd]);
|
|
12
|
-
const fromAmountUSD = useMemo(() => {
|
|
13
|
-
if (!requestedAmount || !sourceTokenPriceUsd)
|
|
14
|
-
return undefined;
|
|
15
|
-
return requestedAmount * sourceTokenPriceUsd;
|
|
16
|
-
}, [requestedAmount, sourceTokenPriceUsd]);
|
|
17
|
-
const priceImpact = useMemo(() => {
|
|
18
|
-
if (fromAmountUSD === undefined || toAmountUSD === undefined)
|
|
19
|
-
return undefined;
|
|
20
|
-
return (toAmountUSD - fromAmountUSD);
|
|
21
|
-
}, [fromAmountUSD, toAmountUSD]);
|
|
22
|
-
const layerswapFees = useMemo(() => {
|
|
23
|
-
if (serviceFee == null || sourceTokenPriceUsd == null)
|
|
24
|
-
return undefined;
|
|
25
|
-
return (serviceFee * sourceTokenPriceUsd);
|
|
26
|
-
}, [serviceFee, sourceTokenPriceUsd]);
|
|
27
|
-
const bridgeExpenses = useMemo(() => {
|
|
28
|
-
if (bridgeFee == null || sourceTokenPriceUsd == null)
|
|
29
|
-
return undefined;
|
|
30
|
-
return (bridgeFee * sourceTokenPriceUsd);
|
|
31
|
-
}, [bridgeFee, sourceTokenPriceUsd]);
|
|
32
|
-
const marketImpact = useMemo(() => {
|
|
33
|
-
if (priceImpact === undefined || layerswapFees === undefined || bridgeExpenses === undefined)
|
|
34
|
-
return undefined;
|
|
35
|
-
return (priceImpact + Number(layerswapFees) + Number(bridgeExpenses));
|
|
36
|
-
}, [priceImpact, layerswapFees, bridgeExpenses]);
|
|
37
|
-
const priceImpactPercentage = useMemo(() => {
|
|
38
|
-
if (fromAmountUSD === undefined || toAmountUSD === undefined)
|
|
39
|
-
return undefined;
|
|
40
|
-
return Number((((toAmountUSD - fromAmountUSD) / fromAmountUSD) * 100).toFixed(2));
|
|
41
|
-
}, [fromAmountUSD, toAmountUSD]);
|
|
42
|
-
if (priceImpact === undefined)
|
|
6
|
+
import { resolvePriceImpactValues } from "../../../lib/fees";
|
|
7
|
+
export const PriceImpact = ({ quote, className }) => {
|
|
8
|
+
const priceImpactValues = useMemo(() => quote ? resolvePriceImpactValues(quote) : undefined, [quote]);
|
|
9
|
+
if (priceImpactValues === undefined)
|
|
43
10
|
return null;
|
|
44
|
-
return (_jsx(_Fragment, { children: _jsxs(Tooltip, { openOnClick: true, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("span", { className: clsx("flex text-secondary-text items-center cursor-default hover:text-primary-text", className), children: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsx("span", { children: "(" }), _jsx(Triangle, { fill: "currentColor", className: `w-3
|
|
11
|
+
return (_jsx(_Fragment, { children: _jsxs(Tooltip, { openOnClick: true, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("span", { className: clsx("flex text-secondary-text items-center cursor-default hover:text-primary-text", className, { "text-warning-foreground hover:text-warning-foreground/80": priceImpactValues.highMarketPriceImpact }), children: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsx("span", { children: "(" }), _jsx(Triangle, { fill: "currentColor", className: `w-3 h-3 stroke-1 fill-current transition-transform ${priceImpactValues.priceImpact !== undefined && priceImpactValues.priceImpact < 0 ? "rotate-180" : ""}` }), _jsxs("span", { children: ["$", Math.abs(priceImpactValues.priceImpact || 0).toFixed(2)] }), _jsx("span", { children: ")" })] }) }) }), _jsxs(TooltipContent, { arrowClasses: "!bg-secondary-500 !fill-secondary-500", side: "top", align: "center", className: "bg-secondary-500! border-secondary-500! text-secondary-text! text-xs font-normal rounded-xl p-4! shadow-card", children: [_jsxs("p", { className: clsx("text-primary-text font-medium text-sm flex items-baseline space-x-0.5 mb-1", { "text-warning-foreground": priceImpactValues.highMarketPriceImpact }), children: [priceImpactValues.highMarketPriceImpact ? (priceImpactValues.criticalMarketPriceImpact ? _jsx("span", { children: "Critical price impact:" }) : _jsx("span", { children: "High price impact:" })) : _jsx("span", { children: "Price impact:" }), _jsx("span", { children: formatCurrency(priceImpactValues.priceImpact) }), _jsx("span", { className: clsx("text-secondary-text text-xs font-normal", { "text-warning-foreground": priceImpactValues.highMarketPriceImpact }), children: priceImpactValues.priceImpactPercentage ? `(${priceImpactValues.priceImpactPercentage < 0 ? "-" : "+"}${Math.abs(priceImpactValues.priceImpactPercentage)}%)` : "" })] }), _jsx("p", { children: "This is the difference in total USD value" }), _jsx("p", { children: "between the assets you send and the assets you receive." }), _jsxs("ul", { className: "mt-3 space-y-2 ", children: [_jsxs("li", { className: "list-none flex justify-between", children: [_jsx("span", { children: "Market impact" }), _jsx("span", { className: "text-primary-text", children: _jsx("span", { children: formatCurrency(priceImpactValues.marketImpact) }) })] }), _jsxs("li", { className: "list-none flex justify-between", children: [_jsx("span", { children: "Bridge expenses" }), _jsxs("span", { className: "text-primary-text", children: [_jsx("span", { children: priceImpactValues.bridgeExpenses?.toFixed(2) !== (0).toFixed(2) ? "-$" : "$" }), _jsx("span", { children: Math.abs(Number(priceImpactValues.bridgeExpenses)).toFixed(2) })] })] }), _jsxs("li", { className: "list-none flex justify-between", children: [_jsx("span", { children: "Layerswap fees" }), _jsxs("span", { className: "text-primary-text", children: [_jsx("span", { children: priceImpactValues.layerswapFees?.toFixed(2) !== (0).toFixed(2) ? "-$" : "$" }), _jsx("span", { children: Math.abs(Number(priceImpactValues.layerswapFees)).toFixed(2) })] })] })] }), _jsx(TooltipArrow, { className: "bg-secondary-500! fill-secondary-500!" })] })] }) }));
|
|
45
12
|
};
|
|
46
13
|
const formatCurrency = (value, decimals = 2) => {
|
|
47
14
|
if (value === undefined || isNaN(value))
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import NumberFlow from "@number-flow/react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import { PriceImpact } from "./PriceImpact";
|
|
5
|
-
export const ReceiveAmount = ({
|
|
5
|
+
export const ReceiveAmount = ({ destination_token, fee, isFeeLoading }) => {
|
|
6
6
|
const receive_amount = fee?.quote.receive_amount;
|
|
7
7
|
const receiveAmountInUsd = receive_amount && destination_token && fee.quote?.destination_token?.price_in_usd ? (receive_amount * fee.quote.destination_token.price_in_usd).toFixed(2) : undefined;
|
|
8
8
|
const quote = fee?.quote;
|
|
9
|
-
return (_jsx(_Fragment, { children: _jsxs("div", { className: "flex
|
|
9
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: "flex-col w-full flex min-w-0 font-normal border-0 text-[28px] leading-7 text-primary-text relative truncate", children: [_jsx("div", { className: "w-full flex items-center justify-start relative", children: _jsx("div", { className: clsx("w-full flex items-center pt-2 pr-3", { "animate-pulse-stronger": isFeeLoading }, { "text-secondary-text": !receive_amount }), children: _jsx(NumberFlow, { value: receive_amount || 0, trend: 0, format: { maximumFractionDigits: fee?.quote.destination_token?.decimals || 2 } }) }) }), _jsxs("div", { className: "flex items-baseline space-x-2 h-5", children: [_jsx("span", { className: "text-base leading-5 font-medium text-secondary-text h-5", children: _jsx(NumberFlow, { className: "p-0", value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD', maximumFractionDigits: receiveAmountInUsd ? 2 : 0 }, trend: 0 }) }), _jsx(PriceImpact, { className: "h-5 text-base leading-5", quote: quote })] })] }) }));
|
|
10
10
|
};
|
|
@@ -38,10 +38,10 @@ const AmountField = forwardRef(function AmountField({ usdPosition = "bottom", ac
|
|
|
38
38
|
const disabled = Boolean(fromExchange && !toCurrency);
|
|
39
39
|
return (_jsx(_Fragment, { children: _jsxs("div", { className: clsx("flex flex-col bg-secondary-500 space-y-0.5 relative w-full group", className, {
|
|
40
40
|
'focus-within:[&_.usd-suffix]:invisible': usdPosition === "right"
|
|
41
|
-
}), children: [_jsx(NumericInput, { disabled: disabled, placeholder: placeholder, step: isNaN(step) ? 0.01 : step, name: name, ref: amountRef, precision: fromCurrency?.precision, tempValue: actionValue, className: "w-full text-[28px] leading-[34px]
|
|
41
|
+
}), children: [_jsx(NumericInput, { disabled: disabled, placeholder: placeholder, step: isNaN(step) ? 0.01 : step, name: name, ref: amountRef, precision: fromCurrency?.precision, tempValue: actionValue, className: "w-full text-[28px] leading-[34px] rounded-xl text-primary-text focus:outline-none focus:border-none focus:ring-0 duration-300 ease-in-out !bg-secondary-500 !font-normal group-[.exchange-amount-field]:px-2.5 group-[.exchange-amount-field]:pb-2 group-[.exchange-amount-field]:pr-2 group-[.exchange-amount-field]:bg-secondary-300! group-[.exchange-amount-field]:pt-2! pl-0", onChange: e => {
|
|
42
42
|
/^[0-9]*[.,]?[0-9]*$/.test(e.target.value) && handleChange(e);
|
|
43
|
-
} }), _jsx("div", { className: clsx("usd-suffix text-base leading-5 font-medium text-secondary-text pointer-events-none", {
|
|
44
|
-
"absolute bottom-
|
|
43
|
+
} }), _jsx("div", { className: clsx("usd-suffix text-base group-[.exchange-amount-field]:text-sm leading-5 font-medium text-secondary-text pointer-events-none", {
|
|
44
|
+
"absolute bottom-[11px]": usdPosition === "right",
|
|
45
45
|
"h-5": usdPosition !== "right",
|
|
46
46
|
"text-secondary-text/45": !!actionValueInUsd
|
|
47
47
|
}, "group-hover:block"), ref: suffixRef, children: `${actionValueInUsd ?? requestedAmountInUsd ?? '$0'}` })] }) }));
|
|
@@ -11,12 +11,12 @@ import { useSwapDataState } from "../../context/swap";
|
|
|
11
11
|
const DestinationPicker = (props) => {
|
|
12
12
|
const { partner } = props;
|
|
13
13
|
const { values } = useFormikContext();
|
|
14
|
-
const {
|
|
14
|
+
const { toAsset: toCurrency } = values;
|
|
15
15
|
const quoteArgs = useMemo(() => transformFormValuesToQuoteArgs(values, true), [values]);
|
|
16
16
|
const { swapId } = useSwapDataState();
|
|
17
17
|
const quoteRefreshInterval = !!swapId ? 0 : undefined;
|
|
18
18
|
const { quote, isQuoteLoading } = useQuoteData(quoteArgs, quoteRefreshInterval);
|
|
19
|
-
return _jsxs("div", { className: "flex flex-col w-full bg-secondary-500 rounded-2xl p-4 pb-[15px] space-y-[27px]", children: [_jsxs("div", { className: "grid grid-cols-9 gap-2 items-center h-7", children: [_jsx("label", { htmlFor: "To", className: "block col-span-4 font-normal text-secondary-text text-base leading-5 w-30", children: "Receive at" }), _jsx("div", { className: "col-span-5 justify-self-end", children: _jsx(Address, { partner: partner, children: ({ destination, addressItem, connectedWallet, partner }) => _jsx(DestinationWalletPicker, { destination: destination, addressItem: addressItem, connectedWallet: connectedWallet, partner: partner }) }) })] }), _jsx("div", { className: "items-center space-y-2", children: _jsxs("div", { className: "grid grid-cols-[1fr_auto] gap-2 w-full max-w-full", children: [_jsx("div", { className: "min-w-0 overflow-hidden", children: _jsx(ReceiveAmount, {
|
|
19
|
+
return _jsxs("div", { className: "flex flex-col w-full bg-secondary-500 rounded-2xl p-4 pb-[15px] space-y-[27px]", children: [_jsxs("div", { className: "grid grid-cols-9 gap-2 items-center h-7", children: [_jsx("label", { htmlFor: "To", className: "block col-span-4 font-normal text-secondary-text text-base leading-5 w-30", children: "Receive at" }), _jsx("div", { className: "col-span-5 justify-self-end", children: _jsx(Address, { partner: partner, children: ({ destination, addressItem, connectedWallet, partner }) => _jsx(DestinationWalletPicker, { destination: destination, addressItem: addressItem, connectedWallet: connectedWallet, partner: partner }) }) })] }), _jsx("div", { className: "items-center space-y-2", children: _jsxs("div", { className: "grid grid-cols-[1fr_auto] gap-2 w-full max-w-full", children: [_jsx("div", { className: "min-w-0 overflow-hidden", children: _jsx(ReceiveAmount, { destination_token: toCurrency, fee: quote, isFeeLoading: isQuoteLoading }) }), _jsx("div", { className: "justify-self-end self-start", children: _jsx(RoutePicker, { direction: "to" }) })] }) })] });
|
|
20
20
|
};
|
|
21
21
|
export const SecondDestinationWalletPicker = () => {
|
|
22
22
|
return _jsxs("div", { className: " justify-center w-full pl-3 pr-2 py-2 bg-secondary-400 items-center flex font-light space-x-2 mx-auto rounded-lg focus-peer:ring-primary focus-peer:border-secondary-400 focus-peer:border focus-peer:ring-1 focus:outline-none disabled:cursor-not-allowed relative grow h-12 ", children: [_jsx(PlusIcon, { className: "stroke-1" }), " ", _jsx("span", { children: "Destination Address" })] });
|
|
@@ -8,7 +8,7 @@ import { useSelectorState } from "../../../components/Select/Selector/Index";
|
|
|
8
8
|
import useWallet from "../../../hooks/useWallet";
|
|
9
9
|
import ConnectWalletButton from "../../../components/Common/ConnectWalletButton";
|
|
10
10
|
import { SearchComponent } from "../Search";
|
|
11
|
-
export const Content = ({ searchQuery, setSearchQuery, rowElements, selectedToken, selectedRoute, direction, onSelect,
|
|
11
|
+
export const Content = ({ searchQuery, setSearchQuery, rowElements, selectedToken, selectedRoute, direction, onSelect, partialPublished }) => {
|
|
12
12
|
const parentRef = useRef(null);
|
|
13
13
|
const [openValues, setOpenValues] = useState(selectedRoute ? [selectedRoute] : []);
|
|
14
14
|
const { shouldFocus } = useSelectorState();
|
|
@@ -56,6 +56,6 @@ export const Content = ({ searchQuery, setSearchQuery, rowElements, selectedToke
|
|
|
56
56
|
}, children: items.map((virtualRow) => {
|
|
57
57
|
const data = rowElements?.[virtualRow.index];
|
|
58
58
|
const key = data?.route?.name || virtualRow.key;
|
|
59
|
-
return _jsx("div", { className: "py-1 box-border w-full overflow-hidden", "data-index": virtualRow.index, ref: virtualizer.measureElement, children: _jsx(Row, {
|
|
59
|
+
return _jsx("div", { className: "py-1 box-border w-full overflow-hidden select-none", "data-index": virtualRow.index, ref: virtualizer.measureElement, children: _jsx(Row, { index: virtualRow.index, scrollContainerRef: parentRef, openValues: openValues, onSelect: onSelect, direction: direction, item: data, selectedRoute: selectedRoute, selectedToken: selectedToken, searchQuery: searchQuery, toggleContent: toggleAccordionItem }) }, key);
|
|
60
60
|
}) })] }) }) }) })] }) })] });
|
|
61
61
|
};
|
|
@@ -10,13 +10,13 @@ import ConnectButton from "../../../components/Buttons/connectButton";
|
|
|
10
10
|
import { WalletsIcons } from "../../../components/Wallet/WalletComponents/ConnectedWallets";
|
|
11
11
|
import { useFormikContext } from "formik";
|
|
12
12
|
import { isValidAddress } from "../../../lib/address/validator";
|
|
13
|
-
import {
|
|
13
|
+
import { useSwapAccounts, useSelectSwapAccount } from "../../../context/swapAccounts";
|
|
14
14
|
import { addressFormat } from "../../../lib/address/formatter";
|
|
15
15
|
const PickerWalletConnect = ({ direction }) => {
|
|
16
16
|
const [openModal, setOpenModal] = useState(false);
|
|
17
17
|
const { values, setFieldValue } = useFormikContext();
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const swapAccounts = useSwapAccounts(direction);
|
|
19
|
+
const selectSwapAccount = useSelectSwapAccount(direction);
|
|
20
20
|
const { connect } = useConnectModal();
|
|
21
21
|
const connectWallet = async () => {
|
|
22
22
|
const result = await connect();
|
|
@@ -31,14 +31,14 @@ const PickerWalletConnect = ({ direction }) => {
|
|
|
31
31
|
const { walletId, address, providerName } = props;
|
|
32
32
|
if (direction == 'to' && isValidAddress(address, values.to))
|
|
33
33
|
setFieldValue(`destination_address`, address);
|
|
34
|
-
|
|
34
|
+
selectSwapAccount({
|
|
35
35
|
id: walletId,
|
|
36
36
|
address,
|
|
37
37
|
providerName,
|
|
38
38
|
});
|
|
39
39
|
setOpenModal(false);
|
|
40
40
|
};
|
|
41
|
-
return _jsxs(_Fragment, { children: [_jsx(AccountsPickerButton, { accounts:
|
|
41
|
+
return _jsxs(_Fragment, { children: [_jsx(AccountsPickerButton, { accounts: swapAccounts, onOpenModalClick: () => setOpenModal(true) }), _jsx(VaulDrawer, { show: openModal, setShow: setOpenModal, header: 'Select wallet', modalId: "connectedWallets", children: _jsxs(VaulDrawer.Snap, { id: "item-1", className: "space-y-1 pb-4", children: [_jsx("button", { type: 'button', onClick: connectWallet, className: "w-full flex justify-center p-2 bg-secondary-500 rounded-md hover:bg-secondary-400", children: _jsxs("div", { className: "flex items-center text-secondary-text gap-1 px-3 py-1", children: [_jsx(Plus, { className: "h-4 w-4" }), _jsx("span", { className: "text-sm", children: "Connect new wallet" })] }) }), swapAccounts.map((account, index) => {
|
|
42
42
|
return (_jsxs("div", { children: [_jsx("div", { className: "flex justify-between items-center px-4 pt-2", children: _jsx("label", { htmlFor: "From", className: "block font-medium text-secondary-text text-sm pl-1 py-1", children: account.provider.name }) }), _jsx(AccountsList, { network: direction === 'from' ? values.from : values.to, onSelect: handleSelectAccount, selectedAccount: account }, index)] }, index));
|
|
43
43
|
})] }) })] });
|
|
44
44
|
};
|
|
@@ -6,20 +6,20 @@ import RoutePickerIcon from "../../../components/Icons/RoutePickerPlaceholder";
|
|
|
6
6
|
import { useBalance } from "../../../lib/balances/useBalance";
|
|
7
7
|
import { ImageWithFallback } from "../../../components/Common/ImageWithFallback";
|
|
8
8
|
import { getKey, useBalanceStore } from "../../../stores/balanceStore";
|
|
9
|
-
import {
|
|
9
|
+
import { useSwapAccounts } from "../../../context/swapAccounts";
|
|
10
10
|
import clsx from "clsx";
|
|
11
11
|
import { formatUsd } from "../../../components/utils/formatUsdAmount";
|
|
12
12
|
import { ExtendedAddress } from "../Address/AddressPicker/AddressWithIcon";
|
|
13
13
|
import { getTotalBalanceInUSD } from "../../../helpers/balanceHelper";
|
|
14
14
|
import { useMemo } from "react";
|
|
15
15
|
export const CurrencySelectItemDisplay = (props) => {
|
|
16
|
-
const { item, route, direction,
|
|
17
|
-
return _jsxs(SelectItem, { className: "group", children: [_jsx(SelectItem.Logo, { imgSrc: item.logo, altText: `${item.symbol} logo`, className: "rounded-full" }), _jsx(NetworkTokenTitle, { item: item, route: route, direction: direction,
|
|
16
|
+
const { item, route, direction, type } = props;
|
|
17
|
+
return _jsxs(SelectItem, { className: "group", children: [_jsx(SelectItem.Logo, { imgSrc: item.logo, altText: `${item.symbol} logo`, className: "rounded-full" }), _jsx(NetworkTokenTitle, { item: item, route: route, direction: direction, type: type })] });
|
|
18
18
|
};
|
|
19
19
|
export const NetworkTokenTitle = (props) => {
|
|
20
|
-
const { item, route, direction,
|
|
21
|
-
const
|
|
22
|
-
const selectedAccount =
|
|
20
|
+
const { item, route, direction, type } = props;
|
|
21
|
+
const swapAccounts = useSwapAccounts(direction);
|
|
22
|
+
const selectedAccount = swapAccounts?.find(w => (direction == 'from' ? w.provider?.withdrawalSupportedNetworks : w.provider?.autofillSupportedNetworks)?.includes(route.name));
|
|
23
23
|
const { balances } = useBalance(selectedAccount?.address, route);
|
|
24
24
|
const tokenbalance = balances?.find(b => b.token === item.symbol);
|
|
25
25
|
const formatted_balance_amount = (tokenbalance?.amount || tokenbalance?.amount === 0) ? truncateDecimals(tokenbalance?.amount, item.precision) : '';
|
|
@@ -27,28 +27,28 @@ export const NetworkTokenTitle = (props) => {
|
|
|
27
27
|
return _jsx(SelectItem.DetailedTitle, { title: item.symbol, secondaryImageAlt: route.display_name, secondary: _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { children: route.display_name }), _jsx("div", { className: "transition-all duration-300 opacity-0 group-hover:opacity-100 group-hover:delay-400 click-delay-on-hover", children: item.contract ?
|
|
28
28
|
_jsx(ExtendedAddress, { network: route, isForCurrency: true, showDetails: true, address: item.contract, logo: item.logo, title: item.symbol, description: item.display_asset, children: _jsxs("div", { className: "flex items-center gap-1 text-secondary-text text-xs cursor-pointer hover:text-primary-text", children: [_jsxs("p", { className: "max-w-[90px] truncate", children: [_jsx("span", { children: "\u2022" }), " ", _jsx("span", { children: item.display_asset || item.symbol })] }), _jsx(Info, { className: "h-3 w-3" })] }) })
|
|
29
29
|
:
|
|
30
|
-
_jsxs("p", { className: "flex items-center gap-1 text-xs text-secondary-text", children: [_jsx("span", { children: "\u2022" }), _jsx("span", { className: "truncate max-w-[80px]", children: item.display_asset || item.symbol })] }) })] }), secondaryLogoSrc: route.logo, children: (
|
|
30
|
+
_jsxs("p", { className: "flex items-center gap-1 text-xs text-secondary-text", children: [_jsx("span", { children: "\u2022" }), _jsx("span", { className: "truncate max-w-[80px]", children: item.display_asset || item.symbol })] }) })] }), secondaryLogoSrc: route.logo, children: (tokenbalance && Number(tokenbalance?.amount) > 0) ? (_jsxs("span", { className: "text-sm text-secondary-text text-right my-auto leading-4 font-medium", children: [Number(usdAmount) > 0 && (_jsx("div", { className: clsx("text-primary-text text-base", { '!text-lg !leading-[22px]': type === 'suggested_token' }), children: formatUsd(usdAmount) })), _jsx("div", { className: 'text-xs leading-4', children: formatted_balance_amount })] })) : _jsx(_Fragment, {}) });
|
|
31
31
|
};
|
|
32
32
|
export const NetworkRouteSelectItemDisplay = (props) => {
|
|
33
|
-
const { item, direction,
|
|
34
|
-
const
|
|
35
|
-
const selectedAccount =
|
|
33
|
+
const { item, direction, hideTokenImages } = props;
|
|
34
|
+
const swapAccounts = useSwapAccounts(direction);
|
|
35
|
+
const selectedAccount = swapAccounts?.find(w => (direction == 'from' ? w.provider?.withdrawalSupportedNetworks : w.provider?.autofillSupportedNetworks)?.includes(item.name));
|
|
36
36
|
const networkBalances = useBalance(selectedAccount?.address, item);
|
|
37
37
|
const totalInUSD = useMemo(() => networkBalances ? getTotalBalanceInUSD(networkBalances, item) : undefined, [networkBalances.balances, item]);
|
|
38
38
|
const tokensWithBalance = networkBalances.balances?.filter(b => b.amount && b.amount > 0)
|
|
39
39
|
?.map(b => b.token);
|
|
40
40
|
const filteredNetworkTokens = item?.tokens?.filter(token => tokensWithBalance?.includes(token.symbol));
|
|
41
|
-
const hasLoadedBalances =
|
|
41
|
+
const hasLoadedBalances = totalInUSD !== null && Number(totalInUSD) > 0;
|
|
42
42
|
const showTokenLogos = hasLoadedBalances && filteredNetworkTokens?.length;
|
|
43
|
-
return (_jsxs(SelectItem, { className: "bg-secondary-500 group rounded-xl hover:bg-secondary-400 group/item relative pr-7 py-2", children: [_jsx(SelectItem.Logo, { imgSrc: item.logo, altText: `${item.display_name} logo`, className: "rounded-md" }), _jsx(SelectItem.Title, { children: _jsxs(_Fragment, { children: [_jsx("span", { children: item.display_name }), hasLoadedBalances ? (_jsxs("div", { className: `${showTokenLogos ? "flex flex-col space-y-0.5" : ""} ${hideTokenImages ? "hidden" : ""}`, children: [_jsx("span", { className: "text-secondary-text text-sm leading-4 font-medium", children: formatUsd(totalInUSD) }), showTokenLogos ? (_jsxs("div", { className: "flex justify-end items-center -space-x-2 relative h-4", children: [filteredNetworkTokens.slice(0, 3).map((t, index) => (_jsx(ImageWithFallback, { src: t.logo, alt: `${t.symbol} logo`, height: "16", width: "16", loading: "eager", fetchPriority: 'high', className: "rounded-full object-contain" }, `${t.symbol}-${index}`))), filteredNetworkTokens.length > 3 && (_jsx("div", { className: "w-4 h-4 bg-secondary-600 text-primary-text text-[8px] rounded-full flex items-center justify-center border-2 border-background", children: _jsxs("span", { children: ["+", filteredNetworkTokens.length - 3] }) }))] })) : _jsx(_Fragment, {})] })) :
|
|
43
|
+
return (_jsxs(SelectItem, { className: "bg-secondary-500 group rounded-xl hover:bg-secondary-400 group/item relative pr-7 py-2", children: [_jsx(SelectItem.Logo, { imgSrc: item.logo, altText: `${item.display_name} logo`, className: "rounded-md" }), _jsx(SelectItem.Title, { children: _jsxs(_Fragment, { children: [_jsx("span", { children: item.display_name }), hasLoadedBalances ? (_jsxs("div", { className: `${showTokenLogos ? "flex flex-col space-y-0.5" : ""} ${hideTokenImages ? "hidden" : ""}`, children: [_jsx("span", { className: "text-secondary-text text-sm leading-4 font-medium", children: formatUsd(totalInUSD) }), showTokenLogos ? (_jsxs("div", { className: "flex justify-end items-center -space-x-2 relative h-4", children: [filteredNetworkTokens.slice(0, 3).map((t, index) => (_jsx(ImageWithFallback, { src: t.logo, alt: `${t.symbol} logo`, height: "16", width: "16", loading: "eager", fetchPriority: 'high', className: "rounded-full object-contain" }, `${t.symbol}-${index}`))), filteredNetworkTokens.length > 3 && (_jsx("div", { className: "w-4 h-4 bg-secondary-600 text-primary-text text-[8px] rounded-full flex items-center justify-center border-2 border-background", children: _jsxs("span", { children: ["+", filteredNetworkTokens.length - 3] }) }))] })) : _jsx(_Fragment, {})] })) : _jsx(_Fragment, {}), _jsx(ChevronDown, { className: "!w-3.5 !h-3.5 absolute right-2 top-1/2 -translate-y-1/2 text-secondary-text transition-opacity duration-200 opacity-0 group-hover/item:opacity-100", "aria-hidden": "true" })] }) })] }));
|
|
44
44
|
};
|
|
45
|
-
export const GroupedTokenHeader = ({ item, direction,
|
|
46
|
-
const
|
|
45
|
+
export const GroupedTokenHeader = ({ item, direction, hideTokenImages }) => {
|
|
46
|
+
const swapAccounts = useSwapAccounts(direction);
|
|
47
47
|
const tokens = item.items;
|
|
48
48
|
const balances = useBalanceStore(s => s.balances);
|
|
49
49
|
const networksWithBalance = Array.from(new Map(tokens
|
|
50
50
|
.map(({ route }) => {
|
|
51
|
-
const address =
|
|
51
|
+
const address = swapAccounts.find(w => (direction == 'from' ? w.provider?.withdrawalSupportedNetworks : w.provider?.autofillSupportedNetworks)?.includes(route.route.name))?.address;
|
|
52
52
|
const key = address && route.route ? getKey(address, route.route) : 'unknown';
|
|
53
53
|
const tokenSymbol = route.token.symbol;
|
|
54
54
|
const networkRoute = route.route;
|
|
@@ -58,7 +58,7 @@ export const GroupedTokenHeader = ({ item, direction, allbalancesLoaded, hideTok
|
|
|
58
58
|
})
|
|
59
59
|
.filter((entry) => !!entry)).values());
|
|
60
60
|
const tokenBalances = tokens.reduce((acc, { route }) => {
|
|
61
|
-
const address =
|
|
61
|
+
const address = swapAccounts.find(w => (direction == 'from' ? w.provider?.withdrawalSupportedNetworks : w.provider?.autofillSupportedNetworks)?.includes(route.route.name))?.address;
|
|
62
62
|
const key = address && route.route ? getKey(address, route.route) : 'unknown';
|
|
63
63
|
const tokenSymbol = route.token.symbol;
|
|
64
64
|
const networkName = route.route.name;
|
|
@@ -70,9 +70,9 @@ export const GroupedTokenHeader = ({ item, direction, allbalancesLoaded, hideTok
|
|
|
70
70
|
return { sum: acc.sum + balanceEntry.amount * price, hasVale: true };
|
|
71
71
|
}, { sum: 0, hasVale: false });
|
|
72
72
|
const mainToken = tokens[0]?.route.token;
|
|
73
|
-
const hasLoadedBalances =
|
|
73
|
+
const hasLoadedBalances = tokenBalances.hasVale && Number(tokenBalances.sum) >= 0;
|
|
74
74
|
const showNetworkIcons = hasLoadedBalances && networksWithBalance.length > 0;
|
|
75
|
-
return (_jsxs(SelectItem, { className: "bg-secondary-500 group rounded-xl hover:bg-secondary-400 group/item relative pr-7 py-2", children: [_jsx(SelectItem.Logo, { imgSrc: mainToken.logo, altText: `${mainToken.symbol} logo`, className: "rounded-full" }), _jsx(SelectItem.Title, { children: _jsxs(_Fragment, { children: [_jsx("span", { children: mainToken.symbol }), hasLoadedBalances ? (_jsxs("div", { className: `${showNetworkIcons ? "flex flex-col space-y-0.5" : ""} ${hideTokenImages ? "invisible" : "visible"}`, children: [_jsx("span", { className: "text-secondary-text text-sm leading-4 font-medium", children: formatUsd(tokenBalances.sum) }), showNetworkIcons && (_jsxs("div", { className: "flex justify-end items-center -space-x-1.5 relative h-4", children: [networksWithBalance.slice(0, 3).map((network, index) => (_jsx(ImageWithFallback, { src: network.logo, alt: `${network.display_name} logo`, height: "16", width: "16", loading: "eager", fetchPriority: "high", className: "rounded-full object-contain" }, `${network.display_name}-${index}`))), networksWithBalance.length > 3 && (_jsx("div", { className: "w-4 h-4 bg-secondary-600 text-primary-text text-[8px] rounded-full flex items-center justify-center border-2 border-background", children: _jsxs("span", { children: ["+", networksWithBalance.length - 3] }) }))] }))] })) :
|
|
75
|
+
return (_jsxs(SelectItem, { className: "bg-secondary-500 group rounded-xl hover:bg-secondary-400 group/item relative pr-7 py-2", children: [_jsx(SelectItem.Logo, { imgSrc: mainToken.logo, altText: `${mainToken.symbol} logo`, className: "rounded-full" }), _jsx(SelectItem.Title, { children: _jsxs(_Fragment, { children: [_jsx("span", { children: mainToken.symbol }), hasLoadedBalances ? (_jsxs("div", { className: `${showNetworkIcons ? "flex flex-col space-y-0.5" : ""} ${hideTokenImages ? "invisible" : "visible"}`, children: [_jsx("span", { className: "text-secondary-text text-sm leading-4 font-medium", children: formatUsd(tokenBalances.sum) }), showNetworkIcons && (_jsxs("div", { className: "flex justify-end items-center -space-x-1.5 relative h-4", children: [networksWithBalance.slice(0, 3).map((network, index) => (_jsx(ImageWithFallback, { src: network.logo, alt: `${network.display_name} logo`, height: "16", width: "16", loading: "eager", fetchPriority: "high", className: "rounded-full object-contain" }, `${network.display_name}-${index}`))), networksWithBalance.length > 3 && (_jsx("div", { className: "w-4 h-4 bg-secondary-600 text-primary-text text-[8px] rounded-full flex items-center justify-center border-2 border-background", children: _jsxs("span", { children: ["+", networksWithBalance.length - 3] }) }))] }))] })) : _jsx(_Fragment, {}), _jsx(ChevronDown, { className: "!w-3.5 !h-3.5 absolute right-2 top-1/2 -translate-y-1/2 text-secondary-text transition-opacity duration-200 opacity-0 group-hover/item:opacity-100", "aria-hidden": "true" })] }) })] }));
|
|
76
76
|
};
|
|
77
77
|
export const SelectedCurrencyDisplay = (props) => {
|
|
78
78
|
const { value, placeholder } = props;
|