Merge branch 'master' into ng-array-parameters

This commit is contained in:
Nicolas Gotchac
2016-11-11 11:18:17 +01:00
38 changed files with 1889 additions and 34 deletions

View File

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

View File

@@ -34,7 +34,7 @@ describe('api/Api', () => {
});
describe('interface', () => {
const api = new Api(new Api.Transport.Http(TEST_HTTP_URL));
const api = new Api(new Api.Transport.Http(TEST_HTTP_URL, -1));
Object.keys(ethereumRpc).sort().forEach((endpoint) => {
describe(endpoint, () => {

View File

@@ -25,7 +25,7 @@ import Api from '../api';
import Contract from './contract';
import { isInstanceOf, isFunction } from '../util/types';
const transport = new Api.Transport.Http(TEST_HTTP_URL);
const transport = new Api.Transport.Http(TEST_HTTP_URL, -1);
const eth = new Api(transport);
describe('api/contract/Contract', () => {

View File

@@ -19,7 +19,7 @@ import { TEST_HTTP_URL, mockHttp } from '../../../../test/mockRpc';
import Http from '../../transport/http';
import Db from './db';
const instance = new Db(new Http(TEST_HTTP_URL));
const instance = new Db(new Http(TEST_HTTP_URL, -1));
describe('api/rpc/Db', () => {
let scope;

View File

@@ -20,7 +20,7 @@ import { isBigNumber } from '../../../../test/types';
import Http from '../../transport/http';
import Eth from './eth';
const instance = new Eth(new Http(TEST_HTTP_URL));
const instance = new Eth(new Http(TEST_HTTP_URL, -1));
describe('rpc/Eth', () => {
const address = '0x63Cf90D3f0410092FC0fca41846f596223979195';

View File

@@ -20,7 +20,7 @@ import { isBigNumber } from '../../../../test/types';
import Http from '../../transport/http';
import Net from './net';
const instance = new Net(new Http(TEST_HTTP_URL));
const instance = new Net(new Http(TEST_HTTP_URL, -1));
describe('api/rpc/Net', () => {
describe('peerCount', () => {

View File

@@ -20,7 +20,7 @@ import { isBigNumber } from '../../../../test/types';
import Http from '../../transport/http';
import Parity from './parity';
const instance = new Parity(new Http(TEST_HTTP_URL));
const instance = new Parity(new Http(TEST_HTTP_URL, -1));
describe('api/rpc/parity', () => {
describe('accountsInfo', () => {

View File

@@ -19,7 +19,7 @@ import { TEST_HTTP_URL, mockHttp } from '../../../../test/mockRpc';
import Http from '../../transport/http';
import Personal from './personal';
const instance = new Personal(new Http(TEST_HTTP_URL));
const instance = new Personal(new Http(TEST_HTTP_URL, -1));
describe('rpc/Personal', () => {
const account = '0x63cf90d3f0410092fc0fca41846f596223979195';

View File

@@ -19,7 +19,7 @@ import { TEST_HTTP_URL, mockHttp } from '../../../../test/mockRpc';
import Http from '../../transport/http';
import Trace from './trace';
const instance = new Trace(new Http(TEST_HTTP_URL));
const instance = new Trace(new Http(TEST_HTTP_URL, -1));
describe('api/rpc/Trace', () => {
let scope;

View File

@@ -19,7 +19,7 @@ import { TEST_HTTP_URL, mockHttp } from '../../../../test/mockRpc';
import Http from '../../transport/http';
import Web3 from './web3';
const instance = new Web3(new Http(TEST_HTTP_URL));
const instance = new Web3(new Http(TEST_HTTP_URL, -1));
describe('api/rpc/Web3', () => {
let scope;

View File

@@ -19,11 +19,14 @@ import JsonRpcBase from '../jsonRpcBase';
/* global fetch */
export default class Http extends JsonRpcBase {
constructor (url) {
constructor (url, connectTimeout = 1000) {
super();
this._connected = true;
this._url = url;
this._connectTimeout = connectTimeout;
this._pollConnection();
}
_encodeOptions (method, params) {
@@ -77,4 +80,17 @@ export default class Http extends JsonRpcBase {
return response.result;
});
}
_pollConnection = () => {
if (this._connectTimeout <= 0) {
return;
}
const nextTimeout = () => setTimeout(this._pollConnection, this._connectTimeout);
this
.execute('net_listening')
.then(nextTimeout)
.catch(nextTimeout);
}
}

View File

@@ -17,7 +17,7 @@
import { TEST_HTTP_URL, mockHttp } from '../../../../test/mockRpc';
import Http from './http';
const transport = new Http(TEST_HTTP_URL);
const transport = new Http(TEST_HTTP_URL, -1);
describe('api/transport/Http', () => {
describe('instance', () => {

View File

@@ -70,7 +70,8 @@ export default class AccountSelector extends Component {
static propTypes = {
list: PropTypes.array.isRequired,
selected: PropTypes.object.isRequired,
handleSetSelected: PropTypes.func.isRequired
handleSetSelected: PropTypes.func.isRequired,
onAccountChange: PropTypes.func
};
state = {
@@ -85,7 +86,8 @@ export default class AccountSelector extends Component {
nestedItems={ nestedAccounts }
open={ this.state.open }
onSelectAccount={ this.onToggleOpen }
autoGenerateNestedIndicator={ false } />
autoGenerateNestedIndicator={ false }
nestedListStyle={ { maxHeight: '14em', overflow: 'auto' } } />
);
return (
@@ -110,6 +112,10 @@ export default class AccountSelector extends Component {
onToggleOpen = () => {
this.setState({ open: !this.state.open });
if (typeof this.props.onAccountChange === 'function') {
this.props.onAccountChange();
}
}
onSelectAccount = (address) => {

View File

@@ -81,6 +81,7 @@ export default class RegisterAction extends Component {
className={ styles.dialog }
onRequestClose={ this.onClose }
actions={ this.renderActions() }
ref='dialog'
autoScrollBodyContent
>
{ this.renderContent() }
@@ -149,7 +150,9 @@ export default class RegisterAction extends Component {
renderForm () {
return (
<div>
<AccountSelector />
<AccountSelector
onAccountChange={ this.onAccountChange }
/>
{ this.renderInputs() }
</div>
);
@@ -175,6 +178,11 @@ export default class RegisterAction extends Component {
});
}
onAccountChange = () => {
const { dialog } = this.refs;
dialog.forceUpdate();
}
onChange (fieldKey, valid, value) {
const { fields } = this.state;
const field = fields[fieldKey];

View File

@@ -75,7 +75,7 @@ const validateTokenAddress = (address, contract, simple) => {
return getTokenTotalSupply(address)
.then(balance => {
if (balance === null) {
if (balance === null || balance.equals(0)) {
return {
error: ERRORS.invalidTokenAddress,
valid: false

View File

@@ -57,6 +57,7 @@ export default class Token extends Component {
isLoading: PropTypes.bool,
isPending: PropTypes.bool,
isTokenOwner: PropTypes.bool.isRequired,
isContractOwner: PropTypes.bool.isRequired,
fullWidth: PropTypes.bool
};
@@ -220,7 +221,7 @@ export default class Token extends Component {
}
renderUnregister () {
if (!this.props.isTokenOwner) {
if (!this.props.isContractOwner) {
return null;
}

View File

@@ -45,7 +45,7 @@ export default class Tokens extends Component {
}
renderTokens (tokens) {
const { accounts } = this.props;
const { accounts, isOwner } = this.props;
return tokens.map((token, index) => {
if (!token || !token.tla) {
@@ -61,7 +61,8 @@ export default class Tokens extends Component {
handleMetaLookup={ this.props.handleMetaLookup }
handleAddMeta={ this.props.handleAddMeta }
key={ index }
isTokenOwner={ isTokenOwner } />
isTokenOwner={ isTokenOwner }
isContractOwner={ isOwner } />
);
});
}

View File

@@ -26,6 +26,7 @@ export default class SecureApi extends Api {
this._connectState = sysuiToken === 'initial' ? 1 : 0;
this._needsToken = false;
this._dappsPort = 8080;
this._dappsInterface = null;
this._signerPort = 8180;
console.log('SecureApi:constructor', sysuiToken);
@@ -100,10 +101,12 @@ export default class SecureApi extends Api {
Promise
.all([
this.parity.dappsPort(),
this.parity.dappsInterface(),
this.parity.signerPort()
])
.then(([dappsPort, signerPort]) => {
.then(([dappsPort, dappsInterface, signerPort]) => {
this._dappsPort = dappsPort.toNumber();
this._dappsInterface = dappsInterface;
this._signerPort = signerPort.toNumber();
});
@@ -122,7 +125,17 @@ export default class SecureApi extends Api {
}
get dappsUrl () {
return `http://${window.location.hostname}:${this._dappsPort}`;
let hostname;
if (window.location.hostname === 'home.parity') {
hostname = 'dapps.parity';
} else if (!this._dappsInterface || this._dappsInterface === '0.0.0.0') {
hostname = window.location.hostname;
} else {
hostname = this._dappsInterface;
}
return `http://${hostname}:${this._dappsPort}`;
}
get signerPort () {