@multiversx/sdk-dapp-liquidity 2.0.0 → 2.1.0-alpha.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/all-networks--dfVLHLJ.js +2 -0
- package/all-networks-Czd8zS1n.mjs +4 -0
- package/api/checkAccount.js +1 -21
- package/api/checkAccount.mjs +13 -13
- package/api/confirmRate.js +1 -29
- package/api/confirmRate.mjs +17 -22
- package/api/getChains.js +1 -17
- package/api/getChains.mjs +10 -10
- package/api/getRate.js +1 -27
- package/api/getRate.mjs +17 -20
- package/api/getTokens.js +1 -22
- package/api/getTokens.mjs +14 -15
- package/api/getTokensBalances.js +1 -21
- package/api/getTokensBalances.mjs +13 -13
- package/api/getTransactions.js +1 -38
- package/api/getTransactions.mjs +25 -31
- package/api/index.js +1 -18
- package/api/index.mjs +16 -16
- package/api/sendTransactions.js +1 -32
- package/api/sendTransactions.mjs +19 -19
- package/api/tests/confirmRate.spec.js +1 -130
- package/api/tests/confirmRate.spec.mjs +44 -58
- package/api/tests/getChains.spec.js +1 -43
- package/api/tests/getChains.spec.mjs +15 -18
- package/api/tests/getRate.spec.js +1 -87
- package/api/tests/getRate.spec.mjs +35 -49
- package/api/tests/getTokens.spec.js +1 -68
- package/api/tests/getTokens.spec.mjs +23 -29
- package/api/tests/getTransactions.spec.js +1 -94
- package/api/tests/getTransactions.spec.mjs +35 -51
- package/api/tests/sendTransactions.spec.js +1 -96
- package/api/tests/sendTransactions.spec.mjs +44 -52
- package/constants/index.js +1 -4
- package/constants/index.mjs +2 -2
- package/default-D0Jk5ROI.mjs +4 -0
- package/default-DbU6vPaB.js +2 -0
- package/helpers/assertRateConfirmationMatchesIntent.d.ts +8 -0
- package/helpers/assertRateConfirmationMatchesIntent.js +2 -0
- package/helpers/assertRateConfirmationMatchesIntent.mjs +20 -0
- package/helpers/base64Utils.js +1 -31
- package/helpers/base64Utils.mjs +14 -24
- package/helpers/decodeLoginToken.js +1 -27
- package/helpers/decodeLoginToken.mjs +13 -18
- package/helpers/decodeToken.js +1 -39
- package/helpers/decodeToken.mjs +20 -31
- package/helpers/getApiURL.js +1 -7
- package/helpers/getApiURL.mjs +3 -5
- package/helpers/getBridgeURL.js +1 -7
- package/helpers/getBridgeURL.mjs +3 -5
- package/helpers/getDisplayName.js +1 -11
- package/helpers/getDisplayName.mjs +3 -8
- package/helpers/getMvxApiURL.js +1 -7
- package/helpers/getMvxApiURL.mjs +3 -5
- package/helpers/getMvxChainId.js +1 -7
- package/helpers/getMvxChainId.mjs +3 -5
- package/helpers/getMvxExplorerAddress.js +1 -7
- package/helpers/getMvxExplorerAddress.mjs +3 -5
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +1 -22
- package/helpers/index.mjs +24 -20
- package/helpers/safeImageUrl.d.ts +1 -0
- package/helpers/safeImageUrl.js +2 -0
- package/helpers/safeImageUrl.mjs +13 -0
- package/helpers/serializeTransaction.js +1 -8
- package/helpers/serializeTransaction.mjs +3 -5
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.d.ts +1 -0
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.js +2 -0
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +52 -0
- package/helpers/tests/base64Utils.spec.js +1 -29
- package/helpers/tests/base64Utils.spec.mjs +11 -24
- package/helpers/tests/decodeLoginToken.spec.js +1 -34
- package/helpers/tests/decodeLoginToken.spec.mjs +13 -24
- package/helpers/tests/decodeToken.spec.js +1 -27
- package/helpers/tests/decodeToken.spec.mjs +7 -12
- package/helpers/tests/safeImageUrl.spec.d.ts +1 -0
- package/helpers/tests/safeImageUrl.spec.js +2 -0
- package/helpers/tests/safeImageUrl.spec.mjs +32 -0
- package/helpers/tests/serializeTransaction.spec.d.ts +1 -0
- package/helpers/tests/serializeTransaction.spec.js +2 -0
- package/helpers/tests/serializeTransaction.spec.mjs +24 -0
- package/index.js +1 -228
- package/index.mjs +196 -192
- package/package.json +14 -9
- package/react.esm-B0AMOHxa.js +73 -0
- package/react.esm-BxvJJ86Q.mjs +9949 -0
- package/reactjs/adapters/SuiAdapter.d.ts +14 -0
- package/reactjs/adapters/SuiAdapter.js +1 -349
- package/reactjs/adapters/SuiAdapter.mjs +171 -199
- package/reactjs/components/AccountAddress/AccountAddress.js +1 -31
- package/reactjs/components/AccountAddress/AccountAddress.mjs +16 -16
- package/reactjs/components/AccountAddress/index.js +1 -4
- package/reactjs/components/AccountAddress/index.mjs +2 -2
- package/reactjs/components/AmountCard/AmountCard.js +1 -33
- package/reactjs/components/AmountCard/AmountCard.mjs +19 -21
- package/reactjs/components/AmountCard/index.js +1 -4
- package/reactjs/components/AmountCard/index.mjs +2 -2
- package/reactjs/components/AmountInput/AmountInput.js +1 -71
- package/reactjs/components/AmountInput/AmountInput.mjs +42 -46
- package/reactjs/components/AmountInput/index.js +1 -4
- package/reactjs/components/AmountInput/index.mjs +2 -2
- package/reactjs/components/BridgeForm/BridgeForm.d.ts +9 -0
- package/reactjs/components/BridgeForm/BridgeForm.js +1 -89
- package/reactjs/components/BridgeForm/BridgeForm.mjs +72 -79
- package/reactjs/components/BridgeForm/Deposit.js +1 -673
- package/reactjs/components/BridgeForm/Deposit.mjs +381 -503
- package/reactjs/components/BridgeForm/Transfer.js +1 -559
- package/reactjs/components/BridgeForm/Transfer.mjs +316 -427
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.js +1 -78
- package/reactjs/components/BridgeForm/hooks/useBridgeAmounts.mjs +47 -70
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.js +1 -58
- package/reactjs/components/BridgeForm/hooks/useBridgeRateFetching.mjs +36 -47
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +1 -266
- package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +163 -231
- package/reactjs/components/BridgeForm/index.js +1 -4
- package/reactjs/components/BridgeForm/index.mjs +2 -2
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +1 -76
- package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +35 -65
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -367
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +177 -193
- package/reactjs/components/BridgeHistory/index.js +1 -4
- package/reactjs/components/BridgeHistory/index.mjs +2 -2
- package/reactjs/components/Connect/BridgeAccountDisplay.js +1 -150
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +99 -115
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -34
- package/reactjs/components/Connect/BridgeConnectButton.mjs +20 -19
- package/reactjs/components/Connect/ChainSelectConnect.js +1 -144
- package/reactjs/components/Connect/ChainSelectConnect.mjs +70 -83
- package/reactjs/components/Connect/CustomConnectButton.js +1 -40
- package/reactjs/components/Connect/CustomConnectButton.mjs +24 -30
- package/reactjs/components/Connect/MvxAccountDisplay.js +1 -97
- package/reactjs/components/Connect/MvxAccountDisplay.mjs +47 -50
- package/reactjs/components/Connect/MvxConnectButton.js +1 -43
- package/reactjs/components/Connect/MvxConnectButton.mjs +35 -40
- package/reactjs/components/Connect/SwitchChainButton.js +1 -29
- package/reactjs/components/Connect/SwitchChainButton.mjs +15 -18
- package/reactjs/components/Connect/index.js +1 -16
- package/reactjs/components/Connect/index.mjs +14 -14
- package/reactjs/components/CopyButton/CopyButton.js +1 -46
- package/reactjs/components/CopyButton/CopyButton.mjs +33 -36
- package/reactjs/components/CopyButton/index.js +1 -4
- package/reactjs/components/CopyButton/index.mjs +2 -2
- package/reactjs/components/CopyButton/utils/copyToClipboard.js +1 -38
- package/reactjs/components/CopyButton/utils/copyToClipboard.mjs +20 -32
- package/reactjs/components/CopyButton/utils/index.js +1 -4
- package/reactjs/components/CopyButton/utils/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/DisplayAmount.js +1 -90
- package/reactjs/components/DisplayAmount/DisplayAmount.mjs +68 -75
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +1 -39
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.mjs +26 -33
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.js +1 -61
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.mjs +38 -46
- package/reactjs/components/DisplayAmount/index.js +1 -4
- package/reactjs/components/DisplayAmount/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/utils/index.js +1 -4
- package/reactjs/components/DisplayAmount/utils/index.mjs +2 -2
- package/reactjs/components/DisplayAmount/utils/truncateAmount.js +1 -21
- package/reactjs/components/DisplayAmount/utils/truncateAmount.mjs +9 -13
- package/reactjs/components/Error/Error.js +1 -66
- package/reactjs/components/Error/Error.mjs +29 -29
- package/reactjs/components/Error/index.js +1 -4
- package/reactjs/components/Error/index.mjs +2 -2
- package/reactjs/components/SmallLoader/SmallLoader.js +1 -21
- package/reactjs/components/SmallLoader/SmallLoader.mjs +13 -18
- package/reactjs/components/SmallLoader/index.js +1 -4
- package/reactjs/components/SmallLoader/index.mjs +2 -2
- package/reactjs/components/ToggleDirection/ToggleDirection.js +1 -30
- package/reactjs/components/ToggleDirection/ToggleDirection.mjs +22 -28
- package/reactjs/components/TokenSelector/TokenSelector.js +1 -172
- package/reactjs/components/TokenSelector/TokenSelector.mjs +98 -118
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +1 -94
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +48 -57
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.js +1 -51
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +45 -44
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.js +1 -18
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.mjs +9 -14
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.js +1 -6
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.mjs +2 -4
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.js +1 -39
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +22 -18
- package/reactjs/components/TokenSelector/components/SelectContainer.js +1 -40
- package/reactjs/components/TokenSelector/components/SelectContainer.mjs +36 -38
- package/reactjs/components/TokenSelector/components/SelectContent.js +1 -136
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +79 -103
- package/reactjs/components/TokenSelector/components/SelectedOption.js +1 -28
- package/reactjs/components/TokenSelector/components/SelectedOption.mjs +22 -24
- package/reactjs/components/TokenSelector/components/TokenIcon.js +1 -81
- package/reactjs/components/TokenSelector/components/TokenIcon.mjs +52 -57
- package/reactjs/components/TokenSelector/components/TokenItem.js +1 -80
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +41 -54
- package/reactjs/components/TokenSelector/components/TokenList.js +1 -23
- package/reactjs/components/TokenSelector/components/TokenList.mjs +19 -21
- package/reactjs/components/TokenSelector/components/TokenSymbol.js +1 -25
- package/reactjs/components/TokenSelector/components/TokenSymbol.mjs +14 -15
- package/reactjs/components/TokenSelector/index.js +1 -4
- package/reactjs/components/TokenSelector/index.mjs +2 -2
- package/reactjs/components/TransactionToast/TransactionToast.js +1 -53
- package/reactjs/components/TransactionToast/TransactionToast.mjs +27 -28
- package/reactjs/components/TransactionToast/TransactionToastContainer.js +1 -20
- package/reactjs/components/TransactionToast/TransactionToastContainer.mjs +16 -18
- package/reactjs/components/TransactionToast/index.js +1 -6
- package/reactjs/components/TransactionToast/index.mjs +4 -4
- package/reactjs/components/TrimAddress/TrimAddress.js +1 -27
- package/reactjs/components/TrimAddress/TrimAddress.mjs +19 -24
- package/reactjs/components/TrimAddress/index.js +1 -4
- package/reactjs/components/TrimAddress/index.mjs +2 -2
- package/reactjs/components/base/MxButton/MxButton.js +1 -71
- package/reactjs/components/base/MxButton/MxButton.mjs +46 -46
- package/reactjs/components/base/MxButton/index.js +1 -4
- package/reactjs/components/base/MxButton/index.mjs +2 -2
- package/reactjs/components/base/MxCard/MxCard.js +1 -54
- package/reactjs/components/base/MxCard/MxCard.mjs +34 -34
- package/reactjs/components/base/MxCard/index.js +1 -4
- package/reactjs/components/base/MxCard/index.mjs +2 -2
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.js +1 -28
- package/reactjs/components/base/MxCircleLoader/MxCircleLoader.mjs +24 -26
- package/reactjs/components/base/MxCircleLoader/index.js +1 -4
- package/reactjs/components/base/MxCircleLoader/index.mjs +2 -2
- package/reactjs/components/base/MxLink/MxLink.js +1 -70
- package/reactjs/components/base/MxLink/MxLink.mjs +44 -46
- package/reactjs/components/base/MxLink/index.js +1 -4
- package/reactjs/components/base/MxLink/index.mjs +2 -2
- package/reactjs/components/base/MxSearch/MxSearch.js +1 -69
- package/reactjs/components/base/MxSearch/MxSearch.mjs +37 -41
- package/reactjs/components/base/MxSearch/index.js +1 -4
- package/reactjs/components/base/MxSearch/index.mjs +2 -2
- package/reactjs/components/base/MxSlideover/MxSlideover.js +1 -78
- package/reactjs/components/base/MxSlideover/MxSlideover.mjs +72 -74
- package/reactjs/components/base/MxSlideover/index.js +1 -4
- package/reactjs/components/base/MxSlideover/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/MxTooltip.js +1 -163
- package/reactjs/components/base/MxTooltip/MxTooltip.mjs +92 -135
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +1 -33
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs +29 -31
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.js +1 -4
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.js +1 -27
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.mjs +23 -25
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.js +1 -4
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.mjs +2 -2
- package/reactjs/components/base/MxTooltip/components/index.js +1 -6
- package/reactjs/components/base/MxTooltip/components/index.mjs +4 -4
- package/reactjs/components/base/MxTooltip/index.js +1 -4
- package/reactjs/components/base/MxTooltip/index.mjs +2 -2
- package/reactjs/components/base/index.js +1 -14
- package/reactjs/components/base/index.mjs +12 -12
- package/reactjs/components/index.js +1 -54
- package/reactjs/components/index.mjs +52 -52
- package/reactjs/constants/chains.js +1 -54
- package/reactjs/constants/chains.mjs +33 -52
- package/reactjs/constants/index.js +1 -13
- package/reactjs/constants/index.mjs +9 -10
- package/reactjs/context/Web3AppProvider.js +1 -40
- package/reactjs/context/Web3AppProvider.mjs +34 -34
- package/reactjs/context/queryClient.js +1 -11
- package/reactjs/context/queryClient.mjs +5 -8
- package/reactjs/context/useWeb3App.js +1 -12
- package/reactjs/context/useWeb3App.mjs +7 -8
- package/reactjs/helpers/index.js +1 -6
- package/reactjs/helpers/index.mjs +4 -4
- package/reactjs/helpers/resolveBridgeApiChainId.js +1 -40
- package/reactjs/helpers/resolveBridgeApiChainId.mjs +21 -34
- package/reactjs/hooks/index.js +1 -35
- package/reactjs/hooks/index.mjs +33 -33
- package/reactjs/hooks/tests/useGenericSignMessage.spec.d.ts +1 -0
- package/reactjs/hooks/tests/useGenericSignMessage.spec.js +2 -0
- package/reactjs/hooks/tests/useGenericSignMessage.spec.mjs +52 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.d.ts +1 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.js +2 -0
- package/reactjs/hooks/tests/useSignTransaction.spec.mjs +156 -0
- package/reactjs/hooks/useAccount.js +1 -13
- package/reactjs/hooks/useAccount.mjs +7 -8
- package/reactjs/hooks/useBalances.js +1 -53
- package/reactjs/hooks/useBalances.mjs +28 -40
- package/reactjs/hooks/useBridgeApiChainId.js +1 -13
- package/reactjs/hooks/useBridgeApiChainId.mjs +9 -9
- package/reactjs/hooks/useBridgeFormik.js +1 -162
- package/reactjs/hooks/useBridgeFormik.mjs +110 -150
- package/reactjs/hooks/useDebounce.js +1 -13
- package/reactjs/hooks/useDebounce.mjs +8 -10
- package/reactjs/hooks/useFetchBridgeData.js +1 -45
- package/reactjs/hooks/useFetchBridgeData.mjs +37 -38
- package/reactjs/hooks/useFetchTokens.js +1 -113
- package/reactjs/hooks/useFetchTokens.mjs +80 -106
- package/reactjs/hooks/useGenericSignMessage.js +1 -55
- package/reactjs/hooks/useGenericSignMessage.mjs +47 -47
- package/reactjs/hooks/useGetChainId.js +1 -11
- package/reactjs/hooks/useGetChainId.mjs +7 -8
- package/reactjs/hooks/useResolveTokenChain.js +1 -20
- package/reactjs/hooks/useResolveTokenChain.mjs +11 -14
- package/reactjs/hooks/useSendTransactions.js +1 -25
- package/reactjs/hooks/useSendTransactions.mjs +19 -23
- package/reactjs/hooks/useSignTransaction.js +1 -86
- package/reactjs/hooks/useSignTransaction.mjs +59 -59
- package/reactjs/hooks/useSuiConnect.js +1 -86
- package/reactjs/hooks/useSuiConnect.mjs +52 -70
- package/reactjs/hooks/validation/index.js +1 -10
- package/reactjs/hooks/validation/index.mjs +8 -8
- package/reactjs/hooks/validation/useAmountSchema.js +1 -32
- package/reactjs/hooks/validation/useAmountSchema.mjs +8 -11
- package/reactjs/hooks/validation/useSecondAmountSchema.js +1 -26
- package/reactjs/hooks/validation/useSecondAmountSchema.mjs +5 -6
- package/reactjs/hooks/validation/useTestHasEnoughFunds.js +1 -37
- package/reactjs/hooks/validation/useTestHasEnoughFunds.mjs +20 -29
- package/reactjs/hooks/validation/useTestIsConnected.js +1 -27
- package/reactjs/hooks/validation/useTestIsConnected.mjs +13 -19
- package/reactjs/index.js +1 -190
- package/reactjs/index.mjs +154 -154
- package/reactjs/init/index.js +1 -5
- package/reactjs/init/index.mjs +3 -3
- package/reactjs/init/init.d.ts +1 -0
- package/reactjs/init/init.js +1 -139
- package/reactjs/init/init.mjs +59 -72
- package/reactjs/queries/index.js +1 -17
- package/reactjs/queries/index.mjs +15 -15
- package/reactjs/queries/useCheckAccount.query.js +1 -39
- package/reactjs/queries/useCheckAccount.query.mjs +29 -33
- package/reactjs/queries/useGetAllTokens.query.js +1 -35
- package/reactjs/queries/useGetAllTokens.query.mjs +26 -30
- package/reactjs/queries/useGetChains.query.js +1 -34
- package/reactjs/queries/useGetChains.query.mjs +26 -28
- package/reactjs/queries/useGetHistory.query.d.ts +1 -1
- package/reactjs/queries/useGetHistory.query.js +1 -68
- package/reactjs/queries/useGetHistory.query.mjs +55 -58
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +1 -1
- package/reactjs/queries/useGetMvxTokensBalances.query.js +1 -71
- package/reactjs/queries/useGetMvxTokensBalances.query.mjs +40 -53
- package/reactjs/queries/useGetNonMvxTokensBalances.query.d.ts +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -81
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +51 -59
- package/reactjs/queries/useGetRate.mutation.js +1 -18
- package/reactjs/queries/useGetRate.mutation.mjs +12 -15
- package/reactjs/reexports.js +1 -48
- package/reactjs/reexports.mjs +13 -13
- package/reactjs/utils/delay.js +1 -6
- package/reactjs/utils/delay.mjs +3 -3
- package/reactjs/utils/formatAmount.js +1 -23
- package/reactjs/utils/formatAmount.mjs +16 -17
- package/reactjs/utils/getCleanStringAmount.js +1 -11
- package/reactjs/utils/getCleanStringAmount.mjs +6 -8
- package/reactjs/utils/getCompletePathname.js +1 -5
- package/reactjs/utils/getCompletePathname.mjs +3 -3
- package/reactjs/utils/getInitialTokens.js +1 -12
- package/reactjs/utils/getInitialTokens.mjs +6 -7
- package/reactjs/utils/hasEnoughFunds.js +1 -19
- package/reactjs/utils/hasEnoughFunds.mjs +11 -14
- package/reactjs/utils/index.js +1 -26
- package/reactjs/utils/index.mjs +24 -24
- package/reactjs/utils/isStringFloat.js +1 -21
- package/reactjs/utils/isStringFloat.mjs +11 -18
- package/reactjs/utils/mxClsx.js +1 -8
- package/reactjs/utils/mxClsx.mjs +4 -6
- package/reactjs/utils/pipe.js +1 -25
- package/reactjs/utils/pipe.mjs +13 -17
- package/reactjs/utils/removeCommas.js +1 -6
- package/reactjs/utils/removeCommas.mjs +2 -4
- package/reactjs/utils/roundAmount.js +1 -40
- package/reactjs/utils/roundAmount.mjs +16 -36
- package/reactjs/utils/testNumber.js +1 -4
- package/reactjs/utils/testNumber.mjs +2 -2
- package/store/inMemoryStore.js +1 -39
- package/store/inMemoryStore.mjs +17 -21
- package/style.css +1 -2274
- package/types/chainType.js +1 -11
- package/types/chainType.mjs +2 -9
- package/types/errors.d.ts +3 -0
- package/types/errors.js +2 -0
- package/types/errors.mjs +8 -0
- package/types/providerType.js +1 -9
- package/types/providerType.mjs +2 -7
- package/types/transaction.d.ts +2 -0
- package/all-networks-EJIVYZ_i.mjs +0 -4
- package/all-networks-NYACMyeN.js +0 -4
- package/default-BYtXv70Z.mjs +0 -4
- package/default-H3AbmzFV.js +0 -4
- package/reactjs/hooks/useSignTransaction.d.ts +0 -511
|
@@ -1,674 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const faSpinner = require("@fortawesome/free-solid-svg-icons/faSpinner");
|
|
6
|
-
const reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
7
|
-
const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
|
|
8
|
-
const react = require("@reown/appkit/react");
|
|
9
|
-
const core = require("@wagmi/core");
|
|
10
|
-
const debounce = require("lodash/debounce");
|
|
11
|
-
const React = require("react");
|
|
12
|
-
const reactToastify = require("react-toastify");
|
|
13
|
-
const reactjs_components_BridgeForm_hooks_useBridgeTokenSelection = require("./hooks/useBridgeTokenSelection.js");
|
|
14
|
-
const reactjs_components_BridgeForm_utils_bridgeFormHelpers = require("./utils/bridgeFormHelpers.js");
|
|
15
|
-
const constants_index = require("../../../constants/index.js");
|
|
16
|
-
const helpers_getApiURL = require("../../../helpers/getApiURL.js");
|
|
17
|
-
const types_chainType = require("../../../types/chainType.js");
|
|
18
|
-
const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
|
|
19
|
-
const reactjs_helpers_resolveBridgeApiChainId = require("../../helpers/resolveBridgeApiChainId.js");
|
|
20
|
-
const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
|
|
21
|
-
const reactjs_hooks_useBridgeApiChainId = require("../../hooks/useBridgeApiChainId.js");
|
|
22
|
-
const reactjs_hooks_useBridgeFormik = require("../../hooks/useBridgeFormik.js");
|
|
23
|
-
const reactjs_hooks_useFetchBridgeData = require("../../hooks/useFetchBridgeData.js");
|
|
24
|
-
const reactjs_hooks_useGetChainId = require("../../hooks/useGetChainId.js");
|
|
25
|
-
const reactjs_hooks_useSendTransactions = require("../../hooks/useSendTransactions.js");
|
|
26
|
-
const reactjs_hooks_useSignTransaction = require("../../hooks/useSignTransaction.js");
|
|
27
|
-
const reactjs_queries_useGetHistory_query = require("../../queries/useGetHistory.query.js");
|
|
28
|
-
const reactjs_queries_useGetRate_mutation = require("../../queries/useGetRate.mutation.js");
|
|
29
|
-
const reactjs_utils_mxClsx = require("../../utils/mxClsx.js");
|
|
30
|
-
const reactjs_components_AmountCard_AmountCard = require("../AmountCard/AmountCard.js");
|
|
31
|
-
const reactjs_components_AmountInput_AmountInput = require("../AmountInput/AmountInput.js");
|
|
32
|
-
const reactjs_components_base_MxButton_MxButton = require("../base/MxButton/MxButton.js");
|
|
33
|
-
require("../base/MxCard/MxCard.js");
|
|
34
|
-
require("../base/MxLink/MxLink.js");
|
|
35
|
-
require("../base/MxSearch/MxSearch.js");
|
|
36
|
-
require("@fortawesome/free-solid-svg-icons/faClose");
|
|
37
|
-
require("@headlessui/react");
|
|
38
|
-
require("react-dom");
|
|
39
|
-
require("react-popper");
|
|
40
|
-
require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");
|
|
41
|
-
require("../../constants/index.js");
|
|
42
|
-
const reactjs_components_BridgeHistory_BridgeHistory = require("../BridgeHistory/BridgeHistory.js");
|
|
43
|
-
const reactjs_components_Connect_BridgeConnectButton = require("../Connect/BridgeConnectButton.js");
|
|
44
|
-
require("wagmi");
|
|
45
|
-
const reactjs_components_Connect_MvxConnectButton = require("../Connect/MvxConnectButton.js");
|
|
46
|
-
const reactjs_components_Connect_BridgeAccountDisplay = require("../Connect/BridgeAccountDisplay.js");
|
|
47
|
-
const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAccountDisplay.js");
|
|
48
|
-
require("@reown/appkit-controllers");
|
|
49
|
-
const reactjs_components_ToggleDirection_ToggleDirection = require("../ToggleDirection/ToggleDirection.js");
|
|
50
|
-
const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
|
|
51
|
-
let fetchRateInterval;
|
|
52
|
-
const Deposit = ({
|
|
53
|
-
mvxChainId,
|
|
54
|
-
mvxAddress,
|
|
55
|
-
username,
|
|
56
|
-
callbackRoute = "/",
|
|
57
|
-
firstTokenIdentifier,
|
|
58
|
-
secondTokenIdentifier,
|
|
59
|
-
firstTokenAmount,
|
|
60
|
-
secondTokenAmount,
|
|
61
|
-
refetchTrigger,
|
|
62
|
-
showHistory,
|
|
63
|
-
forcedDestinationTokenSymbol,
|
|
64
|
-
onSuccessfullySentTransaction,
|
|
65
|
-
onFailedSentTransaction,
|
|
66
|
-
onHistoryClose,
|
|
67
|
-
onMvxConnect,
|
|
68
|
-
onMvxDisconnect,
|
|
69
|
-
onNavigate,
|
|
70
|
-
onChangeDirection
|
|
71
|
-
}) => {
|
|
72
|
-
var _a, _b;
|
|
73
|
-
const ref = React.useRef(null);
|
|
74
|
-
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = React.useState(false);
|
|
75
|
-
const [pendingSigning, setPendingSigning] = React.useState(false);
|
|
76
|
-
const [forceRefetchRate, setForceRefetchRate] = React.useState(1);
|
|
77
|
-
const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
|
|
78
|
-
const account = reactjs_hooks_useAccount.useAccount();
|
|
79
|
-
const { switchNetwork } = react.useAppKitNetwork();
|
|
80
|
-
const {
|
|
81
|
-
config,
|
|
82
|
-
options,
|
|
83
|
-
supportedChains: sdkChains,
|
|
84
|
-
nativeAuthToken,
|
|
85
|
-
bridgeOnly
|
|
86
|
-
} = reactjs_context_useWeb3App.useWeb3App();
|
|
87
|
-
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
88
|
-
const bridgeApiChainId = reactjs_hooks_useBridgeApiChainId.useBridgeApiChainId();
|
|
89
|
-
const {
|
|
90
|
-
evmTokensWithBalances,
|
|
91
|
-
mvxTokensWithBalances,
|
|
92
|
-
isTokensLoading: tokensLoading,
|
|
93
|
-
isLoadingEvmTokensBalances,
|
|
94
|
-
isLoadingMvxTokensBalances,
|
|
95
|
-
chains = [],
|
|
96
|
-
isChainsLoading
|
|
97
|
-
} = reactjs_hooks_useFetchBridgeData.useFetchBridgeData({
|
|
98
|
-
refetchTrigger,
|
|
99
|
-
mvxAddress,
|
|
100
|
-
mvxApiURL: options.mvxApiURL
|
|
101
|
-
});
|
|
102
|
-
const isTokensLoading = tokensLoading || isLoadingEvmTokensBalances || isLoadingMvxTokensBalances || isChainsLoading;
|
|
103
|
-
const activeChain = React.useMemo(() => {
|
|
104
|
-
return sdkChains.find((chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.id, chainId));
|
|
105
|
-
}, [chainId, sdkChains]);
|
|
106
|
-
const mvxChain = React.useMemo(() => {
|
|
107
|
-
return chains.find(
|
|
108
|
-
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
109
|
-
);
|
|
110
|
-
}, [chainId, chains]);
|
|
111
|
-
const { evm, solana, bitcoin, sui } = reactjs_hooks_useSignTransaction.useSignTransaction();
|
|
112
|
-
const sendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions();
|
|
113
|
-
const {
|
|
114
|
-
mutate: getRate,
|
|
115
|
-
data: rate,
|
|
116
|
-
isPending: isPendingRate,
|
|
117
|
-
error: rateError
|
|
118
|
-
} = reactjs_queries_useGetRate_mutation.useGetRateMutation();
|
|
119
|
-
const rateValidationError = ((_a = rateError == null ? void 0 : rateError.response) == null ? void 0 : _a.status) === 400 ? (_b = rateError == null ? void 0 : rateError.response) == null ? void 0 : _b.data.message : void 0;
|
|
120
|
-
const handleSwitchNetwork = React.useCallback(
|
|
121
|
-
(chain) => {
|
|
122
|
-
const sdkChain = sdkChains.find(
|
|
123
|
-
(c) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(c.id, chain.id)
|
|
124
|
-
);
|
|
125
|
-
if (sdkChain) {
|
|
126
|
-
switchNetwork(sdkChain);
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
[sdkChains, switchNetwork]
|
|
130
|
-
);
|
|
131
|
-
const {
|
|
132
|
-
firstToken,
|
|
133
|
-
secondToken,
|
|
134
|
-
fromOptions,
|
|
135
|
-
toOptions,
|
|
136
|
-
selectedChainOption,
|
|
137
|
-
onChangeFirstSelect,
|
|
138
|
-
onChangeSecondSelect,
|
|
139
|
-
handleChangeDirection: handleTokenChangeDirection
|
|
140
|
-
} = reactjs_components_BridgeForm_hooks_useBridgeTokenSelection.useBridgeTokenSelection({
|
|
141
|
-
chains,
|
|
142
|
-
activeChain,
|
|
143
|
-
sdkChains,
|
|
144
|
-
switchNetwork: handleSwitchNetwork,
|
|
145
|
-
fromTokens: evmTokensWithBalances,
|
|
146
|
-
toTokens: mvxTokensWithBalances,
|
|
147
|
-
firstTokenIdentifier,
|
|
148
|
-
secondTokenIdentifier,
|
|
149
|
-
forcedDestinationTokenSymbol,
|
|
150
|
-
isTokensLoading,
|
|
151
|
-
callbackRoute,
|
|
152
|
-
onNavigate
|
|
153
|
-
});
|
|
154
|
-
const isFirstTokenMvx = React.useMemo(() => {
|
|
155
|
-
return firstToken ? constants_index.MVX_CHAIN_IDS.includes(firstToken.chainId.toString()) : false;
|
|
156
|
-
}, [firstToken == null ? void 0 : firstToken.chainId]);
|
|
157
|
-
const isSecondTokenMvx = React.useMemo(() => {
|
|
158
|
-
return secondToken ? constants_index.MVX_CHAIN_IDS.includes(secondToken.chainId.toString()) : false;
|
|
159
|
-
}, [secondToken == null ? void 0 : secondToken.chainId]);
|
|
160
|
-
const [firstAmount, setFirstAmount] = React.useState(firstTokenAmount ?? "");
|
|
161
|
-
const [secondAmount, setSecondAmount] = React.useState(secondTokenAmount ?? "");
|
|
162
|
-
const firstTokenChain = React.useMemo(() => {
|
|
163
|
-
if (!firstToken) {
|
|
164
|
-
return selectedChainOption;
|
|
165
|
-
}
|
|
166
|
-
return chains.find(
|
|
167
|
-
(chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.chainId, firstToken.chainId)
|
|
168
|
-
) ?? selectedChainOption;
|
|
169
|
-
}, [firstToken == null ? void 0 : firstToken.chainId, chains, selectedChainOption]);
|
|
170
|
-
const bridgeFromChainId = React.useMemo(
|
|
171
|
-
() => reactjs_helpers_resolveBridgeApiChainId.toBridgeApiChainId(firstToken == null ? void 0 : firstToken.chainId) ?? bridgeApiChainId,
|
|
172
|
-
[firstToken == null ? void 0 : firstToken.chainId, bridgeApiChainId]
|
|
173
|
-
);
|
|
174
|
-
const bridgeAddress = account.address;
|
|
175
|
-
const isAuthenticated = account.isConnected && Boolean(bridgeAddress);
|
|
176
|
-
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
177
|
-
const fetchRateDebounced = React.useCallback(
|
|
178
|
-
debounce(async (amount) => {
|
|
179
|
-
if (!amount || !Number(amount) || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !bridgeFromChainId) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
getRate({
|
|
183
|
-
nativeAuthToken: nativeAuthToken ?? "",
|
|
184
|
-
body: {
|
|
185
|
-
tokenIn: firstToken.address,
|
|
186
|
-
amountIn: amount,
|
|
187
|
-
fromChainId: bridgeFromChainId,
|
|
188
|
-
tokenOut: secondToken.address,
|
|
189
|
-
toChainId: mvxChainId
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}, 500),
|
|
193
|
-
[
|
|
194
|
-
account.address,
|
|
195
|
-
bridgeFromChainId,
|
|
196
|
-
firstToken == null ? void 0 : firstToken.address,
|
|
197
|
-
secondToken == null ? void 0 : secondToken.address,
|
|
198
|
-
selectedChainOption
|
|
199
|
-
]
|
|
200
|
-
);
|
|
201
|
-
const handleOnChangeFirstAmount = React.useCallback((amount) => {
|
|
202
|
-
setFirstAmount(() => amount);
|
|
203
|
-
}, []);
|
|
204
|
-
const handleOnChangeSecondAmount = React.useCallback((amount) => {
|
|
205
|
-
setSecondAmount(() => amount);
|
|
206
|
-
}, []);
|
|
207
|
-
const handleHistoryClose = React.useCallback(() => {
|
|
208
|
-
onHistoryClose == null ? void 0 : onHistoryClose();
|
|
209
|
-
}, [onHistoryClose]);
|
|
210
|
-
const handleOnFirstMaxBtnChange = React.useCallback(() => {
|
|
211
|
-
const formattedBalance = formatAmount.formatAmount({
|
|
212
|
-
decimals: firstToken == null ? void 0 : firstToken.decimals,
|
|
213
|
-
input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
|
|
214
|
-
addCommas: false,
|
|
215
|
-
digits: 4
|
|
216
|
-
});
|
|
217
|
-
formik.setFieldValue("firstAmount", formattedBalance);
|
|
218
|
-
handleOnChangeFirstAmount(formattedBalance);
|
|
219
|
-
}, [firstToken == null ? void 0 : firstToken.balance, firstToken == null ? void 0 : firstToken.decimals, handleOnChangeFirstAmount]);
|
|
220
|
-
const onSuccess = React.useCallback(
|
|
221
|
-
async (txHashes) => {
|
|
222
|
-
handleOnChangeFirstAmount("");
|
|
223
|
-
handleOnChangeSecondAmount("");
|
|
224
|
-
reactjs_queries_useGetHistory_query.invalidateHistoryQuery();
|
|
225
|
-
reactjs_queries_useGetHistory_query.invalidateHistoryQuery();
|
|
226
|
-
onSuccessfullySentTransaction == null ? void 0 : onSuccessfullySentTransaction(txHashes);
|
|
227
|
-
},
|
|
228
|
-
[
|
|
229
|
-
handleOnChangeFirstAmount,
|
|
230
|
-
handleOnChangeSecondAmount,
|
|
231
|
-
onSuccessfullySentTransaction
|
|
232
|
-
]
|
|
233
|
-
);
|
|
234
|
-
const handleChangeDirection = () => {
|
|
235
|
-
handleTokenChangeDirection();
|
|
236
|
-
onChangeDirection();
|
|
237
|
-
};
|
|
238
|
-
React.useEffect(() => {
|
|
239
|
-
if ((selectedChainOption == null ? void 0 : selectedChainOption.chainId) !== (firstToken == null ? void 0 : firstToken.chainId)) {
|
|
240
|
-
const selectedOption = fromOptions == null ? void 0 : fromOptions.find(
|
|
241
|
-
(option) => option.chainId.toString() === (selectedChainOption == null ? void 0 : selectedChainOption.chainId)
|
|
242
|
-
);
|
|
243
|
-
if (!selectedOption) {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
onChangeFirstSelect(selectedOption);
|
|
247
|
-
}
|
|
248
|
-
}, [selectedChainOption == null ? void 0 : selectedChainOption.chainId]);
|
|
249
|
-
const onSubmit = React.useCallback(
|
|
250
|
-
async ({
|
|
251
|
-
transactions,
|
|
252
|
-
provider
|
|
253
|
-
}) => {
|
|
254
|
-
var _a2, _b2, _c;
|
|
255
|
-
const signedTransactions = [];
|
|
256
|
-
setPendingSigning(true);
|
|
257
|
-
setSigningTransactionsCount(() => transactions.length);
|
|
258
|
-
try {
|
|
259
|
-
let txIndex = -1;
|
|
260
|
-
for (const transaction of transactions) {
|
|
261
|
-
++txIndex;
|
|
262
|
-
try {
|
|
263
|
-
switch (reactjs_components_BridgeForm_utils_bridgeFormHelpers.resolveSigningChainType(transaction, firstTokenChain)) {
|
|
264
|
-
case types_chainType.ChainType.evm: {
|
|
265
|
-
const hash = await evm.signTransaction({
|
|
266
|
-
...transaction,
|
|
267
|
-
value: BigInt(transaction.value),
|
|
268
|
-
gas: BigInt(transaction.gasLimit),
|
|
269
|
-
account: bridgeAddress
|
|
270
|
-
});
|
|
271
|
-
if (!hash) {
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
signedTransactions.push({
|
|
275
|
-
...transaction,
|
|
276
|
-
txHash: hash
|
|
277
|
-
});
|
|
278
|
-
if (txIndex === transactions.length - 1 || !hash) {
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
const transactionReceipt = await core.waitForTransactionReceipt(
|
|
282
|
-
config,
|
|
283
|
-
{
|
|
284
|
-
confirmations: 1,
|
|
285
|
-
hash
|
|
286
|
-
}
|
|
287
|
-
);
|
|
288
|
-
console.info({
|
|
289
|
-
transactionReceipt,
|
|
290
|
-
hash
|
|
291
|
-
});
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
case types_chainType.ChainType.sol:
|
|
295
|
-
if (!transaction.instructions || !transaction.feePayer) {
|
|
296
|
-
break;
|
|
297
|
-
}
|
|
298
|
-
const txHash = await solana.signTransaction({
|
|
299
|
-
feePayer: transaction.feePayer,
|
|
300
|
-
instructions: transaction.instructions,
|
|
301
|
-
recentBlockhash: transaction.recentBlockhash
|
|
302
|
-
});
|
|
303
|
-
if (!txHash) {
|
|
304
|
-
break;
|
|
305
|
-
}
|
|
306
|
-
signedTransactions.push({
|
|
307
|
-
...transaction,
|
|
308
|
-
txHash
|
|
309
|
-
});
|
|
310
|
-
break;
|
|
311
|
-
case types_chainType.ChainType.btc:
|
|
312
|
-
if (!transaction.bitcoinParams) {
|
|
313
|
-
console.error("No bitcoin params");
|
|
314
|
-
break;
|
|
315
|
-
}
|
|
316
|
-
const psbt = await bitcoin.signTransaction(
|
|
317
|
-
transaction.bitcoinParams
|
|
318
|
-
);
|
|
319
|
-
signedTransactions.push({
|
|
320
|
-
...transaction,
|
|
321
|
-
txHash: psbt
|
|
322
|
-
});
|
|
323
|
-
break;
|
|
324
|
-
case types_chainType.ChainType.sui: {
|
|
325
|
-
const serializedTx = (_a2 = transaction.suiParams) == null ? void 0 : _a2.transactionBytes;
|
|
326
|
-
const sender = (_b2 = transaction.suiParams) == null ? void 0 : _b2.sender;
|
|
327
|
-
if (!serializedTx || !sender) {
|
|
328
|
-
console.error("No Sui transaction bytes or sender address");
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
const signature = await sui.signTransaction({
|
|
332
|
-
transaction: serializedTx,
|
|
333
|
-
address: sender
|
|
334
|
-
});
|
|
335
|
-
if (!signature) {
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
signedTransactions.push({
|
|
339
|
-
...transaction,
|
|
340
|
-
suiParams: {
|
|
341
|
-
...transaction.suiParams,
|
|
342
|
-
signature
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
default:
|
|
348
|
-
reactToastify.toast.error("Provider not supported");
|
|
349
|
-
setPendingSigning(false);
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
setSigningTransactionsCount(
|
|
353
|
-
() => transactions.length - 1 - txIndex
|
|
354
|
-
);
|
|
355
|
-
} catch (e) {
|
|
356
|
-
reactToastify.toast.dismiss();
|
|
357
|
-
reactToastify.toast.error("Transaction aborted");
|
|
358
|
-
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
|
|
359
|
-
setPendingSigning(false);
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
const { data: batch } = await sendTransactions({
|
|
364
|
-
transactions: signedTransactions,
|
|
365
|
-
provider,
|
|
366
|
-
url: helpers_getApiURL.getApiURL() ?? "",
|
|
367
|
-
token: nativeAuthToken ?? ""
|
|
368
|
-
});
|
|
369
|
-
const apiHashes = ((_c = batch.transactions) == null ? void 0 : _c.map((tx) => tx.txHash).filter((h) => Boolean(h))) ?? [];
|
|
370
|
-
const localHashes = signedTransactions.map((tx) => tx.txHash).filter((h) => Boolean(h));
|
|
371
|
-
const txHashes = apiHashes.length > 0 ? apiHashes : localHashes.length > 0 ? localHashes : batch.batchId ? [batch.batchId] : [];
|
|
372
|
-
onSuccess(txHashes);
|
|
373
|
-
setPendingSigning(false);
|
|
374
|
-
} catch (e) {
|
|
375
|
-
console.error(e);
|
|
376
|
-
reactToastify.toast.dismiss();
|
|
377
|
-
reactToastify.toast.error("Transaction cancelled");
|
|
378
|
-
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction cancelled");
|
|
379
|
-
setPendingSigning(false);
|
|
380
|
-
setSigningTransactionsCount(0);
|
|
381
|
-
resetSwapForm();
|
|
382
|
-
handleOnChangeFirstAmount("");
|
|
383
|
-
handleOnChangeSecondAmount("");
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
[
|
|
387
|
-
firstTokenChain == null ? void 0 : firstTokenChain.chainType,
|
|
388
|
-
bridgeAddress,
|
|
389
|
-
config,
|
|
390
|
-
handleOnChangeFirstAmount,
|
|
391
|
-
handleOnChangeSecondAmount,
|
|
392
|
-
nativeAuthToken,
|
|
393
|
-
onSuccess,
|
|
394
|
-
sendTransactions,
|
|
395
|
-
bitcoin.signTransaction,
|
|
396
|
-
evm.signTransaction,
|
|
397
|
-
solana.signTransaction,
|
|
398
|
-
sui.signTransaction
|
|
399
|
-
]
|
|
400
|
-
);
|
|
401
|
-
const {
|
|
402
|
-
formik,
|
|
403
|
-
firstAmountError,
|
|
404
|
-
secondAmountError,
|
|
405
|
-
fromChainError,
|
|
406
|
-
handleBlur,
|
|
407
|
-
handleChange,
|
|
408
|
-
handleSubmit,
|
|
409
|
-
resetSwapForm
|
|
410
|
-
} = reactjs_hooks_useBridgeFormik.useBridgeFormik({
|
|
411
|
-
isMvxConnected: Boolean(mvxAddress),
|
|
412
|
-
rate,
|
|
413
|
-
sender: account.address ?? "",
|
|
414
|
-
receiver: mvxAddress ?? "",
|
|
415
|
-
firstToken,
|
|
416
|
-
firstAmount,
|
|
417
|
-
fromChainId: bridgeFromChainId,
|
|
418
|
-
toChainId: mvxChainId,
|
|
419
|
-
secondToken,
|
|
420
|
-
secondAmount,
|
|
421
|
-
setForceRefetchRate,
|
|
422
|
-
onSubmit
|
|
423
|
-
});
|
|
424
|
-
const hasError = Boolean(
|
|
425
|
-
firstAmountError || secondAmountError || fromChainError || rateValidationError
|
|
426
|
-
);
|
|
427
|
-
const amountErrorFirstInput = React.useMemo(() => {
|
|
428
|
-
return firstAmount !== "" ? rateValidationError ?? firstAmountError : void 0;
|
|
429
|
-
}, [firstAmountError, firstAmount, rateValidationError]);
|
|
430
|
-
const amountErrorSecondInput = React.useMemo(() => {
|
|
431
|
-
return secondAmount !== "" ? fromChainError ?? secondAmountError : void 0;
|
|
432
|
-
}, [fromChainError, secondAmountError, secondAmount]);
|
|
433
|
-
React.useEffect(() => {
|
|
434
|
-
if (!firstAmount) {
|
|
435
|
-
setSecondAmount("");
|
|
436
|
-
}
|
|
437
|
-
fetchRateDebounced(firstAmount);
|
|
438
|
-
if (fetchRateInterval) {
|
|
439
|
-
clearInterval(fetchRateInterval);
|
|
440
|
-
}
|
|
441
|
-
fetchRateInterval = setInterval(() => {
|
|
442
|
-
fetchRateDebounced(firstAmount);
|
|
443
|
-
}, 50 * 1e3);
|
|
444
|
-
return () => clearInterval(fetchRateInterval);
|
|
445
|
-
}, [firstAmount, forceRefetchRate, fetchRateDebounced]);
|
|
446
|
-
React.useEffect(() => {
|
|
447
|
-
if (!(rate == null ? void 0 : rate.amountOut)) {
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, rate.amountOut);
|
|
451
|
-
setSecondAmount(rate.amountOut);
|
|
452
|
-
}, [rate == null ? void 0 : rate.amountOut]);
|
|
453
|
-
React.useEffect(() => {
|
|
454
|
-
if (rateValidationError) {
|
|
455
|
-
formik.setFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, "0");
|
|
456
|
-
setSecondAmount("0");
|
|
457
|
-
}
|
|
458
|
-
}, [rateValidationError]);
|
|
459
|
-
React.useEffect(() => {
|
|
460
|
-
if (firstTokenAmount) {
|
|
461
|
-
formik.setFieldValue(
|
|
462
|
-
reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount,
|
|
463
|
-
firstTokenAmount
|
|
464
|
-
);
|
|
465
|
-
handleOnChangeFirstAmount(firstTokenAmount);
|
|
466
|
-
}
|
|
467
|
-
}, []);
|
|
468
|
-
React.useEffect(() => {
|
|
469
|
-
if (secondTokenAmount) {
|
|
470
|
-
formik.setFieldValue(
|
|
471
|
-
reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount,
|
|
472
|
-
secondTokenAmount
|
|
473
|
-
);
|
|
474
|
-
handleOnChangeSecondAmount(secondTokenAmount);
|
|
475
|
-
}
|
|
476
|
-
}, [secondTokenAmount]);
|
|
477
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
478
|
-
"form",
|
|
479
|
-
{
|
|
480
|
-
ref,
|
|
481
|
-
noValidate: true,
|
|
482
|
-
className: "liq-flex liq-flex-col liq-gap-1 liq-relative",
|
|
483
|
-
autoComplete: "off",
|
|
484
|
-
onSubmit: handleSubmit,
|
|
485
|
-
children: [
|
|
486
|
-
showHistory && /* @__PURE__ */ jsxRuntime.jsx(reactjs_components_BridgeHistory_BridgeHistory.BridgeHistory, { mvxAddress, onClose: handleHistoryClose }),
|
|
487
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
488
|
-
reactjs_components_AmountCard_AmountCard.AmountCard,
|
|
489
|
-
{
|
|
490
|
-
className: reactjs_utils_mxClsx.mxClsx(
|
|
491
|
-
"liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
|
|
492
|
-
{
|
|
493
|
-
"liq-pointer-events-none": isTokenSelectorVisible,
|
|
494
|
-
"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80": !isTokenSelectorVisible
|
|
495
|
-
}
|
|
496
|
-
),
|
|
497
|
-
children: [
|
|
498
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
499
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "From" }),
|
|
500
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
501
|
-
reactjs_components_Connect_BridgeAccountDisplay.BridgeAccountDisplay,
|
|
502
|
-
{
|
|
503
|
-
disabled: isPendingRate,
|
|
504
|
-
activeChain: firstTokenChain
|
|
505
|
-
}
|
|
506
|
-
)
|
|
507
|
-
] }),
|
|
508
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
509
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
510
|
-
reactjs_components_AmountInput_AmountInput.AmountInput,
|
|
511
|
-
{
|
|
512
|
-
inputName: "firstAmount",
|
|
513
|
-
inputValue: formik.values.firstAmount,
|
|
514
|
-
amountError: amountErrorFirstInput,
|
|
515
|
-
disabled: false,
|
|
516
|
-
onInputDebounceChange: handleOnChangeFirstAmount,
|
|
517
|
-
onInputChange: handleChange,
|
|
518
|
-
onBlur: handleBlur
|
|
519
|
-
}
|
|
520
|
-
),
|
|
521
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
522
|
-
reactjs_components_TokenSelector_TokenSelector.TokenSelector,
|
|
523
|
-
{
|
|
524
|
-
name: "firstToken",
|
|
525
|
-
disabled: isPendingRate,
|
|
526
|
-
options: fromOptions,
|
|
527
|
-
areOptionsLoading: isTokensLoading,
|
|
528
|
-
isMvxSelector: isFirstTokenMvx,
|
|
529
|
-
isDestination: false,
|
|
530
|
-
color: "neutral-850",
|
|
531
|
-
onChange: onChangeFirstSelect,
|
|
532
|
-
onBlur: handleBlur,
|
|
533
|
-
onMaxBtnClick: handleOnFirstMaxBtnChange,
|
|
534
|
-
selectedOption: firstToken,
|
|
535
|
-
onTokenSelectorDisplay: (visible) => setIsTokenSelectorVisible(visible)
|
|
536
|
-
}
|
|
537
|
-
)
|
|
538
|
-
] })
|
|
539
|
-
]
|
|
540
|
-
}
|
|
541
|
-
),
|
|
542
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: bridgeOnly && /* @__PURE__ */ jsxRuntime.jsx(reactjs_components_ToggleDirection_ToggleDirection.ToggleDirection, { onChangeDirection: handleChangeDirection }) }),
|
|
543
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
544
|
-
reactjs_components_AmountCard_AmountCard.AmountCard,
|
|
545
|
-
{
|
|
546
|
-
className: reactjs_utils_mxClsx.mxClsx(
|
|
547
|
-
"liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
|
|
548
|
-
{
|
|
549
|
-
"liq-pointer-events-none": isTokenSelectorVisible
|
|
550
|
-
}
|
|
551
|
-
),
|
|
552
|
-
children: [
|
|
553
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
|
|
554
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "To" }),
|
|
555
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
556
|
-
reactjs_components_Connect_MvxAccountDisplay.MvxAccountDisplay,
|
|
557
|
-
{
|
|
558
|
-
accountAddress: mvxAddress,
|
|
559
|
-
chainIcon: (mvxChain == null ? void 0 : mvxChain.pngUrl) ?? "",
|
|
560
|
-
username,
|
|
561
|
-
accountExplorerUrl: `${options.mvxExplorerAddress}/accounts/${mvxAddress}`,
|
|
562
|
-
showTag: true,
|
|
563
|
-
onDisconnect: onMvxDisconnect,
|
|
564
|
-
onConnect: onMvxConnect
|
|
565
|
-
}
|
|
566
|
-
)
|
|
567
|
-
] }),
|
|
568
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
|
|
569
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
-
reactjs_components_AmountInput_AmountInput.AmountInput,
|
|
571
|
-
{
|
|
572
|
-
inputName: "secondAmount",
|
|
573
|
-
inputValue: formik.values.secondAmount,
|
|
574
|
-
amountError: amountErrorSecondInput,
|
|
575
|
-
disabled: false,
|
|
576
|
-
onInputDebounceChange: handleOnChangeSecondAmount,
|
|
577
|
-
onInputChange: handleChange,
|
|
578
|
-
onBlur: handleBlur
|
|
579
|
-
}
|
|
580
|
-
),
|
|
581
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
582
|
-
reactjs_components_TokenSelector_TokenSelector.TokenSelector,
|
|
583
|
-
{
|
|
584
|
-
name: "secondToken",
|
|
585
|
-
disabled: isPendingRate,
|
|
586
|
-
omitDisableClass: true,
|
|
587
|
-
options: toOptions,
|
|
588
|
-
areOptionsLoading: isTokensLoading,
|
|
589
|
-
isMvxSelector: isSecondTokenMvx,
|
|
590
|
-
color: "neutral-850",
|
|
591
|
-
onChange: onChangeSecondSelect,
|
|
592
|
-
onBlur: handleBlur,
|
|
593
|
-
selectedOption: secondToken
|
|
594
|
-
}
|
|
595
|
-
)
|
|
596
|
-
] })
|
|
597
|
-
]
|
|
598
|
-
}
|
|
599
|
-
),
|
|
600
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-items-center liq-justify-center", children: [
|
|
601
|
-
!mvxAddress && /* @__PURE__ */ jsxRuntime.jsx(
|
|
602
|
-
reactjs_components_Connect_MvxConnectButton.MvxConnectButton,
|
|
603
|
-
{
|
|
604
|
-
mvxAccountAddress: mvxAddress,
|
|
605
|
-
icon: (mvxChain == null ? void 0 : mvxChain.pngUrl) ?? "",
|
|
606
|
-
onClick: onMvxConnect
|
|
607
|
-
}
|
|
608
|
-
),
|
|
609
|
-
mvxAddress && !isAuthenticated && /* @__PURE__ */ jsxRuntime.jsx(
|
|
610
|
-
reactjs_components_Connect_BridgeConnectButton.BridgeConnectButton,
|
|
611
|
-
{
|
|
612
|
-
className: "liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",
|
|
613
|
-
disabled: isPendingRate,
|
|
614
|
-
activeChain: firstTokenChain
|
|
615
|
-
}
|
|
616
|
-
),
|
|
617
|
-
mvxAddress && isAuthenticated && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
618
|
-
reactjs_components_base_MxButton_MxButton.MxButton,
|
|
619
|
-
{
|
|
620
|
-
type: "submit",
|
|
621
|
-
variant: "neutral-850",
|
|
622
|
-
className: "liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",
|
|
623
|
-
disabled: !hasAmounts || isPendingRate || !mvxAddress || !account.address || hasError || pendingSigning,
|
|
624
|
-
children: [
|
|
625
|
-
hasAmounts && !pendingSigning && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
626
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "Deposit on " }),
|
|
627
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
628
|
-
"img",
|
|
629
|
-
{
|
|
630
|
-
src: (mvxChain == null ? void 0 : mvxChain.pngUrl) ?? "",
|
|
631
|
-
alt: "",
|
|
632
|
-
className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
633
|
-
}
|
|
634
|
-
),
|
|
635
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "MultiversX" })
|
|
636
|
-
] }),
|
|
637
|
-
!hasAmounts && !pendingSigning && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "liq-text-neutral-100", children: "Enter amount" }),
|
|
638
|
-
pendingSigning && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
|
|
639
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
640
|
-
reactFontawesome.FontAwesomeIcon,
|
|
641
|
-
{
|
|
642
|
-
icon: faSpinner.faSpinner,
|
|
643
|
-
spin: true,
|
|
644
|
-
className: "liq-mx-1 liq-flex liq-items-center"
|
|
645
|
-
}
|
|
646
|
-
),
|
|
647
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "Depositing on" }),
|
|
648
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
649
|
-
"img",
|
|
650
|
-
{
|
|
651
|
-
src: (mvxChain == null ? void 0 : mvxChain.pngUrl) ?? "",
|
|
652
|
-
alt: "",
|
|
653
|
-
className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
|
|
654
|
-
}
|
|
655
|
-
),
|
|
656
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { children: "MultiversX" })
|
|
657
|
-
] })
|
|
658
|
-
]
|
|
659
|
-
}
|
|
660
|
-
)
|
|
661
|
-
] }),
|
|
662
|
-
account.address && siginingTransactionsCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
663
|
-
"You will be asked to sign ",
|
|
664
|
-
siginingTransactionsCount,
|
|
665
|
-
" ",
|
|
666
|
-
siginingTransactionsCount > 1 ? "transactions" : "transaction",
|
|
667
|
-
" ",
|
|
668
|
-
"on your wallet"
|
|
669
|
-
] }) })
|
|
670
|
-
]
|
|
671
|
-
}
|
|
672
|
-
) });
|
|
673
|
-
};
|
|
674
|
-
exports.Deposit = Deposit;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),js=require("@fortawesome/free-solid-svg-icons/faSpinner"),Is=require("@fortawesome/react-fontawesome"),Cs=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),Bs=require("@reown/appkit/react"),vs=require("@wagmi/core"),ys=require("lodash/debounce"),t=require("react"),k=require("react-toastify"),As=require("./hooks/useBridgeTokenSelection.js"),ks=require("./utils/bridgeFormHelpers.js"),Se=require("../../../constants/index.js"),Ss=require("../../../helpers/getApiURL.js");require("../../constants/index.js");const H=require("../../../helpers/safeImageUrl.js"),L=require("../../../types/chainType.js"),ws=require("../../context/useWeb3App.js"),T=require("../../helpers/resolveBridgeApiChainId.js"),Ns=require("../../hooks/useAccount.js"),Ms=require("../../hooks/useBridgeApiChainId.js"),S=require("../../hooks/useBridgeFormik.js"),Ds=require("../../hooks/useFetchBridgeData.js"),Fs=require("../../hooks/useGetChainId.js"),Rs=require("../../hooks/useSendTransactions.js"),Es=require("../../hooks/useSignTransaction.js"),Vs=require("../../queries/useGetHistory.query.js"),Ps=require("../../queries/useGetRate.mutation.js"),we=require("../../utils/mxClsx.js"),Ne=require("../AmountCard/AmountCard.js"),Me=require("../AmountInput/AmountInput.js"),Us=require("../base/MxButton/MxButton.js");require("../base/MxCard/MxCard.js");require("../base/MxLink/MxLink.js");require("../base/MxSearch/MxSearch.js");require("@fortawesome/free-solid-svg-icons/faClose");require("@headlessui/react");require("react-dom");require("react-popper");require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");const Hs=require("../BridgeHistory/BridgeHistory.js"),Ls=require("../Connect/BridgeConnectButton.js");require("wagmi");const Ts=require("../Connect/MvxConnectButton.js"),Os=require("../Connect/BridgeAccountDisplay.js"),Gs=require("../Connect/MvxAccountDisplay.js");require("@reown/appkit-controllers");const Ws=require("../ToggleDirection/ToggleDirection.js"),De=require("../TokenSelector/TokenSelector.js");let O;const Xs=({mvxChainId:G,mvxAddress:c,username:Fe,callbackRoute:Re="/",firstTokenIdentifier:Ee,secondTokenIdentifier:Ve,firstTokenAmount:w,secondTokenAmount:j,refetchTrigger:Pe,showHistory:Ue,forcedDestinationTokenSymbol:He,onSuccessfullySentTransaction:N,onFailedSentTransaction:f,onHistoryClose:M,onMvxConnect:re,onMvxDisconnect:Le,onNavigate:Te,onChangeDirection:Oe})=>{var je,Ie;const Ge=t.useRef(null),ae=t.useRef(void 0),[W,We]=t.useState(!1),[D,I]=t.useState(!1),[Xe,ze]=t.useState(1),[X,z]=t.useState(0),g=Ns.useAccount(),{switchNetwork:oe}=Bs.useAppKitNetwork(),ce=Vs.useInvalidateHistoryQuery(),{config:le,options:ue,supportedChains:C,nativeAuthToken:Q,bridgeOnly:Qe}=ws.useWeb3App(),$=Fs.useGetChainId(),de=Ms.useBridgeApiChainId(),{evmTokensWithBalances:$e,mvxTokensWithBalances:Ke,isTokensLoading:Ye,isLoadingEvmTokensBalances:Je,isLoadingMvxTokensBalances:Ze,chains:B=[],isChainsLoading:es}=Ds.useFetchBridgeData({refetchTrigger:Pe,mvxAddress:c,mvxApiURL:ue.mvxApiURL}),K=Ye||Je||Ze||es,ss=t.useMemo(()=>C.find(n=>T.sameBridgeApiChainId(n.id,$)),[$,C]),o=t.useMemo(()=>B.find(n=>n.chainId.toString()===G.toString()),[$,B]),{evm:me,solana:he,bitcoin:ge,sui:pe}=Es.useSignTransaction(),qe=Rs.useSendTransactions(),{mutate:ts,data:u,isPending:v,error:b}=Ps.useGetRateMutation(),y=((je=b==null?void 0:b.response)==null?void 0:je.status)===400?(Ie=b==null?void 0:b.response)==null?void 0:Ie.data.message:void 0,ns=t.useCallback(n=>{const q=C.find(l=>T.sameBridgeApiChainId(l.id,n.id));q&&oe(q)},[C,oe]),{firstToken:e,secondToken:a,fromOptions:F,toOptions:is,selectedChainOption:r,onChangeFirstSelect:fe,onChangeSecondSelect:rs,handleChangeDirection:as}=As.useBridgeTokenSelection({chains:B,activeChain:ss,sdkChains:C,switchNetwork:ns,fromTokens:$e,toTokens:Ke,firstTokenIdentifier:Ee,secondTokenIdentifier:Ve,forcedDestinationTokenSymbol:He,isTokensLoading:K,callbackRoute:Re,onNavigate:Te}),os=t.useMemo(()=>e?Se.MVX_CHAIN_IDS.includes(e.chainId.toString()):!1,[e==null?void 0:e.chainId]),cs=t.useMemo(()=>a?Se.MVX_CHAIN_IDS.includes(a.chainId.toString()):!1,[a==null?void 0:a.chainId]),[d,ls]=t.useState(w??""),[R,E]=t.useState(j??""),x=t.useMemo(()=>e?B.find(n=>T.sameBridgeApiChainId(n.chainId,e.chainId))??r:r,[e==null?void 0:e.chainId,B,r]),V=t.useMemo(()=>T.toBridgeApiChainId(e==null?void 0:e.chainId)??de,[e==null?void 0:e.chainId,de]),Y=g.address,be=g.isConnected&&!!Y,J=d!==""&&R!=="",Z=t.useCallback(ys(async n=>{!n||!Number(n)||!g.address||!(e!=null&&e.address)||!(a!=null&&a.address)||!r||!V||ts({nativeAuthToken:Q??"",body:{tokenIn:e.address,amountIn:n,fromChainId:V,tokenOut:a.address,toChainId:G}})},500),[g.address,V,e==null?void 0:e.address,a==null?void 0:a.address,r]),m=t.useCallback(n=>{ls(()=>n)},[]),_=t.useCallback(n=>{E(()=>n)},[]),us=t.useCallback(()=>{M==null||M()},[M]),ds=t.useCallback(()=>{const n=Cs.formatAmount({decimals:e==null?void 0:e.decimals,input:(e==null?void 0:e.balance)??"0",addCommas:!1,digits:4});p.setFieldValue("firstAmount",n),m(n)},[e==null?void 0:e.balance,e==null?void 0:e.decimals,m]),xe=t.useCallback(async n=>{m(""),_(""),ce(),ce(),N==null||N(n)},[m,_,N]),ms=()=>{as(),Oe()};t.useEffect(()=>{const n=ae.current;if(ae.current=r==null?void 0:r.chainId,!!n&&(r==null?void 0:r.chainId)!==(e==null?void 0:e.chainId)){const q=F==null?void 0:F.find(l=>l.chainId.toString()===(r==null?void 0:r.chainId));if(!q)return;fe(q)}},[r==null?void 0:r.chainId]);const hs=t.useCallback(async({transactions:n,provider:q})=>{var Ce,Be,ve;const l=[];I(!0),z(()=>n.length);try{let A=-1;for(const i of n){++A;try{switch(ks.resolveSigningChainType(i,x)){case L.ChainType.evm:{const h=await me.signTransaction({...i,value:BigInt(i.value),gas:BigInt(i.gasLimit),account:Y});if(!h||(l.push({...i,txHash:h}),A===n.length-1||!h))break;const U=await vs.waitForTransactionReceipt(le,{confirmations:1,hash:h});console.info({transactionReceipt:U,hash:h});break}case L.ChainType.sol:if(!i.instructions||!i.feePayer)break;const ie=await he.signTransaction({feePayer:i.feePayer,instructions:i.instructions,recentBlockhash:i.recentBlockhash});if(!ie)break;l.push({...i,txHash:ie});break;case L.ChainType.btc:if(!i.bitcoinParams){console.error("No bitcoin params");break}const _s=await ge.signTransaction(i.bitcoinParams);l.push({...i,txHash:_s});break;case L.ChainType.sui:{const h=(Ce=i.suiParams)==null?void 0:Ce.transactionBytes,U=(Be=i.suiParams)==null?void 0:Be.sender;if(!h||!U){console.error("No Sui transaction bytes or sender address");break}const ke=await pe.signTransaction({transaction:h,address:U});if(!ke)break;l.push({...i,suiParams:{...i.suiParams,signature:ke}});break}default:k.toast.error("Provider not supported"),I(!1);return}z(()=>n.length-1-A)}catch{k.toast.dismiss(),k.toast.error("Transaction aborted"),f==null||f("Transaction aborted"),I(!1);return}}const{data:ne}=await qe({transactions:l,provider:q,url:Ss.getApiURL()??"",token:Q??""}),ye=((ve=ne.transactions)==null?void 0:ve.map(i=>i.txHash).filter(i=>!!i))??[],Ae=l.map(i=>i.txHash).filter(i=>!!i),xs=ye.length>0?ye:Ae.length>0?Ae:ne.batchId?[ne.batchId]:[];xe(xs),I(!1)}catch(A){console.error(A),k.toast.dismiss(),k.toast.error("Transaction cancelled"),f==null||f("Transaction cancelled"),I(!1),z(0),ps(),m(""),_("")}},[x==null?void 0:x.chainType,Y,le,m,_,Q,xe,qe,ge.signTransaction,me.signTransaction,he.signTransaction,pe.signTransaction]),{formik:p,firstAmountError:ee,secondAmountError:se,fromChainError:te,handleBlur:P,handleChange:_e,handleSubmit:gs,resetSwapForm:ps}=S.useBridgeFormik({isMvxConnected:!!c,rate:u,sender:g.address??"",receiver:c??"",firstToken:e,firstAmount:d,fromChainId:V,toChainId:G,secondToken:a,secondAmount:R,setForceRefetchRate:ze,onSubmit:hs}),qs=!!(ee||se||te||y),fs=t.useMemo(()=>d!==""?y??ee:void 0,[ee,d,y]),bs=t.useMemo(()=>R!==""?te??se:void 0,[te,se,R]);return t.useEffect(()=>(d||E(""),Z(d),O&&clearInterval(O),O=setInterval(()=>{Z(d)},50*1e3),()=>clearInterval(O)),[d,Xe,Z]),t.useEffect(()=>{u!=null&&u.amountOut&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,u.amountOut),E(u.amountOut))},[u==null?void 0:u.amountOut]),t.useEffect(()=>{y&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,"0"),E("0"))},[y]),t.useEffect(()=>{w&&(p.setFieldValue(S.BridgeFormikValuesEnum.firstAmount,w),m(w))},[]),t.useEffect(()=>{j&&(p.setFieldValue(S.BridgeFormikValuesEnum.secondAmount,j),_(j))},[j]),s.jsx(s.Fragment,{children:s.jsxs("form",{ref:Ge,noValidate:!0,className:"liq-flex liq-flex-col liq-gap-1 liq-relative",autoComplete:"off",onSubmit:gs,children:[Ue&&s.jsx(Hs.BridgeHistory,{mvxAddress:c,onClose:us}),s.jsxs(Ne.AmountCard,{className:we.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W,"focus-within:liq-outline-neutral-700/75 hover:liq-outline-neutral-700/55 hover:focus-within:liq-outline-neutral-700/80":!W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"From"}),s.jsx(Os.BridgeAccountDisplay,{disabled:v,activeChain:x})]}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Me.AmountInput,{inputName:"firstAmount",inputValue:p.values.firstAmount,amountError:fs,disabled:!1,onInputDebounceChange:m,onInputChange:_e,onBlur:P}),s.jsx(De.TokenSelector,{name:"firstToken",disabled:v,options:F,areOptionsLoading:K,isMvxSelector:os,isDestination:!1,color:"neutral-850",onChange:fe,onBlur:P,onMaxBtnClick:ds,selectedOption:e,onTokenSelectorDisplay:n=>We(n)})]})]}),s.jsx("div",{className:"liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10",children:Qe&&s.jsx(Ws.ToggleDirection,{onChangeDirection:ms})}),s.jsxs(Ne.AmountCard,{className:we.mxClsx("liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",{"liq-pointer-events-none":W}),children:[s.jsxs("div",{className:"liq-flex liq-items-center liq-gap-1",children:[s.jsx("span",{children:"To"}),s.jsx(Gs.MvxAccountDisplay,{accountAddress:c,chainIcon:H.safeImageUrl(o==null?void 0:o.pngUrl),username:Fe,accountExplorerUrl:`${ue.mvxExplorerAddress}/accounts/${c}`,showTag:!0,onDisconnect:Le,onConnect:re})]}),s.jsxs("div",{className:"liq-flex liq-justify-between liq-gap-1",children:[s.jsx(Me.AmountInput,{inputName:"secondAmount",inputValue:p.values.secondAmount,amountError:bs,disabled:!1,onInputDebounceChange:_,onInputChange:_e,onBlur:P}),s.jsx(De.TokenSelector,{name:"secondToken",disabled:v,omitDisableClass:!0,options:is,areOptionsLoading:K,isMvxSelector:cs,color:"neutral-850",onChange:rs,onBlur:P,selectedOption:a})]})]}),s.jsxs("div",{className:"liq-flex liq-items-center liq-justify-center",children:[!c&&s.jsx(Ts.MvxConnectButton,{mvxAccountAddress:c,icon:H.safeImageUrl(o==null?void 0:o.pngUrl),onClick:re}),c&&!be&&s.jsx(Ls.BridgeConnectButton,{className:"liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",disabled:v,activeChain:x}),c&&be&&s.jsxs(Us.MxButton,{type:"submit",variant:"neutral-850",className:"liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",disabled:!J||v||!c||!g.address||qs||D,children:[J&&!D&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx("div",{children:"Deposit on "}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]}),!J&&!D&&s.jsx("span",{className:"liq-text-neutral-100",children:"Enter amount"}),D&&s.jsxs("div",{className:"liq-flex liq-justify-center liq-items-center liq-gap-2",children:[s.jsx(Is.FontAwesomeIcon,{icon:js.faSpinner,spin:!0,className:"liq-mx-1 liq-flex liq-items-center"}),s.jsx("div",{children:"Depositing on"}),s.jsx("img",{src:H.safeImageUrl(o==null?void 0:o.pngUrl),alt:"",className:"liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"}),s.jsx("div",{children:"MultiversX"})]})]})]}),g.address&&X>0&&s.jsx("div",{className:"liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm",children:s.jsxs("div",{children:["You will be asked to sign ",X," ",X>1?"transactions":"transaction"," ","on your wallet"]})})]})})};exports.Deposit=Xs;
|