Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
improve 'METHOD_DENIED' error message (#2127)
Browse files Browse the repository at this point in the history
* improve 'METHOD_DENIED' error message

* fix

* upstream fixes
  • Loading branch information
luclu authored and frozeman committed Jul 14, 2017
1 parent 65a9fb3 commit 7fae2a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions modules/ipc/ipcProviderBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ const log = require('../utils/logger').create('ipcProviderBackend');
const Sockets = require('../socketManager');
const Settings = require('../settings');
const ethereumNode = require('../ethereumNode');
const Windows = require('../windows');


const ERRORS = {
INVALID_PAYLOAD: { code: -32600, message: 'Payload, or some of its content properties are invalid. Please check if they are valid HEX with 0x prefix.' },
METHOD_DENIED: { code: -32601, message: "Method \'__method__\' not allowed." },
METHOD_TIMEOUT: { code: -32603, message: "Request timed out for method \'__method__\'." },
INVALID_PAYLOAD: { code: -32600, message: "Payload, or some of its content properties are invalid. Please check if they are valid HEX with '0x' prefix." },
METHOD_DENIED: { code: -32601, message: 'Method __method__ not allowed.' },
METHOD_TIMEOUT: { code: -32603, message: 'Request timed out for method __method__.' },
TX_DENIED: { code: -32603, message: 'Transaction denied' },
BATCH_TX_DENIED: { code: -32603, message: 'Transactions denied, sendTransaction is not allowed in batch requests.' },
BATCH_COMPILE_DENIED: { code: -32603, message: 'Compilation denied, compileSolidity is not allowed in batch requests.' },
Expand Down
8 changes: 4 additions & 4 deletions modules/ipc/methods/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ module.exports = class BaseProcessor {
}

// prevent dapps from acccesing admin endpoints
if (!/^eth_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
if (!/^eth_|^bzz_|^shh_|^net_|^web3_|^db_/.test(payload.method)) {
delete payload.result;

payload.error = this.ERRORS.METHOD_DENIED;
const err = _.clone(this.ERRORS.METHOD_DENIED);
err.message = err.message.replace('__method__', `"${payload.method}"`);
payload.error = err;
}
}
};

0 comments on commit 7fae2a8

Please sign in to comment.