Merge branch 'master' into lightserv

This commit is contained in:
Robert Habermeier 2016-12-09 01:29:46 +01:00
commit eec1929658
132 changed files with 2594 additions and 767 deletions

View File

@ -401,7 +401,7 @@ test-darwin:
- git submodule update --init --recursive - git submodule update --init --recursive
script: script:
- export RUST_BACKTRACE=1 - export RUST_BACKTRACE=1
- ./test.sh $CARGOFLAGS --no-release - ./test.sh $CARGOFLAGS
tags: tags:
- osx - osx
allow_failure: true allow_failure: true
@ -428,7 +428,7 @@ test-rust-stable:
script: script:
- export RUST_BACKTRACE=1 - export RUST_BACKTRACE=1
- echo $JS_FILES_MODIFIED - 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: tags:
- rust - rust
- rust-stable - rust-stable
@ -457,7 +457,7 @@ test-rust-beta:
script: script:
- export RUST_BACKTRACE=1 - export RUST_BACKTRACE=1
- echo $JS_FILES_MODIFIED - echo $JS_FILES_MODIFIED
- ./test.sh $CARGOFLAGS --no-release - ./test.sh $CARGOFLAGS
tags: tags:
- rust - rust
- rust-beta - rust-beta
@ -471,7 +471,7 @@ test-rust-nightly:
- git submodule update --init --recursive - git submodule update --init --recursive
script: script:
- export RUST_BACKTRACE=1 - export RUST_BACKTRACE=1
- ./test.sh $CARGOFLAGS --no-release - ./test.sh $CARGOFLAGS
tags: tags:
- rust - rust
- rust-nightly - rust-nightly

View File

@ -16,7 +16,7 @@ git:
matrix: matrix:
include: include:
- rust: stable - rust: stable
env: RUN_TESTS="true" TEST_OPTIONS="--no-release" env: RUN_TESTS="true" TEST_OPTIONS=""
- rust: stable - rust: stable
env: RUN_COVERAGE="true" env: RUN_COVERAGE="true"
- rust: stable - rust: stable
@ -71,8 +71,7 @@ install:
script: script:
- if [ "$RUN_TESTS" = "true" ]; then - if [ "$RUN_TESTS" = "true" ]; then
./js/scripts/lint.sh && ./js/scripts/lint.sh &&
./js/scripts/test.sh && travis_wait 40 ./test.sh $TEST_OPTIONS;
./test.sh $TEST_OPTIONS --verbose;
fi fi
- if [ "$RUN_COVERAGE" = "true" ]; then ./scripts/cov.sh "$KCOV_CMD"; fi - if [ "$RUN_COVERAGE" = "true" ]; then ./scripts/cov.sh "$KCOV_CMD"; fi

94
Cargo.lock generated
View File

@ -10,19 +10,19 @@ dependencies = [
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.5.0", "ethcore 1.5.0",
"ethcore-dapps 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-hash-fetch 1.5.0",
"ethcore-io 1.5.0", "ethcore-io 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-hypervisor 1.2.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-ipc-tests 0.1.0",
"ethcore-light 1.5.0", "ethcore-light 1.5.0",
"ethcore-logger 1.5.0", "ethcore-logger 1.5.0",
"ethcore-rpc 1.5.0", "ethcore-rpc 1.5.0",
"ethcore-signer 1.5.0", "ethcore-signer 1.5.0",
"ethcore-stratum 1.4.0", "ethcore-stratum 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"ethsync 1.5.0", "ethsync 1.5.0",
"fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -274,7 +274,7 @@ dependencies = [
[[package]] [[package]]
name = "ethash" name = "ethash"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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-bloom-journal 0.1.0",
"ethcore-devtools 1.4.0", "ethcore-devtools 1.5.0",
"ethcore-io 1.5.0", "ethcore-io 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-nano 1.4.0", "ethcore-ipc-nano 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"ethjson 0.1.0", "ethjson 0.1.0",
"ethkey 0.2.0", "ethkey 0.2.0",
"ethstore 0.1.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)", "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)", "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)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -344,7 +344,7 @@ version = "1.5.0"
dependencies = [ dependencies = [
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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-hash-fetch 1.5.0",
"ethcore-rpc 1.5.0", "ethcore-rpc 1.5.0",
"ethcore-util 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 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)", "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-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)", "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)", "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)", "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -371,7 +371,7 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-devtools" name = "ethcore-devtools"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -401,9 +401,9 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-ipc" name = "ethcore-ipc"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"ethcore-devtools 1.4.0", "ethcore-devtools 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "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)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -411,7 +411,7 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-ipc-codegen" name = "ethcore-ipc-codegen"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"aster 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "quasi 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -424,9 +424,9 @@ dependencies = [
name = "ethcore-ipc-hypervisor" name = "ethcore-ipc-hypervisor"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-nano 1.4.0", "ethcore-ipc-nano 1.5.0",
"log 0.3.6 (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)", "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)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -435,9 +435,9 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-ipc-nano" name = "ethcore-ipc-nano"
version = "1.4.0" version = "1.5.0"
dependencies = [ 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)", "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)", "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)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
@ -447,10 +447,10 @@ dependencies = [
name = "ethcore-ipc-tests" name = "ethcore-ipc-tests"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"ethcore-devtools 1.4.0", "ethcore-devtools 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-nano 1.4.0", "ethcore-ipc-nano 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"log 0.3.6 (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)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)",
@ -463,8 +463,8 @@ version = "1.5.0"
dependencies = [ dependencies = [
"ethcore 1.5.0", "ethcore 1.5.0",
"ethcore-io 1.5.0", "ethcore-io 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-network 1.5.0", "ethcore-network 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -491,7 +491,7 @@ version = "1.5.0"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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-io 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"ethcrypto 0.1.0", "ethcrypto 0.1.0",
@ -515,11 +515,11 @@ name = "ethcore-rpc"
version = "1.5.0" version = "1.5.0"
dependencies = [ dependencies = [
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "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 1.5.0",
"ethcore-devtools 1.4.0", "ethcore-devtools 1.5.0",
"ethcore-io 1.5.0", "ethcore-io 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"ethcrypto 0.1.0", "ethcrypto 0.1.0",
"ethjson 0.1.0", "ethjson 0.1.0",
@ -546,14 +546,14 @@ version = "1.5.0"
dependencies = [ dependencies = [
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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-io 1.5.0",
"ethcore-rpc 1.5.0", "ethcore-rpc 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)", "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)", "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-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)", "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)", "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)", "ws 0.5.3 (git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable)",
@ -561,13 +561,13 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-stratum" name = "ethcore-stratum"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"env_logger 0.3.3 (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-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-nano 1.4.0", "ethcore-ipc-nano 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
"jsonrpc-core 4.0.0 (git+https://github.com/ethcore/jsonrpc.git)", "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)", "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)", "eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
"ethcore-bigint 0.1.2", "ethcore-bigint 0.1.2",
"ethcore-bloom-journal 0.1.0", "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)", "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)", "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)", "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)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.5.0", "ethcore 1.5.0",
"ethcore-io 1.5.0", "ethcore-io 1.5.0",
"ethcore-ipc 1.4.0", "ethcore-ipc 1.5.0",
"ethcore-ipc-codegen 1.4.0", "ethcore-ipc-codegen 1.5.0",
"ethcore-ipc-nano 1.4.0", "ethcore-ipc-nano 1.5.0",
"ethcore-light 1.5.0", "ethcore-light 1.5.0",
"ethcore-network 1.5.0", "ethcore-network 1.5.0",
"ethcore-util 1.5.0", "ethcore-util 1.5.0",
@ -694,7 +694,7 @@ dependencies = [
[[package]] [[package]]
name = "evmjit" name = "evmjit"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1271,7 +1271,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-ui" name = "parity-ui"
version = "1.4.0" version = "1.5.0"
dependencies = [ dependencies = [
"parity-ui-dev 1.4.0", "parity-ui-dev 1.4.0",
"parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)", "parity-ui-precompiled 1.4.0 (git+https://github.com/ethcore/js-precompiled.git)",
@ -1288,7 +1288,7 @@ dependencies = [
[[package]] [[package]]
name = "parity-ui-precompiled" name = "parity-ui-precompiled"
version = "1.4.0" 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 = [ dependencies = [
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

@ -89,4 +89,4 @@ name = "parity"
[profile.release] [profile.release]
debug = false debug = false
lto = false lto = false
panic = "abort"

View File

@ -1,7 +1,7 @@
[package] [package]
description = "Base Package for all Parity built-in dapps" description = "Base Package for all Parity built-in dapps"
name = "parity-dapps-glue" name = "parity-dapps-glue"
version = "1.4.0" version = "1.5.0"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io"] authors = ["Ethcore <admin@ethcore.io"]
build = "build.rs" build = "build.rs"

View File

@ -3,7 +3,7 @@ description = "Ethcore Parity UI"
homepage = "http://ethcore.io" homepage = "http://ethcore.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "parity-ui" name = "parity-ui"
version = "1.4.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Ethcore <admin@ethcore.io>"]
[build-dependencies] [build-dependencies]

View File

@ -3,7 +3,7 @@ description = "Ethcore Database"
homepage = "http://ethcore.io" homepage = "http://ethcore.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-db" name = "ethcore-db"
version = "1.4.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs" build = "build.rs"

View File

@ -3,7 +3,7 @@ description = "Ethcore development/test/build tools"
homepage = "http://ethcore.io" homepage = "http://ethcore.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-devtools" name = "ethcore-devtools"
version = "1.4.0" version = "1.5.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Ethcore <admin@ethcore.io>"]
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ethash" name = "ethash"
version = "1.4.0" version = "1.5.0"
authors = ["arkpar <arkadiy@ethcore.io"] authors = ["arkpar <arkadiy@ethcore.io"]
[lib] [lib]

View File

@ -194,6 +194,11 @@ impl AccountProvider {
Ok(self.address_book.write().set_meta(account, meta)) 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. /// Returns each account along with name and meta.
pub fn accounts_info(&self) -> Result<HashMap<Address, AccountMeta>, Error> { pub fn accounts_info(&self) -> Result<HashMap<Address, AccountMeta>, Error> {
let r: HashMap<Address, AccountMeta> = try!(self.sstore.accounts()) let r: HashMap<Address, AccountMeta> = try!(self.sstore.accounts())

View File

@ -74,6 +74,12 @@ impl AddressBook {
} }
self.save(); self.save();
} }
/// Removes an entry
pub fn remove(&mut self, a: Address) {
self.cache.remove(&a);
self.save();
}
} }
/// Dapps user settings /// 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}
]);
}
} }

View File

@ -21,13 +21,15 @@ use std::sync::Weak;
use std::time::{UNIX_EPOCH, Duration}; use std::time::{UNIX_EPOCH, Duration};
use util::*; use util::*;
use ethkey::{verify_address, Signature}; use ethkey::{verify_address, Signature};
use rlp::{Rlp, UntrustedRlp, View, encode}; use rlp::{UntrustedRlp, Rlp, View, encode};
use account_provider::AccountProvider; use account_provider::AccountProvider;
use block::*; use block::*;
use spec::CommonParams; use spec::CommonParams;
use engines::Engine; use engines::Engine;
use header::Header; use header::Header;
use error::{Error, BlockError}; use error::{Error, BlockError};
use blockchain::extras::BlockDetails;
use views::HeaderView;
use evm::Schedule; use evm::Schedule;
use ethjson; use ethjson;
use io::{IoContext, IoHandler, TimerToken, IoService, IoChannel}; use io::{IoContext, IoHandler, TimerToken, IoService, IoChannel};
@ -35,8 +37,6 @@ use service::ClientIoMessage;
use transaction::SignedTransaction; use transaction::SignedTransaction;
use env_info::EnvInfo; use env_info::EnvInfo;
use builtin::Builtin; use builtin::Builtin;
use blockchain::extras::BlockDetails;
use views::HeaderView;
/// `AuthorityRound` params. /// `AuthorityRound` params.
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -68,18 +68,20 @@ pub struct AuthorityRound {
params: CommonParams, params: CommonParams,
our_params: AuthorityRoundParams, our_params: AuthorityRoundParams,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
transition_service: IoService<BlockArrived>, transition_service: IoService<()>,
message_channel: Mutex<Option<IoChannel<ClientIoMessage>>>, message_channel: Mutex<Option<IoChannel<ClientIoMessage>>>,
step: AtomicUsize, step: AtomicUsize,
proposed: AtomicBool, proposed: AtomicBool,
account_provider: Mutex<Option<Arc<AccountProvider>>>,
password: RwLock<Option<String>>,
} }
fn header_step(header: &Header) -> Result<usize, ::rlp::DecoderError> { 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> { 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 { trait AsMillis {
@ -101,10 +103,12 @@ impl AuthorityRound {
params: params, params: params,
our_params: our_params, our_params: our_params,
builtins: builtins, builtins: builtins,
transition_service: try!(IoService::<BlockArrived>::start()), transition_service: try!(IoService::<()>::start()),
message_channel: Mutex::new(None), message_channel: Mutex::new(None),
step: AtomicUsize::new(initial_step), 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) }; let handler = TransitionHandler { engine: Arc::downgrade(&engine) };
try!(engine.transition_service.register_handler(Arc::new(handler))); try!(engine.transition_service.register_handler(Arc::new(handler)));
@ -143,20 +147,17 @@ struct TransitionHandler {
engine: Weak<AuthorityRound>, engine: Weak<AuthorityRound>,
} }
#[derive(Clone)]
struct BlockArrived;
const ENGINE_TIMEOUT_TOKEN: TimerToken = 23; const ENGINE_TIMEOUT_TOKEN: TimerToken = 23;
impl IoHandler<BlockArrived> for TransitionHandler { impl IoHandler<()> for TransitionHandler {
fn initialize(&self, io: &IoContext<BlockArrived>) { fn initialize(&self, io: &IoContext<()>) {
if let Some(engine) = self.engine.upgrade() { if let Some(engine) = self.engine.upgrade() {
io.register_timer_once(ENGINE_TIMEOUT_TOKEN, engine.remaining_step_duration().as_millis()) 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)) .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 timer == ENGINE_TIMEOUT_TOKEN {
if let Some(engine) = self.engine.upgrade() { if let Some(engine) = self.engine.upgrade() {
engine.step.fetch_add(1, AtomicOrdering::SeqCst); 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> { fn is_sealer(&self, author: &Address) -> Option<bool> {
let p = &self.our_params; let p = &self.our_params;
Some(p.authorities.contains(author)) 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 /// This operation is synchronous and may (quite reasonably) not be available, in which `false` will
/// be returned. /// 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; } if self.proposed.load(AtomicOrdering::SeqCst) { return None; }
let header = block.header(); let header = block.header();
let step = self.step(); let step = self.step();
if self.is_step_proposer(step, header.author()) { 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. // 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); trace!(target: "poa", "generate_seal: Issuing a block for step {}.", step);
self.proposed.store(true, AtomicOrdering::SeqCst); self.proposed.store(true, AtomicOrdering::SeqCst);
return Some(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]); return Some(vec![encode(&step).to_vec(), encode(&(&*signature as &[u8])).to_vec()]);
@ -303,23 +300,30 @@ impl Engine for AuthorityRound {
t.sender().map(|_|()) // Perform EC recovery and cache sender 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 { 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 new_number = new_header.number();
let best_number = best_header.number(); let best_number = best_header.number();
if new_number != best_number { if new_number != best_number {
new_number > best_number new_number > best_number
} else { } else {
// Take the oldest step at given height. // Take the oldest step at given height.
let new_step: usize = Rlp::new(&new_header.seal()[0]).as_val(); let new_step: usize = Rlp::new(&new_header.seal()[0]).as_val();
let best_step: usize = Rlp::new(&best_header.seal()[0]).as_val(); let best_step: usize = Rlp::new(&best_header.seal()[0]).as_val();
new_step < best_step 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)] #[cfg(test)]
@ -387,12 +391,11 @@ mod tests {
fn generates_seal_and_does_not_double_propose() { fn generates_seal_and_does_not_double_propose() {
let tap = AccountProvider::transient_provider(); let tap = AccountProvider::transient_provider();
let addr1 = tap.insert_account("1".sha3(), "1").unwrap(); 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(); let addr2 = tap.insert_account("2".sha3(), "2").unwrap();
tap.unlock_account_permanently(addr2, "2".into()).unwrap();
let spec = Spec::new_test_round(); let spec = Spec::new_test_round();
let engine = &*spec.engine; let engine = &*spec.engine;
engine.register_account_provider(Arc::new(tap));
let genesis_header = spec.genesis_header(); let genesis_header = spec.genesis_header();
let mut db1 = get_temp_state_db().take(); let mut db1 = get_temp_state_db().take();
spec.ensure_db_good(&mut db1, &TrieFactory::new(TrieSpec::Secure)).unwrap(); 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 = OpenBlock::new(engine, Default::default(), false, db2, &genesis_header, last_hashes, addr2, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b2 = b2.close_and_lock(); 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()); assert!(b1.clone().try_seal(engine, seal).is_ok());
// Second proposal is forbidden. // 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()); assert!(b2.clone().try_seal(engine, seal).is_ok());
// Second proposal is forbidden. // Second proposal is forbidden.
assert!(engine.generate_seal(b2.block(), Some(&tap)).is_none()); assert!(engine.generate_seal(b2.block()).is_none());
} }
} }

View File

@ -58,6 +58,8 @@ pub struct BasicAuthority {
params: CommonParams, params: CommonParams,
our_params: BasicAuthorityParams, our_params: BasicAuthorityParams,
builtins: BTreeMap<Address, Builtin>, builtins: BTreeMap<Address, Builtin>,
account_provider: Mutex<Option<Arc<AccountProvider>>>,
password: RwLock<Option<String>>,
} }
impl BasicAuthority { impl BasicAuthority {
@ -67,6 +69,8 @@ impl BasicAuthority {
params: params, params: params,
our_params: our_params, our_params: our_params,
builtins: builtins, 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()) 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> { fn is_sealer(&self, author: &Address) -> Option<bool> {
Some(self.our_params.authorities.contains(author)) 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 /// This operation is synchronous and may (quite reasonably) not be available, in which `false` will
/// be returned. /// be returned.
fn generate_seal(&self, block: &ExecutedBlock, accounts: Option<&AccountProvider>) -> Option<Vec<Bytes>> { fn generate_seal(&self, block: &ExecutedBlock) -> Option<Vec<Bytes>> {
if let Some(ap) = accounts { if let Some(ref ap) = *self.account_provider.lock() {
let header = block.header(); let header = block.header();
let message = header.bare_hash(); let message = header.bare_hash();
// account should be pernamently unlocked, otherwise sealing will fail // 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()]); return Some(vec![::rlp::encode(&(&*signature as &[u8])).to_vec()]);
} else { } else {
trace!(target: "basicauthority", "generate_seal: FAIL: accounts secret key unavailable"); 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> { fn verify_transaction(&self, t: &SignedTransaction, _header: &Header) -> Result<(), Error> {
t.sender().map(|_|()) // Perform EC recovery and cache sender 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)] #[cfg(test)]
@ -250,10 +257,11 @@ mod tests {
fn can_generate_seal() { fn can_generate_seal() {
let tap = AccountProvider::transient_provider(); let tap = AccountProvider::transient_provider();
let addr = tap.insert_account("".sha3(), "").unwrap(); let addr = tap.insert_account("".sha3(), "").unwrap();
tap.unlock_account_permanently(addr, "".into()).unwrap();
let spec = new_test_authority(); let spec = new_test_authority();
let engine = &*spec.engine; let engine = &*spec.engine;
engine.set_signer(addr, "".into());
engine.register_account_provider(Arc::new(tap));
let genesis_header = spec.genesis_header(); let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db(); let mut db_result = get_temp_state_db();
let mut db = db_result.take(); let mut db = db_result.take();
@ -261,7 +269,7 @@ mod tests {
let last_hashes = Arc::new(vec![genesis_header.hash()]); 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, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock(); 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()); assert!(b.try_seal(engine, seal).is_ok());
} }

View File

@ -23,7 +23,6 @@ use spec::CommonParams;
use evm::Schedule; use evm::Schedule;
use block::ExecutedBlock; use block::ExecutedBlock;
use util::Bytes; use util::Bytes;
use account_provider::AccountProvider;
/// An engine which does not provide any consensus mechanism, just seals blocks internally. /// An engine which does not provide any consensus mechanism, just seals blocks internally.
pub struct InstantSeal { pub struct InstantSeal {
@ -60,7 +59,7 @@ impl Engine for InstantSeal {
fn is_sealer(&self, _author: &Address) -> Option<bool> { Some(true) } 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()) Some(Vec::new())
} }
} }
@ -70,16 +69,12 @@ mod tests {
use util::*; use util::*;
use util::trie::TrieSpec; use util::trie::TrieSpec;
use tests::helpers::*; use tests::helpers::*;
use account_provider::AccountProvider;
use spec::Spec; use spec::Spec;
use header::Header; use header::Header;
use block::*; use block::*;
#[test] #[test]
fn instant_can_seal() { fn instant_can_seal() {
let tap = AccountProvider::transient_provider();
let addr = tap.insert_account("".sha3(), "").unwrap();
let spec = Spec::new_instant(); let spec = Spec::new_instant();
let engine = &*spec.engine; let engine = &*spec.engine;
let genesis_header = spec.genesis_header(); let genesis_header = spec.genesis_header();
@ -87,10 +82,9 @@ mod tests {
let mut db = db_result.take(); let mut db = db_result.take();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap(); spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]); 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(); let b = b.close_and_lock();
// Seal with empty AccountProvider. let seal = engine.generate_seal(b.block()).unwrap();
let seal = engine.generate_seal(b.block(), Some(&tap)).unwrap();
assert!(b.try_seal(engine, seal).is_ok()); assert!(b.try_seal(engine, seal).is_ok());
} }

View File

@ -94,7 +94,7 @@ pub trait Engine : Sync + Send {
/// ///
/// This operation is synchronous and may (quite reasonably) not be available, in which None will /// This operation is synchronous and may (quite reasonably) not be available, in which None will
/// be returned. /// 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) /// 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. /// 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); 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. /// 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 { 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) 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>) {}
} }

View File

@ -19,7 +19,7 @@ use std::time::{Instant, Duration};
use util::*; use util::*;
use util::using_queue::{UsingQueue, GetAction}; use util::using_queue::{UsingQueue, GetAction};
use account_provider::AccountProvider; use account_provider::{AccountProvider, Error as AccountError};
use views::{BlockView, HeaderView}; use views::{BlockView, HeaderView};
use header::Header; use header::Header;
use state::{State, CleanupMode}; 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), /// 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. /// Err(Some(block)) returns for unsuccesful sealing while Err(None) indicates misspecified engine.
fn seal_block_internally(&self, block: ClosedBlock) -> Result<SealedBlock, Option<ClosedBlock>> { fn seal_block_internally(&self, block: ClosedBlock) -> Result<SealedBlock, Option<ClosedBlock>> {
trace!(target: "miner", "seal_block_internally: block has transaction - attempting internal seal."); trace!(target: "miner", "seal_block_internally: attempting internal seal.");
let s = self.engine.generate_seal(block.block(), match self.accounts { let s = self.engine.generate_seal(block.block());
Some(ref x) => Some(&**x),
None => None,
});
if let Some(seal) = s { if let Some(seal) = s {
trace!(target: "miner", "seal_block_internally: managed internal seal. importing..."); trace!(target: "miner", "seal_block_internally: managed internal seal. importing...");
block.lock().try_seal(&*self.engine, seal).or_else(|_| { block.lock().try_seal(&*self.engine, seal).or_else(|(e, _)| {
warn!("prepare_sealing: ERROR: try_seal failed when given internally generated seal. WTF?"); warn!("prepare_sealing: ERROR: try_seal failed when given internally generated seal: {}", e);
Err(None) Err(None)
}) })
} else { } else {
@ -485,7 +482,7 @@ impl Miner {
fn seal_and_import_block_internally(&self, chain: &MiningBlockChainClient, block: ClosedBlock) -> bool { fn seal_and_import_block_internally(&self, chain: &MiningBlockChainClient, block: ClosedBlock) -> bool {
if !block.transactions().is_empty() || self.forced_sealing() { if !block.transactions().is_empty() || self.forced_sealing() {
if let Ok(sealed) = self.seal_block_internally(block) { 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"); trace!(target: "miner", "import_block_internally: imported internally sealed block");
return true return true
} }
@ -740,6 +737,19 @@ impl MinerService for Miner {
*self.author.write() = author; *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) { fn set_extra_data(&self, extra_data: Bytes) {
*self.extra_data.write() = extra_data; *self.extra_data.write() = extra_data;
} }
@ -1042,7 +1052,7 @@ impl MinerService for Miner {
ret.map(f) 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 = let result =
if let Some(b) = self.sealing_work.lock().queue.get_used_if( if let Some(b) = self.sealing_work.lock().queue.get_used_if(
if self.options.enable_resubmission { if self.options.enable_resubmission {
@ -1050,22 +1060,22 @@ impl MinerService for Miner {
} else { } else {
GetAction::Take 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, _)| { b.lock().try_seal(&*self.engine, seal).or_else(|(e, _)| {
warn!(target: "miner", "Mined solution rejected: {}", e); warn!(target: "miner", "Mined solution rejected: {}", e);
Err(Error::PowInvalid) Err(Error::PowInvalid)
}) })
} else { } 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) Err(Error::PowHashInvalid)
}; };
result.and_then(|sealed| { result.and_then(|sealed| {
let n = sealed.header().number(); let n = sealed.header().number();
let h = sealed.header().hash(); let h = sealed.header().hash();
try!(chain.import_sealed_block(sealed)); 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(()) Ok(())
}) })
} }

View File

@ -76,6 +76,9 @@ pub trait MinerService : Send + Sync {
/// Set the author that we will seal blocks as. /// Set the author that we will seal blocks as.
fn set_author(&self, author: Address); 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. /// Get the extra_data that we will seal blocks with.
fn extra_data(&self) -> Bytes; fn extra_data(&self) -> Bytes;

View File

@ -304,6 +304,9 @@ impl SignedTransaction {
/// 0 if `v` would have been 27 under "Electrum" notation, 1 if 28 or 4 if invalid. /// 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 } } 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. /// The network ID, or `None` if this is a global transaction.
pub fn network_id(&self) -> Option<u64> { pub fn network_id(&self) -> Option<u64> {
match self.v { match self.v {

View File

@ -53,6 +53,8 @@ pub struct Config {
/// Maximum heap memory to use. /// Maximum heap memory to use.
/// When the limit is reached, is_full returns true. /// When the limit is reached, is_full returns true.
pub max_mem_use: usize, pub max_mem_use: usize,
/// Settings for the number of verifiers and adaptation strategy.
pub verifier_settings: VerifierSettings,
} }
impl Default for Config { impl Default for Config {
@ -60,6 +62,26 @@ impl Default for Config {
Config { Config {
max_queue_size: 30000, max_queue_size: 30000,
max_mem_use: 50 * 1024 * 1024, 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, ticks_since_adjustment: AtomicUsize,
max_queue_size: usize, max_queue_size: usize,
max_mem_use: usize, max_mem_use: usize,
scale_verifiers: bool,
verifier_handles: Vec<JoinHandle<()>>, verifier_handles: Vec<JoinHandle<()>>,
state: Arc<(Mutex<State>, Condvar)>, state: Arc<(Mutex<State>, Condvar)>,
} }
@ -198,13 +221,16 @@ impl<K: Kind> VerificationQueue<K> {
}); });
let empty = Arc::new(SCondvar::new()); let empty = Arc::new(SCondvar::new());
let panic_handler = PanicHandler::new_in_arc(); 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 num_cpus = ::num_cpus::get();
let default_amount = max(::num_cpus::get(), 3) - 2; let max_verifiers = min(num_cpus, MAX_VERIFIERS);
let state = Arc::new((Mutex::new(State::Work(default_amount)), Condvar::new())); 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); let mut verifier_handles = Vec::with_capacity(max_verifiers);
debug!(target: "verification", "Allocating {} verifiers, {} initially active", max_verifiers, default_amount); 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 { for i in 0..max_verifiers {
debug!(target: "verification", "Adding verification thread #{}", i); debug!(target: "verification", "Adding verification thread #{}", i);
@ -248,6 +274,7 @@ impl<K: Kind> VerificationQueue<K> {
ticks_since_adjustment: AtomicUsize::new(0), ticks_since_adjustment: AtomicUsize::new(0),
max_queue_size: max(config.max_queue_size, MIN_QUEUE_LIMIT), max_queue_size: max(config.max_queue_size, MIN_QUEUE_LIMIT),
max_mem_use: max(config.max_mem_use, MIN_MEM_LIMIT), max_mem_use: max(config.max_mem_use, MIN_MEM_LIMIT),
scale_verifiers: scale_verifiers,
verifier_handles: verifier_handles, verifier_handles: verifier_handles,
state: state, state: state,
} }
@ -597,6 +624,8 @@ impl<K: Kind> VerificationQueue<K> {
self.processing.write().shrink_to_fit(); self.processing.write().shrink_to_fit();
if !self.scale_verifiers { return }
if self.ticks_since_adjustment.fetch_add(1, AtomicOrdering::SeqCst) + 1 >= READJUSTMENT_PERIOD { if self.ticks_since_adjustment.fetch_add(1, AtomicOrdering::SeqCst) + 1 >= READJUSTMENT_PERIOD {
self.ticks_since_adjustment.store(0, AtomicOrdering::SeqCst); self.ticks_since_adjustment.store(0, AtomicOrdering::SeqCst);
} else { } else {
@ -675,10 +704,15 @@ mod tests {
use error::*; use error::*;
use views::*; 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 spec = get_test_spec();
let engine = spec.engine; 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] #[test]
@ -691,7 +725,7 @@ mod tests {
#[test] #[test]
fn can_import_blocks() { 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())) { if let Err(e) = queue.import(Unverified::new(get_good_dummy_block())) {
panic!("error importing block that is valid by definition({:?})", e); panic!("error importing block that is valid by definition({:?})", e);
} }
@ -699,7 +733,7 @@ mod tests {
#[test] #[test]
fn returns_error_for_duplicates() { 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())) { if let Err(e) = queue.import(Unverified::new(get_good_dummy_block())) {
panic!("error importing block that is valid by definition({:?})", e); panic!("error importing block that is valid by definition({:?})", e);
} }
@ -718,7 +752,7 @@ mod tests {
#[test] #[test]
fn returns_ok_for_drained_duplicates() { fn returns_ok_for_drained_duplicates() {
let queue = get_test_queue(); let queue = get_test_queue(false);
let block = get_good_dummy_block(); let block = get_good_dummy_block();
let hash = BlockView::new(&block).header().hash().clone(); let hash = BlockView::new(&block).header().hash().clone();
if let Err(e) = queue.import(Unverified::new(block)) { if let Err(e) = queue.import(Unverified::new(block)) {
@ -735,7 +769,7 @@ mod tests {
#[test] #[test]
fn returns_empty_once_finished() { fn returns_empty_once_finished() {
let queue = get_test_queue(); let queue = get_test_queue(false);
queue.import(Unverified::new(get_good_dummy_block())) queue.import(Unverified::new(get_good_dummy_block()))
.expect("error importing block that is valid by definition"); .expect("error importing block that is valid by definition");
queue.flush(); queue.flush();
@ -763,7 +797,7 @@ mod tests {
fn scaling_limits() { fn scaling_limits() {
use super::MAX_VERIFIERS; use super::MAX_VERIFIERS;
let queue = get_test_queue(); let queue = get_test_queue(true);
queue.scale_verifiers(MAX_VERIFIERS + 1); queue.scale_verifiers(MAX_VERIFIERS + 1);
assert!(queue.num_verifiers() < MAX_VERIFIERS + 1); assert!(queue.num_verifiers() < MAX_VERIFIERS + 1);
@ -775,7 +809,7 @@ mod tests {
#[test] #[test]
fn readjust_verifiers() { fn readjust_verifiers() {
let queue = get_test_queue(); let queue = get_test_queue(true);
// put all the verifiers to sleep to ensure // put all the verifiers to sleep to ensure
// the test isn't timing sensitive. // the test isn't timing sensitive.

View File

@ -1,6 +1,6 @@
[package] [package]
name = "evmjit" name = "evmjit"
version = "1.4.0" version = "1.5.0"
authors = ["debris <marek.kotewicz@gmail.com>"] authors = ["debris <marek.kotewicz@gmail.com>"]
[lib] [lib]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ethcore-ipc-codegen" name = "ethcore-ipc-codegen"
version = "1.4.0" version = "1.5.0"
authors = ["Nikolay Volf"] authors = ["Nikolay Volf"]
license = "GPL-3.0" license = "GPL-3.0"
description = "Macros to auto-generate implementations for ipc call" description = "Macros to auto-generate implementations for ipc call"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ethcore-ipc-nano" name = "ethcore-ipc-nano"
version = "1.4.0" version = "1.5.0"
authors = ["Nikolay Volf <nikolay@ethcore.io>"] authors = ["Nikolay Volf <nikolay@ethcore.io>"]
license = "GPL-3.0" license = "GPL-3.0"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "ethcore-ipc" name = "ethcore-ipc"
version = "1.4.0" version = "1.5.0"
authors = ["Nikolay Volf <nikvolf@gmail.com>"] authors = ["Nikolay Volf <nikvolf@gmail.com>"]
license = "GPL-3.0" license = "GPL-3.0"

View File

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

View File

@ -34,11 +34,18 @@ git fetch origin 2>$GITLOG
git checkout -b $BRANCH git checkout -b $BRANCH
echo "*** Committing compiled files for $UTCDATE" echo "*** Committing compiled files for $UTCDATE"
mv build ../build.new
git add . 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" echo "*** Merging remote"
git merge origin/$BRANCH -X ours --commit -m "$UTCDATE [release]"
git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG
PRECOMPILED_HASH=`git rev-parse HEAD` PRECOMPILED_HASH=`git rev-parse HEAD`

1
js/scripts/test.js Normal file
View File

@ -0,0 +1 @@
// test script 4

View File

@ -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 tokens = func ? this._abi.encodeTokens(func.inputParamTypes(), values) : null;
const call = tokens ? func.encodeCall(tokens) : null; const call = tokens ? func.encodeCall(tokens) : null;
if (options.data && options.data.substr(0, 2) === '0x') { if (data && data.substr(0, 2) === '0x') {
options.data = options.data.substr(2); 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; return options;
} }
@ -209,10 +215,10 @@ export default class Contract {
_bindFunction = (func) => { _bindFunction = (func) => {
func.call = (options, values = []) => { 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 return this._api.eth
.call(callData) .call(callParams)
.then((encoded) => func.decodeOutput(encoded)) .then((encoded) => func.decodeOutput(encoded))
.then((tokens) => tokens.map((token) => token.value)) .then((tokens) => tokens.map((token) => token.value))
.then((returns) => returns.length === 1 ? returns[0] : returns); .then((returns) => returns.length === 1 ? returns[0] : returns);

View File

@ -112,11 +112,15 @@ export function inNumber10 (number) {
} }
export function inNumber16 (number) { export function inNumber16 (number) {
if (isInstanceOf(number, BigNumber)) { const bn = isInstanceOf(number, BigNumber)
return inHex(number.toString(16)); ? 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) { export function inOptions (options) {
@ -130,6 +134,9 @@ export function inOptions (options) {
case 'gas': case 'gas':
case 'gasPrice': case 'gasPrice':
options[key] = inNumber16((new BigNumber(options[key])).round());
break;
case 'value': case 'value':
case 'nonce': case 'nonce':
options[key] = inNumber16(options[key]); options[key] = inNumber16(options[key]);

View File

@ -128,6 +128,11 @@ export default class Parity {
.execute('parity_killAccount', inAddress(account), password); .execute('parity_killAccount', inAddress(account), password);
} }
removeAddress (address) {
return this._transport
.execute('parity_removeAddress', inAddress(address));
}
listGethAccounts () { listGethAccounts () {
return this._transport return this._transport
.execute('parity_listGethAccounts') .execute('parity_listGethAccounts')

View File

@ -68,6 +68,7 @@ export default class Personal {
this._accountsInfo(); this._accountsInfo();
return; return;
case 'parity_removeAddress':
case 'parity_setAccountName': case 'parity_setAccountName':
case 'parity_setAccountMeta': case 'parity_setAccountMeta':
this._accountsInfo(); this._accountsInfo();

File diff suppressed because one or more lines are too long

View File

@ -94,7 +94,6 @@ export default class Application extends Component {
tokenregInstance, tokenregInstance,
accounts: Object accounts: Object
.keys(accountsInfo) .keys(accountsInfo)
.filter((address) => !accountsInfo[address].meta.deleted)
.sort((a, b) => { .sort((a, b) => {
return (accountsInfo[b].uuid || '').localeCompare(accountsInfo[a].uuid || ''); return (accountsInfo[b].uuid || '').localeCompare(accountsInfo[a].uuid || '');
}) })

View File

@ -21,6 +21,9 @@ const muiTheme = getMuiTheme(lightBaseTheme);
import CircularProgress from 'material-ui/CircularProgress'; import CircularProgress from 'material-ui/CircularProgress';
import { Card, CardText } from 'material-ui/Card'; import { Card, CardText } from 'material-ui/Card';
import { nullableProptype } from '~/util/proptypes';
import styles from './application.css'; import styles from './application.css';
import Accounts from '../Accounts'; import Accounts from '../Accounts';
import Events from '../Events'; import Events from '../Events';
@ -28,8 +31,6 @@ import Lookup from '../Lookup';
import Names from '../Names'; import Names from '../Names';
import Records from '../Records'; import Records from '../Records';
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
export default class Application extends Component { export default class Application extends Component {
static childContextTypes = { static childContextTypes = {
muiTheme: PropTypes.object.isRequired, muiTheme: PropTypes.object.isRequired,
@ -44,8 +45,8 @@ export default class Application extends Component {
actions: PropTypes.object.isRequired, actions: PropTypes.object.isRequired,
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
contacts: PropTypes.object.isRequired, contacts: PropTypes.object.isRequired,
contract: nullable(PropTypes.object.isRequired), contract: nullableProptype(PropTypes.object.isRequired),
fee: nullable(PropTypes.object.isRequired), fee: nullableProptype(PropTypes.object.isRequired),
lookup: PropTypes.object.isRequired, lookup: PropTypes.object.isRequired,
events: PropTypes.object.isRequired, events: PropTypes.object.isRequired,
names: PropTypes.object.isRequired, names: PropTypes.object.isRequired,

View File

@ -18,19 +18,19 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { nullableProptype } from '~/util/proptypes';
import Application from './Application'; import Application from './Application';
import * as actions from './actions'; import * as actions from './actions';
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
class Container extends Component { class Container extends Component {
static propTypes = { static propTypes = {
actions: PropTypes.object.isRequired, actions: PropTypes.object.isRequired,
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
contacts: PropTypes.object.isRequired, contacts: PropTypes.object.isRequired,
contract: nullable(PropTypes.object.isRequired), contract: nullableProptype(PropTypes.object.isRequired),
owner: nullable(PropTypes.string.isRequired), owner: nullableProptype(PropTypes.string.isRequired),
fee: nullable(PropTypes.object.isRequired), fee: nullableProptype(PropTypes.object.isRequired),
lookup: PropTypes.object.isRequired, lookup: PropTypes.object.isRequired,
events: PropTypes.object.isRequired events: PropTypes.object.isRequired
}; };

View File

@ -19,21 +19,22 @@ import { Card, CardHeader, CardText } from 'material-ui/Card';
import TextField from 'material-ui/TextField'; import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton'; import RaisedButton from 'material-ui/RaisedButton';
import SearchIcon from 'material-ui/svg-icons/action/search'; import SearchIcon from 'material-ui/svg-icons/action/search';
import { nullableProptype } from '~/util/proptypes';
import renderAddress from '../ui/address.js'; import renderAddress from '../ui/address.js';
import renderImage from '../ui/image.js'; import renderImage from '../ui/image.js';
import recordTypeSelect from '../ui/record-type-select.js'; import recordTypeSelect from '../ui/record-type-select.js';
import styles from './lookup.css'; import styles from './lookup.css';
const nullable = (type) => React.PropTypes.oneOfType([ React.PropTypes.oneOf([ null ]), type ]);
export default class Lookup extends Component { export default class Lookup extends Component {
static propTypes = { static propTypes = {
actions: PropTypes.object.isRequired, actions: PropTypes.object.isRequired,
name: PropTypes.string.isRequired, name: PropTypes.string.isRequired,
type: PropTypes.string.isRequired, type: PropTypes.string.isRequired,
result: nullable(PropTypes.string.isRequired), result: nullableProptype(PropTypes.string.isRequired),
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
contacts: PropTypes.object.isRequired contacts: PropTypes.object.isRequired
} }

View File

@ -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 React, { Component, PropTypes } from 'react';
import { Card, CardHeader, CardText } from 'material-ui/Card'; import { Card, CardHeader, CardText } from 'material-ui/Card';
import TextField from 'material-ui/TextField'; import TextField from 'material-ui/TextField';

View File

@ -24,7 +24,6 @@ export const fetch = () => (dispatch) => {
.then((accountsInfo) => { .then((accountsInfo) => {
const addresses = Object const addresses = Object
.keys(accountsInfo) .keys(accountsInfo)
.filter((address) => accountsInfo[address] && !accountsInfo[address].meta.deleted)
.map((address) => ({ .map((address) => ({
...accountsInfo[address], ...accountsInfo[address],
address, address,

View File

@ -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: { listGethAccounts: {
desc: 'Returns a list of the accounts available from Geth', desc: 'Returns a list of the accounts available from Geth',
params: [], params: [],

View File

@ -102,7 +102,7 @@ export default class AddAddress extends Component {
if (!addressError) { if (!addressError) {
const contact = contacts[address]; const contact = contacts[address];
if (contact && !contact.meta.deleted) { if (contact) {
addressError = ERRORS.duplicateAddress; addressError = ERRORS.duplicateAddress;
} }
} }

View File

@ -231,7 +231,7 @@ export default class AddContract extends Component {
if (!addressError) { if (!addressError) {
const contract = contracts[address]; const contract = contracts[address];
if (contract && !contract.meta.deleted) { if (contract) {
addressError = ERRORS.duplicateAddress; addressError = ERRORS.duplicateAddress;
} }
} }

View File

@ -16,18 +16,62 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { Form, TypedInput, Input, AddressSelect } from '../../../ui'; import { Form, TypedInput, Input, AddressSelect, InputAddress } from '~/ui';
import { parseAbiType } from '../../../util/abi'; import { parseAbiType } from '~/util/abi';
import styles from '../createWallet.css';
export default class WalletDetails extends Component { export default class WalletDetails extends Component {
static propTypes = { static propTypes = {
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
wallet: PropTypes.object.isRequired, wallet: PropTypes.object.isRequired,
errors: PropTypes.object.isRequired, errors: PropTypes.object.isRequired,
onChange: PropTypes.func.isRequired onChange: PropTypes.func.isRequired,
walletType: PropTypes.string.isRequired
}; };
render () { 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; const { accounts, wallet, errors } = this.props;
return ( return (
@ -64,27 +108,36 @@ export default class WalletDetails extends Component {
param={ parseAbiType('address[]') } param={ parseAbiType('address[]') }
/> />
<TypedInput <div className={ styles.splitInput }>
label='required owners' <TypedInput
hint='number of required owners to accept a transaction' label='required owners'
value={ wallet.required } hint='number of required owners to accept a transaction'
error={ errors.required } value={ wallet.required }
onChange={ this.onRequiredChange } error={ errors.required }
param={ parseAbiType('uint') } onChange={ this.onRequiredChange }
/> param={ parseAbiType('uint') }
min={ 1 }
max={ wallet.owners.length + 1 }
/>
<TypedInput <TypedInput
label='wallet day limit' label='wallet day limit'
hint='number of days to wait for other owners confirmation' hint='amount of ETH spendable without confirmations'
value={ wallet.daylimit } value={ wallet.daylimit }
error={ errors.daylimit } error={ errors.daylimit }
onChange={ this.onDaylimitChange } onChange={ this.onDaylimitChange }
param={ parseAbiType('uint') } param={ parseAbiType('uint') }
/> isEth
/>
</div>
</Form> </Form>
); );
} }
onAddressChange = (_, address) => {
this.props.onChange({ address });
}
onAccoutChange = (_, account) => { onAccoutChange = (_, account) => {
this.props.onChange({ account }); this.props.onChange({ account });
} }

View File

@ -16,7 +16,8 @@
import React, { Component, PropTypes } from 'react'; 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'; import styles from '../createWallet.css';
@ -34,15 +35,21 @@ export default class WalletInfo extends Component {
daylimit: PropTypes.oneOfType([ daylimit: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
PropTypes.number PropTypes.number
]).isRequired ]).isRequired,
deployed: PropTypes.bool
}; };
render () { render () {
const { address, required, daylimit, name } = this.props; const { address, required, daylimit, name, deployed } = this.props;
return ( return (
<CompletedStep> <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> <div>
<CopyToClipboard data={ address } label='copy address to clipboard' /> <CopyToClipboard data={ address } label='copy address to clipboard' />
<IdentityIcon address={ address } inline center className={ styles.identityicon } /> <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. <code>{ required }</code> owners are required to confirm a transaction.
</p> </p>
<p> <p>
The daily limit is set to <code>{ daylimit }</code>. The daily limit is set to <code>{ fromWei(daylimit).toFormat() }</code> ETH.
</p> </p>
</CompletedStep> </CompletedStep>
); );
} }
renderOwners () { 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 }> <div key={ id } className={ styles.owner }>
<IdentityIcon address={ address } inline center className={ styles.identityicon } /> <IdentityIcon address={ address } inline center className={ styles.identityicon } />
<div className={ styles.address }>{ this.addressToString(address) }</div> <div className={ styles.address }>{ this.addressToString(address) }</div>

View File

@ -14,8 +14,4 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { PropTypes } from 'react'; export default from './walletType.js';
export default function nullableProptype (type) {
return PropTypes.oneOfType([ PropTypes.oneOf([ null ]), type ]);
}

View 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);
}
}

View File

@ -37,3 +37,22 @@
height: 24px; height: 24px;
} }
} }
.splitInput {
display: flex;
flex-direction: row;
> * {
flex: 1;
margin: 0 0.25em;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
}
}

View File

@ -21,8 +21,9 @@ import ActionDone from 'material-ui/svg-icons/action/done';
import ContentClear from 'material-ui/svg-icons/content/clear'; import ContentClear from 'material-ui/svg-icons/content/clear';
import NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward'; 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 WalletDetails from './WalletDetails';
import WalletInfo from './WalletInfo'; import WalletInfo from './WalletInfo';
import CreateWalletStore from './createWalletStore'; import CreateWalletStore from './createWalletStore';
@ -64,7 +65,7 @@ export default class CreateWallet extends Component {
visible visible
actions={ this.renderDialogActions() } actions={ this.renderDialogActions() }
current={ stage } current={ stage }
steps={ steps } steps={ steps.map((s) => s.title) }
waiting={ waiting } waiting={ waiting }
> >
{ this.renderPage() } { this.renderPage() }
@ -98,24 +99,35 @@ export default class CreateWallet extends Component {
required={ this.store.wallet.required } required={ this.store.wallet.required }
daylimit={ this.store.wallet.daylimit } daylimit={ this.store.wallet.daylimit }
name={ this.store.wallet.name } name={ this.store.wallet.name }
deployed={ this.store.deployed }
/> />
); );
default:
case 'DETAILS': case 'DETAILS':
return ( return (
<WalletDetails <WalletDetails
accounts={ accounts } accounts={ accounts }
wallet={ this.store.wallet } wallet={ this.store.wallet }
errors={ this.store.errors } errors={ this.store.errors }
walletType={ this.store.walletType }
onChange={ this.store.onChange } onChange={ this.store.onChange }
/> />
); );
default:
case 'TYPE':
return (
<WalletType
onChange={ this.store.onTypeChange }
type={ this.store.walletType }
/>
);
} }
} }
renderDialogActions () { renderDialogActions () {
const { step, hasErrors, rejected, onCreate } = this.store; const { step, hasErrors, rejected, onCreate, onNext, onAdd } = this.store;
const cancelBtn = ( const cancelBtn = (
<Button <Button
@ -149,12 +161,11 @@ export default class CreateWallet extends Component {
/> />
); );
const createBtn = ( const nextBtn = (
<Button <Button
icon={ <NavigationArrowForward /> } icon={ <NavigationArrowForward /> }
label='Create' label='Next'
disabled={ hasErrors } onClick={ onNext }
onClick={ onCreate }
/> />
); );
@ -169,9 +180,30 @@ export default class CreateWallet extends Component {
case 'INFO': case 'INFO':
return [ doneBtn ]; return [ doneBtn ];
default:
case 'DETAILS': 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 ];
} }
} }

View File

@ -16,26 +16,29 @@
import { observable, computed, action, transaction } from 'mobx'; import { observable, computed, action, transaction } from 'mobx';
import { ERRORS, validateUint, validateAddress, validateName } from '../../util/validation'; import { validateUint, validateAddress, validateName } from '~/util/validation';
import { ERROR_CODES } from '../../api/transport/error'; import { ERROR_CODES } from '~/api/transport/error';
import { wallet as walletAbi } from '../../contracts/abi'; import Contract from '~/api/contract';
import { wallet as walletCode } from '../../contracts/code'; import { wallet as walletAbi } from '~/contracts/abi';
import { wallet as walletCode } from '~/contracts/code';
import WalletsUtils from '~/util/wallets';
const STEPS = { const STEPS = {
TYPE: { title: 'wallet type' },
DETAILS: { title: 'wallet details' }, DETAILS: { title: 'wallet details' },
DEPLOYMENT: { title: 'wallet deployment', waiting: true }, DEPLOYMENT: { title: 'wallet deployment', waiting: true },
INFO: { title: 'wallet informaton' } INFO: { title: 'wallet informaton' }
}; };
const STEPS_KEYS = Object.keys(STEPS);
export default class CreateWalletStore { export default class CreateWalletStore {
@observable step = null; @observable step = null;
@observable rejected = false; @observable rejected = false;
@observable deployState = null; @observable deployState = null;
@observable deployError = null; @observable deployError = null;
@observable deployed = false;
@observable txhash = null; @observable txhash = null;
@ -49,45 +52,103 @@ export default class CreateWalletStore {
name: '', name: '',
description: '' description: ''
}; };
@observable walletType = 'MULTISIG';
@observable errors = { @observable errors = {
account: null, account: null,
address: null,
owners: null, owners: null,
required: null, required: null,
daylimit: null, daylimit: null,
name: null
name: ERRORS.invalidName
}; };
@computed get stage () { @computed get stage () {
return STEPS_KEYS.findIndex((k) => k === this.step); return this.stepsKeys.findIndex((k) => k === this.step);
} }
@computed get hasErrors () { @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);
}
return errorKey !== 'address';
})
.find((key) => !!this.errors[key]);
} }
steps = Object.values(STEPS).map((s) => s.title); @computed get stepsKeys () {
waiting = Object.values(STEPS) return this.steps.map((s) => s.key);
.map((s, idx) => ({ idx, waiting: s.waiting })) }
.filter((s) => s.waiting)
.map((s) => s.idx); @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) { constructor (api, accounts) {
this.api = api; this.api = api;
this.step = STEPS_KEYS[0]; this.step = this.stepsKeys[0];
this.wallet.account = Object.values(accounts)[0].address; 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) => { @action onChange = (_wallet) => {
const newWallet = Object.assign({}, this.wallet, _wallet); const newWallet = Object.assign({}, this.wallet, _wallet);
const { errors, wallet } = this.validateWallet(newWallet); this.validateWallet(newWallet);
}
transaction(() => { @action onAdd = () => {
this.wallet = wallet; if (this.hasErrors) {
this.errors = errors; 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.owners = owners;
this.wallet.required = require.toNumber();
this.wallet.dailylimit = dailylimit.limit;
});
return this.addWallet(this.wallet);
});
} }
@action onCreate = () => { @action onCreate = () => {
@ -97,7 +158,7 @@ export default class CreateWalletStore {
this.step = 'DEPLOYMENT'; this.step = 'DEPLOYMENT';
const { account, owners, required, daylimit, name, description } = this.wallet; const { account, owners, required, daylimit } = this.wallet;
const options = { const options = {
data: walletCode, data: walletCode,
@ -108,24 +169,9 @@ export default class CreateWalletStore {
.newContract(walletAbi) .newContract(walletAbi)
.deploy(options, [ owners, required, daylimit ], this.onDeploymentState) .deploy(options, [ owners, required, daylimit ], this.onDeploymentState)
.then((address) => { .then((address) => {
return Promise this.deployed = true;
.all([ this.wallet.address = address;
this.api.parity.setAccountName(address, name), return this.addWallet(this.wallet);
this.api.parity.setAccountMeta(address, {
abi: walletAbi,
wallet: true,
timestamp: Date.now(),
deleted: false,
description,
name
})
])
.then(() => {
transaction(() => {
this.wallet.address = address;
this.step = 'INFO';
});
});
}) })
.catch((error) => { .catch((error) => {
if (error.code === ERROR_CODES.REQUEST_REJECTED) { 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) => { onDeploymentState = (error, data) => {
if (error) { if (error) {
return console.error('createWallet::onDeploymentState', 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 accountValidation = validateAddress(_wallet.account);
const requiredValidation = validateUint(_wallet.required); const requiredValidation = validateUint(_wallet.required);
const daylimitValidation = validateUint(_wallet.daylimit); const daylimitValidation = validateUint(_wallet.daylimit);
const nameValidation = validateName(_wallet.name); const nameValidation = validateName(_wallet.name);
const errors = { const errors = {
address: addressValidation.addressError,
account: accountValidation.addressError, account: accountValidation.addressError,
required: requiredValidation.valueError, required: requiredValidation.valueError,
daylimit: daylimitValidation.valueError, daylimit: daylimitValidation.valueError,
@ -188,12 +257,16 @@ export default class CreateWalletStore {
const wallet = { const wallet = {
..._wallet, ..._wallet,
address: addressValidation.address,
account: accountValidation.address, account: accountValidation.address,
required: requiredValidation.value, required: requiredValidation.value,
daylimit: daylimitValidation.value, daylimit: daylimitValidation.value,
name: nameValidation.name name: nameValidation.name
}; };
return { errors, wallet }; transaction(() => {
this.wallet = wallet;
this.errors = errors;
});
} }
} }

View File

@ -19,7 +19,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { ConfirmDialog, IdentityIcon, IdentityName, Input } from '~/ui'; import { ConfirmDialog, IdentityIcon, IdentityName, Input } from '~/ui';
import { newError } from '../../redux/actions'; import { newError } from '~/redux/actions';
import styles from './deleteAccount.css'; import styles from './deleteAccount.css';

View File

@ -17,7 +17,8 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { MenuItem } from 'material-ui'; 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'; import styles from '../executeContract.css';
@ -74,7 +75,7 @@ export default class DetailsStep extends Component {
const functions = contract.functions const functions = contract.functions
.filter((func) => !func.constant) .filter((func) => !func.constant)
.sort((a, b) => a.name.localeCompare(b.name)) .sort((a, b) => (a.name || '').localeCompare(b.name || ''))
.map((func) => { .map((func) => {
const params = (func.abi.inputs || []) const params = (func.abi.inputs || [])
.map((input, index) => { .map((input, index) => {
@ -125,56 +126,22 @@ export default class DetailsStep extends Component {
} }
return (func.abi.inputs || []).map((input, index) => { return (func.abi.inputs || []).map((input, index) => {
const onChange = (event, value) => onValueChange(event, index, value); const onChange = (value) => onValueChange(null, index, value);
const onSelect = (event, _index, value) => onValueChange(event, index, value);
const onSubmit = (value) => onValueChange(null, index, value);
const label = `${input.name}: ${input.type}`; const label = `${input.name}: ${input.type}`;
let inputbox;
switch (input.type) {
case 'address':
inputbox = (
<InputAddressSelect
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 ( return (
<div className={ styles.funcparams } key={ index }> <div
{ inputbox } key={ `${index}_${input.name || ''}` }
className={ styles.funcparams }
>
<TypedInput
label={ label }
value={ values[index] }
error={ valuesError[index] }
onChange={ onChange }
accounts={ accounts }
param={ parseAbiType(input.type) }
/>
</div> </div>
); );
}); });

View File

@ -23,6 +23,7 @@ import ContentClear from 'material-ui/svg-icons/content/clear';
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui'; import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui';
import { MAX_GAS_ESTIMATION } from '../../util/constants'; import { MAX_GAS_ESTIMATION } from '../../util/constants';
import { validateAddress, validateUint } from '../../util/validation'; import { validateAddress, validateUint } from '../../util/validation';
import { parseAbiType } from '~/util/abi';
import DetailsStep from './DetailsStep'; import DetailsStep from './DetailsStep';
@ -66,7 +67,7 @@ class ExecuteContract extends Component {
const { contract } = this.props; const { contract } = this.props;
const functions = contract.functions const functions = contract.functions
.filter((func) => !func.constant) .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]); this.onFuncChange(null, functions[0]);
} }
@ -111,7 +112,7 @@ class ExecuteContract extends Component {
<Button <Button
key='postTransaction' key='postTransaction'
label='post transaction' label='post transaction'
disabled={ sending || hasError } disabled={ !!(sending || hasError) }
icon={ <IdentityIcon address={ fromAddress } button /> } icon={ <IdentityIcon address={ fromAddress } button /> }
onClick={ this.postTransaction } /> onClick={ this.postTransaction } />
]; ];
@ -174,23 +175,9 @@ class ExecuteContract extends Component {
} }
onFuncChange = (event, func) => { onFuncChange = (event, func) => {
const values = func.inputs.map((input) => { const values = (func.abi.inputs || []).map((input) => {
switch (input.kind.type) { const parsedType = parseAbiType(input.type);
case 'address': return parsedType.default;
return '0x';
case 'bool':
return false;
case 'bytes':
return '0x';
case 'uint':
return '0';
default:
return '';
}
}); });
this.setState({ this.setState({

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import nullable from '../../../util/nullable-proptype';
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { Checkbox } from 'material-ui'; import { Checkbox } from 'material-ui';
import InfoIcon from 'material-ui/svg-icons/action/info-outline'; 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 { fromWei } from '~/api/util/wei';
import { Form, Input } from '~/ui'; import { Form, Input } from '~/ui';
import { nullableProptype } from '~/util/proptypes';
import { termsOfService } from '../../../3rdparty/sms-verification'; import { termsOfService } from '../../../3rdparty/sms-verification';
import styles from './gatherData.css'; import styles from './gatherData.css';
@ -32,8 +32,8 @@ export default class GatherData extends Component {
static propTypes = { static propTypes = {
fee: React.PropTypes.instanceOf(BigNumber), fee: React.PropTypes.instanceOf(BigNumber),
isNumberValid: PropTypes.bool.isRequired, isNumberValid: PropTypes.bool.isRequired,
isVerified: nullable(PropTypes.bool.isRequired), isVerified: nullableProptype(PropTypes.bool.isRequired),
hasRequested: nullable(PropTypes.bool.isRequired), hasRequested: nullableProptype(PropTypes.bool.isRequired),
setNumber: PropTypes.func.isRequired, setNumber: PropTypes.func.isRequired,
setConsentGiven: PropTypes.func.isRequired setConsentGiven: PropTypes.func.isRequired
} }

View File

@ -15,8 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import nullable from '../../../util/nullable-proptype';
import { nullableProptype } from '~/util/proptypes';
import TxHash from '~/ui/TxHash'; import TxHash from '~/ui/TxHash';
import { import {
POSTING_CONFIRMATION, POSTED_CONFIRMATION POSTING_CONFIRMATION, POSTED_CONFIRMATION
@ -27,7 +27,7 @@ import styles from './sendConfirmation.css';
export default class SendConfirmation extends Component { export default class SendConfirmation extends Component {
static propTypes = { static propTypes = {
step: PropTypes.any.isRequired, step: PropTypes.any.isRequired,
tx: nullable(PropTypes.any.isRequired) tx: nullableProptype(PropTypes.any.isRequired)
} }
render () { render () {

View File

@ -15,8 +15,8 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import nullable from '../../../util/nullable-proptype';
import { nullableProptype } from '~/util/proptypes';
import TxHash from '~/ui/TxHash'; import TxHash from '~/ui/TxHash';
import { import {
POSTING_REQUEST, POSTED_REQUEST, REQUESTING_SMS POSTING_REQUEST, POSTED_REQUEST, REQUESTING_SMS
@ -27,7 +27,7 @@ import styles from './sendRequest.css';
export default class SendRequest extends Component { export default class SendRequest extends Component {
static propTypes = { static propTypes = {
step: PropTypes.any.isRequired, step: PropTypes.any.isRequired,
tx: nullable(PropTypes.any.isRequired) tx: nullableProptype(PropTypes.any.isRequired)
} }
render () { render () {

View File

@ -17,11 +17,10 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { Checkbox, MenuItem } from 'material-ui'; import { Checkbox, MenuItem } from 'material-ui';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import Form, { Input, InputAddressSelect, AddressSelect, Select } from '~/ui/Form'; 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 imageUnknown from '../../../../assets/images/contracts/unknown-64x64.png';
import styles from '../transfer.css'; import styles from '../transfer.css';
@ -240,11 +239,7 @@ export default class Details extends Component {
} }
renderTokenSelect () { renderTokenSelect () {
const { balance, images, tag, wallet } = this.props; const { balance, images, tag } = this.props;
if (wallet) {
return null;
}
return ( return (
<TokenSelect <TokenSelect

View File

@ -16,10 +16,14 @@
import { observable, computed, action, transaction } from 'mobx'; import { observable, computed, action, transaction } from 'mobx';
import BigNumber from 'bignumber.js'; 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 ERRORS from './errors';
import { ERROR_CODES } from '~/api/transport/error'; 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 = { const TITLES = {
transfer: 'transfer details', transfer: 'transfer details',
@ -71,6 +75,9 @@ export default class TransferStore {
gasLimit = null; gasLimit = null;
onClose = null; onClose = null;
senders = null;
sendersBalances = null;
isWallet = false; isWallet = false;
wallet = null; wallet = null;
@ -108,19 +115,22 @@ export default class TransferStore {
constructor (api, props) { constructor (api, props) {
this.api = api; this.api = api;
const { account, balance, gasLimit, senders, onClose } = props; const { account, balance, gasLimit, senders, onClose, newError, sendersBalances } = props;
this.account = account; this.account = account;
this.balance = balance; this.balance = balance;
this.gasLimit = gasLimit; this.gasLimit = gasLimit;
this.onClose = onClose; this.onClose = onClose;
this.isWallet = account && account.wallet; this.isWallet = account && account.wallet;
this.newError = newError;
if (this.isWallet) { if (this.isWallet) {
this.wallet = props.wallet; this.wallet = props.wallet;
this.walletContract = new Contract(this.api, walletAbi);
} }
if (senders) { if (senders) {
this.senders = senders;
this.sendersBalances = sendersBalances;
this.senderError = ERRORS.requireSender; this.senderError = ERRORS.requireSender;
} }
} }
@ -217,6 +227,10 @@ export default class TransferStore {
this.txhash = txhash; this.txhash = txhash;
this.busyState = 'Your transaction has been posted to the network'; this.busyState = 'Your transaction has been posted to the network';
}); });
if (this.isWallet) {
return this._attachWalletOperation(txhash);
}
}) })
.catch((error) => { .catch((error) => {
this.sending = false; 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) => { @action _onUpdateAll = (valueAll) => {
this.valueAll = valueAll; this.valueAll = valueAll;
this.recalculateGas(); this.recalculateGas();
@ -355,38 +397,52 @@ export default class TransferStore {
} }
@action recalculate = () => { @action recalculate = () => {
const { account, balance } = this; const { account } = this;
if (!account || !balance) { if (!account || !this.balance) {
return; 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 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 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 { value, valueError } = this;
let totalEth = gasTotal; let totalEth = gasTotal;
let totalError = null; let totalError = null;
if (valueAll) { if (valueAll) {
if (isEth) { if (isEth && !isWallet) {
const bn = this.api.util.fromWei(availableEth.minus(gasTotal)); const bn = this.api.util.fromWei(availableEth.minus(gasTotal));
value = (bn.lt(0) ? new BigNumber(0.0) : bn).toString(); value = (bn.lt(0) ? new BigNumber(0.0) : bn).toString();
} else if (isEth) {
value = (available.lt(0) ? new BigNumber(0.0) : available).toString();
} else { } else {
value = available.div(format).toString(); value = available.toString();
} }
} }
if (isEth) { if (isEth && !isWallet) {
totalEth = totalEth.plus(this.api.util.toWei(value || 0)); 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; valueError = ERRORS.largeAmount;
} else if (valueError === ERRORS.largeAmount) { } else if (valueError === ERRORS.largeAmount) {
valueError = null; valueError = null;
@ -409,26 +465,52 @@ export default class TransferStore {
return this._getTransferMethod().postTransaction(options, values); return this._getTransferMethod().postTransaction(options, values);
} }
estimateGas () { _estimateGas (forceToken = false) {
const { options, values } = this._getTransferParams(true); const { options, values } = this._getTransferParams(true, forceToken);
return this._getTransferMethod(true).estimateGas(options, values); 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; const { isEth, isWallet } = this;
if (isEth && !isWallet) { if (isEth && !isWallet && !forceToken) {
return gas ? this.api.eth : this.api.parity; return gas ? this.api.eth : this.api.parity;
} }
if (isWallet) { if (isWallet && !forceToken) {
return this.wallet.instance.execute; return this.wallet.instance.execute;
} }
return this.token.contract.instance.transfer; 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 { isEth, isWallet } = this;
const to = (isEth && !isWallet) ? this.recipient const to = (isEth && !isWallet) ? this.recipient
@ -446,27 +528,30 @@ export default class TransferStore {
options.gas = MAX_GAS_ESTIMATION; options.gas = MAX_GAS_ESTIMATION;
} }
if (isEth && !isWallet) { if (isEth && !isWallet && !forceToken) {
options.value = this.api.util.toWei(this.value || 0); options.value = this.api.util.toWei(this.value || 0);
options.data = this._getData(gas);
if (this.data && this.data.length) {
options.data = this.data;
}
return { options, values: [] }; return { options, values: [] };
} }
const values = isWallet if (isWallet && !forceToken) {
? [ const to = isEth ? this.recipient : this.token.contract.address;
this.recipient, const value = isEth ? this.api.util.toWei(this.value || 0) : new BigNumber(0);
this.api.util.toWei(this.value || 0),
this.data || '' const values = [
] to, value,
: [ this._getData(gas)
this.recipient,
new BigNumber(this.value || 0).mul(this.token.format).toFixed(0)
]; ];
return { options, values };
}
const values = [
this.recipient,
new BigNumber(this.value || 0).mul(this.token.format).toFixed(0)
];
return { options, values }; return { options, values };
} }

View File

@ -18,6 +18,7 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { pick } from 'lodash';
import ActionDoneAll from 'material-ui/svg-icons/action/done-all'; import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import ContentClear from 'material-ui/svg-icons/content/clear'; 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 NavigationArrowForward from 'material-ui/svg-icons/navigation/arrow-forward';
import { newError } from '~/ui/Errors/actions'; import { newError } from '~/ui/Errors/actions';
import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui'; import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash, Input } from '~/ui';
import nullableProptype from '~/util/nullable-proptype'; import { nullableProptype } from '~/util/proptypes';
import Details from './Details'; import Details from './Details';
import Extras from './Extras'; import Extras from './Extras';
@ -45,10 +46,10 @@ class Transfer extends Component {
gasLimit: PropTypes.object.isRequired, gasLimit: PropTypes.object.isRequired,
images: PropTypes.object.isRequired, images: PropTypes.object.isRequired,
account: PropTypes.object,
senders: nullableProptype(PropTypes.object), senders: nullableProptype(PropTypes.object),
sendersBalances: nullableProptype(PropTypes.object),
account: PropTypes.object,
balance: PropTypes.object, balance: PropTypes.object,
balances: PropTypes.object,
wallet: PropTypes.object, wallet: PropTypes.object,
onClose: PropTypes.func onClose: PropTypes.func
} }
@ -133,6 +134,25 @@ class Transfer extends Component {
return ( return (
<CompletedStep> <CompletedStep>
<TxHash hash={ txhash } /> <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> </CompletedStep>
); );
} }
@ -277,7 +297,8 @@ function mapStateToProps (initState, initProps) {
return (state) => { return (state) => {
const { gasLimit } = state.nodeStatus; const { gasLimit } = state.nodeStatus;
return { gasLimit, wallet, senders }; const sendersBalances = senders ? pick(state.balances.balances, Object.keys(senders)) : null;
return { gasLimit, wallet, senders, sendersBalances };
}; };
} }

View 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';

View 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;
}

View 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);

View 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;
});
}
}

View File

@ -29,6 +29,7 @@ import Transfer from './Transfer';
import PasswordManager from './PasswordManager'; import PasswordManager from './PasswordManager';
import SaveContract from './SaveContract'; import SaveContract from './SaveContract';
import LoadContract from './LoadContract'; import LoadContract from './LoadContract';
import WalletSettings from './WalletSettings';
export { export {
AddAddress, AddAddress,
@ -45,5 +46,6 @@ export {
Transfer, Transfer,
PasswordManager, PasswordManager,
LoadContract, LoadContract,
SaveContract SaveContract,
WalletSettings
}; };

View File

@ -113,7 +113,7 @@ export function fetchTokens (_tokenIds) {
export function fetchBalances (_addresses) { export function fetchBalances (_addresses) {
return (dispatch, getState) => { return (dispatch, getState) => {
const { api, personal } = getState(); const { api, personal } = getState();
const { visibleAccounts } = personal; const { visibleAccounts, accounts } = personal;
const addresses = uniq(_addresses || visibleAccounts || []); const addresses = uniq(_addresses || visibleAccounts || []);
@ -123,12 +123,14 @@ export function fetchBalances (_addresses) {
const fullFetch = addresses.length === 1; const fullFetch = addresses.length === 1;
const fetchedAddresses = uniq(addresses.concat(Object.keys(accounts)));
return Promise return Promise
.all(addresses.map((addr) => fetchAccount(addr, api, fullFetch))) .all(fetchedAddresses.map((addr) => fetchAccount(addr, api, fullFetch)))
.then((accountsBalances) => { .then((accountsBalances) => {
const balances = {}; const balances = {};
addresses.forEach((addr, idx) => { fetchedAddresses.forEach((addr, idx) => {
balances[addr] = accountsBalances[idx]; balances[addr] = accountsBalances[idx];
}); });

View File

@ -92,7 +92,7 @@ function findImports (path) {
return { error: 'File not found' }; return { error: 'File not found' };
} }
function compile (data) { function compile (data, optimized = 1) {
const { sourcecode, build } = data; const { sourcecode, build } = data;
const { longVersion } = build; const { longVersion } = build;
@ -109,7 +109,7 @@ function compile (data) {
'': sourcecode '': sourcecode
}; };
const compiled = compiler.compile({ sources: input }, 0, findImports); const compiled = compiler.compile({ sources: input }, optimized, findImports);
self.lastCompile = { self.lastCompile = {
version: longVersion, result: compiled, version: longVersion, result: compiled,

View File

@ -23,6 +23,7 @@ export default class Personal {
} }
start () { start () {
this._removeDeleted();
this._subscribeAccountsInfo(); this._subscribeAccountsInfo();
} }
@ -40,4 +41,29 @@ export default class Personal {
console.log('personal._subscribeAccountsInfo', 'subscriptionId', subscriptionId); 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);
});
}
} }

View File

@ -27,7 +27,7 @@ export function personalAccountsInfo (accountsInfo) {
Object.keys(accountsInfo || {}) Object.keys(accountsInfo || {})
.map((address) => Object.assign({}, accountsInfo[address], { address })) .map((address) => Object.assign({}, accountsInfo[address], { address }))
.filter((account) => !account.meta.deleted) .filter((account) => account.uuid || !account.meta.deleted)
.forEach((account) => { .forEach((account) => {
if (account.uuid) { if (account.uuid) {
accounts[account.address] = account; accounts[account.address] = account;

View File

@ -14,16 +14,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // 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 Contract from '~/api/contract';
import { wallet as WALLET_ABI } from '../../contracts/abi'; import { wallet as WALLET_ABI } from '~/contracts/abi';
import { bytesToHex, toHex } from '../../api/util/format'; 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 { 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_OWNERS = 'owners';
const UPDATE_REQUIRE = 'require'; const UPDATE_REQUIRE = 'require';
@ -56,7 +58,7 @@ function modifyOperation (method, address, owner, operation) {
contract.instance[method] contract.instance[method]
.estimateGas(options, values) .estimateGas(options, values)
.then((gas) => { .then((gas) => {
options.gas = gas; options.gas = gas.mul(1.2);
return contract.instance[method].postTransaction(options, values); return contract.instance[method].postTransaction(options, values);
}) })
.then((requestId) => { .then((requestId) => {
@ -226,7 +228,7 @@ function fetchWalletInfo (contract, update, getState) {
const owners = ownersUpdate && ownersUpdate.value || null; const owners = ownersUpdate && ownersUpdate.value || null;
const transactions = transactionsUpdate && transactionsUpdate.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) => { .then((update) => {
updates.push(update); updates.push(update);
return updates; return updates;
@ -247,58 +249,9 @@ function fetchWalletInfo (contract, update, getState) {
} }
function fetchWalletTransactions (contract) { function fetchWalletTransactions (contract) {
const walletInstance = contract.instance; return WalletsUtils
const signatures = { .fetchTransactions(contract)
single: toHex(walletInstance.SingleTransact.signature), .then((transactions) => {
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 { return {
key: UPDATE_TRANSACTIONS, key: UPDATE_TRANSACTIONS,
value: transactions value: transactions
@ -307,13 +260,8 @@ function fetchWalletTransactions (contract) {
} }
function fetchWalletOwners (contract) { function fetchWalletOwners (contract) {
const walletInstance = contract.instance; return WalletsUtils
.fetchOwners(contract)
return walletInstance
.m_numOwners.call()
.then((mNumOwners) => {
return Promise.all(range(mNumOwners.toNumber()).map((idx) => walletInstance.getOwner.call({}, [ idx ])));
})
.then((value) => { .then((value) => {
return { return {
key: UPDATE_OWNERS, key: UPDATE_OWNERS,
@ -323,10 +271,8 @@ function fetchWalletOwners (contract) {
} }
function fetchWalletRequire (contract) { function fetchWalletRequire (contract) {
const walletInstance = contract.instance; return WalletsUtils
.fetchRequire(contract)
return walletInstance
.m_required.call()
.then((value) => { .then((value) => {
return { return {
key: UPDATE_REQUIRE, key: UPDATE_REQUIRE,
@ -336,97 +282,123 @@ function fetchWalletRequire (contract) {
} }
function fetchWalletDailylimit (contract) { function fetchWalletDailylimit (contract) {
const walletInstance = contract.instance; return WalletsUtils
.fetchDailylimit(contract)
return Promise .then((value) => {
.all([
walletInstance.m_dailyLimit.call(),
walletInstance.m_spentToday.call(),
walletInstance.m_lastDay.call()
])
.then((values) => {
return { return {
key: UPDATE_DAILYLIMIT, key: UPDATE_DAILYLIMIT,
value: { value
limit: values[0],
spent: values[1],
last: values[2]
}
}; };
}); });
} }
function fetchWalletConfirmations (contract, _owners = null, _transactions = null, getState) { function fetchWalletConfirmations (contract, _operations, _owners = null, _transactions = null, getState) {
const walletInstance = contract.instance; const walletInstance = contract.instance;
const wallet = getState().wallet.wallets[contract.address]; const wallet = getState().wallet.wallets[contract.address];
const owners = _owners || (wallet && wallet.owners) || null; const owners = _owners || (wallet && wallet.owners) || null;
const transactions = _transactions || (wallet && wallet.transactions) || 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;
.ConfirmationNeeded
.getAllLogs()
.then((logs) => {
return logs.sort((logA, logB) => {
const comp = logA.blockNumber.comparedTo(logB.blockNumber);
if (comp !== 0) { if (fullLoad) {
return comp; 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);
if (comp !== 0) {
return comp;
}
return logA.transactionIndex.comparedTo(logB.transactionIndex);
});
})
.then((confirmations) => {
if (confirmations.length === 0) {
return confirmations;
} }
return logA.transactionIndex.comparedTo(logB.transactionIndex); // Only fetch confirmations for operations not
// yet confirmed (ie. not yet a transaction)
if (transactions) {
const operations = transactions
.filter((t) => t.operation)
.map((t) => t.operation);
return confirmations.filter((confirmation) => {
return !operations.includes(confirmation.operation);
});
}
return confirmations;
}); });
}) } else {
.then((logs) => { const { confirmations } = wallet;
return logs.map((log) => ({ const nextConfirmations = confirmations
initiator: log.params.initiator.value, .filter((conf) => _operations.includes(conf.operation));
to: log.params.to.value,
data: log.params.data.value, promise = Promise.resolve(nextConfirmations);
value: log.params.value.value, }
operation: bytesToHex(log.params.operation.value),
transactionHash: log.transactionHash, return promise
blockNumber: log.blockNumber,
confirmedBy: []
}));
})
.then((confirmations) => { .then((confirmations) => {
if (confirmations.length === 0) { if (confirmations.length === 0) {
return confirmations; return confirmations;
} }
if (transactions) { const uniqConfirmations = Object.values(
const operations = transactions confirmations.reduce((confirmations, confirmation) => {
.filter((t) => t.operation) confirmations[confirmation.operation] = confirmation;
.map((t) => t.operation); return confirmations;
}, {})
);
return confirmations.filter((confirmation) => { const operations = uniqConfirmations.map((conf) => conf.operation);
return !operations.includes(confirmation.operation);
});
}
return confirmations;
})
.then((confirmations) => {
if (confirmations.length === 0) {
return confirmations;
}
const operations = confirmations.map((conf) => conf.operation);
return Promise return Promise
.all(operations.map((op) => fetchOperationConfirmations(contract, op, owners))) .all(operations.map((op) => fetchOperationConfirmations(contract, op, owners)))
.then((confirmedBys) => { .then((confirmedBys) => {
confirmations.forEach((_, index) => { uniqConfirmations.forEach((_, index) => {
confirmations[index].confirmedBy = confirmedBys[index]; uniqConfirmations[index].confirmedBy = confirmedBys[index];
}); });
return confirmations; return uniqConfirmations;
}); });
}) })
.then((confirmations) => { .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 { return {
key: UPDATE_CONFIRMATIONS, key: UPDATE_CONFIRMATIONS,
value: confirmations value: nextConfirmations
}; };
}); });
} }
@ -481,7 +453,10 @@ function parseLogs (logs) {
logs.forEach((log) => { logs.forEach((log) => {
const { address, topics } = log; const { address, topics } = log;
const eventSignature = toHex(topics[0]); const eventSignature = toHex(topics[0]);
const prev = updates[address] || { address }; const prev = updates[address] || {
[ UPDATE_DAILYLIMIT ]: true,
address
};
switch (eventSignature) { switch (eventSignature) {
case signatures.OwnerChanged: case signatures.OwnerChanged:
@ -500,16 +475,18 @@ function parseLogs (logs) {
}; };
return; return;
case signatures.ConfirmationNeeded:
case signatures.Confirmation: case signatures.Confirmation:
case signatures.Revoke: case signatures.Revoke:
const operation = log.params.operation.value; const operation = bytesToHex(log.params.operation.value);
updates[address] = { updates[address] = {
...prev, ...prev,
[ UPDATE_CONFIRMATIONS ]: uniq( [ UPDATE_CONFIRMATIONS ]: uniq(
(prev.operations || []).concat(operation) (prev[UPDATE_CONFIRMATIONS] || []).concat(operation)
) )
}; };
return; return;
case signatures.Deposit: case signatures.Deposit:
@ -520,17 +497,6 @@ function parseLogs (logs) {
[ UPDATE_TRANSACTIONS ]: true [ UPDATE_TRANSACTIONS ]: true
}; };
return; return;
case signatures.ConfirmationNeeded:
const op = log.params.operation.value;
updates[address] = {
...prev,
[ UPDATE_CONFIRMATIONS ]: uniq(
(prev.operations || []).concat(op)
)
};
return;
} }
}); });

View File

@ -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 React, { Component, PropTypes } from 'react';
import ActionDone from 'material-ui/svg-icons/action/done'; import ActionDone from 'material-ui/svg-icons/action/done';
import ContentClear from 'material-ui/svg-icons/content/clear'; import ContentClear from 'material-ui/svg-icons/content/clear';
import { nodeOrStringProptype } from '~/util/proptypes';
import Button from '../Button'; import Button from '../Button';
import Modal from '../Modal'; import Modal from '../Modal';
@ -15,9 +33,7 @@ export default class ConfirmDialog extends Component {
iconDeny: PropTypes.node, iconDeny: PropTypes.node,
labelConfirm: PropTypes.string, labelConfirm: PropTypes.string,
labelDeny: PropTypes.string, labelDeny: PropTypes.string,
title: PropTypes.oneOfType([ title: nodeOrStringProptype().isRequired,
PropTypes.node, PropTypes.string
]).isRequired,
visible: PropTypes.bool.isRequired, visible: PropTypes.bool.isRequired,
onConfirm: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired,
onDeny: PropTypes.func.isRequired onDeny: PropTypes.func.isRequired

View File

@ -16,17 +16,15 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { nodeOrStringProptype } from '~/util/proptypes';
import styles from './title.css'; import styles from './title.css';
export default class Title extends Component { export default class Title extends Component {
static propTypes = { static propTypes = {
className: PropTypes.string, className: PropTypes.string,
title: PropTypes.oneOfType([ title: nodeOrStringProptype(),
PropTypes.string, PropTypes.node byline: nodeOrStringProptype()
]),
byline: PropTypes.oneOfType([
PropTypes.string, PropTypes.node
])
} }
state = { state = {

View File

@ -17,6 +17,8 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { Card } from 'material-ui/Card'; import { Card } from 'material-ui/Card';
import { nodeOrStringProptype } from '~/util/proptypes';
import Title from './Title'; import Title from './Title';
import styles from './container.css'; import styles from './container.css';
@ -28,9 +30,7 @@ export default class Container extends Component {
compact: PropTypes.bool, compact: PropTypes.bool,
light: PropTypes.bool, light: PropTypes.bool,
style: PropTypes.object, style: PropTypes.object,
title: PropTypes.oneOfType([ title: nodeOrStringProptype()
PropTypes.string, PropTypes.node
])
} }
render () { render () {

View File

@ -20,5 +20,14 @@
} }
.data { .data {
flex: 1;
font-family: monospace; font-family: monospace;
padding: 0 0.5em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.container {
display: flex;
} }

View File

@ -80,7 +80,13 @@ class CopyToClipboard extends Component {
onCopy = () => { onCopy = () => {
const { data, onCopy, cooldown, showSnackbar } = this.props; 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({ this.setState({
copied: true, copied: true,

View File

@ -170,7 +170,7 @@ export default class AddressSelect extends Component {
handleFilter = (searchText, name, item) => { handleFilter = (searchText, name, item) => {
const { address } = item; const { address } = item;
const entry = this.state.entries[address]; const entry = this.state.entries[address];
const lowCaseSearch = searchText.toLowerCase(); const lowCaseSearch = (searchText || '').toLowerCase();
return [entry.name, entry.address] return [entry.name, entry.address]
.some(text => text.toLowerCase().indexOf(lowCaseSearch) !== -1); .some(text => text.toLowerCase().indexOf(lowCaseSearch) !== -1);

View File

@ -120,7 +120,7 @@ export default class AutoComplete extends Component {
switch (keycode(event)) { switch (keycode(event)) {
case 'down': case 'down':
const { menu } = muiAutocomplete.refs; const { menu } = muiAutocomplete.refs;
menu.handleKeyDown(event); menu && menu.handleKeyDown(event);
this.setState({ fakeBlur: true }); this.setState({ fakeBlur: true });
break; break;
@ -133,7 +133,7 @@ export default class AutoComplete extends Component {
const e = new CustomEvent('down'); const e = new CustomEvent('down');
e.which = 40; e.which = 40;
muiAutocomplete.handleKeyDown(e); muiAutocomplete && muiAutocomplete.handleKeyDown(e);
break; break;
} }
} }

View File

@ -66,7 +66,8 @@ export default class Input extends Component {
PropTypes.number, PropTypes.string PropTypes.number, PropTypes.string
]), ]),
min: PropTypes.any, min: PropTypes.any,
max: PropTypes.any max: PropTypes.any,
style: PropTypes.object
}; };
static defaultProps = { static defaultProps = {
@ -74,7 +75,8 @@ export default class Input extends Component {
readOnly: false, readOnly: false,
allowCopy: false, allowCopy: false,
hideUnderline: false, hideUnderline: false,
floatCopy: false floatCopy: false,
style: {}
} }
state = { state = {
@ -89,7 +91,8 @@ export default class Input extends Component {
render () { render () {
const { value } = this.state; 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; const readOnly = this.props.readOnly || disabled;
@ -105,7 +108,7 @@ export default class Input extends Component {
} }
return ( return (
<div className={ styles.container }> <div className={ styles.container } style={ style }>
{ this.renderCopyButton() } { this.renderCopyButton() }
<TextField <TextField
autoComplete='off' autoComplete='off'

View File

@ -53,7 +53,6 @@ class InputAddress extends Component {
const { small, allowCopy, hideUnderline, onSubmit, accountsInfo, tokens } = this.props; const { small, allowCopy, hideUnderline, onSubmit, accountsInfo, tokens } = this.props;
const account = accountsInfo[value] || tokens[value]; const account = accountsInfo[value] || tokens[value];
const hasAccount = account && !(account.meta && account.meta.deleted);
const icon = this.renderIcon(); const icon = this.renderIcon();
@ -74,7 +73,7 @@ class InputAddress extends Component {
label={ label } label={ label }
hint={ hint } hint={ hint }
error={ error } error={ error }
value={ text && hasAccount ? account.name : value } value={ text && account ? account.name : value }
onChange={ this.handleInputChange } onChange={ this.handleInputChange }
onSubmit={ onSubmit } onSubmit={ onSubmit }
allowCopy={ allowCopy && (disabled ? value : false) } allowCopy={ allowCopy && (disabled ? value : false) }

View File

@ -16,6 +16,8 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { nodeOrStringProptype } from '~/util/proptypes';
import Input from '../Input'; import Input from '../Input';
import styles from './inputInline.css'; import styles from './inputInline.css';
@ -33,9 +35,7 @@ export default class InputInline extends Component {
value: PropTypes.oneOfType([ value: PropTypes.oneOfType([
PropTypes.number, PropTypes.string PropTypes.number, PropTypes.string
]), ]),
static: PropTypes.oneOfType([ static: nodeOrStringProptype()
PropTypes.node, PropTypes.string
])
} }
state = { state = {

View File

@ -37,7 +37,10 @@ export default class RadioButtons extends Component {
render () { render () {
const { value, values } = this.props; 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 selectedValue = typeof value !== 'object' ? values[index] : value;
const key = this.getKey(selectedValue, index); const key = this.getKey(selectedValue, index);

View File

@ -29,3 +29,30 @@
position: relative; 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;
}
}

View File

@ -15,7 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { MenuItem } from 'material-ui'; import { MenuItem, Toggle } from 'material-ui';
import { range } from 'lodash'; import { range } from 'lodash';
import IconButton from 'material-ui/IconButton'; import IconButton from 'material-ui/IconButton';
@ -26,7 +26,8 @@ import Input from '~/ui/Form/Input';
import InputAddressSelect from '~/ui/Form/InputAddressSelect'; import InputAddressSelect from '~/ui/Form/InputAddressSelect';
import Select from '~/ui/Form/Select'; 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'; import styles from './typedInput.css';
@ -40,11 +41,31 @@ export default class TypedInput extends Component {
error: PropTypes.any, error: PropTypes.any,
value: PropTypes.any, value: PropTypes.any,
label: PropTypes.string, 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 () { render () {
const { param } = this.props; const { param, isEth } = this.props;
const { type } = param; const { type } = param;
if (type === ABI_TYPES.ARRAY) { if (type === ABI_TYPES.ARRAY) {
@ -80,6 +101,10 @@ export default class TypedInput extends Component {
); );
} }
if (isEth) {
return this.renderEth();
}
return this.renderType(type); return this.renderType(type);
} }
@ -90,16 +115,22 @@ export default class TypedInput extends Component {
}; };
const style = { const style = {
width: 32, width: 24,
height: 32, height: 24,
padding: 0 padding: 0
}; };
const plusStyle = {
...style,
backgroundColor: 'rgba(255, 255, 255, 0.25)',
borderRadius: '50%'
};
return ( return (
<div> <div style={ { marginTop: '0.75em' } }>
<IconButton <IconButton
iconStyle={ iconStyle } iconStyle={ iconStyle }
style={ style } style={ plusStyle }
onTouchTap={ this.onAddField } onTouchTap={ this.onAddField }
> >
<AddIcon /> <AddIcon />
@ -144,18 +175,46 @@ export default class TypedInput extends Component {
return this.renderDefault(); return this.renderDefault();
} }
renderNumber () { renderEth () {
const { label, value, error, param, hint } = this.props; 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 ( return (
<Input <Input
label={ label } label={ label }
hint={ hint } hint={ hint }
value={ value } value={ realValue }
error={ error } error={ error }
onSubmit={ this.onSubmit } onChange={ onChange }
type='number' 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'); 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) => { onChange = (event, value) => {
this.props.onChange(value); this.props.onChange(value);
} }

View File

@ -37,17 +37,16 @@ class IdentityName extends Component {
render () { render () {
const { address, accountsInfo, tokens, empty, name, shorten, unknown, className } = this.props; const { address, accountsInfo, tokens, empty, name, shorten, unknown, className } = this.props;
const account = accountsInfo[address] || tokens[address]; const account = accountsInfo[address] || tokens[address];
const hasAccount = account && (!account.meta || !account.meta.deleted);
if (!hasAccount && empty) { if (!account && empty) {
return null; return null;
} }
const addressFallback = shorten ? (<ShortenedHash data={ address } />) : address; const addressFallback = shorten ? (<ShortenedHash data={ address } />) : address;
const fallback = unknown ? defaultName : addressFallback; 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()) || const displayName = (name && name.toUpperCase().trim()) ||
(hasAccount && !isUuid (account && !isUuid
? account.name.toUpperCase().trim() ? account.name.toUpperCase().trim()
: fallback); : fallback);

View File

@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
import { LinearProgress } from 'material-ui'; import { LinearProgress } from 'material-ui';
import { Step, Stepper, StepLabel } from 'material-ui/Stepper'; import { Step, Stepper, StepLabel } from 'material-ui/Stepper';
import { nodeOrStringProptype } from '~/util/proptypes';
import styles from '../modal.css'; import styles from '../modal.css';
export default class Title extends Component { export default class Title extends Component {
@ -26,9 +28,7 @@ export default class Title extends Component {
current: PropTypes.number, current: PropTypes.number,
steps: PropTypes.array, steps: PropTypes.array,
waiting: PropTypes.array, waiting: PropTypes.array,
title: React.PropTypes.oneOfType([ title: nodeOrStringProptype()
PropTypes.node, PropTypes.string
])
} }
render () { render () {

View File

@ -19,6 +19,8 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { Dialog } from 'material-ui'; import { Dialog } from 'material-ui';
import { nodeOrStringProptype } from '~/util/proptypes';
import Container from '../Container'; import Container from '../Container';
import Title from './Title'; import Title from './Title';
@ -42,9 +44,7 @@ class Modal extends Component {
current: PropTypes.number, current: PropTypes.number,
waiting: PropTypes.array, waiting: PropTypes.array,
steps: PropTypes.array, steps: PropTypes.array,
title: PropTypes.oneOfType([ title: nodeOrStringProptype(),
PropTypes.node, PropTypes.string
]),
visible: PropTypes.bool.isRequired, visible: PropTypes.bool.isRequired,
settings: PropTypes.object.isRequired settings: PropTypes.object.isRequired
} }

31
js/src/util/proptypes.js Normal file
View 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
]);
}

View File

@ -140,7 +140,7 @@ export function validateUint (value) {
const bn = new BigNumber(value); const bn = new BigNumber(value);
if (bn.lt(0)) { if (bn.lt(0)) {
valueError = ERRORS.negativeNumber; valueError = ERRORS.negativeNumber;
} else if (bn.toString().indexOf('.') !== -1) { } else if (!bn.isInteger()) {
valueError = ERRORS.decimalNumber; valueError = ERRORS.decimalNumber;
} }
} catch (e) { } catch (e) {

107
js/src/util/wallets.js Normal file
View 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;
});
}
}

View File

@ -25,16 +25,23 @@ import styles from './header.css';
export default class Header extends Component { export default class Header extends Component {
static contextTypes = { static contextTypes = {
api: PropTypes.object api: PropTypes.object
} };
static propTypes = { static propTypes = {
account: PropTypes.object, account: PropTypes.object,
balance: PropTypes.object balance: PropTypes.object,
} className: PropTypes.string,
children: PropTypes.node
};
static defaultProps = {
className: '',
children: null
};
render () { render () {
const { api } = this.context; const { api } = this.context;
const { account, balance } = this.props; const { account, balance, className, children } = this.props;
const { address, meta, uuid } = account; const { address, meta, uuid } = account;
if (!account) { if (!account) {
@ -46,7 +53,7 @@ export default class Header extends Component {
: <div className={ styles.uuidline }>uuid: { uuid }</div>; : <div className={ styles.uuidline }>uuid: { uuid }</div>;
return ( return (
<div> <div className={ className }>
<Container> <Container>
<IdentityIcon <IdentityIcon
address={ address } /> address={ address } />
@ -74,6 +81,7 @@ export default class Header extends Component {
dappsUrl={ api.dappsUrl } dappsUrl={ api.dappsUrl }
/> />
</div> </div>
{ children }
</Container> </Container>
</div> </div>
); );

View File

@ -24,6 +24,7 @@ import styles from './list.css';
export default class List extends Component { export default class List extends Component {
static propTypes = { static propTypes = {
accounts: PropTypes.object, accounts: PropTypes.object,
walletsOwners: PropTypes.object,
balances: PropTypes.object, balances: PropTypes.object,
link: PropTypes.string, link: PropTypes.string,
search: PropTypes.array, search: PropTypes.array,
@ -42,7 +43,7 @@ export default class List extends Component {
} }
renderAccounts () { renderAccounts () {
const { accounts, balances, link, empty, handleAddSearchToken } = this.props; const { accounts, balances, link, empty, handleAddSearchToken, walletsOwners } = this.props;
if (empty) { if (empty) {
return ( return (
@ -60,6 +61,8 @@ export default class List extends Component {
const account = accounts[address] || {}; const account = accounts[address] || {};
const balance = balances[address] || {}; const balance = balances[address] || {};
const owners = walletsOwners && walletsOwners[address] || null;
return ( return (
<div <div
className={ styles.item } className={ styles.item }
@ -68,6 +71,7 @@ export default class List extends Component {
link={ link } link={ link }
account={ account } account={ account }
balance={ balance } balance={ balance }
owners={ owners }
handleAddSearchToken={ handleAddSearchToken } /> handleAddSearchToken={ handleAddSearchToken } />
</div> </div>
); );

View File

@ -17,8 +17,12 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router'; import { Link } from 'react-router';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import ReactTooltip from 'react-tooltip';
import { Balance, Container, ContainerTitle, IdentityIcon, IdentityName, Tags, Input } from '~/ui'; 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 { export default class Summary extends Component {
static contextTypes = { static contextTypes = {
@ -31,7 +35,8 @@ export default class Summary extends Component {
link: PropTypes.string, link: PropTypes.string,
name: PropTypes.string, name: PropTypes.string,
noLink: PropTypes.bool, noLink: PropTypes.bool,
handleAddSearchToken: PropTypes.func handleAddSearchToken: PropTypes.func,
owners: nullableProptype(PropTypes.array)
}; };
static defaultProps = { static defaultProps = {
@ -100,11 +105,41 @@ export default class Summary extends Component {
title={ this.renderLink() } title={ this.renderLink() }
byline={ addressComponent } /> byline={ addressComponent } />
{ this.renderOwners() }
{ this.renderBalance() } { this.renderBalance() }
</Container> </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 () { renderLink () {
const { link, noLink, account, name } = this.props; const { link, noLink, account, name } = this.props;

View File

@ -22,6 +22,12 @@
left: 7em; left: 7em;
} }
.owners {
margin-top: 1em;
display: flex;
margin-bottom: -0.5em;
}
.toolbar { .toolbar {
position: relative; position: relative;
} }

View File

@ -37,6 +37,7 @@ class Accounts extends Component {
accounts: PropTypes.object.isRequired, accounts: PropTypes.object.isRequired,
hasAccounts: PropTypes.bool.isRequired, hasAccounts: PropTypes.bool.isRequired,
wallets: PropTypes.object.isRequired, wallets: PropTypes.object.isRequired,
walletsOwners: PropTypes.object.isRequired,
hasWallets: PropTypes.bool.isRequired, hasWallets: PropTypes.bool.isRequired,
balances: PropTypes.object balances: PropTypes.object
@ -86,8 +87,15 @@ class Accounts extends Component {
{ this.renderNewWalletDialog() } { this.renderNewWalletDialog() }
{ this.renderActionbar() } { this.renderActionbar() }
{ this.renderAccounts() } <Page>
{ this.renderWallets() } <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> </div>
); );
} }
@ -115,18 +123,13 @@ class Accounts extends Component {
const { searchValues, sortOrder } = this.state; const { searchValues, sortOrder } = this.state;
return ( return (
<Page> <List
<List search={ searchValues }
search={ searchValues } accounts={ accounts }
accounts={ accounts } balances={ balances }
balances={ balances } empty={ !hasAccounts }
empty={ !hasAccounts } order={ sortOrder }
order={ sortOrder } handleAddSearchToken={ this.onAddSearchToken } />
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,21 +138,24 @@ class Accounts extends Component {
return this.renderLoading(this.props.wallets); return this.renderLoading(this.props.wallets);
} }
const { wallets, hasWallets, balances } = this.props; const { wallets, hasWallets, balances, walletsOwners } = this.props;
const { searchValues, sortOrder } = this.state; const { searchValues, sortOrder } = this.state;
if (!wallets || Object.keys(wallets).length === 0) {
return null;
}
return ( return (
<Page> <List
<List link='wallet'
link='wallet' search={ searchValues }
search={ searchValues } accounts={ wallets }
accounts={ wallets } balances={ balances }
balances={ balances } empty={ !hasWallets }
empty={ !hasWallets } order={ sortOrder }
order={ sortOrder } handleAddSearchToken={ this.onAddSearchToken }
handleAddSearchToken={ this.onAddSearchToken } walletsOwners={ walletsOwners }
/> />
</Page>
); );
} }
@ -281,13 +287,29 @@ class Accounts extends Component {
} }
function mapStateToProps (state) { function mapStateToProps (state) {
const { accounts, hasAccounts, wallets, hasWallets } = state.personal; const { accounts, hasAccounts, wallets, hasWallets, accountsInfo } = state.personal;
const { balances } = state.balances; 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 { return {
accounts, accounts,
hasAccounts, hasAccounts,
wallets, wallets,
walletsOwners,
hasWallets, hasWallets,
balances balances
}; };

View File

@ -19,7 +19,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
import { ConfirmDialog, IdentityIcon, IdentityName } from '~/ui'; import { ConfirmDialog, IdentityIcon, IdentityName } from '~/ui';
import { newError } from '../../../redux/actions'; import { newError } from '~/redux/actions';
import styles from '../address.css'; import styles from '../address.css';
@ -27,16 +27,17 @@ class Delete extends Component {
static contextTypes = { static contextTypes = {
api: PropTypes.object.isRequired, api: PropTypes.object.isRequired,
router: PropTypes.object router: PropTypes.object
} };
static propTypes = { static propTypes = {
route: PropTypes.string.isRequired,
address: PropTypes.string, address: PropTypes.string,
account: PropTypes.object, account: PropTypes.object,
route: PropTypes.string.isRequired,
visible: PropTypes.bool, visible: PropTypes.bool,
onClose: PropTypes.func, onClose: PropTypes.func,
newError: PropTypes.func newError: PropTypes.func
} };
render () { render () {
const { account, visible } = this.props; const { account, visible } = this.props;
@ -79,10 +80,8 @@ class Delete extends Component {
const { api, router } = this.context; const { api, router } = this.context;
const { account, route, newError } = this.props; const { account, route, newError } = this.props;
account.meta.deleted = true;
api.parity api.parity
.setAccountMeta(account.address, account.meta) .removeAddress(account.address)
.then(() => { .then(() => {
router.push(route); router.push(route);
this.closeDeleteDialog(); this.closeDeleteDialog();

View File

@ -121,7 +121,7 @@ class Address extends Component {
return ( return (
<Actionbar <Actionbar
title='Address Information' title='Address Information'
buttons={ !contact || contact.meta.deleted ? [] : buttons } /> buttons={ !contact ? [] : buttons } />
); );
} }

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { uniq } from 'lodash';
import { Container } from '~/ui'; import { Container } from '~/ui';
@ -38,7 +39,10 @@ export default class Events extends Component {
return null; 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 ( return (
<Event <Event
key={ event.key } key={ event.key }

View File

@ -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 EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
import ContentClear from 'material-ui/svg-icons/content/clear'; 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 { setVisibleAccounts } from '~/redux/providers/personalActions';
import { EditMeta, ExecuteContract } from '~/modals'; import { EditMeta, ExecuteContract } from '~/modals';
@ -229,7 +229,7 @@ class Contract extends Component {
return ( return (
<Actionbar <Actionbar
title='Contract Information' title='Contract Information'
buttons={ !account || account.meta.deleted ? [] : buttons } /> buttons={ !account ? [] : buttons } />
); );
} }

View File

@ -19,7 +19,7 @@ import { action, computed, observable, transaction } from 'mobx';
import store from 'store'; import store from 'store';
import Contracts from '~/contracts'; import Contracts from '~/contracts';
import { hashToImageUrl } from '../../redux/util'; import { hashToImageUrl } from '~/redux/util';
import builtinApps from './builtin.json'; import builtinApps from './builtin.json';

View File

@ -18,7 +18,7 @@ import React, { Component, PropTypes } from 'react';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { MethodDecoding } from '../../../../ui'; import { MethodDecoding } from '~/ui';
import * as tUtil from '../util/transaction'; import * as tUtil from '../util/transaction';
import Account from '../Account'; import Account from '../Account';

View File

@ -64,7 +64,7 @@ export default class TransactionPending extends Component {
} }
render () { render () {
const { className, id, transaction, store } = this.props; const { className, id, transaction, store, isTest } = this.props;
const { from, value } = transaction; const { from, value } = transaction;
const { totalValue } = this.state; const { totalValue } = this.state;
@ -76,6 +76,7 @@ export default class TransactionPending extends Component {
id={ id } id={ id }
value={ value } value={ value }
from={ from } from={ from }
isTest={ isTest }
fromBalance={ fromBalance } fromBalance={ fromBalance }
className={ styles.transactionDetails } className={ styles.transactionDetails }
transaction={ transaction } transaction={ transaction }

View File

@ -17,6 +17,6 @@
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { identity } from '../util'; import { identity } from '../util';
import { withError } from '../../../redux/util'; import { withError } from '~/redux/util';
export const copyToClipboard = createAction('copy toClipboard', identity, withError(identity)); export const copyToClipboard = createAction('copy toClipboard', identity, withError(identity));

View File

@ -17,7 +17,7 @@
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { identity } from '../util'; import { identity } from '../util';
import { withError } from '../../../redux/util'; import { withError } from '~/redux/util';
export const updateLogging = createAction( export const updateLogging = createAction(
'update logging', identity, withError(flag => `logging updated to ${flag}`) 'update logging', identity, withError(flag => `logging updated to ${flag}`)

View File

@ -17,7 +17,7 @@
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { identity } from '../util'; import { identity } from '../util';
import { withError } from '../../../redux/util'; import { withError } from '~/redux/util';
export const error = createAction('error rpc', identity, export const error = createAction('error rpc', identity,
withError(() => 'error processing rpc call. check console for details', 'error') 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