@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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useAppKitProvider as f, useAppKitAccount as m } from "@reown/appkit/react";
|
|
2
|
+
import { r as a } from "../../../react.esm-BxvJJ86Q.mjs";
|
|
3
|
+
import { useSendTransaction as g } from "wagmi";
|
|
4
|
+
import { useSignTransaction as i } from "../useSignTransaction.mjs";
|
|
5
|
+
jest.mock("@reown/appkit-adapter-solana/react", () => ({
|
|
6
|
+
useAppKitConnection: jest.fn(() => ({ connection: null }))
|
|
7
|
+
}));
|
|
8
|
+
jest.mock("@solana/web3.js", () => ({
|
|
9
|
+
PublicKey: jest.fn(),
|
|
10
|
+
Transaction: jest.fn(() => ({ add: jest.fn().mockReturnThis() })),
|
|
11
|
+
TransactionInstruction: jest.fn()
|
|
12
|
+
}));
|
|
13
|
+
const d = jest.mocked(f), b = jest.mocked(m), u = jest.mocked(g);
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
u.mockReturnValue({
|
|
16
|
+
data: void 0,
|
|
17
|
+
sendTransactionAsync: jest.fn(),
|
|
18
|
+
error: null,
|
|
19
|
+
isError: !1,
|
|
20
|
+
isIdle: !0,
|
|
21
|
+
isPending: !1,
|
|
22
|
+
isSuccess: !1,
|
|
23
|
+
reset: jest.fn(),
|
|
24
|
+
sendTransaction: jest.fn(),
|
|
25
|
+
status: "idle",
|
|
26
|
+
variables: void 0,
|
|
27
|
+
context: void 0,
|
|
28
|
+
failureCount: 0,
|
|
29
|
+
failureReason: null,
|
|
30
|
+
isPaused: !1,
|
|
31
|
+
submittedAt: 0,
|
|
32
|
+
mutate: jest.fn(),
|
|
33
|
+
mutateAsync: jest.fn()
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
const o = "0xabc123def456aaa000111222333444555666777888999aaabbbcccdddeeefff00";
|
|
37
|
+
function r(s) {
|
|
38
|
+
d.mockImplementation((e) => e === "sui" ? { walletProvider: { request: s } } : { walletProvider: void 0 }), b.mockImplementation((e) => (e == null ? void 0 : e.namespace) === "sui" ? {
|
|
39
|
+
address: o,
|
|
40
|
+
isConnected: !0,
|
|
41
|
+
status: "connected"
|
|
42
|
+
} : {
|
|
43
|
+
address: void 0,
|
|
44
|
+
isConnected: !1,
|
|
45
|
+
status: "disconnected"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
describe("useSignTransaction — signSuiTransaction", () => {
|
|
49
|
+
const s = btoa("valid transaction bytes");
|
|
50
|
+
beforeEach(() => {
|
|
51
|
+
u.mockReturnValue({
|
|
52
|
+
data: void 0,
|
|
53
|
+
sendTransactionAsync: jest.fn(),
|
|
54
|
+
error: null,
|
|
55
|
+
isError: !1,
|
|
56
|
+
isIdle: !0,
|
|
57
|
+
isPending: !1,
|
|
58
|
+
isSuccess: !1,
|
|
59
|
+
reset: jest.fn(),
|
|
60
|
+
sendTransaction: jest.fn(),
|
|
61
|
+
status: "idle",
|
|
62
|
+
variables: void 0,
|
|
63
|
+
context: void 0,
|
|
64
|
+
failureCount: 0,
|
|
65
|
+
failureReason: null,
|
|
66
|
+
isPaused: !1,
|
|
67
|
+
submittedAt: 0,
|
|
68
|
+
mutate: jest.fn(),
|
|
69
|
+
mutateAsync: jest.fn()
|
|
70
|
+
});
|
|
71
|
+
}), it("succeeds with valid base64 payload", async () => {
|
|
72
|
+
const e = jest.fn().mockResolvedValue({ signature: "sui-sig-ok" });
|
|
73
|
+
r(e);
|
|
74
|
+
const { result: t } = a(() => i()), n = await t.current.sui.signTransaction({
|
|
75
|
+
transaction: s,
|
|
76
|
+
address: o
|
|
77
|
+
});
|
|
78
|
+
expect(n).toBe("sui-sig-ok"), expect(e).toHaveBeenCalledWith(
|
|
79
|
+
expect.objectContaining({ method: "sui_signTransaction" })
|
|
80
|
+
);
|
|
81
|
+
}), it("throws when payload is not valid base64", async () => {
|
|
82
|
+
const e = jest.fn();
|
|
83
|
+
r(e);
|
|
84
|
+
const { result: t } = a(() => i());
|
|
85
|
+
await expect(
|
|
86
|
+
t.current.sui.signTransaction({
|
|
87
|
+
transaction: "not-valid-base64!!!",
|
|
88
|
+
address: o
|
|
89
|
+
})
|
|
90
|
+
).rejects.toThrow("not valid base64"), expect(e).not.toHaveBeenCalled();
|
|
91
|
+
}), it("throws when payload exceeds 32 KiB", async () => {
|
|
92
|
+
const e = jest.fn();
|
|
93
|
+
r(e);
|
|
94
|
+
const t = new Uint8Array(32 * 1024 + 1), n = btoa(String.fromCharCode(...t)), { result: c } = a(() => i());
|
|
95
|
+
await expect(
|
|
96
|
+
c.current.sui.signTransaction({
|
|
97
|
+
transaction: n,
|
|
98
|
+
address: o
|
|
99
|
+
})
|
|
100
|
+
).rejects.toThrow("maximum size"), expect(e).not.toHaveBeenCalled();
|
|
101
|
+
}), it("throws when payload is an empty string", async () => {
|
|
102
|
+
const e = jest.fn();
|
|
103
|
+
r(e);
|
|
104
|
+
const { result: t } = a(() => i());
|
|
105
|
+
await expect(
|
|
106
|
+
t.current.sui.signTransaction({
|
|
107
|
+
transaction: "",
|
|
108
|
+
address: o
|
|
109
|
+
})
|
|
110
|
+
).rejects.toThrow("No Sui transaction bytes provided"), expect(e).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe("useSignTransaction — signPSBT", () => {
|
|
114
|
+
it("forwards signInputs verbatim to btcWalletProvider.signPSBT", async () => {
|
|
115
|
+
const s = jest.fn().mockResolvedValue({ psbt: "signed-psbt" });
|
|
116
|
+
d.mockImplementation((p) => p === "bip122" ? { walletProvider: { signPSBT: s } } : { walletProvider: void 0 });
|
|
117
|
+
const { result: e } = a(() => i()), t = [
|
|
118
|
+
{
|
|
119
|
+
address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
120
|
+
index: 0,
|
|
121
|
+
sighashTypes: [1]
|
|
122
|
+
}
|
|
123
|
+
], n = {
|
|
124
|
+
psbt: "base64psbt==",
|
|
125
|
+
signInputs: [...t],
|
|
126
|
+
broadcast: !1
|
|
127
|
+
}, c = n.signInputs, l = await e.current.bitcoin.signTransaction(n);
|
|
128
|
+
expect(s).toHaveBeenCalledWith(
|
|
129
|
+
expect.objectContaining({
|
|
130
|
+
signInputs: [
|
|
131
|
+
{
|
|
132
|
+
address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
133
|
+
index: 0,
|
|
134
|
+
sighashTypes: [1]
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
})
|
|
138
|
+
), expect(s).not.toHaveBeenCalledWith(
|
|
139
|
+
expect.objectContaining({ signInputs: [] })
|
|
140
|
+
), expect(n.signInputs).toBe(c), expect(n.signInputs).toEqual(t), expect(l).toBe("signed-psbt");
|
|
141
|
+
}), it("throws when btcWalletProvider is not available", async () => {
|
|
142
|
+
d.mockImplementation(
|
|
143
|
+
() => ({
|
|
144
|
+
walletProvider: void 0
|
|
145
|
+
})
|
|
146
|
+
);
|
|
147
|
+
const { result: s } = a(() => i());
|
|
148
|
+
await expect(
|
|
149
|
+
s.current.bitcoin.signTransaction({
|
|
150
|
+
psbt: "base64psbt==",
|
|
151
|
+
signInputs: [],
|
|
152
|
+
broadcast: !1
|
|
153
|
+
})
|
|
154
|
+
).rejects.toThrow("user is disconnected");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const react = require("@reown/appkit/react");
|
|
5
|
-
const wagmi = require("wagmi");
|
|
6
|
-
const useAccount = () => {
|
|
7
|
-
const appkitAccount = react.useAppKitAccount();
|
|
8
|
-
const wagmiAccount = wagmi.useAccount();
|
|
9
|
-
return {
|
|
10
|
-
...wagmiAccount,
|
|
11
|
-
...appkitAccount
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.useAccount = useAccount;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@reown/appkit/react"),e=require("wagmi"),n=()=>{const c=t.useAppKitAccount();return{...e.useAccount(),...c}};exports.useAccount=n;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { useAppKitAccount } from "@reown/appkit/react";
|
|
2
|
-
import { useAccount as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const wagmiAccount = useAccount$1();
|
|
1
|
+
import { useAppKitAccount as t } from "@reown/appkit/react";
|
|
2
|
+
import { useAccount as o } from "wagmi";
|
|
3
|
+
const A = () => {
|
|
4
|
+
const c = t();
|
|
6
5
|
return {
|
|
7
|
-
...
|
|
8
|
-
...
|
|
6
|
+
...o(),
|
|
7
|
+
...c
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
10
|
export {
|
|
12
|
-
useAccount
|
|
11
|
+
A as useAccount
|
|
13
12
|
};
|
|
@@ -1,54 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const react = require("@reown/appkit/react");
|
|
5
|
-
const axios = require("axios");
|
|
6
|
-
const React = require("react");
|
|
7
|
-
const helpers_getApiURL = require("../../helpers/getApiURL.js");
|
|
8
|
-
const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
|
|
9
|
-
const useBalances = () => {
|
|
10
|
-
const { config } = reactjs_context_useWeb3App.useWeb3App();
|
|
11
|
-
const { address, isConnected } = react.useAppKitAccount();
|
|
12
|
-
const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
|
|
13
|
-
const fetchBalances = async (chainId) => {
|
|
14
|
-
const url = `${helpers_getApiURL.getApiURL()}/user/balance/${address}?chainId=${chainId}`;
|
|
15
|
-
try {
|
|
16
|
-
const { data } = await axios.get(url, {
|
|
17
|
-
headers: {
|
|
18
|
-
Authorization: `Bearer ${nativeAuthToken}`
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return data.reduce(
|
|
22
|
-
(acc, cur) => {
|
|
23
|
-
acc[cur.tokenAddress] = cur.balance;
|
|
24
|
-
return acc;
|
|
25
|
-
},
|
|
26
|
-
{}
|
|
27
|
-
);
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw new Error(`Error fetching balances: ${error}`);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const getBalances = React.useCallback(
|
|
33
|
-
async ({ tokens, chainId }) => {
|
|
34
|
-
const tokensBalances = await fetchBalances(chainId);
|
|
35
|
-
return tokens.map((token) => {
|
|
36
|
-
if (!isConnected || !address || !token.chainId) {
|
|
37
|
-
return {
|
|
38
|
-
tokenId: token.address,
|
|
39
|
-
balance: "0"
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
tokenId: token.address,
|
|
44
|
-
balance: tokensBalances[token.address] ?? "0"
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
[config, isConnected, address]
|
|
49
|
-
);
|
|
50
|
-
return {
|
|
51
|
-
getBalances
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
exports.useBalances = useBalances;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@reown/appkit/react"),p=require("axios"),b=require("react"),h=require("../../helpers/getApiURL.js"),o=require("../context/useWeb3App.js"),A=()=>{const{config:u}=o.useWeb3App(),{address:t,isConnected:a}=l.useAppKitAccount(),{nativeAuthToken:i}=o.useWeb3App(),d=async n=>{const s=`${h.getApiURL()}/user/balance/${t}?chainId=${n}`;try{const{data:r}=await p.get(s,{headers:{Authorization:`Bearer ${i}`}});return r.reduce((e,c)=>(e[c.tokenAddress]=c.balance,e),{})}catch(r){throw new Error(`Error fetching balances: ${r}`)}};return{getBalances:b.useCallback(async({tokens:n,chainId:s})=>{const r=await d(s);return n.map(e=>!a||!t||!e.chainId?{tokenId:e.address,balance:"0"}:{tokenId:e.address,balance:r[e.address]??"0"})},[u,a,t])}};exports.useBalances=A;
|
|
@@ -1,53 +1,41 @@
|
|
|
1
|
-
import { useAppKitAccount } from "@reown/appkit/react";
|
|
2
|
-
import
|
|
3
|
-
import { useCallback } from "react";
|
|
4
|
-
import { getApiURL } from "../../helpers/getApiURL.mjs";
|
|
5
|
-
import { useWeb3App } from "../context/useWeb3App.mjs";
|
|
6
|
-
const
|
|
7
|
-
const { config } =
|
|
8
|
-
|
|
9
|
-
const { nativeAuthToken } = useWeb3App();
|
|
10
|
-
const fetchBalances = async (chainId) => {
|
|
11
|
-
const url = `${getApiURL()}/user/balance/${address}?chainId=${chainId}`;
|
|
1
|
+
import { useAppKitAccount as l } from "@reown/appkit/react";
|
|
2
|
+
import p from "axios";
|
|
3
|
+
import { useCallback as m } from "react";
|
|
4
|
+
import { getApiURL as f } from "../../helpers/getApiURL.mjs";
|
|
5
|
+
import { useWeb3App as c } from "../context/useWeb3App.mjs";
|
|
6
|
+
const w = () => {
|
|
7
|
+
const { config: i } = c(), { address: a, isConnected: s } = l(), { nativeAuthToken: d } = c(), u = async (t) => {
|
|
8
|
+
const n = `${f()}/user/balance/${a}?chainId=${t}`;
|
|
12
9
|
try {
|
|
13
|
-
const { data } = await
|
|
10
|
+
const { data: r } = await p.get(n, {
|
|
14
11
|
headers: {
|
|
15
|
-
Authorization: `Bearer ${
|
|
12
|
+
Authorization: `Bearer ${d}`
|
|
16
13
|
}
|
|
17
14
|
});
|
|
18
|
-
return
|
|
19
|
-
(
|
|
20
|
-
acc[cur.tokenAddress] = cur.balance;
|
|
21
|
-
return acc;
|
|
22
|
-
},
|
|
15
|
+
return r.reduce(
|
|
16
|
+
(e, o) => (e[o.tokenAddress] = o.balance, e),
|
|
23
17
|
{}
|
|
24
18
|
);
|
|
25
|
-
} catch (
|
|
26
|
-
throw new Error(`Error fetching balances: ${
|
|
19
|
+
} catch (r) {
|
|
20
|
+
throw new Error(`Error fetching balances: ${r}`);
|
|
27
21
|
}
|
|
28
22
|
};
|
|
29
|
-
const getBalances = useCallback(
|
|
30
|
-
async ({ tokens, chainId }) => {
|
|
31
|
-
const tokensBalances = await fetchBalances(chainId);
|
|
32
|
-
return tokens.map((token) => {
|
|
33
|
-
if (!isConnected || !address || !token.chainId) {
|
|
34
|
-
return {
|
|
35
|
-
tokenId: token.address,
|
|
36
|
-
balance: "0"
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
tokenId: token.address,
|
|
41
|
-
balance: tokensBalances[token.address] ?? "0"
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
[config, isConnected, address]
|
|
46
|
-
);
|
|
47
23
|
return {
|
|
48
|
-
getBalances
|
|
24
|
+
getBalances: m(
|
|
25
|
+
async ({ tokens: t, chainId: n }) => {
|
|
26
|
+
const r = await u(n);
|
|
27
|
+
return t.map((e) => !s || !a || !e.chainId ? {
|
|
28
|
+
tokenId: e.address,
|
|
29
|
+
balance: "0"
|
|
30
|
+
} : {
|
|
31
|
+
tokenId: e.address,
|
|
32
|
+
balance: r[e.address] ?? "0"
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
[i, s, a]
|
|
36
|
+
)
|
|
49
37
|
};
|
|
50
38
|
};
|
|
51
39
|
export {
|
|
52
|
-
useBalances
|
|
40
|
+
w as useBalances
|
|
53
41
|
};
|
|
@@ -1,14 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const react = require("@reown/appkit/react");
|
|
5
|
-
const React = require("react");
|
|
6
|
-
const reactjs_helpers_resolveBridgeApiChainId = require("../helpers/resolveBridgeApiChainId.js");
|
|
7
|
-
function useBridgeApiChainId() {
|
|
8
|
-
const { chainId, caipNetwork } = react.useAppKitNetwork();
|
|
9
|
-
return React.useMemo(
|
|
10
|
-
() => reactjs_helpers_resolveBridgeApiChainId.toBridgeApiChainId(chainId, caipNetwork),
|
|
11
|
-
[chainId, caipNetwork]
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
exports.useBridgeApiChainId = useBridgeApiChainId;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@reown/appkit/react"),t=require("react"),n=require("../helpers/resolveBridgeApiChainId.js");function o(){const{chainId:e,caipNetwork:i}=r.useAppKitNetwork();return t.useMemo(()=>n.toBridgeApiChainId(e,i),[e,i])}exports.useBridgeApiChainId=o;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useAppKitNetwork } from "@reown/appkit/react";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { toBridgeApiChainId } from "../helpers/resolveBridgeApiChainId.mjs";
|
|
4
|
-
function
|
|
5
|
-
const { chainId, caipNetwork } =
|
|
6
|
-
return
|
|
7
|
-
() =>
|
|
8
|
-
[
|
|
1
|
+
import { useAppKitNetwork as r } from "@reown/appkit/react";
|
|
2
|
+
import { useMemo as t } from "react";
|
|
3
|
+
import { toBridgeApiChainId as e } from "../helpers/resolveBridgeApiChainId.mjs";
|
|
4
|
+
function d() {
|
|
5
|
+
const { chainId: i, caipNetwork: o } = r();
|
|
6
|
+
return t(
|
|
7
|
+
() => e(i, o),
|
|
8
|
+
[i, o]
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
|
-
useBridgeApiChainId
|
|
12
|
+
d as useBridgeApiChainId
|
|
13
13
|
};
|
|
@@ -1,163 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const formik = require("formik");
|
|
5
|
-
const React = require("react");
|
|
6
|
-
const yup = require("yup");
|
|
7
|
-
const reactjs_hooks_validation_useAmountSchema = require("./validation/useAmountSchema.js");
|
|
8
|
-
const reactjs_hooks_validation_useSecondAmountSchema = require("./validation/useSecondAmountSchema.js");
|
|
9
|
-
const api_confirmRate = require("../../api/confirmRate.js");
|
|
10
|
-
const helpers_getApiURL = require("../../helpers/getApiURL.js");
|
|
11
|
-
const types_providerType = require("../../types/providerType.js");
|
|
12
|
-
const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
|
|
13
|
-
var BridgeFormikValuesEnum = /* @__PURE__ */ ((BridgeFormikValuesEnum2) => {
|
|
14
|
-
BridgeFormikValuesEnum2["firstToken"] = "firstToken";
|
|
15
|
-
BridgeFormikValuesEnum2["firstAmount"] = "firstAmount";
|
|
16
|
-
BridgeFormikValuesEnum2["secondToken"] = "secondToken";
|
|
17
|
-
BridgeFormikValuesEnum2["secondAmount"] = "secondAmount";
|
|
18
|
-
BridgeFormikValuesEnum2["fromChainId"] = "fromChainId";
|
|
19
|
-
BridgeFormikValuesEnum2["toChainId"] = "toChainId";
|
|
20
|
-
return BridgeFormikValuesEnum2;
|
|
21
|
-
})(BridgeFormikValuesEnum || {});
|
|
22
|
-
const useBridgeFormik = ({
|
|
23
|
-
sender,
|
|
24
|
-
receiver,
|
|
25
|
-
firstToken,
|
|
26
|
-
firstAmount,
|
|
27
|
-
secondToken,
|
|
28
|
-
secondAmount,
|
|
29
|
-
fromChainId,
|
|
30
|
-
toChainId,
|
|
31
|
-
setForceRefetchRate,
|
|
32
|
-
rate,
|
|
33
|
-
onSubmit,
|
|
34
|
-
isMvxConnected
|
|
35
|
-
}) => {
|
|
36
|
-
const pendingSigningRef = React.useRef();
|
|
37
|
-
const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
|
|
38
|
-
const initialValues = {
|
|
39
|
-
firstAmount: "",
|
|
40
|
-
secondAmount: "",
|
|
41
|
-
fromChainId: fromChainId ?? "",
|
|
42
|
-
toChainId: toChainId ?? ""
|
|
43
|
-
};
|
|
44
|
-
const resetSwapForm = () => {
|
|
45
|
-
formik$1.setTouched({}, false);
|
|
46
|
-
formik$1.setErrors({});
|
|
47
|
-
setFieldValue("firstAmount", "");
|
|
48
|
-
setFieldValue("secondAmount", "");
|
|
49
|
-
};
|
|
50
|
-
const onSubmitFormik = async (values) => {
|
|
51
|
-
var _a, _b;
|
|
52
|
-
if (pendingSigningRef.current) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
pendingSigningRef.current = true;
|
|
56
|
-
try {
|
|
57
|
-
const { data } = await api_confirmRate.confirmRate({
|
|
58
|
-
url: helpers_getApiURL.getApiURL(),
|
|
59
|
-
nativeAuthToken: nativeAuthToken ?? "",
|
|
60
|
-
body: {
|
|
61
|
-
tokenIn: ((_a = values.firstToken) == null ? void 0 : _a.address) ?? "",
|
|
62
|
-
amountIn: (firstAmount == null ? void 0 : firstAmount.toString()) ?? "",
|
|
63
|
-
fromChainId: values.fromChainId ?? "",
|
|
64
|
-
tokenOut: ((_b = values.secondToken) == null ? void 0 : _b.address) ?? "",
|
|
65
|
-
toChainId: values.toChainId ?? "",
|
|
66
|
-
amountOut: (secondAmount == null ? void 0 : secondAmount.toString()) ?? "",
|
|
67
|
-
sender: sender ?? "",
|
|
68
|
-
receiver: receiver ?? "",
|
|
69
|
-
fee: (rate == null ? void 0 : rate.fee) ?? "0",
|
|
70
|
-
provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None,
|
|
71
|
-
orderId: (rate == null ? void 0 : rate.orderId) ?? ""
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
const transactions = data;
|
|
75
|
-
if (!transactions || transactions.length === 0) {
|
|
76
|
-
pendingSigningRef.current = false;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
resetSwapForm();
|
|
80
|
-
onSubmit({
|
|
81
|
-
transactions,
|
|
82
|
-
provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None
|
|
83
|
-
});
|
|
84
|
-
} catch (error) {
|
|
85
|
-
console.error("Error confirming rate:", error);
|
|
86
|
-
setForceRefetchRate == null ? void 0 : setForceRefetchRate((prevState) => prevState + 1);
|
|
87
|
-
} finally {
|
|
88
|
-
pendingSigningRef.current = false;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
const formik$1 = formik.useFormik({
|
|
92
|
-
initialValues,
|
|
93
|
-
validationSchema: yup.object().shape({
|
|
94
|
-
[
|
|
95
|
-
"firstAmount"
|
|
96
|
-
/* firstAmount */
|
|
97
|
-
]: reactjs_hooks_validation_useAmountSchema.useAmountSchema({ isMvxConnected }),
|
|
98
|
-
[
|
|
99
|
-
"firstToken"
|
|
100
|
-
/* firstToken */
|
|
101
|
-
]: yup.object().required(),
|
|
102
|
-
[
|
|
103
|
-
"secondAmount"
|
|
104
|
-
/* secondAmount */
|
|
105
|
-
]: reactjs_hooks_validation_useSecondAmountSchema.useSecondAmountSchema(),
|
|
106
|
-
[
|
|
107
|
-
"secondToken"
|
|
108
|
-
/* secondToken */
|
|
109
|
-
]: yup.object().required(),
|
|
110
|
-
[
|
|
111
|
-
"fromChainId"
|
|
112
|
-
/* fromChainId */
|
|
113
|
-
]: yup.string().required(),
|
|
114
|
-
[
|
|
115
|
-
"toChainId"
|
|
116
|
-
/* toChainId */
|
|
117
|
-
]: yup.string().required()
|
|
118
|
-
}),
|
|
119
|
-
onSubmit: onSubmitFormik
|
|
120
|
-
});
|
|
121
|
-
const {
|
|
122
|
-
errors,
|
|
123
|
-
touched,
|
|
124
|
-
handleBlur,
|
|
125
|
-
handleSubmit,
|
|
126
|
-
handleChange,
|
|
127
|
-
setFieldValue,
|
|
128
|
-
setFieldTouched
|
|
129
|
-
} = formik$1;
|
|
130
|
-
React.useEffect(() => {
|
|
131
|
-
setFieldValue("firstToken", firstToken, true);
|
|
132
|
-
}, [firstToken]);
|
|
133
|
-
React.useEffect(() => {
|
|
134
|
-
setFieldValue("secondToken", secondToken, true);
|
|
135
|
-
}, [secondToken]);
|
|
136
|
-
React.useEffect(() => {
|
|
137
|
-
setFieldValue("fromChainId", fromChainId, true);
|
|
138
|
-
}, [fromChainId]);
|
|
139
|
-
React.useEffect(() => {
|
|
140
|
-
setFieldValue("toChainId", toChainId, true);
|
|
141
|
-
}, [toChainId]);
|
|
142
|
-
const secondAmountError = "secondAmount" in errors && "secondAmount" in touched ? errors.secondAmount : void 0;
|
|
143
|
-
const firstAmountError = "firstAmount" in errors && "firstAmount" in touched ? errors.firstAmount : void 0;
|
|
144
|
-
const fromChainError = "fromChainId" in errors && "fromChainId" in touched ? errors.fromChainId : void 0;
|
|
145
|
-
return {
|
|
146
|
-
formik: formik$1,
|
|
147
|
-
errors,
|
|
148
|
-
touched,
|
|
149
|
-
firstToken,
|
|
150
|
-
secondToken,
|
|
151
|
-
firstAmountError,
|
|
152
|
-
secondAmountError,
|
|
153
|
-
fromChainError,
|
|
154
|
-
handleBlur,
|
|
155
|
-
handleChange,
|
|
156
|
-
handleSubmit,
|
|
157
|
-
setFieldValue,
|
|
158
|
-
resetSwapForm,
|
|
159
|
-
setFieldTouched
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
exports.BridgeFormikValuesEnum = BridgeFormikValuesEnum;
|
|
163
|
-
exports.useBridgeFormik = useBridgeFormik;
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("formik"),s=require("react"),u=require("yup"),x=require("./validation/useAmountSchema.js"),R=require("./validation/useSecondAmountSchema.js"),$=require("../../api/confirmRate.js"),z=require("../../helpers/assertRateConfirmationMatchesIntent.js"),D=require("../../helpers/getApiURL.js"),q=require("../../types/providerType.js"),G=require("../context/useWeb3App.js");var T=(o=>(o.firstToken="firstToken",o.firstAmount="firstAmount",o.secondToken="secondToken",o.secondAmount="secondAmount",o.fromChainId="fromChainId",o.toChainId="toChainId",o))(T||{});const H=({sender:o,receiver:b,firstToken:f,firstAmount:m,secondToken:h,secondAmount:p,fromChainId:I,toChainId:A,setForceRefetchRate:C,rate:n,onSubmit:g,isMvxConnected:_})=>{const d=s.useRef(),{nativeAuthToken:y}=G.useWeb3App(),j={firstAmount:"",secondAmount:"",fromChainId:I??"",toChainId:A??""},S=()=>{c.setTouched({},!1),c.setErrors({}),r("firstAmount",""),r("secondAmount","")},E=async i=>{var k,v;if(!d.current){d.current=!0;try{const{data:l}=await $.confirmRate({url:D.getApiURL(),nativeAuthToken:y??"",body:{tokenIn:((k=i.firstToken)==null?void 0:k.address)??"",amountIn:(m==null?void 0:m.toString())??"",fromChainId:i.fromChainId??"",tokenOut:((v=i.secondToken)==null?void 0:v.address)??"",toChainId:i.toChainId??"",amountOut:(p==null?void 0:p.toString())??"",sender:o??"",receiver:b??"",fee:(n==null?void 0:n.fee)??"0",provider:(n==null?void 0:n.provider)??q.ProviderType.None,orderId:(n==null?void 0:n.orderId)??""}}),t=l;if(!t||t.length===0){d.current=!1;return}z.assertRateConfirmationMatchesIntent({fromChainId:i.fromChainId??"",sender:o??""},t),S(),g({transactions:t,provider:(n==null?void 0:n.provider)??q.ProviderType.None})}catch(l){console.error("Error confirming rate:",l),C==null||C(t=>t+1)}finally{d.current=!1}}},c=W.useFormik({initialValues:j,validationSchema:u.object().shape({firstAmount:x.useAmountSchema({isMvxConnected:_}),firstToken:u.object().required(),secondAmount:R.useSecondAmountSchema(),secondToken:u.object().required(),fromChainId:u.string().required(),toChainId:u.string().required()}),onSubmit:E}),{errors:e,touched:a,handleBlur:M,handleSubmit:O,handleChange:P,setFieldValue:r,setFieldTouched:w}=c;s.useEffect(()=>{r("firstToken",f,!0)},[f]),s.useEffect(()=>{r("secondToken",h,!0)},[h]),s.useEffect(()=>{r("fromChainId",I,!0)},[I]),s.useEffect(()=>{r("toChainId",A,!0)},[A]);const L="secondAmount"in e&&"secondAmount"in a?e.secondAmount:void 0,N="firstAmount"in e&&"firstAmount"in a?e.firstAmount:void 0,U="fromChainId"in e&&"fromChainId"in a?e.fromChainId:void 0;return{formik:c,errors:e,touched:a,firstToken:f,secondToken:h,firstAmountError:N,secondAmountError:L,fromChainError:U,handleBlur:M,handleChange:P,handleSubmit:O,setFieldValue:r,resetSwapForm:S,setFieldTouched:w}};exports.BridgeFormikValuesEnum=T;exports.useBridgeFormik=H;
|