diff --git a/package-lock.json b/package-lock.json index 5cd20b1a7..605d23fbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,16 +36,15 @@ "@solana/wallet-adapter-react-ui": "^0.9.5", "@solana/wallet-adapter-wallets": "^0.19.5", "@solana/web3.js": "^1.35.1", - "@terra-money/terra.js": "^3.1.9", "@terra-money/wallet-provider": "^3.9.4", "@walletconnect/web3-provider": "^1.7.8", "@xlabs-libs/wallet-aggregator-algorand": "0.0.1-alpha.16", "@xlabs-libs/wallet-aggregator-aptos": "^0.0.1-alpha.9", - "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.13", + "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.15", "@xlabs-libs/wallet-aggregator-evm": "0.0.1-alpha.27", "@xlabs-libs/wallet-aggregator-injective": "^0.0.1-alpha.12", "@xlabs-libs/wallet-aggregator-near": "^0.0.1-alpha.5", - "@xlabs-libs/wallet-aggregator-react": "0.0.1-alpha.11", + "@xlabs-libs/wallet-aggregator-react": "0.0.1-alpha.12", "@xlabs-libs/wallet-aggregator-solana": "^0.0.1-alpha.10", "@xlabs-libs/wallet-aggregator-sui": "^0.0.1-alpha.4", "@xlabs-libs/wallet-aggregator-terra": "^0.0.1-alpha.5", @@ -15428,9 +15427,9 @@ } }, "node_modules/@xlabs-libs/wallet-aggregator-core": { - "version": "0.0.1-alpha.14", - "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-core/-/wallet-aggregator-core-0.0.1-alpha.14.tgz", - "integrity": "sha512-O5Bn7UaDV8qMqUhdiBPr3NKtxfS+Cl+sO9pcMnQOqpchk4jenK3IQJ2ZdAZTfhHOpd9Tppp9wHqbM6zTRpauxA==", + "version": "0.0.1-alpha.15", + "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-core/-/wallet-aggregator-core-0.0.1-alpha.15.tgz", + "integrity": "sha512-aTkUUmhCa8CD2pCzC6j/43q0lelsHop3RIXdsDSSGMq3lggcagRfYBYTjiBCe+UloE/+YbK1CDWIdDk7ps5CiA==", "dependencies": { "eventemitter3": "^5.0.0" } @@ -15737,11 +15736,11 @@ } }, "node_modules/@xlabs-libs/wallet-aggregator-react": { - "version": "0.0.1-alpha.11", - "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-react/-/wallet-aggregator-react-0.0.1-alpha.11.tgz", - "integrity": "sha512-J8uOe+g4tWNhAzTe1BPG9L18391GK3tigLLcxafmIO6XKfNl1+pn9q5a9fEOcC3UXxErOf85pqUlsRn9zMRbmA==", + "version": "0.0.1-alpha.12", + "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-react/-/wallet-aggregator-react-0.0.1-alpha.12.tgz", + "integrity": "sha512-6AKJ3Y+VIUPJP1vgBtD1awOerJuCGJkDZYEKwTxUrFk/eiQ+ur59HJCQ4hFVk/5HyowjTyHnaiNlCRYR4hZH7g==", "dependencies": { - "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.11" + "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.15" } }, "node_modules/@xlabs-libs/wallet-aggregator-solana": { @@ -55384,9 +55383,9 @@ } }, "@xlabs-libs/wallet-aggregator-core": { - "version": "0.0.1-alpha.14", - "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-core/-/wallet-aggregator-core-0.0.1-alpha.14.tgz", - "integrity": "sha512-O5Bn7UaDV8qMqUhdiBPr3NKtxfS+Cl+sO9pcMnQOqpchk4jenK3IQJ2ZdAZTfhHOpd9Tppp9wHqbM6zTRpauxA==", + "version": "0.0.1-alpha.15", + "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-core/-/wallet-aggregator-core-0.0.1-alpha.15.tgz", + "integrity": "sha512-aTkUUmhCa8CD2pCzC6j/43q0lelsHop3RIXdsDSSGMq3lggcagRfYBYTjiBCe+UloE/+YbK1CDWIdDk7ps5CiA==", "requires": { "eventemitter3": "^5.0.0" }, @@ -55676,11 +55675,11 @@ } }, "@xlabs-libs/wallet-aggregator-react": { - "version": "0.0.1-alpha.11", - "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-react/-/wallet-aggregator-react-0.0.1-alpha.11.tgz", - "integrity": "sha512-J8uOe+g4tWNhAzTe1BPG9L18391GK3tigLLcxafmIO6XKfNl1+pn9q5a9fEOcC3UXxErOf85pqUlsRn9zMRbmA==", + "version": "0.0.1-alpha.12", + "resolved": "https://registry.npmjs.org/@xlabs-libs/wallet-aggregator-react/-/wallet-aggregator-react-0.0.1-alpha.12.tgz", + "integrity": "sha512-6AKJ3Y+VIUPJP1vgBtD1awOerJuCGJkDZYEKwTxUrFk/eiQ+ur59HJCQ4hFVk/5HyowjTyHnaiNlCRYR4hZH7g==", "requires": { - "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.11" + "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.15" } }, "@xlabs-libs/wallet-aggregator-solana": { diff --git a/package.json b/package.json index 2f4fbdd71..5e0171efe 100644 --- a/package.json +++ b/package.json @@ -31,16 +31,15 @@ "@solana/wallet-adapter-react-ui": "^0.9.5", "@solana/wallet-adapter-wallets": "^0.19.5", "@solana/web3.js": "^1.35.1", - "@terra-money/terra.js": "^3.1.9", "@terra-money/wallet-provider": "^3.9.4", "@walletconnect/web3-provider": "^1.7.8", "@xlabs-libs/wallet-aggregator-algorand": "0.0.1-alpha.16", "@xlabs-libs/wallet-aggregator-aptos": "^0.0.1-alpha.9", - "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.13", + "@xlabs-libs/wallet-aggregator-core": "^0.0.1-alpha.15", "@xlabs-libs/wallet-aggregator-evm": "0.0.1-alpha.27", "@xlabs-libs/wallet-aggregator-injective": "^0.0.1-alpha.12", "@xlabs-libs/wallet-aggregator-near": "^0.0.1-alpha.5", - "@xlabs-libs/wallet-aggregator-react": "0.0.1-alpha.11", + "@xlabs-libs/wallet-aggregator-react": "0.0.1-alpha.12", "@xlabs-libs/wallet-aggregator-solana": "^0.0.1-alpha.10", "@xlabs-libs/wallet-aggregator-sui": "^0.0.1-alpha.4", "@xlabs-libs/wallet-aggregator-terra": "^0.0.1-alpha.5", diff --git a/src/components/ConnectWalletButton.tsx b/src/components/ConnectWalletButton.tsx index 481fa544f..c191f17f8 100644 --- a/src/components/ConnectWalletButton.tsx +++ b/src/components/ConnectWalletButton.tsx @@ -1,17 +1,19 @@ import { ChainId } from "@certusone/wormhole-sdk"; -import { useCallback, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { Wallet } from "@xlabs-libs/wallet-aggregator-core"; import { useChangeWallet, useUnsetWalletFromChain, useWallet, - useWalletsForChain, + useWalletsForChainWithStatus, } from "@xlabs-libs/wallet-aggregator-react"; import ConnectWalletDialog from "./ConnectWalletDialog"; import ToggleConnectedButton from "./ToggleConnectedButton"; import { Typography } from "@material-ui/core"; import { CLUSTER } from "../utils/consts"; import { getIsSanctioned } from "../utils/sanctions"; +import { useSelector } from "react-redux"; +import { RootState } from "../store"; const ConnectWalletButton = ({ chainId }: { chainId: ChainId }) => { const wallet = useWallet(chainId); @@ -19,10 +21,18 @@ const ConnectWalletButton = ({ chainId }: { chainId: ChainId }) => { const unsetWalletFromChain = useUnsetWalletFromChain(); const [isDialogOpen, setIsDialogOpen] = useState(false); const [error, setError] = useState(); - const availableWallets = useWalletsForChain(chainId); - + const { wallets: availableWallets, isDetectingWallets } = + useWalletsForChainWithStatus(chainId); + const sourceChain = useSelector( + (state: RootState) => state.transfer.sourceChain + ); + const [walletsNotAvailable, setWalletsNotAvailable] = useState(false); const pk = wallet?.getAddress(); + useEffect(() => { + setWalletsNotAvailable(availableWallets.length === 0); + }, [sourceChain, availableWallets]); + const connect = useCallback( async (w: Wallet) => { try { @@ -79,11 +89,30 @@ const ConnectWalletButton = ({ chainId }: { chainId: ChainId }) => { return ( <> + {isDetectingWallets && ( + + Detecting wallets ... + + )} + {!isDetectingWallets && walletsNotAvailable && ( + + Wallets not detected for the selected chain + + )} { const classes = useStyles(); const is0x = pk.startsWith("0x"); @@ -56,6 +58,7 @@ const ToggleConnectedButton = ({ size="small" onClick={connect} className={classes.button} + disabled={disabled} > Connect