@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,79 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
|
|
5
|
-
const React = require("react");
|
|
6
|
-
const reactjs_hooks_useBridgeFormik = require("../../../hooks/useBridgeFormik.js");
|
|
7
|
-
const useBridgeAmounts = ({
|
|
8
|
-
firstToken,
|
|
9
|
-
firstTokenAmount,
|
|
10
|
-
secondTokenAmount,
|
|
11
|
-
rate,
|
|
12
|
-
rateValidationError,
|
|
13
|
-
formikSetFieldValue
|
|
14
|
-
}) => {
|
|
15
|
-
const [firstAmount, setFirstAmount] = React.useState(firstTokenAmount ?? "");
|
|
16
|
-
const [secondAmount, setSecondAmount] = React.useState(secondTokenAmount ?? "");
|
|
17
|
-
const handleOnChangeFirstAmount = React.useCallback((amount) => {
|
|
18
|
-
setFirstAmount(amount);
|
|
19
|
-
}, []);
|
|
20
|
-
const handleOnChangeSecondAmount = React.useCallback((amount) => {
|
|
21
|
-
setSecondAmount(amount);
|
|
22
|
-
}, []);
|
|
23
|
-
const handleOnFirstMaxBtnChange = React.useCallback(() => {
|
|
24
|
-
const formattedBalance = formatAmount.formatAmount({
|
|
25
|
-
decimals: firstToken == null ? void 0 : firstToken.decimals,
|
|
26
|
-
input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
|
|
27
|
-
addCommas: false,
|
|
28
|
-
digits: 4
|
|
29
|
-
});
|
|
30
|
-
formikSetFieldValue("firstAmount", formattedBalance);
|
|
31
|
-
handleOnChangeFirstAmount(formattedBalance);
|
|
32
|
-
}, [
|
|
33
|
-
firstToken == null ? void 0 : firstToken.balance,
|
|
34
|
-
firstToken == null ? void 0 : firstToken.decimals,
|
|
35
|
-
formikSetFieldValue,
|
|
36
|
-
handleOnChangeFirstAmount
|
|
37
|
-
]);
|
|
38
|
-
const clearAmounts = React.useCallback(() => {
|
|
39
|
-
handleOnChangeFirstAmount("");
|
|
40
|
-
handleOnChangeSecondAmount("");
|
|
41
|
-
}, [handleOnChangeFirstAmount, handleOnChangeSecondAmount]);
|
|
42
|
-
React.useEffect(() => {
|
|
43
|
-
if (rate == null ? void 0 : rate.amountOut) {
|
|
44
|
-
formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, rate.amountOut);
|
|
45
|
-
setSecondAmount(rate.amountOut);
|
|
46
|
-
}
|
|
47
|
-
}, [rate == null ? void 0 : rate.amountOut, formikSetFieldValue]);
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
if (rateValidationError) {
|
|
50
|
-
formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount, "0");
|
|
51
|
-
setSecondAmount("0");
|
|
52
|
-
}
|
|
53
|
-
}, [rateValidationError, formikSetFieldValue]);
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
if (firstTokenAmount) {
|
|
56
|
-
formikSetFieldValue(reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount, firstTokenAmount);
|
|
57
|
-
handleOnChangeFirstAmount(firstTokenAmount);
|
|
58
|
-
}
|
|
59
|
-
}, [firstTokenAmount, formikSetFieldValue, handleOnChangeFirstAmount]);
|
|
60
|
-
React.useEffect(() => {
|
|
61
|
-
if (secondTokenAmount) {
|
|
62
|
-
formikSetFieldValue(
|
|
63
|
-
reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount,
|
|
64
|
-
secondTokenAmount
|
|
65
|
-
);
|
|
66
|
-
handleOnChangeSecondAmount(secondTokenAmount);
|
|
67
|
-
}
|
|
68
|
-
}, [secondTokenAmount, formikSetFieldValue, handleOnChangeSecondAmount]);
|
|
69
|
-
return {
|
|
70
|
-
firstAmount,
|
|
71
|
-
secondAmount,
|
|
72
|
-
handleOnChangeFirstAmount,
|
|
73
|
-
handleOnChangeSecondAmount,
|
|
74
|
-
handleOnFirstMaxBtnChange,
|
|
75
|
-
clearAmounts,
|
|
76
|
-
hasAmounts: firstAmount !== "" && secondAmount !== ""
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
exports.useBridgeAmounts = useBridgeAmounts;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount"),s=require("react"),b=require("../../../hooks/useBridgeFormik.js"),q=({firstToken:u,firstTokenAmount:t,secondTokenAmount:g,rate:a,rateValidationError:B,formikSetFieldValue:c})=>{const[h,O]=s.useState(t??""),[C,A]=s.useState(g??""),m=s.useCallback(n=>{O(n)},[]),d=s.useCallback(n=>{A(n)},[]),l=s.useCallback(()=>{const n=o.formatAmount({decimals:u==null?void 0:u.decimals,input:(u==null?void 0:u.balance)??"0",addCommas:!1,digits:4});c("firstAmount",n),m(n)},[u==null?void 0:u.balance,u==null?void 0:u.decimals,c,m]),E=s.useCallback(()=>{m(""),d("")},[m,d]);return s.useEffect(()=>{a!=null&&a.amountOut&&(c(b.BridgeFormikValuesEnum.secondAmount,a.amountOut),A(a.amountOut))},[a==null?void 0:a.amountOut,c]),s.useEffect(()=>{B&&(c(b.BridgeFormikValuesEnum.secondAmount,"0"),A("0"))},[B,c]),s.useEffect(()=>{t&&(c(b.BridgeFormikValuesEnum.firstAmount,t),m(t))},[t,c,m]),s.useEffect(()=>{g&&(c(b.BridgeFormikValuesEnum.secondAmount,g),d(g))},[g,c,d]),{firstAmount:h,secondAmount:C,handleOnChangeFirstAmount:m,handleOnChangeSecondAmount:d,handleOnFirstMaxBtnChange:l,clearAmounts:E,hasAmounts:h!==""&&C!==""}};exports.useBridgeAmounts=q;
|
|
@@ -1,78 +1,55 @@
|
|
|
1
|
-
import { formatAmount } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
2
|
-
import { useState, useCallback, useEffect } from "react";
|
|
3
|
-
import { BridgeFormikValuesEnum } from "../../../hooks/useBridgeFormik.mjs";
|
|
4
|
-
const
|
|
5
|
-
firstToken,
|
|
6
|
-
firstTokenAmount,
|
|
7
|
-
secondTokenAmount,
|
|
8
|
-
rate,
|
|
9
|
-
rateValidationError,
|
|
10
|
-
formikSetFieldValue
|
|
1
|
+
import { formatAmount as q } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
2
|
+
import { useState as x, useCallback as O, useEffect as g } from "react";
|
|
3
|
+
import { BridgeFormikValuesEnum as p } from "../../../hooks/useBridgeFormik.mjs";
|
|
4
|
+
const y = ({
|
|
5
|
+
firstToken: c,
|
|
6
|
+
firstTokenAmount: s,
|
|
7
|
+
secondTokenAmount: h,
|
|
8
|
+
rate: u,
|
|
9
|
+
rateValidationError: d,
|
|
10
|
+
formikSetFieldValue: m
|
|
11
11
|
}) => {
|
|
12
|
-
const [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}, [])
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const formattedBalance = formatAmount({
|
|
22
|
-
decimals: firstToken == null ? void 0 : firstToken.decimals,
|
|
23
|
-
input: (firstToken == null ? void 0 : firstToken.balance) ?? "0",
|
|
24
|
-
addCommas: false,
|
|
12
|
+
const [B, E] = x(s ?? ""), [b, C] = x(h ?? ""), n = O((a) => {
|
|
13
|
+
E(a);
|
|
14
|
+
}, []), A = O((a) => {
|
|
15
|
+
C(a);
|
|
16
|
+
}, []), M = O(() => {
|
|
17
|
+
const a = q({
|
|
18
|
+
decimals: c == null ? void 0 : c.decimals,
|
|
19
|
+
input: (c == null ? void 0 : c.balance) ?? "0",
|
|
20
|
+
addCommas: !1,
|
|
25
21
|
digits: 4
|
|
26
22
|
});
|
|
27
|
-
|
|
28
|
-
handleOnChangeFirstAmount(formattedBalance);
|
|
23
|
+
m("firstAmount", a), n(a);
|
|
29
24
|
}, [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
])
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}, [firstTokenAmount, formikSetFieldValue, handleOnChangeFirstAmount]);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (secondTokenAmount) {
|
|
59
|
-
formikSetFieldValue(
|
|
60
|
-
BridgeFormikValuesEnum.secondAmount,
|
|
61
|
-
secondTokenAmount
|
|
62
|
-
);
|
|
63
|
-
handleOnChangeSecondAmount(secondTokenAmount);
|
|
64
|
-
}
|
|
65
|
-
}, [secondTokenAmount, formikSetFieldValue, handleOnChangeSecondAmount]);
|
|
66
|
-
return {
|
|
67
|
-
firstAmount,
|
|
68
|
-
secondAmount,
|
|
69
|
-
handleOnChangeFirstAmount,
|
|
70
|
-
handleOnChangeSecondAmount,
|
|
71
|
-
handleOnFirstMaxBtnChange,
|
|
72
|
-
clearAmounts,
|
|
73
|
-
hasAmounts: firstAmount !== "" && secondAmount !== ""
|
|
25
|
+
c == null ? void 0 : c.balance,
|
|
26
|
+
c == null ? void 0 : c.decimals,
|
|
27
|
+
m,
|
|
28
|
+
n
|
|
29
|
+
]), j = O(() => {
|
|
30
|
+
n(""), A("");
|
|
31
|
+
}, [n, A]);
|
|
32
|
+
return g(() => {
|
|
33
|
+
u != null && u.amountOut && (m(p.secondAmount, u.amountOut), C(u.amountOut));
|
|
34
|
+
}, [u == null ? void 0 : u.amountOut, m]), g(() => {
|
|
35
|
+
d && (m(p.secondAmount, "0"), C("0"));
|
|
36
|
+
}, [d, m]), g(() => {
|
|
37
|
+
s && (m(p.firstAmount, s), n(s));
|
|
38
|
+
}, [s, m, n]), g(() => {
|
|
39
|
+
h && (m(
|
|
40
|
+
p.secondAmount,
|
|
41
|
+
h
|
|
42
|
+
), A(h));
|
|
43
|
+
}, [h, m, A]), {
|
|
44
|
+
firstAmount: B,
|
|
45
|
+
secondAmount: b,
|
|
46
|
+
handleOnChangeFirstAmount: n,
|
|
47
|
+
handleOnChangeSecondAmount: A,
|
|
48
|
+
handleOnFirstMaxBtnChange: M,
|
|
49
|
+
clearAmounts: j,
|
|
50
|
+
hasAmounts: B !== "" && b !== ""
|
|
74
51
|
};
|
|
75
52
|
};
|
|
76
53
|
export {
|
|
77
|
-
useBridgeAmounts
|
|
54
|
+
y as useBridgeAmounts
|
|
78
55
|
};
|
|
@@ -1,59 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const debounce = require("lodash/debounce");
|
|
5
|
-
const React = require("react");
|
|
6
|
-
let fetchRateInterval;
|
|
7
|
-
const useBridgeRateFetching = ({
|
|
8
|
-
firstAmount,
|
|
9
|
-
firstToken,
|
|
10
|
-
secondToken,
|
|
11
|
-
accountAddress,
|
|
12
|
-
fromChainId,
|
|
13
|
-
toChainId,
|
|
14
|
-
nativeAuthToken,
|
|
15
|
-
forceRefetchRate,
|
|
16
|
-
getRate
|
|
17
|
-
}) => {
|
|
18
|
-
const fetchRateDebounced = React.useCallback(
|
|
19
|
-
debounce(async (amount) => {
|
|
20
|
-
if (!amount || !Number(amount) || !accountAddress || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !fromChainId) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
getRate({
|
|
24
|
-
nativeAuthToken: nativeAuthToken ?? "",
|
|
25
|
-
body: {
|
|
26
|
-
tokenIn: firstToken.address,
|
|
27
|
-
amountIn: amount,
|
|
28
|
-
fromChainId,
|
|
29
|
-
tokenOut: secondToken.address,
|
|
30
|
-
toChainId
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}, 500),
|
|
34
|
-
[
|
|
35
|
-
accountAddress,
|
|
36
|
-
firstToken == null ? void 0 : firstToken.address,
|
|
37
|
-
secondToken == null ? void 0 : secondToken.address,
|
|
38
|
-
fromChainId,
|
|
39
|
-
toChainId,
|
|
40
|
-
nativeAuthToken,
|
|
41
|
-
getRate
|
|
42
|
-
]
|
|
43
|
-
);
|
|
44
|
-
React.useEffect(() => {
|
|
45
|
-
if (!firstAmount) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
fetchRateDebounced(firstAmount);
|
|
49
|
-
if (fetchRateInterval) {
|
|
50
|
-
clearInterval(fetchRateInterval);
|
|
51
|
-
}
|
|
52
|
-
fetchRateInterval = setInterval(() => {
|
|
53
|
-
fetchRateDebounced(firstAmount);
|
|
54
|
-
}, 50 * 1e3);
|
|
55
|
-
return () => clearInterval(fetchRateInterval);
|
|
56
|
-
}, [firstAmount, forceRefetchRate, fetchRateDebounced]);
|
|
57
|
-
return { fetchRateDebounced };
|
|
58
|
-
};
|
|
59
|
-
exports.useBridgeRateFetching = useBridgeRateFetching;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("lodash/debounce"),y=require("react");let l;const q=({firstAmount:r,firstToken:e,secondToken:a,accountAddress:c,fromChainId:t,toChainId:v,nativeAuthToken:d,forceRefetchRate:R,getRate:g})=>{const u=y.useCallback(I(async b=>{!b||!Number(b)||!c||!(e!=null&&e.address)||!(a!=null&&a.address)||!t||g({nativeAuthToken:d??"",body:{tokenIn:e.address,amountIn:b,fromChainId:t,tokenOut:a.address,toChainId:v}})},500),[c,e==null?void 0:e.address,a==null?void 0:a.address,t,v,d,g]);return y.useEffect(()=>{if(r)return u(r),l&&clearInterval(l),l=setInterval(()=>{u(r)},50*1e3),()=>clearInterval(l)},[r,R,u]),{fetchRateDebounced:u}};exports.useBridgeRateFetching=q;
|
|
@@ -1,58 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCallback, useEffect } from "react";
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
firstAmount,
|
|
6
|
-
firstToken,
|
|
7
|
-
secondToken,
|
|
8
|
-
accountAddress,
|
|
9
|
-
fromChainId,
|
|
10
|
-
toChainId,
|
|
11
|
-
nativeAuthToken,
|
|
12
|
-
forceRefetchRate,
|
|
13
|
-
getRate
|
|
1
|
+
import d from "lodash/debounce";
|
|
2
|
+
import { useCallback as g, useEffect as x } from "react";
|
|
3
|
+
let b;
|
|
4
|
+
const E = ({
|
|
5
|
+
firstAmount: l,
|
|
6
|
+
firstToken: a,
|
|
7
|
+
secondToken: r,
|
|
8
|
+
accountAddress: v,
|
|
9
|
+
fromChainId: e,
|
|
10
|
+
toChainId: p,
|
|
11
|
+
nativeAuthToken: I,
|
|
12
|
+
forceRefetchRate: R,
|
|
13
|
+
getRate: y
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
getRate({
|
|
21
|
-
nativeAuthToken: nativeAuthToken ?? "",
|
|
15
|
+
const u = g(
|
|
16
|
+
d(async (t) => {
|
|
17
|
+
!t || !Number(t) || !v || !(a != null && a.address) || !(r != null && r.address) || !e || y({
|
|
18
|
+
nativeAuthToken: I ?? "",
|
|
22
19
|
body: {
|
|
23
|
-
tokenIn:
|
|
24
|
-
amountIn:
|
|
25
|
-
fromChainId,
|
|
26
|
-
tokenOut:
|
|
27
|
-
toChainId
|
|
20
|
+
tokenIn: a.address,
|
|
21
|
+
amountIn: t,
|
|
22
|
+
fromChainId: e,
|
|
23
|
+
tokenOut: r.address,
|
|
24
|
+
toChainId: p
|
|
28
25
|
}
|
|
29
26
|
});
|
|
30
27
|
}, 500),
|
|
31
28
|
[
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
v,
|
|
30
|
+
a == null ? void 0 : a.address,
|
|
31
|
+
r == null ? void 0 : r.address,
|
|
32
|
+
e,
|
|
33
|
+
p,
|
|
34
|
+
I,
|
|
35
|
+
y
|
|
39
36
|
]
|
|
40
37
|
);
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
clearInterval(fetchRateInterval);
|
|
48
|
-
}
|
|
49
|
-
fetchRateInterval = setInterval(() => {
|
|
50
|
-
fetchRateDebounced(firstAmount);
|
|
51
|
-
}, 50 * 1e3);
|
|
52
|
-
return () => clearInterval(fetchRateInterval);
|
|
53
|
-
}, [firstAmount, forceRefetchRate, fetchRateDebounced]);
|
|
54
|
-
return { fetchRateDebounced };
|
|
38
|
+
return x(() => {
|
|
39
|
+
if (l)
|
|
40
|
+
return u(l), b && clearInterval(b), b = setInterval(() => {
|
|
41
|
+
u(l);
|
|
42
|
+
}, 50 * 1e3), () => clearInterval(b);
|
|
43
|
+
}, [l, R, u]), { fetchRateDebounced: u };
|
|
55
44
|
};
|
|
56
45
|
export {
|
|
57
|
-
useBridgeRateFetching
|
|
46
|
+
E as useBridgeRateFetching
|
|
58
47
|
};
|
|
@@ -1,267 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const reactjs_helpers_resolveBridgeApiChainId = require("../../../helpers/resolveBridgeApiChainId.js");
|
|
6
|
-
const reactjs_utils_getInitialTokens = require("../../../utils/getInitialTokens.js");
|
|
7
|
-
const reactjs_components_BridgeForm_utils_bridgeFormHelpers = require("../utils/bridgeFormHelpers.js");
|
|
8
|
-
const useBridgeTokenSelection = ({
|
|
9
|
-
chains,
|
|
10
|
-
firstTokenIdentifier,
|
|
11
|
-
secondTokenIdentifier,
|
|
12
|
-
fromTokens,
|
|
13
|
-
toTokens,
|
|
14
|
-
isTokensLoading,
|
|
15
|
-
activeChainId,
|
|
16
|
-
mvxChainId,
|
|
17
|
-
callbackRoute,
|
|
18
|
-
forcedDestinationTokenSymbol,
|
|
19
|
-
onNavigate,
|
|
20
|
-
switchNetwork,
|
|
21
|
-
sdkChains,
|
|
22
|
-
activeChain
|
|
23
|
-
}) => {
|
|
24
|
-
const initializedInitialTokensRef = React.useRef(false);
|
|
25
|
-
const [firstToken, setFirstToken] = React.useState();
|
|
26
|
-
const [secondToken, setSecondToken] = React.useState();
|
|
27
|
-
const fromOptions = React.useMemo(
|
|
28
|
-
() => (fromTokens == null ? void 0 : fromTokens.filter((token) => {
|
|
29
|
-
if (mvxChainId) {
|
|
30
|
-
return token.chainId.toString().toLowerCase() === mvxChainId.toString().toLowerCase();
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
}).map((token) => ({
|
|
34
|
-
...token,
|
|
35
|
-
identifier: token.address,
|
|
36
|
-
ticker: token.symbol
|
|
37
|
-
}))) ?? [],
|
|
38
|
-
[fromTokens, mvxChainId]
|
|
39
|
-
);
|
|
40
|
-
const getAvailableTokens = React.useCallback(
|
|
41
|
-
(option) => reactjs_components_BridgeForm_utils_bridgeFormHelpers.getAvailableTokens(
|
|
42
|
-
option,
|
|
43
|
-
toTokens,
|
|
44
|
-
forcedDestinationTokenSymbol
|
|
45
|
-
),
|
|
46
|
-
[toTokens, forcedDestinationTokenSymbol]
|
|
47
|
-
);
|
|
48
|
-
const toOptions = React.useMemo(() => {
|
|
49
|
-
if (!firstToken) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return (toTokens == null ? void 0 : toTokens.filter(
|
|
53
|
-
(token) => token.symbol.toLowerCase() === firstToken.symbol.toLowerCase()
|
|
54
|
-
).map((token) => ({
|
|
55
|
-
...token,
|
|
56
|
-
identifier: token.address,
|
|
57
|
-
ticker: token.symbol
|
|
58
|
-
}))) ?? [];
|
|
59
|
-
}, [firstToken == null ? void 0 : firstToken.symbol, toTokens]);
|
|
60
|
-
const selectedChainOption = React.useMemo(() => {
|
|
61
|
-
const anchorToken = mvxChainId ? secondToken : firstToken;
|
|
62
|
-
const byAnchorToken = anchorToken && (chains == null ? void 0 : chains.find(
|
|
63
|
-
(option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, anchorToken.chainId)
|
|
64
|
-
));
|
|
65
|
-
if (byAnchorToken) {
|
|
66
|
-
return byAnchorToken;
|
|
67
|
-
}
|
|
68
|
-
const byActiveChain = chains == null ? void 0 : chains.find(
|
|
69
|
-
(option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, activeChain == null ? void 0 : activeChain.id)
|
|
70
|
-
);
|
|
71
|
-
if (byActiveChain) {
|
|
72
|
-
return byActiveChain;
|
|
73
|
-
}
|
|
74
|
-
const byOtherToken = mvxChainId ? firstToken && (chains == null ? void 0 : chains.find(
|
|
75
|
-
(option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, firstToken.chainId)
|
|
76
|
-
)) : secondToken && (chains == null ? void 0 : chains.find(
|
|
77
|
-
(option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, secondToken.chainId)
|
|
78
|
-
));
|
|
79
|
-
return byOtherToken ?? (chains == null ? void 0 : chains[0]);
|
|
80
|
-
}, [
|
|
81
|
-
activeChain == null ? void 0 : activeChain.id,
|
|
82
|
-
chains,
|
|
83
|
-
firstToken == null ? void 0 : firstToken.chainId,
|
|
84
|
-
mvxChainId,
|
|
85
|
-
secondToken == null ? void 0 : secondToken.chainId
|
|
86
|
-
]);
|
|
87
|
-
const getDefaultReceivingToken = React.useCallback(
|
|
88
|
-
(values) => reactjs_components_BridgeForm_utils_bridgeFormHelpers.getDefaultReceivingToken(values, toTokens),
|
|
89
|
-
[toTokens]
|
|
90
|
-
);
|
|
91
|
-
const updateUrlParams = React.useCallback(
|
|
92
|
-
({
|
|
93
|
-
firstTokenId,
|
|
94
|
-
secondTokenId
|
|
95
|
-
}) => {
|
|
96
|
-
reactjs_components_BridgeForm_utils_bridgeFormHelpers.updateUrlParams({
|
|
97
|
-
firstTokenId,
|
|
98
|
-
secondTokenId,
|
|
99
|
-
callbackRoute,
|
|
100
|
-
isTokensLoading,
|
|
101
|
-
onNavigate
|
|
102
|
-
});
|
|
103
|
-
},
|
|
104
|
-
[callbackRoute, isTokensLoading, onNavigate]
|
|
105
|
-
);
|
|
106
|
-
const onChangeFirstSelect = React.useCallback(
|
|
107
|
-
(option) => {
|
|
108
|
-
if (!option) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
setFirstToken(option);
|
|
112
|
-
updateUrlParams({ firstTokenId: option.address });
|
|
113
|
-
let secondOption = toTokens == null ? void 0 : toTokens.find(
|
|
114
|
-
(x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
|
|
115
|
-
);
|
|
116
|
-
if (!secondOption) {
|
|
117
|
-
const availableTokens = getAvailableTokens(option);
|
|
118
|
-
secondOption = availableTokens.find(
|
|
119
|
-
(x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
|
|
120
|
-
) ?? getDefaultReceivingToken(availableTokens);
|
|
121
|
-
}
|
|
122
|
-
if (secondOption) {
|
|
123
|
-
setSecondToken(secondOption);
|
|
124
|
-
updateUrlParams({ secondTokenId: secondOption.address });
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
[getAvailableTokens, getDefaultReceivingToken, updateUrlParams, toTokens]
|
|
128
|
-
);
|
|
129
|
-
const onChangeSecondSelect = React.useCallback(
|
|
130
|
-
(option) => {
|
|
131
|
-
if (!option) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
setSecondToken(option);
|
|
135
|
-
updateUrlParams({ secondTokenId: option.address });
|
|
136
|
-
const firstOption = fromOptions.find(
|
|
137
|
-
(x) => x.symbol.toLowerCase() === option.symbol.toLowerCase()
|
|
138
|
-
);
|
|
139
|
-
if (firstOption) {
|
|
140
|
-
setFirstToken(firstOption);
|
|
141
|
-
updateUrlParams({ firstTokenId: firstOption.address });
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
[fromOptions, updateUrlParams]
|
|
145
|
-
);
|
|
146
|
-
const handleChangeDirection = React.useCallback(() => {
|
|
147
|
-
if (!firstToken || !secondToken) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
setFirstToken(secondToken);
|
|
151
|
-
setSecondToken(firstToken);
|
|
152
|
-
updateUrlParams({
|
|
153
|
-
firstTokenId: secondToken.address,
|
|
154
|
-
secondTokenId: firstToken.address
|
|
155
|
-
});
|
|
156
|
-
const selectedOptionChain = sdkChains == null ? void 0 : sdkChains.find(
|
|
157
|
-
(chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.id, secondToken.chainId)
|
|
158
|
-
);
|
|
159
|
-
if (selectedOptionChain && switchNetwork) {
|
|
160
|
-
switchNetwork(selectedOptionChain);
|
|
161
|
-
}
|
|
162
|
-
}, [firstToken, secondToken, updateUrlParams, sdkChains, switchNetwork]);
|
|
163
|
-
React.useEffect(() => {
|
|
164
|
-
var _a, _b, _c, _d;
|
|
165
|
-
if (isTokensLoading || initializedInitialTokensRef.current || !fromOptions.length) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (firstToken && secondToken) {
|
|
169
|
-
initializedInitialTokensRef.current = true;
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens({
|
|
173
|
-
firstTokenId: firstTokenIdentifier,
|
|
174
|
-
secondTokenId: secondTokenIdentifier
|
|
175
|
-
});
|
|
176
|
-
const firstOption = fromOptions.find(
|
|
177
|
-
({ identifier }) => (initialTokens == null ? void 0 : initialTokens.firstTokenId) === identifier
|
|
178
|
-
) ?? fromOptions.find(
|
|
179
|
-
(option) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(option.chainId, activeChainId)
|
|
180
|
-
) ?? fromOptions[0];
|
|
181
|
-
let secondOption = toTokens == null ? void 0 : toTokens.find(
|
|
182
|
-
(x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
|
|
183
|
-
);
|
|
184
|
-
if (!secondOption) {
|
|
185
|
-
const availableTokens = getAvailableTokens(firstOption);
|
|
186
|
-
secondOption = (availableTokens == null ? void 0 : availableTokens.find(
|
|
187
|
-
({ address }) => {
|
|
188
|
-
var _a2;
|
|
189
|
-
return address.toLowerCase() === ((_a2 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a2.toLowerCase());
|
|
190
|
-
}
|
|
191
|
-
)) ?? availableTokens.find(
|
|
192
|
-
(x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
|
|
193
|
-
) ?? getDefaultReceivingToken(availableTokens);
|
|
194
|
-
}
|
|
195
|
-
const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a.toLowerCase()) === ((_b = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b.toLowerCase()) && ((_c = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c.toLowerCase()) === ((_d = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d.toLowerCase());
|
|
196
|
-
if (hasOptionsSelected) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
let initialized = false;
|
|
200
|
-
if (firstOption) {
|
|
201
|
-
setFirstToken(firstOption);
|
|
202
|
-
updateUrlParams({ firstTokenId: firstOption.address });
|
|
203
|
-
const selectedOptionChain = (sdkChains == null ? void 0 : sdkChains.find(
|
|
204
|
-
(chain) => reactjs_helpers_resolveBridgeApiChainId.sameBridgeApiChainId(chain.id, firstOption.chainId)
|
|
205
|
-
)) ?? activeChain;
|
|
206
|
-
if (selectedOptionChain && switchNetwork) {
|
|
207
|
-
switchNetwork(selectedOptionChain);
|
|
208
|
-
}
|
|
209
|
-
initialized = true;
|
|
210
|
-
}
|
|
211
|
-
if (secondOption) {
|
|
212
|
-
setSecondToken(secondOption);
|
|
213
|
-
updateUrlParams({ secondTokenId: secondOption.address });
|
|
214
|
-
initialized = initialized && true;
|
|
215
|
-
}
|
|
216
|
-
initializedInitialTokensRef.current = initialized;
|
|
217
|
-
}, [
|
|
218
|
-
isTokensLoading,
|
|
219
|
-
fromOptions,
|
|
220
|
-
toTokens,
|
|
221
|
-
firstTokenIdentifier,
|
|
222
|
-
secondTokenIdentifier,
|
|
223
|
-
activeChainId,
|
|
224
|
-
getAvailableTokens,
|
|
225
|
-
getDefaultReceivingToken,
|
|
226
|
-
updateUrlParams,
|
|
227
|
-
sdkChains,
|
|
228
|
-
activeChain,
|
|
229
|
-
switchNetwork,
|
|
230
|
-
firstToken,
|
|
231
|
-
secondToken
|
|
232
|
-
]);
|
|
233
|
-
React.useEffect(() => {
|
|
234
|
-
const selectedTokenOption = fromTokens == null ? void 0 : fromTokens.find(
|
|
235
|
-
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
|
236
|
-
);
|
|
237
|
-
if (selectedTokenOption) {
|
|
238
|
-
setFirstToken((prev) => {
|
|
239
|
-
return prev ? { ...prev, balance: selectedTokenOption.balance } : prev;
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}, [fromTokens, firstToken == null ? void 0 : firstToken.address]);
|
|
243
|
-
React.useEffect(() => {
|
|
244
|
-
const selectedTokenOption = toTokens == null ? void 0 : toTokens.find(
|
|
245
|
-
(x) => x.address === (secondToken == null ? void 0 : secondToken.address)
|
|
246
|
-
);
|
|
247
|
-
if (selectedTokenOption) {
|
|
248
|
-
setSecondToken((prev) => {
|
|
249
|
-
return prev ? { ...prev, balance: selectedTokenOption.balance } : prev;
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}, [toTokens, secondToken == null ? void 0 : secondToken.address]);
|
|
253
|
-
return {
|
|
254
|
-
firstToken,
|
|
255
|
-
secondToken,
|
|
256
|
-
fromOptions,
|
|
257
|
-
toOptions,
|
|
258
|
-
selectedChainOption,
|
|
259
|
-
setFirstToken,
|
|
260
|
-
setSecondToken,
|
|
261
|
-
onChangeFirstSelect,
|
|
262
|
-
onChangeSecondSelect,
|
|
263
|
-
handleChangeDirection,
|
|
264
|
-
updateUrlParams
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
exports.useBridgeTokenSelection = useBridgeTokenSelection;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),n=require("../../../helpers/resolveBridgeApiChainId.js"),W=require("../../../utils/getInitialTokens.js"),O=require("../utils/bridgeFormHelpers.js"),X=({chains:a,firstTokenIdentifier:j,secondTokenIdentifier:q,fromTokens:I,toTokens:t,isTokensLoading:S,activeChainId:F,mvxChainId:m,callbackRoute:M,forcedDestinationTokenSymbol:R,onNavigate:E,switchNetwork:L,sdkChains:i,activeChain:g})=>{const _=u.useRef(!1),[d,o]=u.useState(),[l,B]=u.useState(),y=u.useMemo(()=>(I==null?void 0:I.filter(e=>m?e.chainId.toString().toLowerCase()===m.toString().toLowerCase():!0).map(e=>({...e,identifier:e.address,ticker:e.symbol})))??[],[I,m]),A=u.useCallback(e=>O.getAvailableTokens(e,t,R),[t,R]),G=u.useMemo(()=>d?(t==null?void 0:t.filter(e=>e.symbol.toLowerCase()===d.symbol.toLowerCase()).map(e=>({...e,identifier:e.address,ticker:e.symbol})))??[]:[],[d==null?void 0:d.symbol,t]),J=u.useMemo(()=>{const e=m?l:d,r=e&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,e.chainId)));if(r)return r;const s=a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,g==null?void 0:g.id));return s||((m?d&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,d.chainId))):l&&(a==null?void 0:a.find(f=>n.sameBridgeApiChainId(f.chainId,l.chainId))))??(a==null?void 0:a[0]))},[g==null?void 0:g.id,a,d==null?void 0:d.chainId,m,l==null?void 0:l.chainId]),w=u.useCallback(e=>O.getDefaultReceivingToken(e,t),[t]),b=u.useCallback(({firstTokenId:e,secondTokenId:r})=>{O.updateUrlParams({firstTokenId:e,secondTokenId:r,callbackRoute:M,isTokensLoading:S,onNavigate:E})},[M,S,E]),K=u.useCallback(e=>{if(!e)return;o(e),b({firstTokenId:e.address});let r=t==null?void 0:t.find(s=>s.symbol.toLowerCase()===e.symbol.toLowerCase());if(!r){const s=A(e);r=s.find(p=>p.symbol.toLowerCase()===e.symbol.toLowerCase())??w(s)}r&&(B(r),b({secondTokenId:r.address}))},[A,w,b,t]),Q=u.useCallback(e=>{if(!e)return;B(e),b({secondTokenId:e.address});const r=y.find(s=>s.symbol.toLowerCase()===e.symbol.toLowerCase());r&&(o(r),b({firstTokenId:r.address}))},[y,b]),V=u.useCallback(()=>{if(!d||!l)return;o(l),B(d),b({firstTokenId:l.address,secondTokenId:d.address});const e=i==null?void 0:i.find(r=>n.sameBridgeApiChainId(r.id,l.chainId));e&&L&&L(e)},[d,l,b,i,L]);return u.useEffect(()=>{var P,z,D,U;if(S||_.current||!y.length)return;if(d&&l){_.current=!0;return}const e=W.getInitialTokens({firstTokenId:j,secondTokenId:q}),r=y.find(({identifier:c})=>(e==null?void 0:e.firstTokenId)===c)??y.find(c=>n.sameBridgeApiChainId(c.chainId,F))??y[0];let s=t==null?void 0:t.find(c=>c.symbol.toLowerCase()===(r==null?void 0:r.symbol.toLowerCase()));if(!s){const c=A(r);s=(c==null?void 0:c.find(({address:C})=>{var H;return C.toLowerCase()===((H=(r==null?void 0:r.symbol)??(e==null?void 0:e.secondTokenId))==null?void 0:H.toLowerCase())}))??c.find(C=>C.symbol.toLowerCase()===(r==null?void 0:r.symbol.toLowerCase()))??w(c)}if(!!d&&!!l&&((P=d==null?void 0:d.address)==null?void 0:P.toLowerCase())===((z=r==null?void 0:r.address)==null?void 0:z.toLowerCase())&&((D=l==null?void 0:l.address)==null?void 0:D.toLowerCase())===((U=s==null?void 0:s.address)==null?void 0:U.toLowerCase()))return;let f=!1;if(r){o(r),b({firstTokenId:r.address});const c=(i==null?void 0:i.find(C=>n.sameBridgeApiChainId(C.id,r.chainId)))??g;c&&L&&L(c),f=!0}s&&(B(s),b({secondTokenId:s.address}),f=f&&!0),_.current=f},[S,y,t,j,q,F,A,w,b,i,g,L]),u.useEffect(()=>{const e=I==null?void 0:I.find(r=>r.address===(d==null?void 0:d.address));e&&o(r=>r&&{...r,balance:e.balance})},[I,d==null?void 0:d.address]),u.useEffect(()=>{const e=t==null?void 0:t.find(r=>r.address===(l==null?void 0:l.address));e&&B(r=>r&&{...r,balance:e.balance})},[t,l==null?void 0:l.address]),{firstToken:d,secondToken:l,fromOptions:y,toOptions:G,selectedChainOption:J,setFirstToken:o,setSecondToken:B,onChangeFirstSelect:K,onChangeSecondSelect:Q,handleChangeDirection:V,updateUrlParams:b}};exports.useBridgeTokenSelection=X;
|