Skip to content

Commit

Permalink
Merge pull request from GHSA-43pf-2g29-8wf2
Browse files Browse the repository at this point in the history
  • Loading branch information
rekmarks authored Jul 2, 2020
1 parent 7b13a4e commit a2e7c9e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ export class BrowserTab extends PureComponent {
getRpcMethodMiddleware = ({ hostname }) =>
// all user facing RPC calls not implemented by the provider
createAsyncMiddleware(async (req, res, next) => {
const getAccounts = async () => {
const { approvedHosts, privacyMode, selectedAddress } = this.props;
const isEnabled = !privacyMode || approvedHosts[hostname];

return isEnabled ? [selectedAddress.toLowerCase()] : [];
};

const rpcMethods = {
eth_requestAccounts: async () => {
const { params } = req;
Expand Down Expand Up @@ -504,14 +511,12 @@ export class BrowserTab extends PureComponent {
},

eth_accounts: async () => {
const { approvedHosts, privacyMode, selectedAddress } = this.props;
const isEnabled = !privacyMode || approvedHosts[hostname];
res.result = await getAccounts();
},

if (isEnabled) {
res.result = [selectedAddress.toLowerCase()];
} else {
res.result = [];
}
eth_coinbase: async () => {
const accounts = await getAccounts();
res.result = accounts.length > 0 ? accounts[0] : null;
},

eth_sign: async () => {
Expand Down

0 comments on commit a2e7c9e

Please sign in to comment.