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[]) => {
|
|
||||||
const _provider = new ethers.providers.Web3Provider(window.ethereum);
|
|
||||||
setAddress(accounts[0]);
|
setAddress(accounts[0]);
|
||||||
setProvider(_provider);
|
setProvider(provider);
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("No web3 provider available");
|
console.error("No web3 provider available", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue