I'm using Metamask detect ethereum provider, and while the app is starting, I'm trying to create ethers signer and provider objects and store them in Vue Pinia store. However, when I use the stored signer, I encounter the error:
TypeError: proxy must report the same value for the non-writable, non-configurable property '"provider"'
const provider = await detectEthereumProvider();
if (provider) {
useEthersStore().setProviderSigner()
startApp(provider)
}
async setProviderAndSigner() {
if (window.ethereum) {
this.provider = new ethers.providers.Web3Provider(window.ethereum);
this.signer = this.provider.getSigner();
}
}
I'm also wondering what the best approach is to handle ethers provider and signer, without having to define them every time they are needed.