diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e16350325..efd91663d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,9 +3,9 @@ stages: - test variables: GIT_DEPTH: "3" - SIMPLECOV: "true" + SIMPLECOV: "true" RUST_BACKTRACE: "1" - RUSTFLAGS: "-D warnings" + RUSTFLAGS: "" cache: key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME" untracked: true @@ -26,7 +26,7 @@ linux-stable: - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - dpkg-deb -b deb "parity_"$VER"_amd64.deb" - md5sum "parity_"$VER"_amd64.deb" >> "parity_"$VER"_amd64.deb.md5" - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5 @@ -56,7 +56,7 @@ linux-stable-14.04: - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - dpkg-deb -b deb "parity_"$VER"_amd64.deb" - md5sum "parity_"$VER"_amd64.deb" >> "parity_"$VER"_amd64.deb.md5" - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-ubuntu_14_04-gnu/parity --body target/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-ubuntu_14_04-gnu/parity.md5 --body parity.md5 @@ -121,7 +121,7 @@ linux-centos: - cargo build --release --verbose - strip target/release/parity - md5sum target/release/parity >> parity.md5 - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity --body target/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity.md5 --body parity.md5 @@ -158,7 +158,7 @@ linux-armv7: - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - dpkg-deb -b deb "parity_"$VER"_armhf.deb" - md5sum "parity_"$VER"_armhf.deb" >> "parity_"$VER"_armhf.deb.md5" - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5 @@ -198,7 +198,7 @@ linux-arm: - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - dpkg-deb -b deb "parity_"$VER"_armhf.deb" - md5sum "parity_"$VER"_armhf.deb" >> "parity_"$VER"_armhf.deb.md5" - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5 @@ -231,8 +231,8 @@ linux-armv6: - cat .cargo/config - cargo build --target arm-unknown-linux-gnueabi --release --verbose - arm-linux-gnueabi-strip target/arm-unknown-linux-gnueabi/release/parity - - md5sum target/arm-unknown-linux-gnueabi/release/parity >> parity.md5 - - aws configure set aws_access_key_id $s3_key + - md5sum target/arm-unknown-linux-gnueabi/release/parity >> parity.md5 + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5 @@ -270,7 +270,7 @@ linux-aarch64: - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n") - dpkg-deb -b deb "parity_"$VER"_arm64.deb" - md5sum "parity_"$VER"_arm64.deb" >> "parity_"$VER"_arm64.deb.md5" - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5 @@ -295,7 +295,7 @@ darwin: - cargo build --release --verbose - rm -rf parity.md5 - md5sum target/release/parity >> parity.md5 - - aws configure set aws_access_key_id $s3_key + - aws configure set aws_access_key_id $s3_key - aws configure set aws_secret_access_key $s3_secret - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity - aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5 @@ -316,7 +316,7 @@ windows: - set INCLUDE=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include;C:\vs2015\VC\include;C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt - set LIB=C:\vs2015\VC\lib;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64 - set RUST_BACKTRACE=1 - - set RUSTFLAGS=%RUSTFLAGS% -Zorbit=off -D warnings + - set RUSTFLAGS=%RUSTFLAGS% -Zorbit=off - rustup default stable-x86_64-pc-windows-msvc - cargo build --release --verbose - curl -sL --url "https://github.com/ethcore/win-build/raw/master/SimpleFC.dll" -o nsis\SimpleFC.dll @@ -380,8 +380,8 @@ test-windows: before_script: - git submodule update --init --recursive script: - - export RUST_BACKTRACE=1 - - ./test.sh --verbose + - set RUST_BACKTRACE=1 + - PowerShell ./test.sh --verbose tags: - rust-windows dependencies: @@ -391,9 +391,6 @@ js-release: image: ethcore/javascript:latest only: - master - - beta - - tags - - stable before_script: - ./js/scripts/install-deps.sh script: diff --git a/Cargo.lock b/Cargo.lock index b9d989fbd..92fb0f8d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -370,7 +370,7 @@ version = "1.4.0" dependencies = [ "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)", + "mio 0.6.0 (git+https://github.com/carllerche/mio)", "parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -451,6 +451,7 @@ name = "ethcore-network" version = "1.4.0" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", "ethcore-util 1.4.0", @@ -459,7 +460,7 @@ dependencies = [ "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)", + "mio 0.6.0 (git+https://github.com/carllerche/mio)", "parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.1.0", @@ -516,7 +517,7 @@ dependencies = [ "parity-ui 1.4.0", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", - "ws 0.5.2 (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)", ] [[package]] @@ -886,6 +887,11 @@ name = "lazy_static" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazycell" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.15" @@ -990,7 +996,7 @@ dependencies = [ [[package]] name = "mio" version = "0.6.0-dev" -source = "git+https://github.com/carllerche/mio?rev=62ec763c9cc34d8a452ed0392c575c50ddd5fc8d#62ec763c9cc34d8a452ed0392c575c50ddd5fc8d" +source = "git+https://github.com/ethcore/mio?branch=timer-fix#31eccc40ece3d47abaefaf23bb2114033175b972" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1002,6 +1008,22 @@ dependencies = [ "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio" +version = "0.6.0" +source = "git+https://github.com/carllerche/mio#9f17b70d6fecbf912168267ea74cf536f2cba705" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.23 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "miow" version = "0.1.3" @@ -1213,7 +1235,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.4.0" -source = "git+https://github.com/ethcore/js-precompiled.git#ba726039185238d6fd604f092b089a7d52c0f436" +source = "git+https://github.com/ethcore/js-precompiled.git#eec3d41e6fd1a10e4d69470a9e8c2a7b1b464466" dependencies = [ "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1593,6 +1615,11 @@ name = "slab" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "slab" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "0.1.8" @@ -1884,13 +1911,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ws" -version = "0.5.2" -source = "git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable#00bd2134b07b4bc8ea47b7f6c7afce16bbe34c8f" +version = "0.5.3" +source = "git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable#0cd6c5e3e9d5e61a37d53eb8dcbad523dcc69314" dependencies = [ "bytes 0.4.0-dev (git+https://github.com/carllerche/bytes)", "httparse 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.0-dev (git+https://github.com/carllerche/mio?rev=62ec763c9cc34d8a452ed0392c575c50ddd5fc8d)", + "mio 0.6.0-dev (git+https://github.com/ethcore/mio?branch=timer-fix)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", "sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (git+https://github.com/carllerche/slab?rev=5476efcafb)", @@ -1984,6 +2011,7 @@ dependencies = [ "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f" +"checksum lazycell 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce12306c4739d86ee97c23139f3a34ddf0387bbf181bc7929d287025a8c3ef6b" "checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2" "checksum linked-hash-map 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bda158e0dabeb97ee8a401f4d17e479d6b891a14de0bba79d5cc2d4d325b5e48" "checksum linked-hash-map 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d262045c5b87c0861b3f004610afd0e2c851e2908d08b6c870cbb9d5f494ecd" @@ -1996,7 +2024,8 @@ dependencies = [ "checksum miniz-sys 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d1f4d337a01c32e1f2122510fed46393d53ca35a7f429cb0450abaedfa3ed54" "checksum mio 0.5.1 (git+https://github.com/ethcore/mio?branch=v0.5.x)" = "" "checksum mio 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a637d1ca14eacae06296a008fa7ad955347e34efcb5891cfd8ba05491a37907e" -"checksum mio 0.6.0-dev (git+https://github.com/carllerche/mio?rev=62ec763c9cc34d8a452ed0392c575c50ddd5fc8d)" = "" +"checksum mio 0.6.0 (git+https://github.com/carllerche/mio)" = "" +"checksum mio 0.6.0-dev (git+https://github.com/ethcore/mio?branch=timer-fix)" = "" "checksum miow 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d5bfc6782530ac8ace97af10a540054a37126b63b0702ddaaa243b73b5745b9a" "checksum msdos_time 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c04b68cc63a8480fb2550343695f7be72effdec953a9d4508161c3e69041c7d8" "checksum nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)" = "" @@ -2062,6 +2091,7 @@ dependencies = [ "checksum slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d807fd58c4181bbabed77cb3b891ba9748241a552bcc5be698faaebefc54f46e" "checksum slab 0.2.0 (git+https://github.com/carllerche/slab?rev=5476efcafb)" = "" "checksum slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6dbdd334bd28d328dad1c41b0ea662517883d8880d8533895ef96c8003dec9c4" +"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23" "checksum smallvec 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "fcc8d19212aacecf95e4a7a2179b26f7aeb9732a915cf01f05b0d3e044865410" "checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2" "checksum spmc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "93bdab61c1a413e591c4d17388ffa859eaff2df27f1e13a5ec8b716700605adf" @@ -2099,7 +2129,7 @@ dependencies = [ "checksum webpki 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "813503a5985585e0812d430cd1328ee322f47f66629c8ed4ecab939cf9e92f91" "checksum winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4dfaaa8fbdaa618fa6914b59b2769d690dd7521920a18d84b42d254678dd5fd4" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum ws 0.5.2 (git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable)" = "" +"checksum ws 0.5.3 (git+https://github.com/ethcore/ws-rs.git?branch=mio-upstream-stable)" = "" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum xml-rs 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "65e74b96bd3179209dc70a980da6df843dff09e46eee103a0376c0949257e3ef" "checksum xmltree 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "472a9d37c7c53ab2391161df5b89b1f3bf76dab6ab150d7941ecbdd832282082" diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 4709955d1..0c50d85aa 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -139,7 +139,7 @@ pub struct Client { miner: Arc, sleep_state: Mutex, liveness: AtomicBool, - io_channel: IoChannel, + io_channel: Mutex>, notify: RwLock>>, queue_transactions: AtomicUsize, last_hashes: RwLock>, @@ -235,7 +235,7 @@ impl Client { import_lock: Mutex::new(()), panic_handler: panic_handler, miner: miner, - io_channel: message_channel, + io_channel: Mutex::new(message_channel), notify: RwLock::new(Vec::new()), queue_transactions: AtomicUsize::new(0), last_hashes: RwLock::new(VecDeque::new()), @@ -1139,7 +1139,7 @@ impl BlockChainClient for Client { debug!("Ignoring {} transactions: queue is full", transactions.len()); } else { let len = transactions.len(); - match self.io_channel.send(ClientIoMessage::NewTransactions(transactions)) { + match self.io_channel.lock().send(ClientIoMessage::NewTransactions(transactions)) { Ok(_) => { self.queue_transactions.fetch_add(len, AtomicOrdering::SeqCst); } diff --git a/ethcore/src/miner/banning_queue.rs b/ethcore/src/miner/banning_queue.rs index 0329503bf..f127dc7e8 100644 --- a/ethcore/src/miner/banning_queue.rs +++ b/ethcore/src/miner/banning_queue.rs @@ -130,7 +130,7 @@ impl BanningTransactionQueue { // Ban sender let sender_banned = self.ban_sender(sender); // Ban recipient and codehash - let is_banned = sender_banned || match transaction.action { + let recipient_or_code_banned = match transaction.action { Action::Call(recipient) => { self.ban_recipient(recipient) }, @@ -138,7 +138,7 @@ impl BanningTransactionQueue { self.ban_codehash(transaction.data.sha3()) }, }; - is_banned + sender_banned || recipient_or_code_banned }, None => false, } diff --git a/ethcore/src/miner/transaction_queue.rs b/ethcore/src/miner/transaction_queue.rs index f8baf8989..51c1863f6 100644 --- a/ethcore/src/miner/transaction_queue.rs +++ b/ethcore/src/miner/transaction_queue.rs @@ -110,6 +110,7 @@ impl PartialOrd for TransactionOrigin { } impl Ord for TransactionOrigin { + #[cfg_attr(feature="dev", allow(match_same_arms))] fn cmp(&self, other: &TransactionOrigin) -> Ordering { if *other == *self { return Ordering::Equal; diff --git a/ethcore/src/snapshot/account.rs b/ethcore/src/snapshot/account.rs index 7e4585365..38a4028e1 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/src/snapshot/account.rs @@ -178,7 +178,7 @@ impl Account { CodeState::Hash => { let code_hash = try!(rlp.val_at(3)); if let Some(code) = code_map.get(&code_hash) { - acct_db.emplace(code_hash.clone(), DBValue::from_slice(&code)); + acct_db.emplace(code_hash.clone(), DBValue::from_slice(code)); } (code_hash, None) diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index cc30a5c26..16f7c6ec6 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -213,7 +213,7 @@ pub struct Service { restoration: Mutex>, snapshot_root: PathBuf, db_config: DatabaseConfig, - io_channel: Channel, + io_channel: Mutex, pruning: Algorithm, status: Mutex, reader: RwLock>, @@ -233,7 +233,7 @@ impl Service { restoration: Mutex::new(None), snapshot_root: params.snapshot_root, db_config: params.db_config, - io_channel: params.channel, + io_channel: Mutex::new(params.channel), pruning: params.pruning, status: Mutex::new(RestorationStatus::Inactive), reader: RwLock::new(None), @@ -567,7 +567,7 @@ impl SnapshotService for Service { } fn begin_restore(&self, manifest: ManifestData) { - if let Err(e) = self.io_channel.send(ClientIoMessage::BeginRestoration(manifest)) { + if let Err(e) = self.io_channel.lock().send(ClientIoMessage::BeginRestoration(manifest)) { trace!("Error sending snapshot service message: {:?}", e); } } @@ -578,13 +578,13 @@ impl SnapshotService for Service { } fn restore_state_chunk(&self, hash: H256, chunk: Bytes) { - if let Err(e) = self.io_channel.send(ClientIoMessage::FeedStateChunk(hash, chunk)) { + if let Err(e) = self.io_channel.lock().send(ClientIoMessage::FeedStateChunk(hash, chunk)) { trace!("Error sending snapshot service message: {:?}", e); } } fn restore_block_chunk(&self, hash: H256, chunk: Bytes) { - if let Err(e) = self.io_channel.send(ClientIoMessage::FeedBlockChunk(hash, chunk)) { + if let Err(e) = self.io_channel.lock().send(ClientIoMessage::FeedBlockChunk(hash, chunk)) { trace!("Error sending snapshot service message: {:?}", e); } } diff --git a/ethcore/src/snapshot/watcher.rs b/ethcore/src/snapshot/watcher.rs index 498f00737..43439e437 100644 --- a/ethcore/src/snapshot/watcher.rs +++ b/ethcore/src/snapshot/watcher.rs @@ -16,6 +16,7 @@ //! Watcher for snapshot-related chain events. +use util::Mutex; use client::{BlockChainClient, Client, ChainNotify}; use ids::BlockID; use service::ClientIoMessage; @@ -55,7 +56,7 @@ trait Broadcast: Send + Sync { fn take_at(&self, num: Option); } -impl Broadcast for IoChannel { +impl Broadcast for Mutex> { fn take_at(&self, num: Option) { let num = match num { Some(n) => n, @@ -64,7 +65,7 @@ impl Broadcast for IoChannel { trace!(target: "snapshot_watcher", "broadcast: {}", num); - if let Err(e) = self.send(ClientIoMessage::TakeSnapshot(num)) { + if let Err(e) = self.lock().send(ClientIoMessage::TakeSnapshot(num)) { warn!("Snapshot watcher disconnected from IoService: {}", e); } } @@ -91,7 +92,7 @@ impl Watcher { client: client, sync_status: sync_status, }), - broadcast: Box::new(channel), + broadcast: Box::new(Mutex::new(channel)), period: period, history: history, } diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index affc0b405..3506b8951 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -43,8 +43,6 @@ struct AccountCache { // When changing the type of the values here, be sure to update `mem_used` and // `new`. accounts: LruCache>, - /// DB Code cache. Maps code hashes to shared bytes. - code: MemoryLruCache>>, /// Information on the modifications in recently committed blocks; specifically which addresses /// changed in which block. Ordered by block number. modifications: VecDeque, @@ -95,6 +93,8 @@ pub struct StateDB { db: Box, /// Shared canonical state cache. account_cache: Arc>, + /// DB Code cache. Maps code hashes to shared bytes. + code_cache: Arc>>>>, /// Local dirty cache. local_cache: Vec, /// Shared account bloom. Does not handle chain reorganizations. @@ -125,9 +125,9 @@ impl StateDB { db: db, account_cache: Arc::new(Mutex::new(AccountCache { accounts: LruCache::new(cache_items), - code: MemoryLruCache::new(code_cache_size), modifications: VecDeque::new(), })), + code_cache: Arc::new(Mutex::new(MemoryLruCache::new(code_cache_size))), local_cache: Vec::new(), account_bloom: Arc::new(Mutex::new(bloom)), cache_size: cache_size, @@ -320,6 +320,7 @@ impl StateDB { StateDB { db: self.db.boxed_clone(), account_cache: self.account_cache.clone(), + code_cache: self.code_cache.clone(), local_cache: Vec::new(), account_bloom: self.account_bloom.clone(), cache_size: self.cache_size, @@ -334,6 +335,7 @@ impl StateDB { StateDB { db: self.db.boxed_clone(), account_cache: self.account_cache.clone(), + code_cache: self.code_cache.clone(), local_cache: Vec::new(), account_bloom: self.account_bloom.clone(), cache_size: self.cache_size, @@ -352,10 +354,9 @@ impl StateDB { pub fn mem_used(&self) -> usize { // TODO: account for LRU-cache overhead; this is a close approximation. self.db.mem_used() + { - let cache = self.account_cache.lock(); - - cache.code.current_size() + - cache.accounts.len() * ::std::mem::size_of::>() + let accounts = self.account_cache.lock().accounts.len(); + let code_size = self.code_cache.lock().current_size(); + code_size + accounts * ::std::mem::size_of::>() } } @@ -380,9 +381,9 @@ impl StateDB { /// it simply maps hashes to raw code and will always be correct in the absence of /// hash collisions. pub fn cache_code(&self, hash: H256, code: Arc>) { - let mut cache = self.account_cache.lock(); + let mut cache = self.code_cache.lock(); - cache.code.insert(hash, code); + cache.insert(hash, code); } /// Get basic copy of the cached account. Does not include storage. @@ -397,9 +398,9 @@ impl StateDB { /// Get cached code based on hash. pub fn get_cached_code(&self, hash: &H256) -> Option>> { - let mut cache = self.account_cache.lock(); + let mut cache = self.code_cache.lock(); - cache.code.get_mut(hash).map(|code| code.clone()) + cache.get_mut(hash).map(|code| code.clone()) } /// Get value from a cached account. diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index f801bbe2e..99e09784d 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -109,7 +109,7 @@ pub struct VerificationQueue { struct QueueSignal { deleting: Arc, signalled: AtomicBool, - message_channel: IoChannel, + message_channel: Mutex>, } impl QueueSignal { @@ -121,7 +121,8 @@ impl QueueSignal { } if self.signalled.compare_and_swap(false, true, AtomicOrdering::Relaxed) == false { - if let Err(e) = self.message_channel.send_sync(ClientIoMessage::BlockVerified) { + let channel = self.message_channel.lock().clone(); + if let Err(e) = channel.send_sync(ClientIoMessage::BlockVerified) { debug!("Error sending BlockVerified message: {:?}", e); } } @@ -135,7 +136,8 @@ impl QueueSignal { } if self.signalled.compare_and_swap(false, true, AtomicOrdering::Relaxed) == false { - if let Err(e) = self.message_channel.send(ClientIoMessage::BlockVerified) { + let channel = self.message_channel.lock().clone(); + if let Err(e) = channel.send(ClientIoMessage::BlockVerified) { debug!("Error sending BlockVerified message: {:?}", e); } } @@ -178,7 +180,7 @@ impl VerificationQueue { let ready_signal = Arc::new(QueueSignal { deleting: deleting.clone(), signalled: AtomicBool::new(false), - message_channel: message_channel + message_channel: Mutex::new(message_channel), }); let empty = Arc::new(SCondvar::new()); let panic_handler = PanicHandler::new_in_arc(); diff --git a/js/.gitignore b/js/.gitignore index b3ece001c..acb73a82a 100644 --- a/js/.gitignore +++ b/js/.gitignore @@ -5,3 +5,4 @@ build .coverage .dist .happypack +.npmjs diff --git a/js/assets/images/ethcore-block-black.png b/js/assets/images/ethcore-block-black.png new file mode 100644 index 000000000..780a5be5c Binary files /dev/null and b/js/assets/images/ethcore-block-black.png differ diff --git a/js/assets/images/parity.ico b/js/assets/images/parity.ico new file mode 100644 index 000000000..4551b46be Binary files /dev/null and b/js/assets/images/parity.ico differ diff --git a/js/package.json b/js/package.json index bafb3efcd..ecd749792 100644 --- a/js/package.json +++ b/js/package.json @@ -1,9 +1,9 @@ { "name": "parity.js", - "version": "0.0.1", + "version": "0.1.5", "main": "release/index.js", "jsnext:main": "src/index.js", - "author": "Ethcore Team ", + "author": "Parity Team ", "maintainers": [ "Jaco Greeff" ], @@ -11,7 +11,7 @@ "license": "GPL-3.0", "repository": { "type": "git", - "url": "git+https://github.com/ethcore/parity.js.git" + "url": "git+https://github.com/ethcore/parity.git" }, "keywords": [ "Ethereum", @@ -27,15 +27,13 @@ "build:app": "webpack --progress", "build:lib": "webpack --config webpack.libraries --progress", "build:dll": "webpack --config webpack.vendor --progress", - "ci:build": "npm run ci:build:dll && npm run ci:build:app && npm run ci:build:lib", "ci:build:app": "NODE_ENV=production webpack", "ci:build:lib": "NODE_ENV=production webpack --config webpack.libraries", "ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor", - + "ci:build:npm": "NODE_ENV=production webpack --config webpack.npm", "start": "npm install && npm run build:dll && npm run start:app", "start:app": "webpack-dev-server -d --history-api-fallback --open --hot --inline --progress --colors --port 3000", - "clean": "rm -rf ./build ./coverage", "coveralls": "npm run testCoverage && coveralls < coverage/lcov.info", "lint": "eslint --ignore-path .gitignore ./src/", @@ -65,7 +63,7 @@ "chai": "^3.5.0", "chai-enzyme": "0.4.2", "cheerio": "0.20.0", - "copy-webpack-plugin": "^3.0.1", + "copy-webpack-plugin": "^4.0.0", "core-js": "^2.4.1", "coveralls": "^2.11.11", "css-loader": "^0.23.1", @@ -79,6 +77,7 @@ "eslint-plugin-standard": "^2.0.0", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.8.5", + "fs-extra": "^0.30.0", "happypack": "^2.2.1", "history": "^2.0.0", "html-loader": "^0.4.3", @@ -125,6 +124,7 @@ "material-ui": "^0.16.1", "material-ui-chip-input": "^0.8.0", "moment": "^2.14.1", + "qs": "^6.3.0", "react": "^15.2.1", "react-addons-css-transition-group": "^15.2.1", "react-dom": "^15.2.1", diff --git a/js/parity.md b/js/parity.md new file mode 100644 index 000000000..3e42f5c8d --- /dev/null +++ b/js/parity.md @@ -0,0 +1,81 @@ +# parity.js + +Parity.js is a thin, fast, Promise-based wrapper around the Ethereum APIs. + +## installation + +Install the package with `npm install --save @parity/parity.js` + +## usage + +### initialisation + +```javascript +// import the actual Api class +import { Api } from '@parity/parity.js'; + +// do the setup +const transport = new Api.Transport.Http('http://localhost:8545'); +const api = new Api(transport); +``` + +### making calls + +perform a call + +```javascript +api.eth + .coinbase() + .then((coinbase) => { + console.log(`The coinbase is ${coinbase}`); + }); +``` + +multiple promises + +```javascript +Promise + .all([ + api.eth.coinbase(), + api.net.listening() + ]) + .then(([coinbase, listening]) => { + // do stuff here + }); +``` + +chaining promises + +```javascript +api.eth + .newFilter({...}) + .then((filterId) => api.eth.getFilterChanges(filterId)) + .then((changes) => { + console.log(changes); + }); +``` + +### contracts + +attach contract + +```javascript +const abi = [{ name: 'callMe', inputs: [{ type: 'bool', ...}, { type: 'string', ...}]}, ...abi...]; +const address = '0x123456...9abc'; +const contract = new api.newContract(abi, address); +``` + +find & call a function + +```javascript +contract.instance + .callMe + .call({ gas: 21000 }, [true, 'someString']) // or estimateGas or postTransaction + .then((result) => { + console.log(`the result was ${result}`); + }); +``` + +## apis + +APIs implement the calls as exposed in the [Ethcore JSON Ethereum RPC](https://github.com/ethcore/ethereum-rpc-json/) definitions. Mapping follows the naming conventions of the originals, i.e. `eth_call` becomes `eth.call`, `personal_accounts` becomes `personal.accounts`, etc. diff --git a/js/parity.package.json b/js/parity.package.json new file mode 100644 index 000000000..7d18cc5ed --- /dev/null +++ b/js/parity.package.json @@ -0,0 +1,32 @@ +{ + "name": "@parity/parity.js", + "description": "The Parity Promise-base API & ABI library for interfacing with Ethereum over RPC", + "version": "0.0.0", + "main": "library.js", + "author": "Parity Team ", + "maintainers": [ + "Jaco Greeff" + ], + "contributors": [], + "license": "GPL-3.0", + "repository": { + "type": "git", + "url": "git+https://github.com/ethcore/parity.git" + }, + "keywords": [ + "Ethereum", + "ABI", + "API", + "RPC", + "Parity", + "Promise" + ], + "scripts": { + }, + "devDependencies": { + }, + "dependencies": { + "bignumber.js": "^2.3.0", + "js-sha3": "^0.5.2" + } +} diff --git a/js/scripts/release.sh b/js/scripts/release.sh index 95e561b77..22fd91ab6 100755 --- a/js/scripts/release.sh +++ b/js/scripts/release.sh @@ -1,11 +1,18 @@ #!/bin/bash set -e +# variables +UTCDATE=`date -u "+%Y%m%d-%H%M%S"` +PACKAGES=( "parity.js" ) +BRANCH=$CI_BUILD_REF_NAME +GIT_JS_PRECOMPILED="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git" +GIT_PARITY="https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git" + # setup the git user defaults for the current repo function setup_git_user { git config push.default simple git config merge.ours.driver true - git config user.email "jaco+gitlab@ethcore.io" + git config user.email "$GITHUB_EMAIL" git config user.name "GitLab Build Bot" } @@ -15,47 +22,63 @@ GITLOG=./.git/gitcommand.log pushd $BASEDIR cd ../.dist -# variables -UTCDATE=`date -u "+%Y%m%d-%H%M%S"` - -# init git +# add local files and send it up +echo "*** Setting up GitHub config for js-precompiled" rm -rf ./.git git init - -# add local files and send it up -echo "Setting up GitHub config for js-precompiled" setup_git_user -echo "Checking out $CI_BUILD_REF_NAME branch" -git remote add origin https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/js-precompiled.git +echo "*** Checking out $BRANCH branch" +git remote add origin $GIT_JS_PRECOMPILED git fetch origin 2>$GITLOG -git checkout -b $CI_BUILD_REF_NAME +git checkout -b $BRANCH -echo "Committing compiled files for $UTCDATE" +echo "*** Committing compiled files for $UTCDATE" git add . git commit -m "$UTCDATE" -echo "Merging remote" -git merge origin/$CI_BUILD_REF_NAME -X ours --commit -m "$UTCDATE [release]" -git push origin HEAD:refs/heads/$CI_BUILD_REF_NAME 2>$GITLOG +echo "*** Merging remote" +git merge origin/$BRANCH -X ours --commit -m "$UTCDATE [release]" +git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG PRECOMPILED_HASH=`git rev-parse HEAD` -# back to root -popd +# move to root +cd ../.. -echo "Setting up GitHub config for parity" +echo "*** Setting up GitHub config for parity" setup_git_user -git remote set-url origin https://${GITHUB_JS_PRECOMPILED}:@github.com/ethcore/parity.git -git reset --hard origin/$CI_BUILD_REF_NAME 2>$GITLOG +git remote set-url origin $GIT_PARITY +git reset --hard origin/$BRANCH 2>$GITLOG -echo "Updating cargo package parity-ui-precompiled#$PRECOMPILED_HASH" +echo "*** Bumping package.json patch version" +cd js +npm --no-git-tag-version version +npm version patch +cd .. + +echo "*** Updating cargo parity-ui-precompiled#$PRECOMPILED_HASH" cargo update -p parity-ui-precompiled # --precise "$PRECOMPILED_HASH" -echo "Committing updated files" -git add . +echo "*** Committing updated files" +git add Cargo.lock js/package.json git commit -m "[ci skip] js-precompiled $UTCDATE" -git push origin HEAD:refs/heads/$CI_BUILD_REF_NAME 2>$GITLOG +git push origin HEAD:refs/heads/$BRANCH 2>$GITLOG + +echo "*** Building packages for npmjs" +cd js +# echo -e "$NPM_USERNAME\n$NPM_PASSWORD\n$NPM_EMAIL" | npm login +echo "$NPM_TOKEN" >> ~/.npmrc +npm run ci:build:npm + +echo "*** Publishing $PACKAGE to npmjs" +cd .npmjs +npm publish --access public +cd .. + +# back to root +echo "*** Release completed" +popd # exit with exit code exit 0 diff --git a/js/src/3rdparty/etherscan/call.js b/js/src/3rdparty/etherscan/call.js index 1324bcc9d..5c6cd5945 100644 --- a/js/src/3rdparty/etherscan/call.js +++ b/js/src/3rdparty/etherscan/call.js @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import { stringify } from 'qs'; + const options = { method: 'GET', headers: { @@ -23,19 +25,14 @@ const options = { export function call (module, action, _params, test) { const host = test ? 'testnet.etherscan.io' : 'api.etherscan.io'; - let params = ''; - if (_params) { - Object.keys(_params).map((param) => { - const value = _params[param]; + const query = stringify(Object.assign({ + module, action + }, _params || {})); - params = `${params}&${param}=${value}`; - }); - } - - return fetch(`http://${host}/api?module=${module}&action=${action}${params}`, options) + return fetch(`https://${host}/api?${query}`, options) .then((response) => { - if (response.status !== 200) { + if (!response.ok) { throw { code: response.status, message: response.statusText }; // eslint-disable-line } diff --git a/js/src/3rdparty/etherscan/index.js b/js/src/3rdparty/etherscan/index.js index 55aeba473..ada1503cd 100644 --- a/js/src/3rdparty/etherscan/index.js +++ b/js/src/3rdparty/etherscan/index.js @@ -16,10 +16,13 @@ import { account } from './account'; import { stats } from './stats'; +import { txLink, addressLink } from './links'; const etherscan = { account: account, - stats: stats + stats: stats, + txLink: txLink, + addressLink: addressLink }; export default etherscan; diff --git a/js/src/views/Signer/components/constants/constants.js b/js/src/3rdparty/etherscan/links.js similarity index 68% rename from js/src/views/Signer/components/constants/constants.js rename to js/src/3rdparty/etherscan/links.js index c02384775..2745873fc 100644 --- a/js/src/views/Signer/components/constants/constants.js +++ b/js/src/3rdparty/etherscan/links.js @@ -14,8 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -// links to chain explorers -export const BASE_LINK_ACCOUNT_MORDEN = 'https://testnet.etherscan.io/address/'; -export const BASE_LINK_ACCOUNT_HOMESTEAD = 'https://etherscan.io/address/'; -export const BASE_LINK_TX_MORDEN = 'https://testnet.etherscan.io/tx/'; -export const BASE_LINK_TX_HOMESTEAD = 'https://etherscan.io/tx/'; +export const txLink = (hash, isTestnet = false) => { + return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/tx/${hash}`; +}; + +export const addressLink = (address, isTestnet = false) => { + return `https://${isTestnet ? 'testnet.' : ''}etherscan.io/address/${address}`; +}; diff --git a/js/src/dapps/basiccoin.html b/js/src/dapps/basiccoin.html index 7ac5cb3cb..315a10818 100644 --- a/js/src/dapps/basiccoin.html +++ b/js/src/dapps/basiccoin.html @@ -4,6 +4,7 @@ + Basic Token Deployment diff --git a/js/src/dapps/gavcoin.html b/js/src/dapps/gavcoin.html index f777f2920..3b260bce1 100644 --- a/js/src/dapps/gavcoin.html +++ b/js/src/dapps/gavcoin.html @@ -4,6 +4,7 @@ + GAVcoin diff --git a/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js b/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js index 42de205c1..fe67c3739 100644 --- a/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js +++ b/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js @@ -43,7 +43,7 @@ export default class ActionBuyIn extends Component { accountError: ERRORS.invalidAccount, amount: 0, amountError: ERRORS.invalidAmount, - maxPrice: api.util.fromWei(this.props.price.mul(1.2)).toString(), + maxPrice: api.util.fromWei(this.props.price.mul(1.2)).toFixed(0), maxPriceError: null, sending: false, complete: false diff --git a/js/src/dapps/gavcoin/Application/application.js b/js/src/dapps/gavcoin/Application/application.js index 1ae5d870a..c5eda9db8 100644 --- a/js/src/dapps/gavcoin/Application/application.js +++ b/js/src/dapps/gavcoin/Application/application.js @@ -53,6 +53,7 @@ export default class Application extends Component { action: null, address: null, accounts: [], + accountsInfo: {}, blockNumber: new BigNumber(-1), ethBalance: new BigNumber(0), gavBalance: new BigNumber(0), @@ -68,7 +69,7 @@ export default class Application extends Component { } render () { - const { accounts, address, blockNumber, gavBalance, loading, price, remaining, totalSupply } = this.state; + const { accounts, accountsInfo, address, blockNumber, gavBalance, loading, price, remaining, totalSupply } = this.state; if (loading) { return ( @@ -93,7 +94,7 @@ export default class Application extends Component { gavBalance={ gavBalance } onAction={ this.onAction } /> + accountsInfo={ accountsInfo } /> ); } @@ -216,8 +217,8 @@ export default class Application extends Component { api.personal.accountsInfo() ]); }) - .then(([address, addresses, infos]) => { - infos = infos || {}; + .then(([address, addresses, accountsInfo]) => { + accountsInfo = accountsInfo || {}; console.log(`gavcoin was found at ${address}`); const contract = api.newContract(abis.gavcoin, address); @@ -226,9 +227,10 @@ export default class Application extends Component { loading: false, address, contract, + accountsInfo, instance: contract.instance, accounts: addresses.map((address) => { - const info = infos[address] || {}; + const info = accountsInfo[address] || {}; return { address, diff --git a/js/src/dapps/gavcoin/Events/Event/event.js b/js/src/dapps/gavcoin/Events/Event/event.js index 0b4094ac0..c068454f0 100644 --- a/js/src/dapps/gavcoin/Events/Event/event.js +++ b/js/src/dapps/gavcoin/Events/Event/event.js @@ -14,10 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +import moment from 'moment'; import React, { Component, PropTypes } from 'react'; import IdentityIcon from '../../IdentityIcon'; -import { formatBlockNumber, formatCoins, formatEth } from '../../format'; +import { formatCoins, formatEth, formatHash } from '../../format'; import styles from '../events.css'; @@ -27,7 +28,8 @@ const EMPTY_COLUMN = ( export default class Event extends Component { static contextTypes = { - accounts: PropTypes.array.isRequired + accountsInfo: PropTypes.object.isRequired, + api: PropTypes.object.isRequired } static propTypes = { @@ -38,14 +40,23 @@ export default class Event extends Component { toAddress: PropTypes.string } + state = { + block: null + } + + componentDidMount () { + this.loadBlock(); + } + render () { const { event, fromAddress, toAddress, price, value } = this.props; - const { blockNumber, state, type } = event; + const { block } = this.state; + const { state, type } = event; const cls = `${styles.event} ${styles[state]} ${styles[type.toLowerCase()]}`; return ( - { this.renderBlockNumber(blockNumber) } + { this.renderTimestamp(block) } { this.renderType(type) } { this.renderValue(value) } { this.renderPrice(price) } @@ -55,10 +66,10 @@ export default class Event extends Component { ); } - renderBlockNumber (blockNumber) { + renderTimestamp (block) { return ( - { formatBlockNumber(blockNumber) } + { !block ? ' ' : moment(block.timestamp).fromNow() } ); } @@ -77,8 +88,8 @@ export default class Event extends Component { } renderAddressName (address) { - const { accounts } = this.context; - const account = accounts.find((_account) => _account.address === address); + const { accountsInfo } = this.context; + const account = accountsInfo[address]; if (account && account.name) { return ( @@ -90,7 +101,7 @@ export default class Event extends Component { return (
- { address } + { formatHash(address) }
); } @@ -126,4 +137,19 @@ export default class Event extends Component { ); } + + loadBlock () { + const { api } = this.context; + const { event } = this.props; + + if (!event || !event.blockNumber || event.blockNumber.eq(0)) { + return; + } + + api.eth + .getBlockByNumber(event.blockNumber) + .then((block) => { + this.setState({ block }); + }); + } } diff --git a/js/src/dapps/gavcoin/Events/events.css b/js/src/dapps/gavcoin/Events/events.css index 9be9b37af..cf9184744 100644 --- a/js/src/dapps/gavcoin/Events/events.css +++ b/js/src/dapps/gavcoin/Events/events.css @@ -16,18 +16,20 @@ */ .events { padding: 4em 2em; + text-align: center; } .list { - width: 100%; + margin: 0 auto; border: none; border-spacing: 0; + text-align: left; } .list td { vertical-align: top; - padding: 4px 0.5em; - max-height: 32px; + padding: 0.25em 1em; + max-height: 1.5em; } .event { @@ -38,7 +40,6 @@ .blocknumber, .ethvalue, .gavvalue { - font-family: 'Roboto Mono', monospace; } .blocknumber, diff --git a/js/src/dapps/gavcoin/Events/events.js b/js/src/dapps/gavcoin/Events/events.js index ba71d6541..97dac30bb 100644 --- a/js/src/dapps/gavcoin/Events/events.js +++ b/js/src/dapps/gavcoin/Events/events.js @@ -27,7 +27,7 @@ import styles from './events.css'; export default class Events extends Component { static childContextTypes = { - accounts: PropTypes.array + accountsInfo: PropTypes.object } static contextTypes = { @@ -36,7 +36,7 @@ export default class Events extends Component { } static propTypes = { - accounts: PropTypes.array + accountsInfo: PropTypes.object.isRequired } state = { @@ -84,11 +84,9 @@ export default class Events extends Component { } getChildContext () { - const { accounts } = this.props; + const { accountsInfo } = this.props; - return { - accounts - }; + return { accountsInfo }; } setupFilters () { diff --git a/js/src/dapps/gavcoin/format/index.js b/js/src/dapps/gavcoin/format/index.js index 5e32012d0..ee554bb60 100644 --- a/js/src/dapps/gavcoin/format/index.js +++ b/js/src/dapps/gavcoin/format/index.js @@ -50,3 +50,7 @@ export function formatCoins (amount, decimals = 6) { export function formatEth (eth, decimals = 3) { return api.util.fromWei(eth).toFormat(decimals); } + +export function formatHash (hash) { + return `${hash.substr(0, 10)}...${hash.substr(-8)}`; +} diff --git a/js/src/dapps/githubhint.html b/js/src/dapps/githubhint.html index 085b15953..4689fd7d9 100644 --- a/js/src/dapps/githubhint.html +++ b/js/src/dapps/githubhint.html @@ -4,6 +4,7 @@ + GitHub Hint diff --git a/js/src/dapps/githubhint/Application/application.js b/js/src/dapps/githubhint/Application/application.js index ea7e760c5..8eb3902d3 100644 --- a/js/src/dapps/githubhint/Application/application.js +++ b/js/src/dapps/githubhint/Application/application.js @@ -151,7 +151,7 @@ export default class Application extends Component { let urlError = null; if (url && url.length) { - var re = /^https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}/g; + const re = /^https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}/g; // eslint-disable-line urlError = re.test(url) ? null : 'not matching rexex'; diff --git a/js/src/dapps/registry.html b/js/src/dapps/registry.html index 83c5e8c9b..512932a0a 100644 --- a/js/src/dapps/registry.html +++ b/js/src/dapps/registry.html @@ -4,6 +4,7 @@ + Token Registry diff --git a/js/src/dapps/signaturereg.html b/js/src/dapps/signaturereg.html index be62400d2..3929b425c 100644 --- a/js/src/dapps/signaturereg.html +++ b/js/src/dapps/signaturereg.html @@ -4,6 +4,7 @@ + Method Signature Registry diff --git a/js/src/dapps/tokenreg.html b/js/src/dapps/tokenreg.html index bcf04e298..8510aa817 100644 --- a/js/src/dapps/tokenreg.html +++ b/js/src/dapps/tokenreg.html @@ -4,6 +4,7 @@ + Token Registry diff --git a/js/src/dev.parity.html b/js/src/dev.parity.html index 56811f7c2..c2eb392d3 100644 --- a/js/src/dev.parity.html +++ b/js/src/dev.parity.html @@ -4,6 +4,7 @@ + dev::Parity.js diff --git a/js/src/dev.web3.html b/js/src/dev.web3.html index e55e0109b..ced98fca7 100644 --- a/js/src/dev.web3.html +++ b/js/src/dev.web3.html @@ -4,6 +4,7 @@ + dev::Web3 diff --git a/js/src/index.html b/js/src/index.html index 4ca2e7c1a..397a827d0 100644 --- a/js/src/index.html +++ b/js/src/index.html @@ -4,6 +4,7 @@ + Parity