@multiversx/sdk-dapp-liquidity 0.2.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/README.md +186 -0
- package/all-networks-EJIVYZ_i.mjs +4 -0
- package/all-networks-NYACMyeN.js +4 -0
- package/api/confirmRate.d.ts +11 -0
- package/api/confirmRate.js +30 -0
- package/api/confirmRate.mjs +29 -0
- package/api/getChains.d.ts +6 -0
- package/api/getChains.js +12 -0
- package/api/getChains.mjs +11 -0
- package/api/getRate.d.ts +10 -0
- package/api/getRate.js +28 -0
- package/api/getRate.mjs +27 -0
- package/api/getTokens.d.ts +7 -0
- package/api/getTokens.js +14 -0
- package/api/getTokens.mjs +13 -0
- package/api/getTokensBalances.d.ts +8 -0
- package/api/getTokensBalances.js +17 -0
- package/api/getTokensBalances.mjs +16 -0
- package/api/getTransactions.d.ts +7 -0
- package/api/getTransactions.js +14 -0
- package/api/getTransactions.mjs +13 -0
- package/api/index.d.ts +7 -0
- package/api/index.js +17 -0
- package/api/index.mjs +16 -0
- package/api/sendTransactions.d.ts +11 -0
- package/api/sendTransactions.js +29 -0
- package/api/sendTransactions.mjs +28 -0
- package/api/tests/confirmRate.spec.d.ts +1 -0
- package/api/tests/confirmRate.spec.js +124 -0
- package/api/tests/confirmRate.spec.mjs +122 -0
- package/api/tests/getChains.spec.d.ts +1 -0
- package/api/tests/getChains.spec.js +37 -0
- package/api/tests/getChains.spec.mjs +35 -0
- package/api/tests/getRate.spec.d.ts +1 -0
- package/api/tests/getRate.spec.js +83 -0
- package/api/tests/getRate.spec.mjs +81 -0
- package/api/tests/getTokens.spec.d.ts +1 -0
- package/api/tests/getTokens.spec.js +60 -0
- package/api/tests/getTokens.spec.mjs +58 -0
- package/api/tests/getTransactions.spec.d.ts +1 -0
- package/api/tests/getTransactions.spec.js +89 -0
- package/api/tests/getTransactions.spec.mjs +87 -0
- package/api/tests/sendTransactions.spec.d.ts +1 -0
- package/api/tests/sendTransactions.spec.js +83 -0
- package/api/tests/sendTransactions.spec.mjs +81 -0
- package/bignumber-B8vjg9qn.js +1334 -0
- package/bignumber-CKZkoo0g.mjs +1334 -0
- package/constants/index.d.ts +1 -0
- package/constants/index.js +5 -0
- package/constants/index.mjs +4 -0
- package/default-BYtXv70Z.mjs +4 -0
- package/default-H3AbmzFV.js +4 -0
- package/dto/Chain.dto.d.ts +16 -0
- package/dto/Chain.dto.js +2 -0
- package/dto/Chain.dto.mjs +1 -0
- package/dto/ConfirmRate.dto.d.ts +11 -0
- package/dto/ConfirmRate.dto.js +2 -0
- package/dto/ConfirmRate.dto.mjs +1 -0
- package/dto/Token.dto.d.ts +14 -0
- package/dto/Token.dto.js +2 -0
- package/dto/Token.dto.mjs +1 -0
- package/dto/TokenBalance.dto.d.ts +4 -0
- package/dto/TokenBalance.dto.js +2 -0
- package/dto/TokenBalance.dto.mjs +1 -0
- package/dto/Transaction.dto.d.ts +14 -0
- package/dto/Transaction.dto.js +2 -0
- package/dto/Transaction.dto.mjs +1 -0
- package/dto/index.d.ts +5 -0
- package/dto/index.js +2 -0
- package/dto/index.mjs +1 -0
- package/helpers/base64Utils.d.ts +3 -0
- package/helpers/base64Utils.js +32 -0
- package/helpers/base64Utils.mjs +31 -0
- package/helpers/decodeLoginToken.d.ts +9 -0
- package/helpers/decodeLoginToken.js +28 -0
- package/helpers/decodeLoginToken.mjs +27 -0
- package/helpers/decodeToken.d.ts +11 -0
- package/helpers/decodeToken.js +40 -0
- package/helpers/decodeToken.mjs +39 -0
- package/helpers/getApiURL.d.ts +1 -0
- package/helpers/getApiURL.js +8 -0
- package/helpers/getApiURL.mjs +7 -0
- package/helpers/getBridgeURL.d.ts +1 -0
- package/helpers/getBridgeURL.js +8 -0
- package/helpers/getBridgeURL.mjs +7 -0
- package/helpers/getMvxApiURL.d.ts +1 -0
- package/helpers/getMvxApiURL.js +8 -0
- package/helpers/getMvxApiURL.mjs +7 -0
- package/helpers/getMvxChainId.d.ts +1 -0
- package/helpers/getMvxChainId.js +8 -0
- package/helpers/getMvxChainId.mjs +7 -0
- package/helpers/getMvxExplorerAddress.d.ts +1 -0
- package/helpers/getMvxExplorerAddress.js +8 -0
- package/helpers/getMvxExplorerAddress.mjs +7 -0
- package/helpers/index.d.ts +9 -0
- package/helpers/index.js +23 -0
- package/helpers/index.mjs +22 -0
- package/helpers/serializeTransaction.d.ts +3 -0
- package/helpers/serializeTransaction.js +9 -0
- package/helpers/serializeTransaction.mjs +8 -0
- package/helpers/tests/base64Utils.spec.d.ts +1 -0
- package/helpers/tests/base64Utils.spec.js +30 -0
- package/helpers/tests/base64Utils.spec.mjs +28 -0
- package/helpers/tests/decodeLoginToken.spec.d.ts +1 -0
- package/helpers/tests/decodeLoginToken.spec.js +35 -0
- package/helpers/tests/decodeLoginToken.spec.mjs +33 -0
- package/helpers/tests/decodeToken.spec.d.ts +1 -0
- package/helpers/tests/decodeToken.spec.js +28 -0
- package/helpers/tests/decodeToken.spec.mjs +26 -0
- package/index-B9WqxUXM.mjs +91 -0
- package/index-BXwpbIDQ.mjs +107 -0
- package/index-CnudU77V.js +329 -0
- package/index-DSnomXRI.mjs +68025 -0
- package/index-DZHiA1sX.js +107 -0
- package/index-cvy2-uZ_.js +67946 -0
- package/index.d.ts +6 -0
- package/index.js +189 -0
- package/index.mjs +185 -0
- package/package.json +107 -0
- package/react-B9sQBOh0.mjs +3040 -0
- package/react-BaXyw3AO.js +3040 -0
- package/react-CNXJSTCv.js +38 -0
- package/react-CSQpf1zk.mjs +38 -0
- package/reactjs/components/AccountAddress/AccountAddress.d.ts +6 -0
- package/reactjs/components/AccountAddress/AccountAddress.js +25 -0
- package/reactjs/components/AccountAddress/AccountAddress.mjs +24 -0
- package/reactjs/components/AccountAddress/index.d.ts +1 -0
- package/reactjs/components/AccountAddress/index.js +5 -0
- package/reactjs/components/AccountAddress/index.mjs +4 -0
- package/reactjs/components/AmountCard/AmountCard.d.ts +6 -0
- package/reactjs/components/AmountCard/AmountCard.js +33 -0
- package/reactjs/components/AmountCard/AmountCard.mjs +32 -0
- package/reactjs/components/AmountCard/index.d.ts +1 -0
- package/reactjs/components/AmountCard/index.js +5 -0
- package/reactjs/components/AmountCard/index.mjs +4 -0
- package/reactjs/components/AmountInput/AmountInput.d.ts +13 -0
- package/reactjs/components/AmountInput/AmountInput.js +61 -0
- package/reactjs/components/AmountInput/AmountInput.mjs +60 -0
- package/reactjs/components/AmountInput/index.d.ts +1 -0
- package/reactjs/components/AmountInput/index.js +5 -0
- package/reactjs/components/AmountInput/index.mjs +4 -0
- package/reactjs/components/BridgeForm/BridgeForm.d.ts +16 -0
- package/reactjs/components/BridgeForm/BridgeForm.js +680 -0
- package/reactjs/components/BridgeForm/BridgeForm.mjs +679 -0
- package/reactjs/components/BridgeForm/index.d.ts +1 -0
- package/reactjs/components/BridgeForm/index.js +5 -0
- package/reactjs/components/BridgeForm/index.mjs +4 -0
- package/reactjs/components/BridgeHistory/BridgeHistory.d.ts +4 -0
- package/reactjs/components/BridgeHistory/BridgeHistory.js +233 -0
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +232 -0
- package/reactjs/components/BridgeHistory/index.d.ts +1 -0
- package/reactjs/components/BridgeHistory/index.js +5 -0
- package/reactjs/components/BridgeHistory/index.mjs +4 -0
- package/reactjs/components/Connect/BridgeAccountDisplay.d.ts +6 -0
- package/reactjs/components/Connect/BridgeAccountDisplay.js +85 -0
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +84 -0
- package/reactjs/components/Connect/BridgeConnectButton.d.ts +7 -0
- package/reactjs/components/Connect/BridgeConnectButton.js +26 -0
- package/reactjs/components/Connect/BridgeConnectButton.mjs +25 -0
- package/reactjs/components/Connect/CustomConnectButton.d.ts +7 -0
- package/reactjs/components/Connect/CustomConnectButton.js +42 -0
- package/reactjs/components/Connect/CustomConnectButton.mjs +41 -0
- package/reactjs/components/Connect/MvxAccountDisplay.d.ts +9 -0
- package/reactjs/components/Connect/MvxAccountDisplay.js +75 -0
- package/reactjs/components/Connect/MvxAccountDisplay.mjs +74 -0
- package/reactjs/components/Connect/MvxConnectButton.d.ts +11 -0
- package/reactjs/components/Connect/MvxConnectButton.js +43 -0
- package/reactjs/components/Connect/MvxConnectButton.mjs +42 -0
- package/reactjs/components/Connect/SwitchChainButton.d.ts +7 -0
- package/reactjs/components/Connect/SwitchChainButton.js +33 -0
- package/reactjs/components/Connect/SwitchChainButton.mjs +32 -0
- package/reactjs/components/Connect/index.d.ts +6 -0
- package/reactjs/components/Connect/index.js +15 -0
- package/reactjs/components/Connect/index.mjs +14 -0
- package/reactjs/components/CopyButton/CopyButton.d.ts +6 -0
- package/reactjs/components/CopyButton/CopyButton.js +42 -0
- package/reactjs/components/CopyButton/CopyButton.mjs +41 -0
- package/reactjs/components/CopyButton/index.d.ts +1 -0
- package/reactjs/components/CopyButton/index.js +5 -0
- package/reactjs/components/CopyButton/index.mjs +4 -0
- package/reactjs/components/CopyButton/utils/copyToClipboard.d.ts +1 -0
- package/reactjs/components/CopyButton/utils/copyToClipboard.js +38 -0
- package/reactjs/components/CopyButton/utils/copyToClipboard.mjs +37 -0
- package/reactjs/components/CopyButton/utils/index.d.ts +1 -0
- package/reactjs/components/CopyButton/utils/index.js +5 -0
- package/reactjs/components/CopyButton/utils/index.mjs +4 -0
- package/reactjs/components/DisplayAmount/DisplayAmount.d.ts +21 -0
- package/reactjs/components/DisplayAmount/DisplayAmount.js +91 -0
- package/reactjs/components/DisplayAmount/DisplayAmount.mjs +90 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.d.ts +7 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.js +40 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/AnimateNumber.mjs +39 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/index.d.ts +0 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/index.js +2 -0
- package/reactjs/components/DisplayAmount/components/AnimateNumber/index.mjs +1 -0
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.d.ts +14 -0
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.js +62 -0
- package/reactjs/components/DisplayAmount/components/PrecisedAmount/PrecisedAmount.mjs +61 -0
- package/reactjs/components/DisplayAmount/components/index.d.ts +0 -0
- package/reactjs/components/DisplayAmount/components/index.js +2 -0
- package/reactjs/components/DisplayAmount/components/index.mjs +1 -0
- package/reactjs/components/DisplayAmount/index.d.ts +1 -0
- package/reactjs/components/DisplayAmount/index.js +5 -0
- package/reactjs/components/DisplayAmount/index.mjs +4 -0
- package/reactjs/components/DisplayAmount/utils/index.d.ts +1 -0
- package/reactjs/components/DisplayAmount/utils/index.js +5 -0
- package/reactjs/components/DisplayAmount/utils/index.mjs +4 -0
- package/reactjs/components/DisplayAmount/utils/truncateAmount.d.ts +1 -0
- package/reactjs/components/DisplayAmount/utils/truncateAmount.js +22 -0
- package/reactjs/components/DisplayAmount/utils/truncateAmount.mjs +21 -0
- package/reactjs/components/SmallLoader/SmallLoader.d.ts +4 -0
- package/reactjs/components/SmallLoader/SmallLoader.js +22 -0
- package/reactjs/components/SmallLoader/SmallLoader.mjs +21 -0
- package/reactjs/components/SmallLoader/index.d.ts +1 -0
- package/reactjs/components/SmallLoader/index.js +5 -0
- package/reactjs/components/SmallLoader/index.mjs +4 -0
- package/reactjs/components/TokenSelector/TokenSelector.d.ts +16 -0
- package/reactjs/components/TokenSelector/TokenSelector.js +158 -0
- package/reactjs/components/TokenSelector/TokenSelector.mjs +157 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.d.ts +8 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +86 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +85 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.d.ts +11 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.js +45 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/ChainOptionLabel.mjs +44 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.d.ts +6 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.js +19 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/FormatChainOptionLabel.mjs +18 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.d.ts +3 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.js +7 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/IndicatorSeparator.mjs +6 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.d.ts +4 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.js +33 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/components/SelectedChainOption.mjs +32 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/chainSelectOption.d.ts +10 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/chainSelectOption.js +2 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/chainSelectOption.mjs +1 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/partialChainOption.d.ts +10 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/partialChainOption.js +2 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/types/partialChainOption.mjs +1 -0
- package/reactjs/components/TokenSelector/components/SelectContainer.d.ts +7 -0
- package/reactjs/components/TokenSelector/components/SelectContainer.js +41 -0
- package/reactjs/components/TokenSelector/components/SelectContainer.mjs +40 -0
- package/reactjs/components/TokenSelector/components/SelectContent.d.ts +10 -0
- package/reactjs/components/TokenSelector/components/SelectContent.js +93 -0
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +92 -0
- package/reactjs/components/TokenSelector/components/SelectedOption.d.ts +5 -0
- package/reactjs/components/TokenSelector/components/SelectedOption.js +29 -0
- package/reactjs/components/TokenSelector/components/SelectedOption.mjs +28 -0
- package/reactjs/components/TokenSelector/components/TokenIcon.d.ts +8 -0
- package/reactjs/components/TokenSelector/components/TokenIcon.js +82 -0
- package/reactjs/components/TokenSelector/components/TokenIcon.mjs +81 -0
- package/reactjs/components/TokenSelector/components/TokenItem.d.ts +7 -0
- package/reactjs/components/TokenSelector/components/TokenItem.js +69 -0
- package/reactjs/components/TokenSelector/components/TokenItem.mjs +68 -0
- package/reactjs/components/TokenSelector/components/TokenList.d.ts +7 -0
- package/reactjs/components/TokenSelector/components/TokenList.js +21 -0
- package/reactjs/components/TokenSelector/components/TokenList.mjs +20 -0
- package/reactjs/components/TokenSelector/components/TokenSymbol.d.ts +9 -0
- package/reactjs/components/TokenSelector/components/TokenSymbol.js +26 -0
- package/reactjs/components/TokenSelector/components/TokenSymbol.mjs +25 -0
- package/reactjs/components/TokenSelector/index.d.ts +1 -0
- package/reactjs/components/TokenSelector/index.js +5 -0
- package/reactjs/components/TokenSelector/index.mjs +4 -0
- package/reactjs/components/TransactionToast/TransactionToast.d.ts +9 -0
- package/reactjs/components/TransactionToast/TransactionToast.js +54 -0
- package/reactjs/components/TransactionToast/TransactionToast.mjs +53 -0
- package/reactjs/components/TransactionToast/TransactionToastContainer.d.ts +3 -0
- package/reactjs/components/TransactionToast/TransactionToastContainer.js +21 -0
- package/reactjs/components/TransactionToast/TransactionToastContainer.mjs +20 -0
- package/reactjs/components/TransactionToast/index.d.ts +2 -0
- package/reactjs/components/TransactionToast/index.js +7 -0
- package/reactjs/components/TransactionToast/index.mjs +6 -0
- package/reactjs/components/TrimAddress/TrimAddress.d.ts +8 -0
- package/reactjs/components/TrimAddress/TrimAddress.js +26 -0
- package/reactjs/components/TrimAddress/TrimAddress.mjs +25 -0
- package/reactjs/components/TrimAddress/index.d.ts +1 -0
- package/reactjs/components/TrimAddress/index.js +5 -0
- package/reactjs/components/TrimAddress/index.mjs +4 -0
- package/reactjs/components/base/MxButton/MxButton.d.ts +13 -0
- package/reactjs/components/base/MxButton/MxButton.js +72 -0
- package/reactjs/components/base/MxButton/MxButton.mjs +71 -0
- package/reactjs/components/base/MxButton/index.d.ts +1 -0
- package/reactjs/components/base/MxButton/index.js +5 -0
- package/reactjs/components/base/MxButton/index.mjs +4 -0
- package/reactjs/components/base/MxCard/MxCard.d.ts +10 -0
- package/reactjs/components/base/MxCard/MxCard.js +55 -0
- package/reactjs/components/base/MxCard/MxCard.mjs +54 -0
- package/reactjs/components/base/MxCard/index.d.ts +1 -0
- package/reactjs/components/base/MxCard/index.js +5 -0
- package/reactjs/components/base/MxCard/index.mjs +4 -0
- package/reactjs/components/base/MxLink/MxLink.d.ts +10 -0
- package/reactjs/components/base/MxLink/MxLink.js +71 -0
- package/reactjs/components/base/MxLink/MxLink.mjs +70 -0
- package/reactjs/components/base/MxLink/index.d.ts +1 -0
- package/reactjs/components/base/MxLink/index.js +5 -0
- package/reactjs/components/base/MxLink/index.mjs +4 -0
- package/reactjs/components/base/MxSearch/MxSearch.d.ts +10 -0
- package/reactjs/components/base/MxSearch/MxSearch.js +70 -0
- package/reactjs/components/base/MxSearch/MxSearch.mjs +69 -0
- package/reactjs/components/base/MxSearch/index.d.ts +1 -0
- package/reactjs/components/base/MxSearch/index.js +5 -0
- package/reactjs/components/base/MxSearch/index.mjs +4 -0
- package/reactjs/components/base/MxSlideover/MxSlideover.d.ts +10 -0
- package/reactjs/components/base/MxSlideover/MxSlideover.js +79 -0
- package/reactjs/components/base/MxSlideover/MxSlideover.mjs +78 -0
- package/reactjs/components/base/MxSlideover/index.d.ts +1 -0
- package/reactjs/components/base/MxSlideover/index.js +5 -0
- package/reactjs/components/base/MxSlideover/index.mjs +4 -0
- package/reactjs/components/base/MxTooltip/MxTooltip.d.ts +23 -0
- package/reactjs/components/base/MxTooltip/MxTooltip.js +163 -0
- package/reactjs/components/base/MxTooltip/MxTooltip.mjs +162 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.d.ts +11 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.js +34 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs +33 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.d.ts +1 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.js +5 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContainer/index.mjs +4 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.d.ts +13 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.js +28 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/TooltipContent.mjs +27 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.d.ts +1 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.js +5 -0
- package/reactjs/components/base/MxTooltip/components/TooltipContent/index.mjs +4 -0
- package/reactjs/components/base/MxTooltip/components/index.d.ts +2 -0
- package/reactjs/components/base/MxTooltip/components/index.js +7 -0
- package/reactjs/components/base/MxTooltip/components/index.mjs +6 -0
- package/reactjs/components/base/MxTooltip/index.d.ts +1 -0
- package/reactjs/components/base/MxTooltip/index.js +5 -0
- package/reactjs/components/base/MxTooltip/index.mjs +4 -0
- package/reactjs/components/base/index.d.ts +6 -0
- package/reactjs/components/base/index.js +15 -0
- package/reactjs/components/base/index.mjs +14 -0
- package/reactjs/components/index.d.ts +13 -0
- package/reactjs/components/index.js +51 -0
- package/reactjs/components/index.mjs +50 -0
- package/reactjs/constants/chains.d.ts +35 -0
- package/reactjs/constants/chains.js +38 -0
- package/reactjs/constants/chains.mjs +37 -0
- package/reactjs/constants/index.d.ts +3 -0
- package/reactjs/constants/index.js +12 -0
- package/reactjs/constants/index.mjs +11 -0
- package/reactjs/context/Web3AppProvider.d.ts +12 -0
- package/reactjs/context/Web3AppProvider.js +29 -0
- package/reactjs/context/Web3AppProvider.mjs +28 -0
- package/reactjs/context/queryClient.d.ts +3 -0
- package/reactjs/context/queryClient.js +12 -0
- package/reactjs/context/queryClient.mjs +11 -0
- package/reactjs/context/useWeb3App.d.ts +1 -0
- package/reactjs/context/useWeb3App.js +13 -0
- package/reactjs/context/useWeb3App.mjs +12 -0
- package/reactjs/hooks/index.d.ts +11 -0
- package/reactjs/hooks/index.js +32 -0
- package/reactjs/hooks/index.mjs +31 -0
- package/reactjs/hooks/useAccount.d.ts +77 -0
- package/reactjs/hooks/useAccount.js +18 -0
- package/reactjs/hooks/useAccount.mjs +17 -0
- package/reactjs/hooks/useBalances.d.ts +10 -0
- package/reactjs/hooks/useBalances.js +7 -0
- package/reactjs/hooks/useBalances.mjs +6 -0
- package/reactjs/hooks/useBridgeFormik.d.ts +98 -0
- package/reactjs/hooks/useBridgeFormik.js +182 -0
- package/reactjs/hooks/useBridgeFormik.mjs +181 -0
- package/reactjs/hooks/useDebounce.d.ts +1 -0
- package/reactjs/hooks/useDebounce.js +14 -0
- package/reactjs/hooks/useDebounce.mjs +13 -0
- package/reactjs/hooks/useFetchBridgeData.d.ts +45 -0
- package/reactjs/hooks/useFetchBridgeData.js +44 -0
- package/reactjs/hooks/useFetchBridgeData.mjs +43 -0
- package/reactjs/hooks/useFetchTokens.d.ts +42 -0
- package/reactjs/hooks/useFetchTokens.js +105 -0
- package/reactjs/hooks/useFetchTokens.mjs +104 -0
- package/reactjs/hooks/useGetChainId.d.ts +1 -0
- package/reactjs/hooks/useGetChainId.js +12 -0
- package/reactjs/hooks/useGetChainId.mjs +11 -0
- package/reactjs/hooks/useResolveTokenChain.d.ts +9 -0
- package/reactjs/hooks/useResolveTokenChain.js +21 -0
- package/reactjs/hooks/useResolveTokenChain.mjs +20 -0
- package/reactjs/hooks/useSendTransactions.d.ts +3 -0
- package/reactjs/hooks/useSendTransactions.js +19 -0
- package/reactjs/hooks/useSendTransactions.mjs +18 -0
- package/reactjs/hooks/useSignTransaction.d.ts +69 -0
- package/reactjs/hooks/useSignTransaction.js +17 -0
- package/reactjs/hooks/useSignTransaction.mjs +16 -0
- package/reactjs/hooks/validation/index.d.ts +4 -0
- package/reactjs/hooks/validation/index.js +11 -0
- package/reactjs/hooks/validation/index.mjs +10 -0
- package/reactjs/hooks/validation/useAmountSchema.d.ts +2 -0
- package/reactjs/hooks/validation/useAmountSchema.js +31 -0
- package/reactjs/hooks/validation/useAmountSchema.mjs +13 -0
- package/reactjs/hooks/validation/useSecondAmountSchema.d.ts +2 -0
- package/reactjs/hooks/validation/useSecondAmountSchema.js +27 -0
- package/reactjs/hooks/validation/useSecondAmountSchema.mjs +9 -0
- package/reactjs/hooks/validation/useTestHasEnoughFunds.d.ts +3 -0
- package/reactjs/hooks/validation/useTestHasEnoughFunds.js +38 -0
- package/reactjs/hooks/validation/useTestHasEnoughFunds.mjs +37 -0
- package/reactjs/hooks/validation/useTestIsConnected.d.ts +3 -0
- package/reactjs/hooks/validation/useTestIsConnected.js +21 -0
- package/reactjs/hooks/validation/useTestIsConnected.mjs +20 -0
- package/reactjs/index.d.ts +10 -0
- package/reactjs/index.js +153 -0
- package/reactjs/index.mjs +149 -0
- package/reactjs/init/index.d.ts +1 -0
- package/reactjs/init/index.js +5 -0
- package/reactjs/init/index.mjs +4 -0
- package/reactjs/init/init.d.ts +48 -0
- package/reactjs/init/init.js +53 -0
- package/reactjs/init/init.mjs +35 -0
- package/reactjs/init/tests/init.spec.d.ts +1 -0
- package/reactjs/init/tests/init.spec.js +108 -0
- package/reactjs/init/tests/init.spec.mjs +106 -0
- package/reactjs/queries/index.d.ts +7 -0
- package/reactjs/queries/index.js +20 -0
- package/reactjs/queries/index.mjs +19 -0
- package/reactjs/queries/useGetAllTokens.query.d.ts +3 -0
- package/reactjs/queries/useGetAllTokens.query.js +31 -0
- package/reactjs/queries/useGetAllTokens.query.mjs +30 -0
- package/reactjs/queries/useGetChains.query.d.ts +3 -0
- package/reactjs/queries/useGetChains.query.js +31 -0
- package/reactjs/queries/useGetChains.query.mjs +30 -0
- package/reactjs/queries/useGetEvmTokensBalances.query.d.ts +22 -0
- package/reactjs/queries/useGetEvmTokensBalances.query.js +78 -0
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +77 -0
- package/reactjs/queries/useGetHistory.query.d.ts +4 -0
- package/reactjs/queries/useGetHistory.query.js +47 -0
- package/reactjs/queries/useGetHistory.query.mjs +46 -0
- package/reactjs/queries/useGetMvxTokensBalances.query.d.ts +23 -0
- package/reactjs/queries/useGetMvxTokensBalances.query.js +60 -0
- package/reactjs/queries/useGetMvxTokensBalances.query.mjs +59 -0
- package/reactjs/queries/useGetRate.mutation.d.ts +6 -0
- package/reactjs/queries/useGetRate.mutation.js +19 -0
- package/reactjs/queries/useGetRate.mutation.mjs +18 -0
- package/reactjs/queries/useGetTokens.query.d.ts +3 -0
- package/reactjs/queries/useGetTokens.query.js +34 -0
- package/reactjs/queries/useGetTokens.query.mjs +33 -0
- package/reactjs/reexports.d.ts +6 -0
- package/reactjs/reexports.js +21 -0
- package/reactjs/reexports.mjs +17 -0
- package/reactjs/utils/delay.d.ts +1 -0
- package/reactjs/utils/delay.js +7 -0
- package/reactjs/utils/delay.mjs +6 -0
- package/reactjs/utils/formatAmount.d.ts +7 -0
- package/reactjs/utils/formatAmount.js +24 -0
- package/reactjs/utils/formatAmount.mjs +23 -0
- package/reactjs/utils/getCleanStringAmount.d.ts +4 -0
- package/reactjs/utils/getCleanStringAmount.js +12 -0
- package/reactjs/utils/getCleanStringAmount.mjs +11 -0
- package/reactjs/utils/getCompletePathname.d.ts +1 -0
- package/reactjs/utils/getCompletePathname.js +6 -0
- package/reactjs/utils/getCompletePathname.mjs +5 -0
- package/reactjs/utils/getInitialTokens.d.ts +8 -0
- package/reactjs/utils/getInitialTokens.js +13 -0
- package/reactjs/utils/getInitialTokens.mjs +12 -0
- package/reactjs/utils/hasEnoughFunds.d.ts +5 -0
- package/reactjs/utils/hasEnoughFunds.js +20 -0
- package/reactjs/utils/hasEnoughFunds.mjs +19 -0
- package/reactjs/utils/index.d.ts +12 -0
- package/reactjs/utils/index.js +27 -0
- package/reactjs/utils/index.mjs +26 -0
- package/reactjs/utils/isStringFloat.d.ts +1 -0
- package/reactjs/utils/isStringFloat.js +22 -0
- package/reactjs/utils/isStringFloat.mjs +21 -0
- package/reactjs/utils/mxClsx.d.ts +3 -0
- package/reactjs/utils/mxClsx.js +21 -0
- package/reactjs/utils/mxClsx.mjs +20 -0
- package/reactjs/utils/pipe.d.ts +7 -0
- package/reactjs/utils/pipe.js +26 -0
- package/reactjs/utils/pipe.mjs +25 -0
- package/reactjs/utils/removeCommas.d.ts +1 -0
- package/reactjs/utils/removeCommas.js +7 -0
- package/reactjs/utils/removeCommas.mjs +6 -0
- package/reactjs/utils/roundAmount.d.ts +1 -0
- package/reactjs/utils/roundAmount.js +41 -0
- package/reactjs/utils/roundAmount.mjs +40 -0
- package/reactjs/utils/testNumber.d.ts +1 -0
- package/reactjs/utils/testNumber.js +5 -0
- package/reactjs/utils/testNumber.mjs +4 -0
- package/store/inMemoryStore.d.ts +12 -0
- package/store/inMemoryStore.js +40 -0
- package/store/inMemoryStore.mjs +39 -0
- package/types/batchTransactions.d.ts +6 -0
- package/types/batchTransactions.js +2 -0
- package/types/batchTransactions.mjs +1 -0
- package/types/index.d.ts +4 -0
- package/types/index.js +2 -0
- package/types/index.mjs +1 -0
- package/types/rate.d.ts +11 -0
- package/types/rate.js +2 -0
- package/types/rate.mjs +1 -0
- package/types/token.d.ts +12 -0
- package/types/token.js +2 -0
- package/types/token.mjs +1 -0
- package/types/transaction.d.ts +14 -0
- package/types/transaction.js +2 -0
- package/types/transaction.mjs +1 -0
- package/useBalances-Bxtc4GNK.js +199 -0
- package/useBalances-DA3zEruz.mjs +199 -0
- package/w3m-modal-DCcF1qEB.js +356 -0
- package/w3m-modal-DK3G5GJp.mjs +356 -0
package/types/rate.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/types/token.d.ts
ADDED
package/types/token.js
ADDED
package/types/token.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TransactionBase, Transaction as ViemTransaction } from 'viem/types/transaction';
|
|
2
|
+
|
|
3
|
+
export type ServerTransaction = {
|
|
4
|
+
to: `0x${string}`;
|
|
5
|
+
data: `0x${string}`;
|
|
6
|
+
gasLimit: bigint;
|
|
7
|
+
value: bigint;
|
|
8
|
+
account: string;
|
|
9
|
+
txHash: string;
|
|
10
|
+
};
|
|
11
|
+
export type TransactionType = TransactionBase & {
|
|
12
|
+
account: `0x${string}`;
|
|
13
|
+
};
|
|
14
|
+
export type Transaction = ViemTransaction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
const require$$0 = require("react");
|
|
4
|
+
const reactjs_context_useWeb3App = require("./reactjs/context/useWeb3App.js");
|
|
5
|
+
const viem = require("viem");
|
|
6
|
+
const actions = require("viem/actions");
|
|
7
|
+
function getAction(client, actionFn, name) {
|
|
8
|
+
const action_implicit = client[actionFn.name];
|
|
9
|
+
if (typeof action_implicit === "function")
|
|
10
|
+
return action_implicit;
|
|
11
|
+
const action_explicit = client[name];
|
|
12
|
+
if (typeof action_explicit === "function")
|
|
13
|
+
return action_explicit;
|
|
14
|
+
return (params) => actionFn(client, params);
|
|
15
|
+
}
|
|
16
|
+
function getUnit(unit) {
|
|
17
|
+
if (typeof unit === "number")
|
|
18
|
+
return unit;
|
|
19
|
+
if (unit === "wei")
|
|
20
|
+
return 0;
|
|
21
|
+
return Math.abs(viem.weiUnits[unit]);
|
|
22
|
+
}
|
|
23
|
+
async function multicall(config, parameters) {
|
|
24
|
+
const { allowFailure = true, chainId, contracts, ...rest } = parameters;
|
|
25
|
+
const client = config.getClient({ chainId });
|
|
26
|
+
const action = getAction(client, actions.multicall, "multicall");
|
|
27
|
+
return action({
|
|
28
|
+
allowFailure,
|
|
29
|
+
contracts,
|
|
30
|
+
...rest
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function readContract(config, parameters) {
|
|
34
|
+
const { chainId, ...rest } = parameters;
|
|
35
|
+
const client = config.getClient({ chainId });
|
|
36
|
+
const action = getAction(client, actions.readContract, "readContract");
|
|
37
|
+
return action(rest);
|
|
38
|
+
}
|
|
39
|
+
async function readContracts(config, parameters) {
|
|
40
|
+
var _a;
|
|
41
|
+
const { allowFailure = true, blockNumber, blockTag, ...rest } = parameters;
|
|
42
|
+
const contracts = parameters.contracts;
|
|
43
|
+
try {
|
|
44
|
+
const contractsByChainId = {};
|
|
45
|
+
for (const [index, contract] of contracts.entries()) {
|
|
46
|
+
const chainId = contract.chainId ?? config.state.chainId;
|
|
47
|
+
if (!contractsByChainId[chainId])
|
|
48
|
+
contractsByChainId[chainId] = [];
|
|
49
|
+
(_a = contractsByChainId[chainId]) == null ? void 0 : _a.push({ contract, index });
|
|
50
|
+
}
|
|
51
|
+
const promises = () => Object.entries(contractsByChainId).map(([chainId, contracts2]) => multicall(config, {
|
|
52
|
+
...rest,
|
|
53
|
+
allowFailure,
|
|
54
|
+
blockNumber,
|
|
55
|
+
blockTag,
|
|
56
|
+
chainId: Number.parseInt(chainId),
|
|
57
|
+
contracts: contracts2.map(({ contract }) => contract)
|
|
58
|
+
}));
|
|
59
|
+
const multicallResults = (await Promise.all(promises())).flat();
|
|
60
|
+
const resultIndexes = Object.values(contractsByChainId).flatMap((contracts2) => contracts2.map(({ index }) => index));
|
|
61
|
+
return multicallResults.reduce((results, result, index) => {
|
|
62
|
+
if (results)
|
|
63
|
+
results[resultIndexes[index]] = result;
|
|
64
|
+
return results;
|
|
65
|
+
}, []);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (error instanceof viem.ContractFunctionExecutionError)
|
|
68
|
+
throw error;
|
|
69
|
+
const promises = () => contracts.map((contract) => readContract(config, { ...contract, blockNumber, blockTag }));
|
|
70
|
+
if (allowFailure)
|
|
71
|
+
return (await Promise.allSettled(promises())).map((result) => {
|
|
72
|
+
if (result.status === "fulfilled")
|
|
73
|
+
return { result: result.value, status: "success" };
|
|
74
|
+
return { error: result.reason, result: void 0, status: "failure" };
|
|
75
|
+
});
|
|
76
|
+
return await Promise.all(promises());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function getBalance(config, parameters) {
|
|
80
|
+
const { address, blockNumber, blockTag, chainId, token: tokenAddress, unit = "ether" } = parameters;
|
|
81
|
+
if (tokenAddress) {
|
|
82
|
+
try {
|
|
83
|
+
return await getTokenBalance(config, {
|
|
84
|
+
balanceAddress: address,
|
|
85
|
+
chainId,
|
|
86
|
+
symbolType: "string",
|
|
87
|
+
tokenAddress
|
|
88
|
+
});
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error.name === "ContractFunctionExecutionError") {
|
|
91
|
+
const balance = await getTokenBalance(config, {
|
|
92
|
+
balanceAddress: address,
|
|
93
|
+
chainId,
|
|
94
|
+
symbolType: "bytes32",
|
|
95
|
+
tokenAddress
|
|
96
|
+
});
|
|
97
|
+
const symbol = viem.hexToString(viem.trim(balance.symbol, { dir: "right" }));
|
|
98
|
+
return { ...balance, symbol };
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const client = config.getClient({ chainId });
|
|
104
|
+
const action = getAction(client, actions.getBalance, "getBalance");
|
|
105
|
+
const value = await action(blockNumber ? { address, blockNumber } : { address, blockTag });
|
|
106
|
+
const chain = config.chains.find((x) => x.id === chainId) ?? client.chain;
|
|
107
|
+
return {
|
|
108
|
+
decimals: chain.nativeCurrency.decimals,
|
|
109
|
+
formatted: viem.formatUnits(value, getUnit(unit)),
|
|
110
|
+
symbol: chain.nativeCurrency.symbol,
|
|
111
|
+
value
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
async function getTokenBalance(config, parameters) {
|
|
115
|
+
const { balanceAddress, chainId, symbolType, tokenAddress, unit } = parameters;
|
|
116
|
+
const contract = {
|
|
117
|
+
abi: [
|
|
118
|
+
{
|
|
119
|
+
type: "function",
|
|
120
|
+
name: "balanceOf",
|
|
121
|
+
stateMutability: "view",
|
|
122
|
+
inputs: [{ type: "address" }],
|
|
123
|
+
outputs: [{ type: "uint256" }]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
type: "function",
|
|
127
|
+
name: "decimals",
|
|
128
|
+
stateMutability: "view",
|
|
129
|
+
inputs: [],
|
|
130
|
+
outputs: [{ type: "uint8" }]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: "function",
|
|
134
|
+
name: "symbol",
|
|
135
|
+
stateMutability: "view",
|
|
136
|
+
inputs: [],
|
|
137
|
+
outputs: [{ type: symbolType }]
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
address: tokenAddress
|
|
141
|
+
};
|
|
142
|
+
const [value, decimals, symbol] = await readContracts(config, {
|
|
143
|
+
allowFailure: false,
|
|
144
|
+
contracts: [
|
|
145
|
+
{
|
|
146
|
+
...contract,
|
|
147
|
+
functionName: "balanceOf",
|
|
148
|
+
args: [balanceAddress],
|
|
149
|
+
chainId
|
|
150
|
+
},
|
|
151
|
+
{ ...contract, functionName: "decimals", chainId },
|
|
152
|
+
{ ...contract, functionName: "symbol", chainId }
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
const formatted = viem.formatUnits(value ?? "0", getUnit(unit ?? decimals));
|
|
156
|
+
return { decimals, formatted, symbol, value };
|
|
157
|
+
}
|
|
158
|
+
const useBalances = () => {
|
|
159
|
+
const { config } = reactjs_context_useWeb3App.useWeb3App();
|
|
160
|
+
const fetchBalances = require$$0.useCallback(
|
|
161
|
+
async ({
|
|
162
|
+
address,
|
|
163
|
+
chainId,
|
|
164
|
+
tokenIdentifiers
|
|
165
|
+
}) => {
|
|
166
|
+
return await Promise.all(
|
|
167
|
+
tokenIdentifiers.map(async (tokenIdentifier) => {
|
|
168
|
+
try {
|
|
169
|
+
const balance = await getBalance(config, {
|
|
170
|
+
address,
|
|
171
|
+
chainId: Number(chainId),
|
|
172
|
+
token: tokenIdentifier
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
tokenId: tokenIdentifier,
|
|
176
|
+
balance: balance.value.toString()
|
|
177
|
+
};
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.warn(
|
|
180
|
+
"Error fetching balance for: ",
|
|
181
|
+
tokenIdentifier,
|
|
182
|
+
error
|
|
183
|
+
);
|
|
184
|
+
return {
|
|
185
|
+
tokenId: tokenIdentifier,
|
|
186
|
+
balance: "0"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
[config]
|
|
193
|
+
);
|
|
194
|
+
return {
|
|
195
|
+
fetchBalances
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
exports.getAction = getAction;
|
|
199
|
+
exports.useBalances = useBalances;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { useCallback } from "react";
|
|
2
|
+
import { useWeb3App } from "./reactjs/context/useWeb3App.mjs";
|
|
3
|
+
import { weiUnits, ContractFunctionExecutionError, hexToString, trim, formatUnits } from "viem";
|
|
4
|
+
import { multicall as multicall$1, readContract as readContract$1, getBalance as getBalance$1 } from "viem/actions";
|
|
5
|
+
function getAction(client, actionFn, name) {
|
|
6
|
+
const action_implicit = client[actionFn.name];
|
|
7
|
+
if (typeof action_implicit === "function")
|
|
8
|
+
return action_implicit;
|
|
9
|
+
const action_explicit = client[name];
|
|
10
|
+
if (typeof action_explicit === "function")
|
|
11
|
+
return action_explicit;
|
|
12
|
+
return (params) => actionFn(client, params);
|
|
13
|
+
}
|
|
14
|
+
function getUnit(unit) {
|
|
15
|
+
if (typeof unit === "number")
|
|
16
|
+
return unit;
|
|
17
|
+
if (unit === "wei")
|
|
18
|
+
return 0;
|
|
19
|
+
return Math.abs(weiUnits[unit]);
|
|
20
|
+
}
|
|
21
|
+
async function multicall(config, parameters) {
|
|
22
|
+
const { allowFailure = true, chainId, contracts, ...rest } = parameters;
|
|
23
|
+
const client = config.getClient({ chainId });
|
|
24
|
+
const action = getAction(client, multicall$1, "multicall");
|
|
25
|
+
return action({
|
|
26
|
+
allowFailure,
|
|
27
|
+
contracts,
|
|
28
|
+
...rest
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function readContract(config, parameters) {
|
|
32
|
+
const { chainId, ...rest } = parameters;
|
|
33
|
+
const client = config.getClient({ chainId });
|
|
34
|
+
const action = getAction(client, readContract$1, "readContract");
|
|
35
|
+
return action(rest);
|
|
36
|
+
}
|
|
37
|
+
async function readContracts(config, parameters) {
|
|
38
|
+
var _a;
|
|
39
|
+
const { allowFailure = true, blockNumber, blockTag, ...rest } = parameters;
|
|
40
|
+
const contracts = parameters.contracts;
|
|
41
|
+
try {
|
|
42
|
+
const contractsByChainId = {};
|
|
43
|
+
for (const [index, contract] of contracts.entries()) {
|
|
44
|
+
const chainId = contract.chainId ?? config.state.chainId;
|
|
45
|
+
if (!contractsByChainId[chainId])
|
|
46
|
+
contractsByChainId[chainId] = [];
|
|
47
|
+
(_a = contractsByChainId[chainId]) == null ? void 0 : _a.push({ contract, index });
|
|
48
|
+
}
|
|
49
|
+
const promises = () => Object.entries(contractsByChainId).map(([chainId, contracts2]) => multicall(config, {
|
|
50
|
+
...rest,
|
|
51
|
+
allowFailure,
|
|
52
|
+
blockNumber,
|
|
53
|
+
blockTag,
|
|
54
|
+
chainId: Number.parseInt(chainId),
|
|
55
|
+
contracts: contracts2.map(({ contract }) => contract)
|
|
56
|
+
}));
|
|
57
|
+
const multicallResults = (await Promise.all(promises())).flat();
|
|
58
|
+
const resultIndexes = Object.values(contractsByChainId).flatMap((contracts2) => contracts2.map(({ index }) => index));
|
|
59
|
+
return multicallResults.reduce((results, result, index) => {
|
|
60
|
+
if (results)
|
|
61
|
+
results[resultIndexes[index]] = result;
|
|
62
|
+
return results;
|
|
63
|
+
}, []);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (error instanceof ContractFunctionExecutionError)
|
|
66
|
+
throw error;
|
|
67
|
+
const promises = () => contracts.map((contract) => readContract(config, { ...contract, blockNumber, blockTag }));
|
|
68
|
+
if (allowFailure)
|
|
69
|
+
return (await Promise.allSettled(promises())).map((result) => {
|
|
70
|
+
if (result.status === "fulfilled")
|
|
71
|
+
return { result: result.value, status: "success" };
|
|
72
|
+
return { error: result.reason, result: void 0, status: "failure" };
|
|
73
|
+
});
|
|
74
|
+
return await Promise.all(promises());
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function getBalance(config, parameters) {
|
|
78
|
+
const { address, blockNumber, blockTag, chainId, token: tokenAddress, unit = "ether" } = parameters;
|
|
79
|
+
if (tokenAddress) {
|
|
80
|
+
try {
|
|
81
|
+
return await getTokenBalance(config, {
|
|
82
|
+
balanceAddress: address,
|
|
83
|
+
chainId,
|
|
84
|
+
symbolType: "string",
|
|
85
|
+
tokenAddress
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
if (error.name === "ContractFunctionExecutionError") {
|
|
89
|
+
const balance = await getTokenBalance(config, {
|
|
90
|
+
balanceAddress: address,
|
|
91
|
+
chainId,
|
|
92
|
+
symbolType: "bytes32",
|
|
93
|
+
tokenAddress
|
|
94
|
+
});
|
|
95
|
+
const symbol = hexToString(trim(balance.symbol, { dir: "right" }));
|
|
96
|
+
return { ...balance, symbol };
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const client = config.getClient({ chainId });
|
|
102
|
+
const action = getAction(client, getBalance$1, "getBalance");
|
|
103
|
+
const value = await action(blockNumber ? { address, blockNumber } : { address, blockTag });
|
|
104
|
+
const chain = config.chains.find((x) => x.id === chainId) ?? client.chain;
|
|
105
|
+
return {
|
|
106
|
+
decimals: chain.nativeCurrency.decimals,
|
|
107
|
+
formatted: formatUnits(value, getUnit(unit)),
|
|
108
|
+
symbol: chain.nativeCurrency.symbol,
|
|
109
|
+
value
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function getTokenBalance(config, parameters) {
|
|
113
|
+
const { balanceAddress, chainId, symbolType, tokenAddress, unit } = parameters;
|
|
114
|
+
const contract = {
|
|
115
|
+
abi: [
|
|
116
|
+
{
|
|
117
|
+
type: "function",
|
|
118
|
+
name: "balanceOf",
|
|
119
|
+
stateMutability: "view",
|
|
120
|
+
inputs: [{ type: "address" }],
|
|
121
|
+
outputs: [{ type: "uint256" }]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: "function",
|
|
125
|
+
name: "decimals",
|
|
126
|
+
stateMutability: "view",
|
|
127
|
+
inputs: [],
|
|
128
|
+
outputs: [{ type: "uint8" }]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
type: "function",
|
|
132
|
+
name: "symbol",
|
|
133
|
+
stateMutability: "view",
|
|
134
|
+
inputs: [],
|
|
135
|
+
outputs: [{ type: symbolType }]
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
address: tokenAddress
|
|
139
|
+
};
|
|
140
|
+
const [value, decimals, symbol] = await readContracts(config, {
|
|
141
|
+
allowFailure: false,
|
|
142
|
+
contracts: [
|
|
143
|
+
{
|
|
144
|
+
...contract,
|
|
145
|
+
functionName: "balanceOf",
|
|
146
|
+
args: [balanceAddress],
|
|
147
|
+
chainId
|
|
148
|
+
},
|
|
149
|
+
{ ...contract, functionName: "decimals", chainId },
|
|
150
|
+
{ ...contract, functionName: "symbol", chainId }
|
|
151
|
+
]
|
|
152
|
+
});
|
|
153
|
+
const formatted = formatUnits(value ?? "0", getUnit(unit ?? decimals));
|
|
154
|
+
return { decimals, formatted, symbol, value };
|
|
155
|
+
}
|
|
156
|
+
const useBalances = () => {
|
|
157
|
+
const { config } = useWeb3App();
|
|
158
|
+
const fetchBalances = useCallback(
|
|
159
|
+
async ({
|
|
160
|
+
address,
|
|
161
|
+
chainId,
|
|
162
|
+
tokenIdentifiers
|
|
163
|
+
}) => {
|
|
164
|
+
return await Promise.all(
|
|
165
|
+
tokenIdentifiers.map(async (tokenIdentifier) => {
|
|
166
|
+
try {
|
|
167
|
+
const balance = await getBalance(config, {
|
|
168
|
+
address,
|
|
169
|
+
chainId: Number(chainId),
|
|
170
|
+
token: tokenIdentifier
|
|
171
|
+
});
|
|
172
|
+
return {
|
|
173
|
+
tokenId: tokenIdentifier,
|
|
174
|
+
balance: balance.value.toString()
|
|
175
|
+
};
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.warn(
|
|
178
|
+
"Error fetching balance for: ",
|
|
179
|
+
tokenIdentifier,
|
|
180
|
+
error
|
|
181
|
+
);
|
|
182
|
+
return {
|
|
183
|
+
tokenId: tokenIdentifier,
|
|
184
|
+
balance: "0"
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
);
|
|
189
|
+
},
|
|
190
|
+
[config]
|
|
191
|
+
);
|
|
192
|
+
return {
|
|
193
|
+
fetchBalances
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
export {
|
|
197
|
+
getAction as g,
|
|
198
|
+
useBalances as u
|
|
199
|
+
};
|