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 special = Arc::new({
 | 
				
			||||||
			let mut special = HashMap::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::Utils, apps::utils());
 | 
				
			||||||
			special.insert(
 | 
								special.insert(
 | 
				
			||||||
				router::SpecialEndpoint::Api,
 | 
									router::SpecialEndpoint::Api,
 | 
				
			||||||
 | 
				
			|||||||
@ -25,13 +25,14 @@ use endpoint::{Endpoint, EndpointPath, Handler};
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pub fn rpc<T: Middleware<Metadata>>(
 | 
					pub fn rpc<T: Middleware<Metadata>>(
 | 
				
			||||||
	handler: RpcHandler<Metadata, T>,
 | 
						handler: RpcHandler<Metadata, T>,
 | 
				
			||||||
 | 
						cors_domains: Vec<String>,
 | 
				
			||||||
	panic_handler: Arc<Mutex<Option<Box<Fn() -> () + Send>>>>,
 | 
						panic_handler: Arc<Mutex<Option<Box<Fn() -> () + Send>>>>,
 | 
				
			||||||
) -> Box<Endpoint> {
 | 
					) -> Box<Endpoint> {
 | 
				
			||||||
	Box::new(RpcEndpoint {
 | 
						Box::new(RpcEndpoint {
 | 
				
			||||||
		handler: handler,
 | 
							handler: handler,
 | 
				
			||||||
		meta_extractor: Arc::new(MetadataExtractor),
 | 
							meta_extractor: Arc::new(MetadataExtractor),
 | 
				
			||||||
		panic_handler: panic_handler,
 | 
							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.
 | 
							// NOTE [ToDr] We don't need to do any hosts validation here. It's already done in router.
 | 
				
			||||||
		allowed_hosts: None,
 | 
							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
 | 
					// You should have received a copy of the GNU General Public License
 | 
				
			||||||
// along with Parity.  If not, see <http://www.gnu.org/licenses/>.
 | 
					// 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) {
 | 
					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 [{
 | 
					  return [{
 | 
				
			||||||
    property: 'personal',
 | 
					    property: 'parity',
 | 
				
			||||||
    methods: [
 | 
					    methods: methods(parity, 'parity'),
 | 
				
			||||||
      new Method({
 | 
					 | 
				
			||||||
        name: 'sendTransaction',
 | 
					 | 
				
			||||||
        call: 'personal_sendTransaction',
 | 
					 | 
				
			||||||
        params: 2,
 | 
					 | 
				
			||||||
        inputFormatter: [formatters.inputTransactionFormatter, null]
 | 
					 | 
				
			||||||
      }),
 | 
					 | 
				
			||||||
      new Method({
 | 
					 | 
				
			||||||
        name: 'signerEnabled',
 | 
					 | 
				
			||||||
        call: 'personal_signerEnabled',
 | 
					 | 
				
			||||||
        params: 0,
 | 
					 | 
				
			||||||
        inputFormatter: []
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    properties: []
 | 
					    properties: []
 | 
				
			||||||
  }, {
 | 
					  }, {
 | 
				
			||||||
    property: 'ethcore',
 | 
					    property: 'signer',
 | 
				
			||||||
    methods: [
 | 
					    methods: methods(signer, 'signer'),
 | 
				
			||||||
      new Method({
 | 
					    properties: []
 | 
				
			||||||
        name: 'getNetPeers',
 | 
					  }, {
 | 
				
			||||||
        call: 'ethcore_netPeers',
 | 
					    property: 'trace',
 | 
				
			||||||
        params: 0,
 | 
					    methods: methods(trace, 'trace'),
 | 
				
			||||||
        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: []
 | 
					 | 
				
			||||||
      })
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    properties: []
 | 
					    properties: []
 | 
				
			||||||
  }];
 | 
					  }];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user