Fix console dapp (#4544)
* Fixing linting issues. Better support for console as secure app * Fixing linting issues
This commit is contained in:
parent
e9eed5206e
commit
d925cc05da
@ -301,7 +301,7 @@ impl Server {
|
||||
|
||||
let special = Arc::new({
|
||||
let mut special = HashMap::new();
|
||||
special.insert(router::SpecialEndpoint::Rpc, rpc::rpc(handler, panic_handler.clone()));
|
||||
special.insert(router::SpecialEndpoint::Rpc, rpc::rpc(handler, cors_domains.clone(), panic_handler.clone()));
|
||||
special.insert(router::SpecialEndpoint::Utils, apps::utils());
|
||||
special.insert(
|
||||
router::SpecialEndpoint::Api,
|
||||
|
@ -25,13 +25,14 @@ use endpoint::{Endpoint, EndpointPath, Handler};
|
||||
|
||||
pub fn rpc<T: Middleware<Metadata>>(
|
||||
handler: RpcHandler<Metadata, T>,
|
||||
cors_domains: Vec<String>,
|
||||
panic_handler: Arc<Mutex<Option<Box<Fn() -> () + Send>>>>,
|
||||
) -> Box<Endpoint> {
|
||||
Box::new(RpcEndpoint {
|
||||
handler: handler,
|
||||
meta_extractor: Arc::new(MetadataExtractor),
|
||||
panic_handler: panic_handler,
|
||||
cors_domain: None,
|
||||
cors_domain: Some(cors_domains.into_iter().map(AccessControlAllowOrigin::Value).collect()),
|
||||
// NOTE [ToDr] We don't need to do any hosts validation here. It's already done in router.
|
||||
allowed_hosts: None,
|
||||
})
|
||||
|
File diff suppressed because one or more lines are too long
@ -14,54 +14,35 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import parity from '~/jsonrpc/interfaces/parity';
|
||||
import signer from '~/jsonrpc/interfaces/signer';
|
||||
import trace from '~/jsonrpc/interfaces/trace';
|
||||
|
||||
export default function web3extensions (web3) {
|
||||
const { Method, formatters } = web3._extend;
|
||||
const { Method } = web3._extend;
|
||||
|
||||
// TODO [ToDr] Consider output/input formatters.
|
||||
const methods = (object, name) => {
|
||||
return Object.keys(object).map(method => {
|
||||
return new Method({
|
||||
name: method,
|
||||
call: `${name}_{method}`,
|
||||
params: object[method].params.length
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return [{
|
||||
property: 'personal',
|
||||
methods: [
|
||||
new Method({
|
||||
name: 'sendTransaction',
|
||||
call: 'personal_sendTransaction',
|
||||
params: 2,
|
||||
inputFormatter: [formatters.inputTransactionFormatter, null]
|
||||
}),
|
||||
new Method({
|
||||
name: 'signerEnabled',
|
||||
call: 'personal_signerEnabled',
|
||||
params: 0,
|
||||
inputFormatter: []
|
||||
})
|
||||
],
|
||||
property: 'parity',
|
||||
methods: methods(parity, 'parity'),
|
||||
properties: []
|
||||
}, {
|
||||
property: 'ethcore',
|
||||
methods: [
|
||||
new Method({
|
||||
name: 'getNetPeers',
|
||||
call: 'ethcore_netPeers',
|
||||
params: 0,
|
||||
outputFormatter: x => x
|
||||
}),
|
||||
new Method({
|
||||
name: 'getNetChain',
|
||||
call: 'ethcore_netChain',
|
||||
params: 0,
|
||||
outputFormatter: x => x
|
||||
}),
|
||||
new Method({
|
||||
name: 'gasPriceStatistics',
|
||||
call: 'ethcore_gasPriceStatistics',
|
||||
params: 0,
|
||||
outputFormatter: a => a.map(web3.toBigNumber)
|
||||
}),
|
||||
new Method({
|
||||
name: 'unsignedTransactionsCount',
|
||||
call: 'ethcore_unsignedTransactionsCount',
|
||||
params: 0,
|
||||
inputFormatter: []
|
||||
})
|
||||
],
|
||||
property: 'signer',
|
||||
methods: methods(signer, 'signer'),
|
||||
properties: []
|
||||
}, {
|
||||
property: 'trace',
|
||||
methods: methods(trace, 'trace'),
|
||||
properties: []
|
||||
}];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user