diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index efd91663d..c1fdabd12 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,11 +1,11 @@ stages: - build - - test variables: GIT_DEPTH: "3" SIMPLECOV: "true" RUST_BACKTRACE: "1" RUSTFLAGS: "" + CARGOFLAGS: "" cache: key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME" untracked: true @@ -18,7 +18,7 @@ linux-stable: - tags - stable script: - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - strip target/release/parity - md5sum target/release/parity >> parity.md5 - sh scripts/deb-build.sh amd64 @@ -48,7 +48,7 @@ linux-stable-14.04: - tags - stable script: - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - strip target/release/parity - md5sum target/release/parity >> parity.md5 - sh scripts/deb-build.sh amd64 @@ -78,7 +78,7 @@ linux-beta: - tags - stable script: - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - strip target/release/parity tags: - rust @@ -97,7 +97,7 @@ linux-nightly: - tags - stable script: - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - strip target/release/parity tags: - rust @@ -118,7 +118,7 @@ linux-centos: script: - export CXX="g++" - export CC="gcc" - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - strip target/release/parity - md5sum target/release/parity >> parity.md5 - aws configure set aws_access_key_id $s3_key @@ -150,7 +150,7 @@ linux-armv7: - echo "[target.armv7-unknown-linux-gnueabihf]" >> .cargo/config - echo "linker= \"arm-linux-gnueabihf-gcc\"" >> .cargo/config - cat .cargo/config - - cargo build --target armv7-unknown-linux-gnueabihf --release --verbose + - cargo build --target armv7-unknown-linux-gnueabihf --release $CARGOFLAGS - arm-linux-gnueabihf-strip target/armv7-unknown-linux-gnueabihf/release/parity - md5sum target/armv7-unknown-linux-gnueabihf/release/parity >> parity.md5 - sh scripts/deb-build.sh armhf @@ -190,7 +190,7 @@ linux-arm: - echo "[target.arm-unknown-linux-gnueabihf]" >> .cargo/config - echo "linker= \"arm-linux-gnueabihf-gcc\"" >> .cargo/config - cat .cargo/config - - cargo build --target arm-unknown-linux-gnueabihf --release --verbose + - cargo build --target arm-unknown-linux-gnueabihf --release $CARGOFLAGS - arm-linux-gnueabihf-strip target/arm-unknown-linux-gnueabihf/release/parity - md5sum target/arm-unknown-linux-gnueabihf/release/parity >> parity.md5 - sh scripts/deb-build.sh armhf @@ -229,7 +229,7 @@ linux-armv6: - echo "[target.arm-unknown-linux-gnueabi]" >> .cargo/config - echo "linker= \"arm-linux-gnueabi-gcc\"" >> .cargo/config - cat .cargo/config - - cargo build --target arm-unknown-linux-gnueabi --release --verbose + - cargo build --target arm-unknown-linux-gnueabi --release $CARGOFLAGS - 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 @@ -262,7 +262,7 @@ linux-aarch64: - echo "[target.aarch64-unknown-linux-gnu]" >> .cargo/config - echo "linker= \"aarch64-linux-gnu-gcc\"" >> .cargo/config - cat .cargo/config - - cargo build --target aarch64-unknown-linux-gnu --release --verbose + - cargo build --target aarch64-unknown-linux-gnu --release $CARGOFLAGS - aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/parity - md5sum target/aarch64-unknown-linux-gnu/release/parity >> parity.md5 - sh scripts/deb-build.sh arm64 @@ -292,7 +292,7 @@ darwin: - tags - stable script: - - cargo build --release --verbose + - cargo build --release $CARGOFLAGS - rm -rf parity.md5 - md5sum target/release/parity >> parity.md5 - aws configure set aws_access_key_id $s3_key @@ -318,7 +318,7 @@ windows: - set RUST_BACKTRACE=1 - set RUSTFLAGS=%RUSTFLAGS% -Zorbit=off - rustup default stable-x86_64-pc-windows-msvc - - cargo build --release --verbose + - cargo build --release %CARGOFLAGS% - curl -sL --url "https://github.com/ethcore/win-build/raw/master/SimpleFC.dll" -o nsis\SimpleFC.dll - curl -sL --url "https://github.com/ethcore/win-build/raw/master/vc_redist.x64.exe" -o nsis\vc_redist.x64.exe - signtool sign /f %keyfile% /p %certpass% target\release\parity.exe @@ -353,39 +353,34 @@ windows: - target/release/parity.pdb - nsis/InstallParity.exe name: "x86_64-pc-windows-msvc_parity" +#test-darwin: +# stage: build +# before_script: +# - git submodule update --init --recursive +# script: +# - export RUST_BACKTRACE=1 +# - ./test.sh $CARGOFLAGS --no-release +# tags: +# - osx +#test-windows: +# stage: build +# before_script: +# - git submodule update --init --recursive +# script: +# - set RUST_BACKTRACE=1 +# - cargo test --features json-tests -p rlp -p ethash -p ethcore -p ethcore-bigint -p ethcore-dapps -p ethcore-rpc -p ethcore-signer -p ethcore-util -p ethcore-network -p ethcore-io -p ethkey -p ethstore -p ethsync -p ethcore-ipc -p ethcore-ipc-tests -p ethcore-ipc-nano -p parity %CARGOFLAGS% --verbose --release +# tags: +# - rust-windows +# allow_failure: true test-linux: - stage: test + stage: build before_script: - git submodule update --init --recursive script: - export RUST_BACKTRACE=1 - - ./test.sh --verbose + - ./test.sh $CARGOFLAGS --no-release tags: - rust-test - dependencies: - - linux-stable -test-darwin: - stage: test - before_script: - - git submodule update --init --recursive - script: - - export RUST_BACKTRACE=1 - - ./test.sh --verbose - tags: - - osx - dependencies: - - darwin -test-windows: - stage: test - before_script: - - git submodule update --init --recursive - script: - - set RUST_BACKTRACE=1 - - PowerShell ./test.sh --verbose - tags: - - rust-windows - dependencies: - - windows js-release: stage: build image: ethcore/javascript:latest @@ -399,7 +394,7 @@ js-release: tags: - javascript js-lint: - stage: test + stage: build image: ethcore/javascript:latest before_script: - ./js/scripts/install-deps.sh @@ -408,7 +403,7 @@ js-lint: tags: - javascript-test js-test: - stage: test + stage: build image: ethcore/javascript:latest before_script: - ./js/scripts/install-deps.sh @@ -417,7 +412,7 @@ js-test: tags: - javascript-test js-pack: - stage: test + stage: build image: ethcore/javascript:latest before_script: - ./js/scripts/install-deps.sh diff --git a/.travis.yml b/.travis.yml index d9cda5715..80bf9ba10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ env: - RUN_DOCS="false" - TEST_OPTIONS="" - RUSTFLAGS="-D warnings" + - TRAVIS_NODE_VERSION="6" # GH_TOKEN for documentation - secure: bumJASbZSU8bxJ0EyPUJmu16AiV9EXOpyOj86Jlq/Ty9CfwGqsSXt96uDyE+OUJf34RUFQMsw0nk37/zC4lcn6kqk2wpuH3N/o85Zo/cVZY/NusBWLQqtT5VbYWsV+u2Ua4Tmmsw8yVYQhYwU2ZOejNpflL+Cs9XGgORp1L+/gMRMC2y5Se6ZhwnKPQlRJ8LGsG1dzjQULxzADIt3/zuspNBS8a2urJwlHfGMkvHDoUWCviP/GXoSqw3TZR7FmKyxE19I8n9+iSvm9+oZZquvcgfUxMHn8Gq/b44UbPvjtFOg2yam4xdWXF/RyWCHdc/R9EHorSABeCbefIsm+zcUF3/YQxwpSxM4IZEeH2rTiC7dcrsKw3XsO16xFQz5YI5Bay+CT/wTdMmJd7DdYz7Dyf+pOvcM9WOf/zorxYWSBOMYy0uzbusU2iyIghQ82s7E/Ahg+WARtPgkuTLSB5aL1oCTBKHqQscMr7lo5Ti6RpWLxEdTQMBznc+bMr+6dEtkEcG9zqc6cE9XX+ox3wTU6+HVMfQ1ltCntJ4UKcw3A6INEbw9wgocQa812CIASQ2fE+SCAbz6JxBjIAlFUnD1lUB7S8PdMPwn9plfQgKQ2A5YZqg6FnBdf0rQXIJYxQWKHXj/rBHSUCT0tHACDlzTA+EwWggvkP5AGIxRxm8jhw= - KCOV_CMD="./kcov-master/tmp/usr/local/bin/kcov" @@ -41,6 +42,7 @@ cache: directories: - $TRAVIS_BUILD_DIR/target - $TRAVIS_BUILD_DIR/kcov-master + - $TRAVIS_BUILD_DIR/js/node_modules - $HOME/.cargo addons: @@ -64,9 +66,14 @@ install: make && make install DESTDIR=../tmp && cd ) + - nvm install $TRAVIS_NODE_VERSION && nvm use $TRAVIS_NODE_VERSION && ./js/scripts/install-deps.sh script: - - if [ "$RUN_TESTS" = "true" ]; then ./test.sh $TEST_OPTIONS --verbose; fi + - if [ "$RUN_TESTS" = "true" ]; then + ./js/scripts/lint.sh && + ./js/scripts/test.sh && + ./test.sh $TEST_OPTIONS --verbose; + fi - if [ "$RUN_COVERAGE" = "true" ]; then ./scripts/cov.sh "$KCOV_CMD"; fi after_success: | diff --git a/Cargo.lock b/Cargo.lock index 92fb0f8d5..b5e47dde2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1235,7 +1235,7 @@ dependencies = [ [[package]] name = "parity-ui-precompiled" version = "1.4.0" -source = "git+https://github.com/ethcore/js-precompiled.git#eec3d41e6fd1a10e4d69470a9e8c2a7b1b464466" +source = "git+https://github.com/ethcore/js-precompiled.git#8e8432d2986c29e9ff4c338cb4d2a11bc9c3c557" dependencies = [ "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/README.md b/README.md index a6c987a69..08c04c097 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # [Parity](https://ethcore.io/parity.html) ### Fast, light, and robust Ethereum implementation +[![Join the chat at https://gitter.im/ethcore/parity.js](https://badges.gitter.im/ethcore/parity.js.svg)](https://gitter.im/ethcore/parity.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Join the chat at https://gitter.im/ethcore/parity][gitter-image]][gitter-url] [![GPLv3][license-image]][license-url] [Internal Documentation][doc-url] diff --git a/dapps/src/router/mod.rs b/dapps/src/router/mod.rs index ff60df996..6ca453d6d 100644 --- a/dapps/src/router/mod.rs +++ b/dapps/src/router/mod.rs @@ -105,8 +105,12 @@ impl server::Handler for Router { trace!(target: "dapps", "Resolving to fetchable content."); self.fetch.to_async_handler(path.clone(), control) }, + // NOTE [todr] /home is redirected to home page since some users may have the redirection cached + // (in the past we used 301 instead of 302) + // It should be safe to remove it in (near) future. + // // 404 for non-existent content - (Some(_), _) if *req.method() == hyper::method::Method::Get => { + (Some(ref path), _) if *req.method() == hyper::Method::Get && path.app_id != "home" => { trace!(target: "dapps", "Resolving to 404."); Box::new(ContentHandler::error( StatusCode::NotFound, @@ -116,7 +120,7 @@ impl server::Handler for Router { )) }, // Redirect any other GET request to signer. - _ if *req.method() == hyper::method::Method::Get => { + _ if *req.method() == hyper::Method::Get => { if let Some(port) = self.signer_port { trace!(target: "dapps", "Redirecting to signer interface."); Redirection::boxed(&format!("http://{}", signer_address(port))) diff --git a/dapps/src/tests/redirection.rs b/dapps/src/tests/redirection.rs index aee1cb964..398d08774 100644 --- a/dapps/src/tests/redirection.rs +++ b/dapps/src/tests/redirection.rs @@ -56,6 +56,26 @@ fn should_redirect_to_home_when_trailing_slash_is_missing() { assert_eq!(response.headers.get(0).unwrap(), "Location: http://127.0.0.1:18180"); } +#[test] +fn should_redirect_to_home_for_users_with_cached_redirection() { + // given + let server = serve(); + + // when + let response = request(server, + "\ + GET /home/ HTTP/1.1\r\n\ + Host: 127.0.0.1:8080\r\n\ + Connection: close\r\n\ + \r\n\ + " + ); + + // then + assert_eq!(response.status, "HTTP/1.1 302 Found".to_owned()); + assert_eq!(response.headers.get(0).unwrap(), "Location: http://127.0.0.1:18180"); +} + #[test] fn should_display_404_on_invalid_dapp() { // given diff --git a/ethcore/src/account_provider.rs b/ethcore/src/account_provider.rs index fed1a05fc..064c3e935 100644 --- a/ethcore/src/account_provider.rs +++ b/ethcore/src/account_provider.rs @@ -36,7 +36,7 @@ enum Unlock { /// Use with caution. Perm, /// Account unlocked with a timeout - Timed((Instant, u32)), + Timed(Instant), } /// Data associated with account. @@ -308,8 +308,8 @@ impl AccountProvider { if let Unlock::Temp = data.unlock { unlocked.remove(account).expect("data exists: so key must exist: qed"); } - if let Unlock::Timed((ref start, ref duration)) = data.unlock { - if start.elapsed() > Duration::from_millis(*duration as u64) { + if let Unlock::Timed(ref end) = data.unlock { + if Instant::now() > *end { unlocked.remove(account).expect("data exists: so key must exist: qed"); return Err(Error::NotUnlocked); } @@ -329,7 +329,7 @@ impl AccountProvider { /// Unlocks account temporarily with a timeout. pub fn unlock_account_timed(&self, account: Address, password: String, duration_ms: u32) -> Result<(), Error> { - self.unlock_account(account, password, Unlock::Timed((Instant::now(), duration_ms))) + self.unlock_account(account, password, Unlock::Timed(Instant::now() + Duration::from_millis(duration_ms as u64))) } /// Checks if given account is unlocked @@ -363,11 +363,11 @@ impl AccountProvider { #[cfg(test)] mod tests { - use super::{AccountProvider, AddressBook}; + use super::{AccountProvider, AddressBook, Unlock}; use std::collections::HashMap; + use std::time::Instant; use ethjson::misc::AccountMeta; use ethstore::ethkey::{Generator, Random}; - use std::time::Duration; use devtools::RandomTempPath; #[test] @@ -411,10 +411,10 @@ mod tests { let kp = Random.generate().unwrap(); let ap = AccountProvider::transient_provider(); assert!(ap.insert_account(kp.secret().clone(), "test").is_ok()); - assert!(ap.unlock_account_timed(kp.address(), "test1".into(), 2000).is_err()); - assert!(ap.unlock_account_timed(kp.address(), "test".into(), 2000).is_ok()); + assert!(ap.unlock_account_timed(kp.address(), "test1".into(), 60000).is_err()); + assert!(ap.unlock_account_timed(kp.address(), "test".into(), 60000).is_ok()); assert!(ap.sign(kp.address(), None, Default::default()).is_ok()); - ::std::thread::sleep(Duration::from_millis(2000)); + ap.unlocked.lock().get_mut(&kp.address()).unwrap().unlock = Unlock::Timed(Instant::now()); assert!(ap.sign(kp.address(), None, Default::default()).is_err()); } } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index a518daa5a..e35c27224 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -45,6 +45,7 @@ use block::*; use transaction::{LocalizedTransaction, SignedTransaction, Action}; use blockchain::extras::TransactionAddress; use types::filter::Filter; +use types::mode::Mode as IpcMode; use log_entry::LocalizedLogEntry; use verification::queue::BlockQueue; use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; @@ -123,7 +124,7 @@ impl SleepState { /// Blockchain database client backed by a persistent database. Owns and manages a blockchain and a block queue. /// Call `import_block()` to import a block asynchronously; `flush_queue()` flushes the queue. pub struct Client { - mode: Mode, + mode: Mutex, chain: RwLock>, tracedb: RwLock>, engine: Arc, @@ -221,7 +222,7 @@ impl Client { let client = Client { sleep_state: Mutex::new(SleepState::new(awake)), liveness: AtomicBool::new(awake), - mode: config.mode.clone(), + mode: Mutex::new(config.mode.clone()), chain: RwLock::new(chain), tracedb: tracedb, engine: engine, @@ -620,7 +621,8 @@ impl Client { self.block_queue.collect_garbage(); self.tracedb.read().collect_garbage(); - match self.mode { + let mode = self.mode.lock().clone(); + match mode { Mode::Dark(timeout) => { let mut ss = self.sleep_state.lock(); if let Some(t) = ss.last_activity { @@ -772,7 +774,7 @@ impl BlockChainClient for Client { fn call(&self, t: &SignedTransaction, block: BlockID, analytics: CallAnalytics) -> Result { let header = try!(self.block_header(block).ok_or(CallError::StatePruned)); let view = HeaderView::new(&header); - let last_hashes = self.build_last_hashes(view.hash()); + let last_hashes = self.build_last_hashes(view.parent_hash()); let env_info = EnvInfo { number: view.number(), author: view.author(), @@ -844,12 +846,24 @@ impl BlockChainClient for Client { } fn keep_alive(&self) { - if self.mode != Mode::Active { + let mode = self.mode.lock().clone(); + if mode != Mode::Active { self.wake_up(); (*self.sleep_state.lock()).last_activity = Some(Instant::now()); } } + fn mode(&self) -> IpcMode { self.mode.lock().clone().into() } + + fn set_mode(&self, mode: IpcMode) { + *self.mode.lock() = mode.clone().into(); + match mode { + IpcMode::Active => self.wake_up(), + IpcMode::Off => self.sleep(), + _ => {(*self.sleep_state.lock()).last_activity = Some(Instant::now()); } + } + } + fn best_block_header(&self) -> Bytes { self.chain.read().best_block_header() } diff --git a/ethcore/src/client/config.rs b/ethcore/src/client/config.rs index 850e5c938..c4aeba8a4 100644 --- a/ethcore/src/client/config.rs +++ b/ethcore/src/client/config.rs @@ -76,6 +76,8 @@ pub enum Mode { /// Goes offline after RLP is inactive for some (given) time and /// stays inactive. Dark(Duration), + /// Always off. + Off, } impl Default for Mode { diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index a291a1780..4e0a94345 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -37,6 +37,7 @@ use error::{ImportResult}; use evm::{Factory as EvmFactory, VMType, Schedule}; use miner::{Miner, MinerService, TransactionImportResult}; use spec::Spec; +use types::mode::Mode; use verification::queue::QueueInfo; use block::{OpenBlock, SealedBlock}; @@ -83,6 +84,10 @@ pub struct TestBlockChainClient { pub vm_factory: EvmFactory, /// Timestamp assigned to latest sealed block pub latest_block_timestamp: RwLock, + /// Ancient block info. + pub ancient_block: RwLock>, + /// First block info. + pub first_block: RwLock>, } #[derive(Clone)] @@ -142,6 +147,8 @@ impl TestBlockChainClient { spec: spec, vm_factory: EvmFactory::new(VMType::Interpreter, 1024 * 1024), latest_block_timestamp: RwLock::new(10_000_000), + ancient_block: RwLock::new(None), + first_block: RwLock::new(None), }; client.add_blocks(1, EachBlockWith::Nothing); // add genesis block client.genesis_hash = client.last_hash.read().clone(); @@ -603,10 +610,10 @@ impl BlockChainClient for TestBlockChainClient { genesis_hash: self.genesis_hash.clone(), best_block_hash: self.last_hash.read().clone(), best_block_number: self.blocks.read().len() as BlockNumber - 1, - first_block_hash: None, - first_block_number: None, - ancient_block_hash: None, - ancient_block_number: None, + first_block_hash: self.first_block.read().as_ref().map(|x| x.0), + first_block_number: self.first_block.read().as_ref().map(|x| x.1), + ancient_block_hash: self.ancient_block.read().as_ref().map(|x| x.0), + ancient_block_number: self.ancient_block.read().as_ref().map(|x| x.1) } } @@ -635,4 +642,8 @@ impl BlockChainClient for TestBlockChainClient { fn pending_transactions(&self) -> Vec { self.miner.pending_transactions(self.chain_info().best_block_number) } + + fn mode(&self) -> Mode { Mode::Active } + + fn set_mode(&self, _: Mode) { unimplemented!(); } } diff --git a/ethcore/src/client/traits.rs b/ethcore/src/client/traits.rs index 700b88f8b..d7844ba3d 100644 --- a/ethcore/src/client/traits.rs +++ b/ethcore/src/client/traits.rs @@ -16,6 +16,7 @@ use std::collections::BTreeMap; use util::{U256, Address, H256, H2048, Bytes, Itertools}; +use util::stats::Histogram; use blockchain::TreeRoute; use verification::queue::QueueInfo as BlockQueueInfo; use block::{OpenBlock, SealedBlock}; @@ -37,6 +38,7 @@ use block_import_error::BlockImportError; use ipc::IpcConfig; use types::blockchain_info::BlockChainInfo; use types::block_status::BlockStatus; +use types::mode::Mode; #[ipc(client_ident="RemoteClient")] /// Blockchain database client. Owns and manages a blockchain and a block queue. @@ -190,8 +192,8 @@ pub trait BlockChainClient : Sync + Send { /// list all transactions fn pending_transactions(&self) -> Vec; - /// Get the gas price distribution. - fn gas_price_statistics(&self, sample_size: usize, distribution_size: usize) -> Result, ()> { + /// Sorted list of transaction gas prices from at least last sample_size blocks. + fn gas_price_corpus(&self, sample_size: usize) -> Vec { let mut h = self.chain_info().best_block_hash; let mut corpus = Vec::new(); while corpus.is_empty() { @@ -200,26 +202,34 @@ pub trait BlockChainClient : Sync + Send { let block = BlockView::new(&block_bytes); let header = block.header_view(); if header.number() == 0 { - if corpus.is_empty() { - corpus.push(20_000_000_000u64.into()); // we have literally no information - it' as good a number as any. - } - break; + return corpus; } block.transaction_views().iter().foreach(|t| corpus.push(t.gas_price())); h = header.parent_hash().clone(); } } corpus.sort(); - let n = corpus.len(); - if n > 0 { - Ok((0..(distribution_size + 1)) - .map(|i| corpus[i * (n - 1) / distribution_size]) - .collect::>() - ) - } else { - Err(()) - } + corpus } + + /// Calculate median gas price from recent blocks if they have any transactions. + fn gas_price_median(&self, sample_size: usize) -> Option { + let corpus = self.gas_price_corpus(sample_size); + corpus.get(corpus.len()/2).cloned() + } + + /// Get the gas price distribution based on recent blocks if they have any transactions. + fn gas_price_histogram(&self, sample_size: usize, bucket_number: usize) -> Option { + let raw_corpus = self.gas_price_corpus(sample_size); + let raw_len = raw_corpus.len(); + // Throw out outliers. + let (corpus, _) = raw_corpus.split_at(raw_len-raw_len/40); + Histogram::new(corpus, bucket_number) + } + + fn mode(&self) -> Mode; + + fn set_mode(&self, mode: Mode); } /// Extended client interface used for mining diff --git a/ethcore/src/miner/mod.rs b/ethcore/src/miner/mod.rs index 145d790dd..da93dc0b7 100644 --- a/ethcore/src/miner/mod.rs +++ b/ethcore/src/miner/mod.rs @@ -158,7 +158,7 @@ pub trait MinerService : Send + Sync { fn is_sealing(&self) -> bool; /// Suggested gas price. - fn sensible_gas_price(&self) -> U256 { 20000000000u64.into() } + fn sensible_gas_price(&self) -> U256; /// Suggested gas limit. fn sensible_gas_limit(&self) -> U256 { 21000.into() } diff --git a/ethcore/src/service.rs b/ethcore/src/service.rs index 08ab78116..36b5e7157 100644 --- a/ethcore/src/service.rs +++ b/ethcore/src/service.rs @@ -192,6 +192,8 @@ impl IoHandler for ClientIoHandler { #[cfg_attr(feature="dev", allow(single_match))] fn message(&self, _io: &IoContext, net_message: &ClientIoMessage) { + use std::thread; + match *net_message { ClientIoMessage::BlockVerified => { self.client.import_verified_blocks(); } ClientIoMessage::NewTransactions(ref transactions) => { self.client.import_queued_transactions(transactions); } @@ -203,8 +205,17 @@ impl IoHandler for ClientIoHandler { ClientIoMessage::FeedStateChunk(ref hash, ref chunk) => self.snapshot.feed_state_chunk(*hash, chunk), ClientIoMessage::FeedBlockChunk(ref hash, ref chunk) => self.snapshot.feed_block_chunk(*hash, chunk), ClientIoMessage::TakeSnapshot(num) => { - if let Err(e) = self.snapshot.take_snapshot(&*self.client, num) { - warn!("Failed to take snapshot at block #{}: {}", num, e); + let client = self.client.clone(); + let snapshot = self.snapshot.clone(); + + let res = thread::Builder::new().name("Periodic Snapshot".into()).spawn(move || { + if let Err(e) = snapshot.take_snapshot(&*client, num) { + warn!("Failed to take snapshot at block #{}: {}", num, e); + } + }); + + if let Err(e) = res { + debug!(target: "snapshot", "Failed to initialize periodic snapshot thread: {:?}", e); } }, ClientIoMessage::UpdateSealing => { diff --git a/ethcore/src/tests/client.rs b/ethcore/src/tests/client.rs index e152ac37a..3a24ccf21 100644 --- a/ethcore/src/tests/client.rs +++ b/ethcore/src/tests/client.rs @@ -26,6 +26,7 @@ use miner::Miner; use rlp::{Rlp, View}; use spec::Spec; use views::BlockView; +use util::stats::Histogram; #[test] fn imports_from_empty() { @@ -198,19 +199,37 @@ fn can_collect_garbage() { assert!(client.blockchain_cache_info().blocks < 100 * 1024); } + #[test] -#[cfg_attr(feature="dev", allow(useless_vec))] -fn can_generate_gas_price_statistics() { - let client_result = generate_dummy_client_with_data(16, 1, &vec_into![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]); +fn can_generate_gas_price_median() { + let client_result = generate_dummy_client_with_data(3, 1, &vec_into![1, 2, 3]); let client = client_result.reference(); - let s = client.gas_price_statistics(8, 8).unwrap(); - assert_eq!(s, vec_into![8, 8, 9, 10, 11, 12, 13, 14, 15]); - let s = client.gas_price_statistics(16, 8).unwrap(); - assert_eq!(s, vec_into![0, 1, 3, 5, 7, 9, 11, 13, 15]); - let s = client.gas_price_statistics(32, 8).unwrap(); - assert_eq!(s, vec_into![0, 1, 3, 5, 7, 9, 11, 13, 15]); + assert_eq!(Some(U256::from(2)), client.gas_price_median(3)); + + let client_result = generate_dummy_client_with_data(4, 1, &vec_into![1, 4, 3, 2]); + let client = client_result.reference(); + assert_eq!(Some(U256::from(3)), client.gas_price_median(4)); } +#[test] +fn can_generate_gas_price_histogram() { + let client_result = generate_dummy_client_with_data(20, 1, &vec_into![6354,8593,6065,4842,7845,7002,689,4958,4250,6098,5804,4320,643,8895,2296,8589,7145,2000,2512,1408]); + let client = client_result.reference(); + + let hist = client.gas_price_histogram(20, 5).unwrap(); + let correct_hist = Histogram { bucket_bounds: vec_into![643,2293,3943,5593,7243,8893], counts: vec![4,2,4,6,3] }; + assert_eq!(hist, correct_hist); +} + +#[test] +fn empty_gas_price_histogram() { + let client_result = generate_dummy_client_with_data(20, 0, &vec_into![]); + let client = client_result.reference(); + + assert!(client.gas_price_histogram(20, 5).is_none()); +} + + #[test] fn can_handle_long_fork() { let client_result = generate_dummy_client(1200); diff --git a/ethcore/src/types/mod.rs.in b/ethcore/src/types/mod.rs.in index 32c7faabe..1d2cdb3c0 100644 --- a/ethcore/src/types/mod.rs.in +++ b/ethcore/src/types/mod.rs.in @@ -33,3 +33,4 @@ pub mod transaction_import; pub mod block_import_error; pub mod restoration_status; pub mod snapshot_manifest; +pub mod mode; \ No newline at end of file diff --git a/ethcore/src/types/mode.rs b/ethcore/src/types/mode.rs new file mode 100644 index 000000000..b48a92a89 --- /dev/null +++ b/ethcore/src/types/mode.rs @@ -0,0 +1,55 @@ +// 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 . + +//! Mode type + +pub use std::time::Duration; +use client::Mode as ClientMode; + +/// IPC-capable shadow-type for client::config::Mode +#[derive(Clone, Binary)] +pub enum Mode { + /// Same as ClientMode::Off. + Off, + /// Same as ClientMode::Dark; values in seconds. + Dark(u64), + /// Same as ClientMode::Passive; values in seconds. + Passive(u64, u64), + /// Same as ClientMode::Active. + Active, +} + +impl From for Mode { + fn from(mode: ClientMode) -> Self { + match mode { + ClientMode::Off => Mode::Off, + ClientMode::Dark(timeout) => Mode::Dark(timeout.as_secs()), + ClientMode::Passive(timeout, alarm) => Mode::Passive(timeout.as_secs(), alarm.as_secs()), + ClientMode::Active => Mode::Active, + } + } +} + +impl From for ClientMode { + fn from(mode: Mode) -> Self { + match mode { + Mode::Off => ClientMode::Off, + Mode::Dark(timeout) => ClientMode::Dark(Duration::from_secs(timeout)), + Mode::Passive(timeout, alarm) => ClientMode::Passive(Duration::from_secs(timeout), Duration::from_secs(alarm)), + Mode::Active => ClientMode::Active, + } + } +} \ No newline at end of file diff --git a/ethkey/src/brain.rs b/ethkey/src/brain.rs index f7f9322e0..dd8913c66 100644 --- a/ethkey/src/brain.rs +++ b/ethkey/src/brain.rs @@ -15,7 +15,7 @@ // along with Parity. If not, see . use keccak::Keccak256; -use super::{KeyPair, Error, Generator, Secret}; +use super::{KeyPair, Error, Generator}; /// Simple brainwallet. pub struct Brain(String); @@ -38,9 +38,9 @@ impl Generator for Brain { match i > 16384 { false => i += 1, true => { - let result = KeyPair::from_secret(Secret::from(secret.clone())); - if result.is_ok() { - return result + let result = KeyPair::from_secret(secret.clone().into()); + if result.as_ref().ok().map_or(false, |r| r.address()[0] == 0) { + return result; } }, } diff --git a/js/assets/images/contracts/augur-68x68.png b/js/assets/images/contracts/augur-68x68.png deleted file mode 100644 index 99dd2bb8d..000000000 Binary files a/js/assets/images/contracts/augur-68x68.png and /dev/null differ diff --git a/js/assets/images/contracts/beer-64x64.png b/js/assets/images/contracts/beer-64x64.png deleted file mode 100644 index d75eedd69..000000000 Binary files a/js/assets/images/contracts/beer-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/beer.png b/js/assets/images/contracts/beer.png deleted file mode 100644 index 49846170d..000000000 Binary files a/js/assets/images/contracts/beer.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-euro-64x64.png b/js/assets/images/contracts/coin-euro-64x64.png deleted file mode 100644 index 0af66131b..000000000 Binary files a/js/assets/images/contracts/coin-euro-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-euro.png b/js/assets/images/contracts/coin-euro.png deleted file mode 100644 index d4a5b081e..000000000 Binary files a/js/assets/images/contracts/coin-euro.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-pound-64x64.png b/js/assets/images/contracts/coin-pound-64x64.png deleted file mode 100644 index 645a9d674..000000000 Binary files a/js/assets/images/contracts/coin-pound-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-pound.png b/js/assets/images/contracts/coin-pound.png deleted file mode 100644 index 1158f2377..000000000 Binary files a/js/assets/images/contracts/coin-pound.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-us-dollar-64x64.png b/js/assets/images/contracts/coin-us-dollar-64x64.png deleted file mode 100644 index 44255e1f9..000000000 Binary files a/js/assets/images/contracts/coin-us-dollar-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-us-dollar.png b/js/assets/images/contracts/coin-us-dollar.png deleted file mode 100644 index 918a86ac4..000000000 Binary files a/js/assets/images/contracts/coin-us-dollar.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-yuan-64x64.png b/js/assets/images/contracts/coin-yuan-64x64.png deleted file mode 100644 index ec16a144e..000000000 Binary files a/js/assets/images/contracts/coin-yuan-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/coin-yuan.png b/js/assets/images/contracts/coin-yuan.png deleted file mode 100644 index 1e7b7282a..000000000 Binary files a/js/assets/images/contracts/coin-yuan.png and /dev/null differ diff --git a/js/assets/images/contracts/dgd-64x64.png b/js/assets/images/contracts/dgd-64x64.png deleted file mode 100644 index fa1bd308f..000000000 Binary files a/js/assets/images/contracts/dgd-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/dgd.png b/js/assets/images/contracts/dgd.png deleted file mode 100644 index 09b2831af..000000000 Binary files a/js/assets/images/contracts/dgd.png and /dev/null differ diff --git a/js/assets/images/contracts/dgx-64x64.png b/js/assets/images/contracts/dgx-64x64.png deleted file mode 100644 index c81c3387c..000000000 Binary files a/js/assets/images/contracts/dgx-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/dgx.png b/js/assets/images/contracts/dgx.png deleted file mode 100644 index 9ac5dff1b..000000000 Binary files a/js/assets/images/contracts/dgx.png and /dev/null differ diff --git a/js/assets/images/contracts/firstblood-64x64.png b/js/assets/images/contracts/firstblood-64x64.png deleted file mode 100644 index c18b24528..000000000 Binary files a/js/assets/images/contracts/firstblood-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/firstblood.png b/js/assets/images/contracts/firstblood.png deleted file mode 100644 index 8e43c09ec..000000000 Binary files a/js/assets/images/contracts/firstblood.png and /dev/null differ diff --git a/js/assets/images/contracts/gavcoin-64x64.png b/js/assets/images/contracts/gavcoin-64x64.png deleted file mode 100644 index 13b25a341..000000000 Binary files a/js/assets/images/contracts/gavcoin-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/gavcoin.png b/js/assets/images/contracts/gavcoin.png deleted file mode 100644 index 20e686f20..000000000 Binary files a/js/assets/images/contracts/gavcoin.png and /dev/null differ diff --git a/js/assets/images/contracts/hkg-64x64.png b/js/assets/images/contracts/hkg-64x64.png deleted file mode 100644 index 5c3fef99c..000000000 Binary files a/js/assets/images/contracts/hkg-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/hkg.png b/js/assets/images/contracts/hkg.png deleted file mode 100644 index 9971362d9..000000000 Binary files a/js/assets/images/contracts/hkg.png and /dev/null differ diff --git a/js/assets/images/contracts/iconomi-64x64.png b/js/assets/images/contracts/iconomi-64x64.png deleted file mode 100644 index b3ef6b95b..000000000 Binary files a/js/assets/images/contracts/iconomi-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/iconomi.png b/js/assets/images/contracts/iconomi.png deleted file mode 100644 index cc7b69afe..000000000 Binary files a/js/assets/images/contracts/iconomi.png and /dev/null differ diff --git a/js/assets/images/contracts/maker-64x64.png b/js/assets/images/contracts/maker-64x64.png deleted file mode 100644 index 5747bdba8..000000000 Binary files a/js/assets/images/contracts/maker-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/maker.png b/js/assets/images/contracts/maker.png deleted file mode 100644 index 259c674bb..000000000 Binary files a/js/assets/images/contracts/maker.png and /dev/null differ diff --git a/js/assets/images/contracts/maker.svg b/js/assets/images/contracts/maker.svg deleted file mode 100644 index 3c2c6e634..000000000 --- a/js/assets/images/contracts/maker.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - logo-maker - Created with Sketch. - - - - - - - - - - - - - \ No newline at end of file diff --git a/js/assets/images/contracts/nexium-64x64.png b/js/assets/images/contracts/nexium-64x64.png deleted file mode 100644 index 4b3a34120..000000000 Binary files a/js/assets/images/contracts/nexium-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/nexium.png b/js/assets/images/contracts/nexium.png deleted file mode 100644 index 24693dc94..000000000 Binary files a/js/assets/images/contracts/nexium.png and /dev/null differ diff --git a/js/assets/images/contracts/pluton-64x64.png b/js/assets/images/contracts/pluton-64x64.png deleted file mode 100644 index 3cbe331f6..000000000 Binary files a/js/assets/images/contracts/pluton-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/pluton.png b/js/assets/images/contracts/pluton.png deleted file mode 100644 index ac778ef05..000000000 Binary files a/js/assets/images/contracts/pluton.png and /dev/null differ diff --git a/js/assets/images/contracts/pluton.svg b/js/assets/images/contracts/pluton.svg deleted file mode 100644 index ecbcee82e..000000000 --- a/js/assets/images/contracts/pluton.svg +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/js/assets/images/contracts/singular-64x64.png b/js/assets/images/contracts/singular-64x64.png deleted file mode 100644 index e33e38c1c..000000000 Binary files a/js/assets/images/contracts/singular-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/singular.png b/js/assets/images/contracts/singular.png deleted file mode 100644 index 177ab5b64..000000000 Binary files a/js/assets/images/contracts/singular.png and /dev/null differ diff --git a/js/assets/images/contracts/singular.svg b/js/assets/images/contracts/singular.svg deleted file mode 100644 index a735ca7e1..000000000 --- a/js/assets/images/contracts/singular.svg +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/js/assets/images/contracts/unicorn-64x64.png b/js/assets/images/contracts/unicorn-64x64.png deleted file mode 100644 index 7850b09f1..000000000 Binary files a/js/assets/images/contracts/unicorn-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/unicorn.png b/js/assets/images/contracts/unicorn.png deleted file mode 100644 index 9bd2ef1cc..000000000 Binary files a/js/assets/images/contracts/unicorn.png and /dev/null differ diff --git a/js/assets/images/contracts/xaurum-64x64.png b/js/assets/images/contracts/xaurum-64x64.png deleted file mode 100644 index e3d7411f5..000000000 Binary files a/js/assets/images/contracts/xaurum-64x64.png and /dev/null differ diff --git a/js/assets/images/contracts/xaurum.png b/js/assets/images/contracts/xaurum.png deleted file mode 100644 index c7500c906..000000000 Binary files a/js/assets/images/contracts/xaurum.png and /dev/null differ diff --git a/js/assets/images/dapps/gavcoin-bg.jpg b/js/assets/images/dapps/gavcoin-bg.jpg deleted file mode 100644 index c344f5979..000000000 Binary files a/js/assets/images/dapps/gavcoin-bg.jpg and /dev/null differ diff --git a/js/assets/images/ethcore-block-black.png b/js/assets/images/ethcore-block-black.png deleted file mode 100644 index 780a5be5c..000000000 Binary files a/js/assets/images/ethcore-block-black.png and /dev/null differ diff --git a/js/assets/images/ethcore-block-blue.png b/js/assets/images/ethcore-block-blue.png deleted file mode 100644 index fd93635ec..000000000 Binary files a/js/assets/images/ethcore-block-blue.png and /dev/null differ diff --git a/js/assets/images/ethcore-block.png b/js/assets/images/ethcore-block.png deleted file mode 100644 index bac46e5c9..000000000 Binary files a/js/assets/images/ethcore-block.png and /dev/null differ diff --git a/js/assets/images/ethcore-logo-white-square.png b/js/assets/images/ethcore-logo-white-square.png deleted file mode 100644 index a300b5a0a..000000000 Binary files a/js/assets/images/ethcore-logo-white-square.png and /dev/null differ diff --git a/js/assets/images/parity-logo-black-no-text.ico b/js/assets/images/parity-logo-black-no-text.ico new file mode 100644 index 000000000..8edfa3e6a Binary files /dev/null and b/js/assets/images/parity-logo-black-no-text.ico differ diff --git a/js/assets/images/parity-logo-black-no-text.png b/js/assets/images/parity-logo-black-no-text.png new file mode 100644 index 000000000..b2aea789e Binary files /dev/null and b/js/assets/images/parity-logo-black-no-text.png differ diff --git a/js/assets/images/parity-logo-black-no-text.svg b/js/assets/images/parity-logo-black-no-text.svg new file mode 100644 index 000000000..a4f104838 --- /dev/null +++ b/js/assets/images/parity-logo-black-no-text.svg @@ -0,0 +1,65 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/js/assets/images/parity-logo-black.svg b/js/assets/images/parity-logo-black.svg new file mode 100644 index 000000000..f2b2fa726 --- /dev/null +++ b/js/assets/images/parity-logo-black.svg @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/js/assets/images/parity-logo-white-no-text.svg b/js/assets/images/parity-logo-white-no-text.svg new file mode 100644 index 000000000..213ab1db4 --- /dev/null +++ b/js/assets/images/parity-logo-white-no-text.svg @@ -0,0 +1,66 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/js/assets/images/parity-logo-white.svg b/js/assets/images/parity-logo-white.svg new file mode 100644 index 000000000..7360ef6a6 --- /dev/null +++ b/js/assets/images/parity-logo-white.svg @@ -0,0 +1,100 @@ + + + +image/svg+xml diff --git a/js/assets/images/parity-x56.png b/js/assets/images/parity-x56.png deleted file mode 100644 index e303427a4..000000000 Binary files a/js/assets/images/parity-x56.png and /dev/null differ diff --git a/js/assets/images/parity.ico b/js/assets/images/parity.ico deleted file mode 100644 index 4551b46be..000000000 Binary files a/js/assets/images/parity.ico and /dev/null differ diff --git a/js/assets/images/parity.xcf b/js/assets/images/parity.xcf deleted file mode 100644 index 37fa206c0..000000000 Binary files a/js/assets/images/parity.xcf and /dev/null differ diff --git a/js/package.json b/js/package.json index ecd749792..0ff75b720 100644 --- a/js/package.json +++ b/js/package.json @@ -1,6 +1,6 @@ { "name": "parity.js", - "version": "0.1.5", + "version": "0.1.35", "main": "release/index.js", "jsnext:main": "src/index.js", "author": "Parity Team ", @@ -75,12 +75,13 @@ "eslint-plugin-promise": "^2.0.0", "eslint-plugin-react": "^5.1.1", "eslint-plugin-standard": "^2.0.0", + "extract-loader": "0.0.2", "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", + "html-loader": "^0.4.4", "ignore-styles": "2.0.0", "image-webpack-loader": "^1.8.0", "istanbul": "^1.0.0-alpha.2", @@ -92,6 +93,7 @@ "nock": "^8.0.0", "postcss-import": "^8.1.2", "postcss-loader": "^0.8.1", + "postcss-nested": "^1.0.0", "postcss-simple-vars": "^3.0.0", "react-addons-test-utils": "^15.3.0", "react-copy-to-clipboard": "^4.2.3", @@ -112,6 +114,7 @@ "bignumber.js": "^2.3.0", "blockies": "0.0.2", "bytes": "^2.4.0", + "chart.js": "^2.3.0", "es6-promise": "^3.2.1", "file-saver": "^1.3.3", "format-json": "^1.0.3", @@ -127,12 +130,14 @@ "qs": "^6.3.0", "react": "^15.2.1", "react-addons-css-transition-group": "^15.2.1", + "react-chartjs-2": "^1.5.0", "react-dom": "^15.2.1", "react-redux": "^4.4.5", "react-router": "^2.6.1", "react-router-redux": "^4.0.5", "react-tap-event-plugin": "^1.0.0", "react-tooltip": "^2.0.3", + "recharts": "^0.15.2", "redux": "^3.5.2", "redux-actions": "^0.10.1", "redux-thunk": "^2.1.0", diff --git a/js/scripts/install-deps.sh b/js/scripts/install-deps.sh index 67113f27e..96c2f36b1 100755 --- a/js/scripts/install-deps.sh +++ b/js/scripts/install-deps.sh @@ -6,6 +6,8 @@ cd .. # install deps and store the exit code EXITCODE=0 +node --version +npm --version npm install --progress=false || EXITCODE=1 # back to root diff --git a/js/src/api/format/output.js b/js/src/api/format/output.js index 060a58cb8..8461df20f 100644 --- a/js/src/api/format/output.js +++ b/js/src/api/format/output.js @@ -70,6 +70,20 @@ export function outDate (date) { return new Date(outNumber(date).toNumber() * 1000); } +export function outHistogram (histogram) { + if (histogram) { + Object.keys(histogram).forEach((key) => { + switch (key) { + case 'bucketBounds': + case 'counts': + histogram[key] = histogram[key].map(outNumber); + } + }); + } + + return histogram; +} + export function outLog (log) { Object.keys(log).forEach((key) => { switch (key) { @@ -139,6 +153,28 @@ export function outSignerRequest (request) { return request; } +export function outSyncing (syncing) { + if (syncing && syncing !== 'false') { + Object.keys(syncing).forEach((key) => { + switch (key) { + case 'currentBlock': + case 'highestBlock': + case 'startingBlock': + case 'warpChunksAmount': + case 'warpChunksProcessed': + syncing[key] = outNumber(syncing[key]); + break; + + case 'blockGap': + syncing[key] = syncing[key] ? syncing[key].map(outNumber) : syncing[key]; + break; + } + }); + } + + return syncing; +} + export function outTransaction (tx) { if (tx) { Object.keys(tx).forEach((key) => { diff --git a/js/src/api/format/output.spec.js b/js/src/api/format/output.spec.js index 00c5ba6ad..aac433d70 100644 --- a/js/src/api/format/output.spec.js +++ b/js/src/api/format/output.spec.js @@ -16,7 +16,7 @@ import BigNumber from 'bignumber.js'; -import { outBlock, outAccountInfo, outAddress, outDate, outNumber, outPeers, outReceipt, outTransaction, outTrace } from './output'; +import { outBlock, outAccountInfo, outAddress, outDate, outHistogram, outNumber, outPeers, outReceipt, outSyncing, outTransaction, outTrace } from './output'; import { isAddress, isBigNumber, isInstanceOf } from '../../../test/types'; describe('api/format/output', () => { @@ -120,6 +120,18 @@ describe('api/format/output', () => { }); }); + describe('outHistogram', () => { + ['bucketBounds', 'counts'].forEach((type) => { + it(`formats ${type} as number arrays`, () => { + expect( + outHistogram({ [type]: [0x123, 0x456, 0x789] }) + ).to.deep.equal({ + [type]: [new BigNumber(0x123), new BigNumber(0x456), new BigNumber(0x789)] + }); + }); + }); + }); + describe('outNumber', () => { it('returns a BigNumber equalling the value', () => { const bn = outNumber('0x123456'); @@ -191,6 +203,22 @@ describe('api/format/output', () => { }); }); + describe('outSyncing', () => { + ['currentBlock', 'highestBlock', 'startingBlock', 'warpChunksAmount', 'warpChunksProcessed'].forEach((input) => { + it(`formats ${input} numbers as a number`, () => { + expect(outSyncing({ [input]: '0x123' })).to.deep.equal({ + [input]: new BigNumber('0x123') + }); + }); + }); + + it('formats blockGap properly', () => { + expect(outSyncing({ blockGap: [0x123, 0x456] })).to.deep.equal({ + blockGap: [new BigNumber(0x123), new BigNumber(0x456)] + }); + }); + }); + describe('outTransaction', () => { ['from', 'to'].forEach((input) => { it(`formats ${input} address as address`, () => { diff --git a/js/src/api/rpc/eth/eth.js b/js/src/api/rpc/eth/eth.js index 3d99f82b8..703f3ed11 100644 --- a/js/src/api/rpc/eth/eth.js +++ b/js/src/api/rpc/eth/eth.js @@ -15,7 +15,7 @@ // along with Parity. If not, see . import { inAddress, inBlockNumber, inData, inFilter, inHash, inHex, inNumber16, inOptions } from '../../format/input'; -import { outAddress, outBlock, outLog, outNumber, outReceipt, outTransaction } from '../../format/output'; +import { outAddress, outBlock, outLog, outNumber, outReceipt, outSyncing, outTransaction } from '../../format/output'; export default class Eth { constructor (transport) { @@ -314,7 +314,8 @@ export default class Eth { syncing () { return this._transport - .execute('eth_syncing'); + .execute('eth_syncing') + .then(outSyncing); } uninstallFilter (filterId) { diff --git a/js/src/api/rpc/ethcore/ethcore.e2e.js b/js/src/api/rpc/ethcore/ethcore.e2e.js index ee4056b50..aae7108e7 100644 --- a/js/src/api/rpc/ethcore/ethcore.e2e.js +++ b/js/src/api/rpc/ethcore/ethcore.e2e.js @@ -27,6 +27,16 @@ describe('ethapi.ethcore', () => { }); }); + describe('gasPriceHistogram', () => { + it('returns and translates the target', () => { + return ethapi.ethcore.gasPriceHistogram().then((result) => { + expect(Object.keys(result)).to.deep.equal(['bucketBounds', 'counts']); + expect(result.bucketBounds.length > 0).to.be.true; + expect(result.counts.length > 0).to.be.true; + }); + }); + }); + describe('netChain', () => { it('returns and the chain', () => { return ethapi.ethcore.netChain().then((value) => { diff --git a/js/src/api/rpc/ethcore/ethcore.js b/js/src/api/rpc/ethcore/ethcore.js index b9dec3b69..663143f0d 100644 --- a/js/src/api/rpc/ethcore/ethcore.js +++ b/js/src/api/rpc/ethcore/ethcore.js @@ -15,7 +15,7 @@ // along with Parity. If not, see . import { inAddress, inData, inNumber16 } from '../../format/input'; -import { outAddress, outNumber, outPeers } from '../../format/output'; +import { outAddress, outHistogram, outNumber, outPeers } from '../../format/output'; export default class Ethcore { constructor (transport) { @@ -69,6 +69,12 @@ export default class Ethcore { .then(outNumber); } + gasPriceHistogram () { + return this._transport + .execute('ethcore_gasPriceHistogram') + .then(outHistogram); + } + generateSecretPhrase () { return this._transport .execute('ethcore_generateSecretPhrase'); @@ -85,6 +91,11 @@ export default class Ethcore { .then(outNumber); } + mode () { + return this._transport + .execute('ethcore_mode'); + } + netChain () { return this._transport .execute('ethcore_netChain'); @@ -155,6 +166,11 @@ export default class Ethcore { .execute('ethcore_setMinGasPrice', inNumber16(quantity)); } + setMode (mode) { + return this._transport + .execute('ethcore_setMode', mode); + } + setTransactionsLimit (quantity) { return this._transport .execute('ethcore_setTransactionsLimit', inNumber16(quantity)); diff --git a/js/src/contracts/dappreg.js b/js/src/contracts/dappreg.js index ef07e95c5..5272f6561 100644 --- a/js/src/contracts/dappreg.js +++ b/js/src/contracts/dappreg.js @@ -14,22 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - export default class DappReg { constructor (api, registry) { this._api = api; @@ -69,4 +53,8 @@ export default class DappReg { getImage (id) { return this.meta(id, 'IMG'); } + + getContent (id) { + return this.meta(id, 'CONTENT'); + } } diff --git a/js/src/dapps/basiccoin.html b/js/src/dapps/basiccoin.html index 315a10818..52bc8bc57 100644 --- a/js/src/dapps/basiccoin.html +++ b/js/src/dapps/basiccoin.html @@ -4,7 +4,7 @@ - + Basic Token Deployment diff --git a/js/src/dapps/gavcoin.html b/js/src/dapps/gavcoin.html deleted file mode 100644 index 3b260bce1..000000000 --- a/js/src/dapps/gavcoin.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - GAVcoin - - -
- - - - - - diff --git a/js/src/dapps/gavcoin.js b/js/src/dapps/gavcoin.js deleted file mode 100644 index fae095ef2..000000000 --- a/js/src/dapps/gavcoin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import ReactDOM from 'react-dom'; -import React from 'react'; - -import injectTapEventPlugin from 'react-tap-event-plugin'; -injectTapEventPlugin(); - -import Application from './gavcoin/Application'; - -import '../../assets/fonts/Roboto/font.css'; -import '../../assets/fonts/RobotoMono/font.css'; -import './style.css'; -import './gavcoin.html'; - -ReactDOM.render( - , - document.querySelector('#container') -); diff --git a/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.css b/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.css deleted file mode 100644 index 3b7457cb7..000000000 --- a/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.css +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.account { - padding: 4px 0 !important; - display: inline-block; -} - -.name { - display: inline-block; - margin-right: 1em; - text-transform: uppercase; -} - -.balance { - display: inline-block; - text-align: right; - color: #aaa; - font-family: 'Roboto Mono', monospace; -} - -.details { - display: inline-block; -} - -.image { - display: inline-block; -} - -.image img { - margin: 0 1em -11px 0; -} diff --git a/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.js b/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.js deleted file mode 100644 index 1a55e7f93..000000000 --- a/js/src/dapps/gavcoin/AccountSelector/AccountItem/accountItem.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import IdentityIcon from '../../IdentityIcon'; - -import styles from './accountItem.css'; - -export default class AccountItem extends Component { - static propTypes = { - account: PropTypes.object, - gavBalance: PropTypes.bool - }; - - render () { - const { account, gavBalance } = this.props; - - let balance; - let token; - - if (gavBalance) { - if (account.gavBalance) { - balance = account.gavBalance; - token = 'GAV'; - } - } else { - if (account.ethBalance) { - balance = account.ethBalance; - token = 'ETH'; - } - } - - return ( -
-
- -
-
-
- { account.name || account.address } -
-
- { balance } { token } -
-
-
- ); - } -} diff --git a/js/src/dapps/gavcoin/AccountSelector/AccountItem/index.js b/js/src/dapps/gavcoin/AccountSelector/AccountItem/index.js deleted file mode 100644 index 570b3415a..000000000 --- a/js/src/dapps/gavcoin/AccountSelector/AccountItem/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './accountItem'; diff --git a/js/src/dapps/gavcoin/AccountSelector/accountSelector.js b/js/src/dapps/gavcoin/AccountSelector/accountSelector.js deleted file mode 100644 index e37d23598..000000000 --- a/js/src/dapps/gavcoin/AccountSelector/accountSelector.js +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; -import React, { Component, PropTypes } from 'react'; -import { MenuItem, SelectField } from 'material-ui'; - -import AccountItem from './AccountItem'; - -const NAME_ID = ' '; -let lastSelectedAccount = {}; - -export default class AccountSelect extends Component { - static propTypes = { - accounts: PropTypes.array, - account: PropTypes.object, - anyAccount: PropTypes.bool, - gavBalance: PropTypes.bool, - onSelect: PropTypes.func, - errorText: PropTypes.string, - floatingLabelText: PropTypes.string, - hintText: PropTypes.string - } - - componentDidMount () { - this.props.onSelect(lastSelectedAccount); - } - - render () { - const { account, accounts, anyAccount, errorText, floatingLabelText, gavBalance, hintText } = this.props; - - return ( - - { renderAccounts(accounts, { anyAccount, gavBalance }) } - - ); - } - - onSelect = (event, idx, account) => { - lastSelectedAccount = account || {}; - this.props.onSelect(lastSelectedAccount); - } -} - -function isPositive (numberStr) { - return new BigNumber(numberStr.replace(',', '')).gt(0); -} - -export function renderAccounts (accounts, options = {}) { - return accounts - .filter((account) => { - if (options.anyAccount) { - return true; - } - - if (account.uuid) { - return isPositive(account[options.gavBalance ? 'gavBalance' : 'ethBalance']); - } - - return false; - }) - .map((account) => { - const item = ( - - ); - - return ( - - { item } - - ); - }); -} diff --git a/js/src/dapps/gavcoin/AccountSelector/index.js b/js/src/dapps/gavcoin/AccountSelector/index.js deleted file mode 100644 index de529244a..000000000 --- a/js/src/dapps/gavcoin/AccountSelector/index.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import { renderAccounts } from './accountSelector'; - -export default from './accountSelector'; -export { - renderAccounts -}; diff --git a/js/src/dapps/gavcoin/AccountSelectorText/accountSelectorText.js b/js/src/dapps/gavcoin/AccountSelectorText/accountSelectorText.js deleted file mode 100644 index a83b0ec87..000000000 --- a/js/src/dapps/gavcoin/AccountSelectorText/accountSelectorText.js +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import { TextField } from 'material-ui'; - -import IdentityIcon from '../IdentityIcon'; -import AccountSelector from '../AccountSelector'; - -import styles from './accountSelectorText.css'; - -const NAME_ID = ' '; - -export default class AccountSelectorText extends Component { - static propTypes = { - accounts: PropTypes.array, - account: PropTypes.object, - errorText: PropTypes.string, - gavBalance: PropTypes.bool, - anyAccount: PropTypes.bool, - floatingLabelText: PropTypes.string, - hintText: PropTypes.string, - selector: PropTypes.bool, - onChange: PropTypes.func - } - - render () { - const { selector } = this.props; - - return selector - ? this.renderDropDown() - : this.renderTextField(); - } - - renderDropDown () { - const { account, accounts, anyAccount, errorText, gavBalance, hintText, floatingLabelText, onChange } = this.props; - - return ( - - ); - } - - renderTextField () { - const { account, errorText, hintText, floatingLabelText } = this.props; - - return ( -
- - { this.renderAddressIcon() } -
- ); - } - - renderAddressIcon () { - const { account } = this.props; - - if (!account.address) { - return null; - } - - return ( -
- -
- ); - } - - onChangeAddress = (event, address) => { - const lower = address.toLowerCase(); - const account = this.props.accounts.find((_account) => _account.address.toLowerCase() === lower); - - this.props.onChange(account || { address }); - } -} diff --git a/js/src/dapps/gavcoin/AccountSelectorText/index.js b/js/src/dapps/gavcoin/AccountSelectorText/index.js deleted file mode 100644 index c3aab3e52..000000000 --- a/js/src/dapps/gavcoin/AccountSelectorText/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './accountSelectorText'; diff --git a/js/src/dapps/gavcoin/Accounts/accounts.css b/js/src/dapps/gavcoin/Accounts/accounts.css deleted file mode 100644 index a7fdcee73..000000000 --- a/js/src/dapps/gavcoin/Accounts/accounts.css +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.accounts { - padding: 4em 2em 0 2em; - text-align: center; - width: 100%; -} - -.account { - margin: 0.5em !important; - background: #430 !important; - display: inline-block !important; -} - -.account img { - margin-bottom: -11px; - margin-left: -11px; -} - -.balance { - font-family: 'Roboto Mono', monospace; - color: rgba(255, 255, 255, 1) !important; -} - -.name { - color: rgba(255, 255, 255, 0.7) !important; - margin-right: 1em; - text-transform: uppercase; -} - -.none { - color: rgba(255, 255, 255, 0.7); -} diff --git a/js/src/dapps/gavcoin/Accounts/accounts.js b/js/src/dapps/gavcoin/Accounts/accounts.js deleted file mode 100644 index f510193ac..000000000 --- a/js/src/dapps/gavcoin/Accounts/accounts.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import { Chip } from 'material-ui'; - -import IdentityIcon from '../IdentityIcon'; - -import styles from './accounts.css'; - -export default class Accounts extends Component { - static contextTypes = { - api: PropTypes.object.isRequired, - instance: PropTypes.object.isRequired - } - - static propTypes = { - accounts: PropTypes.array - } - - render () { - const has = this._hasAccounts(); - - return ( -
- { has ? this.renderAccounts() : this.renderEmpty() } -
- ); - } - - renderEmpty () { - return ( -
- You currently do not have any GAVcoin in any of your addresses, buy some -
- ); - } - - renderAccounts () { - const { accounts } = this.props; - - return accounts - .filter((account) => account.hasGav) - .map((account) => { - return ( - - - - { account.name } - - - { account.gavBalance } - - - ); - }); - } - - _hasAccounts () { - const { accounts } = this.props; - - if (!accounts || !accounts.length) { - return false; - } - - return accounts.filter((account) => account.hasGav).length !== 0; - } -} diff --git a/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js b/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js deleted file mode 100644 index fe67c3739..000000000 --- a/js/src/dapps/gavcoin/Actions/ActionBuyIn/actionBuyIn.js +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; -import React, { Component, PropTypes } from 'react'; - -import { Dialog, FlatButton, TextField } from 'material-ui'; - -import { api } from '../../parity'; -import AccountSelector from '../../AccountSelector'; -import { ERRORS, validateAccount, validatePositiveNumber } from '../validation'; - -import styles from '../actions.css'; - -const NAME_ID = ' '; - -export default class ActionBuyIn extends Component { - static contextTypes = { - instance: PropTypes.object.isRequired - } - - static propTypes = { - accounts: PropTypes.array, - price: PropTypes.object, - onClose: PropTypes.func - } - - state = { - account: {}, - accountError: ERRORS.invalidAccount, - amount: 0, - amountError: ERRORS.invalidAmount, - maxPrice: api.util.fromWei(this.props.price.mul(1.2)).toFixed(0), - maxPriceError: null, - sending: false, - complete: false - } - - render () { - const { complete } = this.state; - - if (complete) { - return null; - } - - return ( - - { this.renderFields() } - - ); - } - - renderActions () { - const { complete } = this.state; - - if (complete) { - return ( - - ); - } - - const { accountError, amountError, maxPriceError, sending } = this.state; - const hasError = !!(amountError || accountError || maxPriceError); - - return ([ - , - - ]); - } - - renderFields () { - const maxPriceLabel = `maximum price in ETH (current ${api.util.fromWei(this.props.price).toFormat(3)})`; - - return ( -
- - - -
- ); - } - - onChangeAddress = (account) => { - this.setState({ - account, - accountError: validateAccount(account) - }, this.validateTotal); - } - - onChangeAmount = (event, amount) => { - this.setState({ - amount, - amountError: validatePositiveNumber(amount) - }, this.validateTotal); - } - - onChangeMaxPrice = (event, maxPrice) => { - this.setState({ - maxPrice, - maxPriceError: validatePositiveNumber(maxPrice) - }); - } - - validateTotal = () => { - const { account, accountError, amount, amountError } = this.state; - - if (accountError || amountError) { - return; - } - - if (new BigNumber(amount).gt(account.ethBalance.replace(',', ''))) { - this.setState({ - amountError: ERRORS.invalidTotal - }); - } - } - - onSend = () => { - const { instance } = this.context; - const maxPrice = api.util.toWei(this.state.maxPrice); - const values = [this.state.account.address, maxPrice.toString()]; - const options = { - from: this.state.account.address, - value: api.util.toWei(this.state.amount).toString() - }; - - this.setState({ - sending: true - }); - - instance.buyin - .estimateGas(options, values) - .then((gasEstimate) => { - options.gas = gasEstimate.mul(1.2).toFixed(0); - console.log(`buyin: gas estimated as ${gasEstimate.toFixed(0)} setting to ${options.gas}`); - - return instance.buyin.postTransaction(options, values); - }) - .then(() => { - this.props.onClose(); - this.setState({ - sending: false, - complete: true - }); - }) - .catch((error) => { - console.error('error', error); - this.setState({ - sending: false - }); - }); - } -} diff --git a/js/src/dapps/gavcoin/Actions/ActionBuyIn/index.js b/js/src/dapps/gavcoin/Actions/ActionBuyIn/index.js deleted file mode 100644 index 2c0c2374f..000000000 --- a/js/src/dapps/gavcoin/Actions/ActionBuyIn/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './actionBuyIn'; diff --git a/js/src/dapps/gavcoin/Actions/ActionRefund/actionRefund.js b/js/src/dapps/gavcoin/Actions/ActionRefund/actionRefund.js deleted file mode 100644 index 77944f7c4..000000000 --- a/js/src/dapps/gavcoin/Actions/ActionRefund/actionRefund.js +++ /dev/null @@ -1,194 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; -import React, { Component, PropTypes } from 'react'; - -import { Dialog, FlatButton, TextField } from 'material-ui'; - -import { api } from '../../parity'; -import AccountSelector from '../../AccountSelector'; -import { ERRORS, validateAccount, validatePositiveNumber } from '../validation'; - -import styles from '../actions.css'; - -const DIVISOR = 10 ** 6; -const NAME_ID = ' '; - -export default class ActionRefund extends Component { - static contextTypes = { - instance: PropTypes.object.isRequired - } - - static propTypes = { - accounts: PropTypes.array, - price: PropTypes.object, - onClose: PropTypes.func - } - - state = { - account: {}, - accountError: ERRORS.invalidAccount, - complete: false, - sending: false, - amount: 0, - amountError: ERRORS.invalidAmount, - price: api.util.fromWei(this.props.price).toString(), - priceError: null - } - - render () { - const { complete } = this.state; - - if (complete) { - return null; - } - - return ( - - { this.renderFields() } - - ); - } - - renderActions () { - if (this.state.complete) { - return ( - - ); - } - - const hasError = !!(this.state.priceError || this.state.amountError || this.state.accountError); - - return ([ - , - - ]); - } - - renderFields () { - const priceLabel = `price in ETH (current ${api.util.fromWei(this.props.price).toFormat(3)})`; - - return ( -
- - - -
- ); - } - - onChangeAddress = (account) => { - this.setState({ - account, - accountError: validateAccount(account) - }); - } - - onChangeAmount = (event, amount) => { - this.setState({ - amount, - amountError: validatePositiveNumber(amount) - }); - } - - onChangePrice = (event, price) => { - this.setState({ - price, - priceError: validatePositiveNumber(price) - }); - } - - onSend = () => { - const { instance } = this.context; - const price = api.util.toWei(this.state.price); - const amount = new BigNumber(this.state.amount).mul(DIVISOR); - const values = [price.toString(), amount.toFixed(0)]; - const options = { - from: this.state.account.address - }; - - this.setState({ - sending: true - }); - - instance.refund - .estimateGas(options, values) - .then((gasEstimate) => { - options.gas = gasEstimate.mul(1.2).toFixed(0); - console.log(`refund: gas estimated as ${gasEstimate.toFixed(0)} setting to ${options.gas}`); - - return instance.refund.postTransaction(options, values); - }) - .then(() => { - this.props.onClose(); - this.setState({ - sending: false, - complete: true - }); - }) - .catch((error) => { - console.error('error', error); - this.setState({ - sending: false - }); - }); - } -} diff --git a/js/src/dapps/gavcoin/Actions/ActionTransfer/actionTransfer.js b/js/src/dapps/gavcoin/Actions/ActionTransfer/actionTransfer.js deleted file mode 100644 index 787993ae0..000000000 --- a/js/src/dapps/gavcoin/Actions/ActionTransfer/actionTransfer.js +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; -import React, { Component, PropTypes } from 'react'; - -import { Dialog, FlatButton, TextField, Toggle } from 'material-ui'; - -import AccountSelector from '../../AccountSelector'; -import AccountSelectorText from '../../AccountSelectorText'; -import { ERRORS, validateAccount, validatePositiveNumber } from '../validation'; - -import styles from '../actions.css'; - -const DIVISOR = 10 ** 6; -const NAME_ID = ' '; - -export default class ActionTransfer extends Component { - static contextTypes = { - instance: PropTypes.object.isRequired - } - - static propTypes = { - accounts: PropTypes.array, - price: PropTypes.object, - onClose: PropTypes.func - } - - state = { - fromAccount: {}, - fromAccountError: ERRORS.invalidAccount, - toAccount: {}, - toAccountError: ERRORS.invalidRecipient, - inputAccount: false, - complete: false, - sending: false, - amount: 0, - amountError: ERRORS.invalidAmount - } - - render () { - const { complete } = this.state; - - if (complete) { - return null; - } - - return ( - - { this.renderFields() } - - ); - } - - renderActions () { - const { complete, sending, amountError, fromAccountError, toAccountError } = this.state; - - if (complete) { - return ( - - ); - } - - const hasError = !!(amountError || fromAccountError || toAccountError); - - return ([ - , - - ]); - } - - renderFields () { - const { accounts } = this.props; - const { fromAccount, fromAccountError, toAccount, toAccountError, inputAccount, amount, amountError } = this.state; - - return ( -
- -
- - -
- -
- ); - } - - onChangeFromAccount = (fromAccount) => { - this.setState({ - fromAccount, - fromAccountError: validateAccount(fromAccount) - }, this.validateTotal); - } - - onChangeToAccount = (toAccount) => { - this.setState({ - toAccount, - toAccountError: validateAccount(toAccount) - }); - } - - onChangeToInput = () => { - this.setState({ - inputAccount: !this.state.inputAccount - }); - } - - onChangeAmount = (event, amount) => { - this.setState({ - amount, - amountError: validatePositiveNumber(amount) - }, this.validateTotal); - } - - validateTotal = () => { - const { fromAccount, fromAccountError, amount, amountError } = this.state; - - if (fromAccountError || amountError) { - return; - } - - if (new BigNumber(amount).gt(fromAccount.gavBalance.replace(',', ''))) { - this.setState({ - amountError: ERRORS.invalidTotal - }); - } - } - - onSend = () => { - const { instance } = this.context; - const amount = new BigNumber(this.state.amount).mul(DIVISOR); - const values = [this.state.toAccount.address, amount.toFixed(0)]; - const options = { - from: this.state.fromAccount.address - }; - - this.setState({ - sending: true - }); - - instance.transfer - .estimateGas(options, values) - .then((gasEstimate) => { - options.gas = gasEstimate.mul(1.2).toFixed(0); - console.log(`transfer: gas estimated as ${gasEstimate.toFixed(0)} setting to ${options.gas}`); - - return instance.transfer.postTransaction(options, values); - }) - .then(() => { - this.props.onClose(); - this.setState({ - sending: false, - complete: true - }); - }) - .catch((error) => { - console.error('error', error); - this.setState({ - sending: false - }); - }); - } -} diff --git a/js/src/dapps/gavcoin/Actions/ActionTransfer/index.js b/js/src/dapps/gavcoin/Actions/ActionTransfer/index.js deleted file mode 100644 index 848800e00..000000000 --- a/js/src/dapps/gavcoin/Actions/ActionTransfer/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './actionTransfer'; diff --git a/js/src/dapps/gavcoin/Actions/StepComplete/index.js b/js/src/dapps/gavcoin/Actions/StepComplete/index.js deleted file mode 100644 index 7b95b1937..000000000 --- a/js/src/dapps/gavcoin/Actions/StepComplete/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './stepComplete'; diff --git a/js/src/dapps/gavcoin/Actions/StepComplete/stepComplete.js b/js/src/dapps/gavcoin/Actions/StepComplete/stepComplete.js deleted file mode 100644 index a066a7c30..000000000 --- a/js/src/dapps/gavcoin/Actions/StepComplete/stepComplete.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component } from 'react'; - -import styles from '../actions.css'; - -export default class StepComplete extends Component { - render () { - return ( -
- Your transaction has been posted. Please visit the Parity Signer to authenticate the transfer. -
- ); - } -} diff --git a/js/src/dapps/gavcoin/Actions/actions.css b/js/src/dapps/gavcoin/Actions/actions.css deleted file mode 100644 index 0549a6dc1..000000000 --- a/js/src/dapps/gavcoin/Actions/actions.css +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.actions { - text-align: center; - padding: 2em 0 0 0; - width: 100%; -} - -.button { - margin: 0 0.5em; -} - -.button button { - background-color: #430 !important; - height: 56px !important; - padding: 0 10px !important; -} - -.button button[disabled] { - opacity: 0.25; -} - -.dlgbtn { -} - -.dlgbtn span { - color: #430 !important; -} - -.dlgbtn[disabled] { - opacity: 0.25; -} - -.dialog { -} - -.dialog h3 { - color: #430 !important; - text-transform: uppercase; -} - -.dialogtext { - padding-top: 1em; -} - -.link, .link:hover, .link:visited { - color: rgb(0, 188, 212); - text-decoration: none; -} - -.overlay { - position: relative; -} - -.overlay svg { - opacity: 0; -} - -.toggle { - text-align: right; -} - -.overlaytoggle { - position: absolute !important; - top: 40px; - right: 0; - display: inline-block !important; - width: auto !important; -} diff --git a/js/src/dapps/gavcoin/Actions/actions.js b/js/src/dapps/gavcoin/Actions/actions.js deleted file mode 100644 index e58d2223f..000000000 --- a/js/src/dapps/gavcoin/Actions/actions.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import { RaisedButton } from 'material-ui'; -import ActionAddShoppingCart from 'material-ui/svg-icons/action/add-shopping-cart'; -// import AvReplay from 'material-ui/svg-icons/av/replay'; -import ContentSend from 'material-ui/svg-icons/content/send'; - -import styles from './actions.css'; - -export default class Actions extends Component { - static propTypes = { - onAction: PropTypes.func.isRequired, - gavBalance: PropTypes.object.isRequired - } - - render () { - const { gavBalance } = this.props; - - return ( -
- } - label='buy coins' - primary - onTouchTap={ this.onBuyIn } /> - } - label='send coins' - primary - onTouchTap={ this.onTransfer } /> -
- ); - - // } - // label='claim refund' - // primary - // onTouchTap={ this.onRefund } /> - } - - onBuyIn = () => { - this.props.onAction('BuyIn'); - } - - onTransfer = () => { - const { gavBalance } = this.props; - - if (gavBalance && gavBalance.gt(0)) { - this.props.onAction('Transfer'); - } - } - - onRefund = () => { - this.props.onAction('Refund'); - } -} diff --git a/js/src/dapps/gavcoin/Actions/index.js b/js/src/dapps/gavcoin/Actions/index.js deleted file mode 100644 index 865bd65ce..000000000 --- a/js/src/dapps/gavcoin/Actions/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import ActionBuyIn from './ActionBuyIn'; -import ActionRefund from './ActionRefund'; -import ActionTransfer from './ActionTransfer'; - -export default from './actions'; - -export { - ActionBuyIn, - ActionRefund, - ActionTransfer -}; diff --git a/js/src/dapps/gavcoin/Actions/validation.js b/js/src/dapps/gavcoin/Actions/validation.js deleted file mode 100644 index d494c3392..000000000 --- a/js/src/dapps/gavcoin/Actions/validation.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; - -import { api } from '../parity'; - -export const ERRORS = { - invalidAccount: 'please select an account to transact with', - invalidRecipient: 'please select an account to send to', - invalidAddress: 'the address is not in the correct format', - invalidAmount: 'please enter a positive amount > 0', - invalidTotal: 'the amount is greater than the availale balance' -}; - -export function validatePositiveNumber (value) { - let bn = null; - - try { - bn = new BigNumber(value); - } catch (e) { - } - - if (!bn || !bn.gt(0)) { - return ERRORS.invalidAmount; - } - - return null; -} - -export function validateAccount (account) { - if (!account || !account.address) { - return ERRORS.invalidAccount; - } - - if (!api.util.isAddressValid(account.address)) { - return ERRORS.invalidAddress; - } - - account.address = api.util.toChecksumAddress(account.address); - - return null; -} diff --git a/js/src/dapps/gavcoin/Application/application.js b/js/src/dapps/gavcoin/Application/application.js deleted file mode 100644 index c5eda9db8..000000000 --- a/js/src/dapps/gavcoin/Application/application.js +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; -import React, { Component, PropTypes } from 'react'; - -import getMuiTheme from 'material-ui/styles/getMuiTheme'; -import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'; - -const muiTheme = getMuiTheme(lightBaseTheme); - -import { api } from '../parity'; - -import * as abis from '../../../contracts/abi'; - -import Accounts from '../Accounts'; -import Actions, { ActionBuyIn, ActionRefund, ActionTransfer } from '../Actions'; -import Events from '../Events'; -import Loading from '../Loading'; -import Status from '../Status'; - -import styles from './application.css'; -import bgimage from '../../../../assets/images/dapps/gavcoin-bg.jpg'; - -const bgstyle = { - backgroundImage: `url(${bgimage})` -}; - -const DIVISOR = 10 ** 6; - -export default class Application extends Component { - static childContextTypes = { - api: PropTypes.object, - contract: PropTypes.object, - instance: PropTypes.object, - muiTheme: PropTypes.object - }; - - state = { - action: null, - address: null, - accounts: [], - accountsInfo: {}, - blockNumber: new BigNumber(-1), - ethBalance: new BigNumber(0), - gavBalance: new BigNumber(0), - instance: null, - loading: true, - price: null, - remaining: null, - totalSupply: null - } - - componentDidMount () { - this.attachInterface(); - } - - render () { - const { accounts, accountsInfo, address, blockNumber, gavBalance, loading, price, remaining, totalSupply } = this.state; - - if (loading) { - return ( - - ); - } - - return ( -
- { this.renderModals() } - - - - - -
- ); - } - - renderModals () { - const { action, accounts, price } = this.state; - - switch (action) { - case 'BuyIn': - return ( - - ); - case 'Refund': - return ( - - ); - case 'Transfer': - return ( - - ); - default: - return null; - } - } - - getChildContext () { - const { contract, instance } = this.state; - - return { - api, - contract, - instance, - muiTheme - }; - } - - onAction = (action) => { - this.setState({ - action - }); - } - - onActionClose = () => { - this.setState({ - action: null - }); - } - - onNewBlockNumber = (_error, blockNumber) => { - const { instance, accounts } = this.state; - - if (_error) { - console.error('onNewBlockNumber', _error); - return; - } - - Promise - .all([ - instance.totalSupply.call(), - instance.remaining.call(), - instance.price.call() - ]) - .then(([totalSupply, remaining, price]) => { - this.setState({ - blockNumber, - totalSupply, - remaining, - price - }); - - const gavQueries = accounts.map((account) => instance.balanceOf.call({}, [account.address])); - const ethQueries = accounts.map((account) => api.eth.getBalance(account.address)); - - return Promise.all([ - Promise.all(gavQueries), - Promise.all(ethQueries) - ]); - }) - .then(([gavBalances, ethBalances]) => { - this.setState({ - ethBalance: ethBalances.reduce((total, balance) => total.add(balance), new BigNumber(0)), - gavBalance: gavBalances.reduce((total, balance) => total.add(balance), new BigNumber(0)), - accounts: accounts.map((account, idx) => { - const ethBalance = ethBalances[idx]; - const gavBalance = gavBalances[idx]; - - account.ethBalance = api.util.fromWei(ethBalance).toFormat(3); - account.gavBalance = gavBalance.div(DIVISOR).toFormat(6); - account.hasGav = gavBalance.gt(0); - - return account; - }) - }); - }) - .catch((error) => { - console.error('onNewBlockNumber', error); - }); - } - - attachInterface = () => { - api.ethcore - .registryAddress() - .then((registryAddress) => { - console.log(`the registry was found at ${registryAddress}`); - - const registry = api.newContract(abis.registry, registryAddress).instance; - - return Promise - .all([ - registry.getAddress.call({}, [api.util.sha3('gavcoin'), 'A']), - api.eth.accounts(), - api.personal.accountsInfo() - ]); - }) - .then(([address, addresses, accountsInfo]) => { - accountsInfo = accountsInfo || {}; - console.log(`gavcoin was found at ${address}`); - - const contract = api.newContract(abis.gavcoin, address); - - this.setState({ - loading: false, - address, - contract, - accountsInfo, - instance: contract.instance, - accounts: addresses.map((address) => { - const info = accountsInfo[address] || {}; - - return { - address, - name: info.name, - uuid: info.uuid - }; - }) - }); - - api.subscribe('eth_blockNumber', this.onNewBlockNumber); - }) - .catch((error) => { - console.error('attachInterface', error); - }); - } -} diff --git a/js/src/dapps/gavcoin/Events/Event/event.js b/js/src/dapps/gavcoin/Events/Event/event.js deleted file mode 100644 index c068454f0..000000000 --- a/js/src/dapps/gavcoin/Events/Event/event.js +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import moment from 'moment'; -import React, { Component, PropTypes } from 'react'; - -import IdentityIcon from '../../IdentityIcon'; -import { formatCoins, formatEth, formatHash } from '../../format'; - -import styles from '../events.css'; - -const EMPTY_COLUMN = ( - -); - -export default class Event extends Component { - static contextTypes = { - accountsInfo: PropTypes.object.isRequired, - api: PropTypes.object.isRequired - } - - static propTypes = { - event: PropTypes.object, - value: PropTypes.object, - price: PropTypes.object, - fromAddress: PropTypes.string, - toAddress: PropTypes.string - } - - state = { - block: null - } - - componentDidMount () { - this.loadBlock(); - } - - render () { - const { event, fromAddress, toAddress, price, value } = this.props; - const { block } = this.state; - const { state, type } = event; - const cls = `${styles.event} ${styles[state]} ${styles[type.toLowerCase()]}`; - - return ( - - { this.renderTimestamp(block) } - { this.renderType(type) } - { this.renderValue(value) } - { this.renderPrice(price) } - { this.renderAddress(fromAddress) } - { this.renderAddress(toAddress) } - - ); - } - - renderTimestamp (block) { - return ( - - { !block ? ' ' : moment(block.timestamp).fromNow() } - - ); - } - - renderAddress (address) { - if (!address) { - return EMPTY_COLUMN; - } - - return ( - - - { this.renderAddressName(address) } - - ); - } - - renderAddressName (address) { - const { accountsInfo } = this.context; - const account = accountsInfo[address]; - - if (account && account.name) { - return ( -
- { account.name } -
- ); - } - - return ( -
- { formatHash(address) } -
- ); - } - - renderPrice (price) { - if (!price) { - return EMPTY_COLUMN; - } - - return ( - - { formatEth(price) } ETH - - ); - } - - renderValue (value) { - if (!value) { - return EMPTY_COLUMN; - } - - return ( - - { formatCoins(value) } GAV - - ); - } - - renderType (type) { - return ( - - { type } - - ); - } - - 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/EventBuyin/eventBuyin.js b/js/src/dapps/gavcoin/Events/EventBuyin/eventBuyin.js deleted file mode 100644 index 571da1bef..000000000 --- a/js/src/dapps/gavcoin/Events/EventBuyin/eventBuyin.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import Event from '../Event'; - -export default class EventBuyin extends Component { - static propTypes = { - event: PropTypes.object - } - - render () { - const { event } = this.props; - const { buyer, price, amount } = event.params; - - return ( - - ); - } -} diff --git a/js/src/dapps/gavcoin/Events/EventBuyin/index.js b/js/src/dapps/gavcoin/Events/EventBuyin/index.js deleted file mode 100644 index 77edc578a..000000000 --- a/js/src/dapps/gavcoin/Events/EventBuyin/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './eventBuyin'; diff --git a/js/src/dapps/gavcoin/Events/EventNewTranch/eventNewTranch.js b/js/src/dapps/gavcoin/Events/EventNewTranch/eventNewTranch.js deleted file mode 100644 index 16fa05351..000000000 --- a/js/src/dapps/gavcoin/Events/EventNewTranch/eventNewTranch.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import Event from '../Event'; - -export default class EventNewTranch extends Component { - static propTypes = { - event: PropTypes.object - } - - render () { - const { event } = this.props; - const { price } = event.params; - - return ( - - ); - } -} diff --git a/js/src/dapps/gavcoin/Events/EventNewTranch/index.js b/js/src/dapps/gavcoin/Events/EventNewTranch/index.js deleted file mode 100644 index 46d1d2df6..000000000 --- a/js/src/dapps/gavcoin/Events/EventNewTranch/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './eventNewTranch'; diff --git a/js/src/dapps/gavcoin/Events/EventRefund/eventRefund.js b/js/src/dapps/gavcoin/Events/EventRefund/eventRefund.js deleted file mode 100644 index 5c4ed6562..000000000 --- a/js/src/dapps/gavcoin/Events/EventRefund/eventRefund.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import Event from '../Event'; - -export default class EventRefund extends Component { - static propTypes = { - event: PropTypes.object - } - - render () { - const { event } = this.props; - const { buyer, price, amount } = event.params; - - return ( - - ); - } -} diff --git a/js/src/dapps/gavcoin/Events/EventRefund/index.js b/js/src/dapps/gavcoin/Events/EventRefund/index.js deleted file mode 100644 index bac0f20dc..000000000 --- a/js/src/dapps/gavcoin/Events/EventRefund/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './eventRefund'; diff --git a/js/src/dapps/gavcoin/Events/EventTransfer/index.js b/js/src/dapps/gavcoin/Events/EventTransfer/index.js deleted file mode 100644 index a75b45a0a..000000000 --- a/js/src/dapps/gavcoin/Events/EventTransfer/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './eventTransfer'; diff --git a/js/src/dapps/gavcoin/Events/events.css b/js/src/dapps/gavcoin/Events/events.css deleted file mode 100644 index cf9184744..000000000 --- a/js/src/dapps/gavcoin/Events/events.css +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.events { - padding: 4em 2em; - text-align: center; -} - -.list { - margin: 0 auto; - border: none; - border-spacing: 0; - text-align: left; -} - -.list td { - vertical-align: top; - padding: 0.25em 1em; - max-height: 1.5em; -} - -.event { - line-height: 32px; - vertical-align: top; -} - -.blocknumber, -.ethvalue, -.gavvalue { -} - -.blocknumber, -.gavvalue { - text-align: right; -} - -.ethvalue { - text-align: center; -} - -.type { -} - -.account { -} - -.account img { - margin-bottom: -11px; -} - -.address { -} - -.name { - text-transform: uppercase; -} - -.event div { - display: inline; - margin-right: 1em; - vertical-align: top; -} - -.mined { -} - -.pending { - opacity: 0.5; -} - -.buyin { -} - -.refund { -} - -.transfer { -} - -.newtranch { - background: rgba(255, 175, 0, 0.125); /*rgba(68, 51, 0, 0.15);*/ -} diff --git a/js/src/dapps/gavcoin/Events/events.js b/js/src/dapps/gavcoin/Events/events.js deleted file mode 100644 index 97dac30bb..000000000 --- a/js/src/dapps/gavcoin/Events/events.js +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import { api } from '../parity'; - -import EventBuyin from './EventBuyin'; -import EventNewTranch from './EventNewTranch'; -import EventRefund from './EventRefund'; -import EventTransfer from './EventTransfer'; - -import styles from './events.css'; - -export default class Events extends Component { - static childContextTypes = { - accountsInfo: PropTypes.object - } - - static contextTypes = { - contract: PropTypes.object.isRequired, - instance: PropTypes.object.isRequired - } - - static propTypes = { - accountsInfo: PropTypes.object.isRequired - } - - state = { - allEvents: [], - minedEvents: [], - pendingEvents: [] - } - - componentDidMount () { - this.setupFilters(); - } - - render () { - return ( -
- - - { this.renderEvents() } - -
-
- ); - } - - renderEvents () { - const { allEvents } = this.state; - - if (!allEvents.length) { - return null; - } - - return allEvents - .map((event) => { - switch (event.type) { - case 'Buyin': - return ; - case 'NewTranch': - return ; - case 'Refund': - return ; - case 'Transfer': - return ; - } - }); - } - - getChildContext () { - const { accountsInfo } = this.props; - - return { accountsInfo }; - } - - setupFilters () { - const { contract } = this.context; - - const sortEvents = (a, b) => b.blockNumber.cmp(a.blockNumber) || b.logIndex.cmp(a.logIndex); - const logToEvent = (log) => { - const key = api.util.sha3(JSON.stringify(log)); - const { blockNumber, logIndex, transactionHash, transactionIndex, params, type } = log; - - return { - type: log.event, - state: type, - blockNumber, - logIndex, - transactionHash, - transactionIndex, - params: Object.keys(params).reduce((data, name) => { - data[name] = params[name].value; - return data; - }, {}), - key - }; - }; - - const options = { - fromBlock: 0, - toBlock: 'pending', - limit: 50 - }; - - contract.subscribe(null, options, (error, _logs) => { - if (error) { - console.error('setupFilters', error); - return; - } - - if (!_logs.length) { - return; - } - - const logs = _logs.map(logToEvent); - - const minedEvents = logs - .filter((log) => log.state === 'mined') - .reverse() - .concat(this.state.minedEvents) - .sort(sortEvents); - const pendingEvents = logs - .filter((log) => log.state === 'pending') - .reverse() - .concat(this.state.pendingEvents.filter((event) => { - return !logs.find((log) => { - const isMined = (log.state === 'mined') && (log.transactionHash === event.transactionHash); - const isPending = (log.state === 'pending') && (log.key === event.key); - - return isMined || isPending; - }); - })) - .sort(sortEvents); - const allEvents = pendingEvents.concat(minedEvents); - - this.setState({ - allEvents, - minedEvents, - pendingEvents - }); - }); - } -} diff --git a/js/src/dapps/gavcoin/Events/index.js b/js/src/dapps/gavcoin/Events/index.js deleted file mode 100644 index 88ad6d407..000000000 --- a/js/src/dapps/gavcoin/Events/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './events'; diff --git a/js/src/dapps/gavcoin/IdentityIcon/identityIcon.js b/js/src/dapps/gavcoin/IdentityIcon/identityIcon.js deleted file mode 100644 index 51f48d46a..000000000 --- a/js/src/dapps/gavcoin/IdentityIcon/identityIcon.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import { api } from '../parity'; -import styles from './identityIcon.css'; - -export default class IdentityIcon extends Component { - static propTypes = { - address: PropTypes.string.isRequired - } - - render () { - const { address } = this.props; - - return ( - - ); - } -} diff --git a/js/src/dapps/gavcoin/IdentityIcon/index.js b/js/src/dapps/gavcoin/IdentityIcon/index.js deleted file mode 100644 index 76c107bfb..000000000 --- a/js/src/dapps/gavcoin/IdentityIcon/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './identityIcon'; diff --git a/js/src/dapps/gavcoin/Loading/index.js b/js/src/dapps/gavcoin/Loading/index.js deleted file mode 100644 index 0468cab37..000000000 --- a/js/src/dapps/gavcoin/Loading/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './loading'; diff --git a/js/src/dapps/gavcoin/Loading/loading.js b/js/src/dapps/gavcoin/Loading/loading.js deleted file mode 100644 index 78aaa8828..000000000 --- a/js/src/dapps/gavcoin/Loading/loading.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component } from 'react'; - -import { CircularProgress } from 'material-ui'; - -import styles from './loading.css'; - -export default class Loading extends Component { - render () { - return ( -
- -
- ); - } -} diff --git a/js/src/dapps/gavcoin/Status/index.js b/js/src/dapps/gavcoin/Status/index.js deleted file mode 100644 index 44079b224..000000000 --- a/js/src/dapps/gavcoin/Status/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './status'; diff --git a/js/src/dapps/gavcoin/Status/status.css b/js/src/dapps/gavcoin/Status/status.css deleted file mode 100644 index bb1587148..000000000 --- a/js/src/dapps/gavcoin/Status/status.css +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ -.status { - background: rgba(255, 175, 0, 0.25); - color: #430; - padding: 4em 0 2em 0; - display: flex; - flex-wrap: wrap; -} - -.title { - margin-top: 0; - font-weight: 300; - font-size: 2.5rem; - text-transform: uppercase; -} - -.item { - flex: 0 1 30%; - width: 30%; - margin: 0 1.5%; - text-align: center; -} - -.byline { - font-size: 1.25em; - color: #430; - opacity: 0.75; -} - -.heading { - text-transform: uppercase; - letter-spacing: 0.25em; - font-size: 1.5em; - color: #430; - opacity: 0.75; -} - -.hero { - font-size: 4em; -} diff --git a/js/src/dapps/gavcoin/Status/status.js b/js/src/dapps/gavcoin/Status/status.js deleted file mode 100644 index 81dd0cb16..000000000 --- a/js/src/dapps/gavcoin/Status/status.js +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; - -import { formatBlockNumber, formatCoins, formatEth } from '../format'; - -import styles from './status.css'; - -export default class Status extends Component { - static propTypes = { - address: PropTypes.string, - gavBalance: PropTypes.object, - blockNumber: PropTypes.object, - totalSupply: PropTypes.object, - remaining: PropTypes.object, - price: PropTypes.object, - children: PropTypes.node - } - - render () { - const { blockNumber, gavBalance, totalSupply, remaining, price } = this.props; - - if (!totalSupply) { - return null; - } - - return ( -
-
-
 
-
- { formatCoins(remaining, -1) } -
-
- available for { formatEth(price) }ETH -
-
-
-
GAVcoin
-
- { formatCoins(totalSupply, -1) } -
-
- total at { formatBlockNumber(blockNumber) } -
-
-
-
 
-
- { formatCoins(gavBalance, -1) } -
-
- coin balance -
-
- { this.props.children } -
- ); - } -} diff --git a/js/src/dapps/gavcoin/format/index.js b/js/src/dapps/gavcoin/format/index.js deleted file mode 100644 index ee554bb60..000000000 --- a/js/src/dapps/gavcoin/format/index.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import BigNumber from 'bignumber.js'; - -import { api } from '../parity'; - -const DIVISOR = 10 ** 6; -const ZERO = new BigNumber(0); - -export function formatBlockNumber (blockNumber) { - return ZERO.eq(blockNumber || 0) - ? 'Pending' - : `#${blockNumber.toFormat()}`; -} - -export function formatCoins (amount, decimals = 6) { - const adjusted = amount.div(DIVISOR); - - if (decimals === -1) { - if (adjusted.gte(10000)) { - decimals = 0; - } else if (adjusted.gte(1000)) { - decimals = 1; - } else if (adjusted.gte(100)) { - decimals = 2; - } else if (adjusted.gte(10)) { - decimals = 3; - } else { - decimals = 4; - } - } - - return adjusted.toFormat(decimals); -} - -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/gavcoin/parity.js b/js/src/dapps/gavcoin/parity.js deleted file mode 100644 index f6d59f44d..000000000 --- a/js/src/dapps/gavcoin/parity.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -const { api } = window.parity; - -export { - api -}; diff --git a/js/src/dapps/githubhint.html b/js/src/dapps/githubhint.html index 4689fd7d9..631182fcb 100644 --- a/js/src/dapps/githubhint.html +++ b/js/src/dapps/githubhint.html @@ -4,7 +4,7 @@ - + GitHub Hint diff --git a/js/src/dapps/githubhint/Application/application.css b/js/src/dapps/githubhint/Application/application.css index aa4a68dc6..d149d883d 100644 --- a/js/src/dapps/githubhint/Application/application.css +++ b/js/src/dapps/githubhint/Application/application.css @@ -108,14 +108,19 @@ background: #fcc; } -.hashError { +.hashError, .hashWarning, .hashOk { padding-top: 0.5em; - color: #f66; text-align: center; } -.hashOk { - padding-top: 0.5em; - opacity: 0.5; - text-align: center; +.hashError { + color: #f66; +} + +.hashWarning { + color: #f80; +} + +.hashOk { + opacity: 0.5; } diff --git a/js/src/dapps/githubhint/Application/application.js b/js/src/dapps/githubhint/Application/application.js index 8eb3902d3..3c4ecfda8 100644 --- a/js/src/dapps/githubhint/Application/application.js +++ b/js/src/dapps/githubhint/Application/application.js @@ -29,11 +29,13 @@ const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; export default class Application extends Component { state = { + fromAddress: null, loading: true, url: '', urlError: null, contentHash: '', contentHashError: null, + contentHashOwner: null, registerBusy: false, registerError: null, registerState: '' @@ -63,7 +65,14 @@ export default class Application extends Component { } renderPage () { - const { registerBusy, url, urlError, contentHash, contentHashError } = this.state; + const { fromAddress, registerBusy, url, urlError, contentHash, contentHashError, contentHashOwner } = this.state; + + let hashClass = null; + if (contentHashError) { + hashClass = contentHashOwner !== fromAddress ? styles.hashError : styles.hashWarning; + } else { + hashClass = styles.hashOk; + } return (
@@ -81,7 +90,7 @@ export default class Application extends Component { className={ urlError ? styles.error : null } onChange={ this.onChangeUrl } />
-
+
{ contentHashError || contentHash }
{ registerBusy ? this.renderProgress() : this.renderButtons() } @@ -92,7 +101,7 @@ export default class Application extends Component { } renderButtons () { - const { accounts, fromAddress, url, urlError, contentHashError } = this.state; + const { accounts, fromAddress, url, urlError, contentHashError, contentHashOwner } = this.state; const account = accounts[fromAddress]; return ( @@ -105,7 +114,7 @@ export default class Application extends Component {
+ disabled={ (!!contentHashError && contentHashOwner !== fromAddress) || !!urlError || url.length === 0 }>register url ); } @@ -163,9 +172,9 @@ export default class Application extends Component { } onClickRegister = () => { - const { url, urlError, contentHash, contentHashError, fromAddress, instance } = this.state; + const { url, urlError, contentHash, contentHashError, contentHashOwner, fromAddress, instance } = this.state; - if (!!contentHashError || !!urlError || url.length === 0) { + if ((!!contentHashError && contentHashOwner !== fromAddress) || !!urlError || url.length === 0) { return; } @@ -243,13 +252,17 @@ export default class Application extends Component { instance.entries .call({}, [contentHash]) - .then(([accountSlashRepo, commit, owner]) => { - console.log('lookupHash', accountSlashRepo, api.util.bytesToHex(commit), owner); + .then(([accountSlashRepo, commit, contentHashOwner]) => { + console.log('lookupHash', accountSlashRepo, api.util.bytesToHex(commit), contentHashOwner); - if (owner !== ZERO_ADDRESS) { - this.setState({ contentHashError: contentHash, contentHash: null }); + if (contentHashOwner !== ZERO_ADDRESS) { + this.setState({ + contentHashError: contentHash, + contentHashOwner, + contentHash + }); } else { - this.setState({ contentHashError: null, contentHash }); + this.setState({ contentHashError: null, contentHashOwner, contentHash }); } }); }) diff --git a/js/src/dapps/registry.html b/js/src/dapps/registry.html index 512932a0a..ab399d1e3 100644 --- a/js/src/dapps/registry.html +++ b/js/src/dapps/registry.html @@ -4,7 +4,7 @@ - + Token Registry diff --git a/js/src/dapps/registry/Accounts/accounts.js b/js/src/dapps/registry/Accounts/accounts.js index fe262a84f..e8d8c2bd2 100644 --- a/js/src/dapps/registry/Accounts/accounts.js +++ b/js/src/dapps/registry/Accounts/accounts.js @@ -36,6 +36,8 @@ export default class Accounts extends Component { render () { const { all, selected } = this.props; + const origin = { horizontal: 'right', vertical: 'top' }; + const accountsButton = ( { selected @@ -49,7 +51,9 @@ export default class Accounts extends Component { value={ selected ? this.renderAccount(selected) : null } onChange={ this.onAccountSelect } iconButtonElement={ accountsButton } - animated={ false } + + anchorOrigin={ origin } + targetOrigin={ origin } > { Object.values(all).map(this.renderAccount) } diff --git a/js/src/dapps/registry/Application/application.css b/js/src/dapps/registry/Application/application.css index c5a54040e..ebdb23baa 100644 --- a/js/src/dapps/registry/Application/application.css +++ b/js/src/dapps/registry/Application/application.css @@ -37,3 +37,15 @@ font-size: 80%; background-color: #f0f0f0; } + +.actions { + margin: 1em; + + * { + font-size: 1.3rem !important; + } + + > * { + padding-bottom: 0 !important; + } +} diff --git a/js/src/dapps/registry/Application/application.js b/js/src/dapps/registry/Application/application.js index d0c4bd2f7..e763069a5 100644 --- a/js/src/dapps/registry/Application/application.js +++ b/js/src/dapps/registry/Application/application.js @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . - import React, { Component, PropTypes } from 'react'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; @@ -21,6 +20,7 @@ import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'; const muiTheme = getMuiTheme(lightBaseTheme); import CircularProgress from 'material-ui/CircularProgress'; +import { Card, CardText } from 'material-ui/Card'; import styles from './application.css'; import Accounts from '../Accounts'; import Events from '../Events'; @@ -35,6 +35,7 @@ export default class Application extends Component { muiTheme: PropTypes.object.isRequired, api: PropTypes.object.isRequired }; + getChildContext () { return { muiTheme, api: window.parity.api }; } @@ -57,9 +58,7 @@ export default class Application extends Component { accounts, contacts, contract, fee, lookup, - events, - names, - records + events } = this.props; return ( @@ -71,8 +70,9 @@ export default class Application extends Component { { contract && fee ? (
- - + + { this.renderActions() } +

The Registry is provided by the contract at { contract.address }. @@ -85,4 +85,34 @@ export default class Application extends Component { ); } + renderActions () { + const { + actions, + accounts, + fee, + names, + records + } = this.props; + + const hasAccount = !!accounts.selected; + + if (!hasAccount) { + return ( + + + Please select a valid account in order + to execute actions. + + + ); + } + + return ( +

+ + +
+ ); + } + } diff --git a/js/src/dapps/registry/Events/events.js b/js/src/dapps/registry/Events/events.js index 10280ae52..cb433068f 100644 --- a/js/src/dapps/registry/Events/events.js +++ b/js/src/dapps/registry/Events/events.js @@ -93,6 +93,37 @@ export default class Events extends Component { render () { const { subscriptions, pending, accounts, contacts } = this.props; + + const eventsObject = this.props.events + .filter((e) => eventTypes[e.type]) + .reduce((eventsObject, event) => { + const txHash = event.transaction; + + if ( + (eventsObject[txHash] && eventsObject[txHash].state === 'pending') || + !eventsObject[txHash] + ) { + eventsObject[txHash] = event; + } + + return eventsObject; + }, {}); + + const events = Object + .values(eventsObject) + .sort((evA, evB) => { + if (evA.state === 'pending') { + return -1; + } + + if (evB.state === 'pending') { + return 1; + } + + return evB.timestamp - evA.timestamp; + }) + .map((e) => eventTypes[e.type](e, accounts, contacts)); + return ( @@ -122,11 +153,7 @@ export default class Events extends Component { - { - this.props.events - .filter((e) => eventTypes[e.type]) - .map((e) => eventTypes[e.type](e, accounts, contacts)) - } + { events }
diff --git a/js/src/dapps/registry/Names/names.js b/js/src/dapps/registry/Names/names.js index 907e3bf87..dd7e6f772 100644 --- a/js/src/dapps/registry/Names/names.js +++ b/js/src/dapps/registry/Names/names.js @@ -29,12 +29,19 @@ import styles from './names.css'; const useSignerText = (

Use the Signer to authenticate the following changes.

); const renderNames = (names) => { - const out = []; - for (let name of names) { - out.push(({ name }), ', '); - } - out.pop(); - return out; + const values = Object.values(names); + + return values + .map((name, index) => ( + + { name } + { + index < values.length - 1 + ? (, ) + : null + } + + )); }; const renderQueue = (queue) => { @@ -70,7 +77,6 @@ export default class Names extends Component { static propTypes = { actions: PropTypes.object.isRequired, fee: PropTypes.object.isRequired, - hasAccount: PropTypes.bool.isRequired, pending: PropTypes.bool.isRequired, queue: PropTypes.array.isRequired } @@ -82,20 +88,18 @@ export default class Names extends Component { render () { const { action, name } = this.state; - const { fee, hasAccount, pending, queue } = this.props; + const { fee, pending, queue } = this.props; return ( - { !hasAccount - ? (

Please select an account first.

) - : (action === 'reserve' - ? (

- The fee to reserve a name is { fromWei(fee).toFixed(3) }ETH. -

) - : (

To drop a name, you have to be the owner.

) - ) + { (action === 'reserve' + ? (

+ The fee to reserve a name is { fromWei(fee).toFixed(3) }ETH. +

) + : (

To drop a name, you have to be the owner.

) + ) } @@ -111,7 +115,7 @@ export default class Names extends Component { . const initialState = { - hasAccount: false, pending: false, queue: [] }; export default (state = initialState, action) => { - if (action.type === 'accounts select') { - return { ...state, hasAccount: !!action.address }; - } - if (action.type === 'names reserve start') { return { ...state, pending: true }; } diff --git a/js/src/dapps/registry/Records/records.js b/js/src/dapps/registry/Records/records.js index 355522e60..60640893c 100644 --- a/js/src/dapps/registry/Records/records.js +++ b/js/src/dapps/registry/Records/records.js @@ -11,7 +11,6 @@ export default class Records extends Component { static propTypes = { actions: PropTypes.object.isRequired, - hasAccount: PropTypes.bool.isRequired, pending: PropTypes.bool.isRequired, name: PropTypes.string.isRequired, type: PropTypes.string.isRequired, @@ -21,7 +20,7 @@ export default class Records extends Component { state = { name: '', type: 'A', value: '' }; render () { - const { hasAccount, pending } = this.props; + const { pending } = this.props; const name = this.state.name || this.props.name; const type = this.state.type || this.props.type; const value = this.state.value || this.props.value; @@ -30,10 +29,10 @@ export default class Records extends Component { - { !hasAccount - ? (

Please select an account first.

) - : (

You can only modify entries of names that you previously registered.

) - } +

+ You can only modify entries of names that you previously registered. +

+ { - if (action.type === 'accounts select') { - return { ...state, hasAccount: !!action.address }; - } - if (action.type === 'records update start') { return { ...state, @@ -17,7 +12,7 @@ export default (state = initialState, action) => { }; } - if (action.type === 'records update error' && action.type === 'records update success') { + if (action.type === 'records update error' || action.type === 'records update success') { return { ...state, pending: false, diff --git a/js/src/dapps/signaturereg.html b/js/src/dapps/signaturereg.html index 3929b425c..d050fe803 100644 --- a/js/src/dapps/signaturereg.html +++ b/js/src/dapps/signaturereg.html @@ -4,7 +4,7 @@ - + Method Signature Registry diff --git a/js/src/dapps/tokenreg.html b/js/src/dapps/tokenreg.html index 8510aa817..d16d4082c 100644 --- a/js/src/dapps/tokenreg.html +++ b/js/src/dapps/tokenreg.html @@ -4,7 +4,7 @@ - + Token Registry diff --git a/js/src/dev.parity.html b/js/src/dev.parity.html index c2eb392d3..9cfe5ac18 100644 --- a/js/src/dev.parity.html +++ b/js/src/dev.parity.html @@ -4,7 +4,7 @@ - + dev::Parity.js diff --git a/js/src/dev.web3.html b/js/src/dev.web3.html index ced98fca7..93faba8e5 100644 --- a/js/src/dev.web3.html +++ b/js/src/dev.web3.html @@ -4,7 +4,7 @@ - + dev::Web3 diff --git a/js/src/images/dapps/blocks-350.png b/js/src/images/dapps/blocks-350.png deleted file mode 100644 index 16e0c213d..000000000 Binary files a/js/src/images/dapps/blocks-350.png and /dev/null differ diff --git a/js/src/index.html b/js/src/index.html index 397a827d0..780013432 100644 --- a/js/src/index.html +++ b/js/src/index.html @@ -4,7 +4,7 @@ - + Parity