@layerswap/widget 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Models/LayerSwapSettings.js +0 -1
- package/dist/esm/Models/Theme.js +39 -0
- package/dist/esm/components/Buttons/submitButton.js +2 -1
- package/dist/esm/components/Common/ConnectWalletButton.js +9 -3
- package/dist/esm/components/Common/CountDownTimer.js +0 -1
- package/dist/esm/components/Common/WarningMessage.js +4 -2
- package/dist/esm/components/Common/guideLink.js +4 -6
- package/dist/esm/components/ErrorFallback.js +11 -11
- package/dist/esm/components/HeaderWithMenu.js +1 -1
- package/dist/esm/components/Icons/Wallets/Xverse.js +3 -0
- package/dist/esm/components/Icons/Wallets/index.js +1 -0
- package/dist/esm/components/Input/Address/AddressPicker/index.js +15 -12
- package/dist/esm/components/Input/Amount/Balance.js +1 -1
- package/dist/esm/components/Input/Amount/ExchangeReceiveAmount.js +8 -0
- package/dist/esm/components/Input/Amount/MinMax.js +1 -1
- package/dist/esm/components/Input/Amount/PriceImpact.js +5 -38
- package/dist/esm/components/Input/Amount/ReceiveAmount.js +2 -2
- package/dist/esm/components/Input/Amount/index.js +3 -3
- package/dist/esm/components/Input/DestinationPicker.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Content.js +2 -2
- package/dist/esm/components/Input/RoutePicker/RouterPickerWalletConnect.js +5 -5
- package/dist/esm/components/Input/RoutePicker/Routes.js +18 -18
- package/dist/esm/components/Input/RoutePicker/Rows/CollapsableHeader.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Rows/CollapsibleRow.js +3 -3
- package/dist/esm/components/Input/RoutePicker/Rows/StickyHeader.js +2 -2
- package/dist/esm/components/Input/RoutePicker/Rows/SuggestionsHeader.js +55 -0
- package/dist/esm/components/Input/RoutePicker/Rows/TitleRow.js +11 -0
- package/dist/esm/components/Input/RoutePicker/Rows/index.js +5 -6
- package/dist/esm/components/Input/RoutePicker/index.js +2 -2
- package/dist/esm/components/Input/SourceWalletPicker.js +6 -4
- package/dist/esm/components/Menu/index.js +1 -1
- package/dist/esm/components/Pages/Campaigns/Details/Leaderboard.js +2 -2
- package/dist/esm/components/Pages/Campaigns/Details/Rewards.js +2 -2
- package/dist/esm/components/Pages/Campaigns/Details/index.js +2 -3
- package/dist/esm/components/Pages/Campaigns/index.js +3 -4
- package/dist/esm/components/Pages/Swap/Form/ExchangeForm.js +21 -19
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Rate.js +5 -4
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/Refuel.js +2 -2
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.js +51 -14
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.js +1 -1
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.js +3 -3
- package/dist/esm/components/Pages/Swap/Form/FeeDetails/index.js +8 -9
- package/dist/esm/components/Pages/Swap/Form/Form.js +27 -3
- package/dist/esm/components/Pages/Swap/Form/FormWrapper.js +6 -8
- package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +11 -21
- package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
- package/dist/esm/components/Pages/Swap/Withdraw/Failed.js +12 -8
- package/dist/esm/components/Pages/Swap/Withdraw/ManualWithdraw.js +28 -9
- package/dist/esm/components/Pages/Swap/Withdraw/NotFound.js +15 -4
- package/dist/esm/components/Pages/Swap/Withdraw/Processing/Processing.js +36 -41
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/Summary.js +1 -1
- package/dist/esm/components/Pages/Swap/Withdraw/Summary/index.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/SwapDetails.js +9 -7
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.js +43 -0
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/buttons.js +118 -71
- package/dist/esm/components/Pages/Swap/Withdraw/Wallet/index.js +56 -65
- package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferButton.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferContent.js +2 -2
- package/dist/esm/components/Pages/Swap/Withdraw/Withdraw.js +3 -3
- package/dist/esm/components/Pages/Swap/Withdraw/index.js +5 -4
- package/dist/esm/components/Pages/Swap/Withdraw/messages/TransactionMessages.js +14 -15
- package/dist/esm/components/Pages/SwapHistory/History.js +1 -1
- package/dist/esm/components/Pages/SwapHistory/index.js +4 -4
- package/dist/esm/components/Wallet/WalletComponents/WalletsList.js +1 -1
- package/dist/esm/components/Wallet/WalletModal/Connector.js +2 -2
- package/dist/esm/components/Wallet/WalletModal/ConnectorsList.js +5 -1
- package/dist/esm/components/Wallet/WalletModal/index.js +3 -1
- package/dist/esm/components/Wallet/WalletProviders/index.js +4 -2
- package/dist/esm/components/Widget/Content.js +2 -2
- package/dist/esm/components/Widget/Footer.js +1 -1
- package/dist/esm/components/Widget/Index.js +1 -1
- package/dist/esm/components/WidgetLoading.js +9 -2
- package/dist/esm/context/ErrorProvider.js +14 -0
- package/dist/esm/context/LayerswapProvider.js +6 -5
- package/dist/esm/context/callbackProvider.js +54 -52
- package/dist/esm/context/resolverContext.js +7 -2
- package/dist/esm/context/swap.js +10 -13
- package/dist/esm/context/{balanceAccounts.js → swapAccounts.js} +17 -17
- package/dist/esm/context/validationContext.js +1 -1
- package/dist/esm/context/walletProviders.js +7 -1
- package/dist/esm/context/withdrawalContext.js +2 -2
- package/dist/esm/exports/internal.js +4 -3
- package/dist/esm/helpers/filterSourceNetworks.js +23 -0
- package/dist/esm/helpers/getSettings/getSettings.js +18 -13
- package/dist/esm/helpers/routes.js +4 -1
- package/dist/esm/hooks/useAllWithdrawalBalances.js +6 -5
- package/dist/esm/hooks/useFormRoutes.js +16 -8
- package/dist/esm/hooks/useFormValidation.js +5 -4
- package/dist/esm/hooks/useRouteValidation.js +1 -1
- package/dist/esm/hooks/useSwrSwaps.js +1 -1
- package/dist/esm/hooks/useTransfer.js +9 -0
- package/dist/esm/hooks/useWallet.js +7 -7
- package/dist/esm/lib/AppSettings.js +27 -16
- package/dist/esm/lib/ErrorHandler.js +6 -0
- package/dist/esm/lib/apiClients/layerSwapApiClient.js +12 -35
- package/dist/esm/lib/balances/balanceResolver.js +9 -13
- package/dist/esm/lib/fees.js +50 -0
- package/dist/esm/lib/resolvers/resolverService.js +10 -1
- package/dist/esm/lib/transfers/index.js +1 -0
- package/dist/esm/lib/transfers/transferResolver.js +14 -0
- package/dist/esm/stores/balanceStore.js +0 -1
- package/dist/esm/stores/logStore.js +11 -0
- package/dist/esm/types/balance.js +8 -9
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/logEvents.js +1 -0
- package/dist/index.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/Models/Balance.d.ts +1 -1
- package/dist/types/Models/LayerSwapSettings.d.ts +7 -0
- package/dist/types/Models/LayerSwapSettings.d.ts.map +1 -1
- package/dist/types/Models/Theme.d.ts.map +1 -1
- package/dist/types/components/Buttons/submitButton.d.ts +1 -1
- package/dist/types/components/Buttons/submitButton.d.ts.map +1 -1
- package/dist/types/components/Common/ConnectWalletButton.d.ts +1 -1
- package/dist/types/components/Common/ConnectWalletButton.d.ts.map +1 -1
- package/dist/types/components/Common/CountDownTimer.d.ts.map +1 -1
- package/dist/types/components/Common/WarningMessage.d.ts.map +1 -1
- package/dist/types/components/Common/guideLink.d.ts.map +1 -1
- package/dist/types/components/ErrorFallback.d.ts.map +1 -1
- package/dist/types/components/HeaderWithMenu.d.ts.map +1 -1
- package/dist/types/components/Icons/Wallets/Xverse.d.ts +4 -0
- package/dist/types/components/Icons/Wallets/Xverse.d.ts.map +1 -0
- package/dist/types/components/Icons/Wallets/index.d.ts +1 -0
- package/dist/types/components/Icons/Wallets/index.d.ts.map +1 -1
- package/dist/types/components/Input/Address/AddressNote.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/AddressBook.d.ts +3 -3
- package/dist/types/components/Input/Address/AddressPicker/AddressButton.d.ts +3 -3
- package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/ConnectedWallets.d.ts +2 -2
- package/dist/types/components/Input/Address/AddressPicker/ManualAddressInput.d.ts +4 -4
- package/dist/types/components/Input/Address/AddressPicker/index.d.ts +4 -4
- package/dist/types/components/Input/Address/AddressPicker/index.d.ts.map +1 -1
- package/dist/types/components/Input/Address/index.d.ts +1 -1
- package/dist/types/components/Input/Amount/Balance.d.ts +1 -1
- package/dist/types/components/Input/Amount/Balance.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts +11 -0
- package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts.map +1 -0
- package/dist/types/components/Input/Amount/MinMax.d.ts +1 -1
- package/dist/types/components/Input/Amount/PriceImpact.d.ts +2 -6
- package/dist/types/components/Input/Amount/PriceImpact.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/ReceiveAmount.d.ts +2 -3
- package/dist/types/components/Input/Amount/ReceiveAmount.d.ts.map +1 -1
- package/dist/types/components/Input/Amount/helpers.d.ts +2 -2
- package/dist/types/components/Input/Amount/index.d.ts +1 -1
- package/dist/types/components/Input/CexPicker.d.ts +1 -1
- package/dist/types/components/Input/DestinationPicker.d.ts +1 -1
- package/dist/types/components/Input/DestinationPicker.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Content.d.ts +5 -5
- package/dist/types/components/Input/RoutePicker/Content.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/RouterPickerWalletConnect.d.ts +1 -1
- package/dist/types/components/Input/RoutePicker/Routes.d.ts +4 -8
- package/dist/types/components/Input/RoutePicker/Routes.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts +3 -4
- package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts +6 -5
- package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts +3 -4
- package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts +7 -0
- package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts.map +1 -0
- package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts +7 -0
- package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts.map +1 -0
- package/dist/types/components/Input/RoutePicker/Rows/index.d.ts +5 -5
- package/dist/types/components/Input/RoutePicker/Rows/index.d.ts.map +1 -1
- package/dist/types/components/Input/RoutePicker/index.d.ts +1 -1
- package/dist/types/components/Input/RoutePicker/index.d.ts.map +1 -1
- package/dist/types/components/Input/SourcePicker.d.ts +1 -1
- package/dist/types/components/Input/SourceWalletPicker.d.ts.map +1 -1
- package/dist/types/components/Pages/Campaigns/Details/Leaderboard.d.ts +1 -1
- package/dist/types/components/Pages/Campaigns/Details/Rewards.d.ts +1 -1
- package/dist/types/components/Pages/Campaigns/Details/index.d.ts +1 -2
- package/dist/types/components/Pages/Campaigns/Details/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Campaigns/index.d.ts +2 -3
- package/dist/types/components/Pages/Campaigns/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts +3 -1
- package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts +7 -6
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/ReceiveAmounts.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/RefuelModal.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/Slippage.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts +3 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.d.ts +4 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts +4 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/utils.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts +7 -4
- package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/Form.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/FormButton.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Form/SwapFormValues.d.ts +2 -2
- package/dist/types/components/Pages/Swap/Withdraw/Failed.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts +4 -3
- package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/NotFound.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/QuoteUpdate.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Summary/Summary.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/SwapQuoteDetails.d.ts +3 -3
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts +6 -0
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts.map +1 -0
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts +4 -3
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/WalletTransferContent.d.ts +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts +2 -1
- package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/index.d.ts +1 -2
- package/dist/types/components/Pages/Swap/Withdraw/index.d.ts.map +1 -1
- package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts +3 -4
- package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts.map +1 -1
- package/dist/types/components/Pages/SwapHistory/HistorySummary.d.ts +2 -2
- package/dist/types/components/Pages/SwapHistory/StatusIcons.d.ts +1 -1
- package/dist/types/components/Pages/SwapHistory/SwapDetailsComponent.d.ts +1 -1
- package/dist/types/components/Pages/SwapHistory/index.d.ts +3 -1
- package/dist/types/components/Pages/SwapHistory/index.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts +3 -3
- package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/Connector.d.ts +2 -1
- package/dist/types/components/Wallet/WalletModal/Connector.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts +1 -1
- package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletModal/index.d.ts +1 -1
- package/dist/types/components/Wallet/WalletModal/index.d.ts.map +1 -1
- package/dist/types/components/Wallet/WalletProviders/index.d.ts +3 -1
- package/dist/types/components/Wallet/WalletProviders/index.d.ts.map +1 -1
- package/dist/types/components/Widget/Content.d.ts +2 -1
- package/dist/types/components/Widget/Content.d.ts.map +1 -1
- package/dist/types/components/Widget/Footer.d.ts +2 -1
- package/dist/types/components/Widget/Footer.d.ts.map +1 -1
- package/dist/types/components/Widget/Index.d.ts +3 -2
- package/dist/types/components/Widget/Index.d.ts.map +1 -1
- package/dist/types/components/WidgetLoading.d.ts.map +1 -1
- package/dist/types/components/shadcn/command.d.ts +9 -52
- package/dist/types/components/shadcn/command.d.ts.map +1 -1
- package/dist/types/context/ErrorProvider.d.ts +3 -0
- package/dist/types/context/ErrorProvider.d.ts.map +1 -0
- package/dist/types/context/LayerswapProvider.d.ts +22 -4
- package/dist/types/context/LayerswapProvider.d.ts.map +1 -1
- package/dist/types/context/callbackProvider.d.ts +6 -10
- package/dist/types/context/callbackProvider.d.ts.map +1 -1
- package/dist/types/context/resolverContext.d.ts.map +1 -1
- package/dist/types/context/swap.d.ts +7 -7
- package/dist/types/context/swap.d.ts.map +1 -1
- package/dist/types/context/{balanceAccounts.d.ts → swapAccounts.d.ts} +9 -9
- package/dist/types/context/swapAccounts.d.ts.map +1 -0
- package/dist/types/context/walletProviders.d.ts.map +1 -1
- package/dist/types/context/withdrawalContext.d.ts +2 -0
- package/dist/types/context/withdrawalContext.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +9 -7
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/helpers/accountSelectHelper.d.ts +1 -1
- package/dist/types/helpers/balanceHelper.d.ts +2 -2
- package/dist/types/helpers/filterSourceNetworks.d.ts +4 -0
- package/dist/types/helpers/filterSourceNetworks.d.ts.map +1 -0
- package/dist/types/helpers/getSettings/getSettings.d.ts +1 -1
- package/dist/types/helpers/getSettings/getSettings.d.ts.map +1 -1
- package/dist/types/helpers/routes.d.ts +1 -1
- package/dist/types/helpers/routes.d.ts.map +1 -1
- package/dist/types/helpers/tokenHelper.d.ts +2 -2
- package/dist/types/hooks/useAllWithdrawalBalances.d.ts +2 -1
- package/dist/types/hooks/useAllWithdrawalBalances.d.ts.map +1 -1
- package/dist/types/hooks/useFee.d.ts +1 -1
- package/dist/types/hooks/useFormRoutes.d.ts +2 -3
- package/dist/types/hooks/useFormRoutes.d.ts.map +1 -1
- package/dist/types/hooks/useFormValidation.d.ts +2 -1
- package/dist/types/hooks/useFormValidation.d.ts.map +1 -1
- package/dist/types/hooks/useSwapHistoryData.d.ts +2 -2
- package/dist/types/hooks/useTransfer.d.ts +5 -0
- package/dist/types/hooks/useTransfer.d.ts.map +1 -0
- package/dist/types/hooks/useWallet.d.ts +3 -3
- package/dist/types/hooks/useWallet.d.ts.map +1 -1
- package/dist/types/lib/AppSettings.d.ts +25 -16
- package/dist/types/lib/AppSettings.d.ts.map +1 -1
- package/dist/types/lib/ErrorHandler.d.ts +3 -0
- package/dist/types/lib/ErrorHandler.d.ts.map +1 -0
- package/dist/types/lib/apiClients/layerSwapApiClient.d.ts +1 -9
- package/dist/types/lib/apiClients/layerSwapApiClient.d.ts.map +1 -1
- package/dist/types/lib/balances/balanceResolver.d.ts +3 -3
- package/dist/types/lib/balances/balanceResolver.d.ts.map +1 -1
- package/dist/types/lib/balances/helpers.d.ts +1 -1
- package/dist/types/lib/balances/useBalance.d.ts +1 -1
- package/dist/types/lib/fees.d.ts +16 -0
- package/dist/types/lib/fees.d.ts.map +1 -1
- package/dist/types/lib/gases/gasResolver.d.ts +2 -2
- package/dist/types/lib/gases/useSWRGas.d.ts +3 -3
- package/dist/types/lib/generateSwapInitialValues.d.ts +1 -1
- package/dist/types/lib/nft/nftBalanceResolver.d.ts +1 -1
- package/dist/types/lib/resolvers/resolverService.d.ts +8 -5
- package/dist/types/lib/resolvers/resolverService.d.ts.map +1 -1
- package/dist/types/lib/sorting.d.ts +1 -1
- package/dist/types/lib/transfers/index.d.ts +2 -0
- package/dist/types/lib/transfers/index.d.ts.map +1 -0
- package/dist/types/lib/transfers/transferResolver.d.ts +7 -0
- package/dist/types/lib/transfers/transferResolver.d.ts.map +1 -0
- package/dist/types/stores/balanceStore.d.ts.map +1 -1
- package/dist/types/stores/logStore.d.ts +8 -0
- package/dist/types/stores/logStore.d.ts.map +1 -0
- package/dist/types/stores/walletStore.d.ts +1 -1
- package/dist/types/types/balance.d.ts +2 -2
- package/dist/types/types/balance.d.ts.map +1 -1
- package/dist/types/types/gas.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/logEvents.d.ts +41 -0
- package/dist/types/types/logEvents.d.ts.map +1 -0
- package/dist/types/types/nft.d.ts +1 -1
- package/dist/types/types/transfer.d.ts +7 -2
- package/dist/types/types/transfer.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +23 -5
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/esm/helpers/querryHelper.js +0 -13
- package/dist/esm/lib/logError.js +0 -17
- package/dist/types/context/balanceAccounts.d.ts.map +0 -1
- package/dist/types/helpers/querryHelper.d.ts +0 -3
- package/dist/types/helpers/querryHelper.d.ts.map +0 -1
- package/dist/types/lib/logError.d.ts +0 -3
- package/dist/types/lib/logError.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
const WalletWithdrawalContext = React.createContext(null);
|
|
4
|
-
export const WithdrawalProvider = ({ onWalletWithdrawalSuccess, children }) => {
|
|
5
|
-
return (_jsx(WalletWithdrawalContext.Provider, { value: { onWalletWithdrawalSuccess }, children: children }));
|
|
4
|
+
export const WithdrawalProvider = ({ onWalletWithdrawalSuccess, onCancelWithdrawal, children }) => {
|
|
5
|
+
return (_jsx(WalletWithdrawalContext.Provider, { value: { onWalletWithdrawalSuccess, onCancelWithdrawal }, children: children }));
|
|
6
6
|
};
|
|
7
7
|
export function useWalletWithdrawalState() {
|
|
8
8
|
const data = React.useContext(WalletWithdrawalContext);
|
|
@@ -3,8 +3,6 @@ import KnownInternalNames from "../lib/knownIds";
|
|
|
3
3
|
export { KnownInternalNames };
|
|
4
4
|
import NetworkSettings from "../lib/NetworkSettings";
|
|
5
5
|
export { NetworkSettings };
|
|
6
|
-
import logError from "../lib/logError";
|
|
7
|
-
export { logError };
|
|
8
6
|
export { insertIfNotExists } from "../lib/balances/helpers";
|
|
9
7
|
export * from "../lib/retry";
|
|
10
8
|
export { fetchWithTimeout } from "../lib/fetchWithTimeout";
|
|
@@ -18,11 +16,14 @@ export * from "../components/shadcn";
|
|
|
18
16
|
export { default as WalletMessage } from "../components/Pages/Swap/Withdraw/messages/Message";
|
|
19
17
|
export * from "../components/Buttons";
|
|
20
18
|
export * from "../components/Pages/Swap/Withdraw/Wallet/Common/buttons";
|
|
19
|
+
export * from "../components/Pages/Swap/Withdraw/Wallet/Common/actionMessage";
|
|
21
20
|
export { default as ClickTooltip } from "../components/Common/ClickTooltip";
|
|
22
|
-
export { useSelectedAccount,
|
|
21
|
+
export { useSelectedAccount, useSelectSwapAccount, useSwapAccounts, useNetworkBalance } from "../context/swapAccounts";
|
|
23
22
|
export { default as useWallet } from "../hooks/useWallet";
|
|
24
23
|
export * from "../lib/apiClients";
|
|
25
24
|
export * from "../lib/formatUnits";
|
|
26
25
|
export * from "../stores";
|
|
27
26
|
export { default as shortenAddress } from "../components/utils/ShortenAddress";
|
|
28
27
|
export * from "../context/swap";
|
|
28
|
+
export { useWalletProvidersList } from "../components/Wallet/WalletProviders";
|
|
29
|
+
export { ErrorHandler } from '../lib/ErrorHandler';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function filterSourceNetworks(settings, walletProviders) {
|
|
2
|
+
const networkTypesAggregation = settings.sourceRoutes?.reduce((acc, route) => {
|
|
3
|
+
if (!acc[route.type]) {
|
|
4
|
+
acc[route.type] = [];
|
|
5
|
+
}
|
|
6
|
+
acc[route.type].push(route);
|
|
7
|
+
return acc;
|
|
8
|
+
}, {}) || {};
|
|
9
|
+
const allNetworkTypes = Object.keys(networkTypesAggregation);
|
|
10
|
+
const availableNetworkTypes = allNetworkTypes.filter(networkType => {
|
|
11
|
+
return networkTypesAggregation[networkType].some(route => route.deposit_methods.includes("deposit_address") ||
|
|
12
|
+
walletProviders.some(provider => provider.withdrawalSupportedNetworks.includes(route.name)));
|
|
13
|
+
});
|
|
14
|
+
if (availableNetworkTypes.length === allNetworkTypes.length) {
|
|
15
|
+
return {
|
|
16
|
+
all: true,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
all: false,
|
|
21
|
+
networks: availableNetworkTypes
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -2,17 +2,22 @@ import LayerSwapApiClient from "../../lib/apiClients/layerSwapApiClient";
|
|
|
2
2
|
export async function getSettings(apiKey) {
|
|
3
3
|
const apiClient = new LayerSwapApiClient();
|
|
4
4
|
LayerSwapApiClient.apiKey = apiKey;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
try {
|
|
6
|
+
const { data: networkData } = await apiClient.GetLSNetworksAsync();
|
|
7
|
+
const { data: sourceExchangesData } = await apiClient.GetSourceExchangesAsync();
|
|
8
|
+
const { data: sourceRoutes } = await apiClient.GetRoutesAsync('sources');
|
|
9
|
+
const { data: destinationRoutes } = await apiClient.GetRoutesAsync('destinations');
|
|
10
|
+
if (!networkData)
|
|
11
|
+
return;
|
|
12
|
+
const settings = {
|
|
13
|
+
networks: networkData,
|
|
14
|
+
sourceExchanges: sourceExchangesData || [],
|
|
15
|
+
sourceRoutes: sourceRoutes || [],
|
|
16
|
+
destinationRoutes: destinationRoutes || []
|
|
17
|
+
};
|
|
18
|
+
return settings;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
18
23
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import AppSettings from "../lib/AppSettings";
|
|
1
2
|
export const resolveExchangesURLForSelectedToken = (values) => {
|
|
2
3
|
const include_unmatched = 'true';
|
|
3
4
|
const include_swaps = 'false';
|
|
@@ -62,7 +63,9 @@ export const resolveRoutesURLForSelectedToken = ({ direction, network, token, in
|
|
|
62
63
|
}
|
|
63
64
|
: {})
|
|
64
65
|
});
|
|
65
|
-
const
|
|
66
|
+
const availableNetworkTypes = AppSettings.AvailableSourceNetworkTypes;
|
|
67
|
+
const networkTypesQuery = availableNetworkTypes?.all ? '' : availableNetworkTypes?.networks?.map(type => `network_types=${type}`).join('&') || '';
|
|
68
|
+
const sourceRoutesURL = `/sources?${params.toString()}${networkTypesQuery ? `&${networkTypesQuery}` : ''}`;
|
|
66
69
|
const destinationRoutesURL = `/destinations?${params.toString()}`;
|
|
67
70
|
const result = direction === "from" ? sourceRoutesURL : destinationRoutesURL;
|
|
68
71
|
return result;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useSettingsState } from "../context/settings";
|
|
2
2
|
import { selectResolvedSortingBalances, useBalanceStore } from "../stores/balanceStore";
|
|
3
3
|
import { useEffect, useMemo, useRef } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useSwapAccounts } from "../context/swapAccounts";
|
|
5
5
|
export default function useAllWithdrawalBalances() {
|
|
6
6
|
const networks = useSettingsState().networks;
|
|
7
|
-
const
|
|
7
|
+
const swapAccounts = useSwapAccounts("from");
|
|
8
8
|
const walletNetworks = useMemo(() => {
|
|
9
|
-
return
|
|
9
|
+
return swapAccounts.map(account => {
|
|
10
10
|
const withdrawalNetworks = account.walletWithdrawalSupportedNetworks;
|
|
11
11
|
if (!withdrawalNetworks || withdrawalNetworks.length === 0)
|
|
12
12
|
return [];
|
|
@@ -20,7 +20,7 @@ export default function useAllWithdrawalBalances() {
|
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
}).flat().filter(item => item !== null);
|
|
23
|
-
}, [
|
|
23
|
+
}, [swapAccounts, networks]);
|
|
24
24
|
const walletNetwokrsString = useMemo(() => {
|
|
25
25
|
return walletNetworks.map(item => `${item.address}-${item.network.name}`).join(',');
|
|
26
26
|
}, [walletNetworks]);
|
|
@@ -31,9 +31,10 @@ export default function useAllWithdrawalBalances() {
|
|
|
31
31
|
const lastBalancesRef = useRef(null);
|
|
32
32
|
const resolvedBalances = useBalanceStore(selectResolvedSortingBalances);
|
|
33
33
|
const isLoading = useBalanceStore(s => s.sortingDataIsLoading);
|
|
34
|
+
const partialPublished = useBalanceStore(s => s.partialPublished);
|
|
34
35
|
if (resolvedBalances != null && Object.keys(resolvedBalances).length > 0) {
|
|
35
36
|
lastBalancesRef.current = resolvedBalances;
|
|
36
37
|
}
|
|
37
38
|
const result = resolvedBalances === null && isLoading ? lastBalancesRef.current : resolvedBalances;
|
|
38
|
-
return useMemo(() => ({ isLoading, balances: result }), [result, isLoading]);
|
|
39
|
+
return useMemo(() => ({ isLoading, balances: result, partialPublished }), [result, isLoading, partialPublished]);
|
|
39
40
|
}
|
|
@@ -19,14 +19,25 @@ export default function useFormRoutes({ direction, values }, search) {
|
|
|
19
19
|
});
|
|
20
20
|
const { lockFrom, from, lockTo, to, lockFromAsset, fromAsset, lockToAsset, toAsset } = useInitialSettings();
|
|
21
21
|
const groupByToken = useRouteTokenSwitchStore((s) => s.showTokens);
|
|
22
|
-
const { balances, isLoading
|
|
22
|
+
const { balances, partialPublished, isLoading } = useAllWithdrawalBalances();
|
|
23
23
|
const routesHistory = useRecentNetworksStore(state => state.recentRoutes);
|
|
24
|
+
const loadingSuggestions = useMemo(() => {
|
|
25
|
+
return !partialPublished && isLoading && direction === "from";
|
|
26
|
+
}, [isLoading, direction, partialPublished]);
|
|
24
27
|
// Apply query-based filtering
|
|
25
28
|
const filteredRoutes = useMemo(() => {
|
|
26
29
|
const filtered = filterRoutesByQuery(routes, direction, { lockFrom, from, lockTo, to, lockFromAsset, fromAsset, lockToAsset, toAsset });
|
|
27
30
|
return filtered;
|
|
28
31
|
}, [routes, direction, lockFrom, from, lockTo, to, lockFromAsset, fromAsset, lockToAsset, toAsset]);
|
|
29
|
-
const routeElements = useMemo(() => groupRoutes(
|
|
32
|
+
const routeElements = useMemo(() => groupRoutes({
|
|
33
|
+
routes: filteredRoutes,
|
|
34
|
+
direction,
|
|
35
|
+
balances,
|
|
36
|
+
groupBy: groupByToken ? "token" : "network",
|
|
37
|
+
recents: routesHistory,
|
|
38
|
+
balancesLoaded: loadingSuggestions,
|
|
39
|
+
search
|
|
40
|
+
}), [filteredRoutes, balances, direction, search, groupByToken, routesHistory, loadingSuggestions]);
|
|
30
41
|
const exchanges = useMemo(() => {
|
|
31
42
|
return groupExchanges(exchangesRoutes, search, direction, { lockFrom, from, lockTo, to });
|
|
32
43
|
}, [exchangesRoutes, search, direction, lockFrom, from, lockTo, to]);
|
|
@@ -42,7 +53,6 @@ export default function useFormRoutes({ direction, values }, search) {
|
|
|
42
53
|
exchangeSourceNetworksLoading,
|
|
43
54
|
selectedRoute,
|
|
44
55
|
selectedToken,
|
|
45
|
-
allbalancesLoaded: !balancesLoading,
|
|
46
56
|
}), [
|
|
47
57
|
filteredRoutes,
|
|
48
58
|
routesLoading,
|
|
@@ -52,8 +62,7 @@ export default function useFormRoutes({ direction, values }, search) {
|
|
|
52
62
|
withdrawalNetworks,
|
|
53
63
|
exchangeSourceNetworksLoading,
|
|
54
64
|
selectedRoute,
|
|
55
|
-
selectedToken
|
|
56
|
-
balancesLoading,
|
|
65
|
+
selectedToken
|
|
57
66
|
]);
|
|
58
67
|
}
|
|
59
68
|
function useRoutesData(url, defaultData, fetcher) {
|
|
@@ -169,12 +178,11 @@ const searchInTokens = (routes, search) => {
|
|
|
169
178
|
return symbolMatch || contractMatch || nameMatch || combo;
|
|
170
179
|
});
|
|
171
180
|
};
|
|
172
|
-
|
|
173
|
-
function groupRoutes(routes, direction, balances, groupBy = 'network', recents, balancesLoading, search) {
|
|
181
|
+
function groupRoutes({ routes, direction, balances, groupBy, recents, balancesLoaded, search }) {
|
|
174
182
|
if (search) {
|
|
175
183
|
return resolveSearch(routes, search, direction, balances, recents);
|
|
176
184
|
}
|
|
177
|
-
const suggestedRoutes = getSuggestedRoutes(routes, balances, recents, direction,
|
|
185
|
+
const suggestedRoutes = getSuggestedRoutes(routes, balances, recents, direction, balancesLoaded);
|
|
178
186
|
if (groupBy === "token") {
|
|
179
187
|
const groupedTokens = resolveTokenRoutes(routes, balances, direction);
|
|
180
188
|
return mergeGroups(suggestedRoutes, groupedTokens);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isValidAddress } from '../lib/address/validator';
|
|
2
2
|
export const FORM_VALIDATION_ERROR_CODES = {
|
|
3
|
+
ROUTE_NOT_FOUND: "ROUTE_NOT_FOUND",
|
|
3
4
|
MIN_AMOUNT_ERROR: "MIN_AMOUNT_ERROR",
|
|
4
5
|
MAX_AMOUNT_ERROR: "MAX_AMOUNT_ERROR",
|
|
5
6
|
};
|
|
@@ -20,9 +21,6 @@ export function resolveFormValidation({ values, maxAllowedAmount, minAllowedAmou
|
|
|
20
21
|
if (!amount) {
|
|
21
22
|
return { message: 'Enter an amount' };
|
|
22
23
|
}
|
|
23
|
-
if (!/^[0-9]*[.,]?[0-9]*$/i.test(amount.toString())) {
|
|
24
|
-
return { message: 'Invalid amount' };
|
|
25
|
-
}
|
|
26
24
|
if (amount < 0) {
|
|
27
25
|
return { message: "Can't be negative" };
|
|
28
26
|
}
|
|
@@ -32,6 +30,9 @@ export function resolveFormValidation({ values, maxAllowedAmount, minAllowedAmou
|
|
|
32
30
|
if (minAllowedAmount != undefined && amount < minAllowedAmount) {
|
|
33
31
|
return { code: FORM_VALIDATION_ERROR_CODES.MIN_AMOUNT_ERROR, message: `Min amount is ${minAllowedAmount}` };
|
|
34
32
|
}
|
|
33
|
+
if (!/^[0-9]*[.,]?[0-9]*$/i.test(amount.toString())) {
|
|
34
|
+
return { message: 'Invalid amount' };
|
|
35
|
+
}
|
|
35
36
|
if (values.to) {
|
|
36
37
|
if (values.destination_address && !isValidAddress(values.destination_address, values.to)) {
|
|
37
38
|
return { message: `Enter a valid ${values.to?.display_name} address` };
|
|
@@ -50,7 +51,7 @@ export function resolveFormValidation({ values, maxAllowedAmount, minAllowedAmou
|
|
|
50
51
|
}
|
|
51
52
|
const quoteErrorCode = quoteError?.response?.data?.error?.code || quoteError?.code;
|
|
52
53
|
if (quoteError && quoteErrorCode !== "QUOTE_REQUIRES_NO_DEPOSIT_ADDRESS") {
|
|
53
|
-
return { message: 'Route not found' };
|
|
54
|
+
return { message: 'Route not found', code: FORM_VALIDATION_ERROR_CODES.ROUTE_NOT_FOUND };
|
|
54
55
|
}
|
|
55
56
|
return { message: '' };
|
|
56
57
|
}
|
|
@@ -3,7 +3,7 @@ import { RouteOff } from 'lucide-react';
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useInitialSettings } from '../context/settings';
|
|
5
5
|
import { useFormikContext } from 'formik';
|
|
6
|
-
import { useSelectedAccount } from '../context/
|
|
6
|
+
import { useSelectedAccount } from '../context/swapAccounts';
|
|
7
7
|
import { ICON_CLASSES_WARNING } from '../components/Pages/Swap/Form/SecondaryComponents/validationError/constants';
|
|
8
8
|
export function resolveRouteValidation(quoteError) {
|
|
9
9
|
const { values } = useFormikContext();
|
|
@@ -6,7 +6,7 @@ const PAGE_SIZE = 20;
|
|
|
6
6
|
const getSwapsKey = (index, statuses, addresses) => {
|
|
7
7
|
const addressesParams = addresses?.map(a => `&addresses=${a}`).join('') || '';
|
|
8
8
|
const statusesParams = statuses.map(s => `&statuses=${s}`).join('') || '';
|
|
9
|
-
return `/internal
|
|
9
|
+
return `/swaps/internal?page=${index + 1}${statusesParams}${addressesParams}`;
|
|
10
10
|
};
|
|
11
11
|
export function useSwrSwaps({ statuses, addresses, refreshInterval, autoLoadAllInitially, revalidateAll, revalidateFirstPage }) {
|
|
12
12
|
const apiClient = new LayerSwapApiClient();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { resolverService } from "../lib/resolvers/resolverService";
|
|
2
|
+
import { useCallback } from "react";
|
|
3
|
+
export function useTransfer() {
|
|
4
|
+
const executeTransfer = useCallback(async (params, wallet) => {
|
|
5
|
+
const transferResolver = resolverService.getTransferResolver();
|
|
6
|
+
return transferResolver.executeTransfer(params, wallet);
|
|
7
|
+
}, []);
|
|
8
|
+
return { executeTransfer };
|
|
9
|
+
}
|
|
@@ -39,26 +39,26 @@ const resolveProvider = (network, walletProviders, purpose) => {
|
|
|
39
39
|
case "withdrawal":
|
|
40
40
|
provider = walletProviders.find(provider => provider.withdrawalSupportedNetworks?.includes(network.name));
|
|
41
41
|
break;
|
|
42
|
-
case "
|
|
42
|
+
case "autofill":
|
|
43
43
|
provider = walletProviders.find(provider => provider.autofillSupportedNetworks?.includes(network.name));
|
|
44
44
|
break;
|
|
45
45
|
case "asSource":
|
|
46
46
|
provider = walletProviders.find(provider => provider.asSourceSupportedNetworks?.includes(network.name));
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
|
-
if (provider?.isNotAvailableCondition) {
|
|
50
|
-
const availableWalletsForConnect = provider.availableWalletsForConnect?.filter(connector => (provider.isNotAvailableCondition && network?.name) ? !provider.isNotAvailableCondition(connector.id, network?.name) : true);
|
|
49
|
+
if (provider?.isNotAvailableCondition && purpose) {
|
|
50
|
+
const availableWalletsForConnect = provider.availableWalletsForConnect?.filter(connector => (provider.isNotAvailableCondition && network?.name) ? !provider.isNotAvailableCondition(connector.id, network?.name, purpose) : true);
|
|
51
51
|
const resolvedProvider = {
|
|
52
52
|
...provider,
|
|
53
53
|
connectedWallets: provider.connectedWallets?.map(wallet => {
|
|
54
54
|
return {
|
|
55
55
|
...wallet,
|
|
56
|
-
isNotAvailable: (provider.isNotAvailableCondition && network?.name && wallet.internalId) ? provider.isNotAvailableCondition(wallet.internalId, network?.name) : false,
|
|
56
|
+
isNotAvailable: (provider.isNotAvailableCondition && network?.name && wallet.internalId) ? provider.isNotAvailableCondition(wallet.internalId, network?.name, purpose) : false,
|
|
57
57
|
};
|
|
58
58
|
}),
|
|
59
59
|
activeWallet: provider.activeWallet ? {
|
|
60
60
|
...provider.activeWallet,
|
|
61
|
-
isNotAvailable: (network?.name) ? provider.isNotAvailableCondition(provider.activeWallet.id, network?.name) : false,
|
|
61
|
+
isNotAvailable: (network?.name) ? provider.isNotAvailableCondition(provider.activeWallet.id, network?.name, purpose) : false,
|
|
62
62
|
} : undefined,
|
|
63
63
|
availableWalletsForConnect
|
|
64
64
|
};
|
|
@@ -67,13 +67,13 @@ const resolveProvider = (network, walletProviders, purpose) => {
|
|
|
67
67
|
return provider;
|
|
68
68
|
};
|
|
69
69
|
const resolveWallet = (wallet, network, provider, purpose) => {
|
|
70
|
-
if (provider.isNotAvailableCondition && network?.name && wallet.internalId) {
|
|
70
|
+
if (provider.isNotAvailableCondition && network?.name && wallet.internalId && !purpose) {
|
|
71
71
|
return {
|
|
72
72
|
...wallet,
|
|
73
73
|
isNotAvailable: provider.isNotAvailableCondition(wallet.internalId, network?.name),
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
if (purpose === "
|
|
76
|
+
if (purpose === "autofill") {
|
|
77
77
|
return {
|
|
78
78
|
...wallet,
|
|
79
79
|
isNotAvailable: !wallet.autofillSupportedNetworks?.some(n => n.toLowerCase() === network?.name.toLowerCase()),
|
|
@@ -1,33 +1,44 @@
|
|
|
1
|
-
class
|
|
1
|
+
class WalletsConfigs {
|
|
2
2
|
}
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
feedback_token: '',
|
|
9
|
-
feedback_chat_id: '',
|
|
10
|
-
error_token: '',
|
|
11
|
-
error_chat_id: ''
|
|
12
|
-
};
|
|
13
|
-
AppSettings.WalletConnectConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Pass `walletConnectConfigs` directly to the wallet provider factory
|
|
5
|
+
* (e.g. `createEVMProvider({ walletConnectConfigs })`). This static config will be removed soon.
|
|
6
|
+
*/
|
|
7
|
+
WalletsConfigs.WalletConnectConfig = {
|
|
14
8
|
projectId: '28168903b2d30c75e5f7f2d71902581b',
|
|
15
9
|
name: 'Layerswap',
|
|
16
10
|
description: 'Layerswap App',
|
|
17
11
|
url: 'https://layerswap.io/app/',
|
|
18
|
-
icons: ['https://www.layerswap.io/app/symbol.png']
|
|
12
|
+
icons: ['https://www.layerswap.io/app/symbol.png']
|
|
19
13
|
};
|
|
20
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Pass `tonConfigs` to `createTONProvider({ tonConfigs })`. This fallback will be removed.
|
|
16
|
+
*/
|
|
17
|
+
WalletsConfigs.TonClientConfig = {
|
|
21
18
|
tonApiKey: '815b3d3036592d941bbcec5a4db824a588c1b2d210c3a4b6d188dcd4a15337d2',
|
|
22
19
|
manifestUrl: `https://layerswap.io/app/tonconnect-manifest.json`
|
|
23
20
|
};
|
|
24
|
-
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Pass `imtblPassportConfig` to `createImmutablePassportProvider({ imtblPassportConfig })`.
|
|
23
|
+
*/
|
|
24
|
+
WalletsConfigs.ImtblPassportConfig = {
|
|
25
25
|
publishableKey: "",
|
|
26
26
|
clientId: "",
|
|
27
27
|
redirectUri: "",
|
|
28
28
|
logoutRedirectUri: ""
|
|
29
29
|
};
|
|
30
|
-
AppSettings
|
|
30
|
+
class AppSettings extends WalletsConfigs {
|
|
31
|
+
}
|
|
32
|
+
AppSettings.ApiVersion = "mainnet";
|
|
33
|
+
AppSettings.ExplorerURl = `https://www.layerswap.io/explorer/`;
|
|
34
|
+
AppSettings.LayerswapApiUri = 'https://api.layerswap.io';
|
|
35
|
+
AppSettings.ResourseStorageUrl = 'https://prodlslayerswapbridgesa.blob.core.windows.net/';
|
|
36
|
+
AppSettings.TelegramLogConfigs = {
|
|
37
|
+
feedback_token: '',
|
|
38
|
+
feedback_chat_id: '',
|
|
39
|
+
error_token: '',
|
|
40
|
+
error_chat_id: ''
|
|
41
|
+
};
|
|
31
42
|
AppSettings.LayerswapApiKeys = {
|
|
32
43
|
'mainnet': 'NDBxG+aon6WlbgIA2LfwmcbLU52qUL9qTnztTuTRPNSohf/VnxXpRaJlA5uLSQVqP8YGIiy/0mz+mMeZhLY4/Q',
|
|
33
44
|
'testnet': 'Dz1jVir9WUD0gBWoGbOmS1oe5K4985SGptaZXjF4z9VVrvO5nC9q55h8TE/3CIESRxWdYVpPnz/H2BogL2eG+A'
|
|
@@ -3,7 +3,7 @@ import { InitializeUnauthInstance, InitializeAuthInstance } from "../axiosInterc
|
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import { AuthRefreshFailedError } from "../Errors/AuthRefreshFailedError";
|
|
5
5
|
import { EmptyApiResponse } from "../../Models/ApiResponse";
|
|
6
|
-
|
|
6
|
+
import { ErrorHandler } from "../../lib/ErrorHandler";
|
|
7
7
|
class LayerSwapApiClient {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.fetcher = (url) => this.AuthenticatedRequest("GET", url);
|
|
@@ -23,31 +23,12 @@ class LayerSwapApiClient {
|
|
|
23
23
|
const correlationId = uuidv4();
|
|
24
24
|
return await this.AuthenticatedRequest("POST", `/swaps`, params, { 'X-LS-CORRELATION-ID': correlationId });
|
|
25
25
|
}
|
|
26
|
-
async GetSwapsAsync(page, include_expired) {
|
|
27
|
-
return await this.AuthenticatedRequest("GET", `/internal/swaps?page=${page}&include_expired=${include_expired}`);
|
|
28
|
-
}
|
|
29
|
-
async GetQuote({ params }) {
|
|
30
|
-
const { source_network, source_token, source_address, destination_token, destination_network, amount, use_deposit_address, include_gas, refuel } = params;
|
|
31
|
-
return await this.AuthenticatedRequest("GET", `/quote?source_network=${source_network}&source_token=${source_token}&source_address=${source_address}&destination_network=${destination_network}&destination_token=${destination_token}&use_deposit_address=${use_deposit_address}&include_gas=${include_gas}&amount=${amount}&refuel=${refuel}`);
|
|
32
|
-
}
|
|
33
|
-
async DisconnectExchangeAsync(swapid, exchangeName) {
|
|
34
|
-
return await this.AuthenticatedRequest("DELETE", `/internal/swaps/${swapid}/exchange/${exchangeName}/disconnect`);
|
|
35
|
-
}
|
|
36
|
-
async GetSwapDetailsAsync(id) {
|
|
37
|
-
return await this.AuthenticatedRequest("GET", `/swaps/${id}`);
|
|
38
|
-
}
|
|
39
|
-
async GetDepositAddress(network, source) {
|
|
40
|
-
return await this.AuthenticatedRequest("GET", `/internal/swaps?network=${network}&source=${source}`);
|
|
41
|
-
}
|
|
42
|
-
async WithdrawFromExchange(swapId, exchange, twoFactorCode) {
|
|
43
|
-
return await this.AuthenticatedRequest("POST", `/internal/swaps/${swapId}/exchange/${exchange}/withdraw${twoFactorCode ? `?twoFactorCode=${twoFactorCode}` : ''}`);
|
|
44
|
-
}
|
|
45
|
-
async SwapsMigration(GuestAuthorization) {
|
|
46
|
-
return await this.AuthenticatedRequest("POST", `/internal/swaps/migrate`, null, { GuestAuthorization });
|
|
47
|
-
}
|
|
48
26
|
async GetTransactionStatus(network, tx_id) {
|
|
49
27
|
return await this.UnauthenticatedRequest("GET", `/transaction_status?network=${network}&transaction_id=${tx_id}`);
|
|
50
28
|
}
|
|
29
|
+
async SwapCatchup(swapId, tx_id) {
|
|
30
|
+
return await this.AuthenticatedRequest("POST", `/swaps/${swapId}/deposit_speedup`, { transaction_id: tx_id });
|
|
31
|
+
}
|
|
51
32
|
async AuthenticatedRequest(method, endpoint, data, header) {
|
|
52
33
|
let uri = LayerSwapApiClient.apiBaseEndpoint + "/api/v2" + endpoint;
|
|
53
34
|
return await this._authInterceptor(uri, { method: method, data: data, headers: { 'Access-Control-Allow-Origin': '*', ...(header ? header : {}) } })
|
|
@@ -59,18 +40,14 @@ class LayerSwapApiClient {
|
|
|
59
40
|
return Promise.resolve(new EmptyApiResponse());
|
|
60
41
|
}
|
|
61
42
|
else {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// cause: renderingError.cause,
|
|
71
|
-
// where: 'apiClient',
|
|
72
|
-
// severity: 'error',
|
|
73
|
-
// });
|
|
43
|
+
const error = reason;
|
|
44
|
+
ErrorHandler({
|
|
45
|
+
type: 'APIError',
|
|
46
|
+
message: error.message,
|
|
47
|
+
name: error.name,
|
|
48
|
+
stack: error.stack,
|
|
49
|
+
cause: error.cause
|
|
50
|
+
});
|
|
74
51
|
return Promise.reject(reason);
|
|
75
52
|
}
|
|
76
53
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ErrorHandler } from "../../lib/ErrorHandler";
|
|
1
2
|
export class BalanceResolver {
|
|
2
3
|
constructor(providers) {
|
|
3
4
|
this.providers = providers || [];
|
|
@@ -15,19 +16,14 @@ export class BalanceResolver {
|
|
|
15
16
|
return { balances };
|
|
16
17
|
}
|
|
17
18
|
catch (e) {
|
|
18
|
-
const error =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// cause: error.cause,
|
|
27
|
-
// type: 'BalanceError',
|
|
28
|
-
// where: 'BalanceProviderError',
|
|
29
|
-
// severity: 'error',
|
|
30
|
-
// });
|
|
19
|
+
const error = e;
|
|
20
|
+
ErrorHandler({
|
|
21
|
+
type: 'BalanceResolverError',
|
|
22
|
+
message: error.message,
|
|
23
|
+
name: error.name,
|
|
24
|
+
stack: error.stack,
|
|
25
|
+
cause: error
|
|
26
|
+
});
|
|
31
27
|
return { balances: [] };
|
|
32
28
|
}
|
|
33
29
|
}
|
package/dist/esm/lib/fees.js
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
export function CalculateMinimalAuthorizeAmount(usd_price, amount) {
|
|
2
2
|
return Math.ceil((usd_price * amount) + (usd_price * amount * 0.02));
|
|
3
3
|
}
|
|
4
|
+
export const resolvePriceImpactValues = (quote) => {
|
|
5
|
+
const receiveAmount = quote?.receive_amount;
|
|
6
|
+
const requestedAmount = quote?.requested_amount;
|
|
7
|
+
const sourceTokenPriceUsd = quote?.source_token?.price_in_usd;
|
|
8
|
+
const destinationTokenPriceUsd = quote?.destination_token?.price_in_usd;
|
|
9
|
+
const serviceFee = quote?.service_fee;
|
|
10
|
+
const bridgeFee = quote?.blockchain_fee;
|
|
11
|
+
const receiveAmountUSD = receiveAmount && destinationTokenPriceUsd
|
|
12
|
+
? receiveAmount * destinationTokenPriceUsd
|
|
13
|
+
: undefined;
|
|
14
|
+
const requestedAmountUSD = requestedAmount && sourceTokenPriceUsd
|
|
15
|
+
? requestedAmount * sourceTokenPriceUsd
|
|
16
|
+
: undefined;
|
|
17
|
+
const priceImpact = requestedAmountUSD !== undefined && receiveAmountUSD !== undefined
|
|
18
|
+
? receiveAmountUSD - requestedAmountUSD
|
|
19
|
+
: undefined;
|
|
20
|
+
const layerswapFees = serviceFee != null && sourceTokenPriceUsd != null
|
|
21
|
+
? serviceFee * sourceTokenPriceUsd
|
|
22
|
+
: undefined;
|
|
23
|
+
const bridgeExpenses = bridgeFee != null && sourceTokenPriceUsd != null
|
|
24
|
+
? bridgeFee * sourceTokenPriceUsd
|
|
25
|
+
: undefined;
|
|
26
|
+
const marketImpact = priceImpact !== undefined && layerswapFees !== undefined && bridgeExpenses !== undefined
|
|
27
|
+
? priceImpact + Number(layerswapFees) + Number(bridgeExpenses)
|
|
28
|
+
: undefined;
|
|
29
|
+
const priceImpactPercentage = requestedAmountUSD !== undefined && receiveAmountUSD !== undefined
|
|
30
|
+
? Number((((receiveAmountUSD - requestedAmountUSD) / requestedAmountUSD) * 100).toFixed(2))
|
|
31
|
+
: undefined;
|
|
32
|
+
const marketImpactPercentage = marketImpact !== undefined && requestedAmountUSD !== undefined && requestedAmountUSD > 0
|
|
33
|
+
? Number(((marketImpact / requestedAmountUSD) * 100).toFixed(2))
|
|
34
|
+
: undefined;
|
|
35
|
+
const highMarketPriceImpact = marketImpactPercentage ? marketImpactPercentage < -5 : false;
|
|
36
|
+
const criticalMarketPriceImpact = marketImpactPercentage ? marketImpactPercentage < -10 : false;
|
|
37
|
+
const minReceiveAmountUSD = quote?.min_receive_amount && destinationTokenPriceUsd != null
|
|
38
|
+
? Number(quote.min_receive_amount * destinationTokenPriceUsd).toFixed(2)
|
|
39
|
+
: undefined;
|
|
40
|
+
return {
|
|
41
|
+
receiveAmountUSD,
|
|
42
|
+
requestedAmountUSD,
|
|
43
|
+
priceImpact,
|
|
44
|
+
layerswapFees,
|
|
45
|
+
bridgeExpenses,
|
|
46
|
+
marketImpact,
|
|
47
|
+
priceImpactPercentage,
|
|
48
|
+
marketImpactPercentage,
|
|
49
|
+
highMarketPriceImpact,
|
|
50
|
+
criticalMarketPriceImpact,
|
|
51
|
+
minReceiveAmountUSD,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -2,18 +2,21 @@ import { BalanceResolver } from "../../lib/balances/balanceResolver";
|
|
|
2
2
|
import { GasResolver } from "../../lib/gases/gasResolver";
|
|
3
3
|
import { AddressUtilsResolver } from '../../lib/address/addressUtilsResolver';
|
|
4
4
|
import { NftBalanceResolver } from "../nft/nftBalanceResolver";
|
|
5
|
+
import { TransferResolver } from "../transfers/transferResolver";
|
|
5
6
|
class UtilsResolverService {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.balanceResolver = null;
|
|
8
9
|
this.gasResolver = null;
|
|
9
10
|
this.addressUtilsResolver = null;
|
|
10
11
|
this.nftResolver = null;
|
|
12
|
+
this.transferResolver = null;
|
|
11
13
|
}
|
|
12
|
-
setProviders(balanceProviders, gasProviders, addressUtilsProviders, nftProviders) {
|
|
14
|
+
setProviders(balanceProviders, gasProviders, addressUtilsProviders, nftProviders, transferProviders) {
|
|
13
15
|
this.balanceResolver = new BalanceResolver(balanceProviders);
|
|
14
16
|
this.gasResolver = new GasResolver(gasProviders);
|
|
15
17
|
this.addressUtilsResolver = new AddressUtilsResolver(addressUtilsProviders);
|
|
16
18
|
this.nftResolver = new NftBalanceResolver(nftProviders);
|
|
19
|
+
this.transferResolver = new TransferResolver(transferProviders);
|
|
17
20
|
}
|
|
18
21
|
getBalanceResolver() {
|
|
19
22
|
if (!this.balanceResolver) {
|
|
@@ -39,5 +42,11 @@ class UtilsResolverService {
|
|
|
39
42
|
}
|
|
40
43
|
return this.nftResolver;
|
|
41
44
|
}
|
|
45
|
+
getTransferResolver() {
|
|
46
|
+
if (!this.transferResolver) {
|
|
47
|
+
throw new Error('TransferResolver not initialized. Make sure to call setProviders first.');
|
|
48
|
+
}
|
|
49
|
+
return this.transferResolver;
|
|
50
|
+
}
|
|
42
51
|
}
|
|
43
52
|
export const resolverService = new UtilsResolverService();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransferResolver } from './transferResolver';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class TransferResolver {
|
|
2
|
+
constructor(providers) {
|
|
3
|
+
this.providers = providers || [];
|
|
4
|
+
}
|
|
5
|
+
async executeTransfer(params, wallet) {
|
|
6
|
+
const provider = this.providers.find(p => p.supportsNetwork(params.network));
|
|
7
|
+
if (!provider) {
|
|
8
|
+
const error = `No transfer provider found for network: ${params.network.name}`;
|
|
9
|
+
console.warn(error);
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
return provider.executeTransfer(params, wallet);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -113,7 +113,6 @@ export const useBalanceStore = create()(subscribeWithSelector((set, get, api) =>
|
|
|
113
113
|
});
|
|
114
114
|
set({ balanceKeysForSorting: partial });
|
|
115
115
|
set({ partialPublished: true });
|
|
116
|
-
set({ sortingDataIsLoading: false });
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
118
|
}, { fireImmediately: true });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createStore } from 'zustand';
|
|
2
|
+
const defaultHandler = (error) => {
|
|
3
|
+
console.log('[layerswap:log]', error);
|
|
4
|
+
};
|
|
5
|
+
const createLogStore = () => {
|
|
6
|
+
return createStore()((set) => ({
|
|
7
|
+
logger: defaultHandler,
|
|
8
|
+
setLogger: (handler) => set({ logger: handler })
|
|
9
|
+
}));
|
|
10
|
+
};
|
|
11
|
+
export const logStore = createLogStore();
|