@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,131 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const axios = require("axios");
|
|
4
|
-
const types_providerType = require("../../types/providerType.js");
|
|
5
|
-
const api_confirmRate = require("../confirmRate.js");
|
|
6
|
-
jest.mock("axios");
|
|
7
|
-
const mockedAxios = axios;
|
|
8
|
-
describe("confirmRate", () => {
|
|
9
|
-
const url = "https://api.example.com";
|
|
10
|
-
it("POST confirmRate successfully", async () => {
|
|
11
|
-
const body = {
|
|
12
|
-
tokenIn: "tokenIn",
|
|
13
|
-
tokenOut: "tokenOut",
|
|
14
|
-
fee: "100",
|
|
15
|
-
amountIn: "1000",
|
|
16
|
-
amountOut: "900",
|
|
17
|
-
fromChainId: "97",
|
|
18
|
-
toChainId: "44",
|
|
19
|
-
sender: "0x123",
|
|
20
|
-
receiver: "0x456",
|
|
21
|
-
provider: types_providerType.ProviderType.None,
|
|
22
|
-
orderId: "123"
|
|
23
|
-
};
|
|
24
|
-
const nativeAuthToken = "ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01";
|
|
25
|
-
const config = {
|
|
26
|
-
baseURL: url,
|
|
27
|
-
headers: {
|
|
28
|
-
Authorization: `Bearer ${nativeAuthToken}`
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const response = [
|
|
32
|
-
{
|
|
33
|
-
from: "0xAlice",
|
|
34
|
-
to: "0xBob",
|
|
35
|
-
type: "eip1559",
|
|
36
|
-
gas: "100000",
|
|
37
|
-
gasPrice: "1000000000",
|
|
38
|
-
chainId: 1,
|
|
39
|
-
hash: "0x1234",
|
|
40
|
-
nonce: 1,
|
|
41
|
-
value: "1000000000000000000"
|
|
42
|
-
}
|
|
43
|
-
];
|
|
44
|
-
mockedAxios.post.mockResolvedValue({ data: response });
|
|
45
|
-
const result = await api_confirmRate.confirmRate({
|
|
46
|
-
url,
|
|
47
|
-
nativeAuthToken,
|
|
48
|
-
body
|
|
49
|
-
});
|
|
50
|
-
expect(mockedAxios.post).toHaveBeenCalledWith(
|
|
51
|
-
"/rate/confirm",
|
|
52
|
-
body,
|
|
53
|
-
config
|
|
54
|
-
);
|
|
55
|
-
expect(result.data).toEqual(response);
|
|
56
|
-
});
|
|
57
|
-
it("POST confirmRate with no nativeAuthToken", async () => {
|
|
58
|
-
const body = {
|
|
59
|
-
tokenIn: "tokenIn",
|
|
60
|
-
tokenOut: "tokenOut",
|
|
61
|
-
fee: "100",
|
|
62
|
-
amountIn: "1000",
|
|
63
|
-
amountOut: "900",
|
|
64
|
-
fromChainId: "97",
|
|
65
|
-
toChainId: "44",
|
|
66
|
-
sender: "0x123",
|
|
67
|
-
receiver: "0x456",
|
|
68
|
-
provider: types_providerType.ProviderType.None,
|
|
69
|
-
orderId: "123"
|
|
70
|
-
};
|
|
71
|
-
const nativeAuthToken = "";
|
|
72
|
-
const config = {
|
|
73
|
-
baseURL: url,
|
|
74
|
-
headers: {}
|
|
75
|
-
};
|
|
76
|
-
const response = [
|
|
77
|
-
{
|
|
78
|
-
from: "0xAlice",
|
|
79
|
-
to: "0xBob",
|
|
80
|
-
type: "eip1559",
|
|
81
|
-
gas: "100000",
|
|
82
|
-
gasPrice: "1000000000",
|
|
83
|
-
chainId: 1,
|
|
84
|
-
hash: "0x1234",
|
|
85
|
-
nonce: 1,
|
|
86
|
-
value: "1000000000000000000"
|
|
87
|
-
}
|
|
88
|
-
];
|
|
89
|
-
mockedAxios.post.mockResolvedValue({ data: response });
|
|
90
|
-
const result = await api_confirmRate.confirmRate({
|
|
91
|
-
url,
|
|
92
|
-
nativeAuthToken,
|
|
93
|
-
body
|
|
94
|
-
});
|
|
95
|
-
expect(mockedAxios.post).toHaveBeenCalledWith(
|
|
96
|
-
"/rate/confirm",
|
|
97
|
-
body,
|
|
98
|
-
config
|
|
99
|
-
);
|
|
100
|
-
expect(result.data).toEqual(response);
|
|
101
|
-
});
|
|
102
|
-
it("POST confirmRate should throw an error", async () => {
|
|
103
|
-
const body = {
|
|
104
|
-
tokenIn: "tokenIn",
|
|
105
|
-
tokenOut: "tokenOut",
|
|
106
|
-
fee: "100",
|
|
107
|
-
amountIn: "1000",
|
|
108
|
-
amountOut: "900",
|
|
109
|
-
fromChainId: "97",
|
|
110
|
-
toChainId: "44",
|
|
111
|
-
sender: "0x123",
|
|
112
|
-
receiver: "0x456",
|
|
113
|
-
provider: types_providerType.ProviderType.None,
|
|
114
|
-
orderId: "123"
|
|
115
|
-
};
|
|
116
|
-
const nativeAuthToken = "";
|
|
117
|
-
const config = {
|
|
118
|
-
baseURL: url,
|
|
119
|
-
headers: {}
|
|
120
|
-
};
|
|
121
|
-
mockedAxios.post.mockRejectedValue(new Error("error"));
|
|
122
|
-
await expect(api_confirmRate.confirmRate({ url, nativeAuthToken, body })).rejects.toThrow(
|
|
123
|
-
"error"
|
|
124
|
-
);
|
|
125
|
-
expect(mockedAxios.post).toHaveBeenCalledWith(
|
|
126
|
-
"/rate/confirm",
|
|
127
|
-
body,
|
|
128
|
-
config
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
2
|
+
"use strict";const d=require("axios"),s=require("../../types/providerType.js"),i=require("../confirmRate.js");jest.mock("axios");const n=d;describe("confirmRate",()=>{const o="https://api.example.com";it("POST confirmRate successfully",async()=>{const e={tokenIn:"tokenIn",tokenOut:"tokenOut",fee:"100",amountIn:"1000",amountOut:"900",fromChainId:"97",toChainId:"44",sender:"0x123",receiver:"0x456",provider:s.ProviderType.None,orderId:"123"},t="ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01",a={baseURL:o,headers:{Authorization:`Bearer ${t}`}},r=[{from:"0xAlice",to:"0xBob",type:"eip1559",gas:"100000",gasPrice:"1000000000",chainId:1,hash:"0x1234",nonce:1,value:"1000000000000000000"}];n.post.mockResolvedValue({data:r});const c=await i.confirmRate({url:o,nativeAuthToken:t,body:e});expect(n.post).toHaveBeenCalledWith("/rate/confirm",e,a),expect(c.data).toEqual(r)}),it("POST confirmRate with no nativeAuthToken",async()=>{const e={tokenIn:"tokenIn",tokenOut:"tokenOut",fee:"100",amountIn:"1000",amountOut:"900",fromChainId:"97",toChainId:"44",sender:"0x123",receiver:"0x456",provider:s.ProviderType.None,orderId:"123"},t="",a={baseURL:o,headers:{}},r=[{from:"0xAlice",to:"0xBob",type:"eip1559",gas:"100000",gasPrice:"1000000000",chainId:1,hash:"0x1234",nonce:1,value:"1000000000000000000"}];n.post.mockResolvedValue({data:r});const c=await i.confirmRate({url:o,nativeAuthToken:t,body:e});expect(n.post).toHaveBeenCalledWith("/rate/confirm",e,a),expect(c.data).toEqual(r)}),it("POST confirmRate should throw an error",async()=>{const e={tokenIn:"tokenIn",tokenOut:"tokenOut",fee:"100",amountIn:"1000",amountOut:"900",fromChainId:"97",toChainId:"44",sender:"0x123",receiver:"0x456",provider:s.ProviderType.None,orderId:"123"},t="",a={baseURL:o,headers:{}};n.post.mockRejectedValue(new Error("error")),await expect(i.confirmRate({url:o,nativeAuthToken:t,body:e})).rejects.toThrow("error"),expect(n.post).toHaveBeenCalledWith("/rate/confirm",e,a)})});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ProviderType } from "../../types/providerType.mjs";
|
|
3
|
-
import { confirmRate } from "../confirmRate.mjs";
|
|
1
|
+
import d from "axios";
|
|
2
|
+
import { ProviderType as s } from "../../types/providerType.mjs";
|
|
3
|
+
import { confirmRate as i } from "../confirmRate.mjs";
|
|
4
4
|
jest.mock("axios");
|
|
5
|
-
const
|
|
5
|
+
const n = d;
|
|
6
6
|
describe("confirmRate", () => {
|
|
7
|
-
const
|
|
7
|
+
const o = "https://api.example.com";
|
|
8
8
|
it("POST confirmRate successfully", async () => {
|
|
9
|
-
const
|
|
9
|
+
const e = {
|
|
10
10
|
tokenIn: "tokenIn",
|
|
11
11
|
tokenOut: "tokenOut",
|
|
12
12
|
fee: "100",
|
|
@@ -16,17 +16,14 @@ describe("confirmRate", () => {
|
|
|
16
16
|
toChainId: "44",
|
|
17
17
|
sender: "0x123",
|
|
18
18
|
receiver: "0x456",
|
|
19
|
-
provider:
|
|
19
|
+
provider: s.None,
|
|
20
20
|
orderId: "123"
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const config = {
|
|
24
|
-
baseURL: url,
|
|
21
|
+
}, t = "ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01", a = {
|
|
22
|
+
baseURL: o,
|
|
25
23
|
headers: {
|
|
26
|
-
Authorization: `Bearer ${
|
|
24
|
+
Authorization: `Bearer ${t}`
|
|
27
25
|
}
|
|
28
|
-
}
|
|
29
|
-
const response = [
|
|
26
|
+
}, r = [
|
|
30
27
|
{
|
|
31
28
|
from: "0xAlice",
|
|
32
29
|
to: "0xBob",
|
|
@@ -39,21 +36,19 @@ describe("confirmRate", () => {
|
|
|
39
36
|
value: "1000000000000000000"
|
|
40
37
|
}
|
|
41
38
|
];
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
url,
|
|
45
|
-
nativeAuthToken,
|
|
46
|
-
body
|
|
39
|
+
n.post.mockResolvedValue({ data: r });
|
|
40
|
+
const c = await i({
|
|
41
|
+
url: o,
|
|
42
|
+
nativeAuthToken: t,
|
|
43
|
+
body: e
|
|
47
44
|
});
|
|
48
|
-
expect(
|
|
45
|
+
expect(n.post).toHaveBeenCalledWith(
|
|
49
46
|
"/rate/confirm",
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
it("POST confirmRate with no nativeAuthToken", async () => {
|
|
56
|
-
const body = {
|
|
47
|
+
e,
|
|
48
|
+
a
|
|
49
|
+
), expect(c.data).toEqual(r);
|
|
50
|
+
}), it("POST confirmRate with no nativeAuthToken", async () => {
|
|
51
|
+
const e = {
|
|
57
52
|
tokenIn: "tokenIn",
|
|
58
53
|
tokenOut: "tokenOut",
|
|
59
54
|
fee: "100",
|
|
@@ -63,15 +58,12 @@ describe("confirmRate", () => {
|
|
|
63
58
|
toChainId: "44",
|
|
64
59
|
sender: "0x123",
|
|
65
60
|
receiver: "0x456",
|
|
66
|
-
provider:
|
|
61
|
+
provider: s.None,
|
|
67
62
|
orderId: "123"
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const config = {
|
|
71
|
-
baseURL: url,
|
|
63
|
+
}, t = "", a = {
|
|
64
|
+
baseURL: o,
|
|
72
65
|
headers: {}
|
|
73
|
-
}
|
|
74
|
-
const response = [
|
|
66
|
+
}, r = [
|
|
75
67
|
{
|
|
76
68
|
from: "0xAlice",
|
|
77
69
|
to: "0xBob",
|
|
@@ -84,21 +76,19 @@ describe("confirmRate", () => {
|
|
|
84
76
|
value: "1000000000000000000"
|
|
85
77
|
}
|
|
86
78
|
];
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
url,
|
|
90
|
-
nativeAuthToken,
|
|
91
|
-
body
|
|
79
|
+
n.post.mockResolvedValue({ data: r });
|
|
80
|
+
const c = await i({
|
|
81
|
+
url: o,
|
|
82
|
+
nativeAuthToken: t,
|
|
83
|
+
body: e
|
|
92
84
|
});
|
|
93
|
-
expect(
|
|
85
|
+
expect(n.post).toHaveBeenCalledWith(
|
|
94
86
|
"/rate/confirm",
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
it("POST confirmRate should throw an error", async () => {
|
|
101
|
-
const body = {
|
|
87
|
+
e,
|
|
88
|
+
a
|
|
89
|
+
), expect(c.data).toEqual(r);
|
|
90
|
+
}), it("POST confirmRate should throw an error", async () => {
|
|
91
|
+
const e = {
|
|
102
92
|
tokenIn: "tokenIn",
|
|
103
93
|
tokenOut: "tokenOut",
|
|
104
94
|
fee: "100",
|
|
@@ -108,22 +98,18 @@ describe("confirmRate", () => {
|
|
|
108
98
|
toChainId: "44",
|
|
109
99
|
sender: "0x123",
|
|
110
100
|
receiver: "0x456",
|
|
111
|
-
provider:
|
|
101
|
+
provider: s.None,
|
|
112
102
|
orderId: "123"
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const config = {
|
|
116
|
-
baseURL: url,
|
|
103
|
+
}, t = "", a = {
|
|
104
|
+
baseURL: o,
|
|
117
105
|
headers: {}
|
|
118
106
|
};
|
|
119
|
-
|
|
120
|
-
await expect(confirmRate({ url, nativeAuthToken, body })).rejects.toThrow(
|
|
107
|
+
n.post.mockRejectedValue(new Error("error")), await expect(i({ url: o, nativeAuthToken: t, body: e })).rejects.toThrow(
|
|
121
108
|
"error"
|
|
122
|
-
)
|
|
123
|
-
expect(mockedAxios.post).toHaveBeenCalledWith(
|
|
109
|
+
), expect(n.post).toHaveBeenCalledWith(
|
|
124
110
|
"/rate/confirm",
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
e,
|
|
112
|
+
a
|
|
127
113
|
);
|
|
128
114
|
});
|
|
129
115
|
});
|
|
@@ -1,44 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const axios = require("axios");
|
|
4
|
-
const types_chainType = require("../../types/chainType.js");
|
|
5
|
-
const api_getChains = require("../getChains.js");
|
|
6
|
-
jest.mock("axios");
|
|
7
|
-
const mockedAxios = axios;
|
|
8
|
-
describe("getChains", () => {
|
|
9
|
-
const url = "https://api.example.com";
|
|
10
|
-
it("fetches chains successfully", async () => {
|
|
11
|
-
const response = [
|
|
12
|
-
{
|
|
13
|
-
chainId: "1",
|
|
14
|
-
chainName: "msx",
|
|
15
|
-
pngUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.png",
|
|
16
|
-
svgUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.svg",
|
|
17
|
-
chainType: types_chainType.ChainType.evm,
|
|
18
|
-
rpc: "rpc1",
|
|
19
|
-
blockExplorerUrls: ["explorer1"],
|
|
20
|
-
nativeCurrency: {
|
|
21
|
-
name: "Currency One",
|
|
22
|
-
symbol: "CUR1",
|
|
23
|
-
decimals: 18,
|
|
24
|
-
icon: "icon1"
|
|
25
|
-
},
|
|
26
|
-
networkName: "Network One"
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
mockedAxios.get.mockResolvedValue({ data: response });
|
|
30
|
-
const result = await api_getChains.getChains({
|
|
31
|
-
url,
|
|
32
|
-
nativeAuthToken: "ZKssadass",
|
|
33
|
-
bridgeOnly: false
|
|
34
|
-
});
|
|
35
|
-
expect(mockedAxios.get).toHaveBeenCalled();
|
|
36
|
-
expect(result.data).toEqual(response);
|
|
37
|
-
});
|
|
38
|
-
it("handles error when fetching chains", async () => {
|
|
39
|
-
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
40
|
-
await expect(
|
|
41
|
-
api_getChains.getChains({ url, nativeAuthToken: "ZKssadass", bridgeOnly: false })
|
|
42
|
-
).rejects.toThrow("Network Error");
|
|
43
|
-
});
|
|
44
|
-
});
|
|
2
|
+
"use strict";const o=require("axios"),a=require("../../types/chainType.js"),n=require("../getChains.js");jest.mock("axios");const e=o;describe("getChains",()=>{const t="https://api.example.com";it("fetches chains successfully",async()=>{const s=[{chainId:"1",chainName:"msx",pngUrl:"https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.png",svgUrl:"https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.svg",chainType:a.ChainType.evm,rpc:"rpc1",blockExplorerUrls:["explorer1"],nativeCurrency:{name:"Currency One",symbol:"CUR1",decimals:18,icon:"icon1"},networkName:"Network One"}];e.get.mockResolvedValue({data:s});const r=await n.getChains({url:t,nativeAuthToken:"ZKssadass",bridgeOnly:!1});expect(e.get).toHaveBeenCalled(),expect(r.data).toEqual(s)}),it("handles error when fetching chains",async()=>{e.get.mockRejectedValue(new Error("Network Error")),await expect(n.getChains({url:t,nativeAuthToken:"ZKssadass",bridgeOnly:!1})).rejects.toThrow("Network Error")})});
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ChainType } from "../../types/chainType.mjs";
|
|
3
|
-
import { getChains } from "../getChains.mjs";
|
|
1
|
+
import a from "axios";
|
|
2
|
+
import { ChainType as n } from "../../types/chainType.mjs";
|
|
3
|
+
import { getChains as o } from "../getChains.mjs";
|
|
4
4
|
jest.mock("axios");
|
|
5
|
-
const
|
|
5
|
+
const e = a;
|
|
6
6
|
describe("getChains", () => {
|
|
7
|
-
const
|
|
7
|
+
const t = "https://api.example.com";
|
|
8
8
|
it("fetches chains successfully", async () => {
|
|
9
|
-
const
|
|
9
|
+
const s = [
|
|
10
10
|
{
|
|
11
11
|
chainId: "1",
|
|
12
12
|
chainName: "msx",
|
|
13
13
|
pngUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.png",
|
|
14
14
|
svgUrl: "https://devnet-tools.multiversx.com/liquidity-sdk/ethereum/icon.svg",
|
|
15
|
-
chainType:
|
|
15
|
+
chainType: n.evm,
|
|
16
16
|
rpc: "rpc1",
|
|
17
17
|
blockExplorerUrls: ["explorer1"],
|
|
18
18
|
nativeCurrency: {
|
|
@@ -24,19 +24,16 @@ describe("getChains", () => {
|
|
|
24
24
|
networkName: "Network One"
|
|
25
25
|
}
|
|
26
26
|
];
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
url,
|
|
27
|
+
e.get.mockResolvedValue({ data: s });
|
|
28
|
+
const r = await o({
|
|
29
|
+
url: t,
|
|
30
30
|
nativeAuthToken: "ZKssadass",
|
|
31
|
-
bridgeOnly:
|
|
31
|
+
bridgeOnly: !1
|
|
32
32
|
});
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
mockedAxios.get.mockRejectedValue(new Error("Network Error"));
|
|
38
|
-
await expect(
|
|
39
|
-
getChains({ url, nativeAuthToken: "ZKssadass", bridgeOnly: false })
|
|
33
|
+
expect(e.get).toHaveBeenCalled(), expect(r.data).toEqual(s);
|
|
34
|
+
}), it("handles error when fetching chains", async () => {
|
|
35
|
+
e.get.mockRejectedValue(new Error("Network Error")), await expect(
|
|
36
|
+
o({ url: t, nativeAuthToken: "ZKssadass", bridgeOnly: !1 })
|
|
40
37
|
).rejects.toThrow("Network Error");
|
|
41
38
|
});
|
|
42
39
|
});
|
|
@@ -1,88 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const axios = require("axios");
|
|
4
|
-
const types_providerType = require("../../types/providerType.js");
|
|
5
|
-
const api_getRate = require("../getRate.js");
|
|
6
|
-
jest.mock("axios");
|
|
7
|
-
const mockedAxios = axios;
|
|
8
|
-
describe("getRate", () => {
|
|
9
|
-
const url = "https://api.example.com";
|
|
10
|
-
it("POST rate successfully", async () => {
|
|
11
|
-
const body = {
|
|
12
|
-
tokenIn: "wUSDC",
|
|
13
|
-
tokenOut: "wETH",
|
|
14
|
-
fromChainId: "97",
|
|
15
|
-
toChainId: "44",
|
|
16
|
-
amountIn: "1000000000000000000"
|
|
17
|
-
};
|
|
18
|
-
const nativeAuthToken = "ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01";
|
|
19
|
-
const config = {
|
|
20
|
-
baseURL: url,
|
|
21
|
-
headers: {
|
|
22
|
-
Authorization: `Bearer ${nativeAuthToken}`,
|
|
23
|
-
origin: "https://devnet.template-dapp.multiversx.com"
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const response = {
|
|
27
|
-
fee: "5",
|
|
28
|
-
amountOut: "100",
|
|
29
|
-
provider: types_providerType.ProviderType.None,
|
|
30
|
-
orderId: "123"
|
|
31
|
-
};
|
|
32
|
-
mockedAxios.post.mockResolvedValue({ data: response });
|
|
33
|
-
const result = await api_getRate.getRate({
|
|
34
|
-
url,
|
|
35
|
-
nativeAuthToken,
|
|
36
|
-
body
|
|
37
|
-
});
|
|
38
|
-
expect(mockedAxios.post).toHaveBeenCalledWith("/rate", body, config);
|
|
39
|
-
expect(result.data).toBe(response);
|
|
40
|
-
});
|
|
41
|
-
it("POST rate with no nativeAuthToken", async () => {
|
|
42
|
-
const body = {
|
|
43
|
-
tokenIn: "wUSDC",
|
|
44
|
-
tokenOut: "wETH",
|
|
45
|
-
fromChainId: "97",
|
|
46
|
-
toChainId: "44",
|
|
47
|
-
amountIn: "1000000000000000000"
|
|
48
|
-
};
|
|
49
|
-
const nativeAuthToken = "";
|
|
50
|
-
const config = {
|
|
51
|
-
baseURL: url,
|
|
52
|
-
headers: {}
|
|
53
|
-
};
|
|
54
|
-
const response = {
|
|
55
|
-
fee: "5",
|
|
56
|
-
amountOut: "100",
|
|
57
|
-
provider: types_providerType.ProviderType.None,
|
|
58
|
-
orderId: "123"
|
|
59
|
-
};
|
|
60
|
-
mockedAxios.post.mockResolvedValue({ data: response });
|
|
61
|
-
const result = await api_getRate.getRate({
|
|
62
|
-
url,
|
|
63
|
-
nativeAuthToken,
|
|
64
|
-
body
|
|
65
|
-
});
|
|
66
|
-
expect(mockedAxios.post).toHaveBeenCalledWith("/rate", body, config);
|
|
67
|
-
expect(result.data).toBe(response);
|
|
68
|
-
});
|
|
69
|
-
it("POST rate should throw an error", async () => {
|
|
70
|
-
const body = {
|
|
71
|
-
tokenIn: "wUSDC",
|
|
72
|
-
tokenOut: "wETH",
|
|
73
|
-
fromChainId: "97",
|
|
74
|
-
toChainId: "44",
|
|
75
|
-
amountIn: "1000000000000000000"
|
|
76
|
-
};
|
|
77
|
-
const nativeAuthToken = "";
|
|
78
|
-
const config = {
|
|
79
|
-
baseURL: url,
|
|
80
|
-
headers: {}
|
|
81
|
-
};
|
|
82
|
-
mockedAxios.post.mockRejectedValue(new Error("error"));
|
|
83
|
-
await expect(api_getRate.getRate({ url, nativeAuthToken, body })).rejects.toThrow(
|
|
84
|
-
"error"
|
|
85
|
-
);
|
|
86
|
-
expect(mockedAxios.post).toHaveBeenCalledWith("/rate", body, config);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
2
|
+
"use strict";const i=require("axios"),d=require("../../types/providerType.js"),c=require("../getRate.js");jest.mock("axios");const a=i;describe("getRate",()=>{const t="https://api.example.com";it("POST rate successfully",async()=>{const e={tokenIn:"wUSDC",tokenOut:"wETH",fromChainId:"97",toChainId:"44",amountIn:"1000000000000000000"},o="ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01",n={baseURL:t,headers:{Authorization:`Bearer ${o}`,origin:"https://devnet.template-dapp.multiversx.com"}},s={fee:"5",amountOut:"100",provider:d.ProviderType.None,orderId:"123"};a.post.mockResolvedValue({data:s});const r=await c.getRate({url:t,nativeAuthToken:o,body:e});expect(a.post).toHaveBeenCalledWith("/rate",e,n),expect(r.data).toBe(s)}),it("POST rate with no nativeAuthToken",async()=>{const e={tokenIn:"wUSDC",tokenOut:"wETH",fromChainId:"97",toChainId:"44",amountIn:"1000000000000000000"},o="",n={baseURL:t,headers:{}},s={fee:"5",amountOut:"100",provider:d.ProviderType.None,orderId:"123"};a.post.mockResolvedValue({data:s});const r=await c.getRate({url:t,nativeAuthToken:o,body:e});expect(a.post).toHaveBeenCalledWith("/rate",e,n),expect(r.data).toBe(s)}),it("POST rate should throw an error",async()=>{const e={tokenIn:"wUSDC",tokenOut:"wETH",fromChainId:"97",toChainId:"44",amountIn:"1000000000000000000"},o="",n={baseURL:t,headers:{}};a.post.mockRejectedValue(new Error("error")),await expect(c.getRate({url:t,nativeAuthToken:o,body:e})).rejects.toThrow("error"),expect(a.post).toHaveBeenCalledWith("/rate",e,n)})});
|
|
@@ -1,86 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ProviderType } from "../../types/providerType.mjs";
|
|
3
|
-
import { getRate } from "../getRate.mjs";
|
|
1
|
+
import i from "axios";
|
|
2
|
+
import { ProviderType as d } from "../../types/providerType.mjs";
|
|
3
|
+
import { getRate as c } from "../getRate.mjs";
|
|
4
4
|
jest.mock("axios");
|
|
5
|
-
const
|
|
5
|
+
const a = i;
|
|
6
6
|
describe("getRate", () => {
|
|
7
|
-
const
|
|
7
|
+
const t = "https://api.example.com";
|
|
8
8
|
it("POST rate successfully", async () => {
|
|
9
|
-
const
|
|
9
|
+
const e = {
|
|
10
10
|
tokenIn: "wUSDC",
|
|
11
11
|
tokenOut: "wETH",
|
|
12
12
|
fromChainId: "97",
|
|
13
13
|
toChainId: "44",
|
|
14
14
|
amountIn: "1000000000000000000"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const config = {
|
|
18
|
-
baseURL: url,
|
|
15
|
+
}, o = "ZXJkMXdoOWMwc2pyMnhuOGh6ZjAybHd3Y3I0amsyczg0dGF0OXVkMmthcTZ6cjd4enB2bDlsNXE4YXdtZXg.YUhSMGNITTZMeTlrWlhadVpYUXVkR1Z0Y0d4aGRHVXRaR0Z3Y0M1dGRXeDBhWFpsY25ONExtTnZiUS5lZjc2YjRjNzZlZjZlMTNhNjM5MDc2N2ZjNzhhODhjYTRiYmI1OTE4YTJiOWRkYzQ0OTQyOTI3NjkzNjUwNjUxLjg2NDAwLmV5SjBhVzFsYzNSaGJYQWlPakUzTXpNME9EazBNREI5.04a986df7f0142837f9b1ca1ae4829f7b471e4c3470602ca6a16f2a4d7c6616c4e7628a93b4ce87d9534e95ab9215f893faeb9e0904e1d834007c16e43b12d01", n = {
|
|
16
|
+
baseURL: t,
|
|
19
17
|
headers: {
|
|
20
|
-
Authorization: `Bearer ${
|
|
18
|
+
Authorization: `Bearer ${o}`,
|
|
21
19
|
origin: "https://devnet.template-dapp.multiversx.com"
|
|
22
20
|
}
|
|
23
|
-
}
|
|
24
|
-
const response = {
|
|
21
|
+
}, r = {
|
|
25
22
|
fee: "5",
|
|
26
23
|
amountOut: "100",
|
|
27
|
-
provider:
|
|
24
|
+
provider: d.None,
|
|
28
25
|
orderId: "123"
|
|
29
26
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
url,
|
|
33
|
-
nativeAuthToken,
|
|
34
|
-
body
|
|
27
|
+
a.post.mockResolvedValue({ data: r });
|
|
28
|
+
const s = await c({
|
|
29
|
+
url: t,
|
|
30
|
+
nativeAuthToken: o,
|
|
31
|
+
body: e
|
|
35
32
|
});
|
|
36
|
-
expect(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
it("POST rate with no nativeAuthToken", async () => {
|
|
40
|
-
const body = {
|
|
33
|
+
expect(a.post).toHaveBeenCalledWith("/rate", e, n), expect(s.data).toBe(r);
|
|
34
|
+
}), it("POST rate with no nativeAuthToken", async () => {
|
|
35
|
+
const e = {
|
|
41
36
|
tokenIn: "wUSDC",
|
|
42
37
|
tokenOut: "wETH",
|
|
43
38
|
fromChainId: "97",
|
|
44
39
|
toChainId: "44",
|
|
45
40
|
amountIn: "1000000000000000000"
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const config = {
|
|
49
|
-
baseURL: url,
|
|
41
|
+
}, o = "", n = {
|
|
42
|
+
baseURL: t,
|
|
50
43
|
headers: {}
|
|
51
|
-
}
|
|
52
|
-
const response = {
|
|
44
|
+
}, r = {
|
|
53
45
|
fee: "5",
|
|
54
46
|
amountOut: "100",
|
|
55
|
-
provider:
|
|
47
|
+
provider: d.None,
|
|
56
48
|
orderId: "123"
|
|
57
49
|
};
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
url,
|
|
61
|
-
nativeAuthToken,
|
|
62
|
-
body
|
|
50
|
+
a.post.mockResolvedValue({ data: r });
|
|
51
|
+
const s = await c({
|
|
52
|
+
url: t,
|
|
53
|
+
nativeAuthToken: o,
|
|
54
|
+
body: e
|
|
63
55
|
});
|
|
64
|
-
expect(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
it("POST rate should throw an error", async () => {
|
|
68
|
-
const body = {
|
|
56
|
+
expect(a.post).toHaveBeenCalledWith("/rate", e, n), expect(s.data).toBe(r);
|
|
57
|
+
}), it("POST rate should throw an error", async () => {
|
|
58
|
+
const e = {
|
|
69
59
|
tokenIn: "wUSDC",
|
|
70
60
|
tokenOut: "wETH",
|
|
71
61
|
fromChainId: "97",
|
|
72
62
|
toChainId: "44",
|
|
73
63
|
amountIn: "1000000000000000000"
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const config = {
|
|
77
|
-
baseURL: url,
|
|
64
|
+
}, o = "", n = {
|
|
65
|
+
baseURL: t,
|
|
78
66
|
headers: {}
|
|
79
67
|
};
|
|
80
|
-
|
|
81
|
-
await expect(getRate({ url, nativeAuthToken, body })).rejects.toThrow(
|
|
68
|
+
a.post.mockRejectedValue(new Error("error")), await expect(c({ url: t, nativeAuthToken: o, body: e })).rejects.toThrow(
|
|
82
69
|
"error"
|
|
83
|
-
);
|
|
84
|
-
expect(mockedAxios.post).toHaveBeenCalledWith("/rate", body, config);
|
|
70
|
+
), expect(a.post).toHaveBeenCalledWith("/rate", e, n);
|
|
85
71
|
});
|
|
86
72
|
});
|