@layerswap/widget 1.0.6 → 1.1.1
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 +12 -12
- package/dist/esm/components/HeaderWithMenu.js +1 -1
- package/dist/esm/components/Icons/CircularLoader.js +5 -0
- package/dist/esm/components/Icons/FailIcon.js +2 -2
- package/dist/esm/components/Icons/GlobeIcon.js +3 -0
- package/dist/esm/components/Icons/MenuIcon.js +5 -0
- package/dist/esm/components/Icons/TokenIcon.js +1 -1
- package/dist/esm/components/Icons/Wallets/index.js +0 -1
- package/dist/esm/components/Input/Address/AddressNote.js +2 -2
- package/dist/esm/components/Input/Address/AddressPicker/AddressWithIcon.js +5 -2
- package/dist/esm/components/Input/Address/AddressPicker/index.js +15 -12
- package/dist/esm/components/Input/Address/ContractAddressNote.js +17 -0
- package/dist/esm/components/Input/Address/UrlAddressNote.js +10 -0
- 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 -40
- 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 +19 -3
- package/dist/esm/components/Input/RoutePicker/RouteTokenSwitch.js +4 -4
- package/dist/esm/components/Input/RoutePicker/RouterPickerWalletConnect.js +5 -5
- package/dist/esm/components/Input/RoutePicker/Routes.js +27 -26
- 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/TokenTitleDetails.js +10 -0
- package/dist/esm/components/Input/RoutePicker/index.js +2 -2
- package/dist/esm/components/Input/SourceWalletPicker.js +6 -4
- package/dist/esm/components/Menu/MenuList.js +11 -19
- package/dist/esm/components/Menu/index.js +16 -7
- package/dist/esm/components/Modal/modalWithoutAnimation.js +3 -3
- 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 +3 -4
- 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 +6 -4
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Refuel.js +8 -3
- 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 +10 -11
- package/dist/esm/components/Pages/Swap/Form/Form.js +27 -3
- package/dist/esm/components/Pages/Swap/Form/FormWrapper.js +35 -10
- package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +13 -22
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/FormButton.js +1 -1
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/validationError/ContractAddressValidationCache.js +19 -0
- 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 +44 -45
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/Summary.js +2 -3
- 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 +125 -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/Message.js +4 -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/HistorySummary.js +1 -1
- package/dist/esm/components/Pages/SwapHistory/index.js +4 -4
- package/dist/esm/components/Select/Selector/SelectItem.js +1 -1
- package/dist/esm/components/Wallet/WalletComponents/ConnectedWallets.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 +78 -125
- package/dist/esm/components/Wallet/WalletModal/InstalledExtensionNotFound.js +16 -0
- package/dist/esm/components/Wallet/WalletModal/LoadingConnect.js +27 -0
- package/dist/esm/components/Wallet/WalletModal/MultichainConnectorPicker.js +23 -0
- package/dist/esm/components/Wallet/WalletModal/ProviderPicker.js +26 -0
- package/dist/esm/components/Wallet/WalletModal/WalletQrCode.js +18 -0
- package/dist/esm/components/Wallet/WalletModal/index.js +4 -2
- 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 +21 -21
- package/dist/esm/components/Widget/Index.js +2 -2
- package/dist/esm/components/WidgetLoading.js +9 -2
- package/dist/esm/components/shadcn/checkbox.js +1 -1
- package/dist/esm/context/ErrorProvider.js +14 -0
- package/dist/esm/context/LayerswapProvider.js +6 -5
- package/dist/esm/context/callbackProvider.js +60 -52
- package/dist/esm/context/resolverContext.js +11 -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 +11 -5
- package/dist/esm/hooks/useConnectors.js +72 -0
- 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/address/contractAddressResolver.js +12 -0
- package/dist/esm/lib/apiClients/layerSwapApiClient.js +19 -35
- package/dist/esm/lib/balances/balanceResolver.js +57 -11
- package/dist/esm/lib/balances/errorUtils.js +13 -0
- package/dist/esm/lib/balances/nodeErrorClassifier.js +22 -0
- package/dist/esm/lib/fees.js +50 -0
- package/dist/esm/lib/generateSwapInitialValues.js +2 -2
- package/dist/esm/lib/isNewListed.js +8 -0
- package/dist/esm/lib/knownIds.js +1 -0
- package/dist/esm/lib/resolvers/resolverService.js +19 -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 +39 -18
- package/dist/esm/stores/contractAddressStore.js +178 -0
- package/dist/esm/stores/logStore.js +11 -0
- package/dist/esm/types/balance.js +23 -11
- package/dist/esm/types/contract.js +1 -0
- package/dist/esm/types/index.js +2 -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 +14 -2
- package/dist/types/Models/Balance.d.ts.map +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/CircularLoader.d.ts +4 -0
- package/dist/types/components/Icons/CircularLoader.d.ts.map +1 -0
- package/dist/types/components/Icons/FailIcon.d.ts.map +1 -1
- package/dist/types/components/Icons/GasIcon.d.ts.map +1 -1
- package/dist/types/components/Icons/GlobeIcon.d.ts +4 -0
- package/dist/types/components/Icons/GlobeIcon.d.ts.map +1 -0
- package/dist/types/components/Icons/MenuIcon.d.ts +4 -0
- package/dist/types/components/Icons/MenuIcon.d.ts.map +1 -0
- package/dist/types/components/Icons/TokenIcon.d.ts.map +1 -1
- package/dist/types/components/Icons/Wallets/index.d.ts +0 -1
- package/dist/types/components/Icons/Wallets/index.d.ts.map +1 -1
- package/dist/types/components/Input/Address/AddressNote.d.ts +5 -5
- package/dist/types/components/Input/Address/AddressNote.d.ts.map +1 -1
- 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 +3 -2
- package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts.map +1 -1
- 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/ContractAddressNote.d.ts +9 -0
- package/dist/types/components/Input/Address/ContractAddressNote.d.ts.map +1 -0
- package/dist/types/components/Input/Address/UrlAddressNote.d.ts +10 -0
- package/dist/types/components/Input/Address/UrlAddressNote.d.ts.map +1 -0
- 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 +3 -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/RouterPickerWalletConnect.d.ts.map +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/TokenTitleDetails.d.ts +18 -0
- package/dist/types/components/Input/RoutePicker/TokenTitleDetails.d.ts.map +1 -0
- 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/Menu/MenuList.d.ts.map +1 -1
- package/dist/types/components/Menu/index.d.ts.map +1 -1
- package/dist/types/components/Modal/modalWithoutAnimation.d.ts +4 -2
- package/dist/types/components/Modal/modalWithoutAnimation.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 -2
- 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/FormButton.d.ts.map +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/ContractAddressValidationCache.d.ts +10 -0
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ContractAddressValidationCache.d.ts.map +1 -0
- 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/Summary/Summary.d.ts.map +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/Message.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/HistorySummary.d.ts.map +1 -1
- 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/Select/Command/commandSelect.d.ts.map +1 -1
- package/dist/types/components/Select/Selector/SelectItem.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/InstalledExtensionNotFound.d.ts +7 -0
- package/dist/types/components/Wallet/WalletModal/InstalledExtensionNotFound.d.ts.map +1 -0
- package/dist/types/components/Wallet/WalletModal/LoadingConnect.d.ts +8 -0
- package/dist/types/components/Wallet/WalletModal/LoadingConnect.d.ts.map +1 -0
- package/dist/types/components/Wallet/WalletModal/MultichainConnectorPicker.d.ts +12 -0
- package/dist/types/components/Wallet/WalletModal/MultichainConnectorPicker.d.ts.map +1 -0
- package/dist/types/components/Wallet/WalletModal/ProviderPicker.d.ts +8 -0
- package/dist/types/components/Wallet/WalletModal/ProviderPicker.d.ts.map +1 -0
- package/dist/types/components/Wallet/WalletModal/WalletQrCode.d.ts +6 -0
- package/dist/types/components/Wallet/WalletModal/WalletQrCode.d.ts.map +1 -0
- package/dist/types/components/Wallet/WalletModal/index.d.ts +2 -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 +7 -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/useConnectors.d.ts +28 -0
- package/dist/types/hooks/useConnectors.d.ts.map +1 -0
- 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/address/contractAddressResolver.d.ts +7 -0
- package/dist/types/lib/address/contractAddressResolver.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/errorUtils.d.ts +12 -0
- package/dist/types/lib/balances/errorUtils.d.ts.map +1 -0
- package/dist/types/lib/balances/helpers.d.ts +1 -1
- package/dist/types/lib/balances/nodeErrorClassifier.d.ts +4 -0
- package/dist/types/lib/balances/nodeErrorClassifier.d.ts.map +1 -0
- 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/isNewListed.d.ts +4 -0
- package/dist/types/lib/isNewListed.d.ts.map +1 -0
- package/dist/types/lib/knownIds.d.ts +1 -0
- package/dist/types/lib/knownIds.d.ts.map +1 -1
- package/dist/types/lib/nft/nftBalanceResolver.d.ts +1 -1
- package/dist/types/lib/resolvers/resolverService.d.ts +11 -5
- package/dist/types/lib/resolvers/resolverService.d.ts.map +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 +3 -0
- package/dist/types/stores/balanceStore.d.ts.map +1 -1
- package/dist/types/stores/contractAddressStore.d.ts +43 -0
- package/dist/types/stores/contractAddressStore.d.ts.map +1 -0
- 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/contract.d.ts +6 -0
- package/dist/types/types/contract.d.ts.map +1 -0
- package/dist/types/types/gas.d.ts +2 -2
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/logEvents.d.ts +59 -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 +29 -8
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/esm/components/Icons/Wallets/Keplr.js +0 -3
- package/dist/esm/components/Modal/popover.js +0 -15
- package/dist/esm/components/Wallet/WalletModal/utils.js +0 -23
- package/dist/esm/helpers/querryHelper.js +0 -13
- package/dist/esm/lib/logError.js +0 -17
- package/dist/esm/lib/sorting.js +0 -63
- package/dist/types/components/Icons/Wallets/Keplr.d.ts +0 -4
- package/dist/types/components/Icons/Wallets/Keplr.d.ts.map +0 -1
- package/dist/types/components/Modal/popover.d.ts +0 -12
- package/dist/types/components/Modal/popover.d.ts.map +0 -1
- package/dist/types/components/Wallet/WalletModal/utils.d.ts +0 -2
- package/dist/types/components/Wallet/WalletModal/utils.d.ts.map +0 -1
- 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/types/lib/sorting.d.ts +0 -22
- package/dist/types/lib/sorting.d.ts.map +0 -1
|
@@ -16,12 +16,13 @@ import { useSwapTransactionStore } from '../../../../../stores/swapTransactionSt
|
|
|
16
16
|
import CountdownTimer from '../../../../../components/Common/CountDownTimer';
|
|
17
17
|
import useSWR from 'swr';
|
|
18
18
|
import { useIntercom } from 'react-use-intercom';
|
|
19
|
-
import logError from '../../../../../lib/logError';
|
|
20
|
-
// import { posthog } from 'posthog-js';
|
|
21
19
|
import Steps from './StepsComponent';
|
|
20
|
+
import { useCallbacks } from '../../../../../context/callbackProvider';
|
|
21
|
+
import { ErrorHandler } from '../../../../../lib/ErrorHandler';
|
|
22
22
|
const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
23
|
-
const { boot, show, update
|
|
23
|
+
const { boot, show, update } = useIntercom();
|
|
24
24
|
const { setSwapTransaction, swapTransactions } = useSwapTransactionStore();
|
|
25
|
+
const { onSwapStatusChange } = useCallbacks();
|
|
25
26
|
const { source_network, destination_network, destination_token, } = swapBasicData;
|
|
26
27
|
const { fail_reason } = swapDetails;
|
|
27
28
|
const updateWithProps = () => update({ customAttributes: { swapId: swapDetails.id } });
|
|
@@ -42,17 +43,6 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
42
43
|
const { data: inputTxStatusData } = useSWR((transactionHash && swapInputTransaction?.status !== BackendTransactionStatus.Completed) ? [source_network?.name, transactionHash] : null, ([network, tx_id]) => apiClient.GetTransactionStatus(network, tx_id), { dedupingInterval: 6000 });
|
|
43
44
|
const inputTxStatus = swapInputTransaction ? swapInputTransaction.status : inputTxStatusData?.data?.status.toLowerCase();
|
|
44
45
|
const loggedNotDetectedTxAt = useRef(null);
|
|
45
|
-
const handleSupportClick = useCallback(() => {
|
|
46
|
-
const transactionHash = swapInputTransaction?.transaction_hash || storedWalletTransaction?.hash;
|
|
47
|
-
const message = `Hi! My transaction (Swap ID: ${swapDetails.id}) has been processing for longer than expected. ${transactionHash ? `Transaction hash: ${transactionHash}` : ''} Could you please help me check the status?`;
|
|
48
|
-
boot();
|
|
49
|
-
update({
|
|
50
|
-
customAttributes: {
|
|
51
|
-
swapId: swapDetails.id,
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
showNewMessages(message);
|
|
55
|
-
}, [boot, show, update, swapDetails.id, swapInputTransaction, storedWalletTransaction]);
|
|
56
46
|
useEffect(() => {
|
|
57
47
|
if (inputTxStatus === TransactionStatus.Completed || inputTxStatus === TransactionStatus.Pending) {
|
|
58
48
|
if (swapDetails?.transactions?.find(t => t.type === TransactionType.Input) || !swapDetails) {
|
|
@@ -60,7 +50,14 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
60
50
|
}
|
|
61
51
|
if (Date.now() - (loggedNotDetectedTxAt.current || storedWalletTransaction.timestamp) > 60000) {
|
|
62
52
|
loggedNotDetectedTxAt.current = Date.now();
|
|
63
|
-
|
|
53
|
+
const error = new Error(`Transaction not detected in ${source_network.name}. Tx hash: \`${transactionHash}\`. Tx status: ${inputTxStatus}. Swap id: \`${swapDetails.id}\`. ${source_network.display_name} explorer: ${source_network?.transaction_explorer_template?.replace("{0}", transactionHash)} . LS explorer: https://layerswap.io/explorer/${storedWalletTransaction?.hash} `);
|
|
54
|
+
ErrorHandler({
|
|
55
|
+
type: "TransactionNotDetected",
|
|
56
|
+
message: error.message,
|
|
57
|
+
name: error.name,
|
|
58
|
+
stack: error.stack,
|
|
59
|
+
cause: error.cause
|
|
60
|
+
});
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}, [swapDetails, storedWalletTransaction, source_network]);
|
|
@@ -71,33 +68,35 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
71
68
|
useEffect(() => {
|
|
72
69
|
if (inputTxStatus === TransactionStatus.Failed) {
|
|
73
70
|
const err = new Error("Transaction failed");
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
const error = new Error(`Swap:${swapDetails?.id} transaction:${transactionHash} failed`);
|
|
72
|
+
error.name = `TransactionFailed`;
|
|
73
|
+
error.cause = err;
|
|
74
|
+
ErrorHandler({
|
|
75
|
+
type: "TransactionFailed",
|
|
76
|
+
message: error.message,
|
|
77
|
+
name: error.name,
|
|
78
|
+
stack: error.stack,
|
|
79
|
+
cause: error.cause,
|
|
80
|
+
swapId: swapDetails?.id,
|
|
81
|
+
transactionHash: transactionHash,
|
|
82
|
+
fromAddress: swapInputTransaction?.from,
|
|
83
|
+
toAddress: swapBasicData?.destination_address
|
|
84
|
+
});
|
|
86
85
|
}
|
|
87
86
|
}, [inputTxStatus, transactionHash, swapDetails?.id]);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const status = swapDetails?.status;
|
|
89
|
+
if (status === SwapStatus.Completed ||
|
|
90
|
+
status === SwapStatus.Failed ||
|
|
91
|
+
status === SwapStatus.Expired ||
|
|
92
|
+
status === SwapStatus.LsTransferPending) {
|
|
93
|
+
onSwapStatusChange({
|
|
94
|
+
type: status,
|
|
95
|
+
swapId: swapDetails?.id,
|
|
96
|
+
path: 'Processing',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, [swapDetails?.status, swapDetails?.id]);
|
|
101
100
|
const truncatedRefuelAmount = refuel && truncateDecimals(refuel.amount, refuel.token?.precision);
|
|
102
101
|
const progressStatuses = getProgressStatuses(swapDetails, refuel, inputTxStatusData?.data?.status.toLowerCase());
|
|
103
102
|
const stepStatuses = progressStatuses.stepStatuses;
|
|
@@ -110,7 +109,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
110
109
|
},
|
|
111
110
|
current: {
|
|
112
111
|
name: 'Processing your deposit',
|
|
113
|
-
description: _jsxs("div", { className: 'flex space-x-1', children: [_jsx("div", { className: 'flex items-center space-x-1', children: _jsx(LinkWithIcon, { name: 'View in explorer', url: input_tx_explorer?.replace("{0}", transactionHash) }) }), _jsx("div", { children: _jsx("span", { children: swapInputTransaction && swapInputTransaction?.confirmations && (_jsxs("div", { children: [_jsx("span", { className: 'whitespace-nowrap', children: "| Confirmations" }), _jsxs("span", { className: "text-primary-text ml-1", children: [_jsx("span", { children: swapInputTransaction?.confirmations >= swapInputTransaction?.max_confirmations
|
|
112
|
+
description: _jsxs("div", { className: 'flex space-x-1', children: [_jsx("div", { className: 'flex items-center space-x-1', children: _jsx(LinkWithIcon, { name: 'View in explorer', url: input_tx_explorer?.replace("{0}", transactionHash) }) }), _jsx("div", { children: _jsx("span", { children: swapInputTransaction && swapInputTransaction?.confirmations > 0 && (_jsxs("div", { children: [_jsx("span", { className: 'whitespace-nowrap', children: "| Confirmations " }), _jsxs("span", { className: "text-primary-text ml-1", children: [_jsx("span", { children: swapInputTransaction?.confirmations >= swapInputTransaction?.max_confirmations
|
|
114
113
|
? swapInputTransaction?.max_confirmations
|
|
115
114
|
: swapInputTransaction?.confirmations }), _jsx("span", { children: "/" }), swapInputTransaction?.max_confirmations] })] })) }) })] })
|
|
116
115
|
},
|
|
@@ -147,7 +146,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
147
146
|
},
|
|
148
147
|
complete: {
|
|
149
148
|
name: `${swapOutputTransaction?.amount && truncateDecimals(swapOutputTransaction?.amount, destination_token.decimals)} ${destination_token.symbol} was sent to your address`,
|
|
150
|
-
description: swapOutputTransaction ? _jsx("div", { className: "flex flex-col", children: _jsxs("div", { className: 'flex items-center space-x-1', children: [_jsx("span", { children: "Transaction: " }), _jsx(LinkWithIcon, { name: 'View in explorer', url: output_tx_explorer?.replace("{0}", swapOutputTransaction.transaction_hash) })] }) }) : null,
|
|
149
|
+
description: swapOutputTransaction?.amount ? _jsx("div", { className: "flex flex-col", children: _jsxs("div", { className: 'flex items-center space-x-1', children: [_jsx("span", { children: "Transaction: " }), _jsx(LinkWithIcon, { name: 'View in explorer', url: output_tx_explorer?.replace("{0}", swapOutputTransaction.transaction_hash) })] }) }) : null,
|
|
151
150
|
},
|
|
152
151
|
failed: {
|
|
153
152
|
name: (swapDetails.status === SwapStatus.PendingRefund || swapDetails.status === SwapStatus.Refunded)
|
|
@@ -237,7 +236,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
|
|
|
237
236
|
let currentSteps = allSteps.filter((s) => s.status && s.status != ProgressStatus.Removed);
|
|
238
237
|
let stepsProgressPercentage = currentSteps.filter(x => x.status == ProgressStatus.Complete).length / currentSteps.length * 100;
|
|
239
238
|
const swapStatus = swapDetails.status;
|
|
240
|
-
return (_jsx(Widget.Content, { children: _jsxs("div", { className: `w-full min-h-[410px] h-full space-y-3 flex flex-col justify-between text-primary-text`, children: [_jsx(SwapSummary, {}), _jsxs("div", { className: "bg-secondary-500 font-normal px-3 pt-6 pb-3 rounded-2xl space-y-4 flex flex-col w-full relative z-10 divide-y-2 divide-secondary-300 divide-dashed", children: [_jsx("div", { className: 'pb-4', children: _jsxs("div", { className: 'flex flex-col gap-2 items-center', children: [_jsxs("div", { className: 'flex items-center', children: [swapStatus === SwapStatus.PendingRefund && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-primary/20", children: _jsx(Undo2, { className: "h-7 w-7 text-primary", "aria-hidden": "true" }) })), swapStatus === SwapStatus.Refunded && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center", children: _jsx(CircleCheck, { className: "h-10 w-10 text-primary", strokeWidth: 2, "aria-hidden": "true" }) })), swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded && (_jsx(Gauge, { value: stepsProgressPercentage, size: "small", showCheckmark: swapStatus === SwapStatus.Completed }))] }), _jsxs("div", { className: "flex-col text-center ", children: [_jsx("span", { className: "font-medium text-primary-text", children: progressStatuses.generalStatus.title }), progressStatuses.generalStatus.subTitle &&
|
|
239
|
+
return (_jsx(Widget.Content, { fitContent: true, children: _jsxs("div", { className: `w-full min-h-[410px] h-full space-y-3 flex flex-col justify-between text-primary-text`, children: [_jsx(SwapSummary, {}), _jsxs("div", { className: "bg-secondary-500 font-normal px-3 pt-6 pb-3 rounded-2xl space-y-4 flex flex-col w-full relative z-10 divide-y-2 divide-secondary-300 divide-dashed", children: [_jsx("div", { className: 'pb-4', children: _jsxs("div", { className: 'flex flex-col gap-2 items-center', children: [_jsxs("div", { className: 'flex items-center', children: [swapStatus === SwapStatus.PendingRefund && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-primary/20", children: _jsx(Undo2, { className: "h-7 w-7 text-primary", "aria-hidden": "true" }) })), swapStatus === SwapStatus.Refunded && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center", children: _jsx(CircleCheck, { className: "h-10 w-10 text-primary", strokeWidth: 2, "aria-hidden": "true" }) })), swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded && (_jsx(Gauge, { value: stepsProgressPercentage, size: "small", showCheckmark: swapStatus === SwapStatus.Completed }))] }), _jsxs("div", { className: "flex-col text-center ", children: [_jsx("span", { className: "font-medium text-primary-text", children: progressStatuses.generalStatus.title }), progressStatuses.generalStatus.subTitle &&
|
|
241
240
|
_jsx("span", { className: "text-sm block text-secondary-text", children: progressStatuses.generalStatus.subTitle }), swapOutputTransaction?.status != BackendTransactionStatus.Completed && (swapStatus !== SwapStatus.Cancelled && swapStatus !== SwapStatus.Expired && swapStatus !== SwapStatus.Failed && swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded) &&
|
|
242
241
|
_jsx("span", { className: 'text-sm block space-x-1 text-secondary-text', children: _jsx("span", { children: countDownTimer }) })] })] }) }), _jsxs("div", { className: 'pt-4', children: [swapStatus != SwapStatus.Cancelled && swapStatus != SwapStatus.Expired && currentSteps.find(x => x.status != null) &&
|
|
243
242
|
_jsx("div", { className: 'flex flex-col justify-center space-y-4', children: _jsx(Steps, { steps: currentSteps }) }), ([SwapStatus.Expired, SwapStatus.Cancelled, SwapStatus.UserTransferDelayed].includes(swapStatus)) &&
|
|
@@ -269,8 +268,8 @@ const getProgressStatuses = (swapDetails, refuel, inputTxStatusFromApi) => {
|
|
|
269
268
|
subtitle = null;
|
|
270
269
|
}
|
|
271
270
|
let input_transfer = transactionStatusToProgressStatus(swapInputTxStatus) || '';
|
|
272
|
-
let output_transfer = swapOutputTransaction?.transaction_hash ? ProgressStatus.Complete : inputIsCompleted ? ProgressStatus.Current : ProgressStatus.Upcoming;
|
|
273
|
-
let refuel_transfer = swapRefuelTransaction?.transaction_hash ? ProgressStatus.Complete : !!refuel ? ProgressStatus.Upcoming : ProgressStatus.Removed;
|
|
271
|
+
let output_transfer = (swapOutputTransaction?.transaction_hash && swapOutputTransaction?.amount) ? ProgressStatus.Complete : inputIsCompleted ? ProgressStatus.Current : ProgressStatus.Upcoming;
|
|
272
|
+
let refuel_transfer = (swapRefuelTransaction?.transaction_hash && swapRefuelTransaction?.amount) ? ProgressStatus.Complete : !!refuel ? ProgressStatus.Upcoming : ProgressStatus.Removed;
|
|
274
273
|
let refund_status = ProgressStatus.Removed;
|
|
275
274
|
if (swapStatus === SwapStatus.PendingRefund || swapStatus === SwapStatus.Refunded) {
|
|
276
275
|
// For refund cases: 1) Deposit Confirmed 2) Processing Failed 3) Refund Pending/Completed
|
|
@@ -7,7 +7,6 @@ import useSWR from 'swr';
|
|
|
7
7
|
import { useInitialSettings } from "../../../../../context/settings";
|
|
8
8
|
import { ImageWithFallback } from "../../../../../components/Common/ImageWithFallback";
|
|
9
9
|
import NumberFlow from "@number-flow/react";
|
|
10
|
-
import clsx from "clsx";
|
|
11
10
|
import { PriceImpact } from "../../../../../components/Input/Amount/PriceImpact";
|
|
12
11
|
const Summary = (props) => {
|
|
13
12
|
const { swap, quote, receiveAmount } = props;
|
|
@@ -26,12 +25,12 @@ const Summary = (props) => {
|
|
|
26
25
|
truncateDecimals(refuel.amount, nativeCurrency?.precision) : null;
|
|
27
26
|
const refuelAmountInUsd = nativeCurrency && ((nativeCurrency?.price_in_usd || 1) * (Number(truncatedRefuelAmount) || 0)).toFixed(2);
|
|
28
27
|
return (_jsx("div", { className: "bg-secondary-500 rounded-2xl px-3 py-4 w-full relative z-10 space-y-4", children: _jsxs("div", { className: "font-normal flex flex-col w-full relative z-10 space-y-3", children: [_jsxs("div", { className: "w-full grid grid-cols-10", children: [_jsx(RouteTokenPair, { route: sourceExchange || source, token: sourceCurrency }), _jsxs("div", { className: "flex flex-col col-start-7 col-span-4 items-end", children: [requestedAmount &&
|
|
29
|
-
_jsxs("p", { className: "text-primary-text text-
|
|
28
|
+
_jsxs("p", { className: "text-primary-text text-xl leading-6 font-normal whitespace-nowrap", children: [truncateDecimals(Number(requestedAmount), sourceCurrency.precision), " ", sourceCurrency.symbol] }), _jsx("p", { className: "text-secondary-text text-sm leading-5 flex font-medium justify-end", children: _jsx(NumberFlow, { value: Number(requestedAmountInUsd || 0), prefix: "$", trend: 0 }) })] })] }), _jsxs("div", { className: "relative text-secondary-text", children: [_jsx("hr", { className: "border border-secondary-400 w-full rounded-full" }), _jsx(ArrowDown, { className: "absolute left-1/2 -translate-x-1/2 top-[-10px] h-6 w-6 p-1 bg-secondary-400 rounded-md text-secondary-text" })] }), _jsxs("div", { className: "w-full grid grid-cols-10", children: [_jsx(RouteTokenPair, { route: destination, token: destinationCurrency }), receiveAmount && (_jsxs("div", { className: "flex flex-col justify-end items-end w-full col-start-7 col-span-4 h-[44px]", children: [_jsx("p", { className: "text-primary-text text-xl font-normal text-end", children: _jsx(NumberFlow, { value: receiveAmount, suffix: ` ${destinationCurrency.symbol}`, trend: 0, format: { maximumFractionDigits: quote.quote.destination_token?.decimals || 2 } }) }), _jsxs("p", { className: "text-secondary-text text-sm flex items-center gap-1 font-medium", children: [_jsx(PriceImpact, { className: "text-sm", quote: swapQuote, refuel: refuel }), _jsx(NumberFlow, { value: Number(receiveAmountInUsd || 0), prefix: "$", trend: 0 })] })] }))] }), (!!refuel != undefined && nativeCurrency) ?
|
|
30
29
|
_jsxs("div", { className: "flex items-center justify-between w-full ", children: [_jsxs("div", { className: 'flex items-center gap-3 text-sm', children: [_jsx("span", { className: "relative z-10 flex h-8 w-8 items-center justify-center rounded-lg p-2 bg-primary/20", children: _jsx(Fuel, { className: "h-5 w-5 text-primary", "aria-hidden": "true" }) }), _jsx("p", { children: "Refuel" })] }), _jsxs("div", { className: "flex flex-col items-end", children: [_jsxs("p", { className: "text-primary-text text-sm", children: [truncatedRefuelAmount, " ", nativeCurrency?.symbol] }), _jsxs("p", { className: "text-secondary-text text-sm flex justify-end", children: ["$", refuelAmountInUsd] })] })] })
|
|
31
30
|
:
|
|
32
31
|
_jsx(_Fragment, {})] }) }));
|
|
33
32
|
};
|
|
34
33
|
const RouteTokenPair = ({ route, token }) => {
|
|
35
|
-
return (_jsxs("div", { className: "flex grow gap-4 text-left items-center md:text-base relative col-span-6 align-center", children: [_jsxs("div", { className: "inline-flex items-center relative shrink-0
|
|
34
|
+
return (_jsxs("div", { className: "flex grow gap-4 text-left items-center md:text-base relative col-span-6 align-center", children: [_jsxs("div", { className: "inline-flex items-center relative shrink-0 h-8 w-8", children: [_jsx(ImageWithFallback, { src: token.logo, alt: "Token Logo", height: "28", width: "28", loading: "eager", fetchPriority: "high", className: "rounded-full object-contain" }), _jsx("div", { className: "absolute -right-0.5 -bottom-0.5 rounded border border-secondary-500 bg-secondary-400 overflow-hidden", children: _jsx(ImageWithFallback, { src: route.logo, alt: "Route Logo", height: "16", width: "16", loading: "eager", fetchPriority: "high", className: "object-contain" }) })] }), _jsxs("div", { className: "text-primary-text overflow-hidden", children: [_jsx("p", { className: "text-xl leading-6 font-normal", children: token.symbol }), _jsx("p", { className: "text-secondary-text text-sm truncate whitespace-nowrap font-medium leading-5", children: route.display_name })] })] }));
|
|
36
35
|
};
|
|
37
36
|
export default Summary;
|
|
@@ -5,7 +5,7 @@ import { TransactionType } from "../../../../../lib/apiClients/layerSwapApiClien
|
|
|
5
5
|
import { shortenEmail } from "../../../../../components/utils/ShortenAddress";
|
|
6
6
|
import KnownInternalNames from "../../../../../lib/knownIds";
|
|
7
7
|
import { useInitialSettings } from "../../../../../context/settings";
|
|
8
|
-
import { useSelectedAccount } from "../../../../../context/
|
|
8
|
+
import { useSelectedAccount } from "../../../../../context/swapAccounts";
|
|
9
9
|
const SwapSummary = () => {
|
|
10
10
|
const { hideFrom, account, } = useInitialSettings();
|
|
11
11
|
const { swapBasicData, swapDetails, quote, refuel, quoteIsLoading } = useSwapDataState();
|
|
@@ -18,7 +18,7 @@ const SwapSummary = () => {
|
|
|
18
18
|
const swapOutputTransaction = swapDetails?.transactions?.find(t => t.type === TransactionType.Output);
|
|
19
19
|
const requested_amount = (swapInputTransaction?.amount ?? swapBasicData.requested_amount) || undefined;
|
|
20
20
|
const receiveAmount = quote?.receive_amount;
|
|
21
|
-
const calculatedReceiveAmount = swapOutputTransaction?.amount
|
|
21
|
+
const calculatedReceiveAmount = swapOutputTransaction?.amount ? swapOutputTransaction?.amount : receiveAmount;
|
|
22
22
|
let sourceAccountAddress = "";
|
|
23
23
|
if (hideFrom && account) {
|
|
24
24
|
sourceAccountAddress = account;
|
|
@@ -9,8 +9,10 @@ import { SwapStatus } from '../../../../Models/SwapStatus';
|
|
|
9
9
|
import { useSwapTransactionStore } from '../../../../stores/swapTransactionStore';
|
|
10
10
|
import SubmitButton from '../../../../components/Buttons/submitButton';
|
|
11
11
|
import ManualWithdraw from './ManualWithdraw';
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
import { useCallbacks } from "../../../../context/callbackProvider";
|
|
13
|
+
const SwapDetails = ({ type, onWalletWithdrawalSuccess, onCancelWithdrawal, partner }) => {
|
|
14
|
+
const { swapDetails, swapBasicData, refuel, depositActionsResponse, quote, quoteIsLoading } = useSwapDataState();
|
|
15
|
+
const { onBackClick } = useCallbacks();
|
|
14
16
|
const swapStatus = swapDetails?.status || SwapStatus.UserTransferPending;
|
|
15
17
|
const storedWalletTransactions = useSwapTransactionStore();
|
|
16
18
|
const swapInputTransaction = swapDetails?.transactions?.find(t => t.type === TransactionType.Input);
|
|
@@ -20,18 +22,18 @@ const SwapDetails = ({ type, onWalletWithdrawalSuccess, partner }) => {
|
|
|
20
22
|
}, [swapDetails?.id, storedWalletTransactions]);
|
|
21
23
|
if (!swapBasicData)
|
|
22
24
|
return _jsx(_Fragment, { children: _jsx("div", { className: "w-full h-[430px]", children: _jsx("div", { className: "animate-pulse flex space-x-4", children: _jsxs("div", { className: "flex-1 space-y-6 py-1", children: [_jsx("div", { className: "h-32 bg-secondary-700 rounded-lg" }), _jsx("div", { className: "h-40 bg-secondary-700 rounded-lg" }), _jsx("div", { className: "h-12 bg-secondary-700 rounded-lg" })] }) }) }) });
|
|
23
|
-
return (_jsx(Container, { type: type, children: ((swapStatus === SwapStatus.UserTransferPending
|
|
25
|
+
return (_jsx(Container, { type: type, goBack: onBackClick, children: ((swapStatus === SwapStatus.UserTransferPending
|
|
24
26
|
&& !(swapInputTransaction || storedWalletTransaction))) ?
|
|
25
27
|
(swapBasicData?.use_deposit_address === true
|
|
26
|
-
? _jsx(ManualWithdraw, { swapBasicData: swapBasicData,
|
|
27
|
-
: _jsx(Withdraw, { type: type, onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, partner: partner }))
|
|
28
|
+
? _jsx(ManualWithdraw, { swapBasicData: swapBasicData, depositActions: depositActionsResponse, refuel: refuel, partner: partner, type: type, quote: quote, isQuoteLoading: quoteIsLoading })
|
|
29
|
+
: _jsx(Withdraw, { type: type, onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, onCancelWithdrawal: onCancelWithdrawal, partner: partner }))
|
|
28
30
|
:
|
|
29
31
|
_jsxs("div", { className: 'space-y-3 w-full h-full', children: [_jsx(Processing, {}), storedWalletTransaction?.status == BackendTransactionStatus.Failed &&
|
|
30
32
|
_jsx(SubmitButton, { isDisabled: false, isSubmitting: false, onClick: removeStoredTransaction, children: "Try again" })] }) }));
|
|
31
33
|
};
|
|
32
|
-
const Container = ({ type, children }) => {
|
|
34
|
+
const Container = ({ type, children, goBack }) => {
|
|
33
35
|
if (type === "widget")
|
|
34
|
-
return _jsx(Widget, { children: _jsx(_Fragment, { children: children }) });
|
|
36
|
+
return _jsx(Widget, { goBack: goBack, children: _jsx(_Fragment, { children: children }) });
|
|
35
37
|
else
|
|
36
38
|
return _jsx("div", { className: "w-full flex flex-col justify-between h-full space-y-3 text-secondary-text", children: children });
|
|
37
39
|
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { ActionMessages, ActionMessageType } from "../../messages/TransactionMessages";
|
|
4
|
+
import { ErrorHandler } from "../../../../../../lib/ErrorHandler";
|
|
5
|
+
export const ActionMessage = ({ error, isLoading }) => {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (error && (error?.name === ActionMessageType.UnexpectedErrorMessage
|
|
8
|
+
|| !Object.values(ActionMessageType).includes(error.name))) {
|
|
9
|
+
ErrorHandler({
|
|
10
|
+
type: "SwapWithdrawalError",
|
|
11
|
+
message: error.message,
|
|
12
|
+
name: error.name,
|
|
13
|
+
stack: error.stack,
|
|
14
|
+
cause: error.cause
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}, [error]);
|
|
18
|
+
if (isLoading) {
|
|
19
|
+
return _jsx(ActionMessages.ConfirmActionMessage, {});
|
|
20
|
+
}
|
|
21
|
+
else if (error?.name === ActionMessageType.TransactionRejected) {
|
|
22
|
+
return _jsx(ActionMessages.TransactionRejectedMessage, {});
|
|
23
|
+
}
|
|
24
|
+
else if (error?.name === ActionMessageType.TransactionFailed) {
|
|
25
|
+
return _jsx(ActionMessages.TransactionFailedMessage, {});
|
|
26
|
+
}
|
|
27
|
+
else if (error?.name === ActionMessageType.InsufficientFunds) {
|
|
28
|
+
return _jsx(ActionMessages.InsufficientFundsMessage, {});
|
|
29
|
+
}
|
|
30
|
+
else if (error?.name === ActionMessageType.WaletMismatch) {
|
|
31
|
+
return _jsx(ActionMessages.WaletMismatchMessage, { address: error?.message });
|
|
32
|
+
}
|
|
33
|
+
else if (error?.name === ActionMessageType.DifferentAccountsNotAllowedError) {
|
|
34
|
+
return _jsx(ActionMessages.DifferentAccountsNotAllowedError, { network: error?.message });
|
|
35
|
+
}
|
|
36
|
+
else if (error) {
|
|
37
|
+
if (!error.message)
|
|
38
|
+
return _jsx(ActionMessages.UnexpectedErrorMessage, { message: 'Something went wrong' });
|
|
39
|
+
return _jsx(ActionMessages.UnexpectedErrorMessage, { message: error.message });
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
return _jsx(_Fragment, {});
|
|
43
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useState } from "react";
|
|
2
|
+
import { useCallback, useMemo, useState } from "react";
|
|
3
3
|
import WalletIcon from "../../../../../../components/Icons/WalletIcon";
|
|
4
4
|
import SubmitButton from "../../../../../../components/Buttons/submitButton";
|
|
5
5
|
import useWallet from "../../../../../../hooks/useWallet";
|
|
@@ -8,15 +8,19 @@ import toast from "react-hot-toast";
|
|
|
8
8
|
import { Loader2 } from "lucide-react";
|
|
9
9
|
import WalletMessage from "../../messages/Message";
|
|
10
10
|
import { useConnectModal } from "../../../../../../components/Wallet/WalletModal";
|
|
11
|
-
import { useInitialSettings } from "../../../../../../context/settings";
|
|
11
|
+
import { useInitialSettings, useSettingsState } from "../../../../../../context/settings";
|
|
12
12
|
import { useSwapTransactionStore } from "../../../../../../stores/swapTransactionStore";
|
|
13
|
-
import { BackendTransactionStatus } from "../../../../../../lib/apiClients/layerSwapApiClient";
|
|
13
|
+
import LayerSwapApiClient, { BackendTransactionStatus } from "../../../../../../lib/apiClients/layerSwapApiClient";
|
|
14
14
|
import sleep from "../../../../../../lib/wallets/utils/sleep";
|
|
15
15
|
import { isDiffByPercent } from "../../../../../../components/utils/numbers";
|
|
16
|
-
// import posthog from "posthog-js";
|
|
17
16
|
import { useWalletWithdrawalState } from "../../../../../../context/withdrawalContext";
|
|
18
|
-
import { useSelectedAccount } from "../../../../../../context/
|
|
19
|
-
import {
|
|
17
|
+
import { useSelectedAccount } from "../../../../../../context/swapAccounts";
|
|
18
|
+
import { ErrorHandler } from "../../../../../../lib/ErrorHandler";
|
|
19
|
+
import { resolvePriceImpactValues } from "../../../../../../lib/fees";
|
|
20
|
+
import InfoIcon from "../../../../../../components/Icons/InfoIcon";
|
|
21
|
+
import { addressFormat } from "../../../../../../lib/address/formatter";
|
|
22
|
+
import { useBalance } from "../../../../../../lib/balances/useBalance";
|
|
23
|
+
import KnownInternalNames from "../../../../../../lib/knownIds";
|
|
20
24
|
export const ConnectWalletButton = ({ ...props }) => {
|
|
21
25
|
const { swapBasicData } = useSwapDataState();
|
|
22
26
|
const { source_network } = swapBasicData || {};
|
|
@@ -83,20 +87,26 @@ export const ChangeNetworkButton = (props) => {
|
|
|
83
87
|
export const ButtonWrapper = ({ ...props }) => {
|
|
84
88
|
return _jsx(SubmitButton, { text_align: 'center', buttonStyle: 'filled', size: "medium", type: "button", className: "text-primary-text text-base", ...props, children: props.children });
|
|
85
89
|
};
|
|
86
|
-
export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...props }) => {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const { quote, quoteIsLoading, quoteError } = useSwapDataState();
|
|
90
|
+
export const SendTransactionButton = ({ error, clearError, onClick, swapData: swapBasicData, refuel, ...props }) => {
|
|
91
|
+
const { quote, quoteIsLoading, quoteError, swapId, swapDetails, depositActionsResponse, refuel: refuelData } = useSwapDataState();
|
|
92
|
+
const { onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, onCancelWithdrawal } = useWalletWithdrawalState();
|
|
90
93
|
const { createSwap, setSwapId, setQuoteLoading } = useSwapDataUpdate();
|
|
91
94
|
const { setSwapTransaction } = useSwapTransactionStore();
|
|
92
95
|
const initialSettings = useInitialSettings();
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const
|
|
96
|
+
const layerswapApiClient = new LayerSwapApiClient();
|
|
97
|
+
const selectedSourceAccount = useSelectedAccount("from", swapBasicData.source_network?.name);
|
|
98
|
+
const { networks } = useSettingsState();
|
|
99
|
+
const networkWithTokens = swapBasicData.source_network && networks.find(n => n.name === swapBasicData.source_network?.name);
|
|
100
|
+
const { balances } = useBalance(selectedSourceAccount?.address, networkWithTokens);
|
|
101
|
+
const { wallets } = useWallet(swapBasicData.source_network, 'withdrawal');
|
|
102
|
+
const [actionStateText, setActionStateText] = useState();
|
|
103
|
+
const [loading, setLoading] = useState(false);
|
|
104
|
+
const [showCriticalMarketPriceImpactButtons, setShowCriticalMarketPriceImpactButtons] = useState(false);
|
|
105
|
+
const priceImpactValues = useMemo(() => quote ? resolvePriceImpactValues(quote, refuel ? refuelData : undefined) : undefined, [quote, refuel]);
|
|
106
|
+
const criticalMarketPriceImpact = useMemo(() => priceImpactValues?.criticalMarketPriceImpact, [priceImpactValues]);
|
|
97
107
|
const handleClick = async () => {
|
|
98
108
|
try {
|
|
99
|
-
const selectedWallet = wallets.find(w => w.
|
|
109
|
+
const selectedWallet = selectedSourceAccount && wallets.find(w => w.addresses.some(a => addressFormat(a, swapBasicData.source_network) === addressFormat(selectedSourceAccount?.address, swapBasicData.source_network)));
|
|
100
110
|
if (!selectedSourceAccount) {
|
|
101
111
|
throw new Error('Selected source account is undefined');
|
|
102
112
|
}
|
|
@@ -104,71 +114,89 @@ export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...pro
|
|
|
104
114
|
throw new Error('Wallet is not active');
|
|
105
115
|
}
|
|
106
116
|
setLoading(true);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
clearError?.();
|
|
118
|
+
let swapData = swapDetails;
|
|
119
|
+
let depositActions = depositActionsResponse;
|
|
120
|
+
if (!swapId || !swapDetails) {
|
|
121
|
+
setActionStateText("Preparing");
|
|
122
|
+
setSwapId(undefined);
|
|
123
|
+
const swapValues = {
|
|
124
|
+
amount: swapBasicData.requested_amount.toString(),
|
|
125
|
+
from: swapBasicData.source_network,
|
|
126
|
+
to: swapBasicData.destination_network,
|
|
127
|
+
fromAsset: swapBasicData.source_token,
|
|
128
|
+
toAsset: swapBasicData.destination_token,
|
|
129
|
+
refuel: refuel,
|
|
130
|
+
destination_address: swapBasicData.destination_address,
|
|
131
|
+
depositMethod: 'wallet',
|
|
132
|
+
};
|
|
133
|
+
const newSwapData = await createSwap(swapValues, initialSettings);
|
|
134
|
+
const newSwapId = newSwapData?.swap?.id;
|
|
135
|
+
if (!newSwapId) {
|
|
136
|
+
throw new Error('Swap ID is undefined');
|
|
137
|
+
}
|
|
138
|
+
setSwapId(newSwapId);
|
|
139
|
+
const priceImpactValues = newSwapData.quote ? resolvePriceImpactValues(newSwapData.quote, newSwapData.refuel) : undefined;
|
|
140
|
+
if (priceImpactValues?.criticalMarketPriceImpact) {
|
|
141
|
+
setShowCriticalMarketPriceImpactButtons(true);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (isDiffByPercent(quote?.receive_amount, newSwapData.quote.receive_amount, 2)) {
|
|
145
|
+
setActionStateText("Updating quotes");
|
|
146
|
+
setQuoteLoading(true);
|
|
147
|
+
await sleep(3500);
|
|
148
|
+
setQuoteLoading(false);
|
|
149
|
+
}
|
|
150
|
+
swapData = newSwapData.swap;
|
|
151
|
+
depositActions = newSwapData.deposit_actions;
|
|
123
152
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
setQuoteLoading(true);
|
|
127
|
-
await sleep(3500);
|
|
128
|
-
setQuoteLoading(false);
|
|
129
|
-
}
|
|
130
|
-
setActionStateText("Opening Wallet");
|
|
131
|
-
setSwapId(swapId);
|
|
132
|
-
const depositAction = newSwapData?.deposit_actions && newSwapData?.deposit_actions[0];
|
|
133
|
-
if (!depositAction) {
|
|
134
|
-
throw new Error('No deposit action');
|
|
153
|
+
if (!depositActions?.length) {
|
|
154
|
+
throw new Error('No deposit actions');
|
|
135
155
|
}
|
|
136
|
-
if (!
|
|
137
|
-
throw new Error('No
|
|
156
|
+
if (!swapData) {
|
|
157
|
+
throw new Error('No swap data');
|
|
138
158
|
}
|
|
139
|
-
const transferProps =
|
|
140
|
-
|
|
141
|
-
token: swapData.source_token,
|
|
142
|
-
selectedWallet: selectedWallet,
|
|
143
|
-
amount: depositAction?.amount,
|
|
144
|
-
callData: depositAction?.call_data,
|
|
145
|
-
depositAddress: depositAction?.to_address,
|
|
146
|
-
sequenceNumber: newSwapData.swap?.metadata.sequence_number,
|
|
147
|
-
swapId: swapId,
|
|
148
|
-
userDestinationAddress: newSwapData.swap?.destination_address
|
|
149
|
-
};
|
|
159
|
+
const transferProps = resolveTransactionData(swapData, swapBasicData, depositActions, balances, selectedWallet);
|
|
160
|
+
setActionStateText("Opening Wallet");
|
|
150
161
|
const hash = await onClick(transferProps);
|
|
151
162
|
if (hash) {
|
|
152
163
|
onWalletWithdrawalSuccess?.();
|
|
153
|
-
setSwapTransaction(
|
|
154
|
-
|
|
164
|
+
setSwapTransaction(swapData.id, BackendTransactionStatus.Pending, hash);
|
|
165
|
+
try {
|
|
166
|
+
await layerswapApiClient.SwapCatchup(swapData.id, hash);
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
console.error('Error in SwapCatchup:', e);
|
|
170
|
+
const swapWithdrawalError = new Error(e);
|
|
171
|
+
swapWithdrawalError.name = `SwapCatchupError`;
|
|
172
|
+
swapWithdrawalError.cause = e;
|
|
173
|
+
ErrorHandler({
|
|
174
|
+
type: 'SwapWithdrawalError',
|
|
175
|
+
message: swapWithdrawalError.message,
|
|
176
|
+
name: swapWithdrawalError.name,
|
|
177
|
+
stack: swapWithdrawalError.stack,
|
|
178
|
+
cause: swapWithdrawalError.cause,
|
|
179
|
+
swapId: swapData.id,
|
|
180
|
+
transactionHash: hash,
|
|
181
|
+
fromAddress: selectedSourceAccount?.address,
|
|
182
|
+
toAddress: swapBasicData?.destination_address
|
|
183
|
+
});
|
|
184
|
+
}
|
|
155
185
|
}
|
|
156
186
|
}
|
|
157
187
|
catch (e) {
|
|
158
188
|
setSwapId(undefined);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
// severity: 'error',
|
|
171
|
-
// });
|
|
189
|
+
const error = e;
|
|
190
|
+
ErrorHandler({
|
|
191
|
+
type: 'SwapWithdrawalError',
|
|
192
|
+
message: error.message,
|
|
193
|
+
name: error.name,
|
|
194
|
+
stack: error.stack,
|
|
195
|
+
cause: error.cause,
|
|
196
|
+
swapId: swapId,
|
|
197
|
+
fromAddress: selectedSourceAccount?.address,
|
|
198
|
+
toAddress: swapBasicData?.destination_address
|
|
199
|
+
});
|
|
172
200
|
}
|
|
173
201
|
finally {
|
|
174
202
|
setLoading(false);
|
|
@@ -176,5 +204,31 @@ export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...pro
|
|
|
176
204
|
};
|
|
177
205
|
if (quoteIsLoading || loading)
|
|
178
206
|
return (_jsx(ButtonWrapper, { ...props, isSubmitting: true, isDisabled: true, children: actionStateText || "Preparing" }));
|
|
179
|
-
|
|
207
|
+
if (showCriticalMarketPriceImpactButtons) {
|
|
208
|
+
return (_jsxs(_Fragment, { children: [quote && priceImpactValues && _jsx("div", { className: "py-1", children: _jsxs("div", { className: "flex items-start gap-2.5", children: [_jsx("span", { className: "shrink-0", children: _jsx(InfoIcon, { className: "w-5 h-5 text-warning-foreground" }) }), _jsxs("div", { className: "flex flex-col gap-1.5 pr-4", children: [_jsx("p", { className: "text-primary-text font-semibold leading-4 text-base mt-0.5", children: "Critical receiving amount" }), _jsxs("p", { className: "text-priamry-text text-base font-normal leading-[18px]", children: [_jsx("span", { children: "By continuing, you agree to receive as low as " }), _jsxs("span", { className: "text-warning-foreground text-nowrap", children: [quote.min_receive_amount, " ", quote.destination_token?.symbol, " ($ ", priceImpactValues.minReceiveAmountUSD, ")"] })] })] })] }) }), _jsx(ButtonWrapper, { ...props, onClick: handleClick, buttonStyle: "secondary", size: "small", isSubmitting: false, isDisabled: false, children: "Continue anyway" }), _jsx(ButtonWrapper, { ...props, size: "small", onClick: () => onCancelWithdrawal?.(), isSubmitting: false, isDisabled: false, children: "Cancel & try another route" })] }));
|
|
209
|
+
}
|
|
210
|
+
return (_jsxs(_Fragment, { children: [!!(!swapId && criticalMarketPriceImpact && quote?.destination_token && priceImpactValues && !error) && _jsx("div", { className: "py-1", children: _jsxs("div", { className: "flex items-start gap-2.5", children: [_jsx("span", { className: "shrink-0", children: _jsx(InfoIcon, { className: "w-5 h-5 text-warning-foreground" }) }), _jsxs("div", { className: "flex flex-col gap-1.5 pr-4", children: [_jsx("p", { className: "text-primary-text font-medium leading-4 text-base mt-0.5", children: "Critical receiving amount" }), _jsxs("p", { className: "text-secondary-text text-sm leading-[18px]", children: [_jsx("span", { children: "The \u201Creceive at least\u201D amount is affected by high price impact. You will receive at least " }), _jsxs("span", { children: [quote.min_receive_amount, " ", quote.destination_token?.symbol, " ($ ", priceImpactValues.minReceiveAmountUSD, ") "] })] })] })] }) }), _jsx(ButtonWrapper, { ...props, isSubmitting: props.isSubmitting || loading || quoteIsLoading, onClick: handleClick, isDisabled: quoteIsLoading || !!quoteError, children: error ? 'Try again' : 'Swap now' })] }));
|
|
211
|
+
};
|
|
212
|
+
const resolveTransactionData = (swapDetails, swapBasicData, deposit_actions, balances, selectedWallet) => {
|
|
213
|
+
const depositAction = deposit_actions?.find(action => action.type === 'transfer'
|
|
214
|
+
|| ExceptionNetworks.includes(swapBasicData.source_network?.name) && action.type === 'manual_transfer');
|
|
215
|
+
if (!depositAction) {
|
|
216
|
+
throw new Error('No deposit action found');
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
amount: depositAction.amount,
|
|
220
|
+
callData: depositAction.call_data,
|
|
221
|
+
depositAddress: depositAction.to_address,
|
|
222
|
+
sequenceNumber: swapDetails.metadata.sequence_number,
|
|
223
|
+
swapId: swapDetails.id,
|
|
224
|
+
userDestinationAddress: swapBasicData.destination_address,
|
|
225
|
+
balances: balances,
|
|
226
|
+
network: swapBasicData.source_network,
|
|
227
|
+
token: swapBasicData.source_token,
|
|
228
|
+
selectedWallet: selectedWallet,
|
|
229
|
+
};
|
|
180
230
|
};
|
|
231
|
+
const ExceptionNetworks = [
|
|
232
|
+
KnownInternalNames.Networks.ImmutableXMainnet,
|
|
233
|
+
KnownInternalNames.Networks.ImmutableXSepolia
|
|
234
|
+
];
|