Merge branch 'master' into ppmm

pull/2826/head
Aniket 2 years ago committed by GitHub
commit 7200755262
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      apps/remix-ide/src/app/tabs/injected-provider.tsx
  2. 7
      apps/remix-ide/src/blockchain/execution-context.js

@ -18,7 +18,7 @@ export class InjectedProvider extends Plugin {
sendAsync (data: JsonDataRequest): Promise<any> {
return new Promise((resolve, reject) => {
this.sendAsyncInternal(data, resolve, reject)
this.sendAsyncInternal(data, resolve, reject)
})
}
@ -30,7 +30,7 @@ export class InjectedProvider extends Plugin {
return reject(new Error('no injected provider found.'))
}
try {
if ((window as any) && typeof (window as any).ethereum.enable === 'function') (window as any).ethereum.enable()
if ((window as any) && typeof (window as any).ethereum.request === "function") (window as any).ethereum.request({ method: "eth_requestAccounts" });
if (!await (window as any).ethereum._metamask.isUnlocked()) this.call('notification', 'toast', 'Please make sure the injected provider is unlocked (e.g Metamask).')
await addL2Network(this.chainName, this.chainId, this.rpcUrls)
const resultData = await this.provider.currentProvider.send(data.method, data.params)
@ -61,7 +61,7 @@ export const addL2Network = async (chainName: string, chainId: string, rpcUrls:
},
],
});
await (window as any).ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: chainId }],
@ -71,5 +71,5 @@ export const addL2Network = async (chainName: string, chainId: string, rpcUrls:
}
}
// handle other "switch" errors
}
}
}
}

@ -43,8 +43,7 @@ export class ExecutionContext {
}
askPermission () {
// metamask
if (ethereum && typeof ethereum.enable === 'function') ethereum.enable()
if (ethereum && typeof ethereum.request === "function") ethereum.request({ method: "eth_requestAccounts" });
}
getProvider () {
@ -169,7 +168,7 @@ export class ExecutionContext {
if (this.customNetWorks[context]) {
var network = this.customNetWorks[context]
if (!this.customNetWorks[context].isInjected) {
if (!this.customNetWorks[context].isInjected) {
this.setProviderFromEndpoint(network.provider, { context: network.name }, (error) => {
if (error) infoCb(error)
cb()
@ -183,7 +182,7 @@ export class ExecutionContext {
this.event.trigger('contextChanged', [context])
return cb()
}
}
}
}
currentblockGasLimit () {

Loading…
Cancel
Save