Merge branch 'master' into lightserv
This commit is contained in:
commit
eec1929658
@ -401,7 +401,7 @@ test-darwin:
|
||||
- git submodule update --init --recursive
|
||||
script:
|
||||
- export RUST_BACKTRACE=1
|
||||
- ./test.sh $CARGOFLAGS --no-release
|
||||
- ./test.sh $CARGOFLAGS
|
||||
tags:
|
||||
- osx
|
||||
allow_failure: true
|
||||
@ -428,7 +428,7 @@ test-rust-stable:
|
||||
script:
|
||||
- export RUST_BACKTRACE=1
|
||||
- echo $JS_FILES_MODIFIED
|
||||
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi
|
||||
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi
|
||||
tags:
|
||||
- rust
|
||||
- rust-stable
|
||||
@ -457,7 +457,7 @@ test-rust-beta:
|
||||
script:
|
||||
- export RUST_BACKTRACE=1
|
||||
- echo $JS_FILES_MODIFIED
|
||||
- ./test.sh $CARGOFLAGS --no-release
|
||||
- ./test.sh $CARGOFLAGS
|
||||
tags:
|
||||
- rust
|
||||
- rust-beta
|
||||
@ -471,7 +471,7 @@ test-rust-nightly:
|
||||
- git submodule update --init --recursive
|
||||
script:
|
||||
- export RUST_BACKTRACE=1
|
||||
- ./test.sh $CARGOFLAGS --no-release
|
||||
- ./test.sh $CARGOFLAGS
|
||||
tags:
|
||||
- rust
|
||||
- rust-nightly
|
||||
|
@ -16,7 +16,7 @@ git:
|
||||
matrix:
|
||||
include:
|
||||
- rust: stable
|
||||
env: RUN_TESTS="true" TEST_OPTIONS="--no-release"
|
||||
env: RUN_TESTS="true" TEST_OPTIONS=""
|
||||
- rust: stable
|
||||
env: RUN_COVERAGE="true"
|
||||
- rust: stable
|
||||
@ -71,8 +71,7 @@ install:
|
||||
script:
|
||||
- if [ "$RUN_TESTS" = "true" ]; then
|
||||
./js/scripts/lint.sh &&
|
||||
./js/scripts/test.sh &&
|
||||
./test.sh $TEST_OPTIONS --verbose;
|
||||
travis_wait 40 ./test.sh $TEST_OPTIONS;
|
||||
fi
|
||||
- if [ "$RUN_COVERAGE" = "true" ]; then ./scripts/cov.sh "$KCOV_CMD"; fi
|
||||
|
||||
|
94
Cargo.lock
generated
94
Cargo.lock
generated
@ -10,19 +10,19 @@ dependencies = [
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.5.0",
|
||||
"ethcore-dapps 1.5.0",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-hash-fetch 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-hypervisor 1.2.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"ethcore-ipc-tests 0.1.0",
|
||||
"ethcore-light 1.5.0",
|
||||
"ethcore-logger 1.5.0",
|
||||
"ethcore-rpc 1.5.0",
|
||||
"ethcore-signer 1.5.0",
|
||||
"ethcore-stratum 1.4.0",
|
||||
"ethcore-stratum 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"ethsync 1.5.0",
|
||||
"fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -274,7 +274,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethash"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -292,18 +292,18 @@ dependencies = [
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethash 1.4.0",
|
||||
"ethash 1.5.0",
|
||||
"ethcore-bloom-journal 0.1.0",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"ethjson 0.1.0",
|
||||
"ethkey 0.2.0",
|
||||
"ethstore 0.1.0",
|
||||
"evmjit 1.4.0",
|
||||
"evmjit 1.5.0",
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hyper 0.10.0-a.0 (git+https://github.com/ethcore/hyper)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -344,7 +344,7 @@ version = "1.5.0"
|
||||
dependencies = [
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-hash-fetch 1.5.0",
|
||||
"ethcore-rpc 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
@ -357,7 +357,7 @@ dependencies = [
|
||||
"mime 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime_guess 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-ui 1.4.0",
|
||||
"parity-ui 1.5.0",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -371,7 +371,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-devtools"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -401,9 +401,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-ipc"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -411,7 +411,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-ipc-codegen"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -424,9 +424,9 @@ dependencies = [
|
||||
name = "ethcore-ipc-hypervisor"
|
||||
version = "1.2.0"
|
||||
dependencies = [
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
"semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -435,9 +435,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-ipc-nano"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
@ -447,10 +447,10 @@ dependencies = [
|
||||
name = "ethcore-ipc-tests"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
|
||||
@ -463,8 +463,8 @@ version = "1.5.0"
|
||||
dependencies = [
|
||||
"ethcore 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-network 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -491,7 +491,7 @@ version = "1.5.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"ethcrypto 0.1.0",
|
||||
@ -515,11 +515,11 @@ name = "ethcore-rpc"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethash 1.4.0",
|
||||
"ethash 1.5.0",
|
||||
"ethcore 1.5.0",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"ethcrypto 0.1.0",
|
||||
"ethjson 0.1.0",
|
||||
@ -546,14 +546,14 @@ version = "1.5.0"
|
||||
dependencies = [
|
||||
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-rpc 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parity-ui 1.4.0",
|
||||
"parity-ui 1.5.0",
|
||||
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ws 0.5.3 (git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable)",
|
||||
@ -561,13 +561,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ethcore-stratum"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
"jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)",
|
||||
"jsonrpc-tcp-server 0.1.0 (git+https://github.com/ethcore/jsonrpc.git)",
|
||||
@ -589,7 +589,7 @@ dependencies = [
|
||||
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
|
||||
"ethcore-bigint 0.1.2",
|
||||
"ethcore-bloom-journal 0.1.0",
|
||||
"ethcore-devtools 1.4.0",
|
||||
"ethcore-devtools 1.5.0",
|
||||
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"itertools 0.4.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -677,9 +677,9 @@ dependencies = [
|
||||
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ethcore 1.5.0",
|
||||
"ethcore-io 1.5.0",
|
||||
"ethcore-ipc 1.4.0",
|
||||
"ethcore-ipc-codegen 1.4.0",
|
||||
"ethcore-ipc-nano 1.4.0",
|
||||
"ethcore-ipc 1.5.0",
|
||||
"ethcore-ipc-codegen 1.5.0",
|
||||
"ethcore-ipc-nano 1.5.0",
|
||||
"ethcore-light 1.5.0",
|
||||
"ethcore-network 1.5.0",
|
||||
"ethcore-util 1.5.0",
|
||||
@ -694,7 +694,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "evmjit"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -1271,7 +1271,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parity-ui"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
dependencies = [
|
||||
"parity-ui-dev 1.4.0",
|
||||
"parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)",
|
||||
@ -1288,7 +1288,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "parity-ui-precompiled"
|
||||
version = "1.4.0"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git#57f5bf943f24cf761ba58c1bea35a845e0b12414"
|
||||
source = "git+https://github.com/ethcore/js-precompiled.git#a59b62ecec8773715d1db7e070bbbe5443eb7378"
|
||||
dependencies = [
|
||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -89,4 +89,4 @@ name = "parity"
|
||||
[profile.release]
|
||||
debug = false
|
||||
lto = false
|
||||
|
||||
panic = "abort"
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
description = "Base Package for all Parity built-in dapps"
|
||||
name = "parity-dapps-glue"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
license = "GPL-3.0"
|
||||
authors = ["Ethcore <admin@ethcore.io"]
|
||||
build = "build.rs"
|
||||
|
@ -3,7 +3,7 @@ description = "Ethcore Parity UI"
|
||||
homepage = "http://ethcore.io"
|
||||
license = "GPL-3.0"
|
||||
name = "parity-ui"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -3,7 +3,7 @@ description = "Ethcore Database"
|
||||
homepage = "http://ethcore.io"
|
||||
license = "GPL-3.0"
|
||||
name = "ethcore-db"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
@ -3,7 +3,7 @@ description = "Ethcore development/test/build tools"
|
||||
homepage = "http://ethcore.io"
|
||||
license = "GPL-3.0"
|
||||
name = "ethcore-devtools"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Ethcore <admin@ethcore.io>"]
|
||||
|
||||
[dependencies]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ethash"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["arkpar <arkadiy@ethcore.io"]
|
||||
|
||||
[lib]
|
||||
|
@ -194,6 +194,11 @@ impl AccountProvider {
|
||||
Ok(self.address_book.write().set_meta(account, meta))
|
||||
}
|
||||
|
||||
/// Removes and address from the addressbook
|
||||
pub fn remove_address(&self, addr: Address) -> Result<(), Error> {
|
||||
Ok(self.address_book.write().remove(addr))
|
||||
}
|
||||
|
||||
/// Returns each account along with name and meta.
|
||||
pub fn accounts_info(&self) -> Result<HashMap<Address, AccountMeta>, Error> {
|
||||
let r: HashMap<Address, AccountMeta> = try!(self.sstore.accounts())
|
||||
|
@ -74,6 +74,12 @@ impl AddressBook {
|
||||
}
|
||||
self.save();
|
||||
}
|
||||
|
||||
/// Removes an entry
|
||||
pub fn remove(&mut self, a: Address) {
|
||||
self.cache.remove(&a);
|
||||
self.save();
|
||||
}
|
||||
}
|
||||
|
||||
/// Dapps user settings
|
||||
@ -244,4 +250,22 @@ mod tests {
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_remove_address() {
|
||||
let temp = RandomTempPath::create_dir();
|
||||
let path = temp.as_str().to_owned();
|
||||
let mut b = AddressBook::new(path.clone());
|
||||
|
||||
b.set_name(1.into(), "One".to_owned());
|
||||
b.set_name(2.into(), "Two".to_owned());
|
||||
b.set_name(3.into(), "Three".to_owned());
|
||||
b.remove(2.into());
|
||||
|
||||
let b = AddressBook::new(path);
|
||||
assert_eq!(b.get(), hash_map![
|
||||
1.into() => AccountMeta{name: "One".to_owned(), meta: "{}".to_owned(), uuid: None},
|
||||
3.into() => AccountMeta{name: "Three".to_owned(), meta: "{}".to_owned(), uuid: None}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -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, Rlp, 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)]
|
||||
@ -68,18 +68,20 @@ pub struct AuthorityRound {
|
||||
params: CommonParams,
|
||||
our_params: AuthorityRoundParams,
|
||||
builtins: BTreeMap<Address, Builtin>,
|
||||
transition_service: IoService<BlockArrived>,
|
||||
transition_service: IoService<()>,
|
||||
message_channel: Mutex<Option<IoChannel<ClientIoMessage>>>,
|
||||
step: AtomicUsize,
|
||||
proposed: AtomicBool,
|
||||
account_provider: Mutex<Option<Arc<AccountProvider>>>,
|
||||
password: RwLock<Option<String>>,
|
||||
}
|
||||
|
||||
fn header_step(header: &Header) -> Result<usize, ::rlp::DecoderError> {
|
||||
UntrustedRlp::new(&header.seal()[0]).as_val()
|
||||
UntrustedRlp::new(&header.seal().get(0).expect("was either checked with verify_block_basic or is genesis; has 2 fields; qed (Make sure the spec file has a correct genesis seal)")).as_val()
|
||||
}
|
||||
|
||||
fn header_signature(header: &Header) -> Result<Signature, ::rlp::DecoderError> {
|
||||
UntrustedRlp::new(&header.seal()[1]).as_val::<H520>().map(Into::into)
|
||||
UntrustedRlp::new(&header.seal().get(1).expect("was checked with verify_block_basic; has 2 fields; qed")).as_val::<H520>().map(Into::into)
|
||||
}
|
||||
|
||||
trait AsMillis {
|
||||
@ -101,10 +103,12 @@ impl AuthorityRound {
|
||||
params: params,
|
||||
our_params: our_params,
|
||||
builtins: builtins,
|
||||
transition_service: try!(IoService::<BlockArrived>::start()),
|
||||
transition_service: try!(IoService::<()>::start()),
|
||||
message_channel: Mutex::new(None),
|
||||
step: AtomicUsize::new(initial_step),
|
||||
proposed: AtomicBool::new(false)
|
||||
proposed: AtomicBool::new(false),
|
||||
account_provider: Mutex::new(None),
|
||||
password: RwLock::new(None),
|
||||
});
|
||||
let handler = TransitionHandler { engine: Arc::downgrade(&engine) };
|
||||
try!(engine.transition_service.register_handler(Arc::new(handler)));
|
||||
@ -143,20 +147,17 @@ struct TransitionHandler {
|
||||
engine: Weak<AuthorityRound>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct BlockArrived;
|
||||
|
||||
const ENGINE_TIMEOUT_TOKEN: TimerToken = 23;
|
||||
|
||||
impl IoHandler<BlockArrived> for TransitionHandler {
|
||||
fn initialize(&self, io: &IoContext<BlockArrived>) {
|
||||
impl IoHandler<()> for TransitionHandler {
|
||||
fn initialize(&self, io: &IoContext<()>) {
|
||||
if let Some(engine) = self.engine.upgrade() {
|
||||
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, engine.remaining_step_duration().as_millis())
|
||||
.unwrap_or_else(|e| warn!(target: "poa", "Failed to start consensus step timer: {}.", e))
|
||||
}
|
||||
}
|
||||
|
||||
fn timeout(&self, io: &IoContext<BlockArrived>, timer: TimerToken) {
|
||||
fn timeout(&self, io: &IoContext<()>, timer: TimerToken) {
|
||||
if timer == ENGINE_TIMEOUT_TOKEN {
|
||||
if let Some(engine) = self.engine.upgrade() {
|
||||
engine.step.fetch_add(1, AtomicOrdering::SeqCst);
|
||||
@ -208,10 +209,6 @@ impl Engine for AuthorityRound {
|
||||
});
|
||||
}
|
||||
|
||||
/// Apply the block reward on finalisation of the block.
|
||||
/// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current).
|
||||
fn on_close_block(&self, _block: &mut ExecutedBlock) {}
|
||||
|
||||
fn is_sealer(&self, author: &Address) -> Option<bool> {
|
||||
let p = &self.our_params;
|
||||
Some(p.authorities.contains(author))
|
||||
@ -221,14 +218,14 @@ impl Engine for AuthorityRound {
|
||||
///
|
||||
/// This operation is synchronous and may (quite reasonably) not be available, in which `false` will
|
||||
/// be returned.
|
||||
fn generate_seal(&self, block: &ExecutedBlock, accounts: Option<&AccountProvider>) -> Option<Vec<Bytes>> {
|
||||
fn generate_seal(&self, block: &ExecutedBlock) -> Option<Vec<Bytes>> {
|
||||
if self.proposed.load(AtomicOrdering::SeqCst) { return None; }
|
||||
let header = block.header();
|
||||
let step = self.step();
|
||||
if self.is_step_proposer(step, header.author()) {
|
||||
if let Some(ap) = accounts {
|
||||
if let Some(ref ap) = *self.account_provider.lock() {
|
||||
// Account should be permanently unlocked, otherwise sealing will fail.
|
||||
if let Ok(signature) = ap.sign(*header.author(), None, header.bare_hash()) {
|
||||
if let Ok(signature) = ap.sign(*header.author(), self.password.read().clone(), header.bare_hash()) {
|
||||
trace!(target: "poa", "generate_seal: Issuing a block for step {}.", step);
|
||||
self.proposed.store(true, AtomicOrdering::SeqCst);
|
||||
return Some(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]);
|
||||
@ -303,11 +300,6 @@ impl Engine for AuthorityRound {
|
||||
t.sender().map(|_|()) // Perform EC recovery and cache sender
|
||||
}
|
||||
|
||||
fn register_message_channel(&self, message_channel: IoChannel<ClientIoMessage>) {
|
||||
let mut guard = self.message_channel.lock();
|
||||
*guard = Some(message_channel);
|
||||
}
|
||||
|
||||
fn is_new_best_block(&self, _best_total_difficulty: U256, best_header: HeaderView, _parent_details: &BlockDetails, new_header: &HeaderView) -> bool {
|
||||
let new_number = new_header.number();
|
||||
let best_number = best_header.number();
|
||||
@ -320,6 +312,18 @@ impl Engine for AuthorityRound {
|
||||
new_step < best_step
|
||||
}
|
||||
}
|
||||
|
||||
fn register_message_channel(&self, message_channel: IoChannel<ClientIoMessage>) {
|
||||
*self.message_channel.lock() = Some(message_channel);
|
||||
}
|
||||
|
||||
fn set_signer(&self, _address: Address, password: String) {
|
||||
*self.password.write() = Some(password);
|
||||
}
|
||||
|
||||
fn register_account_provider(&self, account_provider: Arc<AccountProvider>) {
|
||||
*self.account_provider.lock() = Some(account_provider);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -387,12 +391,11 @@ mod tests {
|
||||
fn generates_seal_and_does_not_double_propose() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr1 = tap.insert_account("1".sha3(), "1").unwrap();
|
||||
tap.unlock_account_permanently(addr1, "1".into()).unwrap();
|
||||
let addr2 = tap.insert_account("2".sha3(), "2").unwrap();
|
||||
tap.unlock_account_permanently(addr2, "2".into()).unwrap();
|
||||
|
||||
let spec = Spec::new_test_round();
|
||||
let engine = &*spec.engine;
|
||||
engine.register_account_provider(Arc::new(tap));
|
||||
let genesis_header = spec.genesis_header();
|
||||
let mut db1 = get_temp_state_db().take();
|
||||
spec.ensure_db_good(&mut db1, &TrieFactory::new(TrieSpec::Secure)).unwrap();
|
||||
@ -404,16 +407,18 @@ mod tests {
|
||||
let b2 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![]).unwrap();
|
||||
let b2 = b2.close_and_lock();
|
||||
|
||||
if let Some(seal) = engine.generate_seal(b1.block(), Some(&tap)) {
|
||||
engine.set_signer(addr1, "1".into());
|
||||
if let Some(seal) = engine.generate_seal(b1.block()) {
|
||||
assert!(b1.clone().try_seal(engine, seal).is_ok());
|
||||
// Second proposal is forbidden.
|
||||
assert!(engine.generate_seal(b1.block(), Some(&tap)).is_none());
|
||||
assert!(engine.generate_seal(b1.block()).is_none());
|
||||
}
|
||||
|
||||
if let Some(seal) = engine.generate_seal(b2.block(), Some(&tap)) {
|
||||
engine.set_signer(addr2, "2".into());
|
||||
if let Some(seal) = engine.generate_seal(b2.block()) {
|
||||
assert!(b2.clone().try_seal(engine, seal).is_ok());
|
||||
// Second proposal is forbidden.
|
||||
assert!(engine.generate_seal(b2.block(), Some(&tap)).is_none());
|
||||
assert!(engine.generate_seal(b2.block()).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,8 @@ pub struct BasicAuthority {
|
||||
params: CommonParams,
|
||||
our_params: BasicAuthorityParams,
|
||||
builtins: BTreeMap<Address, Builtin>,
|
||||
account_provider: Mutex<Option<Arc<AccountProvider>>>,
|
||||
password: RwLock<Option<String>>,
|
||||
}
|
||||
|
||||
impl BasicAuthority {
|
||||
@ -67,6 +69,8 @@ impl BasicAuthority {
|
||||
params: params,
|
||||
our_params: our_params,
|
||||
builtins: builtins,
|
||||
account_provider: Mutex::new(None),
|
||||
password: RwLock::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,13 +102,8 @@ impl Engine for BasicAuthority {
|
||||
max(gas_floor_target, gas_limit - gas_limit / bound_divisor + 1.into())
|
||||
}
|
||||
});
|
||||
// info!("ethash: populate_from_parent #{}: difficulty={} and gas_limit={}", header.number, header.difficulty, header.gas_limit);
|
||||
}
|
||||
|
||||
/// Apply the block reward on finalisation of the block.
|
||||
/// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current).
|
||||
fn on_close_block(&self, _block: &mut ExecutedBlock) {}
|
||||
|
||||
fn is_sealer(&self, author: &Address) -> Option<bool> {
|
||||
Some(self.our_params.authorities.contains(author))
|
||||
}
|
||||
@ -113,12 +112,12 @@ impl Engine for BasicAuthority {
|
||||
///
|
||||
/// This operation is synchronous and may (quite reasonably) not be available, in which `false` will
|
||||
/// be returned.
|
||||
fn generate_seal(&self, block: &ExecutedBlock, accounts: Option<&AccountProvider>) -> Option<Vec<Bytes>> {
|
||||
if let Some(ap) = accounts {
|
||||
fn generate_seal(&self, block: &ExecutedBlock) -> Option<Vec<Bytes>> {
|
||||
if let Some(ref ap) = *self.account_provider.lock() {
|
||||
let header = block.header();
|
||||
let message = header.bare_hash();
|
||||
// account should be pernamently unlocked, otherwise sealing will fail
|
||||
if let Ok(signature) = ap.sign(*block.header().author(), None, message) {
|
||||
if let Ok(signature) = ap.sign(*block.header().author(), self.password.read().clone(), message) {
|
||||
return Some(vec![::rlp::encode(&(&*signature as &[u8])).to_vec()]);
|
||||
} else {
|
||||
trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable");
|
||||
@ -179,6 +178,14 @@ impl Engine for BasicAuthority {
|
||||
fn verify_transaction(&self, t: &SignedTransaction, _header: &Header) -> Result<(), Error> {
|
||||
t.sender().map(|_|()) // Perform EC recovery and cache sender
|
||||
}
|
||||
|
||||
fn set_signer(&self, _address: Address, password: String) {
|
||||
*self.password.write() = Some(password);
|
||||
}
|
||||
|
||||
fn register_account_provider(&self, ap: Arc<AccountProvider>) {
|
||||
*self.account_provider.lock() = Some(ap);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -250,10 +257,11 @@ mod tests {
|
||||
fn can_generate_seal() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("".sha3(), "").unwrap();
|
||||
tap.unlock_account_permanently(addr, "".into()).unwrap();
|
||||
|
||||
let spec = new_test_authority();
|
||||
let engine = &*spec.engine;
|
||||
engine.set_signer(addr, "".into());
|
||||
engine.register_account_provider(Arc::new(tap));
|
||||
let genesis_header = spec.genesis_header();
|
||||
let mut db_result = get_temp_state_db();
|
||||
let mut db = db_result.take();
|
||||
@ -261,7 +269,7 @@ mod tests {
|
||||
let last_hashes = Arc::new(vec![genesis_header.hash()]);
|
||||
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
|
||||
let b = b.close_and_lock();
|
||||
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
|
||||
let seal = engine.generate_seal(b.block()).unwrap();
|
||||
assert!(b.try_seal(engine, seal).is_ok());
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ use spec::CommonParams;
|
||||
use evm::Schedule;
|
||||
use block::ExecutedBlock;
|
||||
use util::Bytes;
|
||||
use account_provider::AccountProvider;
|
||||
|
||||
/// An engine which does not provide any consensus mechanism, just seals blocks internally.
|
||||
pub struct InstantSeal {
|
||||
@ -60,7 +59,7 @@ impl Engine for InstantSeal {
|
||||
|
||||
fn is_sealer(&self, _author: &Address) -> Option<bool> { Some(true) }
|
||||
|
||||
fn generate_seal(&self, _block: &ExecutedBlock, _accounts: Option<&AccountProvider>) -> Option<Vec<Bytes>> {
|
||||
fn generate_seal(&self, _block: &ExecutedBlock) -> Option<Vec<Bytes>> {
|
||||
Some(Vec::new())
|
||||
}
|
||||
}
|
||||
@ -70,16 +69,12 @@ mod tests {
|
||||
use util::*;
|
||||
use util::trie::TrieSpec;
|
||||
use tests::helpers::*;
|
||||
use account_provider::AccountProvider;
|
||||
use spec::Spec;
|
||||
use header::Header;
|
||||
use block::*;
|
||||
|
||||
#[test]
|
||||
fn instant_can_seal() {
|
||||
let tap = AccountProvider::transient_provider();
|
||||
let addr = tap.insert_account("".sha3(), "").unwrap();
|
||||
|
||||
let spec = Spec::new_instant();
|
||||
let engine = &*spec.engine;
|
||||
let genesis_header = spec.genesis_header();
|
||||
@ -87,10 +82,9 @@ mod tests {
|
||||
let mut db = db_result.take();
|
||||
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
|
||||
let last_hashes = Arc::new(vec![genesis_header.hash()]);
|
||||
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
|
||||
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::default(), (3141562.into(), 31415620.into()), vec![]).unwrap();
|
||||
let b = b.close_and_lock();
|
||||
// Seal with empty AccountProvider.
|
||||
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
|
||||
let seal = engine.generate_seal(b.block()).unwrap();
|
||||
assert!(b.try_seal(engine, seal).is_ok());
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ pub trait Engine : Sync + Send {
|
||||
///
|
||||
/// This operation is synchronous and may (quite reasonably) not be available, in which None will
|
||||
/// be returned.
|
||||
fn generate_seal(&self, _block: &ExecutedBlock, _accounts: Option<&AccountProvider>) -> Option<Vec<Bytes>> { None }
|
||||
fn generate_seal(&self, _block: &ExecutedBlock) -> Option<Vec<Bytes>> { None }
|
||||
|
||||
/// Phase 1 quick block verification. Only does checks that are cheap. `block` (the header's full block)
|
||||
/// may be provided for additional checks. Returns either a null `Ok` or a general error detailing the problem with import.
|
||||
@ -147,11 +147,17 @@ pub trait Engine : Sync + Send {
|
||||
self.builtins().get(a).expect("attempted to execute nonexistent builtin").execute(input, output);
|
||||
}
|
||||
|
||||
/// Add a channel for communication with Client which can be used for sealing.
|
||||
fn register_message_channel(&self, _message_channel: IoChannel<ClientIoMessage>) {}
|
||||
|
||||
/// Check if new block should be chosen as the one in chain.
|
||||
fn is_new_best_block(&self, best_total_difficulty: U256, _best_header: HeaderView, parent_details: &BlockDetails, new_header: &HeaderView) -> bool {
|
||||
ethash::is_new_best_block(best_total_difficulty, parent_details, new_header)
|
||||
}
|
||||
|
||||
/// Register an account which signs consensus messages.
|
||||
fn set_signer(&self, _address: Address, _password: String) {}
|
||||
|
||||
/// Add a channel for communication with Client which can be used for sealing.
|
||||
fn register_message_channel(&self, _message_channel: IoChannel<ClientIoMessage>) {}
|
||||
|
||||
/// Add an account provider useful for Engines that sign stuff.
|
||||
fn register_account_provider(&self, _account_provider: Arc<AccountProvider>) {}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ use std::time::{Instant, Duration};
|
||||
|
||||
use util::*;
|
||||
use util::using_queue::{UsingQueue, GetAction};
|
||||
use account_provider::AccountProvider;
|
||||
use account_provider::{AccountProvider, Error as AccountError};
|
||||
use views::{BlockView, HeaderView};
|
||||
use header::Header;
|
||||
use state::{State, CleanupMode};
|
||||
@ -464,15 +464,12 @@ impl Miner {
|
||||
/// Attempts to perform internal sealing (one that does not require work) to return Ok(sealed),
|
||||
/// Err(Some(block)) returns for unsuccesful sealing while Err(None) indicates misspecified engine.
|
||||
fn seal_block_internally(&self, block: ClosedBlock) -> Result<SealedBlock, Option<ClosedBlock>> {
|
||||
trace!(target: "miner", "seal_block_internally: block has transaction - attempting internal seal.");
|
||||
let s = self.engine.generate_seal(block.block(), match self.accounts {
|
||||
Some(ref x) => Some(&**x),
|
||||
None => None,
|
||||
});
|
||||
trace!(target: "miner", "seal_block_internally: attempting internal seal.");
|
||||
let s = self.engine.generate_seal(block.block());
|
||||
if let Some(seal) = s {
|
||||
trace!(target: "miner", "seal_block_internally: managed internal seal. importing...");
|
||||
block.lock().try_seal(&*self.engine, seal).or_else(|_| {
|
||||
warn!("prepare_sealing: ERROR: try_seal failed when given internally generated seal. WTF?");
|
||||
block.lock().try_seal(&*self.engine, seal).or_else(|(e, _)| {
|
||||
warn!("prepare_sealing: ERROR: try_seal failed when given internally generated seal: {}", e);
|
||||
Err(None)
|
||||
})
|
||||
} else {
|
||||
@ -485,7 +482,7 @@ impl Miner {
|
||||
fn seal_and_import_block_internally(&self, chain: &MiningBlockChainClient, block: ClosedBlock) -> bool {
|
||||
if !block.transactions().is_empty() || self.forced_sealing() {
|
||||
if let Ok(sealed) = self.seal_block_internally(block) {
|
||||
if chain.import_block(sealed.rlp_bytes()).is_ok() {
|
||||
if chain.import_sealed_block(sealed).is_ok() {
|
||||
trace!(target: "miner", "import_block_internally: imported internally sealed block");
|
||||
return true
|
||||
}
|
||||
@ -740,6 +737,19 @@ impl MinerService for Miner {
|
||||
*self.author.write() = author;
|
||||
}
|
||||
|
||||
fn set_engine_signer(&self, address: Address, password: String) -> Result<(), AccountError> {
|
||||
if self.seals_internally {
|
||||
if let Some(ref ap) = self.accounts {
|
||||
try!(ap.sign(address.clone(), Some(password.clone()), Default::default()));
|
||||
}
|
||||
let mut sealing_work = self.sealing_work.lock();
|
||||
sealing_work.enabled = self.engine.is_sealer(&address).unwrap_or(false);
|
||||
*self.author.write() = address;
|
||||
self.engine.set_signer(address, password);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_extra_data(&self, extra_data: Bytes) {
|
||||
*self.extra_data.write() = extra_data;
|
||||
}
|
||||
@ -1042,7 +1052,7 @@ impl MinerService for Miner {
|
||||
ret.map(f)
|
||||
}
|
||||
|
||||
fn submit_seal(&self, chain: &MiningBlockChainClient, pow_hash: H256, seal: Vec<Bytes>) -> Result<(), Error> {
|
||||
fn submit_seal(&self, chain: &MiningBlockChainClient, block_hash: H256, seal: Vec<Bytes>) -> Result<(), Error> {
|
||||
let result =
|
||||
if let Some(b) = self.sealing_work.lock().queue.get_used_if(
|
||||
if self.options.enable_resubmission {
|
||||
@ -1050,22 +1060,22 @@ impl MinerService for Miner {
|
||||
} else {
|
||||
GetAction::Take
|
||||
},
|
||||
|b| &b.hash() == &pow_hash
|
||||
|b| &b.hash() == &block_hash
|
||||
) {
|
||||
trace!(target: "miner", "Sealing block {}={}={} with seal {:?}", pow_hash, b.hash(), b.header().bare_hash(), seal);
|
||||
trace!(target: "miner", "Submitted block {}={}={} with seal {:?}", block_hash, b.hash(), b.header().bare_hash(), seal);
|
||||
b.lock().try_seal(&*self.engine, seal).or_else(|(e, _)| {
|
||||
warn!(target: "miner", "Mined solution rejected: {}", e);
|
||||
Err(Error::PowInvalid)
|
||||
})
|
||||
} else {
|
||||
warn!(target: "miner", "Mined solution rejected: Block unknown or out of date.");
|
||||
warn!(target: "miner", "Submitted solution rejected: Block unknown or out of date.");
|
||||
Err(Error::PowHashInvalid)
|
||||
};
|
||||
result.and_then(|sealed| {
|
||||
let n = sealed.header().number();
|
||||
let h = sealed.header().hash();
|
||||
try!(chain.import_sealed_block(sealed));
|
||||
info!(target: "miner", "Mined block imported OK. #{}: {}", Colour::White.bold().paint(format!("{}", n)), Colour::White.bold().paint(h.hex()));
|
||||
info!(target: "miner", "Submitted block imported OK. #{}: {}", Colour::White.bold().paint(format!("{}", n)), Colour::White.bold().paint(h.hex()));
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ pub trait MinerService : Send + Sync {
|
||||
/// Set the author that we will seal blocks as.
|
||||
fn set_author(&self, author: Address);
|
||||
|
||||
/// Set info necessary to sign consensus messages.
|
||||
fn set_engine_signer(&self, address: Address, password: String) -> Result<(), ::account_provider::Error>;
|
||||
|
||||
/// Get the extra_data that we will seal blocks with.
|
||||
fn extra_data(&self) -> Bytes;
|
||||
|
||||
|
@ -304,6 +304,9 @@ impl SignedTransaction {
|
||||
/// 0 if `v` would have been 27 under "Electrum" notation, 1 if 28 or 4 if invalid.
|
||||
pub fn standard_v(&self) -> u8 { match self.v { v if v == 27 || v == 28 || v > 36 => ((v - 1) % 2) as u8, _ => 4 } }
|
||||
|
||||
/// The `v` value that appears in the RLP.
|
||||
pub fn original_v(&self) -> u64 { self.v }
|
||||
|
||||
/// The network ID, or `None` if this is a global transaction.
|
||||
pub fn network_id(&self) -> Option<u64> {
|
||||
match self.v {
|
||||
|
@ -53,6 +53,8 @@ pub struct Config {
|
||||
/// Maximum heap memory to use.
|
||||
/// When the limit is reached, is_full returns true.
|
||||
pub max_mem_use: usize,
|
||||
/// Settings for the number of verifiers and adaptation strategy.
|
||||
pub verifier_settings: VerifierSettings,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@ -60,6 +62,26 @@ impl Default for Config {
|
||||
Config {
|
||||
max_queue_size: 30000,
|
||||
max_mem_use: 50 * 1024 * 1024,
|
||||
verifier_settings: VerifierSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Verifier settings.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct VerifierSettings {
|
||||
/// Whether to scale amount of verifiers according to load.
|
||||
// Todo: replace w/ strategy enum?
|
||||
pub scale_verifiers: bool,
|
||||
/// Beginning amount of verifiers.
|
||||
pub num_verifiers: usize,
|
||||
}
|
||||
|
||||
impl Default for VerifierSettings {
|
||||
fn default() -> Self {
|
||||
VerifierSettings {
|
||||
scale_verifiers: false,
|
||||
num_verifiers: MAX_VERIFIERS,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,6 +136,7 @@ pub struct VerificationQueue<K: Kind> {
|
||||
ticks_since_adjustment: AtomicUsize,
|
||||
max_queue_size: usize,
|
||||
max_mem_use: usize,
|
||||
scale_verifiers: bool,
|
||||
verifier_handles: Vec<JoinHandle<()>>,
|
||||
state: Arc<(Mutex<State>, Condvar)>,
|
||||
}
|
||||
@ -198,13 +221,16 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
});
|
||||
let empty = Arc::new(SCondvar::new());
|
||||
let panic_handler = PanicHandler::new_in_arc();
|
||||
let scale_verifiers = config.verifier_settings.scale_verifiers;
|
||||
|
||||
let max_verifiers = min(::num_cpus::get(), MAX_VERIFIERS);
|
||||
let default_amount = max(::num_cpus::get(), 3) - 2;
|
||||
let num_cpus = ::num_cpus::get();
|
||||
let max_verifiers = min(num_cpus, MAX_VERIFIERS);
|
||||
let default_amount = max(1, min(max_verifiers, config.verifier_settings.num_verifiers));
|
||||
let state = Arc::new((Mutex::new(State::Work(default_amount)), Condvar::new()));
|
||||
let mut verifier_handles = Vec::with_capacity(max_verifiers);
|
||||
|
||||
debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, default_amount);
|
||||
debug!(target: "verification", "Verifier auto-scaling {}", if scale_verifiers { "enabled" } else { "disabled" });
|
||||
|
||||
for i in 0..max_verifiers {
|
||||
debug!(target: "verification", "Adding verification thread #{}", i);
|
||||
@ -248,6 +274,7 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
ticks_since_adjustment: AtomicUsize::new(0),
|
||||
max_queue_size: max(config.max_queue_size, MIN_QUEUE_LIMIT),
|
||||
max_mem_use: max(config.max_mem_use, MIN_MEM_LIMIT),
|
||||
scale_verifiers: scale_verifiers,
|
||||
verifier_handles: verifier_handles,
|
||||
state: state,
|
||||
}
|
||||
@ -597,6 +624,8 @@ impl<K: Kind> VerificationQueue<K> {
|
||||
|
||||
self.processing.write().shrink_to_fit();
|
||||
|
||||
if !self.scale_verifiers { return }
|
||||
|
||||
if self.ticks_since_adjustment.fetch_add(1, AtomicOrdering::SeqCst) + 1 >= READJUSTMENT_PERIOD {
|
||||
self.ticks_since_adjustment.store(0, AtomicOrdering::SeqCst);
|
||||
} else {
|
||||
@ -675,10 +704,15 @@ mod tests {
|
||||
use error::*;
|
||||
use views::*;
|
||||
|
||||
fn get_test_queue() -> BlockQueue {
|
||||
// create a test block queue.
|
||||
// auto_scaling enables verifier adjustment.
|
||||
fn get_test_queue(auto_scale: bool) -> BlockQueue {
|
||||
let spec = get_test_spec();
|
||||
let engine = spec.engine;
|
||||
BlockQueue::new(Config::default(), engine, IoChannel::disconnected(), true)
|
||||
|
||||
let mut config = Config::default();
|
||||
config.verifier_settings.scale_verifiers = auto_scale;
|
||||
BlockQueue::new(config, engine, IoChannel::disconnected(), true)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -691,7 +725,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn can_import_blocks() {
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(false);
|
||||
if let Err(e) = queue.import(Unverified::new(get_good_dummy_block())) {
|
||||
panic!("error importing block that is valid by definition({:?})", e);
|
||||
}
|
||||
@ -699,7 +733,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn returns_error_for_duplicates() {
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(false);
|
||||
if let Err(e) = queue.import(Unverified::new(get_good_dummy_block())) {
|
||||
panic!("error importing block that is valid by definition({:?})", e);
|
||||
}
|
||||
@ -718,7 +752,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn returns_ok_for_drained_duplicates() {
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(false);
|
||||
let block = get_good_dummy_block();
|
||||
let hash = BlockView::new(&block).header().hash().clone();
|
||||
if let Err(e) = queue.import(Unverified::new(block)) {
|
||||
@ -735,7 +769,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn returns_empty_once_finished() {
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(false);
|
||||
queue.import(Unverified::new(get_good_dummy_block()))
|
||||
.expect("error importing block that is valid by definition");
|
||||
queue.flush();
|
||||
@ -763,7 +797,7 @@ mod tests {
|
||||
fn scaling_limits() {
|
||||
use super::MAX_VERIFIERS;
|
||||
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(true);
|
||||
queue.scale_verifiers(MAX_VERIFIERS + 1);
|
||||
|
||||
assert!(queue.num_verifiers() < MAX_VERIFIERS + 1);
|
||||
@ -775,7 +809,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn readjust_verifiers() {
|
||||
let queue = get_test_queue();
|
||||
let queue = get_test_queue(true);
|
||||
|
||||
// put all the verifiers to sleep to ensure
|
||||
// the test isn't timing sensitive.
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "evmjit"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["debris <marek.kotewicz@gmail.com>"]
|
||||
|
||||
[lib]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ethcore-ipc-codegen"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Nikolay Volf"]
|
||||
license = "GPL-3.0"
|
||||
description = "Macros to auto-generate implementations for ipc call"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ethcore-ipc-nano"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Nikolay Volf <nikolay@ethcore.io>"]
|
||||
license = "GPL-3.0"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ethcore-ipc"
|
||||
version = "1.4.0"
|
||||
version = "1.5.0"
|
||||
authors = ["Nikolay Volf <nikvolf@gmail.com>"]
|
||||
license = "GPL-3.0"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "parity.js",
|
||||
"version": "0.2.94",
|
||||
"version": "0.2.99",
|
||||
"main": "release/index.js",
|
||||
"jsnext:main": "src/index.js",
|
||||
"author": "Parity Team <admin@parity.io>",
|
||||
|
@ -34,11 +34,18 @@ git fetch origin 2>$GITLOG
|
||||
git checkout -b $BRANCH
|
||||
|
||||
echo "*** Committing compiled files for $UTCDATE"
|
||||
mv build ../build.new
|
||||
git add .
|
||||
git commit -m "$UTCDATE"
|
||||
git commit -m "$UTCDATE [update]"
|
||||
git merge origin/$BRANCH -X ours --commit -m "$UTCDATE [merge]"
|
||||
git rm -r build
|
||||
rm -rf build
|
||||
git commit -m "$UTCDATE [cleanup]"
|
||||
mv ../build.new build
|
||||
git add .
|
||||
git commit -m "$UTCDATE [release]"
|
||||
|
||||
echo "*** Merging remote"
|
||||
git merge origin/$BRANCH -X ours --commit -m "$UTCDATE [release]"
|
||||
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG
|
||||
PRECOMPILED_HASH=`git rev-parse HEAD`
|
||||
|
||||
|
1
js/scripts/test.js
Normal file
1
js/scripts/test.js
Normal file
@ -0,0 +1 @@
|
||||
// test script 4
|
@ -189,15 +189,21 @@ export default class Contract {
|
||||
});
|
||||
}
|
||||
|
||||
_encodeOptions (func, options, values) {
|
||||
getCallData = (func, options, values) => {
|
||||
let data = options.data;
|
||||
|
||||
const tokens = func ? this._abi.encodeTokens(func.inputParamTypes(), values) : null;
|
||||
const call = tokens ? func.encodeCall(tokens) : null;
|
||||
|
||||
if (options.data && options.data.substr(0, 2) === '0x') {
|
||||
options.data = options.data.substr(2);
|
||||
if (data && data.substr(0, 2) === '0x') {
|
||||
data = data.substr(2);
|
||||
}
|
||||
options.data = `0x${options.data || ''}${call || ''}`;
|
||||
|
||||
return `0x${data || ''}${call || ''}`;
|
||||
}
|
||||
|
||||
_encodeOptions (func, options, values) {
|
||||
options.data = this.getCallData(func, options, values);
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -209,10 +215,10 @@ export default class Contract {
|
||||
|
||||
_bindFunction = (func) => {
|
||||
func.call = (options, values = []) => {
|
||||
const callData = this._encodeOptions(func, this._addOptionsTo(options), values);
|
||||
const callParams = this._encodeOptions(func, this._addOptionsTo(options), values);
|
||||
|
||||
return this._api.eth
|
||||
.call(callData)
|
||||
.call(callParams)
|
||||
.then((encoded) => func.decodeOutput(encoded))
|
||||
.then((tokens) => tokens.map((token) => token.value))
|
||||
.then((returns) => returns.length === 1 ? returns[0] : returns);
|
||||
|
@ -112,11 +112,15 @@ export function inNumber10 (number) {
|
||||
}
|
||||
|
||||
export function inNumber16 (number) {
|
||||
if (isInstanceOf(number, BigNumber)) {
|
||||
return inHex(number.toString(16));
|
||||
const bn = isInstanceOf(number, BigNumber)
|
||||
? number
|
||||
: (new BigNumber(number || 0));
|
||||
|
||||
if (!bn.isInteger()) {
|
||||
throw new Error(`[format/input::inNumber16] the given number is not an integer: ${bn.toFormat()}`);
|
||||
}
|
||||
|
||||
return inHex((new BigNumber(number || 0)).toString(16));
|
||||
return inHex(bn.toString(16));
|
||||
}
|
||||
|
||||
export function inOptions (options) {
|
||||
@ -130,6 +134,9 @@ export function inOptions (options) {
|
||||
|
||||
case 'gas':
|
||||
case 'gasPrice':
|
||||
options[key] = inNumber16((new BigNumber(options[key])).round());
|
||||
break;
|
||||
|
||||
case 'value':
|
||||
case 'nonce':
|
||||
options[key] = inNumber16(options[key]);
|
||||
|
@ -128,6 +128,11 @@ export default class Parity {
|
||||
.execute('parity_killAccount', inAddress(account), password);
|
||||
}
|
||||
|
||||
removeAddress (address) {
|
||||
return this._transport
|
||||
.execute('parity_removeAddress', inAddress(address));
|
||||
}
|
||||
|
||||
listGethAccounts () {
|
||||
return this._transport
|
||||
.execute('parity_listGethAccounts')
|
||||
|
@ -68,6 +68,7 @@ export default class Personal {
|
||||
this._accountsInfo();
|
||||
return;
|
||||
|
||||
case 'parity_removeAddress':
|
||||
case 'parity_setAccountName':
|
||||
case 'parity_setAccountMeta':
|
||||
this._accountsInfo();
|
||||
|
File diff suppressed because one or more lines are too long
@ -94,7 +94,6 @@ export default class Application extends Component {
|
||||
tokenregInstance,
|
||||
accounts: Object
|
||||
.keys(accountsInfo)
|
||||
.filter((address) => !accountsInfo[address].meta.deleted)
|
||||
.sort((a, b) => {
|
||||
return (accountsInfo[b].uuid || '').localeCompare(accountsInfo[a].uuid || '');
|
||||
})
|
||||
|
@ -21,6 +21,9 @@ const muiTheme = getMuiTheme(lightBaseTheme);
|
||||
|
||||
import CircularProgress from 'material-ui/CircularProgress';
|
||||
import { Card, CardText } from 'material-ui/Card';
|
||||
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import styles from './application.css';
|
||||
import Accounts from '../Accounts';
|
||||
import Events from '../Events';
|
||||
@ -28,8 +31,6 @@ import Lookup from '../Lookup';
|
||||
import Names from '../Names';
|
||||
import Records from '../Records';
|
||||
|
||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
||||
|
||||
export default class Application extends Component {
|
||||
static childContextTypes = {
|
||||
muiTheme: PropTypes.object.isRequired,
|
||||
@ -44,8 +45,8 @@ export default class Application extends Component {
|
||||
actions: PropTypes.object.isRequired,
|
||||
accounts: PropTypes.object.isRequired,
|
||||
contacts: PropTypes.object.isRequired,
|
||||
contract: nullable(PropTypes.object.isRequired),
|
||||
fee: nullable(PropTypes.object.isRequired),
|
||||
contract: nullableProptype(PropTypes.object.isRequired),
|
||||
fee: nullableProptype(PropTypes.object.isRequired),
|
||||
lookup: PropTypes.object.isRequired,
|
||||
events: PropTypes.object.isRequired,
|
||||
names: PropTypes.object.isRequired,
|
||||
|
@ -18,19 +18,19 @@ import React, { Component, PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import Application from './Application';
|
||||
import * as actions from './actions';
|
||||
|
||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
||||
|
||||
class Container extends Component {
|
||||
static propTypes = {
|
||||
actions: PropTypes.object.isRequired,
|
||||
accounts: PropTypes.object.isRequired,
|
||||
contacts: PropTypes.object.isRequired,
|
||||
contract: nullable(PropTypes.object.isRequired),
|
||||
owner: nullable(PropTypes.string.isRequired),
|
||||
fee: nullable(PropTypes.object.isRequired),
|
||||
contract: nullableProptype(PropTypes.object.isRequired),
|
||||
owner: nullableProptype(PropTypes.string.isRequired),
|
||||
fee: nullableProptype(PropTypes.object.isRequired),
|
||||
lookup: PropTypes.object.isRequired,
|
||||
events: PropTypes.object.isRequired
|
||||
};
|
||||
|
@ -19,21 +19,22 @@ import { Card, CardHeader, CardText } from 'material-ui/Card';
|
||||
import TextField from 'material-ui/TextField';
|
||||
import RaisedButton from 'material-ui/RaisedButton';
|
||||
import SearchIcon from 'material-ui/svg-icons/action/search';
|
||||
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import renderAddress from '../ui/address.js';
|
||||
import renderImage from '../ui/image.js';
|
||||
|
||||
import recordTypeSelect from '../ui/record-type-select.js';
|
||||
import styles from './lookup.css';
|
||||
|
||||
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
|
||||
|
||||
export default class Lookup extends Component {
|
||||
|
||||
static propTypes = {
|
||||
actions: PropTypes.object.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
type: PropTypes.string.isRequired,
|
||||
result: nullable(PropTypes.string.isRequired),
|
||||
result: nullableProptype(PropTypes.string.isRequired),
|
||||
accounts: PropTypes.object.isRequired,
|
||||
contacts: PropTypes.object.isRequired
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { Card, CardHeader, CardText } from 'material-ui/Card';
|
||||
import TextField from 'material-ui/TextField';
|
||||
|
@ -24,7 +24,6 @@ export const fetch = () => (dispatch) => {
|
||||
.then((accountsInfo) => {
|
||||
const addresses = Object
|
||||
.keys(accountsInfo)
|
||||
.filter((address) => accountsInfo[address] && !accountsInfo[address].meta.deleted)
|
||||
.map((address) => ({
|
||||
...accountsInfo[address],
|
||||
address,
|
||||
|
@ -256,6 +256,20 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
removeAddress: {
|
||||
desc: 'Removes an address from the addressbook',
|
||||
params: [
|
||||
{
|
||||
type: Address,
|
||||
desc: 'The address to remove'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
type: Boolean,
|
||||
desc: 'true on success'
|
||||
}
|
||||
},
|
||||
|
||||
listGethAccounts: {
|
||||
desc: 'Returns a list of the accounts available from Geth',
|
||||
params: [],
|
||||
|
@ -102,7 +102,7 @@ export default class AddAddress extends Component {
|
||||
if (!addressError) {
|
||||
const contact = contacts[address];
|
||||
|
||||
if (contact && !contact.meta.deleted) {
|
||||
if (contact) {
|
||||
addressError = ERRORS.duplicateAddress;
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ export default class AddContract extends Component {
|
||||
if (!addressError) {
|
||||
const contract = contracts[address];
|
||||
|
||||
if (contract && !contract.meta.deleted) {
|
||||
if (contract) {
|
||||
addressError = ERRORS.duplicateAddress;
|
||||
}
|
||||
}
|
||||
|
@ -16,18 +16,62 @@
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { Form, TypedInput, Input, AddressSelect } from '../../../ui';
|
||||
import { parseAbiType } from '../../../util/abi';
|
||||
import { Form, TypedInput, Input, AddressSelect, InputAddress } from '~/ui';
|
||||
import { parseAbiType } from '~/util/abi';
|
||||
|
||||
import styles from '../createWallet.css';
|
||||
|
||||
export default class WalletDetails extends Component {
|
||||
static propTypes = {
|
||||
accounts: PropTypes.object.isRequired,
|
||||
wallet: PropTypes.object.isRequired,
|
||||
errors: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired
|
||||
onChange: PropTypes.func.isRequired,
|
||||
walletType: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
render () {
|
||||
const { walletType } = this.props;
|
||||
|
||||
if (walletType === 'WATCH') {
|
||||
return this.renderWatchDetails();
|
||||
}
|
||||
|
||||
return this.renderMultisigDetails();
|
||||
}
|
||||
|
||||
renderWatchDetails () {
|
||||
const { wallet, errors } = this.props;
|
||||
|
||||
return (
|
||||
<Form>
|
||||
<InputAddress
|
||||
label='wallet address'
|
||||
hint='the wallet contract address'
|
||||
value={ wallet.address }
|
||||
error={ errors.address }
|
||||
onChange={ this.onAddressChange }
|
||||
/>
|
||||
|
||||
<Input
|
||||
label='wallet name'
|
||||
hint='the local name for this wallet'
|
||||
value={ wallet.name }
|
||||
error={ errors.name }
|
||||
onChange={ this.onNameChange }
|
||||
/>
|
||||
|
||||
<Input
|
||||
label='wallet description (optional)'
|
||||
hint='the local description for this wallet'
|
||||
value={ wallet.description }
|
||||
onChange={ this.onDescriptionChange }
|
||||
/>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
renderMultisigDetails () {
|
||||
const { accounts, wallet, errors } = this.props;
|
||||
|
||||
return (
|
||||
@ -64,6 +108,7 @@ export default class WalletDetails extends Component {
|
||||
param={ parseAbiType('address[]') }
|
||||
/>
|
||||
|
||||
<div className={ styles.splitInput }>
|
||||
<TypedInput
|
||||
label='required owners'
|
||||
hint='number of required owners to accept a transaction'
|
||||
@ -71,20 +116,28 @@ export default class WalletDetails extends Component {
|
||||
error={ errors.required }
|
||||
onChange={ this.onRequiredChange }
|
||||
param={ parseAbiType('uint') }
|
||||
min={ 1 }
|
||||
max={ wallet.owners.length + 1 }
|
||||
/>
|
||||
|
||||
<TypedInput
|
||||
label='wallet day limit'
|
||||
hint='number of days to wait for other owners confirmation'
|
||||
hint='amount of ETH spendable without confirmations'
|
||||
value={ wallet.daylimit }
|
||||
error={ errors.daylimit }
|
||||
onChange={ this.onDaylimitChange }
|
||||
param={ parseAbiType('uint') }
|
||||
isEth
|
||||
/>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
onAddressChange = (_, address) => {
|
||||
this.props.onChange({ address });
|
||||
}
|
||||
|
||||
onAccoutChange = (_, account) => {
|
||||
this.props.onChange({ account });
|
||||
}
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { CompletedStep, IdentityIcon, CopyToClipboard } from '../../../ui';
|
||||
import { CompletedStep, IdentityIcon, CopyToClipboard } from '~/ui';
|
||||
import { fromWei } from '~/api/util/wei';
|
||||
|
||||
import styles from '../createWallet.css';
|
||||
|
||||
@ -34,15 +35,21 @@ export default class WalletInfo extends Component {
|
||||
daylimit: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.number
|
||||
]).isRequired
|
||||
]).isRequired,
|
||||
|
||||
deployed: PropTypes.bool
|
||||
};
|
||||
|
||||
render () {
|
||||
const { address, required, daylimit, name } = this.props;
|
||||
const { address, required, daylimit, name, deployed } = this.props;
|
||||
|
||||
return (
|
||||
<CompletedStep>
|
||||
<div><code>{ name }</code> has been deployed at</div>
|
||||
<div>
|
||||
<code>{ name }</code>
|
||||
<span> has been </span>
|
||||
<span> { deployed ? 'deployed' : 'added' } at </span>
|
||||
</div>
|
||||
<div>
|
||||
<CopyToClipboard data={ address } label='copy address to clipboard' />
|
||||
<IdentityIcon address={ address } inline center className={ styles.identityicon } />
|
||||
@ -56,16 +63,16 @@ export default class WalletInfo extends Component {
|
||||
<code>{ required }</code> owners are required to confirm a transaction.
|
||||
</p>
|
||||
<p>
|
||||
The daily limit is set to <code>{ daylimit }</code>.
|
||||
The daily limit is set to <code>{ fromWei(daylimit).toFormat() }</code> ETH.
|
||||
</p>
|
||||
</CompletedStep>
|
||||
);
|
||||
}
|
||||
|
||||
renderOwners () {
|
||||
const { account, owners } = this.props;
|
||||
const { account, owners, deployed } = this.props;
|
||||
|
||||
return [].concat(account, owners).map((address, id) => (
|
||||
return [].concat(deployed ? account : null, owners).filter((a) => a).map((address, id) => (
|
||||
<div key={ id } className={ styles.owner }>
|
||||
<IdentityIcon address={ address } inline center className={ styles.identityicon } />
|
||||
<div className={ styles.address }>{ this.addressToString(address) }</div>
|
||||
|
@ -14,8 +14,4 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { PropTypes } from 'react';
|
||||
|
||||
export default function nullableProptype (type) {
|
||||
return PropTypes.oneOfType([ PropTypes.oneOf([ null ]), type ]);
|
||||
}
|
||||
export default from './walletType.js';
|
64
js/src/modals/CreateWallet/WalletType/walletType.js
Normal file
64
js/src/modals/CreateWallet/WalletType/walletType.js
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { RadioButtons } from '~/ui';
|
||||
|
||||
// import styles from '../createWallet.css';
|
||||
|
||||
export default class WalletType extends Component {
|
||||
static propTypes = {
|
||||
onChange: PropTypes.func.isRequired,
|
||||
type: PropTypes.string.isRequired
|
||||
};
|
||||
|
||||
render () {
|
||||
const { type } = this.props;
|
||||
|
||||
return (
|
||||
<RadioButtons
|
||||
name='contractType'
|
||||
value={ type }
|
||||
values={ this.getTypes() }
|
||||
onChange={ this.onTypeChange }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
getTypes () {
|
||||
return [
|
||||
{
|
||||
label: 'Multi-Sig wallet', key: 'MULTISIG',
|
||||
description: (
|
||||
<span>
|
||||
<span>Create/Deploy a </span>
|
||||
<a href='https://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol' target='_blank'>standard multi-signature </a>
|
||||
<span> Wallet</span>
|
||||
</span>
|
||||
)
|
||||
},
|
||||
{
|
||||
label: 'Watch a wallet', key: 'WATCH',
|
||||
description: 'Add an existing wallet to your accounts'
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
onTypeChange = (type) => {
|
||||
this.props.onChange(type.key);
|
||||
}
|
||||
}
|
@ -37,3 +37,22 @@
|
||||
height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.splitInput {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
> * {
|
||||
flex: 1;
|
||||
|
||||
margin: 0 0.25em;
|
||||
|
||||
&:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,9 @@ 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 { Button, Modal, TxHash, BusyStep } from '../../ui';
|
||||
import { Button, Modal, TxHash, BusyStep } from '~/ui';
|
||||
|
||||
import WalletType from './WalletType';
|
||||
import WalletDetails from './WalletDetails';
|
||||
import WalletInfo from './WalletInfo';
|
||||
import CreateWalletStore from './createWalletStore';
|
||||
@ -64,7 +65,7 @@ export default class CreateWallet extends Component {
|
||||
visible
|
||||
actions={ this.renderDialogActions() }
|
||||
current={ stage }
|
||||
steps={ steps }
|
||||
steps={ steps.map((s) => s.title) }
|
||||
waiting={ waiting }
|
||||
>
|
||||
{ this.renderPage() }
|
||||
@ -98,24 +99,35 @@ export default class CreateWallet extends Component {
|
||||
required={ this.store.wallet.required }
|
||||
daylimit={ this.store.wallet.daylimit }
|
||||
name={ this.store.wallet.name }
|
||||
|
||||
deployed={ this.store.deployed }
|
||||
/>
|
||||
);
|
||||
|
||||
default:
|
||||
case 'DETAILS':
|
||||
return (
|
||||
<WalletDetails
|
||||
accounts={ accounts }
|
||||
wallet={ this.store.wallet }
|
||||
errors={ this.store.errors }
|
||||
walletType={ this.store.walletType }
|
||||
onChange={ this.store.onChange }
|
||||
/>
|
||||
);
|
||||
|
||||
default:
|
||||
case 'TYPE':
|
||||
return (
|
||||
<WalletType
|
||||
onChange={ this.store.onTypeChange }
|
||||
type={ this.store.walletType }
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
renderDialogActions () {
|
||||
const { step, hasErrors, rejected, onCreate } = this.store;
|
||||
const { step, hasErrors, rejected, onCreate, onNext, onAdd } = this.store;
|
||||
|
||||
const cancelBtn = (
|
||||
<Button
|
||||
@ -149,12 +161,11 @@ export default class CreateWallet extends Component {
|
||||
/>
|
||||
);
|
||||
|
||||
const createBtn = (
|
||||
const nextBtn = (
|
||||
<Button
|
||||
icon={ <NavigationArrowForward /> }
|
||||
label='Create'
|
||||
disabled={ hasErrors }
|
||||
onClick={ onCreate }
|
||||
label='Next'
|
||||
onClick={ onNext }
|
||||
/>
|
||||
);
|
||||
|
||||
@ -169,9 +180,30 @@ export default class CreateWallet extends Component {
|
||||
case 'INFO':
|
||||
return [ doneBtn ];
|
||||
|
||||
default:
|
||||
case 'DETAILS':
|
||||
return [ cancelBtn, createBtn ];
|
||||
if (this.store.walletType === 'WATCH') {
|
||||
return [ cancelBtn, (
|
||||
<Button
|
||||
icon={ <NavigationArrowForward /> }
|
||||
label='Add'
|
||||
disabled={ hasErrors }
|
||||
onClick={ onAdd }
|
||||
/>
|
||||
) ];
|
||||
}
|
||||
|
||||
return [ cancelBtn, (
|
||||
<Button
|
||||
icon={ <NavigationArrowForward /> }
|
||||
label='Create'
|
||||
disabled={ hasErrors }
|
||||
onClick={ onCreate }
|
||||
/>
|
||||
) ];
|
||||
|
||||
default:
|
||||
case 'TYPE':
|
||||
return [ cancelBtn, nextBtn ];
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,26 +16,29 @@
|
||||
|
||||
import { observable, computed, action, transaction } from 'mobx';
|
||||
|
||||
import { ERRORS, validateUint, validateAddress, validateName } from '../../util/validation';
|
||||
import { ERROR_CODES } from '../../api/transport/error';
|
||||
import { validateUint, validateAddress, validateName } from '~/util/validation';
|
||||
import { ERROR_CODES } from '~/api/transport/error';
|
||||
|
||||
import { wallet as walletAbi } from '../../contracts/abi';
|
||||
import { wallet as walletCode } from '../../contracts/code';
|
||||
import Contract from '~/api/contract';
|
||||
import { wallet as walletAbi } from '~/contracts/abi';
|
||||
import { wallet as walletCode } from '~/contracts/code';
|
||||
|
||||
import WalletsUtils from '~/util/wallets';
|
||||
|
||||
const STEPS = {
|
||||
TYPE: { title: 'wallet type' },
|
||||
DETAILS: { title: 'wallet details' },
|
||||
DEPLOYMENT: { title: 'wallet deployment', waiting: true },
|
||||
INFO: { title: 'wallet informaton' }
|
||||
};
|
||||
|
||||
const STEPS_KEYS = Object.keys(STEPS);
|
||||
|
||||
export default class CreateWalletStore {
|
||||
@observable step = null;
|
||||
@observable rejected = false;
|
||||
|
||||
@observable deployState = null;
|
||||
@observable deployError = null;
|
||||
@observable deployed = false;
|
||||
|
||||
@observable txhash = null;
|
||||
|
||||
@ -49,44 +52,102 @@ export default class CreateWalletStore {
|
||||
name: '',
|
||||
description: ''
|
||||
};
|
||||
@observable walletType = 'MULTISIG';
|
||||
|
||||
@observable errors = {
|
||||
account: null,
|
||||
address: null,
|
||||
owners: null,
|
||||
required: null,
|
||||
daylimit: null,
|
||||
|
||||
name: ERRORS.invalidName
|
||||
name: null
|
||||
};
|
||||
|
||||
@computed get stage () {
|
||||
return STEPS_KEYS.findIndex((k) => k === this.step);
|
||||
return this.stepsKeys.findIndex((k) => k === this.step);
|
||||
}
|
||||
|
||||
@computed get hasErrors () {
|
||||
return !!Object.values(this.errors).find((e) => !!e);
|
||||
return !!Object.keys(this.errors)
|
||||
.filter((errorKey) => {
|
||||
if (this.walletType === 'WATCH') {
|
||||
return ['address', 'name'].includes(errorKey);
|
||||
}
|
||||
|
||||
steps = Object.values(STEPS).map((s) => s.title);
|
||||
waiting = Object.values(STEPS)
|
||||
return errorKey !== 'address';
|
||||
})
|
||||
.find((key) => !!this.errors[key]);
|
||||
}
|
||||
|
||||
@computed get stepsKeys () {
|
||||
return this.steps.map((s) => s.key);
|
||||
}
|
||||
|
||||
@computed get steps () {
|
||||
return Object
|
||||
.keys(STEPS)
|
||||
.map((key) => {
|
||||
return {
|
||||
...STEPS[key],
|
||||
key
|
||||
};
|
||||
})
|
||||
.filter((step) => {
|
||||
return (this.walletType !== 'WATCH' || step.key !== 'DEPLOYMENT');
|
||||
});
|
||||
}
|
||||
|
||||
@computed get waiting () {
|
||||
this.steps
|
||||
.map((s, idx) => ({ idx, waiting: s.waiting }))
|
||||
.filter((s) => s.waiting)
|
||||
.map((s) => s.idx);
|
||||
}
|
||||
|
||||
constructor (api, accounts) {
|
||||
this.api = api;
|
||||
|
||||
this.step = STEPS_KEYS[0];
|
||||
this.step = this.stepsKeys[0];
|
||||
this.wallet.account = Object.values(accounts)[0].address;
|
||||
this.validateWallet(this.wallet);
|
||||
}
|
||||
|
||||
@action onTypeChange = (type) => {
|
||||
this.walletType = type;
|
||||
this.validateWallet(this.wallet);
|
||||
}
|
||||
|
||||
@action onNext = () => {
|
||||
const stepIndex = this.stepsKeys.findIndex((k) => k === this.step) + 1;
|
||||
this.step = this.stepsKeys[stepIndex];
|
||||
}
|
||||
|
||||
@action onChange = (_wallet) => {
|
||||
const newWallet = Object.assign({}, this.wallet, _wallet);
|
||||
const { errors, wallet } = this.validateWallet(newWallet);
|
||||
this.validateWallet(newWallet);
|
||||
}
|
||||
|
||||
@action onAdd = () => {
|
||||
if (this.hasErrors) {
|
||||
return;
|
||||
}
|
||||
|
||||
const walletContract = new Contract(this.api, walletAbi).at(this.wallet.address);
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
WalletsUtils.fetchRequire(walletContract),
|
||||
WalletsUtils.fetchOwners(walletContract),
|
||||
WalletsUtils.fetchDailylimit(walletContract)
|
||||
])
|
||||
.then(([ require, owners, dailylimit ]) => {
|
||||
transaction(() => {
|
||||
this.wallet = wallet;
|
||||
this.errors = errors;
|
||||
this.wallet.owners = owners;
|
||||
this.wallet.required = require.toNumber();
|
||||
this.wallet.dailylimit = dailylimit.limit;
|
||||
});
|
||||
|
||||
return this.addWallet(this.wallet);
|
||||
});
|
||||
}
|
||||
|
||||
@ -97,7 +158,7 @@ export default class CreateWalletStore {
|
||||
|
||||
this.step = 'DEPLOYMENT';
|
||||
|
||||
const { account, owners, required, daylimit, name, description } = this.wallet;
|
||||
const { account, owners, required, daylimit } = this.wallet;
|
||||
|
||||
const options = {
|
||||
data: walletCode,
|
||||
@ -108,24 +169,9 @@ export default class CreateWalletStore {
|
||||
.newContract(walletAbi)
|
||||
.deploy(options, [ owners, required, daylimit ], this.onDeploymentState)
|
||||
.then((address) => {
|
||||
return Promise
|
||||
.all([
|
||||
this.api.parity.setAccountName(address, name),
|
||||
this.api.parity.setAccountMeta(address, {
|
||||
abi: walletAbi,
|
||||
wallet: true,
|
||||
timestamp: Date.now(),
|
||||
deleted: false,
|
||||
description,
|
||||
name
|
||||
})
|
||||
])
|
||||
.then(() => {
|
||||
transaction(() => {
|
||||
this.deployed = true;
|
||||
this.wallet.address = address;
|
||||
this.step = 'INFO';
|
||||
});
|
||||
});
|
||||
return this.addWallet(this.wallet);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.code === ERROR_CODES.REQUEST_REJECTED) {
|
||||
@ -138,6 +184,27 @@ export default class CreateWalletStore {
|
||||
});
|
||||
}
|
||||
|
||||
@action addWallet = (wallet) => {
|
||||
const { address, name, description } = wallet;
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
this.api.parity.setAccountName(address, name),
|
||||
this.api.parity.setAccountMeta(address, {
|
||||
abi: walletAbi,
|
||||
wallet: true,
|
||||
timestamp: Date.now(),
|
||||
deleted: false,
|
||||
description,
|
||||
name,
|
||||
tags: ['wallet']
|
||||
})
|
||||
])
|
||||
.then(() => {
|
||||
this.step = 'INFO';
|
||||
});
|
||||
}
|
||||
|
||||
onDeploymentState = (error, data) => {
|
||||
if (error) {
|
||||
return console.error('createWallet::onDeploymentState', error);
|
||||
@ -173,13 +240,15 @@ export default class CreateWalletStore {
|
||||
}
|
||||
}
|
||||
|
||||
validateWallet = (_wallet) => {
|
||||
@action validateWallet = (_wallet) => {
|
||||
const addressValidation = validateAddress(_wallet.address);
|
||||
const accountValidation = validateAddress(_wallet.account);
|
||||
const requiredValidation = validateUint(_wallet.required);
|
||||
const daylimitValidation = validateUint(_wallet.daylimit);
|
||||
const nameValidation = validateName(_wallet.name);
|
||||
|
||||
const errors = {
|
||||
address: addressValidation.addressError,
|
||||
account: accountValidation.addressError,
|
||||
required: requiredValidation.valueError,
|
||||
daylimit: daylimitValidation.valueError,
|
||||
@ -188,12 +257,16 @@ export default class CreateWalletStore {
|
||||
|
||||
const wallet = {
|
||||
..._wallet,
|
||||
address: addressValidation.address,
|
||||
account: accountValidation.address,
|
||||
required: requiredValidation.value,
|
||||
daylimit: daylimitValidation.value,
|
||||
name: nameValidation.name
|
||||
};
|
||||
|
||||
return { errors, wallet };
|
||||
transaction(() => {
|
||||
this.wallet = wallet;
|
||||
this.errors = errors;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import { ConfirmDialog, IdentityIcon, IdentityName, Input } from '~/ui';
|
||||
import { newError } from '../../redux/actions';
|
||||
import { newError } from '~/redux/actions';
|
||||
|
||||
import styles from './deleteAccount.css';
|
||||
|
||||
|
@ -17,7 +17,8 @@
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { MenuItem } from 'material-ui';
|
||||
|
||||
import { AddressSelect, Form, Input, InputAddressSelect, Select } from '~/ui';
|
||||
import { AddressSelect, Form, Input, Select, TypedInput } from '~/ui';
|
||||
import { parseAbiType } from '~/util/abi';
|
||||
|
||||
import styles from '../executeContract.css';
|
||||
|
||||
@ -74,7 +75,7 @@ export default class DetailsStep extends Component {
|
||||
|
||||
const functions = contract.functions
|
||||
.filter((func) => !func.constant)
|
||||
.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.sort((a, b) => (a.name || '').localeCompare(b.name || ''))
|
||||
.map((func) => {
|
||||
const params = (func.abi.inputs || [])
|
||||
.map((input, index) => {
|
||||
@ -125,56 +126,22 @@ export default class DetailsStep extends Component {
|
||||
}
|
||||
|
||||
return (func.abi.inputs || []).map((input, index) => {
|
||||
const onChange = (event, value) => onValueChange(event, index, value);
|
||||
const onSelect = (event, _index, value) => onValueChange(event, index, value);
|
||||
const onSubmit = (value) => onValueChange(null, index, value);
|
||||
const onChange = (value) => onValueChange(null, index, value);
|
||||
const label = `${input.name}: ${input.type}`;
|
||||
let inputbox;
|
||||
|
||||
switch (input.type) {
|
||||
case 'address':
|
||||
inputbox = (
|
||||
<InputAddressSelect
|
||||
return (
|
||||
<div
|
||||
key={ `${index}_${input.name || ''}` }
|
||||
className={ styles.funcparams }
|
||||
>
|
||||
<TypedInput
|
||||
label={ label }
|
||||
value={ values[index] }
|
||||
error={ valuesError[index] }
|
||||
onChange={ onChange }
|
||||
accounts={ accounts }
|
||||
editing
|
||||
label={ label }
|
||||
value={ values[index] }
|
||||
error={ valuesError[index] }
|
||||
onChange={ onChange } />
|
||||
);
|
||||
break;
|
||||
|
||||
case 'bool':
|
||||
const boolitems = ['false', 'true'].map((bool) => {
|
||||
return (
|
||||
<MenuItem
|
||||
key={ bool }
|
||||
value={ bool }
|
||||
label={ bool }>{ bool }</MenuItem>
|
||||
);
|
||||
});
|
||||
inputbox = (
|
||||
<Select
|
||||
label={ label }
|
||||
value={ values[index] ? 'true' : 'false' }
|
||||
error={ valuesError[index] }
|
||||
onChange={ onSelect }>{ boolitems }</Select>
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
inputbox = (
|
||||
<Input
|
||||
label={ label }
|
||||
value={ values[index] }
|
||||
error={ valuesError[index] }
|
||||
onSubmit={ onSubmit } />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ styles.funcparams } key={ index }>
|
||||
{ inputbox }
|
||||
param={ parseAbiType(input.type) }
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
@ -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 {
|
||||
<Button
|
||||
key='postTransaction'
|
||||
label='post transaction'
|
||||
disabled={ sending || hasError }
|
||||
disabled={ !!(sending || hasError) }
|
||||
icon={ <IdentityIcon address={ fromAddress } button /> }
|
||||
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({
|
||||
|
@ -15,7 +15,6 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import nullable from '../../../util/nullable-proptype';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { Checkbox } from 'material-ui';
|
||||
import InfoIcon from 'material-ui/svg-icons/action/info-outline';
|
||||
@ -24,6 +23,7 @@ import ErrorIcon from 'material-ui/svg-icons/navigation/close';
|
||||
|
||||
import { fromWei } from '~/api/util/wei';
|
||||
import { Form, Input } from '~/ui';
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import { termsOfService } from '../../../3rdparty/sms-verification';
|
||||
import styles from './gatherData.css';
|
||||
@ -32,8 +32,8 @@ export default class GatherData extends Component {
|
||||
static propTypes = {
|
||||
fee: React.PropTypes.instanceOf(BigNumber),
|
||||
isNumberValid: PropTypes.bool.isRequired,
|
||||
isVerified: nullable(PropTypes.bool.isRequired),
|
||||
hasRequested: nullable(PropTypes.bool.isRequired),
|
||||
isVerified: nullableProptype(PropTypes.bool.isRequired),
|
||||
hasRequested: nullableProptype(PropTypes.bool.isRequired),
|
||||
setNumber: PropTypes.func.isRequired,
|
||||
setConsentGiven: PropTypes.func.isRequired
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import nullable from '../../../util/nullable-proptype';
|
||||
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
import TxHash from '~/ui/TxHash';
|
||||
import {
|
||||
POSTING_CONFIRMATION, POSTED_CONFIRMATION
|
||||
@ -27,7 +27,7 @@ import styles from './sendConfirmation.css';
|
||||
export default class SendConfirmation extends Component {
|
||||
static propTypes = {
|
||||
step: PropTypes.any.isRequired,
|
||||
tx: nullable(PropTypes.any.isRequired)
|
||||
tx: nullableProptype(PropTypes.any.isRequired)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
@ -15,8 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import nullable from '../../../util/nullable-proptype';
|
||||
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
import TxHash from '~/ui/TxHash';
|
||||
import {
|
||||
POSTING_REQUEST, POSTED_REQUEST, REQUESTING_SMS
|
||||
@ -27,7 +27,7 @@ import styles from './sendRequest.css';
|
||||
export default class SendRequest extends Component {
|
||||
static propTypes = {
|
||||
step: PropTypes.any.isRequired,
|
||||
tx: nullable(PropTypes.any.isRequired)
|
||||
tx: nullableProptype(PropTypes.any.isRequired)
|
||||
}
|
||||
|
||||
render () {
|
||||
|
@ -17,11 +17,10 @@
|
||||
import BigNumber from 'bignumber.js';
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { Checkbox, MenuItem } from 'material-ui';
|
||||
|
||||
import { isEqual } from 'lodash';
|
||||
|
||||
import Form, { Input, InputAddressSelect, AddressSelect, Select } from '~/ui/Form';
|
||||
import nullableProptype from '~/util/nullable-proptype';
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import imageUnknown from '../../../../assets/images/contracts/unknown-64x64.png';
|
||||
import styles from '../transfer.css';
|
||||
@ -240,11 +239,7 @@ export default class Details extends Component {
|
||||
}
|
||||
|
||||
renderTokenSelect () {
|
||||
const { balance, images, tag, wallet } = this.props;
|
||||
|
||||
if (wallet) {
|
||||
return null;
|
||||
}
|
||||
const { balance, images, tag } = this.props;
|
||||
|
||||
return (
|
||||
<TokenSelect
|
||||
|
@ -16,10 +16,14 @@
|
||||
|
||||
import { observable, computed, action, transaction } from 'mobx';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { uniq } from 'lodash';
|
||||
|
||||
import { wallet as walletAbi } from '~/contracts/abi';
|
||||
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',
|
||||
@ -71,6 +75,9 @@ export default class TransferStore {
|
||||
gasLimit = null;
|
||||
onClose = null;
|
||||
|
||||
senders = null;
|
||||
sendersBalances = null;
|
||||
|
||||
isWallet = false;
|
||||
wallet = null;
|
||||
|
||||
@ -108,19 +115,22 @@ export default class TransferStore {
|
||||
constructor (api, props) {
|
||||
this.api = api;
|
||||
|
||||
const { account, balance, gasLimit, senders, onClose } = props;
|
||||
|
||||
const { account, balance, gasLimit, senders, onClose, newError, sendersBalances } = props;
|
||||
this.account = account;
|
||||
this.balance = balance;
|
||||
this.gasLimit = gasLimit;
|
||||
this.onClose = onClose;
|
||||
this.isWallet = account && account.wallet;
|
||||
this.newError = newError;
|
||||
|
||||
if (this.isWallet) {
|
||||
this.wallet = props.wallet;
|
||||
this.walletContract = new Contract(this.api, walletAbi);
|
||||
}
|
||||
|
||||
if (senders) {
|
||||
this.senders = senders;
|
||||
this.sendersBalances = sendersBalances;
|
||||
this.senderError = ERRORS.requireSender;
|
||||
}
|
||||
}
|
||||
@ -217,6 +227,10 @@ export default class TransferStore {
|
||||
this.txhash = txhash;
|
||||
this.busyState = 'Your transaction has been posted to the network';
|
||||
});
|
||||
|
||||
if (this.isWallet) {
|
||||
return this._attachWalletOperation(txhash);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.sending = false;
|
||||
@ -224,6 +238,34 @@ export default class TransferStore {
|
||||
});
|
||||
}
|
||||
|
||||
@action _attachWalletOperation = (txhash) => {
|
||||
let ethSubscriptionId = null;
|
||||
|
||||
return this.api.subscribe('eth_blockNumber', () => {
|
||||
this.api.eth
|
||||
.getTransactionReceipt(txhash)
|
||||
.then((tx) => {
|
||||
if (!tx) {
|
||||
return;
|
||||
}
|
||||
|
||||
const logs = this.walletContract.parseEventLogs(tx.logs);
|
||||
const operations = uniq(logs
|
||||
.filter((log) => log && log.params && log.params.operation)
|
||||
.map((log) => bytesToHex(log.params.operation.value)));
|
||||
|
||||
if (operations.length > 0) {
|
||||
this.operation = operations[0];
|
||||
}
|
||||
|
||||
this.api.unsubscribe(ethSubscriptionId);
|
||||
ethSubscriptionId = null;
|
||||
});
|
||||
}).then((subId) => {
|
||||
ethSubscriptionId = subId;
|
||||
});
|
||||
}
|
||||
|
||||
@action _onUpdateAll = (valueAll) => {
|
||||
this.valueAll = valueAll;
|
||||
this.recalculateGas();
|
||||
@ -355,38 +397,52 @@ export default class TransferStore {
|
||||
}
|
||||
|
||||
@action recalculate = () => {
|
||||
const { account, balance } = this;
|
||||
const { account } = this;
|
||||
|
||||
if (!account || !balance) {
|
||||
if (!account || !this.balance) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { gas, gasPrice, tag, valueAll, isEth } = this;
|
||||
const balance = this.senders
|
||||
? this.sendersBalances[this.sender]
|
||||
: this.balance;
|
||||
|
||||
if (!balance) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { gas, gasPrice, tag, valueAll, isEth, isWallet } = this;
|
||||
|
||||
const gasTotal = new BigNumber(gasPrice || 0).mul(new BigNumber(gas || 0));
|
||||
const balance_ = balance.tokens.find((b) => tag === b.token.tag);
|
||||
|
||||
const availableEth = new BigNumber(balance.tokens[0].value);
|
||||
const available = new BigNumber(balance_.value);
|
||||
const format = new BigNumber(balance_.token.format || 1);
|
||||
|
||||
const senderBalance = this.balance.tokens.find((b) => tag === b.token.tag);
|
||||
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;
|
||||
@ -409,26 +465,52 @@ export default class TransferStore {
|
||||
return this._getTransferMethod().postTransaction(options, values);
|
||||
}
|
||||
|
||||
estimateGas () {
|
||||
const { options, values } = this._getTransferParams(true);
|
||||
return this._getTransferMethod(true).estimateGas(options, values);
|
||||
_estimateGas (forceToken = false) {
|
||||
const { options, values } = this._getTransferParams(true, forceToken);
|
||||
return this._getTransferMethod(true, forceToken).estimateGas(options, values);
|
||||
}
|
||||
|
||||
_getTransferMethod (gas = false) {
|
||||
estimateGas () {
|
||||
if (this.isEth || !this.isWallet) {
|
||||
return this._estimateGas();
|
||||
}
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
this._estimateGas(true),
|
||||
this._estimateGas()
|
||||
])
|
||||
.then((results) => results[0].plus(results[1]));
|
||||
}
|
||||
|
||||
_getTransferMethod (gas = false, forceToken = false) {
|
||||
const { isEth, isWallet } = this;
|
||||
|
||||
if (isEth && !isWallet) {
|
||||
if (isEth && !isWallet && !forceToken) {
|
||||
return gas ? this.api.eth : this.api.parity;
|
||||
}
|
||||
|
||||
if (isWallet) {
|
||||
if (isWallet && !forceToken) {
|
||||
return this.wallet.instance.execute;
|
||||
}
|
||||
|
||||
return this.token.contract.instance.transfer;
|
||||
}
|
||||
|
||||
_getTransferParams (gas = false) {
|
||||
_getData (gas = false) {
|
||||
const { isEth, isWallet } = this;
|
||||
|
||||
if (!isWallet || isEth) {
|
||||
return this.data && this.data.length ? this.data : '';
|
||||
}
|
||||
|
||||
const func = this._getTransferMethod(gas, true);
|
||||
const { options, values } = this._getTransferParams(gas, true);
|
||||
|
||||
return this.token.contract.getCallData(func, options, values);
|
||||
}
|
||||
|
||||
_getTransferParams (gas = false, forceToken = false) {
|
||||
const { isEth, isWallet } = this;
|
||||
|
||||
const to = (isEth && !isWallet) ? this.recipient
|
||||
@ -446,23 +528,26 @@ export default class TransferStore {
|
||||
options.gas = MAX_GAS_ESTIMATION;
|
||||
}
|
||||
|
||||
if (isEth && !isWallet) {
|
||||
if (isEth && !isWallet && !forceToken) {
|
||||
options.value = this.api.util.toWei(this.value || 0);
|
||||
|
||||
if (this.data && this.data.length) {
|
||||
options.data = this.data;
|
||||
}
|
||||
options.data = this._getData(gas);
|
||||
|
||||
return { options, values: [] };
|
||||
}
|
||||
|
||||
const values = isWallet
|
||||
? [
|
||||
this.recipient,
|
||||
this.api.util.toWei(this.value || 0),
|
||||
this.data || ''
|
||||
]
|
||||
: [
|
||||
if (isWallet && !forceToken) {
|
||||
const to = isEth ? this.recipient : this.token.contract.address;
|
||||
const value = isEth ? this.api.util.toWei(this.value || 0) : new BigNumber(0);
|
||||
|
||||
const values = [
|
||||
to, value,
|
||||
this._getData(gas)
|
||||
];
|
||||
|
||||
return { options, values };
|
||||
}
|
||||
|
||||
const values = [
|
||||
this.recipient,
|
||||
new BigNumber(this.value || 0).mul(this.token.format).toFixed(0)
|
||||
];
|
||||
|
@ -18,6 +18,7 @@ import React, { Component, PropTypes } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { observer } from 'mobx-react';
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
|
||||
import ContentClear from 'material-ui/svg-icons/content/clear';
|
||||
@ -25,8 +26,8 @@ import NavigationArrowBack from 'material-ui/svg-icons/navigation/arrow-back';
|
||||
import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward';
|
||||
|
||||
import { newError } from '~/ui/Errors/actions';
|
||||
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
|
||||
import nullableProptype from '~/util/nullable-proptype';
|
||||
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash, Input } from '~/ui';
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import Details from './Details';
|
||||
import Extras from './Extras';
|
||||
@ -45,10 +46,10 @@ class Transfer extends Component {
|
||||
gasLimit: PropTypes.object.isRequired,
|
||||
images: PropTypes.object.isRequired,
|
||||
|
||||
account: PropTypes.object,
|
||||
senders: nullableProptype(PropTypes.object),
|
||||
sendersBalances: nullableProptype(PropTypes.object),
|
||||
account: PropTypes.object,
|
||||
balance: PropTypes.object,
|
||||
balances: PropTypes.object,
|
||||
wallet: PropTypes.object,
|
||||
onClose: PropTypes.func
|
||||
}
|
||||
@ -133,6 +134,25 @@ class Transfer extends Component {
|
||||
return (
|
||||
<CompletedStep>
|
||||
<TxHash hash={ txhash } />
|
||||
{
|
||||
this.store.operation
|
||||
? (
|
||||
<div>
|
||||
<br />
|
||||
<div>
|
||||
<p>This transaction needs confirmation from other owners.</p>
|
||||
<Input
|
||||
style={ { width: '50%', margin: '0 auto' } }
|
||||
value={ this.store.operation }
|
||||
label='operation hash'
|
||||
readOnly
|
||||
allowCopy
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
: null
|
||||
}
|
||||
</CompletedStep>
|
||||
);
|
||||
}
|
||||
@ -277,7 +297,8 @@ function mapStateToProps (initState, initProps) {
|
||||
|
||||
return (state) => {
|
||||
const { gasLimit } = state.nodeStatus;
|
||||
return { gasLimit, wallet, senders };
|
||||
const sendersBalances = senders ? pick(state.balances.balances, Object.keys(senders)) : null;
|
||||
return { gasLimit, wallet, senders, sendersBalances };
|
||||
};
|
||||
}
|
||||
|
||||
|
17
js/src/modals/WalletSettings/index.js
Normal file
17
js/src/modals/WalletSettings/index.js
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
export default from './walletSettings';
|
63
js/src/modals/WalletSettings/walletSettings.css
Normal file
63
js/src/modals/WalletSettings/walletSettings.css
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.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;
|
||||
}
|
||||
|
321
js/src/modals/WalletSettings/walletSettings.js
Normal file
321
js/src/modals/WalletSettings/walletSettings.js
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 (
|
||||
<Modal
|
||||
visible
|
||||
title='rejected'
|
||||
actions={ this.renderDialogActions() }
|
||||
>
|
||||
<BusyStep
|
||||
title='The modifications have been rejected'
|
||||
state='The wallet settings will not be modified. You can safely close this window.'
|
||||
/>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
visible
|
||||
actions={ this.renderDialogActions() }
|
||||
current={ stage }
|
||||
steps={ steps.map((s) => s.title) }
|
||||
waiting={ waiting }
|
||||
>
|
||||
{ this.renderPage() }
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
renderPage () {
|
||||
const { step } = this.store;
|
||||
|
||||
switch (step) {
|
||||
case 'SENDING':
|
||||
return (
|
||||
<BusyStep
|
||||
title='The modifications are currently being sent'
|
||||
state={ this.store.deployState }
|
||||
>
|
||||
{
|
||||
this.store.requests.map((req) => {
|
||||
const key = req.id;
|
||||
|
||||
if (req.txhash) {
|
||||
return (<TxHash key={ key } hash={ req.txhash } />);
|
||||
}
|
||||
|
||||
if (req.rejected) {
|
||||
return (<p key={ key }>The transaction #{parseInt(key, 16)} has been rejected</p>);
|
||||
}
|
||||
})
|
||||
}
|
||||
</BusyStep>
|
||||
);
|
||||
|
||||
case 'CONFIRMATION':
|
||||
const { changes } = this.store;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>You are about to make the following modifications</p>
|
||||
<div>
|
||||
{ this.renderChanges(changes) }
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
default:
|
||||
case 'EDIT':
|
||||
const { wallet, errors } = this.store;
|
||||
const { accounts, senders } = this.props;
|
||||
|
||||
return (
|
||||
<Form>
|
||||
<p>
|
||||
In order to edit this contract's settings, at
|
||||
least { this.store.initialWallet.require.toNumber() } owners have to
|
||||
send the very same modifications.
|
||||
Otherwise, no modification will be taken into account...
|
||||
</p>
|
||||
|
||||
<AddressSelect
|
||||
label='from account (wallet owner)'
|
||||
hint='send modifications as this owner'
|
||||
value={ wallet.sender }
|
||||
error={ errors.sender }
|
||||
onChange={ this.store.onSenderChange }
|
||||
accounts={ senders }
|
||||
/>
|
||||
|
||||
<TypedInput
|
||||
label='other wallet owners'
|
||||
value={ wallet.owners.slice() }
|
||||
onChange={ this.store.onOwnersChange }
|
||||
accounts={ accounts }
|
||||
param={ parseAbiType('address[]') }
|
||||
/>
|
||||
|
||||
<div className={ styles.splitInput }>
|
||||
<TypedInput
|
||||
label='required owners'
|
||||
hint='number of required owners to accept a transaction'
|
||||
value={ wallet.require }
|
||||
error={ errors.require }
|
||||
onChange={ this.store.onRequireChange }
|
||||
param={ parseAbiType('uint') }
|
||||
min={ 1 }
|
||||
max={ wallet.owners.length }
|
||||
/>
|
||||
|
||||
<TypedInput
|
||||
label='wallet day limit'
|
||||
hint='amount of ETH spendable without confirmations'
|
||||
value={ wallet.dailylimit }
|
||||
error={ errors.dailylimit }
|
||||
onChange={ this.store.onDailylimitChange }
|
||||
param={ parseAbiType('uint') }
|
||||
isEth
|
||||
/>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
renderChanges (changes) {
|
||||
return changes.map((change, index) => (
|
||||
<div key={ `${change.type}_${index}` }>
|
||||
{ this.renderChange(change) }
|
||||
</div>
|
||||
));
|
||||
}
|
||||
|
||||
renderChange (change) {
|
||||
const { accounts } = this.props;
|
||||
|
||||
switch (change.type) {
|
||||
case 'dailylimit':
|
||||
return (
|
||||
<div className={ styles.change }>
|
||||
<div className={ styles.label }>Change Daily Limit</div>
|
||||
<div>
|
||||
<span> from </span>
|
||||
<code> { fromWei(change.initial).toFormat() }</code>
|
||||
<span className={ styles.eth } />
|
||||
<span> to </span>
|
||||
<code> { fromWei(change.value).toFormat() }</code>
|
||||
<span className={ styles.eth } />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'require':
|
||||
return (
|
||||
<div className={ styles.change }>
|
||||
<div className={ styles.label }>Change Required Owners</div>
|
||||
<div>
|
||||
<span> from </span>
|
||||
<code> { change.initial.toNumber() }</code>
|
||||
<span> to </span>
|
||||
<code> { change.value.toNumber() }</code>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'add_owner':
|
||||
return (
|
||||
<div className={ [ styles.change, styles.add ].join(' ') }>
|
||||
<div className={ styles.label }>Add Owner</div>
|
||||
<div>
|
||||
<InputAddress
|
||||
disabled
|
||||
value={ change.value }
|
||||
accounts={ accounts }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'remove_owner':
|
||||
return (
|
||||
<div className={ [ styles.change, styles.remove ].join(' ') }>
|
||||
<div className={ styles.label }>Remove Owner</div>
|
||||
<div>
|
||||
<InputAddress
|
||||
disabled
|
||||
value={ change.value }
|
||||
accounts={ accounts }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
renderDialogActions () {
|
||||
const { onClose } = this.props;
|
||||
const { step, hasErrors, rejected, onNext, send, done } = this.store;
|
||||
|
||||
const cancelBtn = (
|
||||
<Button
|
||||
icon={ <ContentClear /> }
|
||||
label='Cancel'
|
||||
onClick={ onClose }
|
||||
/>
|
||||
);
|
||||
|
||||
const closeBtn = (
|
||||
<Button
|
||||
icon={ <ContentClear /> }
|
||||
label='Close'
|
||||
onClick={ onClose }
|
||||
/>
|
||||
);
|
||||
|
||||
const sendingBtn = (
|
||||
<Button
|
||||
icon={ <ActionDone /> }
|
||||
label='Sending...'
|
||||
disabled
|
||||
/>
|
||||
);
|
||||
|
||||
const nextBtn = (
|
||||
<Button
|
||||
icon={ <NavigationArrowForward /> }
|
||||
label='Next'
|
||||
onClick={ onNext }
|
||||
disabled={ hasErrors }
|
||||
/>
|
||||
);
|
||||
|
||||
const sendBtn = (
|
||||
<Button
|
||||
icon={ <NavigationArrowForward /> }
|
||||
label='Send'
|
||||
onClick={ send }
|
||||
disabled={ hasErrors }
|
||||
/>
|
||||
);
|
||||
|
||||
if (rejected) {
|
||||
return [ closeBtn ];
|
||||
}
|
||||
|
||||
switch (step) {
|
||||
case 'SENDING':
|
||||
return done ? [ closeBtn ] : [ closeBtn, sendingBtn ];
|
||||
|
||||
case 'CONFIRMATION':
|
||||
return [ cancelBtn, sendBtn ];
|
||||
|
||||
default:
|
||||
case 'TYPE':
|
||||
return [ cancelBtn, nextBtn ];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps (initState, initProps) {
|
||||
const { accountsInfo, accounts } = initState.personal;
|
||||
const { owners } = initProps.wallet;
|
||||
|
||||
const senders = pick(accounts, owners);
|
||||
|
||||
return () => {
|
||||
return { accounts: accountsInfo, senders };
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(WalletSettings);
|
306
js/src/modals/WalletSettings/walletSettingsStore.js
Normal file
306
js/src/modals/WalletSettings/walletSettingsStore.js
Normal file
@ -0,0 +1,306 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { observable, computed, action, transaction } from 'mobx';
|
||||
import BigNumber from 'bignumber.js';
|
||||
|
||||
import { validateUint, validateAddress } from '~/util/validation';
|
||||
import { DEFAULT_GAS, MAX_GAS_ESTIMATION } from '~/util/constants';
|
||||
import { ERROR_CODES } from '~/api/transport/error';
|
||||
|
||||
const STEPS = {
|
||||
EDIT: { title: 'wallet settings' },
|
||||
CONFIRMATION: { title: 'confirmation' },
|
||||
SENDING: { title: 'sending transaction', waiting: true }
|
||||
};
|
||||
|
||||
export default class WalletSettingsStore {
|
||||
@observable step = null;
|
||||
@observable requests = [];
|
||||
@observable deployState = '';
|
||||
@observable done = false;
|
||||
|
||||
@observable wallet = {
|
||||
owners: null,
|
||||
require: null,
|
||||
dailylimit: null,
|
||||
sender: ''
|
||||
};
|
||||
|
||||
@observable errors = {
|
||||
owners: null,
|
||||
require: null,
|
||||
dailylimit: null,
|
||||
sender: null
|
||||
};
|
||||
|
||||
@computed get stage () {
|
||||
return this.stepsKeys.findIndex((k) => k === this.step);
|
||||
}
|
||||
|
||||
@computed get hasErrors () {
|
||||
return !!Object.keys(this.errors).find((key) => !!this.errors[key]);
|
||||
}
|
||||
|
||||
@computed get stepsKeys () {
|
||||
return this.steps.map((s) => s.key);
|
||||
}
|
||||
|
||||
@computed get steps () {
|
||||
return Object
|
||||
.keys(STEPS)
|
||||
.map((key) => {
|
||||
return {
|
||||
...STEPS[key],
|
||||
key
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@computed get waiting () {
|
||||
this.steps
|
||||
.map((s, idx) => ({ idx, waiting: s.waiting }))
|
||||
.filter((s) => s.waiting)
|
||||
.map((s) => s.idx);
|
||||
}
|
||||
|
||||
get changes () {
|
||||
const changes = [];
|
||||
|
||||
const prevDailylimit = new BigNumber(this.initialWallet.dailylimit);
|
||||
const nextDailylimit = new BigNumber(this.wallet.dailylimit);
|
||||
|
||||
const prevRequire = new BigNumber(this.initialWallet.require);
|
||||
const nextRequire = new BigNumber(this.wallet.require);
|
||||
|
||||
if (!prevDailylimit.equals(nextDailylimit)) {
|
||||
changes.push({
|
||||
type: 'dailylimit',
|
||||
initial: prevDailylimit,
|
||||
value: nextDailylimit
|
||||
});
|
||||
}
|
||||
|
||||
if (!prevRequire.equals(nextRequire)) {
|
||||
changes.push({
|
||||
type: 'require',
|
||||
initial: prevRequire,
|
||||
value: nextRequire
|
||||
});
|
||||
}
|
||||
|
||||
const prevOwners = this.initialWallet.owners;
|
||||
const nextOwners = this.wallet.owners;
|
||||
|
||||
const ownersToRemove = prevOwners.filter((owner) => !nextOwners.includes(owner));
|
||||
const ownersToAdd = nextOwners.filter((owner) => !prevOwners.includes(owner));
|
||||
|
||||
ownersToRemove.forEach((owner) => {
|
||||
changes.push({
|
||||
type: 'remove_owner',
|
||||
value: owner
|
||||
});
|
||||
});
|
||||
|
||||
ownersToAdd.forEach((owner) => {
|
||||
changes.push({
|
||||
type: 'add_owner',
|
||||
value: owner
|
||||
});
|
||||
});
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
constructor (api, wallet) {
|
||||
this.api = api;
|
||||
this.step = this.stepsKeys[0];
|
||||
|
||||
this.walletInstance = wallet.instance;
|
||||
|
||||
this.initialWallet = {
|
||||
address: wallet.address,
|
||||
owners: wallet.owners,
|
||||
require: wallet.require,
|
||||
dailylimit: wallet.dailylimit.limit
|
||||
};
|
||||
|
||||
transaction(() => {
|
||||
this.wallet.owners = wallet.owners;
|
||||
this.wallet.require = wallet.require;
|
||||
this.wallet.dailylimit = wallet.dailylimit.limit;
|
||||
|
||||
this.validateWallet(this.wallet);
|
||||
});
|
||||
}
|
||||
|
||||
@action onNext = () => {
|
||||
const stepIndex = this.stepsKeys.findIndex((k) => k === this.step) + 1;
|
||||
this.step = this.stepsKeys[stepIndex];
|
||||
}
|
||||
|
||||
@action onChange = (_wallet) => {
|
||||
const newWallet = Object.assign({}, this.wallet, _wallet);
|
||||
this.validateWallet(newWallet);
|
||||
}
|
||||
|
||||
@action onOwnersChange = (owners) => {
|
||||
this.onChange({ owners });
|
||||
}
|
||||
|
||||
@action onRequireChange = (require) => {
|
||||
this.onChange({ require });
|
||||
}
|
||||
|
||||
@action onSenderChange = (_, sender) => {
|
||||
this.onChange({ sender });
|
||||
}
|
||||
|
||||
@action onDailylimitChange = (dailylimit) => {
|
||||
this.onChange({ dailylimit });
|
||||
}
|
||||
|
||||
@action send = () => {
|
||||
const changes = this.changes;
|
||||
const walletInstance = this.walletInstance;
|
||||
this.step = 'SENDING';
|
||||
|
||||
this.onTransactionsState('postTransaction');
|
||||
Promise
|
||||
.all(changes.map((change) => this.sendChange(change, walletInstance)))
|
||||
.then((requestIds) => {
|
||||
this.onTransactionsState('checkRequest');
|
||||
this.requests = requestIds.map((id) => ({ id, rejected: false, txhash: null }));
|
||||
|
||||
return Promise
|
||||
.all(requestIds.map((id) => {
|
||||
return this.api
|
||||
.pollMethod('parity_checkRequest', id)
|
||||
.then((txhash) => {
|
||||
const index = this.requests.findIndex((r) => r.id === id);
|
||||
this.requests[index].txhash = txhash;
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e.code === ERROR_CODES.REQUEST_REJECTED) {
|
||||
const index = this.requests.findIndex((r) => r.id === id);
|
||||
this.requests[index].rejected = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
throw e;
|
||||
});
|
||||
}));
|
||||
})
|
||||
.then(() => {
|
||||
this.done = true;
|
||||
this.onTransactionsState('completed');
|
||||
});
|
||||
}
|
||||
|
||||
@action sendChange = (change, walletInstance) => {
|
||||
const { method, values } = this.getChangeMethod(change, walletInstance);
|
||||
|
||||
const options = {
|
||||
from: this.wallet.sender,
|
||||
to: this.initialWallet.address,
|
||||
gas: MAX_GAS_ESTIMATION
|
||||
};
|
||||
|
||||
return method
|
||||
.estimateGas(options, values)
|
||||
.then((gasEst) => {
|
||||
let gas = gasEst;
|
||||
|
||||
if (gas.gt(DEFAULT_GAS)) {
|
||||
gas = gas.mul(1.2);
|
||||
}
|
||||
options.gas = gas;
|
||||
|
||||
return method.postTransaction(options, values);
|
||||
});
|
||||
}
|
||||
|
||||
getChangeMethod = (change, walletInstance) => {
|
||||
if (change.type === 'require') {
|
||||
return {
|
||||
method: walletInstance.changeRequirement,
|
||||
values: [ change.value ]
|
||||
};
|
||||
}
|
||||
|
||||
if (change.type === 'dailylimit') {
|
||||
return {
|
||||
method: walletInstance.setDailyLimit,
|
||||
values: [ change.value ]
|
||||
};
|
||||
}
|
||||
|
||||
if (change.type === 'add_owner') {
|
||||
return {
|
||||
method: walletInstance.addOwner,
|
||||
values: [ change.value ]
|
||||
};
|
||||
}
|
||||
|
||||
if (change.type === 'remove_owner') {
|
||||
return {
|
||||
method: walletInstance.removeOwner,
|
||||
values: [ change.value ]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@action onTransactionsState = (state) => {
|
||||
switch (state) {
|
||||
case 'estimateGas':
|
||||
case 'postTransaction':
|
||||
this.deployState = 'Preparing transaction for network transmission';
|
||||
return;
|
||||
|
||||
case 'checkRequest':
|
||||
this.deployState = 'Waiting for confirmation of the transaction in the Parity Secure Signer';
|
||||
return;
|
||||
|
||||
case 'completed':
|
||||
this.deployState = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@action validateWallet = (_wallet) => {
|
||||
const senderValidation = validateAddress(_wallet.sender);
|
||||
const requireValidation = validateUint(_wallet.require);
|
||||
const dailylimitValidation = validateUint(_wallet.dailylimit);
|
||||
|
||||
const errors = {
|
||||
sender: senderValidation.addressError,
|
||||
require: requireValidation.valueError,
|
||||
dailylimit: dailylimitValidation.valueError
|
||||
};
|
||||
|
||||
const wallet = {
|
||||
..._wallet,
|
||||
sender: senderValidation.address,
|
||||
require: requireValidation.value,
|
||||
dailylimit: dailylimitValidation.value
|
||||
};
|
||||
|
||||
transaction(() => {
|
||||
this.wallet = wallet;
|
||||
this.errors = errors;
|
||||
});
|
||||
}
|
||||
}
|
@ -29,6 +29,7 @@ import Transfer from './Transfer';
|
||||
import PasswordManager from './PasswordManager';
|
||||
import SaveContract from './SaveContract';
|
||||
import LoadContract from './LoadContract';
|
||||
import WalletSettings from './WalletSettings';
|
||||
|
||||
export {
|
||||
AddAddress,
|
||||
@ -45,5 +46,6 @@ export {
|
||||
Transfer,
|
||||
PasswordManager,
|
||||
LoadContract,
|
||||
SaveContract
|
||||
SaveContract,
|
||||
WalletSettings
|
||||
};
|
||||
|
@ -113,7 +113,7 @@ export function fetchTokens (_tokenIds) {
|
||||
export function fetchBalances (_addresses) {
|
||||
return (dispatch, getState) => {
|
||||
const { api, personal } = getState();
|
||||
const { visibleAccounts } = personal;
|
||||
const { visibleAccounts, accounts } = personal;
|
||||
|
||||
const addresses = uniq(_addresses || visibleAccounts || []);
|
||||
|
||||
@ -123,12 +123,14 @@ export function fetchBalances (_addresses) {
|
||||
|
||||
const fullFetch = addresses.length === 1;
|
||||
|
||||
const fetchedAddresses = uniq(addresses.concat(Object.keys(accounts)));
|
||||
|
||||
return Promise
|
||||
.all(addresses.map((addr) => fetchAccount(addr, api, fullFetch)))
|
||||
.all(fetchedAddresses.map((addr) => fetchAccount(addr, api, fullFetch)))
|
||||
.then((accountsBalances) => {
|
||||
const balances = {};
|
||||
|
||||
addresses.forEach((addr, idx) => {
|
||||
fetchedAddresses.forEach((addr, idx) => {
|
||||
balances[addr] = accountsBalances[idx];
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
|
@ -23,6 +23,7 @@ export default class Personal {
|
||||
}
|
||||
|
||||
start () {
|
||||
this._removeDeleted();
|
||||
this._subscribeAccountsInfo();
|
||||
}
|
||||
|
||||
@ -40,4 +41,29 @@ export default class Personal {
|
||||
console.log('personal._subscribeAccountsInfo', 'subscriptionId', subscriptionId);
|
||||
});
|
||||
}
|
||||
|
||||
_removeDeleted () {
|
||||
this._api.parity
|
||||
.accountsInfo()
|
||||
.then((accountsInfo) => {
|
||||
return Promise.all(
|
||||
Object
|
||||
.keys(accountsInfo)
|
||||
.filter((address) => {
|
||||
const account = accountsInfo[address];
|
||||
|
||||
return !account.uuid && account.meta.deleted;
|
||||
})
|
||||
.map((address) => this._api.parity.removeAddress(address))
|
||||
);
|
||||
})
|
||||
.then((results) => {
|
||||
if (results.length) {
|
||||
console.log(`Removed ${results.length} previously marked addresses`);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.warn('removeDeleted', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ export function personalAccountsInfo (accountsInfo) {
|
||||
|
||||
Object.keys(accountsInfo || {})
|
||||
.map((address) => Object.assign({}, accountsInfo[address], { address }))
|
||||
.filter((account) => !account.meta.deleted)
|
||||
.filter((account) => account.uuid || !account.meta.deleted)
|
||||
.forEach((account) => {
|
||||
if (account.uuid) {
|
||||
accounts[account.address] = account;
|
||||
|
@ -14,16 +14,18 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { isEqual, uniq, range } from 'lodash';
|
||||
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 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 { ERROR_CODES } from '~/api/transport/error';
|
||||
import { MAX_GAS_ESTIMATION } from '../../util/constants';
|
||||
|
||||
import { newError } from '../../ui/Errors/actions';
|
||||
import WalletsUtils from '~/util/wallets';
|
||||
|
||||
import { newError } from '~/ui/Errors/actions';
|
||||
|
||||
const UPDATE_OWNERS = 'owners';
|
||||
const UPDATE_REQUIRE = 'require';
|
||||
@ -56,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) => {
|
||||
@ -226,7 +228,7 @@ function fetchWalletInfo (contract, update, getState) {
|
||||
const owners = ownersUpdate && ownersUpdate.value || null;
|
||||
const transactions = transactionsUpdate && transactionsUpdate.value || null;
|
||||
|
||||
return fetchWalletConfirmations(contract, owners, transactions, getState)
|
||||
return fetchWalletConfirmations(contract, update[UPDATE_CONFIRMATIONS], owners, transactions, getState)
|
||||
.then((update) => {
|
||||
updates.push(update);
|
||||
return updates;
|
||||
@ -247,58 +249,9 @@ function fetchWalletInfo (contract, update, getState) {
|
||||
}
|
||||
|
||||
function fetchWalletTransactions (contract) {
|
||||
const walletInstance = contract.instance;
|
||||
const signatures = {
|
||||
single: toHex(walletInstance.SingleTransact.signature),
|
||||
multi: toHex(walletInstance.MultiTransact.signature),
|
||||
deposit: toHex(walletInstance.Deposit.signature)
|
||||
};
|
||||
|
||||
return contract
|
||||
.getAllLogs({
|
||||
topics: [ [ signatures.single, signatures.multi, signatures.deposit ] ]
|
||||
})
|
||||
.then((logs) => {
|
||||
return logs.sort((logA, logB) => {
|
||||
const comp = logB.blockNumber.comparedTo(logA.blockNumber);
|
||||
|
||||
if (comp !== 0) {
|
||||
return comp;
|
||||
}
|
||||
|
||||
return logB.transactionIndex.comparedTo(logA.transactionIndex);
|
||||
});
|
||||
})
|
||||
.then((logs) => {
|
||||
const transactions = logs.map((log) => {
|
||||
const signature = toHex(log.topics[0]);
|
||||
|
||||
const value = log.params.value.value;
|
||||
const from = signature === signatures.deposit
|
||||
? log.params['_from'].value
|
||||
: contract.address;
|
||||
|
||||
const to = signature === signatures.deposit
|
||||
? contract.address
|
||||
: log.params.to.value;
|
||||
|
||||
const transaction = {
|
||||
transactionHash: log.transactionHash,
|
||||
blockNumber: log.blockNumber,
|
||||
from, to, value
|
||||
};
|
||||
|
||||
if (log.params.operation) {
|
||||
transaction.operation = bytesToHex(log.params.operation.value);
|
||||
}
|
||||
|
||||
if (log.params.data) {
|
||||
transaction.data = log.params.data.value;
|
||||
}
|
||||
|
||||
return transaction;
|
||||
});
|
||||
|
||||
return WalletsUtils
|
||||
.fetchTransactions(contract)
|
||||
.then((transactions) => {
|
||||
return {
|
||||
key: UPDATE_TRANSACTIONS,
|
||||
value: transactions
|
||||
@ -307,13 +260,8 @@ function fetchWalletTransactions (contract) {
|
||||
}
|
||||
|
||||
function fetchWalletOwners (contract) {
|
||||
const walletInstance = contract.instance;
|
||||
|
||||
return walletInstance
|
||||
.m_numOwners.call()
|
||||
.then((mNumOwners) => {
|
||||
return Promise.all(range(mNumOwners.toNumber()).map((idx) => walletInstance.getOwner.call({}, [ idx ])));
|
||||
})
|
||||
return WalletsUtils
|
||||
.fetchOwners(contract)
|
||||
.then((value) => {
|
||||
return {
|
||||
key: UPDATE_OWNERS,
|
||||
@ -323,10 +271,8 @@ function fetchWalletOwners (contract) {
|
||||
}
|
||||
|
||||
function fetchWalletRequire (contract) {
|
||||
const walletInstance = contract.instance;
|
||||
|
||||
return walletInstance
|
||||
.m_required.call()
|
||||
return WalletsUtils
|
||||
.fetchRequire(contract)
|
||||
.then((value) => {
|
||||
return {
|
||||
key: UPDATE_REQUIRE,
|
||||
@ -336,37 +282,47 @@ function fetchWalletRequire (contract) {
|
||||
}
|
||||
|
||||
function fetchWalletDailylimit (contract) {
|
||||
const walletInstance = contract.instance;
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
walletInstance.m_dailyLimit.call(),
|
||||
walletInstance.m_spentToday.call(),
|
||||
walletInstance.m_lastDay.call()
|
||||
])
|
||||
.then((values) => {
|
||||
return WalletsUtils
|
||||
.fetchDailylimit(contract)
|
||||
.then((value) => {
|
||||
return {
|
||||
key: UPDATE_DAILYLIMIT,
|
||||
value: {
|
||||
limit: values[0],
|
||||
spent: values[1],
|
||||
last: values[2]
|
||||
}
|
||||
value
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function fetchWalletConfirmations (contract, _owners = null, _transactions = null, getState) {
|
||||
function fetchWalletConfirmations (contract, _operations, _owners = null, _transactions = null, getState) {
|
||||
const walletInstance = contract.instance;
|
||||
|
||||
const wallet = getState().wallet.wallets[contract.address];
|
||||
|
||||
const owners = _owners || (wallet && wallet.owners) || null;
|
||||
const transactions = _transactions || (wallet && wallet.transactions) || null;
|
||||
// Full load if no operations given, or if the one given aren't loaded yet
|
||||
const fullLoad = !Array.isArray(_operations) || _operations
|
||||
.filter((op) => !wallet.confirmations.find((conf) => conf.operation === op))
|
||||
.length > 0;
|
||||
|
||||
return walletInstance
|
||||
let promise;
|
||||
|
||||
if (fullLoad) {
|
||||
promise = walletInstance
|
||||
.ConfirmationNeeded
|
||||
.getAllLogs()
|
||||
.then((logs) => {
|
||||
return logs.map((log) => ({
|
||||
initiator: log.params.initiator.value,
|
||||
to: log.params.to.value,
|
||||
data: log.params.data.value,
|
||||
value: log.params.value.value,
|
||||
operation: bytesToHex(log.params.operation.value),
|
||||
transactionIndex: log.transactionIndex,
|
||||
transactionHash: log.transactionHash,
|
||||
blockNumber: log.blockNumber,
|
||||
confirmedBy: []
|
||||
}));
|
||||
})
|
||||
.then((logs) => {
|
||||
return logs.sort((logA, logB) => {
|
||||
const comp = logA.blockNumber.comparedTo(logB.blockNumber);
|
||||
@ -378,23 +334,13 @@ function fetchWalletConfirmations (contract, _owners = null, _transactions = nul
|
||||
return logA.transactionIndex.comparedTo(logB.transactionIndex);
|
||||
});
|
||||
})
|
||||
.then((logs) => {
|
||||
return logs.map((log) => ({
|
||||
initiator: log.params.initiator.value,
|
||||
to: log.params.to.value,
|
||||
data: log.params.data.value,
|
||||
value: log.params.value.value,
|
||||
operation: bytesToHex(log.params.operation.value),
|
||||
transactionHash: log.transactionHash,
|
||||
blockNumber: log.blockNumber,
|
||||
confirmedBy: []
|
||||
}));
|
||||
})
|
||||
.then((confirmations) => {
|
||||
if (confirmations.length === 0) {
|
||||
return confirmations;
|
||||
}
|
||||
|
||||
// Only fetch confirmations for operations not
|
||||
// yet confirmed (ie. not yet a transaction)
|
||||
if (transactions) {
|
||||
const operations = transactions
|
||||
.filter((t) => t.operation)
|
||||
@ -406,27 +352,53 @@ function fetchWalletConfirmations (contract, _owners = null, _transactions = nul
|
||||
}
|
||||
|
||||
return confirmations;
|
||||
})
|
||||
});
|
||||
} else {
|
||||
const { confirmations } = wallet;
|
||||
const nextConfirmations = confirmations
|
||||
.filter((conf) => _operations.includes(conf.operation));
|
||||
|
||||
promise = Promise.resolve(nextConfirmations);
|
||||
}
|
||||
|
||||
return promise
|
||||
.then((confirmations) => {
|
||||
if (confirmations.length === 0) {
|
||||
return confirmations;
|
||||
}
|
||||
|
||||
const operations = confirmations.map((conf) => conf.operation);
|
||||
const uniqConfirmations = Object.values(
|
||||
confirmations.reduce((confirmations, confirmation) => {
|
||||
confirmations[confirmation.operation] = confirmation;
|
||||
return confirmations;
|
||||
}, {})
|
||||
);
|
||||
|
||||
const operations = uniqConfirmations.map((conf) => conf.operation);
|
||||
|
||||
return Promise
|
||||
.all(operations.map((op) => fetchOperationConfirmations(contract, op, owners)))
|
||||
.then((confirmedBys) => {
|
||||
confirmations.forEach((_, index) => {
|
||||
confirmations[index].confirmedBy = confirmedBys[index];
|
||||
uniqConfirmations.forEach((_, index) => {
|
||||
uniqConfirmations[index].confirmedBy = confirmedBys[index];
|
||||
});
|
||||
|
||||
return confirmations;
|
||||
return uniqConfirmations;
|
||||
});
|
||||
})
|
||||
.then((confirmations) => {
|
||||
const prevConfirmations = wallet.confirmations || [];
|
||||
const nextConfirmations = prevConfirmations
|
||||
.filter((conA) => !confirmations.find((conB) => conB.operation === conA.operation))
|
||||
.concat(confirmations)
|
||||
.map((conf) => ({
|
||||
...conf,
|
||||
pending: false
|
||||
}));
|
||||
|
||||
return {
|
||||
key: UPDATE_CONFIRMATIONS,
|
||||
value: confirmations
|
||||
value: nextConfirmations
|
||||
};
|
||||
});
|
||||
}
|
||||
@ -481,7 +453,10 @@ function parseLogs (logs) {
|
||||
logs.forEach((log) => {
|
||||
const { address, topics } = log;
|
||||
const eventSignature = toHex(topics[0]);
|
||||
const prev = updates[address] || { address };
|
||||
const prev = updates[address] || {
|
||||
[ UPDATE_DAILYLIMIT ]: true,
|
||||
address
|
||||
};
|
||||
|
||||
switch (eventSignature) {
|
||||
case signatures.OwnerChanged:
|
||||
@ -500,16 +475,18 @@ function parseLogs (logs) {
|
||||
};
|
||||
return;
|
||||
|
||||
case signatures.ConfirmationNeeded:
|
||||
case signatures.Confirmation:
|
||||
case signatures.Revoke:
|
||||
const operation = log.params.operation.value;
|
||||
const operation = bytesToHex(log.params.operation.value);
|
||||
|
||||
updates[address] = {
|
||||
...prev,
|
||||
[ UPDATE_CONFIRMATIONS ]: uniq(
|
||||
(prev.operations || []).concat(operation)
|
||||
(prev[UPDATE_CONFIRMATIONS] || []).concat(operation)
|
||||
)
|
||||
};
|
||||
|
||||
return;
|
||||
|
||||
case signatures.Deposit:
|
||||
@ -520,17 +497,6 @@ function parseLogs (logs) {
|
||||
[ UPDATE_TRANSACTIONS ]: true
|
||||
};
|
||||
return;
|
||||
|
||||
case signatures.ConfirmationNeeded:
|
||||
const op = log.params.operation.value;
|
||||
|
||||
updates[address] = {
|
||||
...prev,
|
||||
[ UPDATE_CONFIRMATIONS ]: uniq(
|
||||
(prev.operations || []).concat(op)
|
||||
)
|
||||
};
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1,7 +1,25 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import ActionDone from 'material-ui/svg-icons/action/done';
|
||||
import ContentClear from 'material-ui/svg-icons/content/clear';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import Button from '../Button';
|
||||
import Modal from '../Modal';
|
||||
|
||||
@ -15,9 +33,7 @@ export default class ConfirmDialog extends Component {
|
||||
iconDeny: PropTypes.node,
|
||||
labelConfirm: PropTypes.string,
|
||||
labelDeny: PropTypes.string,
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.node, PropTypes.string
|
||||
]).isRequired,
|
||||
title: nodeOrStringProptype().isRequired,
|
||||
visible: PropTypes.bool.isRequired,
|
||||
onConfirm: PropTypes.func.isRequired,
|
||||
onDeny: PropTypes.func.isRequired
|
||||
|
@ -16,17 +16,15 @@
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import styles from './title.css';
|
||||
|
||||
export default class Title extends Component {
|
||||
static propTypes = {
|
||||
className: PropTypes.string,
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.string, PropTypes.node
|
||||
]),
|
||||
byline: PropTypes.oneOfType([
|
||||
PropTypes.string, PropTypes.node
|
||||
])
|
||||
title: nodeOrStringProptype(),
|
||||
byline: nodeOrStringProptype()
|
||||
}
|
||||
|
||||
state = {
|
||||
|
@ -17,6 +17,8 @@
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { Card } from 'material-ui/Card';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import Title from './Title';
|
||||
|
||||
import styles from './container.css';
|
||||
@ -28,9 +30,7 @@ export default class Container extends Component {
|
||||
compact: PropTypes.bool,
|
||||
light: PropTypes.bool,
|
||||
style: PropTypes.object,
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.string, PropTypes.node
|
||||
])
|
||||
title: nodeOrStringProptype()
|
||||
}
|
||||
|
||||
render () {
|
||||
|
@ -20,5 +20,14 @@
|
||||
}
|
||||
|
||||
.data {
|
||||
flex: 1;
|
||||
font-family: monospace;
|
||||
padding: 0 0.5em;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
}
|
||||
|
@ -80,7 +80,13 @@ class CopyToClipboard extends Component {
|
||||
|
||||
onCopy = () => {
|
||||
const { data, onCopy, cooldown, showSnackbar } = this.props;
|
||||
const message = (<div>copied <code className={ styles.data }>{ data }</code> to clipboard</div>);
|
||||
const message = (
|
||||
<div className={ styles.container }>
|
||||
<span>copied </span>
|
||||
<code className={ styles.data }> { data } </code>
|
||||
<span> to clipboard</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
this.setState({
|
||||
copied: true,
|
||||
|
@ -170,7 +170,7 @@ export default class AddressSelect extends Component {
|
||||
handleFilter = (searchText, name, item) => {
|
||||
const { address } = item;
|
||||
const entry = this.state.entries[address];
|
||||
const lowCaseSearch = searchText.toLowerCase();
|
||||
const lowCaseSearch = (searchText || '').toLowerCase();
|
||||
|
||||
return [entry.name, entry.address]
|
||||
.some(text => text.toLowerCase().indexOf(lowCaseSearch) !== -1);
|
||||
|
@ -120,7 +120,7 @@ export default class AutoComplete extends Component {
|
||||
switch (keycode(event)) {
|
||||
case 'down':
|
||||
const { menu } = muiAutocomplete.refs;
|
||||
menu.handleKeyDown(event);
|
||||
menu && menu.handleKeyDown(event);
|
||||
this.setState({ fakeBlur: true });
|
||||
break;
|
||||
|
||||
@ -133,7 +133,7 @@ export default class AutoComplete extends Component {
|
||||
const e = new CustomEvent('down');
|
||||
e.which = 40;
|
||||
|
||||
muiAutocomplete.handleKeyDown(e);
|
||||
muiAutocomplete && muiAutocomplete.handleKeyDown(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ export default class Input extends Component {
|
||||
PropTypes.number, PropTypes.string
|
||||
]),
|
||||
min: PropTypes.any,
|
||||
max: PropTypes.any
|
||||
max: PropTypes.any,
|
||||
style: PropTypes.object
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@ -74,7 +75,8 @@ export default class Input extends Component {
|
||||
readOnly: false,
|
||||
allowCopy: false,
|
||||
hideUnderline: false,
|
||||
floatCopy: false
|
||||
floatCopy: false,
|
||||
style: {}
|
||||
}
|
||||
|
||||
state = {
|
||||
@ -89,7 +91,8 @@ export default class Input extends Component {
|
||||
|
||||
render () {
|
||||
const { value } = this.state;
|
||||
const { children, className, hideUnderline, disabled, error, label, hint, multiLine, rows, type, min, max } = this.props;
|
||||
const { children, className, hideUnderline, disabled, error, label } = this.props;
|
||||
const { hint, multiLine, rows, type, min, max, style } = this.props;
|
||||
|
||||
const readOnly = this.props.readOnly || disabled;
|
||||
|
||||
@ -105,7 +108,7 @@ export default class Input extends Component {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ styles.container }>
|
||||
<div className={ styles.container } style={ style }>
|
||||
{ this.renderCopyButton() }
|
||||
<TextField
|
||||
autoComplete='off'
|
||||
|
@ -53,7 +53,6 @@ class InputAddress extends Component {
|
||||
const { small, allowCopy, hideUnderline, onSubmit, accountsInfo, tokens } = this.props;
|
||||
|
||||
const account = accountsInfo[value] || tokens[value];
|
||||
const hasAccount = account && !(account.meta && account.meta.deleted);
|
||||
|
||||
const icon = this.renderIcon();
|
||||
|
||||
@ -74,7 +73,7 @@ class InputAddress extends Component {
|
||||
label={ label }
|
||||
hint={ hint }
|
||||
error={ error }
|
||||
value={ text && hasAccount ? account.name : value }
|
||||
value={ text && account ? account.name : value }
|
||||
onChange={ this.handleInputChange }
|
||||
onSubmit={ onSubmit }
|
||||
allowCopy={ allowCopy && (disabled ? value : false) }
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import Input from '../Input';
|
||||
|
||||
import styles from './inputInline.css';
|
||||
@ -33,9 +35,7 @@ export default class InputInline extends Component {
|
||||
value: PropTypes.oneOfType([
|
||||
PropTypes.number, PropTypes.string
|
||||
]),
|
||||
static: PropTypes.oneOfType([
|
||||
PropTypes.node, PropTypes.string
|
||||
])
|
||||
static: nodeOrStringProptype()
|
||||
}
|
||||
|
||||
state = {
|
||||
|
@ -37,7 +37,10 @@ export default class RadioButtons extends Component {
|
||||
render () {
|
||||
const { value, values } = this.props;
|
||||
|
||||
const index = parseInt(value);
|
||||
const index = Number.isNaN(parseInt(value))
|
||||
? values.findIndex((val) => val.key === value)
|
||||
: parseInt(value);
|
||||
|
||||
const selectedValue = typeof value !== 'object' ? values[index] : value;
|
||||
const key = this.getKey(selectedValue, index);
|
||||
|
||||
|
@ -29,3 +29,30 @@
|
||||
position: relative;
|
||||
}
|
||||
}
|
||||
|
||||
.ethInput {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
|
||||
.input {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
right: 1.5em;
|
||||
bottom: 1em;
|
||||
font-size: 0.85em;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle {
|
||||
margin-bottom: 0.5em;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { MenuItem } from 'material-ui';
|
||||
import { MenuItem, Toggle } from 'material-ui';
|
||||
import { range } from 'lodash';
|
||||
|
||||
import IconButton from 'material-ui/IconButton';
|
||||
@ -26,7 +26,8 @@ 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 { ABI_TYPES } from '~/util/abi';
|
||||
import { fromWei, toWei } from '~/api/util/wei';
|
||||
|
||||
import styles from './typedInput.css';
|
||||
|
||||
@ -40,11 +41,31 @@ export default class TypedInput extends Component {
|
||||
error: PropTypes.any,
|
||||
value: PropTypes.any,
|
||||
label: PropTypes.string,
|
||||
hint: PropTypes.string
|
||||
hint: PropTypes.string,
|
||||
min: PropTypes.number,
|
||||
max: PropTypes.number,
|
||||
isEth: PropTypes.bool
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
min: null,
|
||||
max: null,
|
||||
isEth: false
|
||||
};
|
||||
|
||||
state = {
|
||||
isEth: true,
|
||||
ethValue: 0
|
||||
};
|
||||
|
||||
componentDidMount () {
|
||||
if (this.props.isEth && this.props.value) {
|
||||
this.setState({ ethValue: fromWei(this.props.value) });
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { param } = this.props;
|
||||
const { param, isEth } = this.props;
|
||||
const { type } = param;
|
||||
|
||||
if (type === ABI_TYPES.ARRAY) {
|
||||
@ -80,6 +101,10 @@ export default class TypedInput extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
if (isEth) {
|
||||
return this.renderEth();
|
||||
}
|
||||
|
||||
return this.renderType(type);
|
||||
}
|
||||
|
||||
@ -90,16 +115,22 @@ export default class TypedInput extends Component {
|
||||
};
|
||||
|
||||
const style = {
|
||||
width: 32,
|
||||
height: 32,
|
||||
width: 24,
|
||||
height: 24,
|
||||
padding: 0
|
||||
};
|
||||
|
||||
const plusStyle = {
|
||||
...style,
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.25)',
|
||||
borderRadius: '50%'
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={ { marginTop: '0.75em' } }>
|
||||
<IconButton
|
||||
iconStyle={ iconStyle }
|
||||
style={ style }
|
||||
style={ plusStyle }
|
||||
onTouchTap={ this.onAddField }
|
||||
>
|
||||
<AddIcon />
|
||||
@ -144,18 +175,46 @@ export default class TypedInput extends Component {
|
||||
return this.renderDefault();
|
||||
}
|
||||
|
||||
renderNumber () {
|
||||
const { label, value, error, param, hint } = this.props;
|
||||
renderEth () {
|
||||
const { ethValue } = this.state;
|
||||
|
||||
const value = ethValue && typeof ethValue.toNumber === 'function'
|
||||
? ethValue.toNumber()
|
||||
: ethValue;
|
||||
|
||||
return (
|
||||
<div className={ styles.ethInput }>
|
||||
<div className={ styles.input }>
|
||||
{ this.renderNumber(value, this.onEthValueChange) }
|
||||
{ this.state.isEth ? (<div className={ styles.label }>ETH</div>) : null }
|
||||
</div>
|
||||
<div className={ styles.toggle }>
|
||||
<Toggle
|
||||
toggled={ this.state.isEth }
|
||||
onToggle={ this.onEthTypeChange }
|
||||
style={ { width: 46 } }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderNumber (value = this.props.value, onChange = this.onChange) {
|
||||
const { label, error, param, hint, min, max } = this.props;
|
||||
const realValue = value && typeof value.toNumber === 'function'
|
||||
? value.toNumber()
|
||||
: value;
|
||||
|
||||
return (
|
||||
<Input
|
||||
label={ label }
|
||||
hint={ hint }
|
||||
value={ value }
|
||||
value={ realValue }
|
||||
error={ error }
|
||||
onSubmit={ this.onSubmit }
|
||||
onChange={ onChange }
|
||||
type='number'
|
||||
min={ param.signed ? null : 0 }
|
||||
min={ min !== null ? min : (param.signed ? null : 0) }
|
||||
max={ max !== null ? max : null }
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -222,6 +281,28 @@ export default class TypedInput extends Component {
|
||||
this.props.onChange(value === 'true');
|
||||
}
|
||||
|
||||
onEthTypeChange = () => {
|
||||
const { isEth, ethValue } = this.state;
|
||||
|
||||
if (ethValue === '' || ethValue === undefined) {
|
||||
return this.setState({ isEth: !isEth });
|
||||
}
|
||||
|
||||
const value = isEth ? toWei(ethValue) : fromWei(ethValue);
|
||||
this.setState({ isEth: !isEth, ethValue: value }, () => {
|
||||
this.onEthValueChange(null, value);
|
||||
});
|
||||
}
|
||||
|
||||
onEthValueChange = (event, value) => {
|
||||
const realValue = this.state.isEth && value !== '' && value !== undefined
|
||||
? toWei(value)
|
||||
: value;
|
||||
|
||||
this.setState({ ethValue: value });
|
||||
this.props.onChange(realValue);
|
||||
}
|
||||
|
||||
onChange = (event, value) => {
|
||||
this.props.onChange(value);
|
||||
}
|
||||
|
@ -37,17 +37,16 @@ class IdentityName extends Component {
|
||||
render () {
|
||||
const { address, accountsInfo, tokens, empty, name, shorten, unknown, className } = this.props;
|
||||
const account = accountsInfo[address] || tokens[address];
|
||||
const hasAccount = account && (!account.meta || !account.meta.deleted);
|
||||
|
||||
if (!hasAccount && empty) {
|
||||
if (!account && empty) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const addressFallback = shorten ? (<ShortenedHash data={ address } />) : address;
|
||||
const fallback = unknown ? defaultName : addressFallback;
|
||||
const isUuid = hasAccount && account.name === account.uuid;
|
||||
const isUuid = account && account.name === account.uuid;
|
||||
const displayName = (name && name.toUpperCase().trim()) ||
|
||||
(hasAccount && !isUuid
|
||||
(account && !isUuid
|
||||
? account.name.toUpperCase().trim()
|
||||
: fallback);
|
||||
|
||||
|
@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
|
||||
import { LinearProgress } from 'material-ui';
|
||||
import { Step, Stepper, StepLabel } from 'material-ui/Stepper';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import styles from '../modal.css';
|
||||
|
||||
export default class Title extends Component {
|
||||
@ -26,9 +28,7 @@ export default class Title extends Component {
|
||||
current: PropTypes.number,
|
||||
steps: PropTypes.array,
|
||||
waiting: PropTypes.array,
|
||||
title: React.PropTypes.oneOfType([
|
||||
PropTypes.node, PropTypes.string
|
||||
])
|
||||
title: nodeOrStringProptype()
|
||||
}
|
||||
|
||||
render () {
|
||||
|
@ -19,6 +19,8 @@ import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { Dialog } from 'material-ui';
|
||||
|
||||
import { nodeOrStringProptype } from '~/util/proptypes';
|
||||
|
||||
import Container from '../Container';
|
||||
import Title from './Title';
|
||||
|
||||
@ -42,9 +44,7 @@ class Modal extends Component {
|
||||
current: PropTypes.number,
|
||||
waiting: PropTypes.array,
|
||||
steps: PropTypes.array,
|
||||
title: PropTypes.oneOfType([
|
||||
PropTypes.node, PropTypes.string
|
||||
]),
|
||||
title: nodeOrStringProptype(),
|
||||
visible: PropTypes.bool.isRequired,
|
||||
settings: PropTypes.object.isRequired
|
||||
}
|
||||
|
31
js/src/util/proptypes.js
Normal file
31
js/src/util/proptypes.js
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { PropTypes } from 'react';
|
||||
|
||||
export function nullableProptype (type) {
|
||||
return PropTypes.oneOfType([
|
||||
PropTypes.oneOf([ null ]),
|
||||
type
|
||||
]);
|
||||
}
|
||||
|
||||
export function nodeOrStringProptype () {
|
||||
return PropTypes.oneOfType([
|
||||
PropTypes.node,
|
||||
PropTypes.string
|
||||
]);
|
||||
}
|
@ -140,7 +140,7 @@ export function validateUint (value) {
|
||||
const bn = new BigNumber(value);
|
||||
if (bn.lt(0)) {
|
||||
valueError = ERRORS.negativeNumber;
|
||||
} else if (bn.toString().indexOf('.') !== -1) {
|
||||
} else if (!bn.isInteger()) {
|
||||
valueError = ERRORS.decimalNumber;
|
||||
}
|
||||
} catch (e) {
|
||||
|
107
js/src/util/wallets.js
Normal file
107
js/src/util/wallets.js
Normal file
@ -0,0 +1,107 @@
|
||||
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { range } from 'lodash';
|
||||
|
||||
import { bytesToHex, toHex } from '~/api/util/format';
|
||||
|
||||
export default class WalletsUtils {
|
||||
|
||||
static fetchRequire (walletContract) {
|
||||
return walletContract.instance.m_required.call();
|
||||
}
|
||||
|
||||
static fetchOwners (walletContract) {
|
||||
const walletInstance = walletContract.instance;
|
||||
return walletInstance
|
||||
.m_numOwners.call()
|
||||
.then((mNumOwners) => {
|
||||
return Promise.all(range(mNumOwners.toNumber()).map((idx) => walletInstance.getOwner.call({}, [ idx ])));
|
||||
});
|
||||
}
|
||||
|
||||
static fetchDailylimit (walletContract) {
|
||||
const walletInstance = walletContract.instance;
|
||||
|
||||
return Promise
|
||||
.all([
|
||||
walletInstance.m_dailyLimit.call(),
|
||||
walletInstance.m_spentToday.call(),
|
||||
walletInstance.m_lastDay.call()
|
||||
])
|
||||
.then(([ limit, spent, last ]) => ({
|
||||
limit, spent, last
|
||||
}));
|
||||
}
|
||||
|
||||
static fetchTransactions (walletContract) {
|
||||
const walletInstance = walletContract.instance;
|
||||
const signatures = {
|
||||
single: toHex(walletInstance.SingleTransact.signature),
|
||||
multi: toHex(walletInstance.MultiTransact.signature),
|
||||
deposit: toHex(walletInstance.Deposit.signature)
|
||||
};
|
||||
|
||||
return walletContract
|
||||
.getAllLogs({
|
||||
topics: [ [ signatures.single, signatures.multi, signatures.deposit ] ]
|
||||
})
|
||||
.then((logs) => {
|
||||
return logs.sort((logA, logB) => {
|
||||
const comp = logB.blockNumber.comparedTo(logA.blockNumber);
|
||||
|
||||
if (comp !== 0) {
|
||||
return comp;
|
||||
}
|
||||
|
||||
return logB.transactionIndex.comparedTo(logA.transactionIndex);
|
||||
});
|
||||
})
|
||||
.then((logs) => {
|
||||
const transactions = logs.map((log) => {
|
||||
const signature = toHex(log.topics[0]);
|
||||
|
||||
const value = log.params.value.value;
|
||||
const from = signature === signatures.deposit
|
||||
? log.params['_from'].value
|
||||
: walletContract.address;
|
||||
|
||||
const to = signature === signatures.deposit
|
||||
? walletContract.address
|
||||
: log.params.to.value;
|
||||
|
||||
const transaction = {
|
||||
transactionHash: log.transactionHash,
|
||||
blockNumber: log.blockNumber,
|
||||
from, to, value
|
||||
};
|
||||
|
||||
if (log.params.operation) {
|
||||
transaction.operation = bytesToHex(log.params.operation.value);
|
||||
}
|
||||
|
||||
if (log.params.data) {
|
||||
transaction.data = log.params.data.value;
|
||||
}
|
||||
|
||||
return transaction;
|
||||
});
|
||||
|
||||
return transactions;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -25,16 +25,23 @@ import styles from './header.css';
|
||||
export default class Header extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object
|
||||
}
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
account: PropTypes.object,
|
||||
balance: PropTypes.object
|
||||
}
|
||||
balance: PropTypes.object,
|
||||
className: PropTypes.string,
|
||||
children: PropTypes.node
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
className: '',
|
||||
children: null
|
||||
};
|
||||
|
||||
render () {
|
||||
const { api } = this.context;
|
||||
const { account, balance } = this.props;
|
||||
const { account, balance, className, children } = this.props;
|
||||
const { address, meta, uuid } = account;
|
||||
|
||||
if (!account) {
|
||||
@ -46,7 +53,7 @@ export default class Header extends Component {
|
||||
: <div className={ styles.uuidline }>uuid: { uuid }</div>;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={ className }>
|
||||
<Container>
|
||||
<IdentityIcon
|
||||
address={ address } />
|
||||
@ -74,6 +81,7 @@ export default class Header extends Component {
|
||||
dappsUrl={ api.dappsUrl }
|
||||
/>
|
||||
</div>
|
||||
{ children }
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
|
@ -24,6 +24,7 @@ import styles from './list.css';
|
||||
export default class List extends Component {
|
||||
static propTypes = {
|
||||
accounts: PropTypes.object,
|
||||
walletsOwners: PropTypes.object,
|
||||
balances: PropTypes.object,
|
||||
link: PropTypes.string,
|
||||
search: PropTypes.array,
|
||||
@ -42,7 +43,7 @@ export default class List extends Component {
|
||||
}
|
||||
|
||||
renderAccounts () {
|
||||
const { accounts, balances, link, empty, handleAddSearchToken } = this.props;
|
||||
const { accounts, balances, link, empty, handleAddSearchToken, walletsOwners } = this.props;
|
||||
|
||||
if (empty) {
|
||||
return (
|
||||
@ -60,6 +61,8 @@ export default class List extends Component {
|
||||
const account = accounts[address] || {};
|
||||
const balance = balances[address] || {};
|
||||
|
||||
const owners = walletsOwners && walletsOwners[address] || null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={ styles.item }
|
||||
@ -68,6 +71,7 @@ export default class List extends Component {
|
||||
link={ link }
|
||||
account={ account }
|
||||
balance={ balance }
|
||||
owners={ owners }
|
||||
handleAddSearchToken={ handleAddSearchToken } />
|
||||
</div>
|
||||
);
|
||||
|
@ -17,8 +17,12 @@
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import { isEqual } from 'lodash';
|
||||
import ReactTooltip from 'react-tooltip';
|
||||
|
||||
import { Balance, Container, ContainerTitle, IdentityIcon, IdentityName, Tags, Input } from '~/ui';
|
||||
import { nullableProptype } from '~/util/proptypes';
|
||||
|
||||
import styles from '../accounts.css';
|
||||
|
||||
export default class Summary extends Component {
|
||||
static contextTypes = {
|
||||
@ -31,7 +35,8 @@ export default class Summary extends Component {
|
||||
link: PropTypes.string,
|
||||
name: PropTypes.string,
|
||||
noLink: PropTypes.bool,
|
||||
handleAddSearchToken: PropTypes.func
|
||||
handleAddSearchToken: PropTypes.func,
|
||||
owners: nullableProptype(PropTypes.array)
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@ -100,11 +105,41 @@ export default class Summary extends Component {
|
||||
title={ this.renderLink() }
|
||||
byline={ addressComponent } />
|
||||
|
||||
{ this.renderOwners() }
|
||||
{ this.renderBalance() }
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
renderOwners () {
|
||||
const { owners } = this.props;
|
||||
|
||||
if (!owners || owners.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ styles.owners }>
|
||||
{
|
||||
owners.map((owner) => (
|
||||
<div key={ owner.address }>
|
||||
<div
|
||||
data-tip
|
||||
data-for={ `owner_${owner.address}` }
|
||||
data-effect='solid'
|
||||
>
|
||||
<IdentityIcon address={ owner.address } button />
|
||||
</div>
|
||||
<ReactTooltip id={ `owner_${owner.address}` }>
|
||||
<strong>{ owner.name } </strong><small> (owner)</small>
|
||||
</ReactTooltip>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
renderLink () {
|
||||
const { link, noLink, account, name } = this.props;
|
||||
|
||||
|
@ -22,6 +22,12 @@
|
||||
left: 7em;
|
||||
}
|
||||
|
||||
.owners {
|
||||
margin-top: 1em;
|
||||
display: flex;
|
||||
margin-bottom: -0.5em;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
position: relative;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class Accounts extends Component {
|
||||
accounts: PropTypes.object.isRequired,
|
||||
hasAccounts: PropTypes.bool.isRequired,
|
||||
wallets: PropTypes.object.isRequired,
|
||||
walletsOwners: PropTypes.object.isRequired,
|
||||
hasWallets: PropTypes.bool.isRequired,
|
||||
|
||||
balances: PropTypes.object
|
||||
@ -86,8 +87,15 @@ class Accounts extends Component {
|
||||
{ this.renderNewWalletDialog() }
|
||||
{ this.renderActionbar() }
|
||||
|
||||
{ this.renderAccounts() }
|
||||
<Page>
|
||||
<Tooltip
|
||||
className={ styles.accountTooltip }
|
||||
text='your accounts are visible for easy access, allowing you to edit the meta information, make transfers, view transactions and fund the account'
|
||||
/>
|
||||
|
||||
{ this.renderWallets() }
|
||||
{ this.renderAccounts() }
|
||||
</Page>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -115,7 +123,6 @@ class Accounts extends Component {
|
||||
const { searchValues, sortOrder } = this.state;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<List
|
||||
search={ searchValues }
|
||||
accounts={ accounts }
|
||||
@ -123,10 +130,6 @@ class Accounts extends Component {
|
||||
empty={ !hasAccounts }
|
||||
order={ sortOrder }
|
||||
handleAddSearchToken={ this.onAddSearchToken } />
|
||||
<Tooltip
|
||||
className={ styles.accountTooltip }
|
||||
text='your accounts are visible for easy access, allowing you to edit the meta information, make transfers, view transactions and fund the account' />
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
@ -135,11 +138,14 @@ class Accounts extends Component {
|
||||
return this.renderLoading(this.props.wallets);
|
||||
}
|
||||
|
||||
const { wallets, hasWallets, balances } = this.props;
|
||||
const { wallets, hasWallets, balances, walletsOwners } = this.props;
|
||||
const { searchValues, sortOrder } = this.state;
|
||||
|
||||
if (!wallets || Object.keys(wallets).length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<List
|
||||
link='wallet'
|
||||
search={ searchValues }
|
||||
@ -148,8 +154,8 @@ class Accounts extends Component {
|
||||
empty={ !hasWallets }
|
||||
order={ sortOrder }
|
||||
handleAddSearchToken={ this.onAddSearchToken }
|
||||
walletsOwners={ walletsOwners }
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
@ -281,13 +287,29 @@ class Accounts extends Component {
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { accounts, hasAccounts, wallets, hasWallets } = state.personal;
|
||||
const { accounts, hasAccounts, wallets, hasWallets, accountsInfo } = state.personal;
|
||||
const { balances } = state.balances;
|
||||
const walletsInfo = state.wallet.wallets;
|
||||
|
||||
const walletsOwners = Object
|
||||
.keys(walletsInfo)
|
||||
.map((wallet) => ({
|
||||
owners: walletsInfo[wallet].owners.map((owner) => ({
|
||||
address: owner,
|
||||
name: accountsInfo[owner] && accountsInfo[owner].name || owner
|
||||
})),
|
||||
address: wallet
|
||||
}))
|
||||
.reduce((walletsOwners, wallet) => {
|
||||
walletsOwners[wallet.address] = wallet.owners;
|
||||
return walletsOwners;
|
||||
}, {});
|
||||
|
||||
return {
|
||||
accounts,
|
||||
hasAccounts,
|
||||
wallets,
|
||||
walletsOwners,
|
||||
hasWallets,
|
||||
balances
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import { ConfirmDialog, IdentityIcon, IdentityName } from '~/ui';
|
||||
import { newError } from '../../../redux/actions';
|
||||
import { newError } from '~/redux/actions';
|
||||
|
||||
import styles from '../address.css';
|
||||
|
||||
@ -27,16 +27,17 @@ class Delete extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired,
|
||||
router: PropTypes.object
|
||||
}
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
route: PropTypes.string.isRequired,
|
||||
|
||||
address: PropTypes.string,
|
||||
account: PropTypes.object,
|
||||
route: PropTypes.string.isRequired,
|
||||
visible: PropTypes.bool,
|
||||
onClose: PropTypes.func,
|
||||
newError: PropTypes.func
|
||||
}
|
||||
};
|
||||
|
||||
render () {
|
||||
const { account, visible } = this.props;
|
||||
@ -79,10 +80,8 @@ class Delete extends Component {
|
||||
const { api, router } = this.context;
|
||||
const { account, route, newError } = this.props;
|
||||
|
||||
account.meta.deleted = true;
|
||||
|
||||
api.parity
|
||||
.setAccountMeta(account.address, account.meta)
|
||||
.removeAddress(account.address)
|
||||
.then(() => {
|
||||
router.push(route);
|
||||
this.closeDeleteDialog();
|
||||
|
@ -121,7 +121,7 @@ class Address extends Component {
|
||||
return (
|
||||
<Actionbar
|
||||
title='Address Information'
|
||||
buttons={ !contact || contact.meta.deleted ? [] : buttons } />
|
||||
buttons={ !contact ? [] : buttons } />
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 (
|
||||
<Event
|
||||
key={ event.key }
|
||||
|
@ -23,7 +23,7 @@ import ContentCreate from 'material-ui/svg-icons/content/create';
|
||||
import EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
|
||||
import ContentClear from 'material-ui/svg-icons/content/clear';
|
||||
|
||||
import { newError } from '../../redux/actions';
|
||||
import { newError } from '~/redux/actions';
|
||||
import { setVisibleAccounts } from '~/redux/providers/personalActions';
|
||||
|
||||
import { EditMeta, ExecuteContract } from '~/modals';
|
||||
@ -229,7 +229,7 @@ class Contract extends Component {
|
||||
return (
|
||||
<Actionbar
|
||||
title='Contract Information'
|
||||
buttons={ !account || account.meta.deleted ? [] : buttons } />
|
||||
buttons={ !account ? [] : buttons } />
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ import { action, computed, observable, transaction } from 'mobx';
|
||||
import store from 'store';
|
||||
|
||||
import Contracts from '~/contracts';
|
||||
import { hashToImageUrl } from '../../redux/util';
|
||||
import { hashToImageUrl } from '~/redux/util';
|
||||
|
||||
import builtinApps from './builtin.json';
|
||||
|
||||
|
@ -18,7 +18,7 @@ import React, { Component, PropTypes } from 'react';
|
||||
|
||||
import ReactTooltip from 'react-tooltip';
|
||||
|
||||
import { MethodDecoding } from '../../../../ui';
|
||||
import { MethodDecoding } from '~/ui';
|
||||
|
||||
import * as tUtil from '../util/transaction';
|
||||
import Account from '../Account';
|
||||
|
@ -64,7 +64,7 @@ export default class TransactionPending extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const { className, id, transaction, store } = this.props;
|
||||
const { className, id, transaction, store, isTest } = this.props;
|
||||
const { from, value } = transaction;
|
||||
const { totalValue } = this.state;
|
||||
|
||||
@ -76,6 +76,7 @@ export default class TransactionPending extends Component {
|
||||
id={ id }
|
||||
value={ value }
|
||||
from={ from }
|
||||
isTest={ isTest }
|
||||
fromBalance={ fromBalance }
|
||||
className={ styles.transactionDetails }
|
||||
transaction={ transaction }
|
||||
|
@ -17,6 +17,6 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
|
||||
import { identity } from '../util';
|
||||
import { withError } from '../../../redux/util';
|
||||
import { withError } from '~/redux/util';
|
||||
|
||||
export const copyToClipboard = createAction('copy toClipboard', identity, withError(identity));
|
||||
|
@ -17,7 +17,7 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
|
||||
import { identity } from '../util';
|
||||
import { withError } from '../../../redux/util';
|
||||
import { withError } from '~/redux/util';
|
||||
|
||||
export const updateLogging = createAction(
|
||||
'update logging', identity, withError(flag => `logging updated to ${flag}`)
|
||||
|
@ -17,7 +17,7 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
|
||||
import { identity } from '../util';
|
||||
import { withError } from '../../../redux/util';
|
||||
import { withError } from '~/redux/util';
|
||||
|
||||
export const error = createAction('error rpc', identity,
|
||||
withError(() => 'error processing rpc call. check console for details', 'error')
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user