Backporting to beta (#3229)
* Use ethcore_dappsPort when constructing URLs (#3139) * Upon connect, retrieve the available api ports * Update dapps to load from dappsPort * Update dapps summary with dappsPort * Allow proxy to use dappsPort * Replace /api/ping with HEAD / * Dynamic port for available apps * Retrieve content images with dappsPort * Fix / * Transfer token dropdown image fix * IdentityIcon loads images via contentHash * Update apps fetch to cater for dev & prod * DRY up 127.0.0.1:${dappsPort} with ${dappsUrl} * Cleaning up polluted namespaces (#3143) * Renaming ethcore_ to parity_ * Renaming files * Renaming poluted EthSigning * Tidy up the namespaces * Renaming files to match new structure * Splitting EthSigning into separate traits * jsapi move ethcore.* -> parity.* * Move jsonrpc parity definitions * Update UI API calls for parity interfaces * Move jsapi signer interfaces from personal to signer * Update UI to use signer.* where applicable * Updsate jsapi subscriptions for signer * Fix dodgy merge. * Update README. * Fix some tests. * Move parity-only personal.* to parity.* * Update UI for personal -> parity API moves * Update subscription APIs after personal -> parity move * personal. generateAuthorizationToken -> parity. generateAuthorizationToken (UI) * enode, dappsPort & signerPort (UI) * Update subscription tests (accountsInfo) * subscription update * personal -> parity * Additional error logging on method failures * move postTransaction to parity * Additional debug info with method failures * Fix personal tests. * Console wrning shows parameters, error object does not * Include parity_ signing methods. * Console log http transport info * Fix failing tests * Add RPC stubs for parity_accounts. * Allow some secure built-in dapps * Use parity_accounts in place of accountsInfo * Improve error reporting * Cleanup GHH error handling Former-commit-id: 5a094ccb9f0596d0e07abc23504b80dc099ad584
This commit is contained in:
@@ -149,7 +149,7 @@ export default class Header extends Component {
|
||||
const { account } = this.props;
|
||||
|
||||
this.setState({ name }, () => {
|
||||
api.personal
|
||||
api.parity
|
||||
.setAccountName(account.address, name)
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
|
||||
@@ -81,7 +81,7 @@ class Delete extends Component {
|
||||
|
||||
account.meta.deleted = true;
|
||||
|
||||
api.personal
|
||||
api.parity
|
||||
.setAccountMeta(account.address, account.meta)
|
||||
.then(() => {
|
||||
router.push(route);
|
||||
|
||||
@@ -104,8 +104,8 @@ class Application extends Component {
|
||||
checkAccounts () {
|
||||
const { api } = this.context;
|
||||
|
||||
api.personal
|
||||
.listAccounts()
|
||||
api.eth
|
||||
.accounts()
|
||||
.then((accounts) => {
|
||||
this.setState({
|
||||
showFirstRun: showFirstRun || accounts.length === 0
|
||||
|
||||
@@ -16,20 +16,54 @@
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import Contracts from '../../contracts';
|
||||
import { fetchAvailable } from '../Dapps/registry';
|
||||
|
||||
import styles from './dapp.css';
|
||||
|
||||
const dapphost = process.env.NODE_ENV === 'production' ? 'http://127.0.0.1:8080/ui' : '';
|
||||
|
||||
export default class Dapp extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
params: PropTypes.object
|
||||
};
|
||||
|
||||
state = {
|
||||
app: null
|
||||
}
|
||||
|
||||
componentWillMount () {
|
||||
this.lookup();
|
||||
}
|
||||
|
||||
render () {
|
||||
const { name, type } = this.props.params;
|
||||
const src = (type === 'builtin')
|
||||
? `${dapphost}/${name}.html`
|
||||
: `http://127.0.0.1:8080/${name}/`;
|
||||
const { app } = this.state;
|
||||
const { dappsUrl } = this.context.api;
|
||||
|
||||
if (!app) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let src = null;
|
||||
switch (app.type) {
|
||||
case 'builtin':
|
||||
const dapphost = process.env.NODE_ENV === 'production' && !app.secure
|
||||
? `${dappsUrl}/ui`
|
||||
: '';
|
||||
src = `${dapphost}/${app.url}.html`;
|
||||
break;
|
||||
case 'local':
|
||||
src = `${dappsUrl}/${app.id}/`;
|
||||
break;
|
||||
case 'network':
|
||||
src = `${dappsUrl}/${app.contentHash}/`;
|
||||
break;
|
||||
default:
|
||||
console.error('unknown type', app.type);
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
<iframe
|
||||
@@ -42,4 +76,30 @@ export default class Dapp extends Component {
|
||||
</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 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,31 +32,27 @@ export default class Summary extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { dappsPort } = this.context.api;
|
||||
const { app } = this.props;
|
||||
|
||||
if (!app) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let type = 'builtin';
|
||||
if (app.network) {
|
||||
type = 'network';
|
||||
} else if (app.local) {
|
||||
type = 'local';
|
||||
let image = <div className={ styles.image }> </div>;
|
||||
if (app.image) {
|
||||
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 } />;
|
||||
}
|
||||
|
||||
const url = `/app/${type}/${app.url || app.contentHash || app.id}`;
|
||||
const image = app.image || app.iconUrl
|
||||
? <img src={ app.image || `http://127.0.0.1:8080/${app.id}/${app.iconUrl}` } className={ styles.image } />
|
||||
: <div className={ styles.image }> </div>;
|
||||
|
||||
return (
|
||||
<Container className={ styles.container }>
|
||||
{ image }
|
||||
<div className={ styles.description }>
|
||||
<ContainerTitle
|
||||
className={ styles.title }
|
||||
title={ <Link to={ url }>{ app.name }</Link> }
|
||||
title={ <Link to={ `/app/${app.id}` }>{ app.name }</Link> }
|
||||
byline={ app.description } />
|
||||
<div className={ styles.author }>{ app.author }, v{ app.version }</div>
|
||||
{ this.props.children }
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import { parityNode } from '../../environment';
|
||||
|
||||
const builtinApps = [
|
||||
{
|
||||
id: '0xf9f2d620c2e08f83e45555247146c62185e4ab7cf82a4b9002a265a0d020348f',
|
||||
@@ -57,7 +55,8 @@ const builtinApps = [
|
||||
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'
|
||||
version: '1.0.0',
|
||||
secure: true
|
||||
}
|
||||
];
|
||||
|
||||
@@ -76,16 +75,14 @@ const networkApps = [
|
||||
}
|
||||
];
|
||||
|
||||
export function fetchAvailable (api) {
|
||||
// TODO: Since we don't have an extensive GithubHint app, get the value somehow
|
||||
// RESULT: 0x22cd66e1b05882c0fa17a16d252d3b3ee2238ccbac8153f69a35c83f02ca76ee
|
||||
// api.ethcore
|
||||
// .hashContent('https://codeload.github.com/gavofyork/gavcoin/zip/5a9f11ff2ad0d05c565a938ceffdfa0d23af9981')
|
||||
// .then((sha3) => {
|
||||
// console.log('archive', sha3);
|
||||
// });
|
||||
function getHost (api) {
|
||||
return process.env.NODE_ENV === 'production'
|
||||
? api.dappsUrl
|
||||
: '';
|
||||
}
|
||||
|
||||
return fetch(`${parityNode}/api/apps`)
|
||||
export function fetchAvailable (api) {
|
||||
return fetch(`${getHost(api)}/api/apps`)
|
||||
.then((response) => {
|
||||
return response.ok
|
||||
? response.json()
|
||||
@@ -99,11 +96,11 @@ export function fetchAvailable (api) {
|
||||
const localApps = _localApps
|
||||
.filter((app) => !['ui'].includes(app.id))
|
||||
.map((app) => {
|
||||
app.local = true;
|
||||
app.type = 'local';
|
||||
return app;
|
||||
});
|
||||
|
||||
return api.ethcore
|
||||
return api.parity
|
||||
.registryAddress()
|
||||
.then((registryAddress) => {
|
||||
if (new BigNumber(registryAddress).eq(0)) {
|
||||
@@ -112,13 +109,13 @@ export function fetchAvailable (api) {
|
||||
|
||||
const _builtinApps = builtinApps
|
||||
.map((app) => {
|
||||
app.builtin = true;
|
||||
app.type = 'builtin';
|
||||
return app;
|
||||
});
|
||||
|
||||
return networkApps
|
||||
.map((app) => {
|
||||
app.network = true;
|
||||
app.type = 'network';
|
||||
return app;
|
||||
})
|
||||
.concat(_builtinApps);
|
||||
@@ -134,8 +131,8 @@ export function fetchAvailable (api) {
|
||||
});
|
||||
}
|
||||
|
||||
export function fetchManifest (app, contentHash) {
|
||||
return fetch(`${parityNode}/${contentHash}/manifest.json`)
|
||||
export function fetchManifest (api, app, contentHash) {
|
||||
return fetch(`${getHost(api)}/${contentHash}/manifest.json`)
|
||||
.then((response) => {
|
||||
return response.ok
|
||||
? response.json()
|
||||
|
||||
@@ -89,7 +89,7 @@ export default class Parity extends Component {
|
||||
onChangeMode = (event, index, mode) => {
|
||||
const { api } = this.context;
|
||||
|
||||
api.ethcore
|
||||
api.parity
|
||||
.setMode(mode)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
@@ -104,7 +104,7 @@ export default class Parity extends Component {
|
||||
loadMode () {
|
||||
const { api } = this.context;
|
||||
|
||||
api.ethcore
|
||||
api.parity
|
||||
.mode()
|
||||
.then((mode) => {
|
||||
this.setState({ mode });
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { Container, ContainerTitle } from '../../../ui';
|
||||
|
||||
@@ -22,8 +22,13 @@ import layout from '../layout.css';
|
||||
import styles from './proxy.css';
|
||||
|
||||
export default class Proxy extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired
|
||||
}
|
||||
|
||||
render () {
|
||||
const proxyurl = 'http://127.0.0.1:8080/proxy/proxy.pac';
|
||||
const { dappsUrl } = this.context.api;
|
||||
const proxyurl = `${dappsUrl}/proxy/proxy.pac`;
|
||||
|
||||
return (
|
||||
<Container>
|
||||
|
||||
@@ -50,7 +50,7 @@ export default class SignRequest extends Component {
|
||||
}
|
||||
|
||||
componentWillMount () {
|
||||
this.context.api.ethcore.netChain()
|
||||
this.context.api.parity.netChain()
|
||||
.then((chain) => {
|
||||
this.setState({ chain });
|
||||
})
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class TransactionFinished extends Component {
|
||||
const totalValue = tUtil.getTotalValue(fee, value);
|
||||
this.setState({ totalValue });
|
||||
|
||||
this.context.api.ethcore.netChain()
|
||||
this.context.api.parity.netChain()
|
||||
.then((chain) => {
|
||||
this.setState({ chain });
|
||||
})
|
||||
|
||||
@@ -64,7 +64,7 @@ export default class TransactionPending extends Component {
|
||||
const gasToDisplay = tUtil.getGasDisplay(gas);
|
||||
this.setState({ gasPriceEthmDisplay, totalValue, gasToDisplay });
|
||||
|
||||
this.context.api.ethcore.netChain()
|
||||
this.context.api.parity.netChain()
|
||||
.then((chain) => {
|
||||
this.setState({ chain });
|
||||
})
|
||||
|
||||
@@ -87,7 +87,7 @@ export default class MiningSettings extends Component {
|
||||
onMinGasPriceChange = (newVal) => {
|
||||
const { api } = this.context;
|
||||
|
||||
api.ethcore.setMinGasPrice(numberFromString(newVal));
|
||||
api.parity.setMinGasPrice(numberFromString(newVal));
|
||||
};
|
||||
|
||||
onExtraDataChange = (newVal, isResetToDefault) => {
|
||||
@@ -97,18 +97,18 @@ export default class MiningSettings extends Component {
|
||||
// In case of resetting to default we are just using raw bytes from defaultExtraData
|
||||
// When user sets new value we can safely send a string that will be converted to hex by formatter.
|
||||
const val = isResetToDefault ? nodeStatus.defaultExtraData : newVal;
|
||||
api.ethcore.setExtraData(val);
|
||||
api.parity.setExtraData(val);
|
||||
};
|
||||
|
||||
onAuthorChange = (newVal) => {
|
||||
const { api } = this.context;
|
||||
|
||||
api.ethcore.setAuthor(newVal);
|
||||
api.parity.setAuthor(newVal);
|
||||
};
|
||||
|
||||
onGasFloorTargetChange = (newVal) => {
|
||||
const { api } = this.context;
|
||||
|
||||
api.ethcore.setGasFloorTarget(numberFromString(newVal));
|
||||
api.parity.setGasFloorTarget(numberFromString(newVal));
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user