Backporting to beta (#3239)
* Fixed some typos (#3236) * Add store for dapps state (#3211) * Add mobx * Use mobx store for dapps * Cleanup hidden reads * Remove (now) unused hidden.js * _ denotes internal functions * s/visibleApps/visible/ * AddDapps now use the mobx store as well * Move modalOpen state to store * Simplify * Complete master merge * Remove extra indirection * Remove unneeded check * Readability improvements * Remove final debug info * Load network apps manifests as contentHash (no coding) (#3235) * Add mobx * Use mobx store for dapps * Cleanup hidden reads * Remove (now) unused hidden.js * _ denotes internal functions * s/visibleApps/visible/ * AddDapps now use the mobx store as well * Move modalOpen state to store * Simplify * Complete master merge * Remove extra indirection * Remove unneeded check * Readability improvements * Remove final debug info * Load network manifests from the network * Swallow manifest errors * introduce fetchManifest * Rename cli and config options signer->ui (#3232) * rename options signer->ui * rename config signer->ui Former-commit-id: f4c4934831f80f9217ff4e6afcaa95cdd41caf45
This commit is contained in:
parent
2e9cde38e4
commit
0d20b21ee8
@ -44,7 +44,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-cli": "^6.10.1",
|
"babel-cli": "^6.10.1",
|
||||||
"babel-core": "^6.10.4",
|
"babel-core": "^6.10.4",
|
||||||
"babel-eslint": "^6.1.2",
|
"babel-eslint": "^7.1.0",
|
||||||
"babel-loader": "^6.2.3",
|
"babel-loader": "^6.2.3",
|
||||||
"babel-plugin-lodash": "^3.2.2",
|
"babel-plugin-lodash": "^3.2.2",
|
||||||
"babel-plugin-transform-class-properties": "^6.11.5",
|
"babel-plugin-transform-class-properties": "^6.11.5",
|
||||||
@ -126,6 +126,9 @@
|
|||||||
"marked": "^0.3.6",
|
"marked": "^0.3.6",
|
||||||
"material-ui": "^0.16.1",
|
"material-ui": "^0.16.1",
|
||||||
"material-ui-chip-input": "^0.8.0",
|
"material-ui-chip-input": "^0.8.0",
|
||||||
|
"mobx": "^2.6.1",
|
||||||
|
"mobx-react": "^3.5.8",
|
||||||
|
"mobx-react-devtools": "^4.2.9",
|
||||||
"moment": "^2.14.1",
|
"moment": "^2.14.1",
|
||||||
"qs": "^6.3.0",
|
"qs": "^6.3.0",
|
||||||
"react": "^15.2.1",
|
"react": "^15.2.1",
|
||||||
|
@ -57,4 +57,8 @@ export default class DappReg {
|
|||||||
getContent (id) {
|
getContent (id) {
|
||||||
return this.meta(id, 'CONTENT');
|
return this.meta(id, 'CONTENT');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getManifest (id) {
|
||||||
|
return this.meta(id, 'MANIFEST');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
|
||||||
import Contracts from '../../contracts';
|
import DappsStore from '../Dapps/dappsStore';
|
||||||
import { fetchAvailable } from '../Dapps/registry';
|
|
||||||
|
|
||||||
import styles from './dapp.css';
|
import styles from './dapp.css';
|
||||||
|
|
||||||
|
@observer
|
||||||
export default class Dapp extends Component {
|
export default class Dapp extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
api: PropTypes.object.isRequired
|
api: PropTypes.object.isRequired
|
||||||
@ -30,17 +31,12 @@ export default class Dapp extends Component {
|
|||||||
params: PropTypes.object
|
params: PropTypes.object
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
store = new DappsStore(this.context.api);
|
||||||
app: null
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount () {
|
|
||||||
this.lookup();
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { app } = this.state;
|
|
||||||
const { dappsUrl } = this.context.api;
|
const { dappsUrl } = this.context.api;
|
||||||
|
const { id } = this.props.params;
|
||||||
|
const app = this.store.apps.find((app) => app.id === id);
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
return null;
|
return null;
|
||||||
@ -48,12 +44,6 @@ export default class Dapp extends Component {
|
|||||||
|
|
||||||
let src = null;
|
let src = null;
|
||||||
switch (app.type) {
|
switch (app.type) {
|
||||||
case 'builtin':
|
|
||||||
const dapphost = process.env.NODE_ENV === 'production' && !app.secure
|
|
||||||
? `${dappsUrl}/ui`
|
|
||||||
: '';
|
|
||||||
src = `${dapphost}/${app.url}.html`;
|
|
||||||
break;
|
|
||||||
case 'local':
|
case 'local':
|
||||||
src = `${dappsUrl}/${app.id}/`;
|
src = `${dappsUrl}/${app.id}/`;
|
||||||
break;
|
break;
|
||||||
@ -61,7 +51,10 @@ export default class Dapp extends Component {
|
|||||||
src = `${dappsUrl}/${app.contentHash}/`;
|
src = `${dappsUrl}/${app.contentHash}/`;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.error('unknown type', app.type);
|
const dapphost = process.env.NODE_ENV === 'production' && !app.secure
|
||||||
|
? `${dappsUrl}/ui`
|
||||||
|
: '';
|
||||||
|
src = `${dapphost}/${app.url}.html`;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,30 +69,4 @@ export default class Dapp extends Component {
|
|||||||
</iframe>
|
</iframe>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup () {
|
|
||||||
const { api } = this.context;
|
|
||||||
const { id } = this.props.params;
|
|
||||||
const { dappReg } = Contracts.get();
|
|
||||||
|
|
||||||
fetchAvailable(api)
|
|
||||||
.then((available) => {
|
|
||||||
return available.find((app) => app.id === id);
|
|
||||||
})
|
|
||||||
.then((app) => {
|
|
||||||
if (app.type !== 'network') {
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dappReg
|
|
||||||
.getContent(app.id)
|
|
||||||
.then((contentHash) => {
|
|
||||||
app.contentHash = api.util.bytesToHex(contentHash).substr(2);
|
|
||||||
return app;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then((app) => {
|
|
||||||
this.setState({ app });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
import DoneIcon from 'material-ui/svg-icons/action/done';
|
import DoneIcon from 'material-ui/svg-icons/action/done';
|
||||||
import { List, ListItem } from 'material-ui/List';
|
import { List, ListItem } from 'material-ui/List';
|
||||||
import Checkbox from 'material-ui/Checkbox';
|
import Checkbox from 'material-ui/Checkbox';
|
||||||
@ -23,57 +24,67 @@ import { Modal, Button } from '../../../ui';
|
|||||||
|
|
||||||
import styles from './AddDapps.css';
|
import styles from './AddDapps.css';
|
||||||
|
|
||||||
|
@observer
|
||||||
export default class AddDapps extends Component {
|
export default class AddDapps extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
available: PropTypes.array.isRequired,
|
store: PropTypes.object.isRequired
|
||||||
hidden: PropTypes.array.isRequired,
|
|
||||||
open: PropTypes.bool.isRequired,
|
|
||||||
onHideApp: PropTypes.func.isRequired,
|
|
||||||
onShowApp: PropTypes.func.isRequired,
|
|
||||||
onClose: PropTypes.func.isRequired
|
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { onClose, open, available } = this.props;
|
const { store } = this.props;
|
||||||
|
|
||||||
|
if (!store.modalOpen) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
compact
|
compact
|
||||||
title='visible applications'
|
title='visible applications'
|
||||||
actions={ [
|
actions={ [
|
||||||
<Button label={ 'Done' } key='done' onClick={ onClose } icon={ <DoneIcon /> } />
|
<Button
|
||||||
|
label={ 'Done' }
|
||||||
|
key='done'
|
||||||
|
onClick={ store.closeModal }
|
||||||
|
icon={ <DoneIcon /> }
|
||||||
|
/>
|
||||||
] }
|
] }
|
||||||
visible={ open }
|
visible
|
||||||
scroll>
|
scroll>
|
||||||
<List>
|
<List>
|
||||||
{ available.map(this.renderApp) }
|
{ store.apps.map(this.renderApp) }
|
||||||
</List>
|
</List>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderApp = (app) => {
|
renderApp = (app) => {
|
||||||
const { hidden, onHideApp, onShowApp } = this.props;
|
const { store } = this.props;
|
||||||
const isHidden = hidden.includes(app.id);
|
const isHidden = store.hidden.includes(app.id);
|
||||||
const description = (
|
|
||||||
<div className={ styles.description }>
|
|
||||||
{ app.description }
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
const onCheck = () => {
|
const onCheck = () => {
|
||||||
if (isHidden) {
|
if (isHidden) {
|
||||||
onShowApp(app.id);
|
store.showApp(app.id);
|
||||||
} else {
|
} else {
|
||||||
onHideApp(app.id);
|
store.hideApp(app.id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={ app.id }
|
key={ app.id }
|
||||||
leftCheckbox={ <Checkbox checked={ !isHidden } onCheck={ onCheck } /> }
|
leftCheckbox={
|
||||||
|
<Checkbox
|
||||||
|
checked={ !isHidden }
|
||||||
|
onCheck={ onCheck }
|
||||||
|
/>
|
||||||
|
}
|
||||||
primaryText={ app.name }
|
primaryText={ app.name }
|
||||||
secondaryText={ description } />
|
secondaryText={
|
||||||
|
<div className={ styles.description }>
|
||||||
|
{ app.description }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,10 @@ export default class Summary extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let image = <div className={ styles.image }> </div>;
|
let image = <div className={ styles.image }> </div>;
|
||||||
if (app.image) {
|
if (app.type === 'local') {
|
||||||
image = <img src={ `http://127.0.0.1:${dappsPort}${app.image}` } className={ styles.image } />;
|
|
||||||
} else if (app.iconUrl) {
|
|
||||||
image = <img src={ `http://127.0.0.1:${dappsPort}/${app.id}/${app.iconUrl}` } className={ styles.image } />;
|
image = <img src={ `http://127.0.0.1:${dappsPort}/${app.id}/${app.iconUrl}` } className={ styles.image } />;
|
||||||
|
} else {
|
||||||
|
image = <img src={ `http://127.0.0.1:${dappsPort}${app.image}` } className={ styles.image } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -52,9 +52,16 @@ export default class Summary extends Component {
|
|||||||
<div className={ styles.description }>
|
<div className={ styles.description }>
|
||||||
<ContainerTitle
|
<ContainerTitle
|
||||||
className={ styles.title }
|
className={ styles.title }
|
||||||
title={ <Link to={ `/app/${app.id}` }>{ app.name }</Link> }
|
title={
|
||||||
byline={ app.description } />
|
<Link to={ `/app/${app.id}` }>
|
||||||
<div className={ styles.author }>{ app.author }, v{ app.version }</div>
|
{ app.name }
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
byline={ app.description }
|
||||||
|
/>
|
||||||
|
<div className={ styles.author }>
|
||||||
|
{ app.author }, v{ app.version }
|
||||||
|
</div>
|
||||||
{ this.props.children }
|
{ this.props.children }
|
||||||
</div>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
|
@ -15,60 +15,46 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { observer } from 'mobx-react';
|
||||||
|
|
||||||
import Contracts from '../../contracts';
|
|
||||||
import { hashToImageUrl } from '../../redux/util';
|
|
||||||
import { Actionbar, Page } from '../../ui';
|
import { Actionbar, Page } from '../../ui';
|
||||||
import FlatButton from 'material-ui/FlatButton';
|
import FlatButton from 'material-ui/FlatButton';
|
||||||
import EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
|
import EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
|
||||||
|
|
||||||
import { fetchAvailable } from './registry';
|
import DappsStore from './dappsStore';
|
||||||
import { readHiddenApps, writeHiddenApps } from './hidden';
|
|
||||||
|
|
||||||
import AddDapps from './AddDapps';
|
import AddDapps from './AddDapps';
|
||||||
import Summary from './Summary';
|
import Summary from './Summary';
|
||||||
|
|
||||||
import styles from './dapps.css';
|
import styles from './dapps.css';
|
||||||
|
|
||||||
|
@observer
|
||||||
export default class Dapps extends Component {
|
export default class Dapps extends Component {
|
||||||
static contextTypes = {
|
static contextTypes = {
|
||||||
api: PropTypes.object.isRequired
|
api: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
store = new DappsStore(this.context.api);
|
||||||
available: [],
|
|
||||||
hidden: [],
|
|
||||||
modalOpen: false
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount () {
|
|
||||||
this.loadAvailableApps();
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { available, hidden, modalOpen } = this.state;
|
|
||||||
const apps = available.filter((app) => !hidden.includes(app.id));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AddDapps
|
<AddDapps store={ this.store } />
|
||||||
available={ available }
|
|
||||||
hidden={ hidden }
|
|
||||||
open={ modalOpen }
|
|
||||||
onHideApp={ this.onHideApp }
|
|
||||||
onShowApp={ this.onShowApp }
|
|
||||||
onClose={ this.closeModal }
|
|
||||||
/>
|
|
||||||
<Actionbar
|
<Actionbar
|
||||||
className={ styles.toolbar }
|
className={ styles.toolbar }
|
||||||
title='Decentralized Applications'
|
title='Decentralized Applications'
|
||||||
buttons={ [
|
buttons={ [
|
||||||
<FlatButton label='edit' key='edit' icon={ <EyeIcon /> } onClick={ this.openModal } />
|
<FlatButton
|
||||||
|
label='edit'
|
||||||
|
key='edit'
|
||||||
|
icon={ <EyeIcon /> }
|
||||||
|
onClick={ this.store.openModal }
|
||||||
|
/>
|
||||||
] }
|
] }
|
||||||
/>
|
/>
|
||||||
<Page>
|
<Page>
|
||||||
<div className={ styles.list }>
|
<div className={ styles.list }>
|
||||||
{ apps.map(this.renderApp) }
|
{ this.store.visible.map(this.renderApp) }
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</Page>
|
||||||
</div>
|
</div>
|
||||||
@ -76,10 +62,6 @@ export default class Dapps extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderApp = (app) => {
|
renderApp = (app) => {
|
||||||
if (!app.name) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={ styles.item }
|
className={ styles.item }
|
||||||
@ -88,81 +70,4 @@ export default class Dapps extends Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onHideApp = (id) => {
|
|
||||||
const { hidden } = this.state;
|
|
||||||
const newHidden = hidden.concat(id);
|
|
||||||
|
|
||||||
this.setState({ hidden: newHidden });
|
|
||||||
writeHiddenApps(newHidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
onShowApp = (id) => {
|
|
||||||
const { hidden } = this.state;
|
|
||||||
const newHidden = hidden.filter((_id) => _id !== id);
|
|
||||||
|
|
||||||
this.setState({ hidden: newHidden });
|
|
||||||
writeHiddenApps(newHidden);
|
|
||||||
}
|
|
||||||
|
|
||||||
openModal = () => {
|
|
||||||
this.setState({ modalOpen: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
closeModal = () => {
|
|
||||||
this.setState({ modalOpen: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
loadAvailableApps () {
|
|
||||||
const { api } = this.context;
|
|
||||||
|
|
||||||
fetchAvailable(api)
|
|
||||||
.then((available) => {
|
|
||||||
this.setState({
|
|
||||||
available,
|
|
||||||
hidden: readHiddenApps()
|
|
||||||
});
|
|
||||||
|
|
||||||
this.loadContent();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
loadContent () {
|
|
||||||
const { api } = this.context;
|
|
||||||
const { available } = this.state;
|
|
||||||
const { dappReg } = Contracts.get();
|
|
||||||
|
|
||||||
return Promise
|
|
||||||
.all(available.map((app) => dappReg.getImage(app.id)))
|
|
||||||
.then((images) => {
|
|
||||||
const _available = images
|
|
||||||
.map(hashToImageUrl)
|
|
||||||
.map((image, index) => Object.assign({}, available[index], { image }));
|
|
||||||
|
|
||||||
this.setState({ available: _available });
|
|
||||||
const _networkApps = _available.filter((app) => app.network);
|
|
||||||
|
|
||||||
return Promise
|
|
||||||
.all(_networkApps.map((app) => dappReg.getContent(app.id)))
|
|
||||||
.then((content) => {
|
|
||||||
const networkApps = content.map((_contentHash, index) => {
|
|
||||||
const networkApp = _networkApps[index];
|
|
||||||
const contentHash = api.util.bytesToHex(_contentHash).substr(2);
|
|
||||||
const app = _available.find((_app) => _app.id === networkApp.id);
|
|
||||||
|
|
||||||
console.log(`found content for ${app.id} at ${contentHash}`);
|
|
||||||
return Object.assign({}, app, { contentHash });
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
available: _available.map((app) => {
|
|
||||||
return Object.assign({}, networkApps.find((napp) => app.id === napp.id) || app);
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn('loadImages', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
256
js/src/views/Dapps/dappsStore.js
Normal file
256
js/src/views/Dapps/dappsStore.js
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import { action, computed, observable } from 'mobx';
|
||||||
|
|
||||||
|
import Contracts from '../../contracts';
|
||||||
|
import { hashToImageUrl } from '../../redux/util';
|
||||||
|
|
||||||
|
const builtinApps = [
|
||||||
|
{
|
||||||
|
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
||||||
|
url: 'basiccoin',
|
||||||
|
name: 'Token Deployment',
|
||||||
|
description: 'Deploy new basic tokens that you are able to send around',
|
||||||
|
author: 'Parity Team <admin@ethcore.io>',
|
||||||
|
version: '1.0.0'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '0xd1adaede68d344519025e2ff574650cd99d3830fe6d274c7a7843cdc00e17938',
|
||||||
|
url: 'registry',
|
||||||
|
name: 'Registry',
|
||||||
|
description: 'A global registry of addresses on the network',
|
||||||
|
author: 'Parity Team <admin@ethcore.io>',
|
||||||
|
version: '1.0.0'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '0x0a8048117e51e964628d0f2d26342b3cd915248b59bcce2721e1d05f5cfa2208',
|
||||||
|
url: 'tokenreg',
|
||||||
|
name: 'Token Registry',
|
||||||
|
description: 'A registry of transactable tokens on the network',
|
||||||
|
author: 'Parity Team <admin@ethcore.io>',
|
||||||
|
version: '1.0.0'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '0xf49089046f53f5d2e5f3513c1c32f5ff57d986e46309a42d2b249070e4e72c46',
|
||||||
|
url: 'signaturereg',
|
||||||
|
name: 'Method Registry',
|
||||||
|
description: 'A registry of method signatures for lookups on transactions',
|
||||||
|
author: 'Parity Team <admin@ethcore.io>',
|
||||||
|
version: '1.0.0'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '0x058740ee9a5a3fb9f1cfa10752baec87e09cc45cd7027fd54708271aca300c75',
|
||||||
|
url: 'githubhint',
|
||||||
|
name: 'GitHub Hint',
|
||||||
|
description: 'A mapping of GitHub URLs to hashes for use in contracts as references',
|
||||||
|
author: 'Parity Team <admin@ethcore.io>',
|
||||||
|
version: '1.0.0'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export default class DappsStore {
|
||||||
|
@observable apps = [];
|
||||||
|
@observable hidden = [];
|
||||||
|
@observable modalOpen = false;
|
||||||
|
|
||||||
|
constructor (api) {
|
||||||
|
this._api = api;
|
||||||
|
|
||||||
|
this._readHiddenApps();
|
||||||
|
this._fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@computed get visible () {
|
||||||
|
return this.apps.filter((app) => !this.hidden.includes(app.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@action openModal = () => {
|
||||||
|
this.modalOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@action closeModal = () => {
|
||||||
|
this.modalOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@action hideApp = (id) => {
|
||||||
|
this.hidden = this.hidden.concat(id);
|
||||||
|
this._writeHiddenApps();
|
||||||
|
}
|
||||||
|
|
||||||
|
@action showApp = (id) => {
|
||||||
|
this.hidden = this.hidden.filter((_id) => _id !== id);
|
||||||
|
this._writeHiddenApps();
|
||||||
|
}
|
||||||
|
|
||||||
|
_getHost (api) {
|
||||||
|
return process.env.NODE_ENV === 'production'
|
||||||
|
? this._api.dappsUrl
|
||||||
|
: '';
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetch () {
|
||||||
|
Promise
|
||||||
|
.all([
|
||||||
|
this._fetchLocal(),
|
||||||
|
this._fetchRegistry()
|
||||||
|
])
|
||||||
|
.then(([localApps, registryApps]) => {
|
||||||
|
this.apps = []
|
||||||
|
.concat(localApps)
|
||||||
|
.concat(registryApps)
|
||||||
|
.filter((app) => app.id)
|
||||||
|
.sort((a, b) => (a.name || '').localeCompare(b.name || ''));
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('DappStore:fetch', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchRegistry () {
|
||||||
|
const { dappReg } = Contracts.get();
|
||||||
|
|
||||||
|
return dappReg
|
||||||
|
.count()
|
||||||
|
.then((_count) => {
|
||||||
|
const count = _count.toNumber();
|
||||||
|
const promises = [];
|
||||||
|
|
||||||
|
for (let index = 0; index < count; index++) {
|
||||||
|
promises.push(dappReg.at(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(promises);
|
||||||
|
})
|
||||||
|
.then((appsInfo) => {
|
||||||
|
const appIds = appsInfo.map(([appId, owner]) => {
|
||||||
|
return this._api.util.bytesToHex(appId);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all([
|
||||||
|
Promise.all(appIds.map((appId) => dappReg.getImage(appId))),
|
||||||
|
Promise.all(appIds.map((appId) => dappReg.getContent(appId))),
|
||||||
|
Promise.all(appIds.map((appId) => dappReg.getManifest(appId)))
|
||||||
|
])
|
||||||
|
.then(([imageIds, contentIds, manifestIds]) => {
|
||||||
|
return appIds.map((appId, index) => {
|
||||||
|
const app = builtinApps.find((ba) => ba.id === appId) || {
|
||||||
|
id: appId,
|
||||||
|
contentHash: this._api.util.bytesToHex(contentIds[index]).substr(2),
|
||||||
|
manifestHash: this._api.util.bytesToHex(manifestIds[index]).substr(2),
|
||||||
|
type: 'network'
|
||||||
|
};
|
||||||
|
|
||||||
|
app.image = hashToImageUrl(imageIds[index]);
|
||||||
|
app.type = app.type || 'builtin';
|
||||||
|
|
||||||
|
return app;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then((apps) => {
|
||||||
|
return Promise
|
||||||
|
.all(apps.map((app) => {
|
||||||
|
return app.manifestHash
|
||||||
|
? this._fetchManifest(app.manifestHash)
|
||||||
|
: null;
|
||||||
|
}))
|
||||||
|
.then((manifests) => {
|
||||||
|
return apps.map((app, index) => {
|
||||||
|
const manifest = manifests[index];
|
||||||
|
|
||||||
|
if (manifest) {
|
||||||
|
app.manifestHash = null;
|
||||||
|
Object.keys(manifest)
|
||||||
|
.filter((key) => key !== 'id')
|
||||||
|
.forEach((key) => {
|
||||||
|
app[key] = manifest[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return app;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then((apps) => {
|
||||||
|
return apps.filter((app) => {
|
||||||
|
return !app.manifestHash && app.id;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('DappsStore:fetchRegistry', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchManifest (manifestHash, count = 0) {
|
||||||
|
return fetch(`${this._getHost()}/api/content/${manifestHash}/`)
|
||||||
|
.then((response) => {
|
||||||
|
if (response.ok) {
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count < 1) {
|
||||||
|
return this._fetchManifest(manifestHash, count + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
if (count < 1) {
|
||||||
|
return this._fetchManifest(manifestHash, count + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_fetchLocal () {
|
||||||
|
return fetch(`${this._getHost()}/api/apps`)
|
||||||
|
.then((response) => {
|
||||||
|
return response.ok
|
||||||
|
? response.json()
|
||||||
|
: [];
|
||||||
|
})
|
||||||
|
.then((localApps) => {
|
||||||
|
return localApps
|
||||||
|
.filter((app) => app && app.id && !['ui'].includes(app.id))
|
||||||
|
.map((app) => {
|
||||||
|
app.type = 'local';
|
||||||
|
return app;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('DappsStore:fetchLocal', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_readHiddenApps () {
|
||||||
|
const stored = localStorage.getItem('hiddenApps');
|
||||||
|
|
||||||
|
if (stored) {
|
||||||
|
try {
|
||||||
|
this.hidden = JSON.parse(stored);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('DappsStore:readHiddenApps', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_writeHiddenApps () {
|
||||||
|
localStorage.setItem('hiddenApps', JSON.stringify(this.hidden));
|
||||||
|
}
|
||||||
|
}
|
@ -1,35 +0,0 @@
|
|||||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
|
||||||
// This file is part of Parity.
|
|
||||||
|
|
||||||
// Parity is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
|
|
||||||
// Parity is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
const defaultHidden = [];
|
|
||||||
|
|
||||||
export function readHiddenApps () {
|
|
||||||
const stored = localStorage.getItem('hiddenApps');
|
|
||||||
|
|
||||||
if (stored) {
|
|
||||||
try {
|
|
||||||
return JSON.parse(stored);
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('readHiddenApps', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return defaultHidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function writeHiddenApps (hidden) {
|
|
||||||
localStorage.setItem('hiddenApps', JSON.stringify(hidden));
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
|
||||||
// This file is part of Parity.
|
|
||||||
|
|
||||||
// Parity is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
|
|
||||||
// Parity is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import BigNumber from 'bignumber.js';
|
|
||||||
|
|
||||||
const builtinApps = [
|
|
||||||
{
|
|
||||||
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
|
||||||
url: 'basiccoin',
|
|
||||||
name: 'Token Deployment',
|
|
||||||
description: 'Deploy new basic tokens that you are able to send around',
|
|
||||||
author: 'Parity Team <admin@ethcore.io>',
|
|
||||||
version: '1.0.0'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '0xd1adaede68d344519025e2ff574650cd99d3830fe6d274c7a7843cdc00e17938',
|
|
||||||
url: 'registry',
|
|
||||||
name: 'Registry',
|
|
||||||
description: 'A global registry of addresses on the network',
|
|
||||||
author: 'Parity Team <admin@ethcore.io>',
|
|
||||||
version: '1.0.0'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '0x0a8048117e51e964628d0f2d26342b3cd915248b59bcce2721e1d05f5cfa2208',
|
|
||||||
url: 'tokenreg',
|
|
||||||
name: 'Token Registry',
|
|
||||||
description: 'A registry of transactable tokens on the network',
|
|
||||||
author: 'Parity Team <admin@ethcore.io>',
|
|
||||||
version: '1.0.0'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '0xf49089046f53f5d2e5f3513c1c32f5ff57d986e46309a42d2b249070e4e72c46',
|
|
||||||
url: 'signaturereg',
|
|
||||||
name: 'Method Registry',
|
|
||||||
description: 'A registry of method signatures for lookups on transactions',
|
|
||||||
author: 'Parity Team <admin@ethcore.io>',
|
|
||||||
version: '1.0.0'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '0x058740ee9a5a3fb9f1cfa10752baec87e09cc45cd7027fd54708271aca300c75',
|
|
||||||
url: 'githubhint',
|
|
||||||
name: 'GitHub Hint',
|
|
||||||
description: 'A mapping of GitHub URLs to hashes for use in contracts as references',
|
|
||||||
author: 'Parity Team <admin@ethcore.io>',
|
|
||||||
version: '1.0.0',
|
|
||||||
secure: true
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
// TODO: This is just since we are moving gavcoin to its own repo, for a proper network solution
|
|
||||||
// we need to pull the network apps from the dapp registry. (Builtins & local apps unaffected)
|
|
||||||
// TODO: Manifest needs to be pulled from the content as well, however since the content may or may
|
|
||||||
// not be available locally (and refreshes work for index, and will give a 503), we are putting it
|
|
||||||
// in here. This part needs to be cleaned up.
|
|
||||||
const networkApps = [
|
|
||||||
{
|
|
||||||
id: '0xd798a48831b4ccdbc71de206a1d6a4aa73546c7b6f59c22a47452af414dc64d6',
|
|
||||||
name: 'GAVcoin',
|
|
||||||
description: 'Manage your GAVcoins, the hottest new property in crypto',
|
|
||||||
author: 'Gavin Wood',
|
|
||||||
version: '1.0.0'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
function getHost (api) {
|
|
||||||
return process.env.NODE_ENV === 'production'
|
|
||||||
? api.dappsUrl
|
|
||||||
: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchAvailable (api) {
|
|
||||||
return fetch(`${getHost(api)}/api/apps`)
|
|
||||||
.then((response) => {
|
|
||||||
return response.ok
|
|
||||||
? response.json()
|
|
||||||
: [];
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn('fetchAvailable', error);
|
|
||||||
return [];
|
|
||||||
})
|
|
||||||
.then((_localApps) => {
|
|
||||||
const localApps = _localApps
|
|
||||||
.filter((app) => !['ui'].includes(app.id))
|
|
||||||
.map((app) => {
|
|
||||||
app.type = 'local';
|
|
||||||
return app;
|
|
||||||
});
|
|
||||||
|
|
||||||
return api.parity
|
|
||||||
.registryAddress()
|
|
||||||
.then((registryAddress) => {
|
|
||||||
if (new BigNumber(registryAddress).eq(0)) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const _builtinApps = builtinApps
|
|
||||||
.map((app) => {
|
|
||||||
app.type = 'builtin';
|
|
||||||
return app;
|
|
||||||
});
|
|
||||||
|
|
||||||
return networkApps
|
|
||||||
.map((app) => {
|
|
||||||
app.type = 'network';
|
|
||||||
return app;
|
|
||||||
})
|
|
||||||
.concat(_builtinApps);
|
|
||||||
})
|
|
||||||
.then((registryApps) => {
|
|
||||||
return registryApps
|
|
||||||
.concat(localApps)
|
|
||||||
.sort((a, b) => (a.name || '').localeCompare(b.name || ''));
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn('fetchAvailable', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function fetchManifest (api, app, contentHash) {
|
|
||||||
return fetch(`${getHost(api)}/${contentHash}/manifest.json`)
|
|
||||||
.then((response) => {
|
|
||||||
return response.ok
|
|
||||||
? response.json()
|
|
||||||
: {};
|
|
||||||
})
|
|
||||||
.then((manifest) => {
|
|
||||||
Object.keys.forEach((key) => {
|
|
||||||
app[key] = manifest[key];
|
|
||||||
});
|
|
||||||
|
|
||||||
return app;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn('fetchManifest', error);
|
|
||||||
});
|
|
||||||
}
|
|
@ -35,7 +35,7 @@ export default class Proxy extends Component {
|
|||||||
<ContainerTitle title='Proxy' />
|
<ContainerTitle title='Proxy' />
|
||||||
<div className={ layout.layout }>
|
<div className={ layout.layout }>
|
||||||
<div className={ layout.overview }>
|
<div className={ layout.overview }>
|
||||||
<div>The proxy setup allows you to access Parity and all associated decentralized applications via memororable addresses.</div>
|
<div>The proxy setup allows you to access Parity and all associated decentralized applications via memorable addresses.</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={ layout.details }>
|
<div className={ layout.details }>
|
||||||
<div className={ styles.details }>
|
<div className={ styles.details }>
|
||||||
|
@ -49,7 +49,7 @@ const defaultViews = {
|
|||||||
label: 'Applications',
|
label: 'Applications',
|
||||||
route: '/apps',
|
route: '/apps',
|
||||||
value: 'app',
|
value: 'app',
|
||||||
description: 'Distributed applications that interact with the underlying network. Add applications, manage you application portfolio and interact with application from around the newtork.'
|
description: 'Distributed applications that interact with the underlying network. Add applications, manage you application portfolio and interact with application from around the network.'
|
||||||
},
|
},
|
||||||
|
|
||||||
contracts: {
|
contracts: {
|
||||||
|
@ -40,7 +40,7 @@ class Views extends Component {
|
|||||||
<div className={ layout.overview }>
|
<div className={ layout.overview }>
|
||||||
<div>Manage the available application views, using only the parts of the application that is applicable to you.</div>
|
<div>Manage the available application views, using only the parts of the application that is applicable to you.</div>
|
||||||
<div>Are you an end-user? The defaults are setups for both beginner and advanced users alike.</div>
|
<div>Are you an end-user? The defaults are setups for both beginner and advanced users alike.</div>
|
||||||
<div>Are you a developer? Add some features to manage contracts are interact with application develoyments.</div>
|
<div>Are you a developer? Add some features to manage contracts are interact with application deployments.</div>
|
||||||
<div>Are you a miner or run a large-scale node? Add the features to give you all the information needed to watch the node operation.</div>
|
<div>Are you a miner or run a large-scale node? Add the features to give you all the information needed to watch the node operation.</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={ layout.details }>
|
<div className={ layout.details }>
|
||||||
|
@ -12,7 +12,7 @@ unlock = ["0xdeadbeefcafe0000000000000000000000000000"]
|
|||||||
password = ["~/.safe/password.file"]
|
password = ["~/.safe/password.file"]
|
||||||
keys_iterations = 10240
|
keys_iterations = 10240
|
||||||
|
|
||||||
[signer]
|
[ui]
|
||||||
force = false
|
force = false
|
||||||
disable = false
|
disable = false
|
||||||
port = 8180
|
port = 8180
|
||||||
|
@ -8,7 +8,7 @@ chain = "./chain.json"
|
|||||||
unlock = ["0x1", "0x2", "0x3"]
|
unlock = ["0x1", "0x2", "0x3"]
|
||||||
password = ["passwdfile path"]
|
password = ["passwdfile path"]
|
||||||
|
|
||||||
[signer]
|
[ui]
|
||||||
disable = true
|
disable = true
|
||||||
|
|
||||||
[network]
|
[network]
|
||||||
|
@ -90,18 +90,18 @@ usage! {
|
|||||||
flag_keys_iterations: u32 = 10240u32,
|
flag_keys_iterations: u32 = 10240u32,
|
||||||
or |c: &Config| otry!(c.account).keys_iterations.clone(),
|
or |c: &Config| otry!(c.account).keys_iterations.clone(),
|
||||||
|
|
||||||
flag_force_signer: bool = false,
|
flag_force_ui: bool = false,
|
||||||
or |c: &Config| otry!(c.signer).force.clone(),
|
or |c: &Config| otry!(c.ui).force.clone(),
|
||||||
flag_no_signer: bool = false,
|
flag_no_ui: bool = false,
|
||||||
or |c: &Config| otry!(c.signer).disable.clone(),
|
or |c: &Config| otry!(c.ui).disable.clone(),
|
||||||
flag_signer_port: u16 = 8180u16,
|
flag_ui_port: u16 = 8180u16,
|
||||||
or |c: &Config| otry!(c.signer).port.clone(),
|
or |c: &Config| otry!(c.ui).port.clone(),
|
||||||
flag_signer_interface: String = "local",
|
flag_ui_interface: String = "local",
|
||||||
or |c: &Config| otry!(c.signer).interface.clone(),
|
or |c: &Config| otry!(c.ui).interface.clone(),
|
||||||
flag_signer_path: String = "$HOME/.parity/signer",
|
flag_ui_path: String = "$HOME/.parity/signer",
|
||||||
or |c: &Config| otry!(c.signer).path.clone(),
|
or |c: &Config| otry!(c.ui).path.clone(),
|
||||||
// NOTE [todr] For security reasons don't put this to config files
|
// NOTE [todr] For security reasons don't put this to config files
|
||||||
flag_signer_no_validation: bool = false, or |_| None,
|
flag_ui_no_validation: bool = false, or |_| None,
|
||||||
|
|
||||||
// -- Networking Options
|
// -- Networking Options
|
||||||
flag_warp: bool = false,
|
flag_warp: bool = false,
|
||||||
@ -271,7 +271,7 @@ usage! {
|
|||||||
struct Config {
|
struct Config {
|
||||||
parity: Option<Operating>,
|
parity: Option<Operating>,
|
||||||
account: Option<Account>,
|
account: Option<Account>,
|
||||||
signer: Option<Signer>,
|
ui: Option<Ui>,
|
||||||
network: Option<Network>,
|
network: Option<Network>,
|
||||||
rpc: Option<Rpc>,
|
rpc: Option<Rpc>,
|
||||||
ipc: Option<Ipc>,
|
ipc: Option<Ipc>,
|
||||||
@ -302,7 +302,7 @@ struct Account {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
#[derive(Default, Debug, PartialEq, RustcDecodable)]
|
||||||
struct Signer {
|
struct Ui {
|
||||||
force: Option<bool>,
|
force: Option<bool>,
|
||||||
disable: Option<bool>,
|
disable: Option<bool>,
|
||||||
port: Option<u16>,
|
port: Option<u16>,
|
||||||
@ -418,7 +418,7 @@ struct Misc {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::{
|
use super::{
|
||||||
Args, ArgsError,
|
Args, ArgsError,
|
||||||
Config, Operating, Account, Signer, Network, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, VM, Misc
|
Config, Operating, Account, Ui, Network, Rpc, Ipc, Dapps, Mining, Footprint, Snapshots, VM, Misc
|
||||||
};
|
};
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
@ -511,12 +511,12 @@ mod tests {
|
|||||||
flag_password: vec!["~/.safe/password.file".into()],
|
flag_password: vec!["~/.safe/password.file".into()],
|
||||||
flag_keys_iterations: 10240u32,
|
flag_keys_iterations: 10240u32,
|
||||||
|
|
||||||
flag_force_signer: false,
|
flag_force_ui: false,
|
||||||
flag_no_signer: false,
|
flag_no_ui: false,
|
||||||
flag_signer_port: 8180u16,
|
flag_ui_port: 8180u16,
|
||||||
flag_signer_interface: "127.0.0.1".into(),
|
flag_ui_interface: "127.0.0.1".into(),
|
||||||
flag_signer_path: "$HOME/.parity/signer".into(),
|
flag_ui_path: "$HOME/.parity/signer".into(),
|
||||||
flag_signer_no_validation: false,
|
flag_ui_no_validation: false,
|
||||||
|
|
||||||
// -- Networking Options
|
// -- Networking Options
|
||||||
flag_warp: true,
|
flag_warp: true,
|
||||||
@ -675,7 +675,7 @@ mod tests {
|
|||||||
password: Some(vec!["passwdfile path".into()]),
|
password: Some(vec!["passwdfile path".into()]),
|
||||||
keys_iterations: None,
|
keys_iterations: None,
|
||||||
}),
|
}),
|
||||||
signer: Some(Signer {
|
ui: Some(Ui {
|
||||||
force: None,
|
force: None,
|
||||||
disable: Some(true),
|
disable: Some(true),
|
||||||
port: None,
|
port: None,
|
||||||
|
@ -43,28 +43,29 @@ Operating Options:
|
|||||||
Account Options:
|
Account Options:
|
||||||
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
|
--unlock ACCOUNTS Unlock ACCOUNTS for the duration of the execution.
|
||||||
ACCOUNTS is a comma-delimited list of addresses.
|
ACCOUNTS is a comma-delimited list of addresses.
|
||||||
Implies --no-signer. (default: {flag_unlock:?})
|
Implies --no-ui. (default: {flag_unlock:?})
|
||||||
--password FILE Provide a file containing a password for unlocking
|
--password FILE Provide a file containing a password for unlocking
|
||||||
an account. Leading and trailing whitespace is trimmed.
|
an account. Leading and trailing whitespace is trimmed.
|
||||||
(default: {flag_password:?})
|
(default: {flag_password:?})
|
||||||
--keys-iterations NUM Specify the number of iterations to use when
|
--keys-iterations NUM Specify the number of iterations to use when
|
||||||
deriving key from the password (bigger is more
|
deriving key from the password (bigger is more
|
||||||
secure) (default: {flag_keys_iterations}).
|
secure) (default: {flag_keys_iterations}).
|
||||||
--force-signer Enable Trusted Signer WebSocket endpoint used by
|
|
||||||
Signer UIs, even when --unlock is in use.
|
UI Options:
|
||||||
(default: ${flag_force_signer})
|
--force-ui Enable Trusted UI WebSocket endpoint,
|
||||||
--no-signer Disable Trusted Signer WebSocket endpoint used by
|
even when --unlock is in use. (default: ${flag_force_ui})
|
||||||
Signer UIs. (default: ${flag_no_signer})
|
--no-ui Disable Trusted UI WebSocket endpoint.
|
||||||
--signer-port PORT Specify the port of Trusted Signer server
|
(default: ${flag_no_ui})
|
||||||
(default: {flag_signer_port}).
|
--ui-port PORT Specify the port of Trusted UI server
|
||||||
--signer-interface IP Specify the hostname portion of the Trusted Signer
|
(default: {flag_ui_port}).
|
||||||
|
--ui-interface IP Specify the hostname portion of the Trusted UI
|
||||||
server, IP should be an interface's IP address,
|
server, IP should be an interface's IP address,
|
||||||
or local (default: {flag_signer_interface}).
|
or local (default: {flag_ui_interface}).
|
||||||
--signer-path PATH Specify directory where Signer UIs tokens should
|
--ui-path PATH Specify directory where Trusted UIs tokens should
|
||||||
be stored. (default: {flag_signer_path})
|
be stored. (default: {flag_ui_path})
|
||||||
--signer-no-validation Disable Origin and Host headers validation for
|
--ui-no-validation Disable Origin and Host headers validation for
|
||||||
Trusted Signer. WARNING: INSECURE. Used only for
|
Trusted UI. WARNING: INSECURE. Used only for
|
||||||
development. (default: {flag_signer_no_validation})
|
development. (default: {flag_ui_no_validation})
|
||||||
|
|
||||||
Networking Options:
|
Networking Options:
|
||||||
--warp Enable syncing from the snapshot over the network. (default: {flag_warp})
|
--warp Enable syncing from the snapshot over the network. (default: {flag_warp})
|
||||||
|
@ -95,7 +95,7 @@ impl Configuration {
|
|||||||
let wal = !self.args.flag_fast_and_loose;
|
let wal = !self.args.flag_fast_and_loose;
|
||||||
let warp_sync = self.args.flag_warp;
|
let warp_sync = self.args.flag_warp;
|
||||||
let geth_compatibility = self.args.flag_geth;
|
let geth_compatibility = self.args.flag_geth;
|
||||||
let signer_port = self.signer_port();
|
let ui_port = self.ui_port();
|
||||||
let dapps_conf = self.dapps_config();
|
let dapps_conf = self.dapps_config();
|
||||||
let signer_conf = self.signer_config();
|
let signer_conf = self.signer_config();
|
||||||
let format = try!(self.format());
|
let format = try!(self.format());
|
||||||
@ -243,7 +243,7 @@ impl Configuration {
|
|||||||
vm_type: vm_type,
|
vm_type: vm_type,
|
||||||
warp_sync: warp_sync,
|
warp_sync: warp_sync,
|
||||||
geth_compatibility: geth_compatibility,
|
geth_compatibility: geth_compatibility,
|
||||||
signer_port: signer_port,
|
ui_port: ui_port,
|
||||||
net_settings: self.network_settings(),
|
net_settings: self.network_settings(),
|
||||||
dapps_conf: dapps_conf,
|
dapps_conf: dapps_conf,
|
||||||
signer_conf: signer_conf,
|
signer_conf: signer_conf,
|
||||||
@ -396,11 +396,11 @@ impl Configuration {
|
|||||||
|
|
||||||
fn signer_config(&self) -> SignerConfiguration {
|
fn signer_config(&self) -> SignerConfiguration {
|
||||||
SignerConfiguration {
|
SignerConfiguration {
|
||||||
enabled: self.signer_enabled(),
|
enabled: self.ui_enabled(),
|
||||||
port: self.args.flag_signer_port,
|
port: self.args.flag_ui_port,
|
||||||
interface: self.signer_interface(),
|
interface: self.ui_interface(),
|
||||||
signer_path: self.directories().signer,
|
signer_path: self.directories().signer,
|
||||||
skip_origin_validation: self.args.flag_signer_no_validation,
|
skip_origin_validation: self.args.flag_ui_no_validation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ impl Configuration {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let dapps_path = replace_home(&self.args.flag_dapps_path);
|
let dapps_path = replace_home(&self.args.flag_dapps_path);
|
||||||
let signer_path = replace_home(&self.args.flag_signer_path);
|
let ui_path = replace_home(&self.args.flag_ui_path);
|
||||||
|
|
||||||
if self.args.flag_geth && !cfg!(windows) {
|
if self.args.flag_geth && !cfg!(windows) {
|
||||||
let geth_root = if self.args.flag_testnet { path::ethereum::test() } else { path::ethereum::default() };
|
let geth_root = if self.args.flag_testnet { path::ethereum::test() } else { path::ethereum::default() };
|
||||||
@ -616,7 +616,7 @@ impl Configuration {
|
|||||||
keys: keys_path,
|
keys: keys_path,
|
||||||
db: db_path,
|
db: db_path,
|
||||||
dapps: dapps_path,
|
dapps: dapps_path,
|
||||||
signer: signer_path,
|
signer: ui_path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,16 +628,16 @@ impl Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signer_port(&self) -> Option<u16> {
|
fn ui_port(&self) -> Option<u16> {
|
||||||
if !self.signer_enabled() {
|
if !self.ui_enabled() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(self.args.flag_signer_port)
|
Some(self.args.flag_ui_port)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signer_interface(&self) -> String {
|
fn ui_interface(&self) -> String {
|
||||||
match self.args.flag_signer_interface.as_str() {
|
match self.args.flag_ui_interface.as_str() {
|
||||||
"local" => "127.0.0.1",
|
"local" => "127.0.0.1",
|
||||||
x => x,
|
x => x,
|
||||||
}.into()
|
}.into()
|
||||||
@ -662,16 +662,16 @@ impl Configuration {
|
|||||||
!self.args.flag_dapps_off && !self.args.flag_no_dapps && cfg!(feature = "dapps")
|
!self.args.flag_dapps_off && !self.args.flag_no_dapps && cfg!(feature = "dapps")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signer_enabled(&self) -> bool {
|
fn ui_enabled(&self) -> bool {
|
||||||
if self.args.flag_force_signer {
|
if self.args.flag_force_ui {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let signer_disabled = self.args.flag_unlock.is_some() ||
|
let ui_disabled = self.args.flag_unlock.is_some() ||
|
||||||
self.args.flag_geth ||
|
self.args.flag_geth ||
|
||||||
self.args.flag_no_signer;
|
self.args.flag_no_ui;
|
||||||
|
|
||||||
!signer_disabled
|
!ui_disabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -853,7 +853,7 @@ mod tests {
|
|||||||
wal: true,
|
wal: true,
|
||||||
vm_type: Default::default(),
|
vm_type: Default::default(),
|
||||||
geth_compatibility: false,
|
geth_compatibility: false,
|
||||||
signer_port: Some(8180),
|
ui_port: Some(8180),
|
||||||
net_settings: Default::default(),
|
net_settings: Default::default(),
|
||||||
dapps_conf: Default::default(),
|
dapps_conf: Default::default(),
|
||||||
signer_conf: Default::default(),
|
signer_conf: Default::default(),
|
||||||
@ -976,11 +976,11 @@ mod tests {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
let conf0 = parse(&["parity", "--geth"]);
|
let conf0 = parse(&["parity", "--geth"]);
|
||||||
let conf1 = parse(&["parity", "--geth", "--force-signer"]);
|
let conf1 = parse(&["parity", "--geth", "--force-ui"]);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert_eq!(conf0.signer_enabled(), false);
|
assert_eq!(conf0.ui_enabled(), false);
|
||||||
assert_eq!(conf1.signer_enabled(), true);
|
assert_eq!(conf1.ui_enabled(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -991,7 +991,7 @@ mod tests {
|
|||||||
let conf0 = parse(&["parity", "--unlock", "0x0"]);
|
let conf0 = parse(&["parity", "--unlock", "0x0"]);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert_eq!(conf0.signer_enabled(), false);
|
assert_eq!(conf0.ui_enabled(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -999,10 +999,10 @@ mod tests {
|
|||||||
// given
|
// given
|
||||||
|
|
||||||
// when
|
// when
|
||||||
let conf0 = parse(&["parity", "--signer-path", "signer"]);
|
let conf0 = parse(&["parity", "--ui-path", "signer"]);
|
||||||
let conf1 = parse(&["parity", "--signer-path", "signer", "--signer-no-validation"]);
|
let conf1 = parse(&["parity", "--ui-path", "signer", "--ui-no-validation"]);
|
||||||
let conf2 = parse(&["parity", "--signer-path", "signer", "--signer-port", "3123"]);
|
let conf2 = parse(&["parity", "--ui-path", "signer", "--ui-port", "3123"]);
|
||||||
let conf3 = parse(&["parity", "--signer-path", "signer", "--signer-interface", "test"]);
|
let conf3 = parse(&["parity", "--ui-path", "signer", "--ui-interface", "test"]);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assert_eq!(conf0.signer_config(), SignerConfiguration {
|
assert_eq!(conf0.signer_config(), SignerConfiguration {
|
||||||
|
@ -82,7 +82,7 @@ pub struct RunCmd {
|
|||||||
pub wal: bool,
|
pub wal: bool,
|
||||||
pub vm_type: VMType,
|
pub vm_type: VMType,
|
||||||
pub geth_compatibility: bool,
|
pub geth_compatibility: bool,
|
||||||
pub signer_port: Option<u16>,
|
pub ui_port: Option<u16>,
|
||||||
pub net_settings: NetworkSettings,
|
pub net_settings: NetworkSettings,
|
||||||
pub dapps_conf: dapps::Configuration,
|
pub dapps_conf: dapps::Configuration,
|
||||||
pub signer_conf: signer::Configuration,
|
pub signer_conf: signer::Configuration,
|
||||||
@ -262,7 +262,7 @@ pub fn execute(cmd: RunCmd, logger: Arc<RotatingLogger>) -> Result<(), String> {
|
|||||||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
||||||
signer_service: Arc::new(rpc_apis::SignerService::new(move || {
|
signer_service: Arc::new(rpc_apis::SignerService::new(move || {
|
||||||
signer::generate_new_token(signer_path.clone()).map_err(|e| format!("{:?}", e))
|
signer::generate_new_token(signer_path.clone()).map_err(|e| format!("{:?}", e))
|
||||||
}, cmd.signer_port)),
|
}, cmd.ui_port)),
|
||||||
snapshot: snapshot_service.clone(),
|
snapshot: snapshot_service.clone(),
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
sync: sync_provider.clone(),
|
sync: sync_provider.clone(),
|
||||||
|
@ -109,7 +109,7 @@ fn do_start(conf: Configuration, deps: Dependencies) -> Result<SignerServer, Str
|
|||||||
|
|
||||||
match start_result {
|
match start_result {
|
||||||
Err(signer::ServerError::IoError(err)) => match err.kind() {
|
Err(signer::ServerError::IoError(err)) => match err.kind() {
|
||||||
io::ErrorKind::AddrInUse => Err(format!("Trusted Signer address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --signer-port and --signer-interface options.", addr)),
|
io::ErrorKind::AddrInUse => Err(format!("Trusted UI address {} is already in use, make sure that another instance of an Ethereum client is not running or change the address using the --ui-port and --ui-interface options.", addr)),
|
||||||
_ => Err(format!("Trusted Signer io error: {}", err)),
|
_ => Err(format!("Trusted Signer io error: {}", err)),
|
||||||
},
|
},
|
||||||
Err(e) => Err(format!("Trusted Signer Error: {:?}", e)),
|
Err(e) => Err(format!("Trusted Signer Error: {:?}", e)),
|
||||||
|
Loading…
Reference in New Issue
Block a user