@multiversx/sdk-dapp-liquidity 2.1.0-alpha.0 → 2.1.0-alpha.2
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.js +1 -23
- package/helpers/assertRateConfirmationMatchesIntent.mjs +13 -16
- 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.js +1 -26
- package/helpers/index.mjs +24 -24
- package/helpers/safeImageUrl.js +1 -23
- package/helpers/safeImageUrl.mjs +10 -20
- package/helpers/serializeTransaction.js +1 -8
- package/helpers/serializeTransaction.mjs +3 -5
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.js +1 -63
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +31 -41
- 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.js +1 -48
- package/helpers/tests/safeImageUrl.spec.mjs +28 -43
- package/helpers/tests/serializeTransaction.spec.js +1 -36
- package/helpers/tests/serializeTransaction.spec.mjs +13 -24
- package/index.js +1 -232
- package/index.mjs +196 -196
- package/package.json +5 -4
- package/react.esm-B0AMOHxa.js +73 -0
- package/react.esm-BxvJJ86Q.mjs +9949 -0
- package/reactjs/adapters/SuiAdapter.js +1 -378
- package/reactjs/adapters/SuiAdapter.mjs +160 -217
- 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 -675
- package/reactjs/components/BridgeForm/Deposit.mjs +380 -504
- package/reactjs/components/BridgeForm/Transfer.js +1 -561
- package/reactjs/components/BridgeForm/Transfer.mjs +315 -428
- 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 +33 -65
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -381
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +170 -200
- 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 -35
- package/reactjs/components/Connect/BridgeConnectButton.mjs +20 -20
- 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 -55
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +45 -48
- 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 -43
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +21 -21
- 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 -82
- package/reactjs/components/TokenSelector/components/TokenIcon.mjs +52 -58
- 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 -42
- package/reactjs/context/Web3AppProvider.mjs +34 -36
- 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.js +1 -68
- package/reactjs/hooks/tests/useGenericSignMessage.spec.mjs +23 -38
- package/reactjs/hooks/tests/useSignTransaction.spec.js +1 -195
- package/reactjs/hooks/tests/useSignTransaction.spec.mjs +72 -110
- 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 -167
- package/reactjs/hooks/useBridgeFormik.mjs +110 -155
- 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 -115
- package/reactjs/hooks/useFetchTokens.mjs +80 -108
- package/reactjs/hooks/useGenericSignMessage.js +1 -75
- package/reactjs/hooks/useGenericSignMessage.mjs +44 -64
- 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 -112
- package/reactjs/hooks/useSignTransaction.mjs +50 -76
- 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.js +1 -147
- package/reactjs/init/init.mjs +57 -78
- 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.js +1 -69
- package/reactjs/queries/useGetHistory.query.mjs +53 -57
- package/reactjs/queries/useGetMvxTokensBalances.query.js +1 -66
- package/reactjs/queries/useGetMvxTokensBalances.query.mjs +38 -46
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -81
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +49 -57
- 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.js +1 -9
- package/types/errors.mjs +4 -5
- 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/react.esm-7GsOwMPq.js +0 -11815
- package/react.esm-CU-Iqz8D.mjs +0 -11796
|
@@ -1,196 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
const react = require("@reown/appkit/react");
|
|
4
|
-
const react_esm = require("../../../react.esm-7GsOwMPq.js");
|
|
5
|
-
const wagmi = require("wagmi");
|
|
6
|
-
const reactjs_hooks_useSignTransaction = require("../useSignTransaction.js");
|
|
7
|
-
jest.mock("@reown/appkit-adapter-solana/react", () => ({
|
|
8
|
-
useAppKitConnection: jest.fn(() => ({ connection: null }))
|
|
9
|
-
}));
|
|
10
|
-
jest.mock("@solana/web3.js", () => ({
|
|
11
|
-
PublicKey: jest.fn(),
|
|
12
|
-
Transaction: jest.fn(() => ({ add: jest.fn().mockReturnThis() })),
|
|
13
|
-
TransactionInstruction: jest.fn()
|
|
14
|
-
}));
|
|
15
|
-
const mockUseAppKitProvider = jest.mocked(react.useAppKitProvider);
|
|
16
|
-
const mockUseAppKitAccount = jest.mocked(react.useAppKitAccount);
|
|
17
|
-
const mockUseSendTransaction = jest.mocked(wagmi.useSendTransaction);
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
mockUseSendTransaction.mockReturnValue({
|
|
20
|
-
data: void 0,
|
|
21
|
-
sendTransactionAsync: jest.fn(),
|
|
22
|
-
error: null,
|
|
23
|
-
isError: false,
|
|
24
|
-
isIdle: true,
|
|
25
|
-
isPending: false,
|
|
26
|
-
isSuccess: false,
|
|
27
|
-
reset: jest.fn(),
|
|
28
|
-
sendTransaction: jest.fn(),
|
|
29
|
-
status: "idle",
|
|
30
|
-
variables: void 0,
|
|
31
|
-
context: void 0,
|
|
32
|
-
failureCount: 0,
|
|
33
|
-
failureReason: null,
|
|
34
|
-
isPaused: false,
|
|
35
|
-
submittedAt: 0,
|
|
36
|
-
mutate: jest.fn(),
|
|
37
|
-
mutateAsync: jest.fn()
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
const CONNECTED_SUI_ADDRESS = "0xabc123def456aaa000111222333444555666777888999aaabbbcccdddeeefff00";
|
|
41
|
-
function setupSuiMocks(suiRequest) {
|
|
42
|
-
mockUseAppKitProvider.mockImplementation((namespace) => {
|
|
43
|
-
if (namespace === "sui") {
|
|
44
|
-
return { walletProvider: { request: suiRequest } };
|
|
45
|
-
}
|
|
46
|
-
return { walletProvider: void 0 };
|
|
47
|
-
});
|
|
48
|
-
mockUseAppKitAccount.mockImplementation((opts) => {
|
|
49
|
-
if ((opts == null ? void 0 : opts.namespace) === "sui") {
|
|
50
|
-
return {
|
|
51
|
-
address: CONNECTED_SUI_ADDRESS,
|
|
52
|
-
isConnected: true,
|
|
53
|
-
status: "connected"
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
address: void 0,
|
|
58
|
-
isConnected: false,
|
|
59
|
-
status: "disconnected"
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
describe("useSignTransaction — signSuiTransaction", () => {
|
|
64
|
-
const validBase64 = btoa("valid transaction bytes");
|
|
65
|
-
beforeEach(() => {
|
|
66
|
-
mockUseSendTransaction.mockReturnValue({
|
|
67
|
-
data: void 0,
|
|
68
|
-
sendTransactionAsync: jest.fn(),
|
|
69
|
-
error: null,
|
|
70
|
-
isError: false,
|
|
71
|
-
isIdle: true,
|
|
72
|
-
isPending: false,
|
|
73
|
-
isSuccess: false,
|
|
74
|
-
reset: jest.fn(),
|
|
75
|
-
sendTransaction: jest.fn(),
|
|
76
|
-
status: "idle",
|
|
77
|
-
variables: void 0,
|
|
78
|
-
context: void 0,
|
|
79
|
-
failureCount: 0,
|
|
80
|
-
failureReason: null,
|
|
81
|
-
isPaused: false,
|
|
82
|
-
submittedAt: 0,
|
|
83
|
-
mutate: jest.fn(),
|
|
84
|
-
mutateAsync: jest.fn()
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
it("succeeds with valid base64 payload", async () => {
|
|
88
|
-
const mockRequest = jest.fn().mockResolvedValue({ signature: "sui-sig-ok" });
|
|
89
|
-
setupSuiMocks(mockRequest);
|
|
90
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
91
|
-
const sig = await result.current.sui.signTransaction({
|
|
92
|
-
transaction: validBase64,
|
|
93
|
-
address: CONNECTED_SUI_ADDRESS
|
|
94
|
-
});
|
|
95
|
-
expect(sig).toBe("sui-sig-ok");
|
|
96
|
-
expect(mockRequest).toHaveBeenCalledWith(
|
|
97
|
-
expect.objectContaining({ method: "sui_signTransaction" })
|
|
98
|
-
);
|
|
99
|
-
});
|
|
100
|
-
it("throws when payload is not valid base64", async () => {
|
|
101
|
-
const mockRequest = jest.fn();
|
|
102
|
-
setupSuiMocks(mockRequest);
|
|
103
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
104
|
-
await expect(
|
|
105
|
-
result.current.sui.signTransaction({
|
|
106
|
-
transaction: "not-valid-base64!!!",
|
|
107
|
-
address: CONNECTED_SUI_ADDRESS
|
|
108
|
-
})
|
|
109
|
-
).rejects.toThrow("not valid base64");
|
|
110
|
-
expect(mockRequest).not.toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
it("throws when payload exceeds 32 KiB", async () => {
|
|
113
|
-
const mockRequest = jest.fn();
|
|
114
|
-
setupSuiMocks(mockRequest);
|
|
115
|
-
const largeBytes = new Uint8Array(32 * 1024 + 1);
|
|
116
|
-
const largeBase64 = btoa(String.fromCharCode(...largeBytes));
|
|
117
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
118
|
-
await expect(
|
|
119
|
-
result.current.sui.signTransaction({
|
|
120
|
-
transaction: largeBase64,
|
|
121
|
-
address: CONNECTED_SUI_ADDRESS
|
|
122
|
-
})
|
|
123
|
-
).rejects.toThrow("maximum size");
|
|
124
|
-
expect(mockRequest).not.toHaveBeenCalled();
|
|
125
|
-
});
|
|
126
|
-
it("throws when payload is an empty string", async () => {
|
|
127
|
-
const mockRequest = jest.fn();
|
|
128
|
-
setupSuiMocks(mockRequest);
|
|
129
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
130
|
-
await expect(
|
|
131
|
-
result.current.sui.signTransaction({
|
|
132
|
-
transaction: "",
|
|
133
|
-
address: CONNECTED_SUI_ADDRESS
|
|
134
|
-
})
|
|
135
|
-
).rejects.toThrow("No Sui transaction bytes provided");
|
|
136
|
-
expect(mockRequest).not.toHaveBeenCalled();
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
describe("useSignTransaction — signPSBT", () => {
|
|
140
|
-
it("forwards signInputs verbatim to btcWalletProvider.signPSBT", async () => {
|
|
141
|
-
const mockSignPSBT = jest.fn().mockResolvedValue({ psbt: "signed-psbt" });
|
|
142
|
-
mockUseAppKitProvider.mockImplementation((namespace) => {
|
|
143
|
-
if (namespace === "bip122") {
|
|
144
|
-
return { walletProvider: { signPSBT: mockSignPSBT } };
|
|
145
|
-
}
|
|
146
|
-
return { walletProvider: void 0 };
|
|
147
|
-
});
|
|
148
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
149
|
-
const signInputs = [
|
|
150
|
-
{
|
|
151
|
-
address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
152
|
-
index: 0,
|
|
153
|
-
sighashTypes: [1]
|
|
154
|
-
}
|
|
155
|
-
];
|
|
156
|
-
const params = {
|
|
157
|
-
psbt: "base64psbt==",
|
|
158
|
-
signInputs: [...signInputs],
|
|
159
|
-
broadcast: false
|
|
160
|
-
};
|
|
161
|
-
const originalSignInputs = params.signInputs;
|
|
162
|
-
const psbt = await result.current.bitcoin.signTransaction(params);
|
|
163
|
-
expect(mockSignPSBT).toHaveBeenCalledWith(
|
|
164
|
-
expect.objectContaining({
|
|
165
|
-
signInputs: [
|
|
166
|
-
{
|
|
167
|
-
address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
168
|
-
index: 0,
|
|
169
|
-
sighashTypes: [1]
|
|
170
|
-
}
|
|
171
|
-
]
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
expect(mockSignPSBT).not.toHaveBeenCalledWith(
|
|
175
|
-
expect.objectContaining({ signInputs: [] })
|
|
176
|
-
);
|
|
177
|
-
expect(params.signInputs).toBe(originalSignInputs);
|
|
178
|
-
expect(params.signInputs).toEqual(signInputs);
|
|
179
|
-
expect(psbt).toBe("signed-psbt");
|
|
180
|
-
});
|
|
181
|
-
it("throws when btcWalletProvider is not available", async () => {
|
|
182
|
-
mockUseAppKitProvider.mockImplementation(
|
|
183
|
-
() => ({
|
|
184
|
-
walletProvider: void 0
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
const { result } = react_esm.renderHook(() => reactjs_hooks_useSignTransaction.useSignTransaction());
|
|
188
|
-
await expect(
|
|
189
|
-
result.current.bitcoin.signTransaction({
|
|
190
|
-
psbt: "base64psbt==",
|
|
191
|
-
signInputs: [],
|
|
192
|
-
broadcast: false
|
|
193
|
-
})
|
|
194
|
-
).rejects.toThrow("user is disconnected");
|
|
195
|
-
});
|
|
196
|
-
});
|
|
2
|
+
"use strict";const u=require("@reown/appkit/react"),a=require("../../../react.esm-B0AMOHxa.js"),f=require("wagmi"),i=require("../useSignTransaction.js");jest.mock("@reown/appkit-adapter-solana/react",()=>({useAppKitConnection:jest.fn(()=>({connection:null}))}));jest.mock("@solana/web3.js",()=>({PublicKey:jest.fn(),Transaction:jest.fn(()=>({add:jest.fn().mockReturnThis()})),TransactionInstruction:jest.fn()}));const d=jest.mocked(u.useAppKitProvider),b=jest.mocked(u.useAppKitAccount),l=jest.mocked(f.useSendTransaction);beforeEach(()=>{l.mockReturnValue({data:void 0,sendTransactionAsync:jest.fn(),error:null,isError:!1,isIdle:!0,isPending:!1,isSuccess:!1,reset:jest.fn(),sendTransaction:jest.fn(),status:"idle",variables:void 0,context:void 0,failureCount:0,failureReason:null,isPaused:!1,submittedAt:0,mutate:jest.fn(),mutateAsync:jest.fn()})});const o="0xabc123def456aaa000111222333444555666777888999aaabbbcccdddeeefff00";function r(t){d.mockImplementation(e=>e==="sui"?{walletProvider:{request:t}}:{walletProvider:void 0}),b.mockImplementation(e=>(e==null?void 0:e.namespace)==="sui"?{address:o,isConnected:!0,status:"connected"}:{address:void 0,isConnected:!1,status:"disconnected"})}describe("useSignTransaction — signSuiTransaction",()=>{const t=btoa("valid transaction bytes");beforeEach(()=>{l.mockReturnValue({data:void 0,sendTransactionAsync:jest.fn(),error:null,isError:!1,isIdle:!0,isPending:!1,isSuccess:!1,reset:jest.fn(),sendTransaction:jest.fn(),status:"idle",variables:void 0,context:void 0,failureCount:0,failureReason:null,isPaused:!1,submittedAt:0,mutate:jest.fn(),mutateAsync:jest.fn()})}),it("succeeds with valid base64 payload",async()=>{const e=jest.fn().mockResolvedValue({signature:"sui-sig-ok"});r(e);const{result:s}=a.renderHook(()=>i.useSignTransaction()),n=await s.current.sui.signTransaction({transaction:t,address:o});expect(n).toBe("sui-sig-ok"),expect(e).toHaveBeenCalledWith(expect.objectContaining({method:"sui_signTransaction"}))}),it("throws when payload is not valid base64",async()=>{const e=jest.fn();r(e);const{result:s}=a.renderHook(()=>i.useSignTransaction());await expect(s.current.sui.signTransaction({transaction:"not-valid-base64!!!",address:o})).rejects.toThrow("not valid base64"),expect(e).not.toHaveBeenCalled()}),it("throws when payload exceeds 32 KiB",async()=>{const e=jest.fn();r(e);const s=new Uint8Array(32*1024+1),n=btoa(String.fromCharCode(...s)),{result:c}=a.renderHook(()=>i.useSignTransaction());await expect(c.current.sui.signTransaction({transaction:n,address:o})).rejects.toThrow("maximum size"),expect(e).not.toHaveBeenCalled()}),it("throws when payload is an empty string",async()=>{const e=jest.fn();r(e);const{result:s}=a.renderHook(()=>i.useSignTransaction());await expect(s.current.sui.signTransaction({transaction:"",address:o})).rejects.toThrow("No Sui transaction bytes provided"),expect(e).not.toHaveBeenCalled()})});describe("useSignTransaction — signPSBT",()=>{it("forwards signInputs verbatim to btcWalletProvider.signPSBT",async()=>{const t=jest.fn().mockResolvedValue({psbt:"signed-psbt"});d.mockImplementation(g=>g==="bip122"?{walletProvider:{signPSBT:t}}:{walletProvider:void 0});const{result:e}=a.renderHook(()=>i.useSignTransaction()),s=[{address:"bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",index:0,sighashTypes:[1]}],n={psbt:"base64psbt==",signInputs:[...s],broadcast:!1},c=n.signInputs,p=await e.current.bitcoin.signTransaction(n);expect(t).toHaveBeenCalledWith(expect.objectContaining({signInputs:[{address:"bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",index:0,sighashTypes:[1]}]})),expect(t).not.toHaveBeenCalledWith(expect.objectContaining({signInputs:[]})),expect(n.signInputs).toBe(c),expect(n.signInputs).toEqual(s),expect(p).toBe("signed-psbt")}),it("throws when btcWalletProvider is not available",async()=>{d.mockImplementation(()=>({walletProvider:void 0}));const{result:t}=a.renderHook(()=>i.useSignTransaction());await expect(t.current.bitcoin.signTransaction({psbt:"base64psbt==",signInputs:[],broadcast:!1})).rejects.toThrow("user is disconnected")})});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useAppKitProvider, useAppKitAccount } from "@reown/appkit/react";
|
|
2
|
-
import { r as
|
|
3
|
-
import { useSendTransaction } from "wagmi";
|
|
4
|
-
import { useSignTransaction } from "../useSignTransaction.mjs";
|
|
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
5
|
jest.mock("@reown/appkit-adapter-solana/react", () => ({
|
|
6
6
|
useAppKitConnection: jest.fn(() => ({ connection: null }))
|
|
7
7
|
}));
|
|
@@ -10,18 +10,16 @@ jest.mock("@solana/web3.js", () => ({
|
|
|
10
10
|
Transaction: jest.fn(() => ({ add: jest.fn().mockReturnThis() })),
|
|
11
11
|
TransactionInstruction: jest.fn()
|
|
12
12
|
}));
|
|
13
|
-
const
|
|
14
|
-
const mockUseAppKitAccount = jest.mocked(useAppKitAccount);
|
|
15
|
-
const mockUseSendTransaction = jest.mocked(useSendTransaction);
|
|
13
|
+
const d = jest.mocked(f), b = jest.mocked(m), u = jest.mocked(g);
|
|
16
14
|
beforeEach(() => {
|
|
17
|
-
|
|
15
|
+
u.mockReturnValue({
|
|
18
16
|
data: void 0,
|
|
19
17
|
sendTransactionAsync: jest.fn(),
|
|
20
18
|
error: null,
|
|
21
|
-
isError:
|
|
22
|
-
isIdle:
|
|
23
|
-
isPending:
|
|
24
|
-
isSuccess:
|
|
19
|
+
isError: !1,
|
|
20
|
+
isIdle: !0,
|
|
21
|
+
isPending: !1,
|
|
22
|
+
isSuccess: !1,
|
|
25
23
|
reset: jest.fn(),
|
|
26
24
|
sendTransaction: jest.fn(),
|
|
27
25
|
status: "idle",
|
|
@@ -29,46 +27,35 @@ beforeEach(() => {
|
|
|
29
27
|
context: void 0,
|
|
30
28
|
failureCount: 0,
|
|
31
29
|
failureReason: null,
|
|
32
|
-
isPaused:
|
|
30
|
+
isPaused: !1,
|
|
33
31
|
submittedAt: 0,
|
|
34
32
|
mutate: jest.fn(),
|
|
35
33
|
mutateAsync: jest.fn()
|
|
36
34
|
});
|
|
37
35
|
});
|
|
38
|
-
const
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
address: CONNECTED_SUI_ADDRESS,
|
|
50
|
-
isConnected: true,
|
|
51
|
-
status: "connected"
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
address: void 0,
|
|
56
|
-
isConnected: false,
|
|
57
|
-
status: "disconnected"
|
|
58
|
-
};
|
|
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"
|
|
59
46
|
});
|
|
60
47
|
}
|
|
61
48
|
describe("useSignTransaction — signSuiTransaction", () => {
|
|
62
|
-
const
|
|
49
|
+
const s = btoa("valid transaction bytes");
|
|
63
50
|
beforeEach(() => {
|
|
64
|
-
|
|
51
|
+
u.mockReturnValue({
|
|
65
52
|
data: void 0,
|
|
66
53
|
sendTransactionAsync: jest.fn(),
|
|
67
54
|
error: null,
|
|
68
|
-
isError:
|
|
69
|
-
isIdle:
|
|
70
|
-
isPending:
|
|
71
|
-
isSuccess:
|
|
55
|
+
isError: !1,
|
|
56
|
+
isIdle: !0,
|
|
57
|
+
isPending: !1,
|
|
58
|
+
isSuccess: !1,
|
|
72
59
|
reset: jest.fn(),
|
|
73
60
|
sendTransaction: jest.fn(),
|
|
74
61
|
status: "idle",
|
|
@@ -76,89 +63,69 @@ describe("useSignTransaction — signSuiTransaction", () => {
|
|
|
76
63
|
context: void 0,
|
|
77
64
|
failureCount: 0,
|
|
78
65
|
failureReason: null,
|
|
79
|
-
isPaused:
|
|
66
|
+
isPaused: !1,
|
|
80
67
|
submittedAt: 0,
|
|
81
68
|
mutate: jest.fn(),
|
|
82
69
|
mutateAsync: jest.fn()
|
|
83
70
|
});
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
transaction: validBase64,
|
|
91
|
-
address: CONNECTED_SUI_ADDRESS
|
|
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
|
|
92
77
|
});
|
|
93
|
-
expect(
|
|
94
|
-
expect(mockRequest).toHaveBeenCalledWith(
|
|
78
|
+
expect(n).toBe("sui-sig-ok"), expect(e).toHaveBeenCalledWith(
|
|
95
79
|
expect.objectContaining({ method: "sui_signTransaction" })
|
|
96
80
|
);
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const { result } = renderHook(() => useSignTransaction());
|
|
81
|
+
}), it("throws when payload is not valid base64", async () => {
|
|
82
|
+
const e = jest.fn();
|
|
83
|
+
r(e);
|
|
84
|
+
const { result: t } = a(() => i());
|
|
102
85
|
await expect(
|
|
103
|
-
|
|
86
|
+
t.current.sui.signTransaction({
|
|
104
87
|
transaction: "not-valid-base64!!!",
|
|
105
|
-
address:
|
|
88
|
+
address: o
|
|
106
89
|
})
|
|
107
|
-
).rejects.toThrow("not valid base64");
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
setupSuiMocks(mockRequest);
|
|
113
|
-
const largeBytes = new Uint8Array(32 * 1024 + 1);
|
|
114
|
-
const largeBase64 = btoa(String.fromCharCode(...largeBytes));
|
|
115
|
-
const { result } = renderHook(() => useSignTransaction());
|
|
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());
|
|
116
95
|
await expect(
|
|
117
|
-
|
|
118
|
-
transaction:
|
|
119
|
-
address:
|
|
96
|
+
c.current.sui.signTransaction({
|
|
97
|
+
transaction: n,
|
|
98
|
+
address: o
|
|
120
99
|
})
|
|
121
|
-
).rejects.toThrow("maximum size");
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
setupSuiMocks(mockRequest);
|
|
127
|
-
const { result } = renderHook(() => useSignTransaction());
|
|
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());
|
|
128
105
|
await expect(
|
|
129
|
-
|
|
106
|
+
t.current.sui.signTransaction({
|
|
130
107
|
transaction: "",
|
|
131
|
-
address:
|
|
108
|
+
address: o
|
|
132
109
|
})
|
|
133
|
-
).rejects.toThrow("No Sui transaction bytes provided");
|
|
134
|
-
expect(mockRequest).not.toHaveBeenCalled();
|
|
110
|
+
).rejects.toThrow("No Sui transaction bytes provided"), expect(e).not.toHaveBeenCalled();
|
|
135
111
|
});
|
|
136
112
|
});
|
|
137
113
|
describe("useSignTransaction — signPSBT", () => {
|
|
138
114
|
it("forwards signInputs verbatim to btcWalletProvider.signPSBT", async () => {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return { walletProvider: { signPSBT: mockSignPSBT } };
|
|
143
|
-
}
|
|
144
|
-
return { walletProvider: void 0 };
|
|
145
|
-
});
|
|
146
|
-
const { result } = renderHook(() => useSignTransaction());
|
|
147
|
-
const signInputs = [
|
|
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 = [
|
|
148
118
|
{
|
|
149
119
|
address: "bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh",
|
|
150
120
|
index: 0,
|
|
151
121
|
sighashTypes: [1]
|
|
152
122
|
}
|
|
153
|
-
]
|
|
154
|
-
const params = {
|
|
123
|
+
], n = {
|
|
155
124
|
psbt: "base64psbt==",
|
|
156
|
-
signInputs: [...
|
|
157
|
-
broadcast:
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const psbt = await result.current.bitcoin.signTransaction(params);
|
|
161
|
-
expect(mockSignPSBT).toHaveBeenCalledWith(
|
|
125
|
+
signInputs: [...t],
|
|
126
|
+
broadcast: !1
|
|
127
|
+
}, c = n.signInputs, l = await e.current.bitcoin.signTransaction(n);
|
|
128
|
+
expect(s).toHaveBeenCalledWith(
|
|
162
129
|
expect.objectContaining({
|
|
163
130
|
signInputs: [
|
|
164
131
|
{
|
|
@@ -168,26 +135,21 @@ describe("useSignTransaction — signPSBT", () => {
|
|
|
168
135
|
}
|
|
169
136
|
]
|
|
170
137
|
})
|
|
171
|
-
)
|
|
172
|
-
expect(mockSignPSBT).not.toHaveBeenCalledWith(
|
|
138
|
+
), expect(s).not.toHaveBeenCalledWith(
|
|
173
139
|
expect.objectContaining({ signInputs: [] })
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
expect(psbt).toBe("signed-psbt");
|
|
178
|
-
});
|
|
179
|
-
it("throws when btcWalletProvider is not available", async () => {
|
|
180
|
-
mockUseAppKitProvider.mockImplementation(
|
|
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(
|
|
181
143
|
() => ({
|
|
182
144
|
walletProvider: void 0
|
|
183
145
|
})
|
|
184
146
|
);
|
|
185
|
-
const { result } =
|
|
147
|
+
const { result: s } = a(() => i());
|
|
186
148
|
await expect(
|
|
187
|
-
|
|
149
|
+
s.current.bitcoin.signTransaction({
|
|
188
150
|
psbt: "base64psbt==",
|
|
189
151
|
signInputs: [],
|
|
190
|
-
broadcast:
|
|
152
|
+
broadcast: !1
|
|
191
153
|
})
|
|
192
154
|
).rejects.toThrow("user is disconnected");
|
|
193
155
|
});
|
|
@@ -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;
|