Merge branch 'master' into transactions-propagate
This commit is contained in:
commit
3bfd6c5998
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1250,7 +1250,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "parity-ui-precompiled"
|
||||
version = "1.4.0"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git#5e3b9629692c550811b228d68ca99d1461a4f6cb"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git#957c5a66c33f3b06a7ae804ac5edc59c20e4535b"
|
||||
dependencies = [
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 97066e40ccd061f727deb5cd860e4d9135aa2551
|
||||
Subproject commit 9028c4801fd39fbb71a9796979182549a24e81c8
|
@ -20,6 +20,7 @@ use std::collections::HashMap;
|
||||
use time;
|
||||
use ethkey::Address;
|
||||
use {json, SafeAccount, Error};
|
||||
use json::UUID;
|
||||
use super::KeyDirectory;
|
||||
|
||||
const IGNORED_FILES: &'static [&'static str] = &["thumbs.db", "address_book.json"];
|
||||
@ -112,7 +113,7 @@ impl KeyDirectory for DiskDirectory {
|
||||
// build file path
|
||||
let filename = account.filename.as_ref().cloned().unwrap_or_else(|| {
|
||||
let timestamp = time::strftime("%Y-%m-%dT%H-%M-%S", &time::now_utc()).expect("Time-format string is valid.");
|
||||
format!("UTC--{}Z--{:?}", timestamp, account.address)
|
||||
format!("UTC--{}Z--{}", timestamp, UUID::from(account.id))
|
||||
});
|
||||
|
||||
// update account filename
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "parity.js",
|
||||
"version": "0.2.49",
|
||||
"version": "0.2.50",
|
||||
"main": "release/index.js",
|
||||
"jsnext:main": "src/index.js",
|
||||
"author": "Parity Team <admin@parity.io>",
|
||||
@ -122,6 +122,7 @@
|
||||
"brace": "^0.9.0",
|
||||
"bytes": "^2.4.0",
|
||||
"chart.js": "^2.3.0",
|
||||
"es6-error": "^4.0.0",
|
||||
"es6-promise": "^3.2.1",
|
||||
"ethereumjs-tx": "^1.1.2",
|
||||
"file-saver": "^1.3.3",
|
||||
|
@ -68,11 +68,13 @@ if [ "$BRANCH" == "master" ]; then
|
||||
fi
|
||||
|
||||
echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH"
|
||||
git submodule update
|
||||
cargo update -p parity-ui-precompiled
|
||||
# --precise "$PRECOMPILED_HASH"
|
||||
|
||||
echo "*** Committing updated files"
|
||||
git add .
|
||||
git add js
|
||||
git add Cargo.lock
|
||||
git commit -m "[ci skip] js-precompiled $UTCDATE"
|
||||
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG
|
||||
|
||||
|
53
js/src/api/transport/error.js
Normal file
53
js/src/api/transport/error.js
Normal file
@ -0,0 +1,53 @@
|
||||
// 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 ExtendableError from 'es6-error';
|
||||
|
||||
export const ERROR_CODES = {
|
||||
UNSUPPORTED_REQUEST: -32000,
|
||||
NO_WORK: -32001,
|
||||
NO_AUTHOR: -32002,
|
||||
NO_NEW_WORK: -32003,
|
||||
NOT_ENOUGH_DATA: -32006,
|
||||
UNKNOWN_ERROR: -32009,
|
||||
TRANSACTION_ERROR: -32010,
|
||||
EXECUTION_ERROR: -32015,
|
||||
ACCOUNT_LOCKED: -32020,
|
||||
PASSWORD_INVALID: -32021,
|
||||
ACCOUNT_ERROR: -32023,
|
||||
SIGNER_DISABLED: -32030,
|
||||
DAPPS_DISABLED: -32031,
|
||||
NETWORK_DISABLED: -32035,
|
||||
REQUEST_REJECTED: -32040,
|
||||
REQUEST_REJECTED_LIMIT: -32041,
|
||||
REQUEST_NOT_FOUND: -32042,
|
||||
COMPILATION_ERROR: -32050,
|
||||
ENCRYPTION_ERROR: -32055,
|
||||
FETCH_ERROR: -32060
|
||||
};
|
||||
|
||||
export default class TransportError extends ExtendableError {
|
||||
constructor (method, code, message) {
|
||||
const m = `${method}: ${code}: ${message}`;
|
||||
super(m);
|
||||
|
||||
this.code = code;
|
||||
this.type = Object.keys(ERROR_CODES).find((k) => ERROR_CODES[k] === code) || '';
|
||||
|
||||
this.method = method;
|
||||
this.text = message;
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@
|
||||
|
||||
import { Logging } from '../../subscriptions';
|
||||
import JsonRpcBase from '../jsonRpcBase';
|
||||
import TransportError from '../error';
|
||||
|
||||
/* global fetch */
|
||||
export default class Http extends JsonRpcBase {
|
||||
@ -73,7 +74,8 @@ export default class Http extends JsonRpcBase {
|
||||
this.error(JSON.stringify(response));
|
||||
console.error(`${method}(${JSON.stringify(params)}): ${response.error.code}: ${response.error.message}`);
|
||||
|
||||
throw new Error(`${method}: ${response.error.code}: ${response.error.message}`);
|
||||
const error = new TransportError(method, response.error.code, response.error.message);
|
||||
throw error;
|
||||
}
|
||||
|
||||
this.log(JSON.stringify(response));
|
||||
|
@ -16,3 +16,4 @@
|
||||
|
||||
export Http from './http';
|
||||
export Ws from './ws';
|
||||
export TransportError from './error.js';
|
||||
|
@ -18,6 +18,7 @@ import { keccak_256 } from 'js-sha3'; // eslint-disable-line camelcase
|
||||
|
||||
import { Logging } from '../../subscriptions';
|
||||
import JsonRpcBase from '../jsonRpcBase';
|
||||
import TransportError from '../error';
|
||||
|
||||
/* global WebSocket */
|
||||
export default class Ws extends JsonRpcBase {
|
||||
@ -109,7 +110,9 @@ export default class Ws extends JsonRpcBase {
|
||||
|
||||
console.error(`${method}(${JSON.stringify(params)}): ${result.error.code}: ${result.error.message}`);
|
||||
|
||||
reject(new Error(`${method}: ${result.error.code}: ${result.error.message}`));
|
||||
const error = new TransportError(method, result.error.code, result.error.message);
|
||||
reject(error);
|
||||
|
||||
delete this._messages[result.id];
|
||||
return;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ import ErrorStep from './ErrorStep';
|
||||
|
||||
import styles from './deployContract.css';
|
||||
|
||||
import { ERROR_CODES } from '../../api/transport/error';
|
||||
|
||||
const steps = ['contract details', 'deployment', 'completed'];
|
||||
|
||||
export default class DeployContract extends Component {
|
||||
@ -63,7 +65,8 @@ export default class DeployContract extends Component {
|
||||
params: [],
|
||||
paramsError: [],
|
||||
step: 0,
|
||||
deployError: null
|
||||
deployError: null,
|
||||
rejected: false
|
||||
}
|
||||
|
||||
componentWillMount () {
|
||||
@ -92,15 +95,20 @@ export default class DeployContract extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { step, deployError } = this.state;
|
||||
const { step, deployError, rejected } = this.state;
|
||||
|
||||
const realSteps = deployError || rejected ? null : steps;
|
||||
const title = realSteps
|
||||
? null
|
||||
: (deployError ? 'deployment failed' : 'rejected');
|
||||
|
||||
return (
|
||||
<Modal
|
||||
actions={ this.renderDialogActions() }
|
||||
current={ step }
|
||||
steps={ deployError ? null : steps }
|
||||
title={ deployError ? 'deployment failed' : null }
|
||||
waiting={ [1] }
|
||||
steps={ realSteps }
|
||||
title={ title }
|
||||
waiting={ realSteps ? [1] : null }
|
||||
visible
|
||||
scroll>
|
||||
{ this.renderStep() }
|
||||
@ -158,7 +166,7 @@ export default class DeployContract extends Component {
|
||||
|
||||
renderStep () {
|
||||
const { accounts, readOnly } = this.props;
|
||||
const { address, deployError, step, deployState, txhash } = this.state;
|
||||
const { address, deployError, step, deployState, txhash, rejected } = this.state;
|
||||
|
||||
if (deployError) {
|
||||
return (
|
||||
@ -166,6 +174,15 @@ export default class DeployContract extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (rejected) {
|
||||
return (
|
||||
<BusyStep
|
||||
title='The deployment has been rejected'
|
||||
state='You can safely close this window, the contract deployment will not occur.'
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
switch (step) {
|
||||
case 0:
|
||||
return (
|
||||
@ -273,6 +290,11 @@ export default class DeployContract extends Component {
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.code === ERROR_CODES.REQUEST_REJECTED) {
|
||||
this.setState({ rejected: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
console.error('error deploying contract', error);
|
||||
this.setState({ deployError: error });
|
||||
store.dispatch({ type: 'newError', error });
|
||||
|
@ -23,6 +23,8 @@ import { validateAddress, validateUint } from '../../util/validation';
|
||||
|
||||
import DetailsStep from './DetailsStep';
|
||||
|
||||
import { ERROR_CODES } from '../../api/transport/error';
|
||||
|
||||
export default class ExecuteContract extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired,
|
||||
@ -49,7 +51,8 @@ export default class ExecuteContract extends Component {
|
||||
step: 0,
|
||||
sending: false,
|
||||
busyState: null,
|
||||
txhash: null
|
||||
txhash: null,
|
||||
rejected: false
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
@ -80,6 +83,7 @@ export default class ExecuteContract extends Component {
|
||||
const { onClose, fromAddress } = this.props;
|
||||
const { sending, step, fromAddressError, valuesError } = this.state;
|
||||
const hasError = fromAddressError || valuesError.find((error) => error);
|
||||
|
||||
const cancelBtn = (
|
||||
<Button
|
||||
key='cancel'
|
||||
@ -115,7 +119,16 @@ export default class ExecuteContract extends Component {
|
||||
|
||||
renderStep () {
|
||||
const { onFromAddressChange } = this.props;
|
||||
const { step, busyState, txhash } = this.state;
|
||||
const { step, busyState, txhash, rejected } = this.state;
|
||||
|
||||
if (rejected) {
|
||||
return (
|
||||
<BusyStep
|
||||
title='The execution has been rejected'
|
||||
state='You can safely close this window, the function execution will not occur.'
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (step === 0) {
|
||||
return (
|
||||
@ -221,7 +234,17 @@ export default class ExecuteContract extends Component {
|
||||
})
|
||||
.then((requestId) => {
|
||||
this.setState({ busyState: 'Waiting for authorization in the Parity Signer' });
|
||||
return api.pollMethod('parity_checkRequest', requestId);
|
||||
|
||||
return api
|
||||
.pollMethod('parity_checkRequest', requestId)
|
||||
.catch((e) => {
|
||||
if (e.code === ERROR_CODES.REQUEST_REJECTED) {
|
||||
this.setState({ rejected: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
throw e;
|
||||
});
|
||||
})
|
||||
.then((txhash) => {
|
||||
this.setState({ sending: false, step: 2, txhash, busyState: 'Your transaction has been posted to the network' });
|
||||
|
@ -28,13 +28,16 @@ import Extras from './Extras';
|
||||
import ERRORS from './errors';
|
||||
import styles from './transfer.css';
|
||||
|
||||
import { ERROR_CODES } from '../../api/transport/error';
|
||||
|
||||
const DEFAULT_GAS = '21000';
|
||||
const DEFAULT_GASPRICE = '20000000000';
|
||||
const TITLES = {
|
||||
transfer: 'transfer details',
|
||||
sending: 'sending',
|
||||
complete: 'complete',
|
||||
extras: 'extra information'
|
||||
extras: 'extra information',
|
||||
rejected: 'rejected'
|
||||
};
|
||||
const STAGES_BASIC = [TITLES.transfer, TITLES.sending, TITLES.complete];
|
||||
const STAGES_EXTRA = [TITLES.transfer, TITLES.extras, TITLES.sending, TITLES.complete];
|
||||
@ -74,7 +77,8 @@ export default class Transfer extends Component {
|
||||
valueAll: false,
|
||||
valueError: null,
|
||||
isEth: true,
|
||||
busyState: null
|
||||
busyState: null,
|
||||
rejected: false
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
@ -82,13 +86,19 @@ export default class Transfer extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { stage, extras } = this.state;
|
||||
const { stage, extras, rejected } = this.state;
|
||||
|
||||
const steps = [].concat(extras ? STAGES_EXTRA : STAGES_BASIC);
|
||||
|
||||
if (rejected) {
|
||||
steps[steps.length - 1] = TITLES.rejected;
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
actions={ this.renderDialogActions() }
|
||||
current={ stage }
|
||||
steps={ extras ? STAGES_EXTRA : STAGES_BASIC }
|
||||
steps={ steps }
|
||||
waiting={ extras ? [2] : [1] }
|
||||
visible
|
||||
scroll
|
||||
@ -133,7 +143,16 @@ export default class Transfer extends Component {
|
||||
}
|
||||
|
||||
renderCompletePage () {
|
||||
const { sending, txhash, busyState } = this.state;
|
||||
const { sending, txhash, busyState, rejected } = this.state;
|
||||
|
||||
if (rejected) {
|
||||
return (
|
||||
<BusyStep
|
||||
title='The transaction has been rejected'
|
||||
state='You can safely close this window, the transfer will not occur.'
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (sending) {
|
||||
return (
|
||||
@ -455,7 +474,17 @@ export default class Transfer extends Component {
|
||||
: this._sendToken()
|
||||
).then((requestId) => {
|
||||
this.setState({ busyState: 'Waiting for authorization in the Parity Signer' });
|
||||
return api.pollMethod('parity_checkRequest', requestId);
|
||||
|
||||
return api
|
||||
.pollMethod('parity_checkRequest', requestId)
|
||||
.catch((e) => {
|
||||
if (e.code === ERROR_CODES.REQUEST_REJECTED) {
|
||||
this.setState({ rejected: true });
|
||||
return false;
|
||||
}
|
||||
|
||||
throw e;
|
||||
});
|
||||
})
|
||||
.then((txhash) => {
|
||||
this.onNext();
|
||||
|
@ -17,4 +17,10 @@
|
||||
|
||||
.container {
|
||||
z-index: 10101 !important;
|
||||
|
||||
button {
|
||||
color: white !important;
|
||||
margin: 0 !important;
|
||||
margin-right: -16px !important;
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,12 @@ import { closeErrors } from './actions';
|
||||
|
||||
import styles from './errors.css';
|
||||
|
||||
const ERROR_REGEX = /-(\d+): (.+)$/;
|
||||
|
||||
class Errors extends Component {
|
||||
static propTypes = {
|
||||
message: PropTypes.string,
|
||||
error: PropTypes.object,
|
||||
visible: PropTypes.bool,
|
||||
onCloseErrors: PropTypes.func
|
||||
};
|
||||
@ -37,22 +40,60 @@ class Errors extends Component {
|
||||
return null;
|
||||
}
|
||||
|
||||
const text = this.getErrorMessage();
|
||||
|
||||
return (
|
||||
<Snackbar
|
||||
open
|
||||
className={ styles.container }
|
||||
message={ message }
|
||||
autoHideDuration={ 5000 }
|
||||
onRequestClose={ onCloseErrors } />
|
||||
open
|
||||
action='close'
|
||||
autoHideDuration={ 60000 }
|
||||
message={ text }
|
||||
onActionTouchTap={ onCloseErrors }
|
||||
onRequestClose={ this.onRequestClose }
|
||||
bodyStyle={ {
|
||||
whiteSpace: 'pre-line',
|
||||
height: 'auto'
|
||||
} }
|
||||
contentStyle={ {
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
lineHeight: '1.5em',
|
||||
padding: '0.75em 0',
|
||||
alignItems: 'center'
|
||||
} }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
getErrorMessage = () => {
|
||||
const { message, error } = this.props;
|
||||
|
||||
if (!error.text && !ERROR_REGEX.test(message)) {
|
||||
return message;
|
||||
}
|
||||
|
||||
const matches = ERROR_REGEX.exec(message);
|
||||
|
||||
const code = error.code || parseInt(matches[1]) * -1;
|
||||
const text = error.text || matches[2];
|
||||
|
||||
return `[${code}] ${text}`;
|
||||
}
|
||||
|
||||
onRequestClose = (reason) => {
|
||||
if (reason === 'timeout') {
|
||||
this.props.onCloseErrors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { message, visible } = state.errors;
|
||||
const { message, error, visible } = state.errors;
|
||||
|
||||
return {
|
||||
message,
|
||||
error,
|
||||
visible
|
||||
};
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ function newError (state, action) {
|
||||
|
||||
return Object.assign({}, state, {
|
||||
visible: true,
|
||||
message: error.message
|
||||
message: error.message,
|
||||
error
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user