@layerswap/widget 1.0.5 → 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 -8
- package/dist/esm/components/Buttons/copyButton.js +5 -3
- package/dist/esm/components/Buttons/submitButton.js +2 -1
- package/dist/esm/components/ColorSchema.js +3 -10
- package/dist/esm/components/Common/ConnectWalletButton.js +9 -3
- package/dist/esm/components/Common/CountDownTimer.js +0 -15
- 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 +8 -2
- 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/NumericInput.js +7 -4
- package/dist/esm/components/Input/RoutePicker/Content.js +19 -3
- 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 +6 -7
- package/dist/esm/components/Input/RoutePicker/index.js +2 -2
- package/dist/esm/components/Input/SourceWalletPicker.js +7 -5
- package/dist/esm/components/Menu/index.js +2 -2
- package/dist/esm/components/Modal/vaulModal.js +11 -16
- 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 +8 -6
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Slippage.js +6 -1
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.js +51 -14
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.js +2 -2
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.js +4 -4
- 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 +8 -14
- package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +11 -13
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.js +1 -1
- package/dist/esm/components/Pages/Swap/Withdraw/Failed.js +12 -8
- package/dist/esm/components/Pages/Swap/Withdraw/ManualWithdraw.js +29 -10
- 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 +3 -3
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/index.js +3 -3
- 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 +2 -2
- package/dist/esm/components/Pages/SwapHistory/SwapDetailsComponent.js +4 -1
- package/dist/esm/components/Pages/SwapHistory/index.js +6 -6
- package/dist/esm/components/Wallet/WalletComponents/ConnectedWallets.js +1 -1
- package/dist/esm/components/Wallet/WalletComponents/WalletsList.js +4 -3
- package/dist/esm/components/Wallet/WalletModal/Connector.js +2 -2
- package/dist/esm/components/Wallet/WalletModal/ConnectorsList.js +49 -24
- 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 +2 -3
- package/dist/esm/components/WidgetLoading.js +9 -2
- package/dist/esm/components/utils/RoundDecimals.js +4 -2
- package/dist/esm/context/ErrorProvider.js +14 -0
- package/dist/esm/context/LayerswapProvider.js +6 -5
- package/dist/esm/context/asyncModal.js +1 -1
- package/dist/esm/context/callbackProvider.js +54 -60
- package/dist/esm/context/resolverContext.js +7 -2
- package/dist/esm/context/swap.js +13 -18
- 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 +11 -6
- 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 +28 -17
- package/dist/esm/lib/ErrorHandler.js +6 -0
- package/dist/esm/lib/NetworkSettings.js +0 -16
- package/dist/esm/lib/apiClients/layerSwapApiClient.js +12 -35
- package/dist/esm/lib/axiosInterceptor.js +2 -2
- 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 +1 -2
- 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 +2 -2
- 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 +0 -3
- package/dist/types/Models/Theme.d.ts.map +1 -1
- package/dist/types/components/Buttons/copyButton.d.ts +3 -1
- package/dist/types/components/Buttons/copyButton.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/ColorSchema.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/NumericInput.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/Modal/vaulModal.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/Refuel.d.ts.map +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/SwapDetailsComponent.d.ts.map +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/components/utils/RoundDecimals.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 -12
- 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/validationContext.d.ts +1 -0
- package/dist/types/context/validationContext.d.ts.map +1 -1
- 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 +10 -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/NetworkSettings.d.ts +0 -1
- package/dist/types/lib/NetworkSettings.d.ts.map +1 -1
- package/dist/types/lib/apiClients/layerSwapApiClient.d.ts +2 -10
- 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 +25 -6
- 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
|
@@ -6,7 +6,6 @@ import SpinIcon from "../../../components/Icons/spinIcon";
|
|
|
6
6
|
import useSWR from 'swr';
|
|
7
7
|
import { Widget } from "../../../components/Widget/Index";
|
|
8
8
|
import { ImageWithFallback } from "../../../components/Common/ImageWithFallback";
|
|
9
|
-
import { LayerswapProvider } from "../../../context/LayerswapProvider";
|
|
10
9
|
export const CampaignsComponent = ({ onCampaignSelect }) => {
|
|
11
10
|
const apiClient = new LayerSwapApiClient();
|
|
12
11
|
const { data: campaignsData, isLoading } = useSWR('/campaigns', apiClient.fetcher);
|
|
@@ -19,13 +18,13 @@ export const CampaignsComponent = ({ onCampaignSelect }) => {
|
|
|
19
18
|
const activeCampaigns = sortedCampaigns?.filter(IsCampaignActive) || [];
|
|
20
19
|
const inactiveCampaigns = sortedCampaigns?.filter(c => !IsCampaignActive(c)) || [];
|
|
21
20
|
return (_jsx(_Fragment, { children: _jsx(Widget.Content, { children: !isLoading ?
|
|
22
|
-
_jsxs("div", { className: "space-y-5 h-full text-primary-text sm:min-h-[350px]", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "font-bold text-left leading-5", children: "Campaigns" }), _jsx("div", { className: "bg-secondary-500 divide-y divide-secondary-500 rounded-lg shadow-lg border border-secondary-500 hover:border-secondary-400 transition duration-200", children: _jsx("div", { className: "p-3 space-y-4", children: activeCampaigns.length > 0 ?
|
|
21
|
+
_jsxs("div", { className: "space-y-5 h-full w-full text-primary-text sm:min-h-[350px]", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "font-bold text-left leading-5", children: "Campaigns" }), _jsx("div", { className: "bg-secondary-500 divide-y divide-secondary-500 rounded-lg shadow-lg border border-secondary-500 hover:border-secondary-400 transition duration-200", children: _jsx("div", { className: "p-3 space-y-4", children: activeCampaigns.length > 0 ?
|
|
23
22
|
activeCampaigns.map(c => _jsx(CampaignItem, { onCampaignSelect: onCampaignSelect, campaign: c }, c.id))
|
|
24
23
|
:
|
|
25
24
|
_jsxs("div", { className: "flex flex-col items-center justify-center space-y-2 w-full", children: [_jsx(Gift, { className: "h-10 w-10 text-primary" }), _jsx("p", { className: "font-bold text-center", children: "There are no active campaigns right now" })] }) }) })] }), inactiveCampaigns.length > 0 &&
|
|
26
25
|
_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "font-bold text-left leading-5", children: "Old campaigns" }), _jsx("div", { className: "bg-secondary-500 divide-y divide-secondary-500 rounded-lg shadow-lg border border-secondary-500 hover:border-secondary-400 transition duration-200", children: _jsx("div", { className: "p-3 dpsv flex flex-col space-y-4", children: inactiveCampaigns?.map(c => _jsx(CampaignItem, { onCampaignSelect: onCampaignSelect, campaign: c }, c.id)) }) })] })] })
|
|
27
26
|
:
|
|
28
|
-
_jsx("div", { className: "absolute top-[calc(50%-5px)] left-[calc(50%-5px)]", children: _jsx(SpinIcon, { className: "animate-spin h-5 w-5" }) }) }) }));
|
|
27
|
+
_jsx("div", { className: "h-full w-full relative min-h-[350px]", children: _jsx("div", { className: "absolute top-[calc(50%-5px)] left-[calc(50%-5px)]", children: _jsx(SpinIcon, { className: "animate-spin h-5 w-5" }) }) }) }) }));
|
|
29
28
|
};
|
|
30
29
|
const CampaignItem = ({ campaign, onCampaignSelect }) => {
|
|
31
30
|
const campaignDaysLeft = ((new Date(campaign.end_date).getTime() - new Date().getTime()) / 86400000).toFixed();
|
|
@@ -38,5 +37,5 @@ function IsCampaignActive(campaign) {
|
|
|
38
37
|
return (new Date(campaign?.end_date).getTime() > now.getTime());
|
|
39
38
|
}
|
|
40
39
|
export const Campaigns = (props) => {
|
|
41
|
-
return (_jsx(
|
|
40
|
+
return (_jsx(Widget, { goBack: props.goBack, hideMenu: props.hideMenu, children: _jsx(CampaignsComponent, { onCampaignSelect: props.onCampaignSelect }) }));
|
|
42
41
|
};
|
|
@@ -18,18 +18,19 @@ import useWallet from "../../../../hooks/useWallet";
|
|
|
18
18
|
import clsx from "clsx";
|
|
19
19
|
import { useSwapDataState } from "../../../../context/swap";
|
|
20
20
|
import { useClickOutside } from "../../../../hooks/useClickOutside";
|
|
21
|
-
import {
|
|
21
|
+
import { useCallbacks } from "../../../../context/callbackProvider";
|
|
22
22
|
import QuoteDetails from "./FeeDetails";
|
|
23
23
|
import DepositMethodComponent from "./FeeDetails/DepositMethod";
|
|
24
24
|
import { AddressGroup } from "../../../../components/Input/Address/AddressPicker";
|
|
25
25
|
import { ImageWithFallback } from "../../../../components/Common/ImageWithFallback";
|
|
26
|
-
|
|
26
|
+
import { ExchangeReceiveAmount } from "../../../../components/Input/Amount/ExchangeReceiveAmount";
|
|
27
|
+
const ExchangeForm = ({ partner, showBanner, dismissBanner }) => {
|
|
27
28
|
const { values, isSubmitting } = useFormikContext();
|
|
28
|
-
const
|
|
29
|
+
const { onFormChange } = useCallbacks();
|
|
29
30
|
useEffect(() => {
|
|
30
|
-
|
|
31
|
-
}, [values,
|
|
32
|
-
const { fromAsset: fromCurrency, from, to: destination, destination_address, amount } = values || {};
|
|
31
|
+
onFormChange?.(values);
|
|
32
|
+
}, [values, onFormChange]);
|
|
33
|
+
const { fromAsset: fromCurrency, from, to: destination, destination_address, amount, toAsset: toCurrency } = values || {};
|
|
33
34
|
const quoteArgs = useMemo(() => transformFormValuesToQuoteArgs(values, true), [values]);
|
|
34
35
|
const [actionTempValue, setActionTempValue] = useState(undefined);
|
|
35
36
|
const { wallets } = useWallet();
|
|
@@ -44,19 +45,20 @@ const ExchangeForm = ({ partner }) => {
|
|
|
44
45
|
const handleActionHover = (value) => {
|
|
45
46
|
setActionTempValue(value);
|
|
46
47
|
};
|
|
47
|
-
return (_jsxs(_Fragment, { children: [_jsx(DepositMethodComponent, {}), _jsxs(Form, { className: "h-full grow flex flex-col flex-1 justify-between w-full gap-3", children: [_jsx(Widget.Content, { children: _jsxs("div", { className: "flex flex-col w-full
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
return (_jsxs(_Fragment, { children: [_jsx(DepositMethodComponent, {}), _jsxs(Form, { className: "h-full grow flex flex-col flex-1 justify-between w-full gap-3", children: [_jsx(Widget.Content, { children: _jsxs("div", { className: "w-full flex flex-col justify-between flex-1 relative", children: [_jsxs("div", { className: "flex flex-col w-full gap-3", children: [_jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "From", className: "block font-normal text-secondary-text text-base leading-5", children: "Send from" }), _jsx("div", { className: "relative", children: _jsx(CexPicker, {}) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx("label", { htmlFor: "From", className: "block font-normal text-secondary-text text-base leading-5", children: "Send to" }), _jsx("div", { className: "relative group exchange-picker", children: _jsx(RoutePicker, { direction: "to", isExchange: true }) }), _jsx("div", { className: "hover:bg-secondary-300 bg-secondary-500 rounded-2xl p-3 h-[52px]", children: _jsx(Address, { partner: partner, children: ({ addressItem }) => {
|
|
49
|
+
const addressProviderIcon = (partner?.is_wallet && addressItem?.group === AddressGroup.FromQuery && partner?.logo) ? partner.logo : undefined;
|
|
50
|
+
return _jsx(_Fragment, { children: addressItem ? _jsx(_Fragment, { children: _jsx(AddressButton, { address: addressItem.address, network: destination, wallet: wallet, addressProviderIcon: addressProviderIcon }) })
|
|
51
|
+
: destination_address ? _jsx(_Fragment, { children: _jsx(AddressButton, { address: destination_address }) })
|
|
52
|
+
:
|
|
53
|
+
_jsxs("span", { className: "flex items-center", children: [_jsx(SelectedEchangePlaceholder, { placeholder: 'Enter destination address' }), _jsx("span", { className: "absolute right-0 px-1 pr-5 pointer-events-none text-primary-text", children: _jsx(ChevronDown, { className: "h-4 w-4 text-secondary-text", "aria-hidden": "true" }) })] }) });
|
|
54
|
+
} }) })] }), _jsxs("div", { className: "bg-secondary-500 rounded-2xl p-3 group space-y-2", onClick: setShowQuickActions, ref: parentRef, children: [_jsxs("div", { className: "flex justify-between items-center", children: [_jsx("label", { htmlFor: "From", className: "block font-normal text-secondary-text text-base ml-2 leading-5", children: "Enter amount" }), from && fromCurrency && minAllowedAmount && maxAmountFromApi &&
|
|
55
|
+
_jsx("div", { className: clsx({
|
|
56
|
+
"hidden": !showQuickActions,
|
|
57
|
+
"block": showQuickActions,
|
|
58
|
+
}, "group-hover:block"), children: _jsx(MinMax, { from: from, fromCurrency: fromCurrency, limitsMinAmount: minAllowedAmount, limitsMaxAmount: maxAmountFromApi, onActionHover: handleActionHover, depositMethod: "deposit_address" }) })] }), _jsxs("div", { className: "relative group exchange-amount-field", children: [_jsx(AmountField, { className: "pb-0! rounded-xl!", fee: quote, usdPosition: "right", actionValue: actionTempValue }), quote &&
|
|
59
|
+
_jsxs("div", { className: "mt-3 ml-2", children: [_jsx("span", { className: "text-base leading-5 text-secondary-text", children: "You will receive" }), _jsx(ExchangeReceiveAmount, { destination_token: toCurrency, fee: quote, isFeeLoading: isQuoteLoading })] })] })] })] }), _jsxs("div", { children: [routeValidation.message
|
|
60
|
+
? _jsx(ValidationError, {})
|
|
61
|
+
: null, _jsx(QuoteDetails, { swapValues: values, quote: quote?.quote, isQuoteLoading: isQuoteLoading, reward: quote?.reward, variant: "base" })] })] }) }), _jsx(Widget.Footer, { showPoweredBy: true, children: _jsx(FormButton, { shouldConnectWallet: false, values: values, disabled: !isValid || isSubmitting || !quote || isQuoteLoading, error: error, isSubmitting: isSubmitting, partner: partner }) })] })] }));
|
|
60
62
|
};
|
|
61
63
|
export default ExchangeForm;
|
|
62
64
|
const AddressButton = ({ address, network, wallet, addressProviderIcon }) => {
|
|
@@ -2,13 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { ArrowRight } from "lucide-react";
|
|
4
4
|
import { truncateDecimals } from "../../../../../components/utils/RoundDecimals";
|
|
5
|
-
export const RateElement = ({ fromAsset, toAsset, requestAmount, receiveAmount, }) => {
|
|
5
|
+
export const RateElement = ({ fromAsset, toAsset, requestAmount, receiveAmount, totalFeeInUsd }) => {
|
|
6
6
|
const [flipped, setFlipped] = useState(false);
|
|
7
|
-
if (
|
|
7
|
+
if (toAsset.price_in_usd === 0) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const totalFee = totalFeeInUsd ? totalFeeInUsd / toAsset.price_in_usd : 0;
|
|
11
|
+
const fromRate = (receiveAmount + totalFee) / requestAmount;
|
|
12
|
+
const toRate = requestAmount / (receiveAmount + totalFee);
|
|
12
13
|
const fromRateTruncated = truncateDecimals(fromRate, fromAsset?.precision || 6);
|
|
13
14
|
const toRateTruncated = truncateDecimals(toRate, toAsset?.precision || 6);
|
|
14
15
|
return (_jsx("div", { className: "flex text-sm ml-1 font-small items-center cursor-pointer", onClick: () => setFlipped(!flipped), children: !flipped ? (_jsxs(_Fragment, { children: [_jsxs("p", { children: [_jsx("span", { children: "1" }), " ", _jsx("span", { children: fromAsset?.symbol })] }), _jsx(ArrowRight, { className: "w-3 h-3 mx-1" }), _jsxs("span", { children: [fromRateTruncated, " ", toAsset?.symbol] })] })) : (_jsxs(_Fragment, { children: [_jsxs("p", { children: [_jsx("span", { children: "1" }), " ", _jsx("span", { children: toAsset?.symbol })] }), _jsx(ArrowRight, { className: "w-3 h-3 mx-1" }), _jsxs("span", { children: [toRateTruncated, " ", fromAsset?.symbol] })] })) }));
|
|
@@ -6,6 +6,8 @@ import clsx from "clsx";
|
|
|
6
6
|
import { useBalance } from "../../../../../lib/balances/useBalance";
|
|
7
7
|
import { isValidAddress } from "../../../../../lib/address/validator";
|
|
8
8
|
import ToggleButton from "../../../../../components/Buttons/toggleButton";
|
|
9
|
+
import { useValidationContext } from "../../../../../context/validationContext";
|
|
10
|
+
import { FORM_VALIDATION_ERROR_CODES } from "../../../../../hooks/useFormValidation";
|
|
9
11
|
const RefuelToggle = ({ onButtonClick, quote, minAllowedAmount }) => {
|
|
10
12
|
const { values, setFieldValue } = useFormikContext();
|
|
11
13
|
const { toAsset: toCurrency, to, destination_address, refuel, amount } = values;
|
|
@@ -13,6 +15,7 @@ const RefuelToggle = ({ onButtonClick, quote, minAllowedAmount }) => {
|
|
|
13
15
|
const destinationNativeBalance = destination_address && balances?.find(b => (b.token === to?.token?.symbol) && (b.network === to.name));
|
|
14
16
|
const needRefuel = toCurrency && toCurrency.refuel && to && to.token && isValidAddress(destination_address, to) && destinationNativeBalance && destinationNativeBalance?.amount == 0;
|
|
15
17
|
const previouslySelectedDestination = useRef(to);
|
|
18
|
+
const { formValidation } = useValidationContext();
|
|
16
19
|
useEffect(() => {
|
|
17
20
|
if (to && previouslySelectedDestination.current !== to && !!refuel) {
|
|
18
21
|
setFieldValue('refuel', false);
|
|
@@ -22,14 +25,13 @@ const RefuelToggle = ({ onButtonClick, quote, minAllowedAmount }) => {
|
|
|
22
25
|
const handleConfirmToggleChange = (value) => {
|
|
23
26
|
setFieldValue('refuel', value);
|
|
24
27
|
};
|
|
25
|
-
const showRefuel = needRefuel &&
|
|
26
|
-
return (showRefuel
|
|
27
|
-
_jsx("div", { className: clsx("gap-4 flex relative items-center outline-hidden w-full text-primary-text px-4 py-3 bg-secondary-500 border border-transparent transition-colors duration-200 rounded-2xl mt-
|
|
28
|
-
"
|
|
28
|
+
const showRefuel = needRefuel && formValidation.code !== FORM_VALIDATION_ERROR_CODES.ROUTE_NOT_FOUND;
|
|
29
|
+
return (showRefuel &&
|
|
30
|
+
_jsx("div", { className: clsx("gap-4 flex relative items-center outline-hidden w-full text-primary-text px-4 py-3 bg-secondary-500 border border-transparent transition-colors duration-200 rounded-2xl mt-3", {
|
|
31
|
+
"border-primary!": needRefuel && !refuel
|
|
29
32
|
}), children: _jsxs("div", { className: "flex justify-between w-full text-secondary-text ", children: [_jsxs("button", { className: "space-y-1 mt-1 mb-0.5", type: "button", onClick: () => onButtonClick(), children: [_jsxs("div", { className: "flex items-center text-base space-x-1", children: [_jsx("p", { className: "leading-4", children: "Refuel" }), _jsx("div", { className: "p-0.5", children: _jsx(Info, { className: "h-3 w-3 text-secondary-text hover:text-primary-text", "aria-hidden": "true", strokeWidth: 2.5 }) })] }), needRefuel && !refuel &&
|
|
30
33
|
_jsxs("p", { className: "text-xs", children: [_jsx("span", { children: "You need gas on" }), " ", _jsx("span", { children: to.display_name })] }), refuel && quote &&
|
|
31
34
|
_jsxs("p", { className: "text-xs", children: [_jsx("span", { children: "You'll get " }), quote?.refuel ? _jsxs("span", { children: ["~$", quote.refuel.amount_in_usd] }) : _jsx("span", { className: "w-5 h-3 rounded animate-pulse bg-secondary-200 text-transparent", children: "token" }), " ", _jsx("span", { children: "in" }), " ", _jsx("span", { children: to?.display_name }), " ", _jsx("span", { children: "for gas fees" })] }), refuel && !quote &&
|
|
32
|
-
_jsxs("p", { className: "text-xs", children: [_jsx("span", { children: "You'll get" }), " ", _jsx("span", { children: toCurrency.refuel?.token.symbol }), " ", _jsx("span", { children: "for gas fees" })] })] }), _jsx(ToggleButton, { value: !!refuel, onChange: handleConfirmToggleChange })] }) })
|
|
33
|
-
: null);
|
|
35
|
+
_jsxs("p", { className: "text-xs", children: [_jsx("span", { children: "You'll get" }), " ", _jsx("span", { children: toCurrency.refuel?.token.symbol }), " ", _jsx("span", { children: "for gas fees" })] })] }), _jsx(ToggleButton, { value: !!refuel, onChange: handleConfirmToggleChange })] }) }));
|
|
34
36
|
};
|
|
35
37
|
export default RefuelToggle;
|
|
@@ -65,11 +65,16 @@ const SlippageInput = forwardRef(function SlippageInput({ valueDecimal, onDeboun
|
|
|
65
65
|
}, 300);
|
|
66
66
|
return () => clearTimeout(t);
|
|
67
67
|
}, [localPercent, invalid]);
|
|
68
|
-
return (_jsxs(Popover, { open: invalid, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("div", { className: clsx("flex items-center gap-1 text-secondary-text text-sm px-2 py-2 -my-1 border rounded-lg font-normal leading-4 focus-within:outline-none focus-within:ring-0 border-secondary-300", invalid ? "animate-shake" : ""), children: [_jsx("input", { type: "number", ref: ref, autoComplete: "off", autoFocus: false, className: clsx("w-10 bg-transparent border-none outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 focus:border-transparent focus:shadow-none text-primary-text text-base leading-3.5 p-0 text-right"), value: localPercent, onChange: (e) => {
|
|
68
|
+
return (_jsxs(Popover, { open: invalid, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("div", { className: clsx("flex items-center gap-1 text-secondary-text text-sm px-2 py-2 -my-1 border rounded-lg font-normal leading-4 focus-within:outline-none focus-within:ring-0 border-secondary-300", invalid ? "animate-shake" : ""), children: [_jsx("input", { type: "number", ref: ref, autoComplete: "off", autoFocus: false, title: "", className: clsx("w-10 bg-transparent border-none outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0 focus:border-transparent focus:shadow-none text-primary-text text-base leading-3.5 p-0 text-right"), value: localPercent, onChange: (e) => {
|
|
69
69
|
const next = e.target.value === "" ? undefined : Number(e.target.value);
|
|
70
70
|
if (!Number.isNaN(next)) {
|
|
71
71
|
onEditing?.();
|
|
72
72
|
setLocalPercent(next);
|
|
73
73
|
}
|
|
74
|
+
}, onKeyDown: (e) => {
|
|
75
|
+
if (e.key == "Enter") {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
74
79
|
} }), _jsx("span", { children: "%" })] }) }), _jsx(PopoverContent, { side: "top", align: "center", className: "text-xs", children: "Slippage can not be out of 0.1% - 5% range." })] }));
|
|
75
80
|
});
|
|
@@ -6,17 +6,19 @@ import useSWRGas from "../../../../../../lib/gases/useSWRGas";
|
|
|
6
6
|
import useWallet from "../../../../../../hooks/useWallet";
|
|
7
7
|
import useSWRNftBalance from "../../../../../../lib/nft/useSWRNftBalance";
|
|
8
8
|
import { resolveTokenUsdPrice } from "../../../../../../helpers/tokenHelper";
|
|
9
|
-
import { useSelectedAccount } from "../../../../../../context/
|
|
9
|
+
import { useSelectedAccount } from "../../../../../../context/swapAccounts";
|
|
10
10
|
import { RateElement } from "../Rate";
|
|
11
11
|
import { Slippage } from "../Slippage";
|
|
12
12
|
import { truncateDecimals } from "../../../../../../components/utils/RoundDecimals";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import { isValidAddress } from "../../../../../../lib/address/validator";
|
|
14
|
+
import { addressFormat } from "../../../../../../lib/address/formatter";
|
|
15
|
+
import { ExtendedAddress } from "../../../../../../components/Input/Address/AddressPicker/AddressWithIcon";
|
|
16
|
+
import shortenAddress from "../../../../../../components/utils/ShortenAddress";
|
|
17
|
+
export const DetailedEstimates = ({ quote, reward, swapValues: values, variant }) => {
|
|
16
18
|
const shouldCheckNFT = reward?.campaign_type === "for_nft_holders" && reward?.nft_contract_address;
|
|
17
19
|
const { balance: nftBalance, isLoading, error } = useSWRNftBalance(values.destination_address || '', values.to, reward?.nft_contract_address || '');
|
|
18
20
|
const showReward = !(!reward || !values.destination_address || shouldCheckNFT && (isLoading || error || nftBalance === undefined || nftBalance <= 0));
|
|
19
|
-
return _jsxs("div", { className: "flex flex-col w-full px-2", children: [variant === "extended" && _jsx(GasFee, { values: values, quote: quote }), _jsx(Fees, { quote: quote, values: values }), _jsx(Rate, { fromAsset: values?.fromAsset, toAsset: values?.toAsset, requestAmount: quote?.requested_amount, receiveAmount: quote?.receive_amount }), variant === "extended" && values.depositMethod === "wallet" && _jsx(Slippage, { quoteData: quote, values: values }), _jsx(Estimates, { quote: quote }), showReward && _jsx(Reward, { reward: reward })] });
|
|
21
|
+
return _jsxs("div", { className: "flex flex-col w-full px-2", children: [variant === "extended" && _jsx(GasFee, { values: values, quote: quote }), _jsx(Fees, { quote: quote, values: values }), values.depositMethod !== "deposit_address" && _jsx(Rate, { fromAsset: values?.fromAsset, toAsset: values?.toAsset, requestAmount: quote?.requested_amount, receiveAmount: quote?.receive_amount, totalFeeInUsd: quote?.total_fee_in_usd }), values.depositMethod === "deposit_address" && variant === "extended" && values?.fromAsset?.contract && _jsx(ExchangeTokenContract, { fromAsset: values?.fromAsset, network: values?.from }), variant === "extended" && values.depositMethod === "wallet" && _jsx(Slippage, { quoteData: quote, values: values }), _jsx(Estimates, { quote: quote }), showReward && _jsx(Reward, { reward: reward })] });
|
|
20
22
|
};
|
|
21
23
|
const RowWrapper = ({ children, title }) => {
|
|
22
24
|
return _jsxs("div", { className: "flex items-center w-full justify-between gap-1 py-3 px-2 text-sm", children: [_jsx("div", { className: "inline-flex items-center text-left text-secondary-text gap-1 pr-4", children: _jsx("label", { children: title }) }), _jsx("div", { className: "text-right text-primary-text", children: children })] });
|
|
@@ -34,22 +36,57 @@ export const GasFee = ({ values, quote }) => {
|
|
|
34
36
|
const gasCurrencyName = gasData?.token?.symbol;
|
|
35
37
|
if (!gasFeeInUsd || !gasFeeInUsd)
|
|
36
38
|
return null;
|
|
37
|
-
return _jsx(RowWrapper, { title: "Gas Fee", children: isGasLoading ? (_jsx(LoadingBar, {})) : _jsx("div", { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: gas !== undefined && (_jsx("span", { className: "text-sm ml-1 font-small", children: displayGasFeeInUsd })) }), _jsxs(TooltipContent, { className: "
|
|
39
|
+
return _jsx(RowWrapper, { title: "Gas Fee", children: isGasLoading ? (_jsx(LoadingBar, {})) : _jsx("div", { children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: gas !== undefined && (_jsx("span", { className: "text-sm ml-1 font-small", children: displayGasFeeInUsd })) }), _jsxs(TooltipContent, { className: "bg-secondary-300! border-secondary-300! text-primary-text!", children: [_jsxs("span", { children: [gas || '-', " "] }), _jsx("span", { children: gas ? gasCurrencyName : '' })] })] }) }) });
|
|
38
40
|
};
|
|
39
41
|
const Fees = ({ quote, values }) => {
|
|
40
42
|
const lsFeeAmountInUsd = quote?.total_fee_in_usd;
|
|
41
|
-
const
|
|
43
|
+
const feeDiscount = quote?.fee_discount;
|
|
44
|
+
const hasDiscount = feeDiscount != null && feeDiscount > 0;
|
|
45
|
+
// total_fee is the original fee, discounted fee is total_fee - fee_discount
|
|
46
|
+
const originalFee = quote?.total_fee;
|
|
47
|
+
const discountedFee = hasDiscount && originalFee !== undefined
|
|
48
|
+
? originalFee - feeDiscount
|
|
49
|
+
: originalFee;
|
|
50
|
+
// Calculate fees in USD
|
|
51
|
+
const sourceTokenPriceInUsd = resolveTokenUsdPrice(values.fromAsset, quote);
|
|
52
|
+
const originalFeeInUsd = originalFee !== undefined && sourceTokenPriceInUsd != null
|
|
53
|
+
? originalFee * sourceTokenPriceInUsd
|
|
54
|
+
: null;
|
|
55
|
+
// Calculate discounted fee in USD
|
|
56
|
+
const discountedFeeInUsd = discountedFee !== undefined && sourceTokenPriceInUsd != null
|
|
57
|
+
? discountedFee * sourceTokenPriceInUsd
|
|
58
|
+
: null;
|
|
59
|
+
const displayOriginalFeeInUsd = originalFeeInUsd != null
|
|
60
|
+
? (originalFeeInUsd < 0.01 ? '<$0.01' : `$${originalFeeInUsd.toFixed(2)}`)
|
|
61
|
+
: null;
|
|
62
|
+
const isFree = discountedFee !== undefined && discountedFee === 0;
|
|
63
|
+
const displayLsFeeInUsd = isFree
|
|
64
|
+
? "Free"
|
|
65
|
+
: (discountedFeeInUsd != null
|
|
66
|
+
? (discountedFeeInUsd < 0.01 ? '<$0.01' : `$${discountedFeeInUsd.toFixed(2)}`)
|
|
67
|
+
: null);
|
|
42
68
|
const currencyName = values.fromAsset?.symbol || '';
|
|
43
|
-
const displayLsFee =
|
|
44
|
-
|
|
69
|
+
const displayLsFee = discountedFee !== undefined
|
|
70
|
+
? truncateDecimals(discountedFee, values.fromAsset?.decimals)
|
|
71
|
+
: undefined;
|
|
72
|
+
return _jsx(RowWrapper, { title: "Fees", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: displayLsFeeInUsd !== undefined && (_jsxs("div", { className: "flex items-center gap-2 text-sm ml-1 font-small", children: [hasDiscount && displayOriginalFeeInUsd && (_jsx("span", { className: "line-through text-primary-text-tertiary", children: displayOriginalFeeInUsd })), _jsx("span", { className: hasDiscount || isFree ? "text-primary-text" : "", children: displayLsFeeInUsd })] })) }), _jsxs(TooltipContent, { className: "bg-secondary-300! border-ssecondary-300! text-primart-text!", children: [_jsxs("span", { children: [displayLsFee || '-', " "] }), _jsx("span", { children: displayLsFee ? currencyName : '' })] })] }) });
|
|
45
73
|
};
|
|
46
74
|
const Estimates = ({ quote }) => {
|
|
47
|
-
return _jsx(RowWrapper, { title: "
|
|
75
|
+
return _jsx(RowWrapper, { title: "Est. time", children: _jsx(AverageCompletionTime, { avgCompletionTime: quote?.avg_completion_time }) });
|
|
48
76
|
};
|
|
49
77
|
const Reward = ({ reward }) => {
|
|
50
|
-
return _jsx(RowWrapper, { title: "Reward", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: reward?.amount_in_usd !== undefined && (_jsxs("span", { className: "text-sm ml-1 font-small", children: ["$", reward.amount_in_usd.toFixed(2)] })) }), _jsxs(TooltipContent, { className: "
|
|
78
|
+
return _jsx(RowWrapper, { title: "Reward", children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: reward?.amount_in_usd !== undefined && (_jsxs("span", { className: "text-sm ml-1 font-small", children: ["$", reward.amount_in_usd.toFixed(2)] })) }), _jsxs(TooltipContent, { className: "bg-secondary-300! border-secondary-300! text-primart-text!", children: [_jsxs("span", { children: [reward?.amount || '-', " "] }), _jsx("span", { children: reward?.amount ? reward.token.symbol : '' })] })] }) });
|
|
51
79
|
};
|
|
52
|
-
const Rate = ({ fromAsset, toAsset, requestAmount, receiveAmount }) => {
|
|
53
|
-
|
|
80
|
+
const Rate = ({ fromAsset, toAsset, requestAmount, receiveAmount, totalFeeInUsd }) => {
|
|
81
|
+
if (!fromAsset || !toAsset || !requestAmount || !receiveAmount || !totalFeeInUsd) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return _jsx(RowWrapper, { title: "Rate", children: _jsx(RateElement, { fromAsset: fromAsset, toAsset: toAsset, requestAmount: requestAmount, receiveAmount: receiveAmount, totalFeeInUsd: totalFeeInUsd }) });
|
|
85
|
+
};
|
|
86
|
+
const ExchangeTokenContract = ({ fromAsset, network }) => {
|
|
87
|
+
return _jsx(RowWrapper, { title: `${network?.display_name} - ${fromAsset?.symbol}`, children: (fromAsset?.contract && network && (isValidAddress(fromAsset?.contract, network)) ?
|
|
88
|
+
_jsx("div", { className: "text-sm group/addressItem text-secondary-text", children: _jsx(ExtendedAddress, { address: addressFormat(fromAsset?.contract, network), network: network, showDetails: false, shouldShowChevron: false }) })
|
|
89
|
+
:
|
|
90
|
+
_jsx("p", { className: "text-sm text-secondary-text", children: fromAsset?.contract ? shortenAddress(fromAsset.contract) : '' })) });
|
|
54
91
|
};
|
|
55
|
-
const LoadingBar = () => (_jsx("div", { className: 'h-
|
|
92
|
+
const LoadingBar = () => (_jsx("div", { className: 'h-2.5 w-16 inline-flex bg-gray-500 rounded-xs animate-pulse' }));
|
|
@@ -15,11 +15,11 @@ import { useInitialSettings } from '../../../../../../context/settings';
|
|
|
15
15
|
export const SummaryRow = ({ quoteData, isQuoteLoading, values, wallet, onOpen, sourceAddress, isOpen, destination, destinationAddress, partner }) => {
|
|
16
16
|
const { destination_address: destinationAddressFromQuery } = useInitialSettings();
|
|
17
17
|
const addressProviderIcon = destinationAddressFromQuery && partner?.is_wallet && addressFormat(destinationAddressFromQuery, values?.to) === addressFormat(values?.destination_address, values?.to) && partner?.logo;
|
|
18
|
-
return (_jsxs("div", { className: clsx("flex flex-col w-full p-2", { "!pb-0 !-mb-1": isOpen }), children: [values.destination_address && sourceAddress?.toLowerCase() !== values.destination_address?.toLowerCase() && (_jsxs("div", { className: `flex items-center w-full justify-between gap-1 text-sm px-2 py-3`, children: [_jsx("div", { className: "inline-flex items-center text-left text-secondary-text gap-1 pr-4", children: _jsx("label", { children: "Send to" }) }), _jsx("div", { className: "text-right text-primary-text", children: _jsxs("span", { className: "cursor-pointer hover:underline flex items-center gap-2", children: [wallet?.icon ? (_jsx(wallet.icon, { className: "w-4 h-4
|
|
18
|
+
return (_jsxs("div", { className: clsx("flex flex-col w-full p-2", { "!pb-0 !-mb-1": isOpen }), children: [values.destination_address && sourceAddress?.toLowerCase() !== values.destination_address?.toLowerCase() && (_jsxs("div", { className: `flex items-center w-full justify-between gap-1 text-sm px-2 py-3`, children: [_jsx("div", { className: "inline-flex items-center text-left text-secondary-text gap-1 pr-4", children: _jsx("label", { children: "Send to" }) }), _jsx("div", { className: "text-right text-primary-text", children: _jsxs("span", { className: "cursor-pointer hover:underline flex items-center gap-2", children: [wallet?.icon ? (_jsx(wallet.icon, { className: "w-4 h-4 bg-secondary-700 rounded-sm" })) : addressProviderIcon ? (_jsx(ImageWithFallback, { alt: "Partner logo", className: "rounded-md object-contain h-4 w-4", src: addressProviderIcon, width: "36", height: "36" })) : (_jsx(AddressIcon, { className: "h-4 w-4", address: values.destination_address, size: 36, rounded: "4px" })), ((isValidAddress(values?.destination_address, values?.to) && values?.to) ?
|
|
19
19
|
_jsx("div", { className: "text-sm group/addressItem text-secondary-text", children: _jsx(ExtendedAddress, { address: addressFormat(values?.destination_address, values?.to), network: values?.to, showDetails: wallet ? true : false, title: wallet?.displayName?.split("-")[0], description: wallet?.providerName, logo: wallet?.icon, shouldShowChevron: false }) })
|
|
20
20
|
:
|
|
21
21
|
_jsx("p", { className: "text-sm text-secondary-text", children: shortenAddress(values?.destination_address) }))] }) })] })), _jsxs("div", { className: "flex items-center w-full justify-between gap-1 text-sm px-2 py-3", children: [_jsx("div", { className: "inline-flex items-center text-left text-secondary-text", children: _jsx("label", { children: "Receive at least" }) }), _jsx("div", { className: "text-right text-primary-text h-5", children: quoteData?.quote?.min_receive_amount !== undefined && !isNaN(quoteData?.quote?.min_receive_amount) && (_jsx(NumberFlow, { value: quoteData?.quote?.min_receive_amount, trend: 0, format: { maximumFractionDigits: quoteData?.quote.destination_token?.decimals || 2 }, suffix: ` ${values?.toAsset?.symbol}` })) })] }), _jsx(Slippage, { quoteData: quoteData.quote, values: values }), isOpen &&
|
|
22
|
-
_jsx(GasFee, { values: values, quote: quoteData.quote }), _jsxs("div", { className: `${isOpen ? "hidden" : ""} flex items-center w-full justify-between px-2 py-3`, children: [_jsx(DetailsButton, { quote: quoteData, isQuoteLoading: isQuoteLoading, swapValues: values, destination: destination, destinationAddress: destinationAddress }), _jsxs("button", { type: "button", onClick: (e) => {
|
|
22
|
+
_jsx(GasFee, { values: values, quote: quoteData.quote }), _jsxs("div", { className: `${isOpen ? "hidden" : ""} flex items-center w-full justify-between px-2 py-3`, children: [_jsx(DetailsButton, { quote: quoteData?.quote, isQuoteLoading: isQuoteLoading, swapValues: values, destination: destination, destinationAddress: destinationAddress, reward: quoteData?.reward }), _jsxs("button", { type: "button", onClick: (e) => {
|
|
23
23
|
e.stopPropagation();
|
|
24
24
|
onOpen?.();
|
|
25
25
|
}, className: "flex items-center text-secondary-text text-sm whitespace-nowrap gap-0.5 hover:text-primary-text", "aria-label": "See details", children: [_jsx("span", { children: "See details" }), _jsx(ChevronDown, { className: "h-3.5 w-3.5" })] })] })] }));
|
|
@@ -6,12 +6,12 @@ import useWallet from '../../../../../../hooks/useWallet';
|
|
|
6
6
|
import { SummaryRow } from './SummaryRow';
|
|
7
7
|
import { DetailedEstimates } from './DetailedEstimates';
|
|
8
8
|
import { addressFormat } from '../../../../../../lib/address/formatter';
|
|
9
|
-
import { useSelectedAccount } from '../../../../../../context/
|
|
9
|
+
import { useSelectedAccount } from '../../../../../../context/swapAccounts';
|
|
10
10
|
const SwapQuoteComp = ({ swapValues: values, quote: quoteData, isQuoteLoading, partner }) => {
|
|
11
11
|
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
-
const { wallets: destWallets } = useWallet(values.to, '
|
|
13
|
-
const wallet = (values?.to && values?.destination_address) ? destWallets?.find(w => addressFormat(
|
|
12
|
+
const { wallets: destWallets } = useWallet(values.to, 'autofill');
|
|
13
|
+
const wallet = (values?.to && values?.destination_address) ? destWallets?.find(w => w.addresses?.some(a => addressFormat(a, values.to) === addressFormat(values.destination_address, values.to))) : undefined;
|
|
14
14
|
const selectedSourceAccount = useSelectedAccount("from", values?.from?.name);
|
|
15
|
-
return (_jsx(Accordion, { type: "single", collapsible: true, className: "w-full", value: isOpen ? 'quote' : '', onValueChange: (v) => setIsOpen(v === 'quote'), children: _jsxs(AccordionItem, { value: "quote", className: "bg-secondary-500 rounded-2xl", children: [_jsx(AccordionTrigger, { onClick: (e) => e.preventDefault(), className: "w-full rounded-2xl flex items-center justify-between cursor-auto", children: _jsx(SummaryRow, { isQuoteLoading: isQuoteLoading, values: values, wallet: wallet, quoteData: quoteData, destination: values.to, destinationAddress: values.destination_address, onOpen: () => setIsOpen(true), isOpen: isOpen, sourceAddress: selectedSourceAccount?.address, partner: partner }) }), _jsx(AccordionContent, { className: "rounded-2xl", children: _jsx(DetailedEstimates, { swapValues: values, quote: quoteData, variant: 'base' }) }), isOpen && (_jsx("div", { className: "px-3.5 pb-3", children: _jsxs("button", { type: "button", onClick: () => setIsOpen(false), className: "mx-auto flex items-center justify-center gap-1 text-sm text-secondary-text hover:text-primary-text", children: [_jsx("span", { children: "Close details" }), _jsx(ChevronDown, { className: "h-3.5 w-3.5 rotate-180 transition-transform" })] }) }))] }) }));
|
|
15
|
+
return (_jsx(Accordion, { type: "single", collapsible: true, className: "w-full", value: isOpen ? 'quote' : '', onValueChange: (v) => setIsOpen(v === 'quote'), children: _jsxs(AccordionItem, { value: "quote", className: "bg-secondary-500 rounded-2xl", children: [_jsx(AccordionTrigger, { onClick: (e) => e.preventDefault(), className: "w-full rounded-2xl flex items-center justify-between cursor-auto", children: _jsx(SummaryRow, { isQuoteLoading: isQuoteLoading, values: values, wallet: wallet, quoteData: quoteData, destination: values.to, destinationAddress: values.destination_address, onOpen: () => setIsOpen(true), isOpen: isOpen, sourceAddress: selectedSourceAccount?.address, partner: partner }) }), _jsx(AccordionContent, { className: "rounded-2xl", children: _jsx(DetailedEstimates, { swapValues: values, quote: quoteData?.quote, reward: quoteData?.reward, variant: 'base' }) }), isOpen && (_jsx("div", { className: "px-3.5 pb-3", children: _jsxs("button", { type: "button", onClick: () => setIsOpen(false), className: "mx-auto flex items-center justify-center gap-1 text-sm text-secondary-text hover:text-primary-text", children: [_jsx("span", { children: "Close details" }), _jsx(ChevronDown, { className: "h-3.5 w-3.5 rotate-180 transition-transform" })] }) }))] }) }));
|
|
16
16
|
};
|
|
17
17
|
export default SwapQuoteComp;
|
|
@@ -13,29 +13,28 @@ import ExchangeGasIcon from '../../../../../components/Icons/ExchangeGasIcon';
|
|
|
13
13
|
import useSWRNftBalance from '../../../../../lib/nft/useSWRNftBalance';
|
|
14
14
|
import NumberFlow from '@number-flow/react';
|
|
15
15
|
import { resolveTokenUsdPrice } from '../../../../../helpers/tokenHelper';
|
|
16
|
-
import { useSelectedAccount } from '../../../../../context/
|
|
16
|
+
import { useSelectedAccount } from '../../../../../context/swapAccounts';
|
|
17
17
|
import { CupIcon } from '../../../../../components/Icons/CupIcon';
|
|
18
18
|
import { DetailedEstimates } from './SwapQuote/DetailedEstimates';
|
|
19
|
-
export default function QuoteDetails({ swapValues: values, quote
|
|
19
|
+
export default function QuoteDetails({ swapValues: values, quote, isQuoteLoading, reward, variant = 'extended', triggerClassnames }) {
|
|
20
20
|
const { toAsset, fromAsset: fromCurrency, destination_address } = values || {};
|
|
21
21
|
const [isAccordionOpen, setIsAccordionOpen] = useState(false);
|
|
22
|
-
return (_jsx(_Fragment, { children:
|
|
23
|
-
_jsx(Accordion, { type: 'single', collapsible: true, className: 'w-full', value: isAccordionOpen ? 'quote' : '', onValueChange: (value) => { setIsAccordionOpen(value === 'quote'); }, children: _jsxs(AccordionItem, { value: 'quote', className: 'bg-secondary-500 rounded-2xl', children: [_jsxs(AccordionTrigger, { className: clsx('p-3.5 pr-5 w-full rounded-2xl flex items-center justify-between transition-colors duration-200 hover:bg-secondary-400', {
|
|
22
|
+
return (_jsx(_Fragment, { children: quote &&
|
|
23
|
+
_jsx(Accordion, { type: 'single', collapsible: true, className: 'w-full', value: isAccordionOpen ? 'quote' : '', onValueChange: (value) => { setIsAccordionOpen(value === 'quote'); }, children: _jsxs(AccordionItem, { value: 'quote', className: 'bg-secondary-500 rounded-2xl', children: [_jsxs(AccordionTrigger, { className: clsx('p-3.5 pr-5 w-full rounded-2xl flex items-center justify-between transition-colors duration-200 hover:bg-secondary-400 mt-3', triggerClassnames, {
|
|
24
24
|
'bg-secondary-500': !isAccordionOpen,
|
|
25
25
|
'bg-secondary-400': isAccordionOpen,
|
|
26
26
|
'animate-pulse-strong': isQuoteLoading && !isAccordionOpen
|
|
27
27
|
}), children: [(isAccordionOpen) ?
|
|
28
28
|
_jsx("p", { className: 'text-sm', children: "Details" })
|
|
29
29
|
:
|
|
30
|
-
_jsx(DetailsButton, { quote:
|
|
31
|
-
_jsx(DetailedEstimates, { swapValues: values, quote:
|
|
30
|
+
_jsx(DetailsButton, { quote: quote, isQuoteLoading: isQuoteLoading, swapValues: values, destination: values.to, destinationAddress: destination_address, reward: reward }), _jsx(ChevronDown, { className: 'h-3.5 w-3.5 text-secondary-text' })] }), _jsx(AccordionContent, { className: 'rounded-2xl', children: _jsx(ResizablePanel, { children: (quote || isQuoteLoading) && fromCurrency && toAsset &&
|
|
31
|
+
_jsx(DetailedEstimates, { swapValues: values, quote: quote, variant: variant, reward: reward }) }) })] }) }) }));
|
|
32
32
|
}
|
|
33
|
-
export const DetailsButton = ({ quote
|
|
34
|
-
const { quote, reward } = quoteData || {};
|
|
33
|
+
export const DetailsButton = ({ quote, reward, isQuoteLoading, swapValues: values, destination, destinationAddress }) => {
|
|
35
34
|
const isCEX = !!values.fromExchange;
|
|
36
35
|
const sourceAccountNetwork = !isCEX ? values.from : undefined;
|
|
37
36
|
const selectedSourceAccount = useSelectedAccount("from", sourceAccountNetwork?.name);
|
|
38
|
-
const { wallets } = useWallet(
|
|
37
|
+
const { wallets } = useWallet(quote?.source_network, 'withdrawal');
|
|
39
38
|
const wallet = wallets.find(w => w.id === selectedSourceAccount?.id);
|
|
40
39
|
const { gasData: gasData } = useSWRGas(selectedSourceAccount?.address, values.from, values.fromAsset, values.amount, wallet);
|
|
41
40
|
const gasTokenPriceInUsd = resolveTokenUsdPrice(gasData?.token, quote);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { SwapDataProvider } from "../../../../context/swap";
|
|
4
|
-
import { useMemo } from "react";
|
|
4
|
+
import { useMemo, useState } from "react";
|
|
5
5
|
import { NetworkExchangeTabs, Tabs, TabsContent } from "./NetworkExchangeTabs";
|
|
6
6
|
import NetworkForm from "./NetworkForm";
|
|
7
7
|
import ExchangeForm from "./ExchangeForm";
|
|
@@ -15,15 +15,39 @@ import useSWR from "swr";
|
|
|
15
15
|
import AppSettings from "../../../../lib/AppSettings";
|
|
16
16
|
import clsx from "clsx";
|
|
17
17
|
export default function Form() {
|
|
18
|
-
const { from, appName, defaultTab: defaultTabQueryParam } = useInitialSettings();
|
|
18
|
+
const { from, appName, defaultTab: defaultTabQueryParam, theme: themeName } = useInitialSettings();
|
|
19
19
|
const { sourceExchanges } = useSettingsState();
|
|
20
20
|
const defaultTab = useMemo(() => {
|
|
21
21
|
return defaultTabResolver({ from, sourceExchanges, defaultTabQueryParam });
|
|
22
22
|
}, [from, sourceExchanges]);
|
|
23
|
+
const [showBanner, setShowBanner] = useState(false);
|
|
24
|
+
// useEffect(() => {
|
|
25
|
+
// if (typeof window === "undefined") return;
|
|
26
|
+
// const sessionCountKey = "exchange_banner_session_count";
|
|
27
|
+
// const closedKey = "exchange_banner_closed";
|
|
28
|
+
// const seenKey = "exchange_banner_seen";
|
|
29
|
+
// if (sessionStorage.getItem(closedKey) === "1") return;
|
|
30
|
+
// if (!sessionStorage.getItem(seenKey)) {
|
|
31
|
+
// sessionStorage.setItem(seenKey, "1");
|
|
32
|
+
// const next =
|
|
33
|
+
// (parseInt(localStorage.getItem(sessionCountKey) || "0") || 0) + 1;
|
|
34
|
+
// localStorage.setItem(sessionCountKey, String(next));
|
|
35
|
+
// if (next <= 3) setShowBanner(true);
|
|
36
|
+
// } else {
|
|
37
|
+
// const count = parseInt(localStorage.getItem(sessionCountKey) || "0") || 0;
|
|
38
|
+
// if (count <= 3) setShowBanner(true);
|
|
39
|
+
// }
|
|
40
|
+
// }, []);
|
|
41
|
+
const dismissBanner = () => {
|
|
42
|
+
setShowBanner(false);
|
|
43
|
+
if (typeof window !== "undefined") {
|
|
44
|
+
sessionStorage.setItem("exchange_banner_closed", "1");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
23
47
|
const layerswapApiClient = new LayerSwapApiClient();
|
|
24
48
|
const { data: partnerData } = useSWR(appName && `/internal/apps?name=${appName}`, layerswapApiClient.fetcher);
|
|
25
49
|
const partner = appName && partnerData?.data?.client_id?.toLowerCase() === appName?.toLowerCase() ? partnerData?.data : undefined;
|
|
26
|
-
return _jsxs(Tabs, { defaultValue: defaultTab, children: [_jsx("div", { className: clsx("hidden sm:block", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion !== true }), children: _jsx(NetworkExchangeTabs, {}) }), _jsx(TabsContent, { value: "cross-chain", children: _jsx(SwapDataProvider, { children: _jsx(FormWrapper, { type: "cross-chain", partner: partner, children: _jsx(Widget, { contextualMenu: _jsx("div", { className: clsx("block w-full", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion == true }), children: _jsx(NetworkExchangeTabs, {}) }), children: _jsx(ValidationProvider, { children: _jsx(NetworkForm, { partner: partner }) }) }) }) }) }), _jsx(TabsContent, { value: "exchange", children: _jsx(SwapDataProvider, { children: _jsx(FormWrapper, { type: "exchange", partner: partner, children: _jsx(Widget, { contextualMenu: _jsx("div", { className: clsx("block w-full", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion == true }), children: _jsx(NetworkExchangeTabs, {}) }), children: _jsx(ValidationProvider, { children: _jsx(ExchangeForm, { partner: partner }) }) }) }) }) })] });
|
|
50
|
+
return _jsxs(Tabs, { defaultValue: defaultTab, children: [_jsx("div", { className: clsx("hidden sm:block", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion !== true }), children: _jsx(NetworkExchangeTabs, {}) }), _jsx(TabsContent, { value: "cross-chain", children: _jsx(SwapDataProvider, { children: _jsx(FormWrapper, { type: "cross-chain", partner: partner, children: _jsx(Widget, { contextualMenu: _jsx("div", { className: clsx("block w-full", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion == true }), children: _jsx(NetworkExchangeTabs, {}) }), children: _jsx(ValidationProvider, { children: _jsx(NetworkForm, { partner: partner }) }) }) }) }) }), _jsx(TabsContent, { value: "exchange", children: _jsx(SwapDataProvider, { children: _jsx(FormWrapper, { type: "exchange", partner: partner, children: _jsx(Widget, { contextualMenu: _jsx("div", { className: clsx("block w-full", { 'sm:hidden': AppSettings.ThemeData?.enableWideVersion == true }), children: _jsx(NetworkExchangeTabs, {}) }), children: _jsx(ValidationProvider, { children: _jsx(ExchangeForm, { partner: partner, showBanner: showBanner, dismissBanner: dismissBanner }) }) }) }) }) })] });
|
|
27
51
|
}
|
|
28
52
|
const defaultTabResolver = ({ from, sourceExchanges, defaultTabQueryParam }) => {
|
|
29
53
|
if (defaultTabQueryParam) {
|
|
@@ -14,9 +14,9 @@ import VaulDrawer from "../../../../components/Modal/vaulModal";
|
|
|
14
14
|
import { addressFormat } from "../../../../lib/address/formatter";
|
|
15
15
|
import AddressNote from "../../../../components/Input/Address/AddressNote";
|
|
16
16
|
import { useBalance } from "../../../../lib/balances/useBalance";
|
|
17
|
-
import { useSelectedAccount } from "../../../../context/
|
|
17
|
+
import { useSelectedAccount } from "../../../../context/swapAccounts";
|
|
18
18
|
import SwapDetails from "../Withdraw/SwapDetails";
|
|
19
|
-
import {
|
|
19
|
+
import { useCallbacks } from "../../../../context/callbackProvider";
|
|
20
20
|
export default function FormWrapper({ children, type, partner }) {
|
|
21
21
|
const formikRef = useRef(null);
|
|
22
22
|
const [showConnectNetworkModal, setShowConnectNetworkModal] = useState(false);
|
|
@@ -29,8 +29,7 @@ export default function FormWrapper({ children, type, partner }) {
|
|
|
29
29
|
const [walletWihdrawDone, setWalletWihdrawDone] = useState(false);
|
|
30
30
|
const selectedSourceAccount = useSelectedAccount("from", swapBasicData?.source_network?.name);
|
|
31
31
|
const { mutate: mutateBalances } = useBalance(selectedSourceAccount?.address, sourceNetworkWithTokens);
|
|
32
|
-
const
|
|
33
|
-
const triggerSwapCreateCallback = useSwapCreateCallback();
|
|
32
|
+
const { onSwapModalStateChange } = useCallbacks();
|
|
34
33
|
const { getConfirmation } = useAsyncModal();
|
|
35
34
|
const initialSettings = useInitialSettings();
|
|
36
35
|
const { destination_address: destinationAddressFromQuery } = initialSettings;
|
|
@@ -48,7 +47,7 @@ export default function FormWrapper({ children, type, partner }) {
|
|
|
48
47
|
destinationAddressFromQuery &&
|
|
49
48
|
(addressFormat(destinationAddressFromQuery?.toString(), to) === addressFormat(destination_address, to)) &&
|
|
50
49
|
!isAddressFromQueryConfirmed) {
|
|
51
|
-
const provider = to && getProvider(to, '
|
|
50
|
+
const provider = to && getProvider(to, 'autofill');
|
|
52
51
|
const isDestAddressConnected = destination_address && provider?.connectedWallets?.some((wallet) => addressFormat(wallet.address, to) === addressFormat(destination_address, to));
|
|
53
52
|
const confirmed = !isDestAddressConnected ? await getConfirmation({
|
|
54
53
|
content: _jsx(AddressNote, { partner: partner, values: values }),
|
|
@@ -71,7 +70,6 @@ export default function FormWrapper({ children, type, partner }) {
|
|
|
71
70
|
partner,
|
|
72
71
|
createSwap: async (...props) => {
|
|
73
72
|
const response = await createSwap(...props);
|
|
74
|
-
triggerSwapCreateCallback(response);
|
|
75
73
|
return response;
|
|
76
74
|
},
|
|
77
75
|
setShowSwapModal: handleShowSwapModal,
|
|
@@ -87,7 +85,7 @@ export default function FormWrapper({ children, type, partner }) {
|
|
|
87
85
|
: generateSwapInitialValues(settings, initialSettings, type);
|
|
88
86
|
const handleShowSwapModal = useCallback((value) => {
|
|
89
87
|
setSwapModalOpen(value);
|
|
90
|
-
|
|
88
|
+
onSwapModalStateChange(value);
|
|
91
89
|
if (!value) {
|
|
92
90
|
if (walletWihdrawDone) {
|
|
93
91
|
mutateBalances();
|
|
@@ -100,7 +98,7 @@ export default function FormWrapper({ children, type, partner }) {
|
|
|
100
98
|
setWalletWihdrawDone(true);
|
|
101
99
|
}, []);
|
|
102
100
|
return _jsx(_Fragment, { children: _jsx(Formik, { innerRef: formikRef, initialValues: initialValues, validateOnMount: true, onSubmit: handleSubmit, children: _jsxs(_Fragment, { children: [_jsx(VaulDrawer, { show: showConnectNetworkModal, setShow: setShowConnectNetworkModal, header: `${networkToConnect?.DisplayName} connect`, modalId: "showNetwork", children: _jsx(VaulDrawer.Snap, { id: "item-1", children: networkToConnect &&
|
|
103
|
-
_jsx(ConnectNetwork, { NetworkDisplayName: networkToConnect?.DisplayName, AppURL: networkToConnect?.AppURL }) }) }), _jsx(VaulDrawer, { show: swapModalOpen, setShow: handleShowSwapModal, header: `Complete the swap`, modalId: "showSwap", className: !swapBasicData?.use_deposit_address ? "
|
|
101
|
+
_jsx(ConnectNetwork, { NetworkDisplayName: networkToConnect?.DisplayName, AppURL: networkToConnect?.AppURL }) }) }), _jsx(VaulDrawer, { show: swapModalOpen, setShow: handleShowSwapModal, header: `Complete the swap`, modalId: "showSwap", className: !swapBasicData?.use_deposit_address ? "expandContainerHeight" : "", children: _jsx(VaulDrawer.Snap, { id: "item-1", children: _jsx(SwapDetails, { type: "contained", onWalletWithdrawalSuccess: handleWalletWithdrawalSuccess, partner: partner, onCancelWithdrawal: () => handleShowSwapModal(false) }) }) }), children] }) }) });
|
|
104
102
|
}
|
|
105
103
|
const handleCreateSwap = async ({ query, values, partner, setShowSwapModal, createSwap, setNetworkToConnect, setShowConnectNetworkModal, setSwapId, setSubmitedFormValues }) => {
|
|
106
104
|
setSubmitedFormValues(values);
|
|
@@ -130,15 +128,11 @@ const handleCreateSwap = async ({ query, values, partner, setShowSwapModal, crea
|
|
|
130
128
|
setShowConnectNetworkModal(true);
|
|
131
129
|
}
|
|
132
130
|
else if (data?.code === LSAPIKnownErrorCode.NETWORK_CURRENCY_DAILY_LIMIT_REACHED) {
|
|
133
|
-
const time = data.metadata.RemainingLimitPeriod?.split(':');
|
|
134
|
-
const hours = Number(time[0]);
|
|
135
|
-
const minutes = Number(time[1]);
|
|
136
|
-
const remainingTime = `${hours > 0 ? `${hours.toFixed()} ${(hours > 1 ? 'hours' : 'hour')}` : ''} ${minutes > 0 ? `${minutes.toFixed()} ${(minutes > 1 ? 'minutes' : 'minute')}` : ''}`;
|
|
137
131
|
if (data.metadata.AvailableTransactionAmount) {
|
|
138
|
-
throw new Error(`Daily limit of ${values.fromAsset?.symbol} transfers from ${values.from?.display_name} is reached. Please try sending up to ${data.metadata.AvailableTransactionAmount} ${values.fromAsset?.symbol}
|
|
132
|
+
throw new Error(`Daily limit of ${values.fromAsset?.symbol} transfers from ${values.from?.display_name} is reached. Please try sending up to ${data.metadata.AvailableTransactionAmount} ${values.fromAsset?.symbol}.`);
|
|
139
133
|
}
|
|
140
134
|
else {
|
|
141
|
-
throw new Error(`Daily limit of ${values.fromAsset?.symbol} transfers from ${values.from?.display_name} is reached
|
|
135
|
+
throw new Error(`Daily limit of ${values.fromAsset?.symbol} transfers from ${values.from?.display_name} is reached.`);
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
138
|
else {
|
|
@@ -18,12 +18,12 @@ import { transformFormValuesToQuoteArgs, useQuoteData } from "../../../../hooks/
|
|
|
18
18
|
import { useValidationContext } from "../../../../context/validationContext";
|
|
19
19
|
import { useSwapDataState } from "../../../../context/swap";
|
|
20
20
|
import ReserveGasNote from "../../../../components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote";
|
|
21
|
-
import { useSelectedAccount } from "../../../../context/
|
|
21
|
+
import { useSelectedAccount } from "../../../../context/swapAccounts";
|
|
22
22
|
import QuoteDetails from "./FeeDetails";
|
|
23
23
|
import DepositMethodComponent from "./FeeDetails/DepositMethod";
|
|
24
24
|
import RefuelToggle from "./FeeDetails/Refuel";
|
|
25
25
|
import RefuelModal from "./FeeDetails/RefuelModal";
|
|
26
|
-
import {
|
|
26
|
+
import { useCallbacks } from "../../../../context/callbackProvider";
|
|
27
27
|
const NetworkForm = ({ partner }) => {
|
|
28
28
|
const [openRefuelModal, setOpenRefuelModal] = useState(false);
|
|
29
29
|
const { values, setValues, isSubmitting, setFieldValue, } = useFormikContext();
|
|
@@ -40,10 +40,10 @@ const NetworkForm = ({ partner }) => {
|
|
|
40
40
|
const initialSettings = useInitialSettings();
|
|
41
41
|
const isValid = !formValidation.message;
|
|
42
42
|
const error = formValidation.message;
|
|
43
|
-
const
|
|
43
|
+
const { onFormChange } = useCallbacks();
|
|
44
44
|
useEffect(() => {
|
|
45
|
-
|
|
46
|
-
}, [values,
|
|
45
|
+
onFormChange(values);
|
|
46
|
+
}, [values, onFormChange]);
|
|
47
47
|
useEffect(() => {
|
|
48
48
|
if (!source || !toAsset || !toAsset.refuel) {
|
|
49
49
|
setFieldValue('refuel', false, true);
|
|
@@ -54,14 +54,12 @@ const NetworkForm = ({ partner }) => {
|
|
|
54
54
|
setFieldValue('amount', (nativeTokenBalance?.amount - networkGas).toString(), true);
|
|
55
55
|
}, [setFieldValue]);
|
|
56
56
|
const shouldConnectWallet = (source && source?.deposit_methods?.includes('wallet') && depositMethod !== 'deposit_address' && !selectedSourceAccount) || (!source && !wallets.length && depositMethod !== 'deposit_address');
|
|
57
|
-
return (_jsxs(_Fragment, { children: [_jsx(DepositMethodComponent, {}), _jsxs(Form, { className: "h-full grow flex flex-col flex-1 justify-between w-full gap-3", children: [_jsx(Widget.Content, { children: _jsxs("div", { className: "w-full flex flex-col justify-between flex-1
|
|
58
|
-
_jsx(ValueSwapperButton, { values: values, setValues: setValues, providers: providers, query: initialSettings }), !(initialSettings?.hideTo && values?.to) && _jsx(DestinationPicker, { isFeeLoading: isQuoteLoading, fee: quote, partner: partner })] }), Number(values.amount) > 0
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
? _jsx(ValidationError, {})
|
|
64
|
-
: null, _jsx(QuoteDetails, { swapValues: values, quote: quote, isQuoteLoading: isQuoteLoading })] }) }), _jsx(Widget.Footer, { showPoweredBy: true, children: _jsx(FormButton, { shouldConnectWallet: shouldConnectWallet, values: values, disabled: !isValid || isSubmitting || !quote || isQuoteLoading, error: error, isSubmitting: isSubmitting, partner: partner }) }), _jsx(RefuelModal, { openModal: openRefuelModal, setOpenModal: setOpenRefuelModal, fee: quote })] })] }));
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsx(DepositMethodComponent, {}), _jsxs(Form, { className: "h-full grow flex flex-col flex-1 justify-between w-full gap-3", children: [_jsx(Widget.Content, { children: _jsxs("div", { className: "w-full flex flex-col justify-between flex-1", children: [_jsxs("div", { className: 'flex-col relative flex justify-between gap-2 w-full leading-4', children: [!(initialSettings?.hideFrom && values?.from) && _jsx(SourcePicker, { minAllowedAmount: minAllowedAmount, maxAllowedAmount: maxAllowedAmount, fee: quote }), !initialSettings?.hideFrom && !initialSettings?.hideTo &&
|
|
58
|
+
_jsx(ValueSwapperButton, { values: values, setValues: setValues, providers: providers, query: initialSettings }), !(initialSettings?.hideTo && values?.to) && _jsx(DestinationPicker, { isFeeLoading: isQuoteLoading, fee: quote, partner: partner })] }), _jsxs("div", { children: [Number(values.amount) > 0 &&
|
|
59
|
+
_jsx(ReserveGasNote, { maxAllowedAmount: maxAllowedAmount, minAllowedAmount: minAllowedAmount, onSubmit: handleReserveGas }), values.toAsset?.refuel && !initialSettings.hideRefuel &&
|
|
60
|
+
_jsx(RefuelToggle, { quote: quote, onButtonClick: () => setOpenRefuelModal(true), minAllowedAmount: minAllowedAmount }), routeValidation.message
|
|
61
|
+
? _jsx("div", { className: "mt-3", children: _jsx(ValidationError, {}) })
|
|
62
|
+
: null, _jsx(QuoteDetails, { swapValues: values, quote: quote?.quote, reward: quote?.reward, isQuoteLoading: isQuoteLoading })] })] }) }), _jsx(Widget.Footer, { showPoweredBy: true, children: _jsx(FormButton, { shouldConnectWallet: shouldConnectWallet, values: values, disabled: !isValid || isSubmitting || !quote || isQuoteLoading, error: error, isSubmitting: isSubmitting, partner: partner }) }), _jsx(RefuelModal, { openModal: openRefuelModal, setOpenModal: setOpenRefuelModal, fee: quote })] })] }));
|
|
65
63
|
};
|
|
66
64
|
const ValueSwapperButton = ({ values, setValues, providers, query }) => {
|
|
67
65
|
const [animate, cycle] = useCycle({ rotateX: 0 }, { rotateX: 180 });
|