Skip to content

Commit f6a01ce

Browse files
author
ci-bot
committed
fix updating provider
1 parent 445dbf2 commit f6a01ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/remix-ide/src/blockchain/blockchain.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class Blockchain extends Plugin {
123123
this.registeredPluginEvents.push(plugin.name)
124124
this.on(plugin.name, 'chainChanged', () => {
125125
if (plugin.name === this.executionContext.executionContext) {
126+
this.changeExecutionContext({ context: plugin.name }, null, null, null)
126127
this.detectNetwork((error, network) => {
127128
this.networkStatus = { network, error }
128129
if (network.networkNativeCurrency) this.networkNativeCurrency = network.networkNativeCurrency

apps/remix-ide/src/blockchain/execution-context.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function track(event) {
2020
}
2121
if (typeof window !== 'undefined' && typeof window.ethereum !== 'undefined') {
2222
var injectedProvider = window.ethereum
23-
provider = new ethers.BrowserProvider(injectedProvider)
23+
provider = new ethers.BrowserProvider(injectedProvider, 'any')
2424
} else {
2525
provider = new ethers.JsonRpcProvider('http://localhost:8545')
2626
}
@@ -86,6 +86,7 @@ export class ExecutionContext {
8686
return reject('No provider set')
8787
}
8888
const cb = async (err, id) => {
89+
console.log('detectNetwork id', id, err)
8990
let name = 'Custom'
9091
let networkNativeCurrency = { name: "Ether", symbol: "ETH", decimals: 18 }
9192
if (err) name = 'Unknown'
@@ -129,6 +130,7 @@ export class ExecutionContext {
129130
return resolve({ id, name, lastBlock: this.lastBlock, currentFork: this.currentFork, networkNativeCurrency })
130131
}
131132
}
133+
console.log('detectNetwork', provider)
132134
provider.getNetwork().then(async (network) => await cb(null, parseInt(network.chainId))).catch(err => cb(err))
133135
}
134136
})
@@ -180,7 +182,8 @@ export class ExecutionContext {
180182
await network.init()
181183
this.currentFork = network.config.fork
182184
// injected
183-
provider = new ethers.BrowserProvider(network.provider)
185+
console.log('executionContextChange', network.provider)
186+
provider = new ethers.BrowserProvider(network.provider, 'any')
184187
this.executionContext = context
185188
this.isConnected = await this._updateChainContext()
186189
this.event.trigger('contextChanged', [context])

0 commit comments

Comments
 (0)