Merge branch 'master' into new-token

This commit is contained in:
Tomasz Drwięga
2016-11-14 09:22:06 +01:00
26 changed files with 266 additions and 106 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "parity.js",
"version": "0.2.33",
"version": "0.2.37",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Parity Team <admin@parity.io>",

View File

@@ -309,7 +309,6 @@ export default class Contract {
try {
subscriptions[idx].callback(null, this.parseEventLogs(logs));
} catch (error) {
this.unsubscribe(idx);
console.error('_sendSubscriptionChanges', error);
}
});

View File

@@ -107,7 +107,6 @@ export default class Manager {
callback(error, data);
} catch (error) {
console.error(`Unable to update callback for subscriptionId ${subscriptionId}`, error);
this.unsubscribe(subscriptionId);
}
}

View File

@@ -28,26 +28,26 @@ export function attachInterface () {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('githubhint'), 'A']),
api.eth.accounts(),
api.parity.accounts()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = accountsInfo || {};
.then(([address, accountsInfo]) => {
console.log(`githubhint was found at ${address}`);
const contract = api.newContract(abis.githubhint, address);
const accounts = addresses.reduce((obj, address) => {
const info = accountsInfo[address] || {};
const accounts = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.reduce((obj, address) => {
const account = accountsInfo[address];
return Object.assign(obj, {
[address]: {
address,
name: info.name,
uuid: info.uuid
}
});
}, {});
return Object.assign(obj, {
[address]: {
address,
name: account.name
}
});
}, {});
const fromAddress = Object.keys(accounts)[0];
return {

View File

@@ -49,3 +49,15 @@
padding-bottom: 0 !important;
}
}
.warning {
background: #f80;
bottom: 0;
color: #fff;
left: 0;
opacity: 1;
padding: 1.5em;
position: fixed;
right: 50%;
z-index: 100;
}

View File

@@ -53,6 +53,7 @@ export default class Application extends Component {
};
render () {
const { api } = window.parity;
const {
actions,
accounts, contacts,
@@ -60,9 +61,11 @@ export default class Application extends Component {
lookup,
events
} = this.props;
let warning = null;
return (
<div>
{ warning }
<div className={ styles.header }>
<h1>RΞgistry</h1>
<Accounts { ...accounts } actions={ actions.accounts } />
@@ -70,13 +73,11 @@ export default class Application extends Component {
{ contract && fee ? (
<div>
<Lookup { ...lookup } accounts={ accounts.all } contacts={ contacts } actions={ actions.lookup } />
{ this.renderActions() }
<Events { ...events } accounts={ accounts.all } contacts={ contacts } actions={ actions.events } />
<p className={ styles.address }>
The Registry is provided by the contract at <code>{ contract.address }.</code>
</p>
<div className={ styles.warning }>
WARNING: The name registry is experimental. Please ensure that you understand the risks, benefits & consequences of registering a name before doing so. A non-refundable fee of { api.util.fromWei(fee).toFormat(3) }<small>ETH</small> is required for all registrations.
</div>
</div>
) : (
<CircularProgress size={ 60 } />

View File

@@ -19,18 +19,16 @@ import { api } from '../parity';
export const set = (addresses) => ({ type: 'addresses set', addresses });
export const fetch = () => (dispatch) => {
return Promise
.all([
api.eth.accounts(),
api.parity.accounts()
])
.then(([ accounts, data ]) => {
data = data || {};
const addresses = Object.keys(data)
.filter((address) => data[address] && !data[address].meta.deleted)
return api.parity
.accounts()
.then((accountsInfo) => {
const addresses = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address] && !accountsInfo[address].meta.deleted)
.map((address) => ({
...data[address], address,
isAccount: accounts.includes(address)
...accountsInfo[address],
address,
isAccount: !!accountsInfo[address].uuid
}));
dispatch(set(addresses));
})

View File

@@ -146,7 +146,7 @@ export default class Import extends Component {
}
sortFunctions = (a, b) => {
return a.name.localeCompare(b.name);
return (a.name || '').localeCompare(b.name || '');
}
countFunctions () {

View File

@@ -49,26 +49,26 @@ export function attachInterface (callback) {
return Promise
.all([
registry.getAddress.call({}, [api.util.sha3('signaturereg'), 'A']),
api.eth.accounts(),
api.parity.accounts()
]);
})
.then(([address, addresses, accountsInfo]) => {
accountsInfo = accountsInfo || {};
.then(([address, accountsInfo]) => {
console.log(`signaturereg was found at ${address}`);
const contract = api.newContract(abis.signaturereg, address);
const accounts = addresses.reduce((obj, address) => {
const info = accountsInfo[address] || {};
const accounts = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.reduce((obj, address) => {
const info = accountsInfo[address] || {};
return Object.assign(obj, {
[address]: {
address,
name: info.name || 'Unnamed',
uuid: info.uuid
}
});
}, {});
return Object.assign(obj, {
[address]: {
address,
name: info.name || 'Unnamed'
}
});
}, {});
const fromAddress = Object.keys(accounts)[0];
return {

View File

@@ -35,16 +35,13 @@ export const setSelectedAccount = (address) => ({
});
export const loadAccounts = () => (dispatch) => {
Promise
.all([
api.eth.accounts(),
api.parity.accounts()
])
.then(([ accounts, accountsInfo ]) => {
accountsInfo = accountsInfo || {};
const accountsList = accounts
.map(address => ({
api.parity
.accounts()
.then((accountsInfo) => {
const accountsList = Object
.keys(accountsInfo)
.filter((address) => accountsInfo[address].uuid)
.map((address) => ({
...accountsInfo[address],
address
}));

View File

@@ -20,3 +20,15 @@
flex-direction: column;
align-items: center;
}
.warning {
background: #f80;
bottom: 0;
color: #fff;
left: 0;
opacity: 1;
padding: 1.5em;
position: fixed;
right: 50%;
z-index: 100;
}

View File

@@ -17,6 +17,8 @@
import React, { Component, PropTypes } from 'react';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import { api } from '../parity';
import Loading from '../Loading';
import Status from '../Status';
import Tokens from '../Tokens';
@@ -59,6 +61,9 @@ export default class Application extends Component {
<Actions />
<Tokens />
<div className={ styles.warning }>
WARNING: The token registry is experimental. Please ensure that you understand the steps, risks, benefits & consequences of registering a token before doing so. A non-refundable fee of { api.util.fromWei(contract.fee).toFormat(3) }<small>ETH</small> is required for all registrations.
</div>
</div>
);
}

View File

@@ -31,6 +31,12 @@
.title {
font-size: 3rem;
font-weight: 300;
margin-top: 0;
margin: 0;
text-transform: uppercase;
}
.byline {
font-size: 1.25em;
opacity: 0.75;
margin: 0 0 1.75em 0;
}

View File

@@ -29,17 +29,12 @@ export default class Status extends Component {
};
render () {
const { address, fee } = this.props;
const { fee } = this.props;
return (
<div className={ styles.status }>
<h1 className={ styles.title }>Token Registry</h1>
<Chip
isAddress
value={ address }
label='Address' />
<h3 className={ styles.byline }>A global registry of all recognised tokens on the network</h3>
<Chip
isAddress={ false }
value={ api.util.fromWei(fee).toFixed(3) + 'ETH' }