From 529a7fc33c61a88298a63fc205585538b219f4f5 Mon Sep 17 00:00:00 2001
From: keorn
Date: Mon, 5 Dec 2016 17:08:16 +0000
Subject: [PATCH 01/56] add password and AccountProvider
---
ethcore/src/engines/authority_round.rs | 46 +++++++++++------------
ethcore/src/engines/basic_authority.rs | 13 +++++--
ethcore/src/engines/instant_seal.rs | 12 ++----
ethcore/src/engines/mod.rs | 14 +++++--
ethcore/src/miner/miner.rs | 43 ++++++++++++++-------
ethcore/src/miner/mod.rs | 3 ++
parity/run.rs | 5 ++-
rpc/src/v1/impls/parity_set.rs | 6 +++
rpc/src/v1/tests/eth.rs | 1 +
rpc/src/v1/tests/helpers/miner_service.rs | 10 +++++
rpc/src/v1/tests/helpers/sync_provider.rs | 2 +-
rpc/src/v1/tests/mocked/parity_set.rs | 17 +++++++++
rpc/src/v1/traits/parity_set.rs | 4 ++
13 files changed, 119 insertions(+), 57 deletions(-)
diff --git a/ethcore/src/engines/authority_round.rs b/ethcore/src/engines/authority_round.rs
index f28a06117..646c107e0 100644
--- a/ethcore/src/engines/authority_round.rs
+++ b/ethcore/src/engines/authority_round.rs
@@ -21,13 +21,15 @@ use std::sync::Weak;
use std::time::{UNIX_EPOCH, Duration};
use util::*;
use ethkey::{verify_address, Signature};
-use rlp::{Rlp, UntrustedRlp, View, encode};
+use rlp::{UntrustedRlp, View, encode};
use account_provider::AccountProvider;
use block::*;
use spec::CommonParams;
use engines::Engine;
use header::Header;
use error::{Error, BlockError};
+use blockchain::extras::BlockDetails;
+use views::HeaderView;
use evm::Schedule;
use ethjson;
use io::{IoContext, IoHandler, TimerToken, IoService, IoChannel};
@@ -35,8 +37,6 @@ use service::ClientIoMessage;
use transaction::SignedTransaction;
use env_info::EnvInfo;
use builtin::Builtin;
-use blockchain::extras::BlockDetails;
-use views::HeaderView;
/// `AuthorityRound` params.
#[derive(Debug, PartialEq)]
@@ -72,6 +72,7 @@ pub struct AuthorityRound {
message_channel: Mutex
- The daily limit is set to { daylimit }.
+ The daily limit is set to { fromWei(daylimit).toFormat() } ETH.
);
diff --git a/js/src/modals/CreateWallet/WalletType/walletType.js b/js/src/modals/CreateWallet/WalletType/walletType.js
index e77d58fc6..868c6ad9b 100644
--- a/js/src/modals/CreateWallet/WalletType/walletType.js
+++ b/js/src/modals/CreateWallet/WalletType/walletType.js
@@ -43,7 +43,13 @@ export default class WalletType extends Component {
return [
{
label: 'Multi-Sig wallet', key: 'MULTISIG',
- description: 'A standard multi-signature Wallet'
+ description: (
+
+ Create/Deploy a
+ standard multi-signature
+ Wallet
+
+ )
},
{
label: 'Watch a wallet', key: 'WATCH',
diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js
index f5e2f1855..d8c308a12 100644
--- a/js/src/modals/CreateWallet/createWalletStore.js
+++ b/js/src/modals/CreateWallet/createWalletStore.js
@@ -16,7 +16,7 @@
import { observable, computed, action, transaction } from 'mobx';
-import { validateUint, validateAddress, validateName } from '../../util/validation';
+import { validateUint, validateAddress, validateName } from '~/util/validation';
import { ERROR_CODES } from '~/api/transport/error';
import Contract from '~/api/contract';
diff --git a/js/src/modals/Transfer/store.js b/js/src/modals/Transfer/store.js
index a0c7967b9..8f8baf55f 100644
--- a/js/src/modals/Transfer/store.js
+++ b/js/src/modals/Transfer/store.js
@@ -23,7 +23,7 @@ import { bytesToHex } from '~/api/util/format';
import Contract from '~/api/contract';
import ERRORS from './errors';
import { ERROR_CODES } from '~/api/transport/error';
-import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '../../util/constants';
+import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '~/util/constants';
const TITLES = {
transfer: 'transfer details',
@@ -116,7 +116,6 @@ export default class TransferStore {
this.api = api;
const { account, balance, gasLimit, senders, onClose, newError, sendersBalances } = props;
-
this.account = account;
this.balance = balance;
this.gasLimit = gasLimit;
@@ -412,34 +411,38 @@ export default class TransferStore {
return;
}
- const { gas, gasPrice, tag, valueAll, isEth } = this;
+ const { gas, gasPrice, tag, valueAll, isEth, isWallet } = this;
const gasTotal = new BigNumber(gasPrice || 0).mul(new BigNumber(gas || 0));
const availableEth = new BigNumber(balance.tokens[0].value);
const senderBalance = this.balance.tokens.find((b) => tag === b.token.tag);
- const available = new BigNumber(senderBalance.value);
const format = new BigNumber(senderBalance.token.format || 1);
+ const available = isWallet
+ ? this.api.util.fromWei(new BigNumber(senderBalance.value))
+ : (new BigNumber(senderBalance.value)).div(format);
let { value, valueError } = this;
let totalEth = gasTotal;
let totalError = null;
if (valueAll) {
- if (isEth) {
+ if (isEth && !isWallet) {
const bn = this.api.util.fromWei(availableEth.minus(gasTotal));
value = (bn.lt(0) ? new BigNumber(0.0) : bn).toString();
+ } else if (isEth) {
+ value = (available.lt(0) ? new BigNumber(0.0) : available).toString();
} else {
- value = available.div(format).toString();
+ value = available.toString();
}
}
- if (isEth) {
+ if (isEth && !isWallet) {
totalEth = totalEth.plus(this.api.util.toWei(value || 0));
}
- if (new BigNumber(value || 0).gt(available.div(format))) {
+ if (new BigNumber(value || 0).gt(available)) {
valueError = ERRORS.largeAmount;
} else if (valueError === ERRORS.largeAmount) {
valueError = null;
diff --git a/js/src/modals/Transfer/transfer.js b/js/src/modals/Transfer/transfer.js
index 402e3ae4f..e1e2a0951 100644
--- a/js/src/modals/Transfer/transfer.js
+++ b/js/src/modals/Transfer/transfer.js
@@ -139,8 +139,8 @@ class Transfer extends Component {
? (
-
- This transaction needs confirmation from other owners.
+
+
This transaction needs confirmation from other owners.
-
+
)
: null
@@ -298,7 +298,6 @@ function mapStateToProps (initState, initProps) {
return (state) => {
const { gasLimit } = state.nodeStatus;
const sendersBalances = senders ? pick(state.balances.balances, Object.keys(senders)) : null;
-
return { gasLimit, wallet, senders, sendersBalances };
};
}
diff --git a/js/src/modals/WalletSettings/index.js b/js/src/modals/WalletSettings/index.js
new file mode 100644
index 000000000..9b15a5f3b
--- /dev/null
+++ b/js/src/modals/WalletSettings/index.js
@@ -0,0 +1,17 @@
+// 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 .
+
+export default from './walletSettings';
diff --git a/js/src/modals/WalletSettings/walletSettings.css b/js/src/modals/WalletSettings/walletSettings.css
new file mode 100644
index 000000000..ae52013cd
--- /dev/null
+++ b/js/src/modals/WalletSettings/walletSettings.css
@@ -0,0 +1,63 @@
+/* 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 .
+*/
+
+.splitInput {
+ display: flex;
+ flex-direction: row;
+
+ > * {
+ flex: 1;
+
+ margin: 0 0.25em;
+
+ &:first-child {
+ margin-left: 0;
+ }
+
+ &:last-child {
+ margin-right: 0;
+ }
+ }
+}
+
+.change {
+ background-color: rgba(255, 255, 255, 0.1);
+ padding: 0.75em 1.75em;
+ margin-bottom: 1em;
+
+ &.add {
+ background-color: rgba(139, 195, 74, 0.5);
+ }
+
+ &.remove {
+ background-color: rgba(244, 67, 54, 0.5);
+ }
+
+ .label {
+ text-transform: uppercase;
+ margin-bottom: 0.5em;
+ margin-left: -1em;
+ font-size: 0.8em;
+ }
+}
+
+.eth:after {
+ content: 'ETH';
+ font-size: 0.75em;
+ margin-left: 0.125em;
+}
+
diff --git a/js/src/modals/WalletSettings/walletSettings.js b/js/src/modals/WalletSettings/walletSettings.js
new file mode 100644
index 000000000..1b2b2cc1a
--- /dev/null
+++ b/js/src/modals/WalletSettings/walletSettings.js
@@ -0,0 +1,321 @@
+// 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 .
+
+import React, { Component, PropTypes } from 'react';
+import { connect } from 'react-redux';
+import { observer } from 'mobx-react';
+import { pick } from 'lodash';
+
+import ActionDone from 'material-ui/svg-icons/action/done';
+import ContentClear from 'material-ui/svg-icons/content/clear';
+import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward';
+import { parseAbiType } from '~/util/abi';
+
+import { Button, Modal, TxHash, BusyStep, Form, TypedInput, InputAddress, AddressSelect } from '~/ui';
+import { fromWei } from '~/api/util/wei';
+
+import WalletSettingsStore from './walletSettingsStore.js';
+import styles from './walletSettings.css';
+
+@observer
+class WalletSettings extends Component {
+ static contextTypes = {
+ api: PropTypes.object.isRequired
+ };
+
+ static propTypes = {
+ accounts: PropTypes.object.isRequired,
+ wallet: PropTypes.object.isRequired,
+ onClose: PropTypes.func.isRequired,
+ senders: PropTypes.object.isRequired
+ };
+
+ store = new WalletSettingsStore(this.context.api, this.props.wallet);
+
+ render () {
+ const { stage, steps, waiting, rejected } = this.store;
+
+ if (rejected) {
+ return (
+
+
+
+ );
+ }
+
+ return (
+ s.title) }
+ waiting={ waiting }
+ >
+ { this.renderPage() }
+
+ );
+ }
+
+ renderPage () {
+ const { step } = this.store;
+
+ switch (step) {
+ case 'SENDING':
+ return (
+
+ {
+ this.store.requests.map((req) => {
+ const key = req.id;
+
+ if (req.txhash) {
+ return ();
+ }
+
+ if (req.rejected) {
+ return (
The transaction #{parseInt(key, 16)} has been rejected
);
});
diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js
index c3b64d738..4a708d17a 100644
--- a/js/src/modals/ExecuteContract/executeContract.js
+++ b/js/src/modals/ExecuteContract/executeContract.js
@@ -23,6 +23,7 @@ import ContentClear from 'material-ui/svg-icons/content/clear';
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
import { MAX_GAS_ESTIMATION } from '../../util/constants';
import { validateAddress, validateUint } from '../../util/validation';
+import { parseAbiType } from '~/util/abi';
import DetailsStep from './DetailsStep';
@@ -66,7 +67,7 @@ class ExecuteContract extends Component {
const { contract } = this.props;
const functions = contract.functions
.filter((func) => !func.constant)
- .sort((a, b) => a.name.localeCompare(b.name));
+ .sort((a, b) => (a.name || '').localeCompare(b.name || ''));
this.onFuncChange(null, functions[0]);
}
@@ -111,7 +112,7 @@ class ExecuteContract extends Component {
}
onClick={ this.postTransaction } />
];
@@ -174,23 +175,9 @@ class ExecuteContract extends Component {
}
onFuncChange = (event, func) => {
- const values = func.inputs.map((input) => {
- switch (input.kind.type) {
- case 'address':
- return '0x';
-
- case 'bool':
- return false;
-
- case 'bytes':
- return '0x';
-
- case 'uint':
- return '0';
-
- default:
- return '';
- }
+ const values = (func.abi.inputs || []).map((input) => {
+ const parsedType = parseAbiType(input.type);
+ return parsedType.default;
});
this.setState({
diff --git a/js/src/redux/providers/compilerWorker.js b/js/src/redux/providers/compilerWorker.js
index 247333f5e..f624a4e5f 100644
--- a/js/src/redux/providers/compilerWorker.js
+++ b/js/src/redux/providers/compilerWorker.js
@@ -92,7 +92,7 @@ function findImports (path) {
return { error: 'File not found' };
}
-function compile (data) {
+function compile (data, optimized = 1) {
const { sourcecode, build } = data;
const { longVersion } = build;
@@ -109,7 +109,7 @@ function compile (data) {
'': sourcecode
};
- const compiled = compiler.compile({ sources: input }, 0, findImports);
+ const compiled = compiler.compile({ sources: input }, optimized, findImports);
self.lastCompile = {
version: longVersion, result: compiled,
diff --git a/js/src/redux/providers/walletActions.js b/js/src/redux/providers/walletActions.js
index 10f6a278e..8e13ac1a0 100644
--- a/js/src/redux/providers/walletActions.js
+++ b/js/src/redux/providers/walletActions.js
@@ -58,7 +58,7 @@ function modifyOperation (method, address, owner, operation) {
contract.instance[method]
.estimateGas(options, values)
.then((gas) => {
- options.gas = gas;
+ options.gas = gas.mul(1.2);
return contract.instance[method].postTransaction(options, values);
})
.then((requestId) => {
diff --git a/js/src/views/Contract/Events/events.js b/js/src/views/Contract/Events/events.js
index f0bee3e25..69ae8fd6a 100644
--- a/js/src/views/Contract/Events/events.js
+++ b/js/src/views/Contract/Events/events.js
@@ -15,6 +15,7 @@
// along with Parity. If not, see .
import React, { Component, PropTypes } from 'react';
+import { uniq } from 'lodash';
import { Container } from '~/ui';
@@ -38,7 +39,10 @@ export default class Events extends Component {
return null;
}
- const list = events.map((event) => {
+ const eventsKey = uniq(events.map((e) => e.key));
+ const list = eventsKey.map((eventKey) => {
+ const event = events.find((e) => e.key === eventKey);
+
return (
Date: Fri, 9 Dec 2016 00:32:45 +0000
Subject: [PATCH 33/56] [ci skip] js-precompiled 20161209-003004
---
Cargo.lock | 2 +-
js/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index f603410f0..ff4c35734 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1271,7 +1271,7 @@ dependencies = [
[[package]]
name = "parity-ui-precompiled"
version = "1.4.0"
-source = "git+https://github.com/ethcore/js-precompiled.git#a59b62ecec8773715d1db7e070bbbe5443eb7378"
+source = "git+https://github.com/ethcore/js-precompiled.git#f5365b857b006ed60c02eb9360d60d7ddef65104"
dependencies = [
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
diff --git a/js/package.json b/js/package.json
index 62bf37b49..a758936f2 100644
--- a/js/package.json
+++ b/js/package.json
@@ -1,6 +1,6 @@
{
"name": "parity.js",
- "version": "0.2.99",
+ "version": "0.2.100",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Parity Team ",
From f9a24f3c8e0a120c718f00e3f54e1a19f422e0f3 Mon Sep 17 00:00:00 2001
From: Jaco Greeff
Date: Fri, 9 Dec 2016 02:33:12 +0100
Subject: [PATCH 34/56] Update babel, fix CI build due to breaking changes
(#3754)
* Update babel to latest version
* Re-add circular deps plugin
* Bump for build
* Fixes for babel build
---
js/.babelrc | 1 +
js/package.json | 11 ++--
js/scripts/test.js | 2 +-
js/src/api/contract/contract.js | 9 ++-
.../Animated/AnimateChildren.css | 55 ----------------
.../Animated/Animated.js | 28 ---------
.../Animated/children.js | 63 -------------------
.../components-compositors/Animated/index.js | 17 -----
js/src/views/Status/components/Calls/Calls.js | 31 ++++-----
js/webpack/shared.js | 8 ++-
10 files changed, 31 insertions(+), 194 deletions(-)
delete mode 100644 js/src/views/Status/components-compositors/Animated/AnimateChildren.css
delete mode 100644 js/src/views/Status/components-compositors/Animated/Animated.js
delete mode 100644 js/src/views/Status/components-compositors/Animated/children.js
delete mode 100644 js/src/views/Status/components-compositors/Animated/index.js
diff --git a/js/.babelrc b/js/.babelrc
index 2298d98c0..8147da435 100644
--- a/js/.babelrc
+++ b/js/.babelrc
@@ -7,6 +7,7 @@
"transform-runtime",
"transform-decorators-legacy",
"transform-class-properties",
+ "transform-object-rest-spread",
"lodash"
],
"retainLines": true,
diff --git a/js/package.json b/js/package.json
index a758936f2..4cbac5a75 100644
--- a/js/package.json
+++ b/js/package.json
@@ -48,25 +48,26 @@
},
"devDependencies": {
"babel-cli": "6.18.0",
- "babel-core": "6.18.2",
+ "babel-core": "6.20.0",
"babel-eslint": "7.1.1",
"babel-loader": "6.2.8",
"babel-plugin-lodash": "3.2.10",
- "babel-plugin-transform-class-properties": "6.19.0",
+ "babel-plugin-transform-class-properties": "6.18.0",
"babel-plugin-transform-decorators-legacy": "1.3.4",
+ "babel-plugin-transform-object-rest-spread": "6.20.2",
"babel-plugin-transform-react-remove-prop-types": "0.2.11",
"babel-plugin-transform-runtime": "6.15.0",
- "babel-polyfill": "6.16.0",
+ "babel-polyfill": "6.20.0",
"babel-preset-es2015": "6.18.0",
- "babel-preset-es2015-rollup": "1.2.0",
"babel-preset-es2016": "6.16.0",
"babel-preset-es2017": "6.16.0",
"babel-preset-react": "6.16.0",
"babel-preset-stage-0": "6.16.0",
"babel-register": "6.18.0",
- "babel-runtime": "6.18.0",
+ "babel-runtime": "6.20.0",
"chai": "3.5.0",
"chai-enzyme": "0.6.1",
+ "circular-dependency-plugin": "2.0.0",
"copy-webpack-plugin": "4.0.1",
"core-js": "2.4.1",
"coveralls": "2.11.15",
diff --git a/js/scripts/test.js b/js/scripts/test.js
index 318fd7c84..78f2f99bd 100644
--- a/js/scripts/test.js
+++ b/js/scripts/test.js
@@ -1 +1 @@
-// test script 4
+// test script 6
diff --git a/js/src/api/contract/contract.js b/js/src/api/contract/contract.js
index ed922a02c..1185199e1 100644
--- a/js/src/api/contract/contract.js
+++ b/js/src/api/contract/contract.js
@@ -262,12 +262,11 @@ export default class Contract {
}
const options = this._getFilterOptions(event, _options);
+ options.fromBlock = 0;
+ options.toBlock = 'latest';
+
return this._api.eth
- .getLogs({
- fromBlock: 0,
- toBlock: 'latest',
- ...options
- })
+ .getLogs(options)
.then((logs) => this.parseEventLogs(logs));
}
diff --git a/js/src/views/Status/components-compositors/Animated/AnimateChildren.css b/js/src/views/Status/components-compositors/Animated/AnimateChildren.css
deleted file mode 100644
index 5d7b5b39a..000000000
--- a/js/src/views/Status/components-compositors/Animated/AnimateChildren.css
+++ /dev/null
@@ -1,55 +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 .
-*/
-/* todo [adgo] - make local */
-:global .transition-appear {
- opacity: 0.01;
-}
-
-:global .transition-appear.transition-appear-active {
- opacity: 1;
- transition: opacity .3s ease-in-out;
-}
-
-:global .transition-enter {
- opacity: 0.01;
-}
-
-:global .transition-enter.transition-enter-active {
- opacity: 1;
- transition: opacity .3s ease-in-out;
-}
-
-:global .transition-leave {
- opacity: 1;
-}
-
-:global .transition-leave.transition-leave-active {
- opacity: 0.01;
- transition: opacity .3s ease-in-out;
-}
-
-:global .absoluteAnimationContainer {
- position: relative;
-}
-
-:global .absoluteAnimationContainer > .transition-leave {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- width: 100%;
-}
diff --git a/js/src/views/Status/components-compositors/Animated/Animated.js b/js/src/views/Status/components-compositors/Animated/Animated.js
deleted file mode 100644
index c22344c01..000000000
--- a/js/src/views/Status/components-compositors/Animated/Animated.js
+++ /dev/null
@@ -1,28 +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 .
-
-import React, { Component } from 'react';
-import AnimateChildren from './children';
-
-export default Wrapped => class Animated extends Component {
- render () {
- return (
-
-
-
- );
- }
-};
diff --git a/js/src/views/Status/components-compositors/Animated/children.js b/js/src/views/Status/components-compositors/Animated/children.js
deleted file mode 100644
index be7f910bf..000000000
--- a/js/src/views/Status/components-compositors/Animated/children.js
+++ /dev/null
@@ -1,63 +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 .
-
-import React, { Component, PropTypes } from 'react';
-import { isReactComponent } from '../../util/react';
-import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
-import './AnimateChildren.css';
-
-export default class AnimateChildren extends Component {
- render () {
- const className = this.props.absolute ? 'absoluteAnimationContainer' : '';
- return (
-
- { this.renderChildren() }
-
- );
- }
-
- renderChildren () {
- const { children, isView } = this.props;
-
- if (isView) {
- return React.cloneElement(this.props.children, {
- key: this.props.pathname
- });
- }
-
- if (isReactComponent(children)) {
- return React.cloneElement(this.props.children, { ...this.props });
- }
-
- return children;
- }
-
- static propTypes = {
- children: PropTypes.any.isRequired,
- pathname: PropTypes.string,
- isView: PropTypes.bool,
- absolute: PropTypes.bool
- }
-
-}
diff --git a/js/src/views/Status/components-compositors/Animated/index.js b/js/src/views/Status/components-compositors/Animated/index.js
deleted file mode 100644
index ee48d0704..000000000
--- a/js/src/views/Status/components-compositors/Animated/index.js
+++ /dev/null
@@ -1,17 +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 .
-
-export default from './Animated';
diff --git a/js/src/views/Status/components/Calls/Calls.js b/js/src/views/Status/components/Calls/Calls.js
index 7734104ec..1115ec632 100644
--- a/js/src/views/Status/components/Calls/Calls.js
+++ b/js/src/views/Status/components/Calls/Calls.js
@@ -15,7 +15,6 @@
// along with Parity. If not, see .
import React, { Component, PropTypes } from 'react';
-import AnimateChildren from '../../components-compositors/Animated/children';
import Call from '../Call';
import CallsToolbar from '../CallsToolbar';
import styles from './Calls.css';
@@ -73,13 +72,11 @@ export default class Calls extends Component {
}
return (
-
-
-
- Fire up some calls and the results will be here.
-
-
-
+
+
+ Fire up some calls and the results will be here.
+
>>,
host_channel: Mutex>>,
handlers: Arc>, HandlerId>>>,
}
@@ -424,19 +424,19 @@ impl IoService where Message: Send + Sync + Clone + 'static {
});
Ok(IoService {
panic_handler: panic_handler,
- thread: Some(thread),
+ thread: Mutex::new(Some(thread)),
host_channel: Mutex::new(channel),
handlers: handlers,
})
}
- pub fn stop(&mut self) {
+ pub fn stop(&self) {
trace!(target: "shutdown", "[IoService] Closing...");
// Clear handlers so that shared pointers are not stuck on stack
// in Channel::send_sync
self.handlers.write().clear();
self.host_channel.lock().send(IoMessage::Shutdown).unwrap_or_else(|e| warn!("Error on IO service shutdown: {:?}", e));
- if let Some(thread) = self.thread.take() {
+ if let Some(thread) = self.thread.lock().take() {
thread.join().unwrap_or_else(|e| {
debug!(target: "shutdown", "Error joining IO service event loop thread: {:?}", e);
});
From befcc9cc1a432b3ec7563418c0dcbe4ec9f83320 Mon Sep 17 00:00:00 2001
From: Jaco Greeff
Date: Fri, 9 Dec 2016 13:44:10 +0100
Subject: [PATCH 39/56] Cleanups (#3742)
* Remove unused file
* Combine tx checks into single file
* Move UI components into UI
* DRY links
* Unused rollup config
* Cleanup util paths
* Revert "Move UI components into UI"
This reverts commit 3379e61246cde635c296d31322b71e63395a5cd4.
* Re-apply ~/util/tx move
* Cleanup unused styles
---
js/src/3rdparty/etherscan/links.js | 8 ++-
js/src/jsonrpc/rollup.config.js | 12 -----
js/src/modals/AddAddress/addAddress.js | 2 +-
js/src/modals/AddContract/addContract.js | 2 +-
.../modals/CreateWallet/createWalletStore.js | 5 +-
.../DeployContract/DetailsStep/detailsStep.js | 4 +-
.../ParametersStep/parametersStep.js | 2 +-
.../modals/DeployContract/deployContract.js | 2 +-
js/src/modals/EditMeta/editMeta.js | 2 +-
.../modals/ExecuteContract/executeContract.js | 4 +-
js/src/modals/SMSVerification/store.js | 5 +-
js/src/modals/SaveContract/saveContract.js | 2 +-
js/src/modals/Shapeshift/shapeshift.js | 2 +-
js/src/redux/providers/walletActions.js | 6 +--
js/src/ui/Form/TypedInput/typedInput.js | 3 +-
js/src/ui/TxHash/txHash.js | 2 +-
js/src/ui/TxList/txList.js | 2 +-
js/src/util/check-if-tx-failed.js | 28 ----------
js/src/util/is-testnet.js | 19 -------
...{wait-for-block-confirmations.js => tx.js} | 17 ++++--
.../Account/Transactions/transactions.css | 3 --
.../Account/Transactions/transactions.js | 2 +-
js/src/views/Account/account.css | 2 -
js/src/views/Account/account.js | 2 +-
js/src/views/Accounts/accounts.css | 2 -
js/src/views/Accounts/accounts.js | 2 +-
js/src/views/Address/address.css | 52 +++++++++----------
js/src/views/Address/address.js | 4 +-
js/src/views/Addresses/addresses.css | 20 ++++---
js/src/views/Addresses/addresses.js | 2 +-
js/src/views/Connection/connection.js | 1 -
js/src/views/Contract/Events/Event/event.js | 2 +-
js/src/views/Contract/contract.css | 26 ++++------
js/src/views/Contract/contract.js | 2 +-
js/src/views/Contracts/contracts.css | 18 -------
js/src/views/Contracts/contracts.js | 5 +-
js/src/views/Settings/settings.css | 44 +++++++---------
js/src/views/Settings/settings.js | 2 +-
.../Account/AccountLink/AccountLink.js | 2 +-
.../components/TxHashLink/TxHashLink.js | 2 +-
.../Signer/containers/Embedded/embedded.css | 3 --
.../Signer/containers/Embedded/embedded.js | 2 +-
.../containers/RequestsPage/RequestsPage.css | 6 ---
.../containers/RequestsPage/RequestsPage.js | 5 +-
js/src/views/Signer/signer.css | 24 ---------
js/src/views/Signer/signer.js | 4 +-
.../containers/StatusPage/StatusPage.js | 4 +-
.../containers/StatusPage/statusPage.css | 18 -------
48 files changed, 118 insertions(+), 272 deletions(-)
delete mode 100644 js/src/jsonrpc/rollup.config.js
delete mode 100644 js/src/util/check-if-tx-failed.js
delete mode 100644 js/src/util/is-testnet.js
rename js/src/util/{wait-for-block-confirmations.js => tx.js} (73%)
delete mode 100644 js/src/views/Contracts/contracts.css
delete mode 100644 js/src/views/Signer/signer.css
delete mode 100644 js/src/views/Status/containers/StatusPage/statusPage.css
diff --git a/js/src/3rdparty/etherscan/links.js b/js/src/3rdparty/etherscan/links.js
index 2745873fc..e85572850 100644
--- a/js/src/3rdparty/etherscan/links.js
+++ b/js/src/3rdparty/etherscan/links.js
@@ -14,10 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
+export const url = (isTestnet = false) => {
+ return `https://${isTestnet ? 'testnet.' : ''}etherscan.io`;
+};
+
export const txLink = (hash, isTestnet = false) => {
- return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/tx/${hash}`;
+ return `${url(isTestnet)}/tx/${hash}`;
};
export const addressLink = (address, isTestnet = false) => {
- return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/address/${address}`;
+ return `${url(isTestnet)}/address/${address}`;
};
diff --git a/js/src/jsonrpc/rollup.config.js b/js/src/jsonrpc/rollup.config.js
deleted file mode 100644
index cc4f8c931..000000000
--- a/js/src/jsonrpc/rollup.config.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import babel from 'rollup-plugin-babel';
-
-export default {
- entry: 'src/index.js',
- dest: 'release/index.js',
- format: 'cjs',
- plugins: [babel({
- babelrc: false,
- presets: ['es2015-rollup', 'stage-0'],
- runtimeHelpers: true
- })]
-};
diff --git a/js/src/modals/AddAddress/addAddress.js b/js/src/modals/AddAddress/addAddress.js
index 590287e73..e44cb0b3c 100644
--- a/js/src/modals/AddAddress/addAddress.js
+++ b/js/src/modals/AddAddress/addAddress.js
@@ -19,7 +19,7 @@ import ContentAdd from 'material-ui/svg-icons/content/add';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { Button, Modal, Form, Input, InputAddress } from '~/ui';
-import { ERRORS, validateAddress, validateName } from '../../util/validation';
+import { ERRORS, validateAddress, validateName } from '~/util/validation';
export default class AddAddress extends Component {
static contextTypes = {
diff --git a/js/src/modals/AddContract/addContract.js b/js/src/modals/AddContract/addContract.js
index 71f8a911d..b19398001 100644
--- a/js/src/modals/AddContract/addContract.js
+++ b/js/src/modals/AddContract/addContract.js
@@ -21,7 +21,7 @@ import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forwa
import NavigationArrowBack from 'material-ui/svg-icons/navigation/arrow-back';
import { Button, Modal, Form, Input, InputAddress, RadioButtons } from '~/ui';
-import { ERRORS, validateAbi, validateAddress, validateName } from '../../util/validation';
+import { ERRORS, validateAbi, validateAddress, validateName } from '~/util/validation';
import { eip20, wallet } from '~/contracts/abi';
diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js
index d8c308a12..1d3aa6ee2 100644
--- a/js/src/modals/CreateWallet/createWalletStore.js
+++ b/js/src/modals/CreateWallet/createWalletStore.js
@@ -16,13 +16,12 @@
import { observable, computed, action, transaction } from 'mobx';
-import { validateUint, validateAddress, validateName } from '~/util/validation';
-import { ERROR_CODES } from '~/api/transport/error';
-
import Contract from '~/api/contract';
+import { ERROR_CODES } from '~/api/transport/error';
import { wallet as walletAbi } from '~/contracts/abi';
import { wallet as walletCode } from '~/contracts/code';
+import { validateUint, validateAddress, validateName } from '~/util/validation';
import WalletsUtils from '~/util/wallets';
const STEPS = {
diff --git a/js/src/modals/DeployContract/DetailsStep/detailsStep.js b/js/src/modals/DeployContract/DetailsStep/detailsStep.js
index 54ef8f850..aa0a30e55 100644
--- a/js/src/modals/DeployContract/DetailsStep/detailsStep.js
+++ b/js/src/modals/DeployContract/DetailsStep/detailsStep.js
@@ -18,8 +18,8 @@ import React, { Component, PropTypes } from 'react';
import { MenuItem } from 'material-ui';
import { AddressSelect, Form, Input, Select } from '~/ui';
-import { validateAbi } from '../../../util/validation';
-import { parseAbiType } from '../../../util/abi';
+import { validateAbi } from '~/util/validation';
+import { parseAbiType } from '~/util/abi';
export default class DetailsStep extends Component {
static contextTypes = {
diff --git a/js/src/modals/DeployContract/ParametersStep/parametersStep.js b/js/src/modals/DeployContract/ParametersStep/parametersStep.js
index 4c7228b67..4ab5df693 100644
--- a/js/src/modals/DeployContract/ParametersStep/parametersStep.js
+++ b/js/src/modals/DeployContract/ParametersStep/parametersStep.js
@@ -32,7 +32,7 @@
import React, { Component, PropTypes } from 'react';
import { Form, TypedInput } from '~/ui';
-import { parseAbiType } from '../../../util/abi';
+import { parseAbiType } from '~/util/abi';
import styles from '../deployContract.css';
diff --git a/js/src/modals/DeployContract/deployContract.js b/js/src/modals/DeployContract/deployContract.js
index ae5578e40..5bf4fc389 100644
--- a/js/src/modals/DeployContract/deployContract.js
+++ b/js/src/modals/DeployContract/deployContract.js
@@ -19,7 +19,7 @@ import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { BusyStep, CompletedStep, CopyToClipboard, Button, IdentityIcon, Modal, TxHash } from '~/ui';
-import { ERRORS, validateAbi, validateCode, validateName } from '../../util/validation';
+import { ERRORS, validateAbi, validateCode, validateName } from '~/util/validation';
import DetailsStep from './DetailsStep';
import ParametersStep from './ParametersStep';
diff --git a/js/src/modals/EditMeta/editMeta.js b/js/src/modals/EditMeta/editMeta.js
index ad26c19fe..8ab9233f1 100644
--- a/js/src/modals/EditMeta/editMeta.js
+++ b/js/src/modals/EditMeta/editMeta.js
@@ -19,7 +19,7 @@ import ContentClear from 'material-ui/svg-icons/content/clear';
import ContentSave from 'material-ui/svg-icons/content/save';
import { Button, Form, Input, InputChip, Modal } from '~/ui';
-import { validateName } from '../../util/validation';
+import { validateName } from '~/util/validation';
export default class EditMeta extends Component {
static contextTypes = {
diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js
index 4a708d17a..2db5e2b04 100644
--- a/js/src/modals/ExecuteContract/executeContract.js
+++ b/js/src/modals/ExecuteContract/executeContract.js
@@ -21,8 +21,8 @@ import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
-import { MAX_GAS_ESTIMATION } from '../../util/constants';
-import { validateAddress, validateUint } from '../../util/validation';
+import { MAX_GAS_ESTIMATION } from '~/util/constants';
+import { validateAddress, validateUint } from '~/util/validation';
import { parseAbiType } from '~/util/abi';
import DetailsStep from './DetailsStep';
diff --git a/js/src/modals/SMSVerification/store.js b/js/src/modals/SMSVerification/store.js
index 49b91fa70..7a132aaf7 100644
--- a/js/src/modals/SMSVerification/store.js
+++ b/js/src/modals/SMSVerification/store.js
@@ -21,9 +21,8 @@ import { sha3 } from '~/api/util/sha3';
import Contracts from '~/contracts';
import { checkIfVerified, checkIfRequested, awaitPuzzle } from '~/contracts/sms-verification';
-import { postToServer } from '../../3rdparty/sms-verification';
-import checkIfTxFailed from '../../util/check-if-tx-failed';
-import waitForConfirmations from '../../util/wait-for-block-confirmations';
+import { postToServer } from '~/3rdparty/sms-verification';
+import { checkIfTxFailed, waitForConfirmations } from '~/util/tx';
export const LOADING = 'fetching-contract';
export const QUERY_DATA = 'query-data';
diff --git a/js/src/modals/SaveContract/saveContract.js b/js/src/modals/SaveContract/saveContract.js
index c73fd8a21..5d7863632 100644
--- a/js/src/modals/SaveContract/saveContract.js
+++ b/js/src/modals/SaveContract/saveContract.js
@@ -20,7 +20,7 @@ import SaveIcon from 'material-ui/svg-icons/content/save';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { Button, Modal, Editor, Form, Input } from '~/ui';
-import { ERRORS, validateName } from '../../util/validation';
+import { ERRORS, validateName } from '~/util/validation';
import styles from './saveContract.css';
diff --git a/js/src/modals/Shapeshift/shapeshift.js b/js/src/modals/Shapeshift/shapeshift.js
index 562c8cbf3..9c5d696b0 100644
--- a/js/src/modals/Shapeshift/shapeshift.js
+++ b/js/src/modals/Shapeshift/shapeshift.js
@@ -19,7 +19,7 @@ import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear';
import { Button, IdentityIcon, Modal } from '~/ui';
-import initShapeshift from '../../3rdparty/shapeshift';
+import initShapeshift from '~/3rdparty/shapeshift';
import shapeshiftLogo from '../../../assets/images/shapeshift-logo.png';
import AwaitingDepositStep from './AwaitingDepositStep';
diff --git a/js/src/redux/providers/walletActions.js b/js/src/redux/providers/walletActions.js
index 8e13ac1a0..4a8a3f82a 100644
--- a/js/src/redux/providers/walletActions.js
+++ b/js/src/redux/providers/walletActions.js
@@ -17,12 +17,10 @@
import { isEqual, uniq } from 'lodash';
import Contract from '~/api/contract';
-import { wallet as WALLET_ABI } from '~/contracts/abi';
import { bytesToHex, toHex } from '~/api/util/format';
-
import { ERROR_CODES } from '~/api/transport/error';
-import { MAX_GAS_ESTIMATION } from '../../util/constants';
-
+import { wallet as WALLET_ABI } from '~/contracts/abi';
+import { MAX_GAS_ESTIMATION } from '~/util/constants';
import WalletsUtils from '~/util/wallets';
import { newError } from '~/ui/Errors/actions';
diff --git a/js/src/ui/Form/TypedInput/typedInput.js b/js/src/ui/Form/TypedInput/typedInput.js
index 9162348e0..a81ec7b79 100644
--- a/js/src/ui/Form/TypedInput/typedInput.js
+++ b/js/src/ui/Form/TypedInput/typedInput.js
@@ -22,12 +22,11 @@ import IconButton from 'material-ui/IconButton';
import AddIcon from 'material-ui/svg-icons/content/add';
import RemoveIcon from 'material-ui/svg-icons/content/remove';
+import { fromWei, toWei } from '~/api/util/wei';
import Input from '~/ui/Form/Input';
import InputAddressSelect from '~/ui/Form/InputAddressSelect';
import Select from '~/ui/Form/Select';
-
import { ABI_TYPES } from '~/util/abi';
-import { fromWei, toWei } from '~/api/util/wei';
import styles from './typedInput.css';
diff --git a/js/src/ui/TxHash/txHash.js b/js/src/ui/TxHash/txHash.js
index 81c4e0bf5..715568fd9 100644
--- a/js/src/ui/TxHash/txHash.js
+++ b/js/src/ui/TxHash/txHash.js
@@ -20,7 +20,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { LinearProgress } from 'material-ui';
-import { txLink } from '../../3rdparty/etherscan/links';
+import { txLink } from '~/3rdparty/etherscan/links';
import ShortenedHash from '../ShortenedHash';
import styles from './txHash.css';
diff --git a/js/src/ui/TxList/txList.js b/js/src/ui/TxList/txList.js
index b8c53c1d9..3f5dab264 100644
--- a/js/src/ui/TxList/txList.js
+++ b/js/src/ui/TxList/txList.js
@@ -20,7 +20,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { observer } from 'mobx-react';
-import { txLink, addressLink } from '../../3rdparty/etherscan/links';
+import { txLink, addressLink } from '~/3rdparty/etherscan/links';
import IdentityIcon from '../IdentityIcon';
import IdentityName from '../IdentityName';
diff --git a/js/src/util/check-if-tx-failed.js b/js/src/util/check-if-tx-failed.js
deleted file mode 100644
index 39689bedd..000000000
--- a/js/src/util/check-if-tx-failed.js
+++ /dev/null
@@ -1,28 +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 .
-
-const checkIfTxFailed = (api, tx, gasSent) => {
- return api.pollMethod('eth_getTransactionReceipt', tx)
- .then((receipt) => {
- // TODO: Right now, there's no way to tell wether the EVM code crashed.
- // Because you usually send a bit more gas than estimated (to make sure
- // it gets mined quickly), we transaction probably failed if all the gas
- // has been used up.
- return receipt.gasUsed.eq(gasSent);
- });
-};
-
-export default checkIfTxFailed;
diff --git a/js/src/util/is-testnet.js b/js/src/util/is-testnet.js
deleted file mode 100644
index c2bf2c450..000000000
--- a/js/src/util/is-testnet.js
+++ /dev/null
@@ -1,19 +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 .
-
-export default (chain) => {
- return chain === 'morden' || chain === 'ropsten' || chain === 'testnet';
-};
diff --git a/js/src/util/wait-for-block-confirmations.js b/js/src/util/tx.js
similarity index 73%
rename from js/src/util/wait-for-block-confirmations.js
rename to js/src/util/tx.js
index 79ba2be25..b688d06fe 100644
--- a/js/src/util/wait-for-block-confirmations.js
+++ b/js/src/util/tx.js
@@ -18,7 +18,18 @@ const isValidReceipt = (receipt) => {
return receipt && receipt.blockNumber && receipt.blockNumber.gt(0);
};
-const waitForConfirmations = (api, tx, confirmations) => {
+export function checkIfTxFailed (api, tx, gasSent) {
+ return api.pollMethod('eth_getTransactionReceipt', tx)
+ .then((receipt) => {
+ // TODO: Right now, there's no way to tell wether the EVM code crashed.
+ // Because you usually send a bit more gas than estimated (to make sure
+ // it gets mined quickly), we transaction probably failed if all the gas
+ // has been used up.
+ return receipt.gasUsed.eq(gasSent);
+ });
+}
+
+export function waitForConfirmations (api, tx, confirmations) {
return new Promise((resolve, reject) => {
api.pollMethod('eth_getTransactionReceipt', tx, isValidReceipt)
.then((receipt) => {
@@ -39,6 +50,4 @@ const waitForConfirmations = (api, tx, confirmations) => {
.catch(reject);
});
});
-};
-
-export default waitForConfirmations;
+}
diff --git a/js/src/views/Account/Transactions/transactions.css b/js/src/views/Account/Transactions/transactions.css
index 13d727deb..6b44d298f 100644
--- a/js/src/views/Account/Transactions/transactions.css
+++ b/js/src/views/Account/Transactions/transactions.css
@@ -15,9 +15,6 @@
/* along with Parity. If not, see .
*/
-.transactions {
-}
-
.infonone {
opacity: 0.25;
}
diff --git a/js/src/views/Account/Transactions/transactions.js b/js/src/views/Account/Transactions/transactions.js
index e71781adf..2e98208b6 100644
--- a/js/src/views/Account/Transactions/transactions.js
+++ b/js/src/views/Account/Transactions/transactions.js
@@ -18,7 +18,7 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
-import etherscan from '../../../3rdparty/etherscan';
+import etherscan from '~/3rdparty/etherscan';
import { Container, TxList } from '~/ui';
import styles from './transactions.css';
diff --git a/js/src/views/Account/account.css b/js/src/views/Account/account.css
index b1410f23a..a9a039c83 100644
--- a/js/src/views/Account/account.css
+++ b/js/src/views/Account/account.css
@@ -14,8 +14,6 @@
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see .
*/
-.account {
-}
.btnicon {
width: 24px;
diff --git a/js/src/views/Account/account.js b/js/src/views/Account/account.js
index 98b0a5e97..cbacd5280 100644
--- a/js/src/views/Account/account.js
+++ b/js/src/views/Account/account.js
@@ -105,7 +105,7 @@ class Account extends Component {
}
return (
-
+
{ this.renderDeleteDialog(account) }
{ this.renderEditDialog(account) }
{ this.renderFundDialog() }
diff --git a/js/src/views/Accounts/accounts.css b/js/src/views/Accounts/accounts.css
index 469f33ddc..317905fd5 100644
--- a/js/src/views/Accounts/accounts.css
+++ b/js/src/views/Accounts/accounts.css
@@ -14,8 +14,6 @@
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see .
*/
-.accounts {
-}
.accountTooltip {
top: 13.3em;
diff --git a/js/src/views/Accounts/accounts.js b/js/src/views/Accounts/accounts.js
index a8a29945f..4383b7662 100644
--- a/js/src/views/Accounts/accounts.js
+++ b/js/src/views/Accounts/accounts.js
@@ -82,7 +82,7 @@ class Accounts extends Component {
render () {
return (
-
{ this.renderActionbar(account) }
{ this.renderDeleteDialog(account) }
{ this.renderEditDialog(account) }
diff --git a/js/src/views/Contracts/contracts.css b/js/src/views/Contracts/contracts.css
deleted file mode 100644
index eab0858e7..000000000
--- a/js/src/views/Contracts/contracts.css
+++ /dev/null
@@ -1,18 +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 .
-*/
-.contracts {
-}
diff --git a/js/src/views/Contracts/contracts.js b/js/src/views/Contracts/contracts.js
index d97d88b09..b84705b32 100644
--- a/js/src/views/Contracts/contracts.js
+++ b/js/src/views/Contracts/contracts.js
@@ -28,8 +28,6 @@ import { setVisibleAccounts } from '~/redux/providers/personalActions';
import List from '../Accounts/List';
-import styles from './contracts.css';
-
class Contracts extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
@@ -80,7 +78,7 @@ class Contracts extends Component {
const { searchValues, sortOrder } = this.state;
return (
-
);
+ );
}
renderCustomCursor = () => {
diff --git a/js/src/modals/Transfer/GasPriceSelector/index.js b/js/src/ui/GasPriceEditor/GasPriceSelector/index.js
similarity index 100%
rename from js/src/modals/Transfer/GasPriceSelector/index.js
rename to js/src/ui/GasPriceEditor/GasPriceSelector/index.js
diff --git a/js/src/ui/GasPriceEditor/gasPriceEditor.css b/js/src/ui/GasPriceEditor/gasPriceEditor.css
new file mode 100644
index 000000000..cf1fff81c
--- /dev/null
+++ b/js/src/ui/GasPriceEditor/gasPriceEditor.css
@@ -0,0 +1,49 @@
+/* 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 .
+*/
+
+.columns {
+ display: flex;
+ flex-wrap: wrap;
+ position: relative;
+}
+
+.graphColumn {
+ flex: 65;
+}
+
+.editColumn {
+ flex: 35;
+ padding-left: 1em;
+ justify-ontent: space-around;
+ padding-bottom: 12;
+ display: flex;
+ flex-wrap: wrap;
+ position: relative;
+ flex-direction: column;
+}
+
+.gasPriceDesc {
+ font-size: 0.75em;
+ opacity: 0.5;
+}
+
+.row {
+ display: flex;
+ flex-wrap: wrap;
+ position: relative;
+ flex-direction: column;
+}
diff --git a/js/src/ui/GasPriceEditor/gasPriceEditor.js b/js/src/ui/GasPriceEditor/gasPriceEditor.js
new file mode 100644
index 000000000..c6759ddf1
--- /dev/null
+++ b/js/src/ui/GasPriceEditor/gasPriceEditor.js
@@ -0,0 +1,98 @@
+// 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 .
+
+import BigNumber from 'bignumber.js';
+import React, { Component, PropTypes } from 'react';
+import { observer } from 'mobx-react';
+
+import Input from '../Form/Input';
+import GasPriceSelector from './GasPriceSelector';
+import Store from './store';
+
+import styles from './gasPriceEditor.css';
+
+@observer
+export default class GasPriceEditor extends Component {
+ static propTypes = {
+ children: PropTypes.node,
+ store: PropTypes.object.isRequired,
+ onChange: PropTypes.func
+ }
+
+ static Store = Store;
+
+ render () {
+ const { children, store } = this.props;
+ const { estimated, priceDefault, price, gas, histogram, errorGas, errorPrice } = store;
+
+ const gasLabel = `gas (estimated: ${new BigNumber(estimated).toFormat()})`;
+ const priceLabel = `price (current: ${new BigNumber(priceDefault).toFormat()})`;
+
+ return (
+
+
+
+
+ You can choose the gas price based on the
+ distribution of recent included transaction gas prices.
+ The lower the gas price is, the cheaper the transaction will
+ be. The higher the gas price is, the faster it should
+ get mined by the network.
+
+
+
+
+
+
+
+
+
+
+
+ { children }
+
+
+
+ );
+ }
+
+ onEditGas = (event, gas) => {
+ const { store, onChange } = this.props;
+
+ store.setGas(gas);
+ onChange && onChange('gas', gas);
+ }
+
+ onEditGasPrice = (event, price) => {
+ const { store, onChange } = this.props;
+
+ store.setPrice(price);
+ onChange && onChange('gasPrice', price);
+ }
+}
diff --git a/js/src/ui/GasPriceEditor/index.js b/js/src/ui/GasPriceEditor/index.js
new file mode 100644
index 000000000..956f6ffd2
--- /dev/null
+++ b/js/src/ui/GasPriceEditor/index.js
@@ -0,0 +1,17 @@
+// 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 .
+
+export default from './gasPriceEditor';
diff --git a/js/src/ui/GasPriceEditor/store.js b/js/src/ui/GasPriceEditor/store.js
new file mode 100644
index 000000000..3f3e50430
--- /dev/null
+++ b/js/src/ui/GasPriceEditor/store.js
@@ -0,0 +1,105 @@
+// 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 .
+
+import BigNumber from 'bignumber.js';
+import { action, observable, transaction } from 'mobx';
+
+import { ERRORS, validatePositiveNumber } from '~/util/validation';
+import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '~/util/constants';
+
+export default class GasPriceEditor {
+ @observable errorEstimated = null;
+ @observable errorGas = null;
+ @observable errorPrice = null;
+ @observable estimated = DEFAULT_GAS;
+ @observable histogram = null;
+ @observable price = DEFAULT_GASPRICE;
+ @observable priceDefault = DEFAULT_GASPRICE;
+ @observable gas = DEFAULT_GAS;
+ @observable gasLimit = 0;
+
+ constructor (api, gasLimit, loadDefaults = true) {
+ this._api = api;
+ this.gasLimit = gasLimit;
+
+ if (loadDefaults) {
+ this.loadDefaults();
+ }
+ }
+
+ @action setEstimated = (estimated) => {
+ transaction(() => {
+ const bn = new BigNumber(estimated);
+
+ this.estimated = estimated;
+
+ if (bn.gte(MAX_GAS_ESTIMATION)) {
+ this.errorEstimated = ERRORS.gasException;
+ } else if (bn.gte(this.gasLimit)) {
+ this.errorEstimated = ERRORS.gasBlockLimit;
+ } else {
+ this.errorEstimated = null;
+ }
+ });
+ }
+
+ @action setHistogram = (gasHistogram) => {
+ this.histogram = gasHistogram;
+ }
+
+ @action setPrice = (price) => {
+ transaction(() => {
+ this.errorPrice = validatePositiveNumber(price).numberError;
+ this.price = price;
+ });
+ }
+
+ @action setGas = (gas) => {
+ transaction(() => {
+ const { numberError } = validatePositiveNumber(gas);
+ const bn = new BigNumber(gas);
+
+ this.gas = gas;
+
+ if (numberError) {
+ this.errorGas = numberError;
+ } else if (bn.gte(this.gasLimit)) {
+ this.errorGas = ERRORS.gasBlockLimit;
+ } else {
+ this.errorGas = null;
+ }
+ });
+ }
+
+ @action loadDefaults () {
+ Promise
+ .all([
+ this._api.parity.gasPriceHistogram(),
+ this._api.eth.gasPrice()
+ ])
+ .then(([gasPriceHistogram, gasPrice]) => {
+ transaction(() => {
+ this.setPrice(gasPrice.toFixed(0));
+ this.setHistogram(gasPriceHistogram);
+
+ this.priceDefault = gasPrice.toFixed();
+ });
+ })
+ .catch((error) => {
+ console.warn('getDefaults', error);
+ });
+ }
+}
diff --git a/js/src/ui/index.js b/js/src/ui/index.js
index 6c763f0f3..c5a965458 100644
--- a/js/src/ui/index.js
+++ b/js/src/ui/index.js
@@ -31,6 +31,7 @@ import CopyToClipboard from './CopyToClipboard';
import Editor from './Editor';
import Errors from './Errors';
import Form, { AddressSelect, FormWrap, TypedInput, Input, InputAddress, InputAddressSelect, InputChip, InputInline, Select, RadioButtons } from './Form';
+import GasPriceEditor from './GasPriceEditor';
import IdentityIcon from './IdentityIcon';
import IdentityName from './IdentityName';
import Loading from './Loading';
@@ -67,7 +68,7 @@ export {
Errors,
Form,
FormWrap,
- TypedInput,
+ GasPriceEditor,
Input,
InputAddress,
InputAddressSelect,
@@ -91,5 +92,6 @@ export {
Tooltip,
Tooltips,
TxHash,
- TxList
+ TxList,
+ TypedInput
};
diff --git a/js/src/util/validation.js b/js/src/util/validation.js
index 2b64141db..3d312a2f4 100644
--- a/js/src/util/validation.js
+++ b/js/src/util/validation.js
@@ -20,6 +20,7 @@ import util from '~/api/util';
export const ERRORS = {
invalidAddress: 'address is an invalid network address',
+ invalidAmount: 'the supplied amount should be a valid positive number',
duplicateAddress: 'the address is already in your address book',
invalidChecksum: 'address has failed the checksum formatting',
invalidName: 'name should not be blank and longer than 2',
@@ -27,7 +28,9 @@ export const ERRORS = {
invalidCode: 'code should be the compiled hex string',
invalidNumber: 'invalid number format',
negativeNumber: 'input number should be positive',
- decimalNumber: 'input number should not contain decimals'
+ decimalNumber: 'input number should not contain decimals',
+ gasException: 'the transaction will throw an exception with the current values',
+ gasBlockLimit: 'the transaction execution will exceed the block gas limit'
};
export function validateAbi (abi, api) {
@@ -133,6 +136,25 @@ export function validateName (name) {
};
}
+export function validatePositiveNumber (number) {
+ let numberError = null;
+
+ try {
+ const v = new BigNumber(number);
+
+ if (v.lt(0)) {
+ numberError = ERRORS.invalidAmount;
+ }
+ } catch (e) {
+ numberError = ERRORS.invalidAmount;
+ }
+
+ return {
+ number,
+ numberError
+ };
+}
+
export function validateUint (value) {
let valueError = null;
From 1213ada59ce2d48b1aed4b91c67d1dd11f5267aa Mon Sep 17 00:00:00 2001
From: GitLab Build Bot
Date: Fri, 9 Dec 2016 12:52:50 +0000
Subject: [PATCH 41/56] [ci skip] js-precompiled 20161209-125036
---
Cargo.lock | 2 +-
js/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 5795de427..d0664d801 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1271,7 +1271,7 @@ dependencies = [
[[package]]
name = "parity-ui-precompiled"
version = "1.4.0"
-source = "git+https://github.com/ethcore/js-precompiled.git#1bf7160f6c8f25353d790dbd0935560d3d395727"
+source = "git+https://github.com/ethcore/js-precompiled.git#8e8e515f958d2d4a5abec07253a51a052f2b744d"
dependencies = [
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
diff --git a/js/package.json b/js/package.json
index 4be14d531..ab501f6a7 100644
--- a/js/package.json
+++ b/js/package.json
@@ -1,6 +1,6 @@
{
"name": "parity.js",
- "version": "0.2.102",
+ "version": "0.2.103",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Parity Team ",
From cc8c2ea58d64aab71c28c695390fda384ad4cd13 Mon Sep 17 00:00:00 2001
From: arkpar
Date: Wed, 7 Dec 2016 23:13:53 +0100
Subject: [PATCH 42/56] Reject existing tx
---
ethcore/src/client/client.rs | 4 ++++
ethcore/src/client/test_client.rs | 4 ++++
ethcore/src/client/traits.rs | 3 +++
ethcore/src/miner/miner.rs | 15 ++++++++++++---
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs
index 21c5a2366..dcdadd3d1 100644
--- a/ethcore/src/client/client.rs
+++ b/ethcore/src/client/client.rs
@@ -1060,6 +1060,10 @@ impl BlockChainClient for Client {
self.transaction_address(id).and_then(|address| self.chain.read().transaction(&address))
}
+ fn transaction_block(&self, id: TransactionID) -> Option {
+ self.transaction_address(id).map(|addr| addr.block_hash)
+ }
+
fn uncle(&self, id: UncleID) -> Option {
let index = id.position;
self.block_body(id.block).and_then(|body| BodyView::new(&body).uncle_rlp_at(index))
diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs
index dd00db7ec..cce102622 100644
--- a/ethcore/src/client/test_client.rs
+++ b/ethcore/src/client/test_client.rs
@@ -432,6 +432,10 @@ impl BlockChainClient for TestBlockChainClient {
None // Simple default.
}
+ fn transaction_block(&self, _id: TransactionID) -> Option {
+ None // Simple default.
+ }
+
fn uncle(&self, _id: UncleID) -> Option {
None // Simple default.
}
diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs
index 7bf17279c..e23a564d4 100644
--- a/ethcore/src/client/traits.rs
+++ b/ethcore/src/client/traits.rs
@@ -129,6 +129,9 @@ pub trait BlockChainClient : Sync + Send {
/// Get transaction with given hash.
fn transaction(&self, id: TransactionID) -> Option;
+ /// Get the hash of block that contains the transaction, if any.
+ fn transaction_block(&self, id: TransactionID) -> Option;
+
/// Get uncle with given id.
fn uncle(&self, id: UncleID) -> Option;
diff --git a/ethcore/src/miner/miner.rs b/ethcore/src/miner/miner.rs
index 8d1f55567..b171856b9 100644
--- a/ethcore/src/miner/miner.rs
+++ b/ethcore/src/miner/miner.rs
@@ -23,7 +23,7 @@ use account_provider::{AccountProvider, Error as AccountError};
use views::{BlockView, HeaderView};
use header::Header;
use state::{State, CleanupMode};
-use client::{MiningBlockChainClient, Executive, Executed, EnvInfo, TransactOptions, BlockID, CallAnalytics};
+use client::{MiningBlockChainClient, Executive, Executed, EnvInfo, TransactOptions, BlockID, CallAnalytics, TransactionID};
use client::TransactionImportResult;
use executive::contract_address;
use block::{ClosedBlock, SealedBlock, IsBlock, Block};
@@ -357,6 +357,8 @@ impl Miner {
let block_number = open_block.block().fields().header.number();
// TODO Push new uncles too.
+ let mut tx_count: usize = 0;
+ let tx_total = transactions.len();
for tx in transactions {
let hash = tx.hash();
let start = Instant::now();
@@ -378,7 +380,7 @@ impl Miner {
},
_ => {},
}
-
+ trace!(target: "miner", "Adding tx {:?} took {:?}", hash, took);
match result {
Err(Error::Execution(ExecutionError::BlockGasLimitReached { gas_limit, gas_used, gas })) => {
debug!(target: "miner", "Skipping adding transaction to block because of gas limit: {:?} (limit: {:?}, used: {:?}, gas: {:?})", hash, gas_limit, gas_used, gas);
@@ -407,9 +409,12 @@ impl Miner {
"Error adding transaction to block: number={}. transaction_hash={:?}, Error: {:?}",
block_number, hash, e);
},
- _ => {} // imported ok
+ _ => {
+ tx_count += 1;
+ } // imported ok
}
}
+ trace!(target: "miner", "Pushed {}/{} transactions", tx_count, tx_total);
let block = open_block.close();
@@ -580,6 +585,10 @@ impl Miner {
let best_block_header: Header = ::rlp::decode(&chain.best_block_header());
transactions.into_iter()
.map(|tx| {
+ if chain.transaction_block(TransactionID::Hash(tx.hash())).is_some() {
+ debug!(target: "miner", "Rejected tx {:?}: already in the blockchain", tx.hash());
+ return Err(Error::Transaction(TransactionError::AlreadyImported));
+ }
match self.engine.verify_transaction_basic(&tx, &best_block_header) {
Err(e) => {
debug!(target: "miner", "Rejected tx {:?} with invalid signature: {:?}", tx.hash(), e);
From d2494d14255cdd431471e84d46fbccc28e10f057 Mon Sep 17 00:00:00 2001
From: Jaco Greeff
Date: Fri, 9 Dec 2016 15:43:24 +0100
Subject: [PATCH 43/56] GasPrice selection for contract execution
---
.../DetailsStep/detailsStep.js | 35 +++-
.../ExecuteContract/executeContract.css | 12 ++
.../modals/ExecuteContract/executeContract.js | 154 ++++++++++++------
js/src/modals/Transfer/Extras/extras.js | 11 +-
js/src/modals/Transfer/store.js | 2 +
js/src/ui/GasPriceEditor/gasPriceEditor.js | 18 +-
js/src/ui/GasPriceEditor/store.js | 20 ++-
7 files changed, 184 insertions(+), 68 deletions(-)
diff --git a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js
index b4488729a..3ffb929a9 100644
--- a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js
+++ b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js
@@ -15,13 +15,19 @@
// along with Parity. If not, see .
import React, { Component, PropTypes } from 'react';
-import { MenuItem } from 'material-ui';
+import { Checkbox, MenuItem } from 'material-ui';
import { AddressSelect, Form, Input, Select, TypedInput } from '~/ui';
import { parseAbiType } from '~/util/abi';
import styles from '../executeContract.css';
+const CHECK_STYLE = {
+ position: 'absolute',
+ top: '38px',
+ left: '1em'
+};
+
export default class DetailsStep extends Component {
static propTypes = {
accounts: PropTypes.object.isRequired,
@@ -31,10 +37,12 @@ export default class DetailsStep extends Component {
onAmountChange: PropTypes.func.isRequired,
fromAddress: PropTypes.string,
fromAddressError: PropTypes.string,
+ gasEdit: PropTypes.bool,
onFromAddressChange: PropTypes.func.isRequired,
func: PropTypes.object,
funcError: PropTypes.string,
onFuncChange: PropTypes.func,
+ onGasEditClick: PropTypes.func,
values: PropTypes.array.isRequired,
valuesError: PropTypes.array.isRequired,
warning: PropTypes.string,
@@ -42,7 +50,7 @@ export default class DetailsStep extends Component {
}
render () {
- const { accounts, amount, amountError, fromAddress, fromAddressError, onFromAddressChange, onAmountChange } = this.props;
+ const { accounts, amount, amountError, fromAddress, fromAddressError, gasEdit, onGasEditClick, onFromAddressChange, onAmountChange } = this.props;
return (
);
}
diff --git a/js/src/modals/ExecuteContract/executeContract.css b/js/src/modals/ExecuteContract/executeContract.css
index a83b373ee..6b7132912 100644
--- a/js/src/modals/ExecuteContract/executeContract.css
+++ b/js/src/modals/ExecuteContract/executeContract.css
@@ -42,3 +42,15 @@
padding: 0.75em;
text-align: center;
}
+
+.columns {
+ display: flex;
+ flex-wrap: wrap;
+ position: relative;
+
+ &>div {
+ flex: 0 1 50%;
+ width: 50%;
+ position: relative;
+ }
+}
diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js
index 2db5e2b04..3f7940ca3 100644
--- a/js/src/modals/ExecuteContract/executeContract.js
+++ b/js/src/modals/ExecuteContract/executeContract.js
@@ -17,19 +17,36 @@
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
+import { observer } from 'mobx-react';
import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear';
+import NavigationArrowBack from 'material-ui/svg-icons/navigation/arrow-back';
+import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward';
-import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
+import { BusyStep, Button, CompletedStep, GasPriceEditor, IdentityIcon, Modal, TxHash } from '~/ui';
import { MAX_GAS_ESTIMATION } from '~/util/constants';
import { validateAddress, validateUint } from '~/util/validation';
import { parseAbiType } from '~/util/abi';
import DetailsStep from './DetailsStep';
-import ERRORS from '../Transfer/errors';
import { ERROR_CODES } from '~/api/transport/error';
+const STEP_DETAILS = 0;
+const STEP_BUSY_OR_GAS = 1;
+const STEP_BUSY = 2;
+
+const TITLES = {
+ transfer: 'function details',
+ sending: 'sending',
+ complete: 'complete',
+ gas: 'gas selection',
+ rejected: 'rejected'
+};
+const STAGES_BASIC = [TITLES.transfer, TITLES.sending, TITLES.complete];
+const STAGES_GAS = [TITLES.transfer, TITLES.gas, TITLES.sending, TITLES.complete];
+
+@observer
class ExecuteContract extends Component {
static contextTypes = {
api: PropTypes.object.isRequired,
@@ -46,21 +63,22 @@ class ExecuteContract extends Component {
onFromAddressChange: PropTypes.func.isRequired
}
+ gasStore = new GasPriceEditor.Store(this.context.api, this.props.gasLimit);
+
state = {
amount: '0',
amountError: null,
+ busyState: null,
fromAddressError: null,
func: null,
funcError: null,
- gas: null,
- gasLimitError: null,
+ gasEdit: false,
+ rejected: false,
+ step: STEP_DETAILS,
+ sending: false,
values: [],
valuesError: [],
- step: 0,
- sending: false,
- busyState: null,
- txhash: null,
- rejected: false
+ txhash: null
}
componentDidMount () {
@@ -79,15 +97,21 @@ class ExecuteContract extends Component {
}
render () {
- const { sending } = this.state;
+ const { sending, step, gasEdit, rejected } = this.state;
+ const steps = gasEdit ? STAGES_GAS : STAGES_BASIC;
+
+ if (rejected) {
+ steps[steps.length - 1] = TITLES.rejected;
+ }
return (
+ current={ step }
+ steps={ steps }
+ visible
+ waiting={ gasEdit ? [STEP_BUSY] : [STEP_BUSY_OR_GAS] }>
{ this.renderStep() }
);
@@ -95,7 +119,7 @@ class ExecuteContract extends Component {
renderDialogActions () {
const { onClose, fromAddress } = this.props;
- const { sending, step, fromAddressError, valuesError } = this.state;
+ const { gasEdit, sending, step, fromAddressError, valuesError } = this.state;
const hasError = fromAddressError || valuesError.find((error) => error);
const cancelBtn = (
@@ -105,21 +129,44 @@ class ExecuteContract extends Component {
icon={ }
onClick={ onClose } />
);
+ const postBtn = (
+ }
+ onClick={ this.postTransaction } />
+ );
+ const nextBtn = (
+ }
+ onClick={ this.onNextClick } />
+ );
+ const prevBtn = (
+ }
+ onClick={ this.onPrevClick } />
+ );
- if (step === 0) {
+ if (step === STEP_DETAILS) {
return [
cancelBtn,
- }
- onClick={ this.postTransaction } />
+ gasEdit ? nextBtn : postBtn
];
- } else if (step === 1) {
+ } else if (step === (gasEdit ? STEP_BUSY : STEP_BUSY_OR_GAS)) {
return [
cancelBtn
];
+ } else if (gasEdit && (step === STEP_BUSY_OR_GAS)) {
+ return [
+ cancelBtn,
+ prevBtn,
+ postBtn
+ ];
}
return [
@@ -133,7 +180,8 @@ class ExecuteContract extends Component {
renderStep () {
const { onFromAddressChange } = this.props;
- const { step, busyState, gasLimitError, txhash, rejected } = this.state;
+ const { gasEdit, step, busyState, txhash, rejected } = this.state;
+ const { errorEstimated } = this.gasStore;
if (rejected) {
return (
@@ -144,23 +192,29 @@ class ExecuteContract extends Component {
);
}
- if (step === 0) {
+ if (step === STEP_DETAILS) {
return (
);
- } else if (step === 1) {
+ } else if (step === (gasEdit ? STEP_BUSY : STEP_BUSY_OR_GAS)) {
return (
);
+ } else if (gasEdit && (step === STEP_BUSY_OR_GAS)) {
+ return (
+
+ );
}
return (
@@ -171,6 +225,7 @@ class ExecuteContract extends Component {
}
onAmountChange = (amount) => {
+ this.gasStore.setEthValue(amount);
this.setState({ amount }, this.estimateGas);
}
@@ -221,7 +276,7 @@ class ExecuteContract extends Component {
estimateGas = (_fromAddress) => {
const { api } = this.context;
- const { fromAddress, gasLimit } = this.props;
+ const { fromAddress } = this.props;
const { amount, func, values } = this.state;
const options = {
gas: MAX_GAS_ESTIMATION,
@@ -237,18 +292,11 @@ class ExecuteContract extends Component {
.estimateGas(options, values)
.then((gasEst) => {
const gas = gasEst.mul(1.2);
- let gasLimitError = null;
- if (gas.gte(MAX_GAS_ESTIMATION)) {
- gasLimitError = ERRORS.gasException;
- } else if (gas.gt(gasLimit)) {
- gasLimitError = ERRORS.gasBlockLimit;
- }
+ console.log(`estimateGas: received ${gasEst.toFormat(0)}, adjusted to ${gas.toFormat(0)}`);
- this.setState({
- gas,
- gasLimitError
- });
+ this.gasStore.setEstimated(gasEst.toFixed(0));
+ this.gasStore.setGas(gas.toFixed(0));
})
.catch((error) => {
console.warn('estimateGas', error);
@@ -258,22 +306,18 @@ class ExecuteContract extends Component {
postTransaction = () => {
const { api, store } = this.context;
const { fromAddress } = this.props;
- const { amount, func, values } = this.state;
+ const { amount, func, gasEdit, values } = this.state;
const options = {
- gas: MAX_GAS_ESTIMATION,
+ gas: this.gasStore.gas,
+ gasPrice: this.gasStore.price,
from: fromAddress,
value: api.util.toWei(amount || 0)
};
- this.setState({ sending: true, step: 1 });
+ this.setState({ sending: true, step: gasEdit ? STEP_BUSY : STEP_BUSY_OR_GAS });
func
- .estimateGas(options, values)
- .then((gas) => {
- options.gas = gas.mul(1.2).toFixed(0);
- console.log(`estimateGas: received ${gas.toFormat(0)}, adjusted to ${gas.mul(1.2).toFormat(0)}`);
- return func.postTransaction(options, values);
- })
+ .postTransaction(options, values)
.then((requestId) => {
this.setState({ busyState: 'Waiting for authorization in the Parity Signer' });
@@ -296,6 +340,24 @@ class ExecuteContract extends Component {
store.dispatch({ type: 'newError', error });
});
}
+
+ onGasEditClick = () => {
+ this.setState({
+ gasEdit: !this.state.gasEdit
+ });
+ }
+
+ onNextClick = () => {
+ this.setState({
+ step: this.state.step + 1
+ });
+ }
+
+ onPrevClick = () => {
+ this.setState({
+ step: this.state.step - 1
+ });
+ }
}
function mapStateToProps (state) {
diff --git a/js/src/modals/Transfer/Extras/extras.js b/js/src/modals/Transfer/Extras/extras.js
index 6d2bfc821..def5a22c6 100644
--- a/js/src/modals/Transfer/Extras/extras.js
+++ b/js/src/modals/Transfer/Extras/extras.js
@@ -30,21 +30,14 @@ export default class Extras extends Component {
}
render () {
- const { gasStore, onChange, total, totalError } = this.props;
+ const { gasStore, onChange } = this.props;
return (
);
}
diff --git a/js/src/modals/Transfer/store.js b/js/src/modals/Transfer/store.js
index a43057c86..cbb10f17f 100644
--- a/js/src/modals/Transfer/store.js
+++ b/js/src/modals/Transfer/store.js
@@ -408,6 +408,8 @@ export default class TransferStore {
this.totalError = totalError;
this.value = value;
this.valueError = valueError;
+ this.gasStore.setErrorTotal(totalError);
+ this.gasStore.setEthValue(totalEth);
});
}
diff --git a/js/src/ui/GasPriceEditor/gasPriceEditor.js b/js/src/ui/GasPriceEditor/gasPriceEditor.js
index c6759ddf1..8c94dfca7 100644
--- a/js/src/ui/GasPriceEditor/gasPriceEditor.js
+++ b/js/src/ui/GasPriceEditor/gasPriceEditor.js
@@ -26,8 +26,11 @@ import styles from './gasPriceEditor.css';
@observer
export default class GasPriceEditor extends Component {
+ static contextTypes = {
+ api: PropTypes.object.isRequired
+ };
+
static propTypes = {
- children: PropTypes.node,
store: PropTypes.object.isRequired,
onChange: PropTypes.func
}
@@ -35,9 +38,11 @@ export default class GasPriceEditor extends Component {
static Store = Store;
render () {
- const { children, store } = this.props;
- const { estimated, priceDefault, price, gas, histogram, errorGas, errorPrice } = store;
+ const { api } = this.context;
+ const { store } = this.props;
+ const { estimated, priceDefault, price, gas, histogram, errorGas, errorPrice, errorTotal, totalValue } = store;
+ const eth = api.util.fromWei(totalValue).toFormat();
const gasLabel = `gas (estimated: ${new BigNumber(estimated).toFormat()})`;
const priceLabel = `price (current: ${new BigNumber(priceDefault).toFormat()})`;
@@ -75,7 +80,12 @@ export default class GasPriceEditor extends Component {
- { children }
+
diff --git a/js/src/ui/GasPriceEditor/store.js b/js/src/ui/GasPriceEditor/store.js
index 3f3e50430..afa5e15b2 100644
--- a/js/src/ui/GasPriceEditor/store.js
+++ b/js/src/ui/GasPriceEditor/store.js
@@ -15,7 +15,7 @@
// along with Parity. If not, see .
import BigNumber from 'bignumber.js';
-import { action, observable, transaction } from 'mobx';
+import { action, computed, observable, transaction } from 'mobx';
import { ERRORS, validatePositiveNumber } from '~/util/validation';
import { DEFAULT_GAS, DEFAULT_GASPRICE, MAX_GAS_ESTIMATION } from '~/util/constants';
@@ -24,12 +24,14 @@ export default class GasPriceEditor {
@observable errorEstimated = null;
@observable errorGas = null;
@observable errorPrice = null;
+ @observable errorTotal = null;
@observable estimated = DEFAULT_GAS;
@observable histogram = null;
@observable price = DEFAULT_GASPRICE;
@observable priceDefault = DEFAULT_GASPRICE;
@observable gas = DEFAULT_GAS;
@observable gasLimit = 0;
+ @observable weiValue = '0';
constructor (api, gasLimit, loadDefaults = true) {
this._api = api;
@@ -40,6 +42,18 @@ export default class GasPriceEditor {
}
}
+ @computed get totalValue () {
+ try {
+ return new BigNumber(this.gas).mul(this.price).add(this.weiValue);
+ } catch (error) {
+ return new BigNumber(0);
+ }
+ }
+
+ @action setErrorTotal = (errorTotal) => {
+ this.errorTotal = errorTotal;
+ }
+
@action setEstimated = (estimated) => {
transaction(() => {
const bn = new BigNumber(estimated);
@@ -56,6 +70,10 @@ export default class GasPriceEditor {
});
}
+ @action setEthValue = (weiValue) => {
+ this.weiValue = weiValue;
+ }
+
@action setHistogram = (gasHistogram) => {
this.histogram = gasHistogram;
}
From 63137b15482344ff9df634c086abaabed452eadc Mon Sep 17 00:00:00 2001
From: Nicolas Gotchac
Date: Fri, 9 Dec 2016 15:52:28 +0100
Subject: [PATCH 44/56] Add enhanced Wallet solidity code
---
js/src/contracts/snippets/enhanced-wallet.sol | 460 ++++++++++++++++++
1 file changed, 460 insertions(+)
create mode 100644 js/src/contracts/snippets/enhanced-wallet.sol
diff --git a/js/src/contracts/snippets/enhanced-wallet.sol b/js/src/contracts/snippets/enhanced-wallet.sol
new file mode 100644
index 000000000..374eb595f
--- /dev/null
+++ b/js/src/contracts/snippets/enhanced-wallet.sol
@@ -0,0 +1,460 @@
+//sol Wallet
+// Multi-sig, daily-limited account proxy/wallet.
+// @authors:
+// Gav Wood
+// inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a
+// single, or, crucially, each of a number of, designated owners.
+// usage:
+// use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by
+// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
+// interior is executed.
+pragma solidity ^0.4.6;
+
+contract multisig {
+ // EVENTS
+
+ // this contract can accept a confirmation, in which case
+ // we record owner and operation (hash) alongside it.
+ event Confirmation(address owner, bytes32 operation);
+ event Revoke(address owner, bytes32 operation);
+
+ // some others are in the case of an owner changing.
+ event OwnerChanged(address oldOwner, address newOwner);
+ event OwnerAdded(address newOwner);
+ event OwnerRemoved(address oldOwner);
+
+ // the last one is emitted if the required signatures change
+ event RequirementChanged(uint newRequirement);
+
+ // Funds has arrived into the wallet (record how much).
+ event Deposit(address _from, uint value);
+ // Single transaction going out of the wallet (record who signed for it, how much, and to whom it's going).
+ event SingleTransact(address owner, uint value, address to, bytes data);
+ // Multi-sig transaction going out of the wallet (record who signed for it last, the operation hash, how much, and to whom it's going).
+ event MultiTransact(address owner, bytes32 operation, uint value, address to, bytes data);
+ // Confirmation still needed for a transaction.
+ event ConfirmationNeeded(bytes32 operation, address initiator, uint value, address to, bytes data);
+}
+
+contract multisigAbi is multisig {
+ function isOwner(address _addr) returns (bool);
+
+ function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool);
+
+ function confirm(bytes32 _h) returns(bool);
+
+ // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
+ function setDailyLimit(uint _newLimit);
+
+ function addOwner(address _owner);
+
+ function removeOwner(address _owner);
+
+ function changeRequirement(uint _newRequired);
+
+ // Revokes a prior confirmation of the given operation
+ function revoke(bytes32 _operation);
+
+ function changeOwner(address _from, address _to);
+
+ function execute(address _to, uint _value, bytes _data) returns(bool);
+}
+
+contract WalletLibrary is multisig {
+ // TYPES
+
+ // struct for the status of a pending operation.
+ struct PendingState {
+ uint yetNeeded;
+ uint ownersDone;
+ uint index;
+ }
+
+ // Transaction structure to remember details of transaction lest it need be saved for a later call.
+ struct Transaction {
+ address to;
+ uint value;
+ bytes data;
+ }
+
+ /******************************
+ ***** MULTI OWNED SECTION ****
+ ******************************/
+
+ // MODIFIERS
+
+ // simple single-sig function modifier.
+ modifier onlyowner {
+ if (isOwner(msg.sender))
+ _;
+ }
+ // multi-sig function modifier: the operation must have an intrinsic hash in order
+ // that later attempts can be realised as the same underlying operation and
+ // thus count as confirmations.
+ modifier onlymanyowners(bytes32 _operation) {
+ if (confirmAndCheck(_operation))
+ _;
+ }
+
+ // METHODS
+
+ // constructor is given number of sigs required to do protected "onlymanyowners" transactions
+ // as well as the selection of addresses capable of confirming them.
+ function initMultiowned(address[] _owners, uint _required) {
+ m_numOwners = _owners.length + 1;
+ m_owners[1] = uint(msg.sender);
+ m_ownerIndex[uint(msg.sender)] = 1;
+ m_required = _required;
+
+ for (uint i = 0; i < _owners.length; ++i)
+ {
+ m_owners[2 + i] = uint(_owners[i]);
+ m_ownerIndex[uint(_owners[i])] = 2 + i;
+ }
+ }
+
+ // Revokes a prior confirmation of the given operation
+ function revoke(bytes32 _operation) {
+ uint ownerIndex = m_ownerIndex[uint(msg.sender)];
+ // make sure they're an owner
+ if (ownerIndex == 0) return;
+ uint ownerIndexBit = 2**ownerIndex;
+ var pending = m_pending[_operation];
+ if (pending.ownersDone & ownerIndexBit > 0) {
+ pending.yetNeeded++;
+ pending.ownersDone -= ownerIndexBit;
+ Revoke(msg.sender, _operation);
+ }
+ }
+
+ // Replaces an owner `_from` with another `_to`.
+ function changeOwner(address _from, address _to) onlymanyowners(sha3(msg.data)) {
+ if (isOwner(_to)) return;
+ uint ownerIndex = m_ownerIndex[uint(_from)];
+ if (ownerIndex == 0) return;
+
+ clearPending();
+ m_owners[ownerIndex] = uint(_to);
+ m_ownerIndex[uint(_from)] = 0;
+ m_ownerIndex[uint(_to)] = ownerIndex;
+ OwnerChanged(_from, _to);
+ }
+
+ function addOwner(address _owner) onlymanyowners(sha3(msg.data)) {
+ if (isOwner(_owner)) return;
+
+ clearPending();
+ if (m_numOwners >= c_maxOwners)
+ reorganizeOwners();
+ if (m_numOwners >= c_maxOwners)
+ return;
+ m_numOwners++;
+ m_owners[m_numOwners] = uint(_owner);
+ m_ownerIndex[uint(_owner)] = m_numOwners;
+ OwnerAdded(_owner);
+ }
+
+ function removeOwner(address _owner) onlymanyowners(sha3(msg.data)) {
+ uint ownerIndex = m_ownerIndex[uint(_owner)];
+ if (ownerIndex == 0) return;
+ if (m_required > m_numOwners - 1) return;
+
+ m_owners[ownerIndex] = 0;
+ m_ownerIndex[uint(_owner)] = 0;
+ clearPending();
+ reorganizeOwners(); //make sure m_numOwner is equal to the number of owners and always points to the optimal free slot
+ OwnerRemoved(_owner);
+ }
+
+ function changeRequirement(uint _newRequired) onlymanyowners(sha3(msg.data)) {
+ if (_newRequired > m_numOwners) return;
+ m_required = _newRequired;
+ clearPending();
+ RequirementChanged(_newRequired);
+ }
+
+ function isOwner(address _addr) returns (bool) {
+ return m_ownerIndex[uint(_addr)] > 0;
+ }
+
+
+ function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
+ var pending = m_pending[_operation];
+ uint ownerIndex = m_ownerIndex[uint(_owner)];
+
+ // make sure they're an owner
+ if (ownerIndex == 0) return false;
+
+ // determine the bit to set for this owner.
+ uint ownerIndexBit = 2**ownerIndex;
+ return !(pending.ownersDone & ownerIndexBit == 0);
+ }
+
+ // INTERNAL METHODS
+
+ function confirmAndCheck(bytes32 _operation) internal returns (bool) {
+ // determine what index the present sender is:
+ uint ownerIndex = m_ownerIndex[uint(msg.sender)];
+ // make sure they're an owner
+ if (ownerIndex == 0) return;
+
+ var pending = m_pending[_operation];
+ // if we're not yet working on this operation, switch over and reset the confirmation status.
+ if (pending.yetNeeded == 0) {
+ // reset count of confirmations needed.
+ pending.yetNeeded = m_required;
+ // reset which owners have confirmed (none) - set our bitmap to 0.
+ pending.ownersDone = 0;
+ pending.index = m_pendingIndex.length++;
+ m_pendingIndex[pending.index] = _operation;
+ }
+ // determine the bit to set for this owner.
+ uint ownerIndexBit = 2**ownerIndex;
+ // make sure we (the message sender) haven't confirmed this operation previously.
+ if (pending.ownersDone & ownerIndexBit == 0) {
+ Confirmation(msg.sender, _operation);
+ // ok - check if count is enough to go ahead.
+ if (pending.yetNeeded <= 1) {
+ // enough confirmations: reset and run interior.
+ delete m_pendingIndex[m_pending[_operation].index];
+ delete m_pending[_operation];
+ return true;
+ }
+ else
+ {
+ // not enough: record that this owner in particular confirmed.
+ pending.yetNeeded--;
+ pending.ownersDone |= ownerIndexBit;
+ }
+ }
+ }
+
+ function reorganizeOwners() private {
+ uint free = 1;
+ while (free < m_numOwners)
+ {
+ while (free < m_numOwners && m_owners[free] != 0) free++;
+ while (m_numOwners > 1 && m_owners[m_numOwners] == 0) m_numOwners--;
+ if (free < m_numOwners && m_owners[m_numOwners] != 0 && m_owners[free] == 0)
+ {
+ m_owners[free] = m_owners[m_numOwners];
+ m_ownerIndex[m_owners[free]] = free;
+ m_owners[m_numOwners] = 0;
+ }
+ }
+ }
+
+ function clearPending() internal {
+ uint length = m_pendingIndex.length;
+ for (uint i = 0; i < length; ++i)
+ if (m_pendingIndex[i] != 0)
+ delete m_pending[m_pendingIndex[i]];
+ delete m_pendingIndex;
+ }
+
+
+ /******************************
+ ****** DAY LIMIT SECTION *****
+ ******************************/
+
+ // MODIFIERS
+
+ // simple modifier for daily limit.
+ modifier limitedDaily(uint _value) {
+ if (underLimit(_value))
+ _;
+ }
+
+ // METHODS
+
+ // constructor - stores initial daily limit and records the present day's index.
+ function initDaylimit(uint _limit) {
+ m_dailyLimit = _limit;
+ m_lastDay = today();
+ }
+ // (re)sets the daily limit. needs many of the owners to confirm. doesn't alter the amount already spent today.
+ function setDailyLimit(uint _newLimit) onlymanyowners(sha3(msg.data)) {
+ m_dailyLimit = _newLimit;
+ }
+ // resets the amount already spent today. needs many of the owners to confirm.
+ function resetSpentToday() onlymanyowners(sha3(msg.data)) {
+ m_spentToday = 0;
+ }
+
+ // INTERNAL METHODS
+
+ // checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and
+ // returns true. otherwise just returns false.
+ function underLimit(uint _value) internal onlyowner returns (bool) {
+ // reset the spend limit if we're on a different day to last time.
+ if (today() > m_lastDay) {
+ m_spentToday = 0;
+ m_lastDay = today();
+ }
+ // check to see if there's enough left - if so, subtract and return true.
+ // overflow protection // dailyLimit check
+ if (m_spentToday + _value >= m_spentToday && m_spentToday + _value <= m_dailyLimit) {
+ m_spentToday += _value;
+ return true;
+ }
+ return false;
+ }
+
+ // determines today's index.
+ function today() private constant returns (uint) { return now / 1 days; }
+
+
+ /******************************
+ ********* WALLET SECTION *****
+ ******************************/
+
+ // METHODS
+
+ // constructor - just pass on the owner array to the multiowned and
+ // the limit to daylimit
+ function initWallet(address[] _owners, uint _required, uint _daylimit) {
+ initMultiowned(_owners, _required);
+ initDaylimit(_daylimit) ;
+ }
+
+ // kills the contract sending everything to `_to`.
+ function kill(address _to) onlymanyowners(sha3(msg.data)) {
+ suicide(_to);
+ }
+
+ // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit.
+ // If not, goes into multisig process. We provide a hash on return to allow the sender to provide
+ // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value
+ // and _data arguments). They still get the option of using them if they want, anyways.
+ function execute(address _to, uint _value, bytes _data) onlyowner returns(bool _callValue) {
+ // first, take the opportunity to check that we're under the daily limit.
+ if (underLimit(_value)) {
+ SingleTransact(msg.sender, _value, _to, _data);
+ // yes - just execute the call.
+ _callValue =_to.call.value(_value)(_data);
+ } else {
+ // determine our operation hash.
+ bytes32 _r = sha3(msg.data, block.number);
+ if (!confirm(_r) && m_txs[_r].to == 0) {
+ m_txs[_r].to = _to;
+ m_txs[_r].value = _value;
+ m_txs[_r].data = _data;
+ ConfirmationNeeded(_r, msg.sender, _value, _to, _data);
+ }
+ }
+ }
+
+ // confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
+ // to determine the body of the transaction from the hash provided.
+ function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
+ if (m_txs[_h].to != 0) {
+ m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data);
+ MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
+ delete m_txs[_h];
+ return true;
+ }
+ }
+
+ // INTERNAL METHODS
+
+ function clearWalletPending() internal {
+ uint length = m_pendingIndex.length;
+ for (uint i = 0; i < length; ++i)
+ delete m_txs[m_pendingIndex[i]];
+ clearPending();
+ }
+
+ // FIELDS
+ address constant _walletLibrary = 0xcafecafecafecafecafecafecafecafecafecafe;
+
+ // the number of owners that must confirm the same operation before it is run.
+ uint m_required;
+ // pointer used to find a free slot in m_owners
+ uint m_numOwners;
+
+ uint public m_dailyLimit;
+ uint public m_spentToday;
+ uint public m_lastDay;
+
+ // list of owners
+ uint[256] m_owners;
+ uint constant c_maxOwners = 250;
+
+ // index on the list of owners to allow reverse lookup
+ mapping(uint => uint) m_ownerIndex;
+ // the ongoing operations.
+ mapping(bytes32 => PendingState) m_pending;
+ bytes32[] m_pendingIndex;
+
+ // pending transactions we have at present.
+ mapping (bytes32 => Transaction) m_txs;
+}
+
+
+contract Wallet is multisig {
+
+ // WALLET CONSTRUCTOR
+ // calls the `initWallet` method of the Library in this context
+ function Wallet(address[] _owners, uint _required, uint _daylimit) {
+ // Signature of the Wallet Library's init function
+ bytes4 sig = bytes4(sha3("initWallet(address[],uint256,uint256)"));
+ address target = _walletLibrary;
+
+ // Compute the size of the call data : arrays has 2
+ // 32bytes for offset and length, plus 32bytes per element ;
+ // plus 2 32bytes for each uint
+ uint argarraysize = (2 + _owners.length);
+ uint argsize = (2 + argarraysize) * 32;
+
+ assembly {
+ // Add the signature first to memory
+ mstore(0x0, sig)
+ // Add the call data, which is at the end of the
+ // code
+ codecopy(0x4, sub(codesize, argsize), argsize)
+ // Delegate call to the library
+ delegatecall(sub(gas, 10000), target, 0x0, add(argsize, 0x4), 0x0, 0x0)
+ }
+ }
+
+ // METHODS
+
+ // gets called when no other function matches
+ function() payable {
+ // just being sent some cash?
+ if (msg.value > 0)
+ Deposit(msg.sender, msg.value);
+ else if (msg.data.length > 0)
+ _walletLibrary.delegatecall(msg.data);
+ }
+
+ // Gets an owner by 0-indexed position (using numOwners as the count)
+ function getOwner(uint ownerIndex) constant returns (address) {
+ return address(m_owners[ownerIndex + 1]);
+ }
+
+ // As return statement unavailable in fallback, explicit the method here
+
+ function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
+ return _walletLibrary.delegatecall(msg.data);
+ }
+
+ function isOwner(address _addr) returns (bool) {
+ return _walletLibrary.delegatecall(msg.data);
+ }
+
+ // FIELDS
+ address constant _walletLibrary = 0xcafecafecafecafecafecafecafecafecafecafe;
+
+ // the number of owners that must confirm the same operation before it is run.
+ uint public m_required;
+ // pointer used to find a free slot in m_owners
+ uint public m_numOwners;
+
+ uint public m_dailyLimit;
+ uint public m_spentToday;
+ uint public m_lastDay;
+
+ // list of owners
+ uint[256] m_owners;
+}
From d992c642ffb2aa5c50e058a51bd59209f8bb7142 Mon Sep 17 00:00:00 2001
From: Jaco Greeff
Date: Fri, 9 Dec 2016 15:55:50 +0100
Subject: [PATCH 45/56] Adjust to final step on rejected/completed
---
js/src/modals/ExecuteContract/executeContract.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js
index 3f7940ca3..7b4e8ccd2 100644
--- a/js/src/modals/ExecuteContract/executeContract.js
+++ b/js/src/modals/ExecuteContract/executeContract.js
@@ -307,6 +307,8 @@ class ExecuteContract extends Component {
const { api, store } = this.context;
const { fromAddress } = this.props;
const { amount, func, gasEdit, values } = this.state;
+ const steps = gasEdit ? STAGES_GAS : STAGES_BASIC;
+ const finalstep = steps.length - 1;
const options = {
gas: this.gasStore.gas,
gasPrice: this.gasStore.price,
@@ -325,7 +327,7 @@ class ExecuteContract extends Component {
.pollMethod('parity_checkRequest', requestId)
.catch((error) => {
if (error.code === ERROR_CODES.REQUEST_REJECTED) {
- this.setState({ rejected: true });
+ this.setState({ rejected: true, step: finalstep });
return false;
}
@@ -333,7 +335,7 @@ class ExecuteContract extends Component {
});
})
.then((txhash) => {
- this.setState({ sending: false, step: 2, txhash, busyState: 'Your transaction has been posted to the network' });
+ this.setState({ sending: false, step: finalstep, txhash, busyState: 'Your transaction has been posted to the network' });
})
.catch((error) => {
console.error('postTransaction', error);
From efee55ae84159f8cf62c54304632e1eb1b21ee9d Mon Sep 17 00:00:00 2001
From: Nicolas Gotchac
Date: Fri, 9 Dec 2016 16:24:11 +0100
Subject: [PATCH 46/56] Updated Wallet Version ! Now only 500k gas for Wallet
creation
---
js/src/contracts/code/index.js | 2 +-
js/src/contracts/code/wallet.js | 10 +++++---
.../CreateWallet/WalletType/walletType.js | 5 +++-
.../modals/CreateWallet/createWalletStore.js | 25 +++++++++++++------
4 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/js/src/contracts/code/index.js b/js/src/contracts/code/index.js
index baa144979..ff6d218eb 100644
--- a/js/src/contracts/code/index.js
+++ b/js/src/contracts/code/index.js
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-import wallet from './wallet';
+import { wallet } from './wallet';
export {
wallet
diff --git a/js/src/contracts/code/wallet.js b/js/src/contracts/code/wallet.js
index 94aa04b7b..35ed3b106 100644
--- a/js/src/contracts/code/wallet.js
+++ b/js/src/contracts/code/wallet.js
@@ -16,8 +16,10 @@
/**
* @version Solidity v0.4.6
- * @from https://github.com/ethereum/dapp-bin/blob/dd5c485359074d49f571693ae064ce78970f3d6d/wallet/wallet.sol
- * @date 22-Nov-2016 @ 15h00 UTC
+ * @from https://github.com/ethcore/parity/blob/63137b15482344ff9df634c086abaabed452eadc/js/src/contracts/snippets/enhanced-wallet.sol
+ * @date 09-Dec-2016 @ 16h00 UTC
*/
-export default '0x606060405234610000576040516113bb3803806113bb83398101604090815281516020830151918301519201915b805b83835b815160019081019055600033600160a060020a03166003825b505550600160a060020a033316600090815261010260205260408120600190555b82518110156100ee57828181518110156100005790602001906020020151600160a060020a0316600282600201610100811015610000570160005b5081905550806002016101026000858481518110156100005790602001906020020151600160a060020a03168152602001908152602001600020819055505b60010161006c565b60008290555b50505061010581905561011264010000000061127861012182021704565b610107555b505b50505061012b565b6201518042045b90565b611282806101396000396000f3606060405236156100da5760e060020a6000350463173825d981146101305780632f54bf6e146101425780634123cb6b1461016657806352375093146101855780635c52c2f5146101a4578063659010e7146101b35780637065cb48146101d2578063746c9171146101e4578063797af62714610203578063b20d30a914610227578063b61d27f614610239578063b75c7dc61461026b578063ba51a6df1461027d578063c2cf73261461028f578063c41a360a146102b6578063cbf0b0c0146102e2578063f00d4b5d146102f4578063f1736d8614610309575b61012e5b600034111561012b5760408051600160a060020a033316815234602082015281517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c929181900390910190a15b5b565b005b346100005761012e600435610328565b005b3461000057610152600435610415565b604080519115158252519081900360200190f35b3461000057610173610436565b60408051918252519081900360200190f35b346100005761017361043c565b60408051918252519081900360200190f35b346100005761012e610443565b005b346100005761017361047b565b60408051918252519081900360200190f35b346100005761012e600435610482565b005b3461000057610173610571565b60408051918252519081900360200190f35b3461000057610152600435610577565b604080519115158252519081900360200190f35b346100005761012e6004356107e3565b005b34610000576101736004803590602480359160443591820191013561081c565b60408051918252519081900360200190f35b346100005761012e600435610ab3565b005b346100005761012e600435610b5e565b005b3461000057610152600435602435610be0565b604080519115158252519081900360200190f35b34610000576102c6600435610c35565b60408051600160a060020a039092168252519081900360200190f35b346100005761012e600435610c55565b005b346100005761012e600435602435610c93565b005b3461000057610173610d8c565b60408051918252519081900360200190f35b600060003660405180838380828437820191505092505050604051809103902061035181610d93565b1561040e57600160a060020a03831660009081526101026020526040902054915081151561037e5761040e565b60016001540360005411156103925761040e565b6000600283610100811015610000570160005b5055600160a060020a038316600090815261010260205260408120556103c9610f32565b6103d1611002565b60408051600160a060020a038516815290517f58619076adf5bb0943d100ef88d52d7c3fd691b19d3a9071b555b651fbf418da9181900360200190a15b5b5b505050565b600160a060020a03811660009081526101026020526040812054115b919050565b60015481565b6101075481565b60003660405180838380828437820191505092505050604051809103902061046a81610d93565b15610476576000610106555b5b5b50565b6101065481565b6000366040518083838082843782019150509250505060405180910390206104a981610d93565b1561056b576104b782610415565b156104c15761056b565b6104c9610f32565b60015460fa90106104dc576104dc611002565b5b60015460fa90106104ed5761056b565b60018054810190819055600160a060020a03831690600290610100811015610000570160005b5055600154600160a060020a03831660008181526101026020908152604091829020939093558051918252517f994a936646fe87ffe4f1e469d3d6aa417d6b855598397f323de5b449f765f0c3929181900390910190a15b5b5b5050565b60005481565b60008161058381610d93565b156107da5760008381526101086020526040902054600160a060020a0316156107da5760008381526101086020526040908190208054600180830154935160029384018054600160a060020a0390941695949093919283928592918116156101000260001901160480156106385780601f1061060d57610100808354040283529160200191610638565b820191906000526020600020905b81548152906001019060200180831161061b57829003601f168201915b505091505060006040518083038185876185025a03f15050506000848152610108602090815260409182902060018082015482548551600160a060020a033381811683529682018c905296810183905295166060860181905260a06080870181815260029586018054958616156101000260001901909516959095049087018190527fe7c957c06e9a662c1a6c77366179f5b702b97651dc28eee7d5bf1dff6e40bb4a975094958a95929491939290919060c08301908490801561073d5780601f106107125761010080835404028352916020019161073d565b820191906000526020600020905b81548152906001019060200180831161072057829003601f168201915b5050965050505050505060405180910390a16000838152610108602052604081208054600160a060020a0319168155600180820183905560028083018054858255939493909281161561010002600019011604601f81901061079f57506107d1565b601f0160209004906000526020600020908101906107d191905b808211156107cd57600081556001016107b9565b5090565b5b505050600191505b5b5b5b50919050565b60003660405180838380828437820191505092505050604051809103902061080a81610d93565b1561056b576101058290555b5b5b5050565b600061082733610415565b15610aa85761083584611131565b156108f3577f92ca3a80853e6663fa31fa10b99225f18d4902939b4c53a9caae9043f6efd00433858786866040518086600160a060020a0316815260200185815260200184600160a060020a0316815260200180602001828103825284848281815260200192508082843760405192018290039850909650505050505050a184600160a060020a03168484846040518083838082843782019150509250505060006040518083038185876185025a03f15060009350610aa892505050565b6000364360405180848480828437820191505082815260200193505050506040518091039020905061092481610577565b158015610947575060008181526101086020526040902054600160a060020a0316155b15610aa857600081815261010860209081526040822080546c01000000000000000000000000808a0204600160a060020a0319909116178155600180820188905560029182018054818652948490209094601f928116156101000260001901169290920481019290920481019185919087908390106109d15782800160ff198235161785556109fe565b828001600101855582156109fe579182015b828111156109fe5782358255916020019190600101906109e3565b5b50610a1f9291505b808211156107cd57600081556001016107b9565b5090565b50507f1733cbb53659d713b79580f79f3f9ff215f78a7c7aa45890f3b89fc5cddfbf32813386888787604051808760001916815260200186600160a060020a0316815260200185815260200184600160a060020a031681526020018060200182810382528484828181526020019250808284376040519201829003995090975050505050505050a15b5b5b5b949350505050565b600160a060020a033316600090815261010260205260408120549080821515610adb57610b57565b50506000828152610103602052604081206001810154600284900a929083161115610b575780546001908101825581018054839003905560408051600160a060020a03331681526020810186905281517fc7fb647e59b18047309aa15aad418e5d7ca96d173ad704f1031a2c3d7591734b929181900390910190a15b5b50505050565b600036604051808383808284378201915050925050506040518091039020610b8581610d93565b1561056b57600154821115610b995761056b565b6000829055610ba6610f32565b6040805183815290517facbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da9181900360200190a15b5b5b5050565b600082815261010360209081526040808320600160a060020a038516845261010290925282205482811515610c185760009350610c2c565b8160020a9050808360010154166000141593505b50505092915050565b6000600282600101610100811015610000570160005b505490505b919050565b600036604051808383808284378201915050925050506040518091039020610c7c81610d93565b1561056b5781600160a060020a0316ff5b5b5b5050565b6000600036604051808383808284378201915050925050506040518091039020610cbc81610d93565b15610b5757610cca83610415565b15610cd457610b57565b600160a060020a038416600090815261010260205260409020549150811515610cfc57610b57565b610d04610f32565b82600160a060020a0316600283610100811015610000570160005b5055600160a060020a0380851660008181526101026020908152604080832083905593871680835291849020869055835192835282015281517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c929181900390910190a15b5b5b50505050565b6101055481565b600160a060020a033316600090815261010260205260408120548180821515610dbb57610f28565b60008581526101036020526040902080549092501515610e4f576000805483556001808401919091556101048054918201808255828015829011610e2457600083815260209020610e249181019083015b808211156107cd57600081556001016107b9565b5090565b5b50505060028301819055610104805487929081101561000057906000526020600020900160005b50555b8260020a90508082600101541660001415610f285760408051600160a060020a03331681526020810187905281517fe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda929181900390910190a1815460019011610f155760008581526101036020526040902060020154610104805490919081101561000057906000526020600020900160005b506000908190558581526101036020526040812081815560018082018390556002909101919091559350610f2856610f28565b8154600019018255600182018054821790555b5b5b505050919050565b6101045460005b81811015610ff557610108600061010483815481101561000057906000526020600020900160005b50548152602081019190915260400160009081208054600160a060020a0319168155600180820183905560028083018054858255939493909281161561010002600019011604601f819010610fb65750610fe8565b601f016020900490600052602060002090810190610fe891905b808211156107cd57600081556001016107b9565b5090565b5b5050505b600101610f39565b61056b6111a4565b5b5050565b60015b600154811015610476575b600154811080156110325750600281610100811015610000570160005b505415155b1561103f57600101611010565b5b600160015411801561106457506002600154610100811015610000570160005b5054155b156110785760018054600019019055611040565b6001548110801561109c57506002600154610100811015610000570160005b505415155b80156110b85750600281610100811015610000570160005b5054155b15611128576002600154610100811015610000570160005b5054600282610100811015610000570160005b5055806101026000600283610100811015610000570160005b505481526020019081526020016000208190555060006002600154610100811015610000570160005b50555b611005565b5b50565b600061113c33610415565b15610431576101075461114d611278565b111561116657600061010655611161611278565b610107555b610106548281011080159061118357506101055482610106540111155b1561119957506101068054820190556001610431565b5060005b5b5b919050565b6101045460005b818110156112215761010481815481101561000057906000526020600020900160005b50541561121857610103600061010483815481101561000057906000526020600020900160005b505481526020810191909152604001600090812081815560018101829055600201555b5b6001016111ab565b610104805460008083559190915261040e907f4c0be60200faa20559308cb7b5a1bb3255c16cb1cab91f525b5ae7a03d02fabe908101905b808211156107cd57600081556001016107b9565b5090565b5b505b5050565b6201518042045b9056';
-
+export const wallet = '0x6060604052346100005760405161041b38038061041b83398101604090815281516020830151918301519201915b604080517f696e697457616c6c657428616464726573735b5d2c75696e743235362c75696e81527f7432353629000000000000000000000000000000000000000000000000000000602080830191909152915190819003602501902084516000829052909173__WalletLibrary_________________________91600281019160049182010290819038829003903960006000600483016000866127105a03f45b505050505050505b610337806100e46000396000f36060604052361561006c5760e060020a60003504632f54bf6e81146101245780634123cb6b146101485780635237509314610167578063659010e714610186578063746c9171146101a5578063c2cf7326146101c4578063c41a360a146101eb578063f1736d8614610217575b6101225b60003411156100c15760408051600160a060020a033316815234602082015281517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c929181900390910190a161011e565b600036111561011e5773__WalletLibrary_________________________600160a060020a0316600036600060405160200152604051808383808284378201915050925050506020604051808303818560325a03f4156100005750505b5b5b565b005b3461000057610134600435610236565b604080519115158252519081900360200190f35b3461000057610155610297565b60408051918252519081900360200190f35b346100005761015561029d565b60408051918252519081900360200190f35b34610000576101556102a3565b60408051918252519081900360200190f35b34610000576101556102a9565b60408051918252519081900360200190f35b34610000576101346004356024356102af565b604080519115158252519081900360200190f35b34610000576101fb600435610311565b60408051600160a060020a039092168252519081900360200190f35b3461000057610155610331565b60408051918252519081900360200190f35b600073__WalletLibrary_________________________600160a060020a0316600036600060405160200152604051808383808284378201915050925050506020604051808303818560325a03f4156100005750506040515190505b919050565b60015481565b60045481565b60035481565b60005481565b600073__WalletLibrary_________________________600160a060020a0316600036600060405160200152604051808383808284378201915050925050506020604051808303818560325a03f4156100005750506040515190505b92915050565b6000600582600101610100811015610000570160005b505490505b919050565b6002548156';
+export const walletLibrary = '0x606060405234610000575b611381806100186000396000f3606060405236156100da5760e060020a6000350463173825d981146100df5780632f54bf6e146100f157806352375093146101155780635c52c2f514610134578063659010e7146101435780637065cb4814610162578063797af627146101745780639da5e0eb14610198578063b20d30a9146101aa578063b61d27f6146101bc578063b75c7dc614610227578063ba51a6df14610239578063c2cf73261461024b578063c57c5f6014610272578063cbf0b0c0146102c6578063e46dcfeb146102d8578063f00d4b5d14610331578063f1736d8614610346575b610000565b34610000576100ef600435610365565b005b3461000057610101600435610452565b604080519115158252519081900360200190f35b3461000057610122610473565b60408051918252519081900360200190f35b34610000576100ef610479565b005b34610000576101226104b0565b60408051918252519081900360200190f35b34610000576100ef6004356104b6565b005b34610000576101016004356105a5565b604080519115158252519081900360200190f35b34610000576100ef60043561081e565b005b34610000576100ef600435610832565b005b3461000057604080516020600460443581810135601f810184900484028501840190955284845261010194823594602480359560649492939190920191819084018382808284375094965061086a95505050505050565b604080519115158252519081900360200190f35b34610000576100ef600435610bcc565b005b34610000576100ef600435610c77565b005b3461000057610101600435602435610cf9565b604080519115158252519081900360200190f35b34610000576100ef6004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496505093359350610d4e92505050565b005b34610000576100ef600435610e13565b005b34610000576100ef60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610e5192505050565b005b34610000576100ef600435602435610e6a565b005b3461000057610122610f63565b60408051918252519081900360200190f35b600060003660405180838380828437820191505092505050604051809103902061038e81610f69565b1561044b57600160a060020a0383166000908152610105602052604090205491508115156103bb5761044b565b60016001540360005411156103cf5761044b565b6000600583610100811015610000570160005b5055600160a060020a03831660009081526101056020526040812055610406611108565b61040e6111dc565b60408051600160a060020a038516815290517f58619076adf5bb0943d100ef88d52d7c3fd691b19d3a9071b555b651fbf418da9181900360200190a15b5b5b505050565b600160a060020a03811660009081526101056020526040812054115b919050565b60045481565b6000366040518083838082843782019150509250505060405180910390206104a081610f69565b156104ab5760006003555b5b5b50565b60035481565b6000366040518083838082843782019150509250505060405180910390206104dd81610f69565b1561059f576104eb82610452565b156104f55761059f565b6104fd611108565b60015460fa9010610510576105106111dc565b5b60015460fa90106105215761059f565b60018054810190819055600160a060020a03831690600590610100811015610000570160005b5055600154600160a060020a03831660008181526101056020908152604091829020939093558051918252517f994a936646fe87ffe4f1e469d3d6aa417d6b855598397f323de5b449f765f0c3929181900390910190a15b5b5b5050565b6000816105b181610f69565b156108155760008381526101086020526040902054600160a060020a0316156108155760008381526101086020526040908190208054600180830154935160029384018054600160a060020a0390941695949093919283928592918116156101000260001901160480156106665780601f1061063b57610100808354040283529160200191610666565b820191906000526020600020905b81548152906001019060200180831161064957829003601f168201915b505091505060006040518083038185876185025a03f15050506000848152610108602090815260409182902060018082015482548551600160a060020a033381811683529682018c905296810183905295166060860181905260a06080870181815260029586018054958616156101000260001901909516959095049087018190527fe7c957c06e9a662c1a6c77366179f5b702b97651dc28eee7d5bf1dff6e40bb4a975094958a95929491939290919060c08301908490801561076b5780601f106107405761010080835404028352916020019161076b565b820191906000526020600020905b81548152906001019060200180831161074e57829003601f168201915b5050965050505050505060405180910390a1600083815261010860205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600180820183905560028083018054858255939493909281161561010002600019011604601f8190106107da575061080c565b601f01602090049060005260206000209081019061080c91905b8082111561080857600081556001016107f4565b5090565b5b505050600191505b5b5b5b50919050565b600281905561082b61130b565b6004555b50565b60003660405180838380828437820191505092505050604051809103902061085981610f69565b1561059f5760028290555b5b5b5050565b6000600061087733610452565b15610bc05761088584611315565b156109bc577f92ca3a80853e6663fa31fa10b99225f18d4902939b4c53a9caae9043f6efd004338587866040518085600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156109335780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a184600160a060020a03168484604051808280519060200190808383829060006004602084601f0104600302600f01f150905090810190601f16801561099c5780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876185025a03f1925050509150610bc0565b600036436040518084848082843782019150508281526020019350505050604051809103902090506109ed816105a5565b158015610a10575060008181526101086020526040902054600160a060020a0316155b15610bc057600081815261010860209081526040822080546c01000000000000000000000000808a020473ffffffffffffffffffffffffffffffffffffffff199091161781556001808201889055865160029283018054818752958590209095601f9381161561010002600019011693909304820184900483019390929190880190839010610aaa57805160ff1916838001178555610ad7565b82800160010185558215610ad7579182015b82811115610ad7578251825591602001919060010190610abc565b5b50610af89291505b8082111561080857600081556001016107f4565b5090565b50507f1733cbb53659d713b79580f79f3f9ff215f78a7c7aa45890f3b89fc5cddfbf328133868887604051808660001916815260200185600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f168015610bae5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a15b5b5b5b5b509392505050565b600160a060020a033316600090815261010560205260408120549080821515610bf457610c70565b50506000828152610106602052604081206001810154600284900a929083161115610c705780546001908101825581018054839003905560408051600160a060020a03331681526020810186905281517fc7fb647e59b18047309aa15aad418e5d7ca96d173ad704f1031a2c3d7591734b929181900390910190a15b5b50505050565b600036604051808383808284378201915050925050506040518091039020610c9e81610f69565b1561059f57600154821115610cb25761059f565b6000829055610cbf611108565b6040805183815290517facbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da9181900360200190a15b5b5b5050565b600082815261010660209081526040808320600160a060020a038516845261010590925282205482811515610d315760009350610d45565b8160020a9050808360010154166000141593505b50505092915050565b815160019081019055600033600160a060020a03166006825b505550600160a060020a033316600090815261010560205260408120600190558181555b825181101561044b57828181518110156100005790602001906020020151600160a060020a0316600582600201610100811015610000570160005b5081905550806002016101056000858481518110156100005790602001906020020151600160a060020a03168152602001908152602001600020819055505b600101610d8b565b5b505050565b600036604051808383808284378201915050925050506040518091039020610e3a81610f69565b1561059f5781600160a060020a0316ff5b5b5b5050565b610e5b8383610d4e565b61044b8161081e565b5b505050565b6000600036604051808383808284378201915050925050506040518091039020610e9381610f69565b15610c7057610ea183610452565b15610eab57610c70565b600160a060020a038416600090815261010560205260409020549150811515610ed357610c70565b610edb611108565b82600160a060020a0316600583610100811015610000570160005b5055600160a060020a0380851660008181526101056020908152604080832083905593871680835291849020869055835192835282015281517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c929181900390910190a15b5b5b50505050565b60025481565b600160a060020a033316600090815261010560205260408120548180821515610f91576110fe565b60008581526101066020526040902080549092501515611025576000805483556001808401919091556101078054918201808255828015829011610ffa57600083815260209020610ffa9181019083015b8082111561080857600081556001016107f4565b5090565b5b50505060028301819055610107805487929081101561000057906000526020600020900160005b50555b8260020a905080826001015416600014156110fe5760408051600160a060020a03331681526020810187905281517fe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda929181900390910190a18154600190116110eb5760008581526101066020526040902060020154610107805490919081101561000057906000526020600020900160005b5060009081905585815261010660205260408120818155600180820183905560029091019190915593506110fe566110fe565b8154600019018255600182018054821790555b5b5b505050919050565b6101075460005b818110156111855761010781815481101561000057906000526020600020900160005b50541561117c57610106600061010783815481101561000057906000526020600020900160005b505481526020810191909152604001600090812081815560018101829055600201555b5b60010161110f565b610107805460008083559190915261044b907f47c4908e245f386bfc1825973249847f4053a761ddb4880ad63c323a7b5a2a25908101905b8082111561080857600081556001016107f4565b5090565b5b505b5050565b60015b6001548110156104ab575b6001548110801561120c5750600581610100811015610000570160005b505415155b15611219576001016111ea565b5b600160015411801561123e57506005600154610100811015610000570160005b5054155b15611252576001805460001901905561121a565b6001548110801561127657506005600154610100811015610000570160005b505415155b80156112925750600581610100811015610000570160005b5054155b15611302576005600154610100811015610000570160005b5054600582610100811015610000570160005b5055806101056000600583610100811015610000570160005b505481526020019081526020016000208190555060006005600154610100811015610000570160005b50555b6111df565b5b50565b6201518042045b90565b600061132033610452565b1561046e5760045461133061130b565b111561134757600060035561134361130b565b6004555b600354828101108015906113615750600254826003540111155b1561137657506003805482019055600161046e565b5060005b5b5b91905056';
+export const walletSourceURL = 'https://github.com/ethcore/parity/blob/63137b15482344ff9df634c086abaabed452eadc/js/src/contracts/snippets/enhanced-wallet.sol';
+export const walletLibraryRegKey = 'walletLibrary';
diff --git a/js/src/modals/CreateWallet/WalletType/walletType.js b/js/src/modals/CreateWallet/WalletType/walletType.js
index 868c6ad9b..93dd818f1 100644
--- a/js/src/modals/CreateWallet/WalletType/walletType.js
+++ b/js/src/modals/CreateWallet/WalletType/walletType.js
@@ -17,6 +17,7 @@
import React, { Component, PropTypes } from 'react';
import { RadioButtons } from '~/ui';
+import { walletSourceURL } from '~/contracts/code/wallet';
// import styles from '../createWallet.css';
@@ -46,7 +47,9 @@ export default class WalletType extends Component {
description: (
Create/Deploy a
- standard multi-signature
+
+ standard multi-signature
+ Wallet
)
diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js
index d8c308a12..e6edab56b 100644
--- a/js/src/modals/CreateWallet/createWalletStore.js
+++ b/js/src/modals/CreateWallet/createWalletStore.js
@@ -20,8 +20,10 @@ import { validateUint, validateAddress, validateName } from '~/util/validation';
import { ERROR_CODES } from '~/api/transport/error';
import Contract from '~/api/contract';
+import Contracts from '~/contracts';
import { wallet as walletAbi } from '~/contracts/abi';
import { wallet as walletCode } from '~/contracts/code';
+import { walletLibraryRegKey } from '~/contracts/code/wallet';
import WalletsUtils from '~/util/wallets';
@@ -160,14 +162,23 @@ export default class CreateWalletStore {
const { account, owners, required, daylimit } = this.wallet;
- const options = {
- data: walletCode,
- from: account
- };
+ Contracts
+ .get()
+ .registry
+ .lookupAddress(walletLibraryRegKey)
+ .then((address) => {
+ const walletLibraryAddress = address.replace(/^0x/, '').toLowerCase();
+ const code = walletCode.replace(/(_)+WalletLibrary(_)+/g, walletLibraryAddress);
- this.api
- .newContract(walletAbi)
- .deploy(options, [ owners, required, daylimit ], this.onDeploymentState)
+ const options = {
+ data: code,
+ from: account
+ };
+
+ return this.api
+ .newContract(walletAbi)
+ .deploy(options, [ owners, required, daylimit ], this.onDeploymentState);
+ })
.then((address) => {
this.deployed = true;
this.wallet.address = address;
From caf3a96c1999a4342c87435844f7349cdb5b0480 Mon Sep 17 00:00:00 2001
From: Nicolas Gotchac
Date: Fri, 9 Dec 2016 16:29:57 +0100
Subject: [PATCH 47/56] Add fallback Full Fleshed Wallet if no library
---
js/src/contracts/code/wallet.js | 4 ++++
js/src/modals/CreateWallet/createWalletStore.js | 8 +++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/js/src/contracts/code/wallet.js b/js/src/contracts/code/wallet.js
index 35ed3b106..92bcf8795 100644
--- a/js/src/contracts/code/wallet.js
+++ b/js/src/contracts/code/wallet.js
@@ -23,3 +23,7 @@ export const wallet = '0x6060604052346100005760405161041b38038061041b83398101604
export const walletLibrary = '0x606060405234610000575b611381806100186000396000f3606060405236156100da5760e060020a6000350463173825d981146100df5780632f54bf6e146100f157806352375093146101155780635c52c2f514610134578063659010e7146101435780637065cb4814610162578063797af627146101745780639da5e0eb14610198578063b20d30a9146101aa578063b61d27f6146101bc578063b75c7dc614610227578063ba51a6df14610239578063c2cf73261461024b578063c57c5f6014610272578063cbf0b0c0146102c6578063e46dcfeb146102d8578063f00d4b5d14610331578063f1736d8614610346575b610000565b34610000576100ef600435610365565b005b3461000057610101600435610452565b604080519115158252519081900360200190f35b3461000057610122610473565b60408051918252519081900360200190f35b34610000576100ef610479565b005b34610000576101226104b0565b60408051918252519081900360200190f35b34610000576100ef6004356104b6565b005b34610000576101016004356105a5565b604080519115158252519081900360200190f35b34610000576100ef60043561081e565b005b34610000576100ef600435610832565b005b3461000057604080516020600460443581810135601f810184900484028501840190955284845261010194823594602480359560649492939190920191819084018382808284375094965061086a95505050505050565b604080519115158252519081900360200190f35b34610000576100ef600435610bcc565b005b34610000576100ef600435610c77565b005b3461000057610101600435602435610cf9565b604080519115158252519081900360200190f35b34610000576100ef6004808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437509496505093359350610d4e92505050565b005b34610000576100ef600435610e13565b005b34610000576100ef60048080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284375094965050843594602001359350610e5192505050565b005b34610000576100ef600435602435610e6a565b005b3461000057610122610f63565b60408051918252519081900360200190f35b600060003660405180838380828437820191505092505050604051809103902061038e81610f69565b1561044b57600160a060020a0383166000908152610105602052604090205491508115156103bb5761044b565b60016001540360005411156103cf5761044b565b6000600583610100811015610000570160005b5055600160a060020a03831660009081526101056020526040812055610406611108565b61040e6111dc565b60408051600160a060020a038516815290517f58619076adf5bb0943d100ef88d52d7c3fd691b19d3a9071b555b651fbf418da9181900360200190a15b5b5b505050565b600160a060020a03811660009081526101056020526040812054115b919050565b60045481565b6000366040518083838082843782019150509250505060405180910390206104a081610f69565b156104ab5760006003555b5b5b50565b60035481565b6000366040518083838082843782019150509250505060405180910390206104dd81610f69565b1561059f576104eb82610452565b156104f55761059f565b6104fd611108565b60015460fa9010610510576105106111dc565b5b60015460fa90106105215761059f565b60018054810190819055600160a060020a03831690600590610100811015610000570160005b5055600154600160a060020a03831660008181526101056020908152604091829020939093558051918252517f994a936646fe87ffe4f1e469d3d6aa417d6b855598397f323de5b449f765f0c3929181900390910190a15b5b5b5050565b6000816105b181610f69565b156108155760008381526101086020526040902054600160a060020a0316156108155760008381526101086020526040908190208054600180830154935160029384018054600160a060020a0390941695949093919283928592918116156101000260001901160480156106665780601f1061063b57610100808354040283529160200191610666565b820191906000526020600020905b81548152906001019060200180831161064957829003601f168201915b505091505060006040518083038185876185025a03f15050506000848152610108602090815260409182902060018082015482548551600160a060020a033381811683529682018c905296810183905295166060860181905260a06080870181815260029586018054958616156101000260001901909516959095049087018190527fe7c957c06e9a662c1a6c77366179f5b702b97651dc28eee7d5bf1dff6e40bb4a975094958a95929491939290919060c08301908490801561076b5780601f106107405761010080835404028352916020019161076b565b820191906000526020600020905b81548152906001019060200180831161074e57829003601f168201915b5050965050505050505060405180910390a1600083815261010860205260408120805473ffffffffffffffffffffffffffffffffffffffff19168155600180820183905560028083018054858255939493909281161561010002600019011604601f8190106107da575061080c565b601f01602090049060005260206000209081019061080c91905b8082111561080857600081556001016107f4565b5090565b5b505050600191505b5b5b5b50919050565b600281905561082b61130b565b6004555b50565b60003660405180838380828437820191505092505050604051809103902061085981610f69565b1561059f5760028290555b5b5b5050565b6000600061087733610452565b15610bc05761088584611315565b156109bc577f92ca3a80853e6663fa31fa10b99225f18d4902939b4c53a9caae9043f6efd004338587866040518085600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156109335780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a184600160a060020a03168484604051808280519060200190808383829060006004602084601f0104600302600f01f150905090810190601f16801561099c5780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876185025a03f1925050509150610bc0565b600036436040518084848082843782019150508281526020019350505050604051809103902090506109ed816105a5565b158015610a10575060008181526101086020526040902054600160a060020a0316155b15610bc057600081815261010860209081526040822080546c01000000000000000000000000808a020473ffffffffffffffffffffffffffffffffffffffff199091161781556001808201889055865160029283018054818752958590209095601f9381161561010002600019011693909304820184900483019390929190880190839010610aaa57805160ff1916838001178555610ad7565b82800160010185558215610ad7579182015b82811115610ad7578251825591602001919060010190610abc565b5b50610af89291505b8082111561080857600081556001016107f4565b5090565b50507f1733cbb53659d713b79580f79f3f9ff215f78a7c7aa45890f3b89fc5cddfbf328133868887604051808660001916815260200185600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f168015610bae5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a15b5b5b5b5b509392505050565b600160a060020a033316600090815261010560205260408120549080821515610bf457610c70565b50506000828152610106602052604081206001810154600284900a929083161115610c705780546001908101825581018054839003905560408051600160a060020a03331681526020810186905281517fc7fb647e59b18047309aa15aad418e5d7ca96d173ad704f1031a2c3d7591734b929181900390910190a15b5b50505050565b600036604051808383808284378201915050925050506040518091039020610c9e81610f69565b1561059f57600154821115610cb25761059f565b6000829055610cbf611108565b6040805183815290517facbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da9181900360200190a15b5b5b5050565b600082815261010660209081526040808320600160a060020a038516845261010590925282205482811515610d315760009350610d45565b8160020a9050808360010154166000141593505b50505092915050565b815160019081019055600033600160a060020a03166006825b505550600160a060020a033316600090815261010560205260408120600190558181555b825181101561044b57828181518110156100005790602001906020020151600160a060020a0316600582600201610100811015610000570160005b5081905550806002016101056000858481518110156100005790602001906020020151600160a060020a03168152602001908152602001600020819055505b600101610d8b565b5b505050565b600036604051808383808284378201915050925050506040518091039020610e3a81610f69565b1561059f5781600160a060020a0316ff5b5b5b5050565b610e5b8383610d4e565b61044b8161081e565b5b505050565b6000600036604051808383808284378201915050925050506040518091039020610e9381610f69565b15610c7057610ea183610452565b15610eab57610c70565b600160a060020a038416600090815261010560205260409020549150811515610ed357610c70565b610edb611108565b82600160a060020a0316600583610100811015610000570160005b5055600160a060020a0380851660008181526101056020908152604080832083905593871680835291849020869055835192835282015281517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c929181900390910190a15b5b5b50505050565b60025481565b600160a060020a033316600090815261010560205260408120548180821515610f91576110fe565b60008581526101066020526040902080549092501515611025576000805483556001808401919091556101078054918201808255828015829011610ffa57600083815260209020610ffa9181019083015b8082111561080857600081556001016107f4565b5090565b5b50505060028301819055610107805487929081101561000057906000526020600020900160005b50555b8260020a905080826001015416600014156110fe5760408051600160a060020a03331681526020810187905281517fe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda929181900390910190a18154600190116110eb5760008581526101066020526040902060020154610107805490919081101561000057906000526020600020900160005b5060009081905585815261010660205260408120818155600180820183905560029091019190915593506110fe566110fe565b8154600019018255600182018054821790555b5b5b505050919050565b6101075460005b818110156111855761010781815481101561000057906000526020600020900160005b50541561117c57610106600061010783815481101561000057906000526020600020900160005b505481526020810191909152604001600090812081815560018101829055600201555b5b60010161110f565b610107805460008083559190915261044b907f47c4908e245f386bfc1825973249847f4053a761ddb4880ad63c323a7b5a2a25908101905b8082111561080857600081556001016107f4565b5090565b5b505b5050565b60015b6001548110156104ab575b6001548110801561120c5750600581610100811015610000570160005b505415155b15611219576001016111ea565b5b600160015411801561123e57506005600154610100811015610000570160005b5054155b15611252576001805460001901905561121a565b6001548110801561127657506005600154610100811015610000570160005b505415155b80156112925750600581610100811015610000570160005b5054155b15611302576005600154610100811015610000570160005b5054600582610100811015610000570160005b5055806101056000600583610100811015610000570160005b505481526020019081526020016000208190555060006005600154610100811015610000570160005b50555b6111df565b5b50565b6201518042045b90565b600061132033610452565b1561046e5760045461133061130b565b111561134757600060035561134361130b565b6004555b600354828101108015906113615750600254826003540111155b1561137657506003805482019055600161046e565b5060005b5b5b91905056';
export const walletSourceURL = 'https://github.com/ethcore/parity/blob/63137b15482344ff9df634c086abaabed452eadc/js/src/contracts/snippets/enhanced-wallet.sol';
export const walletLibraryRegKey = 'walletLibrary';
+
+// Used if no Wallet Library found in registry...
+// Compiled from `wallet.sol` using Solidity v0.4.6
+export const fullWalletCode = '0x606060405234610000576040516113bb3803806113bb83398101604090815281516020830151918301519201915b805b83835b815160019081019055600033600160a060020a03166003825b505550600160a060020a033316600090815261010260205260408120600190555b82518110156100ee57828181518110156100005790602001906020020151600160a060020a0316600282600201610100811015610000570160005b5081905550806002016101026000858481518110156100005790602001906020020151600160a060020a03168152602001908152602001600020819055505b60010161006c565b60008290555b50505061010581905561011264010000000061127861012182021704565b610107555b505b50505061012b565b6201518042045b90565b611282806101396000396000f3606060405236156100da5760e060020a6000350463173825d981146101305780632f54bf6e146101425780634123cb6b1461016657806352375093146101855780635c52c2f5146101a4578063659010e7146101b35780637065cb48146101d2578063746c9171146101e4578063797af62714610203578063b20d30a914610227578063b61d27f614610239578063b75c7dc61461026b578063ba51a6df1461027d578063c2cf73261461028f578063c41a360a146102b6578063cbf0b0c0146102e2578063f00d4b5d146102f4578063f1736d8614610309575b61012e5b600034111561012b5760408051600160a060020a033316815234602082015281517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c929181900390910190a15b5b565b005b346100005761012e600435610328565b005b3461000057610152600435610415565b604080519115158252519081900360200190f35b3461000057610173610436565b60408051918252519081900360200190f35b346100005761017361043c565b60408051918252519081900360200190f35b346100005761012e610443565b005b346100005761017361047b565b60408051918252519081900360200190f35b346100005761012e600435610482565b005b3461000057610173610571565b60408051918252519081900360200190f35b3461000057610152600435610577565b604080519115158252519081900360200190f35b346100005761012e6004356107e3565b005b34610000576101736004803590602480359160443591820191013561081c565b60408051918252519081900360200190f35b346100005761012e600435610ab3565b005b346100005761012e600435610b5e565b005b3461000057610152600435602435610be0565b604080519115158252519081900360200190f35b34610000576102c6600435610c35565b60408051600160a060020a039092168252519081900360200190f35b346100005761012e600435610c55565b005b346100005761012e600435602435610c93565b005b3461000057610173610d8c565b60408051918252519081900360200190f35b600060003660405180838380828437820191505092505050604051809103902061035181610d93565b1561040e57600160a060020a03831660009081526101026020526040902054915081151561037e5761040e565b60016001540360005411156103925761040e565b6000600283610100811015610000570160005b5055600160a060020a038316600090815261010260205260408120556103c9610f32565b6103d1611002565b60408051600160a060020a038516815290517f58619076adf5bb0943d100ef88d52d7c3fd691b19d3a9071b555b651fbf418da9181900360200190a15b5b5b505050565b600160a060020a03811660009081526101026020526040812054115b919050565b60015481565b6101075481565b60003660405180838380828437820191505092505050604051809103902061046a81610d93565b15610476576000610106555b5b5b50565b6101065481565b6000366040518083838082843782019150509250505060405180910390206104a981610d93565b1561056b576104b782610415565b156104c15761056b565b6104c9610f32565b60015460fa90106104dc576104dc611002565b5b60015460fa90106104ed5761056b565b60018054810190819055600160a060020a03831690600290610100811015610000570160005b5055600154600160a060020a03831660008181526101026020908152604091829020939093558051918252517f994a936646fe87ffe4f1e469d3d6aa417d6b855598397f323de5b449f765f0c3929181900390910190a15b5b5b5050565b60005481565b60008161058381610d93565b156107da5760008381526101086020526040902054600160a060020a0316156107da5760008381526101086020526040908190208054600180830154935160029384018054600160a060020a0390941695949093919283928592918116156101000260001901160480156106385780601f1061060d57610100808354040283529160200191610638565b820191906000526020600020905b81548152906001019060200180831161061b57829003601f168201915b505091505060006040518083038185876185025a03f15050506000848152610108602090815260409182902060018082015482548551600160a060020a033381811683529682018c905296810183905295166060860181905260a06080870181815260029586018054958616156101000260001901909516959095049087018190527fe7c957c06e9a662c1a6c77366179f5b702b97651dc28eee7d5bf1dff6e40bb4a975094958a95929491939290919060c08301908490801561073d5780601f106107125761010080835404028352916020019161073d565b820191906000526020600020905b81548152906001019060200180831161072057829003601f168201915b5050965050505050505060405180910390a16000838152610108602052604081208054600160a060020a0319168155600180820183905560028083018054858255939493909281161561010002600019011604601f81901061079f57506107d1565b601f0160209004906000526020600020908101906107d191905b808211156107cd57600081556001016107b9565b5090565b5b505050600191505b5b5b5b50919050565b60003660405180838380828437820191505092505050604051809103902061080a81610d93565b1561056b576101058290555b5b5b5050565b600061082733610415565b15610aa85761083584611131565b156108f3577f92ca3a80853e6663fa31fa10b99225f18d4902939b4c53a9caae9043f6efd00433858786866040518086600160a060020a0316815260200185815260200184600160a060020a0316815260200180602001828103825284848281815260200192508082843760405192018290039850909650505050505050a184600160a060020a03168484846040518083838082843782019150509250505060006040518083038185876185025a03f15060009350610aa892505050565b6000364360405180848480828437820191505082815260200193505050506040518091039020905061092481610577565b158015610947575060008181526101086020526040902054600160a060020a0316155b15610aa857600081815261010860209081526040822080546c01000000000000000000000000808a0204600160a060020a0319909116178155600180820188905560029182018054818652948490209094601f928116156101000260001901169290920481019290920481019185919087908390106109d15782800160ff198235161785556109fe565b828001600101855582156109fe579182015b828111156109fe5782358255916020019190600101906109e3565b5b50610a1f9291505b808211156107cd57600081556001016107b9565b5090565b50507f1733cbb53659d713b79580f79f3f9ff215f78a7c7aa45890f3b89fc5cddfbf32813386888787604051808760001916815260200186600160a060020a0316815260200185815260200184600160a060020a031681526020018060200182810382528484828181526020019250808284376040519201829003995090975050505050505050a15b5b5b5b949350505050565b600160a060020a033316600090815261010260205260408120549080821515610adb57610b57565b50506000828152610103602052604081206001810154600284900a929083161115610b575780546001908101825581018054839003905560408051600160a060020a03331681526020810186905281517fc7fb647e59b18047309aa15aad418e5d7ca96d173ad704f1031a2c3d7591734b929181900390910190a15b5b50505050565b600036604051808383808284378201915050925050506040518091039020610b8581610d93565b1561056b57600154821115610b995761056b565b6000829055610ba6610f32565b6040805183815290517facbdb084c721332ac59f9b8e392196c9eb0e4932862da8eb9beaf0dad4f550da9181900360200190a15b5b5b5050565b600082815261010360209081526040808320600160a060020a038516845261010290925282205482811515610c185760009350610c2c565b8160020a9050808360010154166000141593505b50505092915050565b6000600282600101610100811015610000570160005b505490505b919050565b600036604051808383808284378201915050925050506040518091039020610c7c81610d93565b1561056b5781600160a060020a0316ff5b5b5b5050565b6000600036604051808383808284378201915050925050506040518091039020610cbc81610d93565b15610b5757610cca83610415565b15610cd457610b57565b600160a060020a038416600090815261010260205260409020549150811515610cfc57610b57565b610d04610f32565b82600160a060020a0316600283610100811015610000570160005b5055600160a060020a0380851660008181526101026020908152604080832083905593871680835291849020869055835192835282015281517fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c929181900390910190a15b5b5b50505050565b6101055481565b600160a060020a033316600090815261010260205260408120548180821515610dbb57610f28565b60008581526101036020526040902080549092501515610e4f576000805483556001808401919091556101048054918201808255828015829011610e2457600083815260209020610e249181019083015b808211156107cd57600081556001016107b9565b5090565b5b50505060028301819055610104805487929081101561000057906000526020600020900160005b50555b8260020a90508082600101541660001415610f285760408051600160a060020a03331681526020810187905281517fe1c52dc63b719ade82e8bea94cc41a0d5d28e4aaf536adb5e9cccc9ff8c1aeda929181900390910190a1815460019011610f155760008581526101036020526040902060020154610104805490919081101561000057906000526020600020900160005b506000908190558581526101036020526040812081815560018082018390556002909101919091559350610f2856610f28565b8154600019018255600182018054821790555b5b5b505050919050565b6101045460005b81811015610ff557610108600061010483815481101561000057906000526020600020900160005b50548152602081019190915260400160009081208054600160a060020a0319168155600180820183905560028083018054858255939493909281161561010002600019011604601f819010610fb65750610fe8565b601f016020900490600052602060002090810190610fe891905b808211156107cd57600081556001016107b9565b5090565b5b5050505b600101610f39565b61056b6111a4565b5b5050565b60015b600154811015610476575b600154811080156110325750600281610100811015610000570160005b505415155b1561103f57600101611010565b5b600160015411801561106457506002600154610100811015610000570160005b5054155b156110785760018054600019019055611040565b6001548110801561109c57506002600154610100811015610000570160005b505415155b80156110b85750600281610100811015610000570160005b5054155b15611128576002600154610100811015610000570160005b5054600282610100811015610000570160005b5055806101026000600283610100811015610000570160005b505481526020019081526020016000208190555060006002600154610100811015610000570160005b50555b611005565b5b50565b600061113c33610415565b15610431576101075461114d611278565b111561116657600061010655611161611278565b610107555b610106548281011080159061118357506101055482610106540111155b1561119957506101068054820190556001610431565b5060005b5b5b919050565b6101045460005b818110156112215761010481815481101561000057906000526020600020900160005b50541561121857610103600061010483815481101561000057906000526020600020900160005b505481526020810191909152604001600090812081815560018101829055600201555b5b6001016111ab565b610104805460008083559190915261040e907f4c0be60200faa20559308cb7b5a1bb3255c16cb1cab91f525b5ae7a03d02fabe908101905b808211156107cd57600081556001016107b9565b5090565b5b505b5050565b6201518042045b9056';
diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js
index e6edab56b..7f516eb25 100644
--- a/js/src/modals/CreateWallet/createWalletStore.js
+++ b/js/src/modals/CreateWallet/createWalletStore.js
@@ -23,7 +23,7 @@ import Contract from '~/api/contract';
import Contracts from '~/contracts';
import { wallet as walletAbi } from '~/contracts/abi';
import { wallet as walletCode } from '~/contracts/code';
-import { walletLibraryRegKey } from '~/contracts/code/wallet';
+import { walletLibraryRegKey, fullWalletCode } from '~/contracts/code/wallet';
import WalletsUtils from '~/util/wallets';
@@ -167,8 +167,10 @@ export default class CreateWalletStore {
.registry
.lookupAddress(walletLibraryRegKey)
.then((address) => {
- const walletLibraryAddress = address.replace(/^0x/, '').toLowerCase();
- const code = walletCode.replace(/(_)+WalletLibrary(_)+/g, walletLibraryAddress);
+ const walletLibraryAddress = (address || '').replace(/^0x/, '').toLowerCase();
+ const code = walletLibraryAddress.length && !/^0+$/.test(walletLibraryAddress)
+ ? walletCode.replace(/(_)+WalletLibrary(_)+/g, walletLibraryAddress)
+ : fullWalletCode;
const options = {
data: code,
From ff11634e1d4e2c0dc7945719c40f7d1952d9439e Mon Sep 17 00:00:00 2001
From: Nicolas Gotchac
Date: Fri, 9 Dec 2016 16:55:43 +0100
Subject: [PATCH 48/56] PR Grumble
---
js/src/modals/CreateWallet/createWalletStore.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/js/src/modals/CreateWallet/createWalletStore.js b/js/src/modals/CreateWallet/createWalletStore.js
index 5e6e8a81a..3edf8f638 100644
--- a/js/src/modals/CreateWallet/createWalletStore.js
+++ b/js/src/modals/CreateWallet/createWalletStore.js
@@ -20,8 +20,7 @@ import Contract from '~/api/contract';
import Contracts from '~/contracts';
import { ERROR_CODES } from '~/api/transport/error';
import { wallet as walletAbi } from '~/contracts/abi';
-import { wallet as walletCode } from '~/contracts/code';
-import { walletLibraryRegKey, fullWalletCode } from '~/contracts/code/wallet';
+import { wallet as walletCode, walletLibraryRegKey, fullWalletCode } from '~/contracts/code/wallet';
import { validateUint, validateAddress, validateName } from '~/util/validation';
import WalletsUtils from '~/util/wallets';
From ffd8314a115b49c9dc7eeff582bd480fbaec0a8e Mon Sep 17 00:00:00 2001
From: Jaco Greeff
Date: Fri, 9 Dec 2016 17:52:25 +0100
Subject: [PATCH 49/56] Be lenient around invalid owners map (#3764)
* Be lenient around invalid owners map
* Filter invalid owners before render
---
js/src/views/Accounts/Summary/summary.js | 6 ++++--
js/src/views/Accounts/accounts.js | 18 +++++++++++-------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/js/src/views/Accounts/Summary/summary.js b/js/src/views/Accounts/Summary/summary.js
index 764f24edf..aeff8a2e5 100644
--- a/js/src/views/Accounts/Summary/summary.js
+++ b/js/src/views/Accounts/Summary/summary.js
@@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
+import BigNumber from 'bignumber.js';
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { isEqual } from 'lodash';
@@ -113,15 +114,16 @@ export default class Summary extends Component {
renderOwners () {
const { owners } = this.props;
+ const ownersValid = (owners || []).filter((owner) => owner.address && new BigNumber(owner.address).gt(0));
- if (!owners || owners.length === 0) {
+ if (!ownersValid || ownersValid.length === 0) {
return null;
}
return (