Skip to content
This repository was archived by the owner on Mar 3, 2021. It is now read-only.

Commit 0954560

Browse files
authored
Merge pull request #1138 from ethereum/yann300-patch-6
manage metamask privacy mode
2 parents b9fdc27 + 633bcb3 commit 0954560

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

remix-lib/src/execution/execution-context.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global ethereum */
12
'use strict'
23
var Web3 = require('web3')
34
var EventManager = require('../eventManager')
@@ -96,9 +97,15 @@ function ExecutionContext () {
9697
executionContext = 'vm'
9798
} else {
9899
executionContext = injectedProvider ? 'injected' : 'vm'
100+
if (executionContext === 'injected') this.askPermission()
99101
}
100102
}
101103

104+
this.askPermission = function () {
105+
// metamask
106+
if (ethereum && typeof ethereum.enable === 'function') ethereum.enable()
107+
}
108+
102109
this.getProvider = function () {
103110
return executionContext
104111
}
@@ -190,6 +197,7 @@ function ExecutionContext () {
190197
infoCb(alertMsg)
191198
return cb()
192199
} else {
200+
self.askPermission()
193201
executionContext = context
194202
web3.setProvider(injectedProvider)
195203
self._updateBlockGasLimit()

0 commit comments

Comments
 (0)