Merge branch 'master' into auth-bft

This commit is contained in:
keorn 2016-11-30 13:06:21 +00:00
commit 155da50fcd
195 changed files with 2555 additions and 1623 deletions

View File

@ -8,7 +8,6 @@ variables:
RUST_BACKTRACE: "1"
RUSTFLAGS: ""
CARGOFLAGS: ""
NIGHTLY: "nigtly"
cache:
key: "$CI_BUILD_STAGE/$CI_BUILD_REF_NAME"
untracked: true
@ -232,9 +231,9 @@ linux-armv6:
stage: build
image: ethcore/rust-armv6:latest
only:
- beta
- tags
- stable
# - beta
# - tags
# - stable
- triggers
script:
- export CC=arm-linux-gnueabi-gcc
@ -305,41 +304,6 @@ linux-aarch64:
- target/aarch64-unknown-linux-gnu/release/parity
name: "aarch64-unknown-linux-gnu_parity"
allow_failure: true
#linux-alpine:
# stage: build
# image: ethcore/rust-alpine:latest
# only:
# - beta
# - tags
# - stable
# - triggers
# script:
# - export HOST_CC=gcc
# - export HOST_CXX=g++
# - cargo build --release $CARGOFLAGS
# - strip target/release/parity
# - md5sum target/release/parity > parity.md5
# - sh scripts/deb-build.sh arm64
# - cp target/aarch64-unknown-linux-gnu/release/parity deb/usr/bin/parity
# - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
# - dpkg-deb -b deb "parity_"$VER"_arm64.deb"
# - md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5"
# - aws configure set aws_access_key_id $s3_key
# - aws configure set aws_secret_access_key $s3_secret
# - if [[ $CI_BUILD_REF_NAME =~ ^(master|beta|stable)$ ]]; then export S3_BUCKET=builds-parity-published; else export S3_BUCKET=builds-parity; fi
# - aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu
# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity --body target/aarch64-unknown-linux-gnu/release/parity
# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/parity.md5 --body parity.md5
# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb" --body "parity_"$VER"_arm64.deb"
# - aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/aarch64-unknown-linux-gnu/"parity_"$VER"_arm64.deb.md5" --body "parity_"$VER"_arm64.deb.md5"
# tags:
# - rust
# - rust-alpine
# artifacts:
# paths:
# - target/aarch64-unknown-linux-gnu/release/parity
# name: "aarch64-unknown-linux-gnu_parity"
# allow_failure: true
darwin:
stage: build
only:

28
Cargo.lock generated
View File

@ -3,7 +3,7 @@ name = "parity"
version = "1.5.0"
dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
@ -146,15 +146,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "clippy"
version = "0.0.96"
version = "0.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"clippy_lints 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clippy_lints"
version = "0.0.96"
version = "0.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -224,7 +224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "elastic-array"
version = "0.6.0"
source = "git+https://github.com/ethcore/elastic-array#70e4012e691b732c7c4cb04e9232799e6aa268bc"
source = "git+https://github.com/ethcore/elastic-array#346f1ba5982576dab9d0b8fa178b50e1db0a21cd"
dependencies = [
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -280,7 +280,7 @@ dependencies = [
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.4.0",
@ -333,7 +333,7 @@ dependencies = [
name = "ethcore-dapps"
version = "1.5.0"
dependencies = [
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-devtools 1.4.0",
"ethcore-hash-fetch 1.5.0",
@ -490,7 +490,7 @@ dependencies = [
name = "ethcore-rpc"
version = "1.5.0"
dependencies = [
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.4.0",
"ethcore 1.5.0",
"ethcore-devtools 1.4.0",
@ -520,7 +520,7 @@ dependencies = [
name = "ethcore-signer"
version = "1.5.0"
dependencies = [
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-devtools 1.4.0",
"ethcore-io 1.5.0",
@ -559,7 +559,7 @@ version = "1.5.0"
dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.6.0 (git+https://github.com/ethcore/elastic-array)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"eth-secp256k1 0.5.4 (git+https://github.com/ethcore/rust-secp256k1)",
@ -649,7 +649,7 @@ dependencies = [
name = "ethsync"
version = "1.5.0"
dependencies = [
"clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.5.0",
"ethcore-io 1.5.0",
@ -1263,7 +1263,7 @@ dependencies = [
[[package]]
name = "parity-ui-precompiled"
version = "1.4.0"
source = "git+https://github.com/ethcore/js-precompiled.git#7cb42b0c636f76eb478c9270a1e507ac3c3ba434"
source = "git+https://github.com/ethcore/js-precompiled.git#da35604af4259da3abd7a12a4c4925906c78f746"
dependencies = [
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -2005,8 +2005,8 @@ dependencies = [
"checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27"
"checksum bytes 0.4.0-dev (git+https://github.com/carllerche/bytes)" = "<none>"
"checksum cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de1e760d7b6535af4241fca8bd8adf68e2e7edacc6b29f5d399050c5e48cf88c"
"checksum clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)" = "6eacf01b0aad84a0817703498f72d252df7c0faf6a5b86d0be4265f1829e459f"
"checksum clippy_lints 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)" = "a49960c9aab544ce86b004dcb61620e8b898fea5fc0f697a028f460f48221ed6"
"checksum clippy 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "5b4fabf979ddf6419a313c1c0ada4a5b95cfd2049c56e8418d622d27b4b6ff32"
"checksum clippy_lints 0.0.103 (registry+https://github.com/rust-lang/crates.io-index)" = "ce96ec05bfe018a0d5d43da115e54850ea2217981ff0f2e462780ab9d594651a"
"checksum cookie 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90266f45846f14a1e986c77d1e9c2626b8c342ed806fe60241ec38cc8697b245"
"checksum crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fb974f835e90390c5f9dfac00f05b06dc117299f5ea4e85fbc7bb443af4911cc"
"checksum ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)" = "<none>"

View File

@ -47,7 +47,7 @@ ethcore-hash-fetch = { path = "ethcore/hash-fetch" }
rlp = { path = "util/rlp" }
ethcore-stratum = { path = "stratum" }
ethcore-dapps = { path = "dapps", optional = true }
clippy = { version = "0.0.96", optional = true}
clippy = { version = "0.0.103", optional = true}
[target.'cfg(windows)'.dependencies]
winapi = "0.2"

View File

@ -34,7 +34,7 @@ ethcore-hash-fetch = { path = "../ethcore/hash-fetch" }
fetch = { path = "../util/fetch" }
parity-ui = { path = "./ui" }
clippy = { version = "0.0.96", optional = true}
clippy = { version = "0.0.103", optional = true}
[build-dependencies]
serde_codegen = { version = "0.8", optional = true }

View File

@ -17,6 +17,7 @@
use endpoint::EndpointInfo;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct App {
pub id: String,
pub name: String,
@ -54,6 +55,7 @@ impl Into<EndpointInfo> for App {
}
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct ApiError {
pub code: String,
pub title: String,

View File

@ -11,7 +11,7 @@ build = "build.rs"
ethcore-ipc-codegen = { path = "../ipc/codegen" }
[dependencies]
clippy = { version = "0.0.96", optional = true}
clippy = { version = "0.0.103", optional = true}
ethcore-devtools = { path = "../devtools" }
ethcore-ipc = { path = "../ipc/rpc" }
rocksdb = { git = "https://github.com/ethcore/rust-rocksdb" }

View File

@ -3,6 +3,7 @@ WORKDIR /build
# install tools and dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
g++ \
curl \
git \

View File

@ -4,6 +4,7 @@ WORKDIR /build
RUN apt-get update && \
apt-get install -y \
g++ \
build-essential \
curl \
git \
file \

View File

@ -29,7 +29,7 @@ byteorder = "0.5"
transient-hashmap = "0.1"
linked-hash-map = "0.3.0"
evmjit = { path = "../evmjit", optional = true }
clippy = { version = "0.0.96", optional = true}
clippy = { version = "0.0.103", optional = true}
ethash = { path = "../ethash" }
ethcore-util = { path = "../util" }
ethcore-io = { path = "../util/io" }

View File

@ -121,10 +121,6 @@ impl<'db> HashDB for AccountDB<'db>{
fn remove(&mut self, _key: &H256) {
unimplemented!()
}
fn get_aux(&self, hash: &[u8]) -> Option<DBValue> {
self.db.get_aux(hash)
}
}
/// DB backend wrapper for Account trie
@ -197,18 +193,6 @@ impl<'db> HashDB for AccountDBMut<'db>{
let key = combine_key(&self.address_hash, key);
self.db.remove(&key)
}
fn insert_aux(&mut self, hash: Vec<u8>, value: Vec<u8>) {
self.db.insert_aux(hash, value);
}
fn get_aux(&self, hash: &[u8]) -> Option<DBValue> {
self.db.get_aux(hash)
}
fn remove_aux(&mut self, hash: &[u8]) {
self.db.remove_aux(hash);
}
}
struct Wrapping<'db>(&'db HashDB);

View File

@ -594,9 +594,9 @@ mod tests {
use factory::Factories;
use state_db::StateDB;
use views::BlockView;
use util::Address;
use util::{Address, TrieFactory};
use util::hash::FixedHash;
use util::trie::TrieSpec;
use std::sync::Arc;
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
@ -637,7 +637,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock();
@ -653,7 +653,7 @@ mod tests {
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap()
.close_and_lock().seal(engine, vec![]).unwrap();
@ -662,7 +662,7 @@ mod tests {
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let e = enact_and_seal(&orig_bytes, engine, false, db, &genesis_header, last_hashes, Default::default()).unwrap();
assert_eq!(e.rlp_bytes(), orig_bytes);
@ -681,7 +681,7 @@ mod tests {
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut uncle1_header = Header::new();
@ -697,7 +697,7 @@ mod tests {
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let e = enact_and_seal(&orig_bytes, engine, false, db, &genesis_header, last_hashes, Default::default()).unwrap();
let bytes = e.rlp_bytes();

View File

@ -22,7 +22,7 @@ use std::time::{Instant};
use time::precise_time_ns;
// util
use util::{Bytes, PerfTimer, Itertools, Mutex, RwLock};
use util::{Bytes, PerfTimer, Itertools, Mutex, RwLock, Hashable};
use util::{journaldb, TrieFactory, Trie};
use util::{U256, H256, Address, H2048, Uint, FixedHash};
use util::trie::TrieSpec;
@ -172,9 +172,10 @@ impl Client {
false => TrieSpec::Secure,
};
let trie_factory = TrieFactory::new(trie_spec);
let journal_db = journaldb::new(db.clone(), config.pruning, ::db::COL_STATE);
let mut state_db = StateDB::new(journal_db, config.state_cache_size);
if state_db.journal_db().is_empty() && try!(spec.ensure_db_good(&mut state_db)) {
if state_db.journal_db().is_empty() && try!(spec.ensure_db_good(&mut state_db, &trie_factory)) {
let mut batch = DBTransaction::new(&db);
try!(state_db.journal_under(&mut batch, 0, &spec.genesis_header().hash()));
try!(db.write(batch).map_err(ClientError::Database));
@ -216,7 +217,7 @@ impl Client {
let factories = Factories {
vm: EvmFactory::new(config.vm_type.clone(), config.jump_table_size),
trie: TrieFactory::new(trie_spec),
trie: trie_factory,
accountdb: Default::default(),
};
@ -888,8 +889,8 @@ impl BlockChainClient for Client {
}
fn keep_alive(&self) {
let should_wake = match &*self.mode.lock() {
&Mode::Dark(..) | &Mode::Passive(..) => true,
let should_wake = match *self.mode.lock() {
Mode::Dark(..) | Mode::Passive(..) => true,
_ => false,
};
if should_wake {
@ -971,6 +972,10 @@ impl BlockChainClient for Client {
self.state_at(id).map(|s| s.nonce(address))
}
fn storage_root(&self, address: &Address, id: BlockID) -> Option<H256> {
self.state_at(id).and_then(|s| s.storage_root(address))
}
fn block_hash(&self, id: BlockID) -> Option<H256> {
let chain = self.chain.read();
Self::block_hash(&chain, id)
@ -988,7 +993,7 @@ impl BlockChainClient for Client {
self.state_at(id).map(|s| s.storage_at(address, position))
}
fn list_accounts(&self, id: BlockID) -> Option<Vec<Address>> {
fn list_accounts(&self, id: BlockID, after: Option<&Address>, count: u64) -> Option<Vec<Address>> {
if !self.factories.trie.is_fat() {
trace!(target: "fatdb", "list_accounts: Not a fat DB");
return None;
@ -1008,18 +1013,68 @@ impl BlockChainClient for Client {
}
};
let iter = match trie.iter() {
let mut iter = match trie.iter() {
Ok(iter) => iter,
_ => return None,
};
if let Some(after) = after {
if let Err(e) = iter.seek(after) {
trace!(target: "fatdb", "list_accounts: Couldn't seek the DB: {:?}", e);
}
}
let accounts = iter.filter_map(|item| {
item.ok().map(|(addr, _)| Address::from_slice(&addr))
}).collect();
}).take(count as usize).collect();
Some(accounts)
}
fn list_storage(&self, id: BlockID, account: &Address, after: Option<&H256>, count: u64) -> Option<Vec<H256>> {
if !self.factories.trie.is_fat() {
trace!(target: "fatdb", "list_stroage: Not a fat DB");
return None;
}
let state = match self.state_at(id) {
Some(state) => state,
_ => return None,
};
let root = match state.storage_root(account) {
Some(root) => root,
_ => return None,
};
let (_, db) = state.drop();
let account_db = self.factories.accountdb.readonly(db.as_hashdb(), account.sha3());
let trie = match self.factories.trie.readonly(account_db.as_hashdb(), &root) {
Ok(trie) => trie,
_ => {
trace!(target: "fatdb", "list_storage: Couldn't open the DB");
return None;
}
};
let mut iter = match trie.iter() {
Ok(iter) => iter,
_ => return None,
};
if let Some(after) = after {
if let Err(e) = iter.seek(after) {
trace!(target: "fatdb", "list_accounts: Couldn't seek the DB: {:?}", e);
}
}
let keys = iter.filter_map(|item| {
item.ok().map(|(key, _)| H256::from_slice(&key))
}).take(count as usize).collect();
Some(keys)
}
fn transaction(&self, id: TransactionID) -> Option<LocalizedTransaction> {
self.transaction_address(id).and_then(|address| self.chain.read().transaction(&address))
}

View File

@ -333,7 +333,7 @@ impl MiningBlockChainClient for TestBlockChainClient {
let genesis_header = self.spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
self.spec.ensure_db_good(&mut db).unwrap();
self.spec.ensure_db_good(&mut db, &TrieFactory::default()).unwrap();
let last_hashes = vec![genesis_header.hash()];
let mut open_block = OpenBlock::new(
@ -385,6 +385,10 @@ impl BlockChainClient for TestBlockChainClient {
}
}
fn storage_root(&self, _address: &Address, _id: BlockID) -> Option<H256> {
None
}
fn latest_nonce(&self, address: &Address) -> U256 {
self.nonce(address, BlockID::Latest).unwrap()
}
@ -416,10 +420,13 @@ impl BlockChainClient for TestBlockChainClient {
}
}
fn list_accounts(&self, _id: BlockID) -> Option<Vec<Address>> {
fn list_accounts(&self, _id: BlockID, _after: Option<&Address>, _count: u64) -> Option<Vec<Address>> {
None
}
fn list_storage(&self, _id: BlockID, _account: &Address, _after: Option<&H256>, _count: u64) -> Option<Vec<H256>> {
None
}
fn transaction(&self, _id: TransactionID) -> Option<LocalizedTransaction> {
None // Simple default.
}

View File

@ -68,6 +68,10 @@ pub trait BlockChainClient : Sync + Send {
/// May not fail on BlockID::Latest.
fn nonce(&self, address: &Address, id: BlockID) -> Option<U256>;
/// Attempt to get address storage root at given block.
/// May not fail on BlockID::Latest.
fn storage_root(&self, address: &Address, id: BlockID) -> Option<H256>;
/// Get address nonce at the latest block's state.
fn latest_nonce(&self, address: &Address) -> U256 {
self.nonce(address, BlockID::Latest)
@ -114,7 +118,12 @@ pub trait BlockChainClient : Sync + Send {
}
/// Get a list of all accounts in the block `id`, if fat DB is in operation, otherwise `None`.
fn list_accounts(&self, id: BlockID) -> Option<Vec<Address>>;
/// If `after` is set the list starts with the following item.
fn list_accounts(&self, id: BlockID, after: Option<&Address>, count: u64) -> Option<Vec<Address>>;
/// Get a list of all storage keys in the block `id`, if fat DB is in operation, otherwise `None`.
/// If `after` is set the list starts with the following item.
fn list_storage(&self, id: BlockID, account: &Address, after: Option<&H256>, count: u64) -> Option<Vec<H256>>;
/// Get transaction with given hash.
fn transaction(&self, id: TransactionID) -> Option<LocalizedTransaction>;

View File

@ -126,7 +126,7 @@ impl AuthorityRound {
}
fn step_proposer(&self, step: usize) -> &Address {
let ref p = self.our_params;
let p = &self.our_params;
p.authorities.get(step % p.authority_n).expect("There are authority_n authorities; taking number modulo authority_n gives number in authority_n range; qed")
}
@ -213,7 +213,7 @@ impl Engine for AuthorityRound {
fn on_close_block(&self, _block: &mut ExecutedBlock) {}
fn is_sealer(&self, author: &Address) -> Option<bool> {
let ref p = self.our_params;
let p = &self.our_params;
Some(p.authorities.contains(author))
}
@ -320,6 +320,7 @@ impl Engine for AuthorityRound {
#[cfg(test)]
mod tests {
use util::*;
use util::trie::TrieSpec;
use env_info::EnvInfo;
use header::Header;
use error::{Error, BlockError};
@ -390,9 +391,9 @@ mod tests {
engine.register_account_provider(Arc::new(tap));
let genesis_header = spec.genesis_header();
let mut db1 = get_temp_state_db().take();
spec.ensure_db_good(&mut db1).unwrap();
spec.ensure_db_good(&mut db1, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let mut db2 = get_temp_state_db().take();
spec.ensure_db_good(&mut db2).unwrap();
spec.ensure_db_good(&mut db2, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b1 = OpenBlock::new(engine, Default::default(), false, db1, &genesis_header, last_hashes.clone(), addr1, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b1 = b1.close_and_lock();

View File

@ -190,6 +190,7 @@ impl Engine for BasicAuthority {
#[cfg(test)]
mod tests {
use util::*;
use util::trie::TrieSpec;
use block::*;
use env_info::EnvInfo;
use error::{BlockError, Error};
@ -263,7 +264,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, addr, (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock();

View File

@ -67,6 +67,7 @@ impl Engine for InstantSeal {
#[cfg(test)]
mod tests {
use util::*;
use util::trie::TrieSpec;
use tests::helpers::*;
use spec::Spec;
use header::Header;
@ -79,7 +80,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::default(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close_and_lock();

View File

@ -435,6 +435,7 @@ impl Header {
#[cfg(test)]
mod tests {
use util::*;
use util::trie::TrieSpec;
use block::*;
use tests::helpers::*;
use env_info::EnvInfo;
@ -451,7 +452,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = b.close();
@ -465,7 +466,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let mut b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut uncle = Header::new();

View File

@ -72,6 +72,7 @@ pub fn new_morden() -> Spec { load(include_bytes!("../../res/ethereum/morden.jso
#[cfg(test)]
mod tests {
use util::*;
use util::trie::TrieSpec;
use state::*;
use super::*;
use tests::helpers::*;
@ -84,7 +85,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
spec.ensure_db_good(&mut db).unwrap();
spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let s = State::from_existing(db, genesis_header.state_root().clone(), engine.account_start_nonce(), Default::default()).unwrap();
assert_eq!(s.balance(&"0000000000000000000000000000000000000001".into()), 1u64.into());
assert_eq!(s.balance(&"0000000000000000000000000000000000000002".into()), 1u64.into());

View File

@ -197,19 +197,17 @@ impl<Gas: CostType> Gasometer<Gas> {
let address = u256_to_address(stack.peek(1));
let is_value_transfer = !stack.peek(2).is_zero();
if instruction == instructions::CALL {
if (
!schedule.no_empty && !ext.exists(&address)
) || (
schedule.no_empty && is_value_transfer && !ext.exists_and_not_null(&address)
if instruction == instructions::CALL && (
(!schedule.no_empty && !ext.exists(&address))
||
(schedule.no_empty && is_value_transfer && !ext.exists_and_not_null(&address))
) {
gas = overflowing!(gas.overflow_add(schedule.call_new_account_gas.into()));
}
};
if is_value_transfer {
gas = overflowing!(gas.overflow_add(schedule.call_value_transfer_gas.into()));
};
}
let requested = *stack.peek(0);
@ -347,7 +345,7 @@ fn test_mem_gas_cost() {
let result = gasometer.mem_gas_cost(&schedule, current_mem_size, &mem_size);
// then
if let Ok(_) = result {
if result.is_ok() {
assert!(false, "Should fail with OutOfGas");
}
}

View File

@ -103,7 +103,7 @@ impl Ext for FakeExt {
}
fn balance(&self, address: &Address) -> U256 {
*self.balances.get(address).unwrap()
self.balances[address]
}
fn blockhash(&self, number: &U256) -> H256 {

View File

@ -514,9 +514,11 @@ impl<'a> Executive<'a> {
#[cfg(test)]
#[allow(dead_code)]
mod tests {
use std::sync::Arc;
use ethkey::{Generator, Random};
use super::*;
use util::*;
use util::{H256, U256, U512, Address, Uint, FixedHash, FromHex, FromStr};
use util::bytes::BytesRef;
use action_params::{ActionParams, ActionValue};
use env_info::EnvInfo;
use evm::{Factory, VMType};

View File

@ -151,7 +151,7 @@ impl GasPriceCalibrator {
if Instant::now() >= self.next_calibration {
let usd_per_tx = self.options.usd_per_tx;
trace!(target: "miner", "Getting price info");
if let Ok(_) = PriceInfo::get(move |price: PriceInfo| {
let price_info = PriceInfo::get(move |price: PriceInfo| {
trace!(target: "miner", "Price info arrived: {:?}", price);
let usd_per_eth = price.ethusd;
let wei_per_usd: f32 = 1.0e18 / usd_per_eth;
@ -159,7 +159,9 @@ impl GasPriceCalibrator {
let wei_per_gas: f32 = wei_per_usd * usd_per_tx / gas_per_tx;
info!(target: "miner", "Updated conversion rate to Ξ1 = {} ({} wei/gas)", Colour::White.bold().paint(format!("US${}", usd_per_eth)), Colour::Yellow.bold().paint(format!("{}", wei_per_gas)));
set_price(U256::from(wei_per_gas as u64));
}) {
});
if price_info.is_ok() {
self.next_calibration = Instant::now() + self.options.recalibration_period;
} else {
warn!(target: "miner", "Unable to update Ether price.");
@ -1149,15 +1151,16 @@ impl MinerService for Miner {
#[cfg(test)]
mod tests {
use std::sync::Arc;
use std::time::Duration;
use super::super::{MinerService, PrioritizationStrategy};
use super::*;
use util::*;
use block::IsBlock;
use util::{U256, Uint, FromHex};
use ethkey::{Generator, Random};
use client::{BlockChainClient, TestBlockChainClient, EachBlockWith, TransactionImportResult};
use header::BlockNumber;
use types::transaction::{Transaction, SignedTransaction, Action};
use block::*;
use spec::Spec;
use tests::helpers::{generate_dummy_client};

View File

@ -990,7 +990,7 @@ impl TransactionQueue {
let mut update_last_nonce_to = None;
{
let by_nonce = self.future.by_address.row_mut(&address);
if let None = by_nonce {
if by_nonce.is_none() {
return;
}
let mut by_nonce = by_nonce.expect("None is tested in early-exit condition above; qed");
@ -1222,12 +1222,12 @@ mod test {
use util::table::*;
use util::*;
use ethkey::{Random, Generator};
use transaction::*;
use error::{Error, TransactionError};
use super::*;
use super::{TransactionSet, TransactionOrder, VerifiedTransaction};
use miner::local_transactions::LocalTransactionsList;
use client::TransactionImportResult;
use transaction::{SignedTransaction, Transaction, Action};
fn unwrap_tx_err(err: Result<TransactionImportResult, Error>) -> TransactionError {
match err.unwrap_err() {

View File

@ -64,13 +64,13 @@ impl PodAccount {
}
/// Place additional data into given hash DB.
pub fn insert_additional(&self, db: &mut AccountDBMut) {
pub fn insert_additional(&self, db: &mut AccountDBMut, factory: &TrieFactory) {
match self.code {
Some(ref c) if !c.is_empty() => { db.insert(c); }
_ => {}
}
let mut r = H256::new();
let mut t = SecTrieDBMut::new(db, &mut r);
let mut t = factory.create(db, &mut r);
for (k, v) in &self.storage {
if let Err(e) = t.insert(k, &rlp::encode(&U256::from(&**v))) {
warn!("Encountered potential DB corruption: {}", e);

View File

@ -552,11 +552,11 @@ const POW_VERIFY_RATE: f32 = 0.02;
pub fn verify_old_block(rng: &mut OsRng, header: &Header, engine: &Engine, chain: &BlockChain, body: Option<&[u8]>, always: bool) -> Result<(), ::error::Error> {
if always || rng.gen::<f32>() <= POW_VERIFY_RATE {
match chain.block_header(header.parent_hash()) {
Some(parent) => engine.verify_block_family(&header, &parent, body),
None => engine.verify_block_seal(&header),
Some(parent) => engine.verify_block_family(header, &parent, body),
None => engine.verify_block_seal(header),
}
} else {
engine.verify_block_basic(&header, body)
engine.verify_block_basic(header, body)
}
}

View File

@ -244,13 +244,13 @@ impl Spec {
}
/// Ensure that the given state DB has the trie nodes in for the genesis state.
pub fn ensure_db_good(&self, db: &mut StateDB) -> Result<bool, Box<TrieError>> {
pub fn ensure_db_good(&self, db: &mut StateDB, factory: &TrieFactory) -> Result<bool, Box<TrieError>> {
if !db.as_hashdb().contains(&self.state_root()) {
trace!(target: "spec", "ensure_db_good: Fresh database? Cannot find state root {}", self.state_root());
let mut root = H256::new();
{
let mut t = SecTrieDBMut::new(db.as_hashdb_mut(), &mut root);
let mut t = factory.create(db.as_hashdb_mut(), &mut root);
for (address, account) in self.genesis_state.get().iter() {
try!(t.insert(&**address, &account.rlp()));
}
@ -258,7 +258,7 @@ impl Spec {
trace!(target: "spec", "ensure_db_good: Populated sec trie; root is {}", root);
for (address, account) in self.genesis_state.get().iter() {
db.note_non_null_account(address);
account.insert_additional(&mut AccountDBMut::new(db.as_hashdb_mut(), address));
account.insert_additional(&mut AccountDBMut::new(db.as_hashdb_mut(), address), factory);
}
assert!(db.as_hashdb().contains(&self.state_root()));
Ok(true)

View File

@ -314,11 +314,10 @@ impl Account {
self.code_hash == SHA3_EMPTY
}
#[cfg(test)]
/// return the storage root associated with this account or None if it has been altered via the overlay.
/// Return the storage root associated with this account or None if it has been altered via the overlay.
pub fn storage_root(&self) -> Option<&H256> { if self.storage_is_clean() {Some(&self.storage_root)} else {None} }
/// return the storage overlay.
/// Return the storage overlay.
pub fn storage_changes(&self) -> &HashMap<H256, H256> { &self.storage_changes }
/// Increment the nonce of the account by one.
@ -445,11 +444,10 @@ impl fmt::Debug for Account {
#[cfg(test)]
mod tests {
use rlp::{UntrustedRlp, RlpType, View, Compressible};
use util::*;
use super::*;
use account_db::*;
use rlp::*;
#[test]
fn account_compress() {

View File

@ -369,6 +369,12 @@ impl State {
|a| a.as_ref().map_or(self.account_start_nonce, |account| *account.nonce()))
}
/// Get the storage root of account `a`.
pub fn storage_root(&self, a: &Address) -> Option<H256> {
self.ensure_cached(a, RequireCache::None, true,
|a| a.as_ref().and_then(|account| account.storage_root().cloned()))
}
/// Mutate storage of account `address` so that it is `value` for `key`.
pub fn storage_at(&self, address: &Address, key: &H256) -> H256 {
// Storage key search and update works like this:
@ -445,6 +451,7 @@ impl State {
}
/// Add `incr` to the balance of account `a`.
#[cfg_attr(feature="dev", allow(single_match))]
pub fn add_balance(&mut self, a: &Address, incr: &U256, cleanup_mode: CleanupMode) {
trace!(target: "state", "add_balance({}, {}): {}", a, incr, self.balance(a));
let is_value_transfer = !incr.is_zero();

View File

@ -57,6 +57,7 @@ impl Substate {
}
/// Get the cleanup mode object from this.
#[cfg_attr(feature="dev", allow(wrong_self_convention))]
pub fn to_cleanup_mode(&mut self, schedule: &Schedule) -> CleanupMode {
match (schedule.no_empty, schedule.kill_empty) {
(false, _) => CleanupMode::ForceCreate,

View File

@ -397,6 +397,7 @@ impl StateDB {
}
/// Get cached code based on hash.
#[cfg_attr(feature="dev", allow(map_clone))]
pub fn get_cached_code(&self, hash: &H256) -> Option<Arc<Vec<u8>>> {
let mut cache = self.code_cache.lock();

View File

@ -62,7 +62,7 @@ fn should_return_registrar() {
&db_config
).unwrap();
let params = client.additional_params();
let address = params.get("registrar").unwrap();
let address = &params["registrar"];
assert_eq!(address.len(), 40);
assert!(U256::from_str(address).is_ok());
@ -93,7 +93,7 @@ fn imports_good_block() {
&db_config
).unwrap();
let good_block = get_good_dummy_block();
if let Err(_) = client.import_block(good_block) {
if client.import_block(good_block).is_err() {
panic!("error importing block being good by definition");
}
client.flush_queue();
@ -203,18 +203,18 @@ fn can_collect_garbage() {
#[test]
fn can_generate_gas_price_median() {
let client_result = generate_dummy_client_with_data(3, 1, &vec_into![1, 2, 3]);
let client_result = generate_dummy_client_with_data(3, 1, slice_into![1, 2, 3]);
let client = client_result.reference();
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_result = generate_dummy_client_with_data(4, 1, slice_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_result = generate_dummy_client_with_data(20, 1, slice_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();
@ -224,7 +224,7 @@ fn can_generate_gas_price_histogram() {
#[test]
fn empty_gas_price_histogram() {
let client_result = generate_dummy_client_with_data(20, 0, &vec_into![]);
let client_result = generate_dummy_client_with_data(20, 0, slice_into![]);
let client = client_result.reference();
assert!(client.gas_price_histogram(20, 5).is_none());

View File

@ -18,6 +18,7 @@ use ethkey::KeyPair;
use io::*;
use client::{BlockChainClient, Client, ClientConfig};
use util::*;
use util::trie::TrieSpec;
use spec::*;
use state_db::StateDB;
use block::{OpenBlock, Drain};
@ -157,7 +158,7 @@ pub fn generate_dummy_client_with_spec_and_data<F>(get_test_spec: F, block_numbe
let mut db_result = get_temp_state_db();
let mut db = db_result.take();
test_spec.ensure_db_good(&mut db).unwrap();
test_spec.ensure_db_good(&mut db, &TrieFactory::new(TrieSpec::Secure)).unwrap();
let genesis_header = test_spec.genesis_header();
let mut rolling_timestamp = 40;
@ -262,7 +263,7 @@ pub fn get_test_client_with_blocks(blocks: Vec<Bytes>) -> GuardedTempResult<Arc<
).unwrap();
for block in &blocks {
if let Err(_) = client.import_block(block.clone()) {
if client.import_block(block.clone()).is_err() {
panic!("panic importing block which is well-formed");
}
}

View File

@ -19,16 +19,16 @@
pub use std::time::Duration;
use client::Mode as ClientMode;
/// IPC-capable shadow-type for client::config::Mode
/// IPC-capable shadow-type for `client::config::Mode`
#[derive(Clone, Binary, Debug)]
pub enum Mode {
/// Same as ClientMode::Off.
/// Same as `ClientMode::Off`.
Off,
/// Same as ClientMode::Dark; values in seconds.
/// Same as `ClientMode::Dark`; values in seconds.
Dark(u64),
/// Same as ClientMode::Passive; values in seconds.
/// Same as `ClientMode::Passive`; values in seconds.
Passive(u64, u64),
/// Same as ClientMode::Active.
/// Same as `ClientMode::Active`.
Active,
}

View File

@ -73,7 +73,7 @@ pub struct Transaction {
impl Transaction {
/// Append object with a without signature into RLP stream
pub fn rlp_append_unsigned_transaction(&self, s: &mut RlpStream, network_id: Option<u8>) {
s.begin_list(if let None = network_id { 6 } else { 9 });
s.begin_list(if network_id.is_none() { 6 } else { 9 });
s.append(&self.nonce);
s.append(&self.gas_price);
s.append(&self.gas);

View File

@ -29,6 +29,7 @@ use header::{BlockNumber, Header};
use rlp::{UntrustedRlp, View};
use transaction::SignedTransaction;
use views::BlockView;
use time::get_time;
/// Preprocessed block data gathered in `verify_block_unordered` call
pub struct PreverifiedBlock {
@ -209,6 +210,10 @@ pub fn verify_header_params(header: &Header, engine: &Engine) -> Result<(), Erro
if header.number() != 0 && header.extra_data().len() > maximum_extra_data_size {
return Err(From::from(BlockError::ExtraDataOutOfBounds(OutOfBounds { min: None, max: Some(maximum_extra_data_size), found: header.extra_data().len() })));
}
let max_time = get_time().sec as u64 + 30;
if header.timestamp() > max_time {
return Err(From::from(BlockError::InvalidTimestamp(OutOfBounds { max: Some(max_time), min: None, found: header.timestamp() })))
}
Ok(())
}
@ -258,6 +263,7 @@ mod tests {
use tests::helpers::*;
use types::log_entry::{LogEntry, LocalizedLogEntry};
use rlp::View;
use time::get_time;
fn check_ok(result: Result<(), Error>) {
result.unwrap_or_else(|e| panic!("Block verification failed: {:?}", e));
@ -271,6 +277,14 @@ mod tests {
}
}
fn check_fail_timestamp(result: Result<(), Error>) {
match result {
Err(Error::Block(BlockError::InvalidTimestamp(_))) => (),
Err(other) => panic!("Block verification failed.\nExpected: InvalidTimestamp\nGot: {:?}", other),
Ok(_) => panic!("Block verification failed.\nExpected: InvalidTimestamp\nGot: Ok"),
}
}
struct TestBlockChain {
blocks: HashMap<H256, Bytes>,
numbers: HashMap<BlockNumber, H256>,
@ -515,6 +529,14 @@ mod tests {
check_fail(family_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine, &bc),
InvalidTimestamp(OutOfBounds { max: None, min: Some(parent.timestamp() + 1), found: header.timestamp() }));
header = good.clone();
header.set_timestamp(2450000000);
check_fail_timestamp(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine));
header = good.clone();
header.set_timestamp(get_time().sec as u64 + 40);
check_fail_timestamp(basic_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine));
header = good.clone();
header.set_number(9);
check_fail(family_test(&create_test_block_with_data(&header, &good_transactions, &good_uncles), engine, &bc),

View File

@ -1,5 +1,8 @@
{
"presets": ["es2017", "es2016", "es2015", "stage-0", "react"],
"presets": [
"es2017", "es2016", "es2015",
"stage-0", "react"
],
"plugins": [
"transform-runtime",
"transform-decorators-legacy",
@ -10,6 +13,9 @@
"env": {
"production": {
"plugins": ["transform-react-remove-prop-types"]
},
"development": {
"plugins": ["react-hot-loader/babel"]
}
}
}

View File

@ -15,6 +15,7 @@
"no-debugger": "error",
"no-alert": "error",
"jsx-quotes": ["error", "prefer-single"],
"react/jsx-curly-spacing": ["error", "always"]
"react/jsx-curly-spacing": ["error", "always"],
"object-property-newline": 0
}
}

1
js/.npmrc Normal file
View File

@ -0,0 +1 @@
save-prefix='~'

View File

@ -1,6 +1,6 @@
{
"name": "parity.js",
"version": "0.2.74",
"version": "0.2.79",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Parity Team <admin@parity.io>",
@ -26,16 +26,16 @@
],
"scripts": {
"build": "npm run build:lib && npm run build:dll && npm run build:app",
"build:app": "webpack --progress",
"build:lib": "webpack --config webpack.libraries --progress",
"build:dll": "webpack --config webpack.vendor --progress",
"build:app": "webpack --config webpack/app --progress",
"build:lib": "webpack --config webpack/libraries --progress",
"build:dll": "webpack --config webpack/vendor --progress",
"ci:build": "npm run ci:build:lib && npm run ci:build:dll && npm run ci:build:app",
"ci:build:app": "NODE_ENV=production webpack",
"ci:build:lib": "NODE_ENV=production webpack --config webpack.libraries",
"ci:build:dll": "NODE_ENV=production webpack --config webpack.vendor",
"ci:build:npm": "NODE_ENV=production webpack --config webpack.npm",
"ci:build:app": "NODE_ENV=production webpack --config webpack/app",
"ci:build:lib": "NODE_ENV=production webpack --config webpack/libraries",
"ci:build:dll": "NODE_ENV=production webpack --config webpack/vendor",
"ci:build:npm": "NODE_ENV=production webpack --config webpack/npm",
"start": "npm install && npm run build:lib && npm run build:dll && npm run start:app",
"start:app": "webpack-dev-server -d --history-api-fallback --open --hot --inline --progress --colors --port 3000",
"start:app": "node webpack/dev.server",
"clean": "rm -rf ./build ./coverage",
"coveralls": "npm run testCoverage && coveralls < coverage/lcov.info",
"lint": "eslint --ignore-path .gitignore ./src/",
@ -47,127 +47,132 @@
"prepush": "npm run lint:cached"
},
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-core": "^6.10.4",
"babel-eslint": "^7.1.0",
"babel-loader": "^6.2.3",
"babel-plugin-lodash": "^3.2.2",
"babel-plugin-transform-class-properties": "^6.11.5",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-react-remove-prop-types": "^0.2.9",
"babel-plugin-transform-runtime": "^6.9.0",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-rollup": "^1.1.1",
"babel-preset-es2016": "^6.11.3",
"babel-preset-es2017": "^6.14.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "6.9.0",
"babel-runtime": "^6.9.2",
"chai": "^3.5.0",
"babel-cli": "~6.18.0",
"babel-core": "~6.18.2",
"babel-eslint": "~7.1.0",
"babel-loader": "~6.2.3",
"babel-plugin-lodash": "~3.2.2",
"babel-plugin-transform-class-properties": "~6.19.0",
"babel-plugin-transform-decorators-legacy": "~1.3.4",
"babel-plugin-transform-react-remove-prop-types": "~0.2.9",
"babel-plugin-transform-runtime": "~6.15.0",
"babel-polyfill": "~6.16.0",
"babel-preset-es2015": "~6.18.0",
"babel-preset-es2015-rollup": "~1.2.0",
"babel-preset-es2016": "~6.16.0",
"babel-preset-es2017": "~6.16.0",
"babel-preset-react": "~6.16.0",
"babel-preset-stage-0": "~6.16.0",
"babel-register": "6.18.0",
"babel-runtime": "~6.18.0",
"chai": "~3.5.0",
"chai-enzyme": "0.4.2",
"cheerio": "0.20.0",
"copy-webpack-plugin": "^4.0.0",
"core-js": "^2.4.1",
"coveralls": "^2.11.11",
"css-loader": "^0.23.1",
"copy-webpack-plugin": "~4.0.0",
"core-js": "~2.4.1",
"coveralls": "~2.11.11",
"css-loader": "~0.26.0",
"enzyme": "2.3.0",
"eslint": "^3.1.0",
"eslint-config-semistandard": "^6.0.2",
"eslint-config-standard": "^5.3.5",
"eslint-config-standard-react": "^3.0.0",
"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.4",
"husky": "^0.11.9",
"eslint": "~3.10.2",
"eslint-config-semistandard": "~7.0.0",
"eslint-config-standard": "~6.2.1",
"eslint-config-standard-react": "~4.2.0",
"eslint-plugin-promise": "~3.4.0",
"eslint-plugin-react": "~6.7.1",
"eslint-plugin-standard": "~2.0.0",
"express": "~4.14.0",
"extract-loader": "0.1.0",
"extract-text-webpack-plugin": "~2.0.0-beta.4",
"file-loader": "~0.9.0",
"fs-extra": "~0.30.0",
"happypack": "~3.0.0",
"history": "~2.0.0",
"html-loader": "~0.4.4",
"html-webpack-plugin": "~2.24.1",
"http-proxy-middleware": "~0.17.2",
"husky": "~0.11.9",
"ignore-styles": "2.0.0",
"image-webpack-loader": "^1.8.0",
"istanbul": "^1.0.0-alpha.2",
"image-webpack-loader": "~3.0.0",
"istanbul": "~1.0.0-alpha.2",
"jsdom": "9.2.1",
"json-loader": "^0.5.4",
"mocha": "^3.0.0-1",
"json-loader": "~0.5.4",
"mocha": "~3.0.0-1",
"mock-local-storage": "1.0.2",
"mock-socket": "^3.0.1",
"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",
"raw-loader": "^0.5.1",
"mock-socket": "~3.0.1",
"nock": "~8.0.0",
"postcss-import": "8.1.0",
"postcss-loader": "~1.1.1",
"postcss-nested": "~1.0.0",
"postcss-simple-vars": "~3.0.0",
"progress": "~1.1.8",
"raw-loader": "~0.5.1",
"react-addons-perf": "~15.3.2",
"react-addons-test-utils": "~15.3.2",
"react-copy-to-clipboard": "^4.2.3",
"react-dom": "~15.3.2",
"react-hot-loader": "~1.3.0",
"rucksack-css": "^0.8.6",
"sinon": "^1.17.4",
"sinon-as-promised": "^4.0.2",
"sinon-chai": "^2.8.0",
"style-loader": "^0.13.0",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.15.2",
"react-hot-loader": "~3.0.0-beta.6",
"rucksack-css": "~0.8.6",
"sinon": "~1.17.4",
"sinon-as-promised": "~4.0.2",
"sinon-chai": "~2.8.0",
"style-loader": "~0.13.0",
"url-loader": "~0.5.7",
"webpack": "~2.1.0-beta.27",
"webpack-dev-middleware": "~1.8.4",
"webpack-error-notification": "0.1.6",
"webpack-hot-middleware": "~2.13.2",
"websocket": "^1.0.23"
"websocket": "~1.0.23"
},
"dependencies": {
"bignumber.js": "^2.3.0",
"bignumber.js": "~2.3.0",
"blockies": "0.0.2",
"brace": "^0.9.0",
"bytes": "^2.4.0",
"chart.js": "^2.3.0",
"es6-error": "^4.0.0",
"es6-promise": "^3.2.1",
"ethereumjs-tx": "^1.1.2",
"file-saver": "^1.3.3",
"format-json": "^1.0.3",
"format-number": "^2.0.1",
"geopattern": "^1.2.3",
"isomorphic-fetch": "^2.2.1",
"js-sha3": "^0.5.2",
"lodash": "^4.11.1",
"marked": "^0.3.6",
"brace": "~0.9.0",
"bytes": "~2.4.0",
"chart.js": "~2.3.0",
"es6-error": "~4.0.0",
"es6-promise": "~3.2.1",
"ethereumjs-tx": "~1.1.2",
"eventemitter3": "~2.0.2",
"file-saver": "~1.3.3",
"format-json": "~1.0.3",
"format-number": "~2.0.1",
"geopattern": "~1.2.3",
"isomorphic-fetch": "~2.2.1",
"js-sha3": "~0.5.2",
"lodash": "~4.11.1",
"marked": "~0.3.6",
"material-ui": "0.16.1",
"material-ui-chip-input": "^0.8.0",
"mobx": "^2.6.1",
"mobx-react": "^3.5.8",
"mobx-react-devtools": "^4.2.9",
"moment": "^2.14.1",
"phoneformat.js": "^1.0.3",
"qs": "^6.3.0",
"material-ui-chip-input": "~0.8.0",
"mobx": "~2.6.1",
"mobx-react": "~3.5.8",
"mobx-react-devtools": "~4.2.9",
"moment": "~2.14.1",
"phoneformat.js": "~1.0.3",
"qs": "~6.3.0",
"react": "~15.3.2",
"react-ace": "^4.0.0",
"react-ace": "~4.0.0",
"react-addons-css-transition-group": "~15.3.2",
"react-chartjs-2": "^1.5.0",
"react-chartjs-2": "~1.5.0",
"react-copy-to-clipboard": "~4.2.3",
"react-dom": "~15.3.2",
"react-dropzone": "^3.7.3",
"react-redux": "^4.4.5",
"react-router": "^2.6.1",
"react-router-redux": "^4.0.5",
"react-dropzone": "~3.7.3",
"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",
"rlp": "^2.0.0",
"scryptsy": "^2.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",
"rlp": "~2.0.0",
"scryptsy": "~2.0.0",
"solc": "ngotchac/solc-js",
"store": "^1.3.20",
"utf8": "^2.1.1",
"valid-url": "^1.0.9",
"validator": "^5.7.0",
"web3": "^0.17.0-beta",
"whatwg-fetch": "^1.0.0",
"worker-loader": "^0.7.1"
"store": "~1.3.20",
"utf8": "~2.1.1",
"valid-url": "~1.0.9",
"validator": "~5.7.0",
"web3": "~0.17.0-beta",
"whatwg-fetch": "~1.0.0",
"worker-loader": "~0.7.1"
}
}

View File

@ -27,9 +27,10 @@ export const termsOfService = (
</ul>
);
export const postToServer = (query) => {
export const postToServer = (query, isTestnet = false) => {
const port = isTestnet ? 8443 : 443;
query = stringify(query);
return fetch('https://sms-verification.parity.io/?' + query, {
return fetch(`https://sms-verification.parity.io:${port}/?` + query, {
method: 'POST', mode: 'cors', cache: 'no-store'
})
.then((res) => {

View File

@ -15,16 +15,16 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import Abi from '../../abi';
import Api from '../api';
import { isInstanceOf } from '../util/types';
let nextSubscriptionId = 0;
export default class Contract {
constructor (api, abi) {
if (!isInstanceOf(api, Api)) {
if (!api) {
throw new Error('API instance needs to be provided to Contract');
} else if (!abi) {
}
if (!abi) {
throw new Error('ABI needs to be provided to Contract instance');
}

View File

@ -17,7 +17,7 @@
import BigNumber from 'bignumber.js';
import { isArray, isHex, isInstanceOf, isString } from '../util/types';
import { padLeft } from '../util/format';
import { padLeft, toHex } from '../util/format';
export function inAddress (address) {
// TODO: address validation if we have upper-lower addresses
@ -100,15 +100,7 @@ export function inFilter (options) {
}
export function inHex (str) {
if (str && str.toString) {
str = str.toString(16);
}
if (str && str.substr(0, 2) === '0x') {
return str.toLowerCase();
}
return `0x${(str || '').toLowerCase()}`;
return toHex(str);
}
export function inNumber10 (number) {

View File

@ -15,7 +15,6 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { range } from 'lodash';
import { inHex } from '../format/input';
export function bytesToHex (bytes) {
return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join('');
@ -38,11 +37,23 @@ export function asciiToHex (string) {
}
export function padRight (input, length) {
const value = inHex(input).substr(2, length * 2);
const value = toHex(input).substr(2, length * 2);
return '0x' + value + range(length * 2 - value.length).map(() => '0').join('');
}
export function padLeft (input, length) {
const value = inHex(input).substr(2, length * 2);
const value = toHex(input).substr(2, length * 2);
return '0x' + range(length * 2 - value.length).map(() => '0').join('') + value;
}
export function toHex (str) {
if (str && str.toString) {
str = str.toString(16);
}
if (str && str.substr(0, 2) === '0x') {
return str.toLowerCase();
}
return `0x${(str || '').toLowerCase()}`;
}

View File

@ -1 +1 @@
[{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"certify","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"request","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"},{"name":"_puzzle","type":"bytes32"}],"name":"puzzle","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"uint256"}],"name":"setFee","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"revoke","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_code","type":"bytes32"}],"name":"confirm","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"drain","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"delegate","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getUint","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setDelegate","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"}],"name":"certified","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"get","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Requested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"},{"indexed":false,"name":"puzzle","type":"bytes32"}],"name":"Puzzled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Confirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Revoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"old","type":"address"},{"indexed":true,"name":"current","type":"address"}],"name":"NewOwner","type":"event"}]
[{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"certify","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"request","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"},{"name":"_puzzle","type":"bytes32"}],"name":"puzzle","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getAddress","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"uint256"}],"name":"setFee","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_who","type":"address"}],"name":"revoke","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_code","type":"bytes32"}],"name":"confirm","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"drain","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"delegate","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"getUint","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_new","type":"address"}],"name":"setDelegate","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"}],"name":"certified","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"fee","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_who","type":"address"},{"name":"_field","type":"string"}],"name":"get","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Requested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"},{"indexed":false,"name":"puzzle","type":"bytes32"}],"name":"Puzzled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Confirmed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"who","type":"address"}],"name":"Revoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"old","type":"address"},{"indexed":true,"name":"current","type":"address"}],"name":"NewOwner","type":"event"}]

View File

@ -19,7 +19,7 @@ import Registry from './registry';
import SignatureReg from './signaturereg';
import TokenReg from './tokenreg';
import GithubHint from './githubhint';
import smsVerification from './sms-verification';
import * as smsVerification from './sms-verification';
let instance = null;

View File

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import subscribeToEvent from '../util/subscribe-to-event';
export const checkIfVerified = (contract, account) => {
return contract.instance.certified.call({}, [account]);
};
@ -50,3 +52,36 @@ export const checkIfRequested = (contract, account) => {
});
});
};
const blockNumber = (api) => {
return new Promise((resolve, reject) => {
api.subscribe('eth_blockNumber', (err, block) => {
if (err) {
return reject(err);
}
resolve(block);
})
.then((subscription) => {
api.unsubscribe(subscription);
})
.catch(reject);
});
};
export const awaitPuzzle = (api, contract, account) => {
return blockNumber(api)
.then((block) => {
return new Promise((resolve, reject) => {
const subscription = subscribeToEvent(contract, 'Puzzled', {
from: block.toNumber(),
filter: (log) => log.params.who.value === account
});
subscription.once('error', reject);
subscription.once('log', subscription.unsubscribe);
subscription.once('log', resolve);
subscription.once('timeout', () => {
reject(new Error('Timed out waiting for the puzzle.'));
});
});
});
};

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Basic Token Deployment</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="basiccoin.js"></script>
</body>
</html>

View File

@ -32,7 +32,6 @@ const routerHistory = useRouterHistory(createHashHistory)({});
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './basiccoin.html';
ReactDOM.render(
<Router history={ routerHistory }>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Dapp Registry</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="dappreg.js"></script>
</body>
</html>

View File

@ -17,17 +17,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { useStrict } from 'mobx';
injectTapEventPlugin();
useStrict(true);
import Application from './dappreg/Application';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './dappreg.html';
ReactDOM.render(
<Application />,

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>GitHub Hint</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="githubhint.js"></script>
</body>
</html>

View File

@ -25,7 +25,6 @@ import Application from './githubhint/Application';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './githubhint.html';
ReactDOM.render(
<Application />,

37
js/src/dapps/index.ejs Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><%= htmlWebpackPlugin.options.title %></title>
<style>
html, body, #container {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: white;
font-family: 'Roboto', sans-serif;
font-size: 16px;
font-weight: 300;
}
.loading {
text-align: center;
padding-top: 5em;
font-size: 2em;
color: #999;
}
</style>
</head>
<body>
<div id="container">
<div class="loading">Loading</div>
</div>
<script src="vendor.js"></script>
<% if (!htmlWebpackPlugin.options.secure) { %>
<script src="/parity-utils/parity.js"></script>
<% } %>
</body>
</html>

25
js/src/dapps/index.js Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
module.exports = [
{ name: 'basiccoin', entry: 'basiccoin.js', title: 'Basic Token Deployment' },
{ name: 'dappreg', entry: 'dappreg.js', title: 'Dapp Registry' },
{ name: 'githubhint', entry: 'githubhint.js', title: 'GitHub Hint', secure: true },
{ name: 'localtx', entry: 'localtx.js', title: 'Local transactions Viewer', secure: true },
{ name: 'registry', entry: 'registry.js', title: 'Registry' },
{ name: 'signaturereg', entry: 'signaturereg.js', title: 'Method Signature Registry' },
{ name: 'tokenreg', entry: 'tokenreg.js', title: 'Token Registry' }
];

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Local transactions Viewer</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="localtx.js"></script>
</body>
</html>

View File

@ -25,7 +25,6 @@ import Application from './localtx/Application';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './localtx.html';
ReactDOM.render(
<Application />,

View File

@ -110,7 +110,7 @@ export class Transaction extends BaseTransaction {
static renderHeader () {
return (
<tr className={ styles.header }>
<th></th>
<th />
<th>
Transaction
</th>
@ -129,8 +129,7 @@ export class Transaction extends BaseTransaction {
<th>
# Propagated
</th>
<th>
</th>
<th />
</tr>
);
}
@ -201,7 +200,7 @@ export class LocalTransaction extends BaseTransaction {
static renderHeader () {
return (
<tr className={ styles.header }>
<th></th>
<th />
<th>
Transaction
</th>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Token Registry</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="registry.js"></script>
</body>
</html>

View File

@ -27,7 +27,6 @@ import Container from './registry/Container';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './registry.html';
ReactDOM.render(
<Provider store={ store }>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Method Signature Registry</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="signaturereg.js"></script>
</body>
</html>

View File

@ -25,7 +25,6 @@ import Application from './signaturereg/Application';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './signaturereg.html';
ReactDOM.render(
<Application />,

View File

@ -73,7 +73,7 @@ export default class Import extends Component {
Provide the ABI (Contract Interface) in the space provided below. Only non-constant functions (names &amp; types) will be imported, while constant functions and existing signatures will be ignored.
</div>
<div className={ styles.info }>
<textarea rows='8' className={ styles.error } onChange={ this.onAbiEdit }></textarea>
<textarea rows='8' className={ styles.error } onChange={ this.onAbiEdit } />
<div className={ styles.error }>
{ abiError }
</div>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Token Registry</title>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="/parity-utils/parity.js"></script>
<script src="tokenreg.js"></script>
</body>
</html>

View File

@ -27,7 +27,6 @@ import Container from './tokenreg/Container';
import '../../assets/fonts/Roboto/font.css';
import '../../assets/fonts/RobotoMono/font.css';
import './style.css';
import './tokenreg.html';
ReactDOM.render(
(

View File

@ -147,7 +147,7 @@ export const loadToken = (index) => (dispatch, getState) => {
dispatch(setTokenData(index, null));
dispatch(setTokenLoading(index, false));
if (!e instanceof TypeError) {
if (!(e instanceof TypeError)) {
console.error(`loadToken #${index} error`, e);
}
});

34
js/src/index.ejs Normal file
View File

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><%= htmlWebpackPlugin.options.title %></title>
<style>
html, body, #container {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background: white;
font-family: 'Roboto', sans-serif;
font-size: 16px;
font-weight: 300;
}
.loading {
text-align: center;
padding-top: 5em;
font-size: 2em;
color: #999;
}
</style>
</head>
<body>
<div id="container">
<div class="loading">Loading</span>
</div>
<script src="vendor.js"></script>
</body>
</html>

View File

@ -1,21 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="/parity-logo-black-no-text.png" type="image/png">
<title>Parity</title>
<style>
html, body, #container {
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="vendor.js"></script>
<script src="commons.js"></script>
<script src="index.js"></script>
</body>
</html>

View File

@ -22,17 +22,20 @@ es6Promise.polyfill();
import React from 'react';
import ReactDOM from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import injectTapEventPlugin from 'react-tap-event-plugin';
import { createHashHistory } from 'history';
import { Redirect, Router, Route, useRouterHistory } from 'react-router';
import { useRouterHistory } from 'react-router';
import qs from 'querystring';
import SecureApi from './secureApi';
import ContractInstances from './contracts';
import { initStore } from './redux';
import { ContextProvider, muiTheme } from './ui';
import { Accounts, Account, Addresses, Address, Application, Contract, Contracts, WriteContract, Dapp, Dapps, Settings, SettingsBackground, SettingsParity, SettingsProxy, SettingsViews, Signer, Status } from './views';
import ContextProvider from './ui/ContextProvider';
import muiTheme from './ui/Theme';
import MainApplication from './main';
import { setApi } from './redux/providers/apiActions';
@ -41,9 +44,6 @@ import './environment';
import '../assets/fonts/Roboto/font.css';
import '../assets/fonts/RobotoMono/font.css';
import styles from './reset.css';
import './index.html';
injectTapEventPlugin();
if (process.env.NODE_ENV === 'development') {
@ -77,32 +77,47 @@ window.secureApi = api;
const routerHistory = useRouterHistory(createHashHistory)({});
ReactDOM.render(
<AppContainer>
<ContextProvider api={ api } muiTheme={ muiTheme } store={ store }>
<Router className={ styles.reset } history={ routerHistory }>
<Redirect from='/' to='/accounts' />
<Redirect from='/auth' to='/accounts' query={ {} } />
<Redirect from='/settings' to='/settings/views' />
<Route path='/' component={ Application }>
<Route path='accounts' component={ Accounts } />
<Route path='account/:address' component={ Account } />
<Route path='addresses' component={ Addresses } />
<Route path='address/:address' component={ Address } />
<Route path='apps' component={ Dapps } />
<Route path='app/:id' component={ Dapp } />
<Route path='contracts' component={ Contracts } />
<Route path='contracts/write' component={ WriteContract } />
<Route path='contract/:address' component={ Contract } />
<Route path='settings' component={ Settings }>
<Route path='background' component={ SettingsBackground } />
<Route path='proxy' component={ SettingsProxy } />
<Route path='views' component={ SettingsViews } />
<Route path='parity' component={ SettingsParity } />
</Route>
<Route path='signer' component={ Signer } />
<Route path='status' component={ Status } />
<Route path='status/:subpage' component={ Status } />
</Route>
</Router>
</ContextProvider>,
<MainApplication
routerHistory={ routerHistory }
/>
</ContextProvider>
</AppContainer>,
document.querySelector('#container')
);
if (module.hot) {
// module.hot.accept('./redux', () => {
// // redux store has a method replaceReducer
// // const newStore = initStore(api);
// console.warn('REDUX UPDATE');
// // store.replaceReducer(appReducer);
// // ReactDOM.render(
// // <AppContainer>
// // <ContextProvider api={ api } muiTheme={ muiTheme } store={ newStore }>
// // <MainApplication
// // routerHistory={ routerHistory }
// // />
// // </ContextProvider>
// // </AppContainer>,
// // document.querySelector('#container')
// // );
// });
module.hot.accept('./main.js', () => {
require('./main.js');
ReactDOM.render(
<AppContainer>
<ContextProvider api={ api } muiTheme={ muiTheme } store={ store }>
<MainApplication
routerHistory={ routerHistory }
/>
</ContextProvider>
</AppContainer>,
document.querySelector('#container')
);
});
}

60
js/src/main.js Normal file
View File

@ -0,0 +1,60 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react';
import { Redirect, Router, Route } from 'react-router';
import { Accounts, Account, Addresses, Address, Application, Contract, Contracts, WriteContract, Dapp, Dapps, Settings, SettingsBackground, SettingsParity, SettingsProxy, SettingsViews, Signer, Status } from './views';
import styles from './reset.css';
export default class MainApplication extends Component {
static propTypes = {
routerHistory: PropTypes.any.isRequired
};
render () {
const { routerHistory } = this.props;
return (
<Router className={ styles.reset } history={ routerHistory }>
<Redirect from='/' to='/accounts' />
<Redirect from='/auth' to='/accounts' query={ {} } />
<Redirect from='/settings' to='/settings/views' />
<Route path='/' component={ Application }>
<Route path='accounts' component={ Accounts } />
<Route path='account/:address' component={ Account } />
<Route path='addresses' component={ Addresses } />
<Route path='address/:address' component={ Address } />
<Route path='apps' component={ Dapps } />
<Route path='app/:id' component={ Dapp } />
<Route path='contracts' component={ Contracts } />
<Route path='contracts/write' component={ WriteContract } />
<Route path='contract/:address' component={ Contract } />
<Route path='settings' component={ Settings }>
<Route path='background' component={ SettingsBackground } />
<Route path='proxy' component={ SettingsProxy } />
<Route path='views' component={ SettingsViews } />
<Route path='parity' component={ SettingsParity } />
</Route>
<Route path='signer' component={ Signer } />
<Route path='status' component={ Status } />
<Route path='status/:subpage' component={ Status } />
</Route>
</Router>
);
}
}

View File

@ -128,7 +128,7 @@ export default class DeployContract extends Component {
title={ title }
waiting={ waiting }
visible
scroll>
>
{ this.renderStep() }
</Modal>
);

View File

@ -62,7 +62,6 @@ export default class LoadContract extends Component {
title={ title }
actions={ this.renderDialogActions() }
visible
scroll
>
{ this.renderBody() }
</Modal>

View File

@ -22,6 +22,10 @@ import SendIcon from 'material-ui/svg-icons/content/send';
import { Tabs, Tab } from 'material-ui/Tabs';
import Paper from 'material-ui/Paper';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { showSnackbar } from '../../redux/providers/snackbarActions';
import Form, { Input } from '../../ui/Form';
import { Button, Modal, IdentityName, IdentityIcon } from '../../ui';
@ -30,13 +34,14 @@ import styles from './passwordManager.css';
const TEST_ACTION = 'TEST_ACTION';
const CHANGE_ACTION = 'CHANGE_ACTION';
export default class PasswordManager extends Component {
class PasswordManager extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
}
static propTypes = {
account: PropTypes.object.isRequired,
showSnackbar: PropTypes.func.isRequired,
onClose: PropTypes.func
}
@ -333,7 +338,7 @@ export default class PasswordManager extends Component {
}
handleChangePassword = () => {
const { account } = this.props;
const { account, showSnackbar, onClose } = this.props;
const { currentPass, newPass, repeatNewPass, passwordHint } = this.state;
if (repeatNewPass !== newPass) {
@ -371,12 +376,9 @@ export default class PasswordManager extends Component {
.changePassword(account.address, currentPass, newPass)
])
.then(() => {
const message = {
value: 'Your password has been successfully changed',
success: true
};
this.setState({ waiting: false, message, showMessage: true });
showSnackbar(<div>Your password has been successfully changed.</div>);
this.setState({ waiting: false, showMessage: false });
onClose();
});
})
.catch(e => {
@ -385,3 +387,14 @@ export default class PasswordManager extends Component {
});
}
}
function mapDispatchToProps (dispatch) {
return bindActionCreators({
showSnackbar
}, dispatch);
}
export default connect(
null,
mapDispatchToProps
)(PasswordManager);

View File

@ -53,7 +53,7 @@ export default class GatherData extends Component {
{ this.renderCertified() }
{ this.renderRequested() }
<Input
label={ 'phone number' }
label={ 'phone number in international format' }
hint={ 'the SMS will be sent to this number' }
error={ isNumberValid ? null : 'invalid number' }
disabled={ isVerified }

View File

@ -25,7 +25,7 @@ import {
LOADING,
QUERY_DATA,
POSTING_REQUEST, POSTED_REQUEST,
REQUESTING_SMS, REQUESTED_SMS,
REQUESTING_SMS, QUERY_CODE,
POSTING_CONFIRMATION, POSTED_CONFIRMATION,
DONE
} from './store';
@ -48,7 +48,7 @@ export default class SMSVerification extends Component {
[LOADING]: 0,
[QUERY_DATA]: 1,
[POSTING_REQUEST]: 2, [POSTED_REQUEST]: 2, [REQUESTING_SMS]: 2,
[REQUESTED_SMS]: 3,
[QUERY_CODE]: 3,
[POSTING_CONFIRMATION]: 4, [POSTED_CONFIRMATION]: 4,
[DONE]: 5
}
@ -61,7 +61,7 @@ export default class SMSVerification extends Component {
<Modal
actions={ this.renderDialogActions(phase, error, isStepValid) }
title='verify your account via SMS'
visible scroll
visible
current={ phase }
steps={ ['Prepare', 'Enter Data', 'Request', 'Enter Code', 'Confirm', 'Done!'] }
waiting={ error ? [] : [ 0, 2, 4 ] }
@ -137,7 +137,7 @@ export default class SMSVerification extends Component {
step,
fee, number, isNumberValid, isVerified, hasRequested,
requestTx, isCodeValid, confirmationTx,
setNumber, setConsentGiven, setCode
setCode
} = this.props.store;
switch (phase) {

View File

@ -47,7 +47,7 @@ export default class SendRequest extends Component {
case REQUESTING_SMS:
return (
<p>Requesting an SMS from the Parity server.</p>
<p>Requesting an SMS from the Parity server and waiting for the puzzle to be put into the contract.</p>
);
default:

View File

@ -20,19 +20,16 @@ import { sha3 } from '../../api/util/sha3';
import Contracts from '../../contracts';
import { checkIfVerified, checkIfRequested } from '../../contracts/sms-verification';
import { checkIfVerified, checkIfRequested, awaitPuzzle } from '../../contracts/sms-verification';
import { postToServer } from '../../3rdparty/sms-verification';
import checkIfTxFailed from '../../util/check-if-tx-failed';
import waitForConfirmations from '../../util/wait-for-block-confirmations';
const validCode = /^[A-Z\s]+$/i;
export const LOADING = 'fetching-contract';
export const QUERY_DATA = 'query-data';
export const POSTING_REQUEST = 'posting-request';
export const POSTED_REQUEST = 'posted-request';
export const REQUESTING_SMS = 'requesting-sms';
export const REQUESTED_SMS = 'requested-sms';
export const QUERY_CODE = 'query-code';
export const POSTING_CONFIRMATION = 'posting-confirmation';
export const POSTED_CONFIRMATION = 'posted-confirmation';
@ -50,11 +47,9 @@ export default class VerificationStore {
@observable number = '';
@observable requestTx = null;
@observable code = '';
@observable isCodeValid = null;
@observable confirmationTx = null;
@computed get isCodeValid () {
return validCode.test(this.code);
}
@computed get isNumberValid () {
return phone.isValidNumber(this.number);
}
@ -72,20 +67,19 @@ export default class VerificationStore {
return this.contract && this.fee && this.isVerified !== null && this.hasRequested !== null;
case QUERY_DATA:
return this.isNumberValid && this.consentGiven;
case REQUESTED_SMS:
return this.requestTx;
case QUERY_CODE:
return this.isCodeValid;
return this.requestTx && this.isCodeValid === true;
case POSTED_CONFIRMATION:
return this.confirmationTx;
return !!this.confirmationTx;
default:
return false;
}
}
constructor (api, account) {
constructor (api, account, isTestnet) {
this.api = api;
this.account = account;
this.isTestnet = isTestnet;
this.step = LOADING;
Contracts.create(api).registry.getContract('smsverification')
@ -151,7 +145,26 @@ export default class VerificationStore {
}
@action setCode = (code) => {
const { contract, account } = this;
if (!contract || !account || code.length === 0) return;
const confirm = contract.functions.find((fn) => fn.name === 'confirm');
const options = { from: account };
const values = [ sha3(code) ];
this.code = code;
this.isCodeValid = null;
confirm.estimateGas(options, values)
.then((gas) => {
options.gas = gas.mul(1.2).toFixed(0);
return confirm.call(options, values);
})
.then((result) => {
this.isCodeValid = result === true;
})
.catch((err) => {
this.error = 'Failed to check if the code is valid: ' + err.message;
});
}
@action sendRequest = () => {
@ -188,11 +201,15 @@ export default class VerificationStore {
chain
.then(() => {
this.step = REQUESTING_SMS;
return postToServer({ number, address: account });
return api.parity.netChain();
})
.then((chain) => {
this.step = REQUESTING_SMS;
return postToServer({ number, address: account }, this.isTestnet);
})
.then(() => awaitPuzzle(api, contract, account))
.then(() => {
this.step = REQUESTED_SMS;
this.step = QUERY_CODE;
})
.catch((err) => {
this.error = 'Failed to request a confirmation SMS: ' + err.message;

View File

@ -104,7 +104,6 @@ class Transfer extends Component {
steps={ steps }
waiting={ extras ? [2] : [1] }
visible
scroll
>
{ this.renderWarning() }
{ this.renderPage() }

View File

@ -17,7 +17,7 @@
import { newError } from '../ui/Errors/actions';
import { setAddressImage } from './providers/imagesActions';
import { clearStatusLogs, toggleStatusLogs, toggleStatusRefresh } from './providers/statusActions';
import { toggleView } from '../views/Settings';
import { toggleView } from '../views/Settings/actions';
export {
newError,

View File

@ -19,9 +19,9 @@ import { routerReducer } from 'react-router-redux';
import { apiReducer, balancesReducer, blockchainReducer, compilerReducer, imagesReducer, personalReducer, signerReducer, statusReducer as nodeStatusReducer, snackbarReducer } from './providers';
import { errorReducer } from '../ui/Errors';
import { settingsReducer } from '../views/Settings';
import { tooltipReducer } from '../ui/Tooltips';
import errorReducer from '../ui/Errors/reducers';
import settingsReducer from '../views/Settings/reducers';
import tooltipReducer from '../ui/Tooltips/reducers';
export default function () {
return combineReducers({

View File

@ -19,7 +19,7 @@ import React, { Component, PropTypes } from 'react';
import FileSaver from 'file-saver';
import FileDownloadIcon from 'material-ui/svg-icons/file/file-download';
import { Button } from '../../';
import Button from '../../Button';
class ActionbarExport extends Component {
static propTypes = {

View File

@ -20,7 +20,8 @@ import FileUploadIcon from 'material-ui/svg-icons/file/file-upload';
import ContentClear from 'material-ui/svg-icons/content/clear';
import ActionDoneAll from 'material-ui/svg-icons/action/done-all';
import { Modal, Button } from '../../';
import Button from '../../Button';
import Modal from '../../Modal';
import styles from './import.css';

View File

@ -17,7 +17,8 @@
import React, { Component, PropTypes } from 'react';
import ActionSearch from 'material-ui/svg-icons/action/search';
import { Button, InputChip } from '../../';
import Button from '../../Button';
import InputChip from '../../Form/InputChip';
import styles from './search.css';

View File

@ -22,7 +22,7 @@ import MenuItem from 'material-ui/MenuItem';
import SortIcon from 'material-ui/svg-icons/content/sort';
import { Button } from '../../';
import Button from '../../Button';
import SortStore from './sortStore';
import styles from './sort.css';

View File

@ -17,6 +17,8 @@
import React, { Component, PropTypes } from 'react';
import { Card } from 'material-ui/Card';
import Title from './Title';
import styles from './container.css';
export default class Container extends Component {
@ -25,7 +27,10 @@ export default class Container extends Component {
className: PropTypes.string,
compact: PropTypes.bool,
light: PropTypes.bool,
style: PropTypes.object
style: PropTypes.object,
title: PropTypes.oneOfType([
PropTypes.string, PropTypes.node
])
}
render () {
@ -35,9 +40,22 @@ export default class Container extends Component {
return (
<div className={ classes } style={ style }>
<Card className={ compact ? styles.compact : styles.padded }>
{ this.renderTitle() }
{ children }
</Card>
</div>
);
}
renderTitle () {
const { title } = this.props;
if (!title) {
return null;
}
return (
<Title title={ title } />
);
}
}

View File

@ -22,7 +22,10 @@ import IconButton from 'material-ui/IconButton';
import AddIcon from 'material-ui/svg-icons/content/add';
import RemoveIcon from 'material-ui/svg-icons/content/remove';
import { Input, InputAddressSelect, Select } from '../../../ui';
import Input from '../../../ui/Form/Input';
import InputAddressSelect from '../../../ui/Form/InputAddressSelect';
import Select from '../../../ui/Form/Select';
import { ABI_TYPES } from '../../../util/abi';
import styles from './typedInput.css';

View File

@ -18,6 +18,8 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import ShortenedHash from '../ShortenedHash';
const defaultName = 'UNNAMED';
class IdentityName extends Component {
@ -41,7 +43,7 @@ class IdentityName extends Component {
return null;
}
const addressFallback = shorten ? this.formatHash(address) : address;
const addressFallback = shorten ? (<ShortenedHash data={ address } />) : address;
const fallback = unknown ? defaultName : addressFallback;
const isUuid = hasAccount && account.name === account.uuid;
const displayName = (name && name.toUpperCase().trim()) ||
@ -55,14 +57,6 @@ class IdentityName extends Component {
</span>
);
}
formatHash (hash) {
if (!hash || hash.length <= 16) {
return hash;
}
return `${hash.substr(2, 6)}...${hash.slice(-6)}`;
}
}
function mapStateToProps (state) {

View File

@ -41,7 +41,6 @@ class Modal extends Component {
compact: PropTypes.bool,
current: PropTypes.number,
waiting: PropTypes.array,
scroll: PropTypes.bool,
steps: PropTypes.array,
title: PropTypes.oneOfType([
PropTypes.node, PropTypes.string
@ -52,7 +51,7 @@ class Modal extends Component {
render () {
const { muiTheme } = this.context;
const { actions, busy, className, current, children, compact, scroll, steps, waiting, title, visible, settings } = this.props;
const { actions, busy, className, current, children, compact, steps, waiting, title, visible, settings } = this.props;
const contentStyle = muiTheme.parity.getBackgroundStyle(null, settings.backgroundSeed);
const header = (
<Title
@ -70,7 +69,7 @@ class Modal extends Component {
actions={ actions }
actionsContainerStyle={ ACTIONS_STYLE }
autoDetectWindowHeight={ false }
autoScrollBodyContent={ !!scroll }
autoScrollBodyContent
actionsContainerClassName={ styles.actions }
bodyClassName={ styles.body }
contentClassName={ styles.content }

View File

@ -0,0 +1,17 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
export default from './shortenedHash';

View File

@ -0,0 +1,21 @@
/* Copyright 2015, 2016 Ethcore (UK) Ltd.
/* This file is part of Parity.
/*
/* Parity is free software: you can redistribute it and/or modify
/* it under the terms of the GNU General Public License as published by
/* the Free Software Foundation, either version 3 of the License, or
/* (at your option) any later version.
/*
/* Parity is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/
.hash {
display: inline-block;
word-break: break-all;
}

View File

@ -0,0 +1,41 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import React, { Component, PropTypes } from 'react';
import styles from './shortenedHash.css';
export default class ShortenedHash extends Component {
static propTypes = {
data: PropTypes.string.isRequired
}
render () {
const { data } = this.props;
let shortened = data.toLowerCase();
if (shortened.slice(0, 2) === '0x') {
shortened = shortened.slice(2);
}
if (shortened.length > (6 + 6)) {
shortened = shortened.slice(0, 6) + '…' + shortened.slice(-6);
}
return (
<abbr className={ styles.hash } title={ shortened }>{ shortened }</abbr>
);
}
}

View File

@ -15,19 +15,12 @@
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/
.details {
}
.header {
}
.hash {
padding-top: 1em;
word-break: break-all;
}
.confirm {
padding-top: 1em;
opacity: 0.5;
}

View File

@ -19,7 +19,9 @@ import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { LinearProgress } from 'material-ui';
import { txLink } from '../../3rdparty/etherscan/links';
import ShortenedHash from '../ShortenedHash';
import styles from './txHash.css';
@ -62,22 +64,23 @@ class TxHash extends Component {
render () {
const { hash, isTest, summary } = this.props;
let header = null;
if (!summary) {
header = (
<div className={ styles.header }>
The transaction has been posted to the network with a transaction hash of
</div>
const link = (
<a href={ txLink(hash, isTest) } target='_blank'>
<ShortenedHash data={ hash } />
</a>
);
let header = (
<p>The transaction has been posted to the network, with a hash of { link }.</p>
);
if (summary) {
header = (<p>{ link }</p>);
}
return (
<div className={ styles.details }>
<div>
{ header }
<div className={ styles.hash }>
<a href={ txLink(hash, isTest) } target='_blank'>{ hash }</a>
</div>
{ this.renderConfirmations() }
</div>
);
@ -87,17 +90,29 @@ class TxHash extends Component {
const { maxConfirmations } = this.props;
const { blockNumber, transaction } = this.state;
let txBlock = 'Pending';
let confirmations = 'No';
let value = 0;
if (transaction && transaction.blockNumber && transaction.blockNumber.gt(0)) {
const num = blockNumber.minus(transaction.blockNumber).plus(1);
txBlock = `#${transaction.blockNumber.toFormat(0)}`;
confirmations = num.toFormat(0);
value = num.gt(maxConfirmations) ? maxConfirmations : num.toNumber();
if (!(transaction && transaction.blockNumber && transaction.blockNumber.gt(0))) {
return (
<div className={ styles.confirm }>
<LinearProgress
className={ styles.progressbar }
color='white'
mode='indeterminate'
/>
<div className={ styles.progressinfo }>waiting for confirmations</div>
</div>
);
}
const confirmations = blockNumber.minus(transaction.blockNumber).plus(1);
const value = Math.min(confirmations.toNumber(), maxConfirmations);
let count;
if (confirmations.gt(maxConfirmations)) {
count = confirmations.toFormat(0);
} else {
count = confirmations.toFormat(0) + `/${maxConfirmations}`;
}
const unit = value === 1 ? 'confirmation' : 'confirmations';
return (
<div className={ styles.confirm }>
<LinearProgress
@ -106,9 +121,10 @@ class TxHash extends Component {
max={ maxConfirmations }
value={ value }
color='white'
mode='determinate' />
mode='determinate'
/>
<div className={ styles.progressinfo }>
{ txBlock } / { confirmations } confirmations
<abbr title={ `block #${blockNumber.toFormat(0)}` }>{ count } { unit }</abbr>
</div>
</div>
);

View File

@ -14,4 +14,4 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
export default from './transaction';
export default from './txList';

131
js/src/ui/TxList/store.js Normal file
View File

@ -0,0 +1,131 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { action, observable, transaction } from 'mobx';
import { uniq } from 'lodash';
export default class Store {
@observable blocks = {};
@observable sortedHashes = [];
@observable transactions = {};
constructor (api) {
this._api = api;
this._subscriptionId = 0;
this._pendingHashes = [];
this.subscribe();
}
@action addBlocks = (blocks) => {
this.blocks = Object.assign({}, this.blocks, blocks);
}
@action addTransactions = (transactions) => {
transaction(() => {
this.transactions = Object.assign({}, this.transactions, transactions);
this.sortedHashes = Object
.keys(this.transactions)
.sort((ahash, bhash) => {
const bnA = this.transactions[ahash].blockNumber;
const bnB = this.transactions[bhash].blockNumber;
if (bnB.eq(0)) {
return bnB.eq(bnA) ? 0 : 1;
}
return bnB.comparedTo(bnA);
});
this._pendingHashes = this.sortedHashes.filter((hash) => this.transactions[hash].blockNumber.eq(0));
});
}
@action clearPending () {
this._pendingHashes = [];
}
subscribe () {
this._api
.subscribe('eth_blockNumber', (error, blockNumber) => {
if (error) {
return;
}
if (this._pendingHashes.length) {
this.loadTransactions(this._pendingHashes);
this.clearPending();
}
})
.then((subscriptionId) => {
this._subscriptionId = subscriptionId;
});
}
unsubscribe () {
if (!this._subscriptionId) {
return;
}
this._api.unsubscribe(this._subscriptionId);
this._subscriptionId = 0;
}
loadTransactions (_txhashes) {
const txhashes = _txhashes.filter((hash) => !this.transactions[hash] || this._pendingHashes.includes(hash));
if (!txhashes || !txhashes.length) {
return;
}
Promise
.all(txhashes.map((txhash) => this._api.eth.getTransactionByHash(txhash)))
.then((transactions) => {
this.addTransactions(
transactions.reduce((transactions, tx, index) => {
transactions[txhashes[index]] = tx;
return transactions;
}, {})
);
this.loadBlocks(transactions.map((tx) => tx.blockNumber ? tx.blockNumber.toNumber() : 0));
})
.catch((error) => {
console.warn('loadTransactions', error);
});
}
loadBlocks (_blockNumbers) {
const blockNumbers = uniq(_blockNumbers).filter((bn) => !this.blocks[bn]);
if (!blockNumbers || !blockNumbers.length) {
return;
}
Promise
.all(blockNumbers.map((blockNumber) => this._api.eth.getBlockByNumber(blockNumber)))
.then((blocks) => {
this.addBlocks(
blocks.reduce((blocks, block, index) => {
blocks[blockNumbers[index]] = block;
return blocks;
}, {})
);
})
.catch((error) => {
console.warn('loadBlocks', error);
});
}
}

View File

@ -0,0 +1,81 @@
/* Copyright 2015, 2016 Ethcore (UK) Ltd.
/* This file is part of Parity.
/*
/* Parity is free software: you can redistribute it and/or modify
/* it under the terms of the GNU General Public License as published by
/* the Free Software Foundation, either version 3 of the License, or
/* (at your option) any later version.
/*
/* Parity is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/
.transactions {
width: 100%;
border-collapse: collapse;
tr {
line-height: 32px;
vertical-align: top;
&:nth-child(even) {
background: rgba(255, 255, 255, 0.04);
}
}
th {
color: #aaa;
text-align: center;
}
td {
vertical-align: top;
padding: 0.75em 0.75em;
&.method {
width: 40%;
}
&.timestamp {
padding-top: 1.5em;
text-align: right;
line-height: 1.5em;
opacity: 0.5;
}
&.transaction {
padding-top: 1.5em;
text-align: center;
& div {
line-height: 1.25em;
min-height: 1.25em;
}
}
}
.icon {
margin: 0;
}
.link {
vertical-align: top;
}
.right {
text-align: right;
}
.center {
text-align: center;
}
.left {
text-align: left;
}
}

178
js/src/ui/TxList/txList.js Normal file
View File

@ -0,0 +1,178 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import moment from 'moment';
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { observer } from 'mobx-react';
import { txLink, addressLink } from '../../3rdparty/etherscan/links';
import IdentityIcon from '../IdentityIcon';
import IdentityName from '../IdentityName';
import MethodDecoding from '../MethodDecoding';
import Store from './store';
import styles from './txList.css';
@observer
class TxList extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
}
static propTypes = {
address: PropTypes.string.isRequired,
hashes: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object
]).isRequired,
isTest: PropTypes.bool.isRequired
}
store = new Store(this.context.api);
componentWillMount () {
this.store.loadTransactions(this.props.hashes);
}
componentWillUnmount () {
this.store.unsubscribe();
}
componentWillReceiveProps (newProps) {
this.store.loadTransactions(newProps.hashes);
}
render () {
return (
<table className={ styles.transactions }>
<tbody>
{ this.renderRows() }
</tbody>
</table>
);
}
renderRows () {
const { address, isTest } = this.props;
return this.store.sortedHashes.map((txhash) => {
const tx = this.store.transactions[txhash];
return (
<tr key={ tx.hash }>
{ this.renderBlockNumber(tx.blockNumber) }
{ this.renderAddress(tx.from) }
<td className={ styles.transaction }>
{ this.renderEtherValue(tx.value) }
<div></div>
<div>
<a
className={ styles.link }
href={ txLink(tx.hash, isTest) }
target='_blank'>
{ `${tx.hash.substr(2, 6)}...${tx.hash.slice(-6)}` }
</a>
</div>
</td>
{ this.renderAddress(tx.to) }
<td className={ styles.method }>
<MethodDecoding
historic
address={ address }
transaction={ tx } />
</td>
</tr>
);
});
}
renderAddress (address) {
const { isTest } = this.props;
let esLink = null;
if (address) {
esLink = (
<a
href={ addressLink(address, isTest) }
target='_blank'
className={ styles.link }>
<IdentityName address={ address } shorten />
</a>
);
}
return (
<td className={ styles.address }>
<div className={ styles.center }>
<IdentityIcon
center
className={ styles.icon }
address={ address } />
</div>
<div className={ styles.center }>
{ esLink || 'DEPLOY' }
</div>
</td>
);
}
renderEtherValue (_value) {
const { api } = this.context;
const value = api.util.fromWei(_value);
if (value.eq(0)) {
return <div className={ styles.value }>{ ' ' }</div>;
}
return (
<div className={ styles.value }>
{ value.toFormat(5) }<small>ETH</small>
</div>
);
}
renderBlockNumber (_blockNumber) {
const blockNumber = _blockNumber.toNumber();
const block = this.store.blocks[blockNumber];
return (
<td className={ styles.timestamp }>
<div>{ blockNumber && block ? moment(block.timestamp).fromNow() : null }</div>
<div>{ blockNumber ? _blockNumber.toFormat() : 'Pending' }</div>
</td>
);
}
}
function mapStateToProps (state) {
const { isTest } = state.nodeStatus;
return {
isTest
};
}
function mapDispatchToProps (dispatch) {
return bindActionCreators({}, dispatch);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(TxList);

View File

@ -37,10 +37,12 @@ import Modal, { Busy as BusyStep, Completed as CompletedStep } from './Modal';
import muiTheme from './Theme';
import Page from './Page';
import ParityBackground from './ParityBackground';
import ShortenedHash from './ShortenedHash';
import SignerIcon from './SignerIcon';
import Tags from './Tags';
import Tooltips, { Tooltip } from './Tooltips';
import TxHash from './TxHash';
import TxList from './TxList';
export {
Actionbar,
@ -79,9 +81,11 @@ export {
Page,
ParityBackground,
RadioButtons,
ShortenedHash,
SignerIcon,
Tags,
Tooltip,
Tooltips,
TxHash
TxHash,
TxList
};

19
js/src/util/is-testnet.js Normal file
View File

@ -0,0 +1,19 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
export default (chain) => {
return chain === 'morden' || chain === 'ropsten' || chain === 'testnet';
};

View File

@ -0,0 +1,77 @@
// Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import EventEmitter from 'eventemitter3';
const defaults = {
from: 0, // TODO
to: 'latest',
timeout: null,
filter: () => true
};
const subscribeToEvent = (contract, name, opt = {}) => {
opt = Object.assign({}, defaults, opt);
let subscription = null;
let timeout = null;
const unsubscribe = () => {
if (subscription) {
contract.unsubscribe(subscription);
subscription = null;
}
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
};
const emitter = new EventEmitter();
emitter.unsubscribe = unsubscribe;
if (typeof opt.timeout === 'number') {
timeout = setTimeout(() => {
unsubscribe();
emitter.emit('timeout');
}, opt.timeout);
}
const callback = (err, logs) => {
if (err) {
return emitter.emit('error', err);
}
for (let log of logs) {
if (opt.filter(log)) {
emitter.emit('log', log);
}
}
};
contract.subscribe(name, {
fromBlock: opt.from, toBlock: opt.to
}, callback)
.then((_subscription) => {
subscription = _subscription;
})
.catch((err) => {
emitter.emit('error', err);
});
return emitter;
};
export default subscribeToEvent;

Some files were not shown because too many files have changed in this diff Show More