Closed kombos closed 1 year ago
Having the same issue, the only way i can get the modal to pop up correctly is to open in incognito mode...
Same issue here
UPDATE: I was able to achieve the desired behavior by modifying the web3Modal instantiation and the onConnect
function as follows. Let me know if this fixes the issue for you!
this.web3Modal = new Web3Modal({
network: this.getNetwork(),
cacheProvider: false,
disableInjectedProvider: false,
providerOptions: this.getProviderOptions()
});
onConnect = async () => {
let provider, hasProvider
try {
provider = await this.web3Modal.connect();
hasProvider = true;
} catch ( err ) {
await this.resetApp()
hasProvider = false;
}
if (hasProvider) {
try {
await this.subscribeProvider(provider);
} catch ( err ) {
console.error(`Error calling subscribeProvider - ${ err.message }`);
}
const web3 = initWeb3(provider);
const accounts = await web3.eth.getAccounts();
const address = accounts[0];
const networkId = await web3.eth.net.getId();
const chainId = await web3.eth.chainId();
const currentAccountTruncated = this.smartTrim(address, 16) + ' '
try {
await this.setState({
web3,
provider,
connected: true,
address,
chainId,
networkId,
currentAccountTruncated
});
} catch ( err ) {
console.error( `Error setting state in onConnect - ${ err.message }` );
}
try {
await this.getAccountAssets();
} catch ( err ) {
console.error( `Error calling getAccountAssets - ${ err.message }` );
}
}
};
I had the same Issue, the problem occured when I used metamask (plugin) with cacheProvider: true
.
If you have connected to metamask atleast once, you need to clear your local storage and then set cacheProvider: false
Is there not a PR for this yet? such an annoying issue
try this @Amirjab21
@Sanjeev-Hegde thanks a lot.
With stable version 2.0.0 of Web3Modal now released, we are officially dropping support for version 1.x Due to this this issue/pr was marked for closing. It is highly recommended to upgrade as 2.x will be receiving further updates that will enable functionality for some of our newer sdks like auth and push as well as support for WalletConnect v2 (See this post about WalletConnect v1 being deprecated https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)
If you need to continue using Web3Modal 1.x and require this feature/fix implemented, we suggest adding it via forking V1 branch.
I'm trying to implement web3modal in the following way in a dev environment (using ganache):
Expected Result: Should open the modal with list of providers to select from..
Actual Result Automatically taking the injected provider (metamask) even at first run, even when disableInjectedProvider is set to false, and cache is disabled.
would appreciate it if anyone has an instance of code which actually works (the react component implementation, not the vanilla javascript implementation). Thanks.