fix: connect to wallet
This commit is contained in:
parent
a3fe2709db
commit
b6296dd07f
|
@ -11,17 +11,14 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ConnectWallet({ setAddress, setProvider }: Props) {
|
export default function ConnectWallet({ setAddress, setProvider }: Props) {
|
||||||
const connectWallet = () => {
|
const connectWallet = async () => {
|
||||||
try {
|
try {
|
||||||
window.ethereum
|
const provider = new ethers.providers.Web3Provider(window.ethereum);
|
||||||
.request({ method: "eth_requestAccounts" })
|
const accounts = await provider.send("eth_requestAccounts", []);
|
||||||
.then((accounts: string[]) => {
|
setAddress(accounts[0]);
|
||||||
const _provider = new ethers.providers.Web3Provider(window.ethereum);
|
setProvider(provider);
|
||||||
setAddress(accounts[0]);
|
|
||||||
setProvider(_provider);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("No web3 provider available");
|
console.error("No web3 provider available", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue