fix: connect to wallet

This commit is contained in:
fryorcraken.eth 2022-08-20 18:49:25 +10:00
parent a3fe2709db
commit b6296dd07f
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
1 changed files with 6 additions and 9 deletions

View File

@ -11,17 +11,14 @@ interface Props {
}
export default function ConnectWallet({ setAddress, setProvider }: Props) {
const connectWallet = () => {
const connectWallet = async () => {
try {
window.ethereum
.request({ method: "eth_requestAccounts" })
.then((accounts: string[]) => {
const _provider = new ethers.providers.Web3Provider(window.ethereum);
setAddress(accounts[0]);
setProvider(_provider);
});
const provider = new ethers.providers.Web3Provider(window.ethereum);
const accounts = await provider.send("eth_requestAccounts", []);
setAddress(accounts[0]);
setProvider(provider);
} catch (e) {
console.error("No web3 provider available");
console.error("No web3 provider available", e);
}
};