forked from MetaMask/web3-provider-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhitelist.js
43 lines (38 loc) · 1.18 KB
/
whitelist.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const inherits = require('util').inherits
const Subprovider = require('./subprovider.js')
module.exports = WhitelistProvider
inherits(WhitelistProvider, Subprovider)
function WhitelistProvider(methods){
this.methods = methods;
if (this.methods == null) {
this.methods = [
'eth_gasPrice',
'eth_blockNumber',
'eth_getBalance',
'eth_getBlockByHash',
'eth_getBlockByNumber',
'eth_getBlockTransactionCountByHash',
'eth_getBlockTransactionCountByNumber',
'eth_getCode',
'eth_getStorageAt',
'eth_getTransactionByBlockHashAndIndex',
'eth_getTransactionByBlockNumberAndIndex',
'eth_getTransactionByHash',
'eth_getTransactionCount',
'eth_getTransactionReceipt',
'eth_getUncleByBlockHashAndIndex',
'eth_getUncleByBlockNumberAndIndex',
'eth_getUncleCountByBlockHash',
'eth_getUncleCountByBlockNumber',
'eth_sendRawTransaction',
'eth_getLogs'
];
}
}
WhitelistProvider.prototype.handleRequest = function(payload, next, end){
if (this.methods.indexOf(payload.method) >= 0) {
next();
} else {
end(new Error("Method '" + payload.method + "' not allowed in whitelist."));
}
}