Merge branch 'master' into ng-webpack-update
This commit is contained in:
commit
807790ce95
106
.gitlab-ci.yml
106
.gitlab-ci.yml
@ -31,7 +31,7 @@ linux-stable:
|
|||||||
- md5sum "parity_"$VER"_amd64.deb" > "parity_"$VER"_amd64.deb.md5"
|
- md5sum "parity_"$VER"_amd64.deb" > "parity_"$VER"_amd64.deb.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/x86_64-unknown-linux-gnu
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity --body target/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-unknown-linux-gnu/parity.md5 --body parity.md5
|
||||||
@ -98,7 +98,7 @@ linux-centos:
|
|||||||
- md5sum target/release/parity > parity.md5
|
- md5sum target/release/parity > parity.md5
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/x86_64-unknown-centos-gnu
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu
|
||||||
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity --body target/release/parity
|
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity --body target/release/parity
|
||||||
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket builds-parity --key $CI_BUILD_REF_NAME/x86_64-unknown-centos-gnu/parity.md5 --body parity.md5
|
||||||
@ -130,7 +130,7 @@ linux-i686:
|
|||||||
- md5sum "parity_"$VER"_i386.deb" > "parity_"$VER"_i386.deb.md5"
|
- md5sum "parity_"$VER"_i386.deb" > "parity_"$VER"_i386.deb.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/i686-unknown-linux-gnu
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/i686-unknown-linux-gnu
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity --body target/i686-unknown-linux-gnu/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity --body target/i686-unknown-linux-gnu/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/i686-unknown-linux-gnu/parity.md5 --body parity.md5
|
||||||
@ -172,7 +172,7 @@ linux-armv7:
|
|||||||
- md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5"
|
- md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/armv7-unknown-linux-gnueabihf
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity --body target/armv7-unknown-linux-gnueabihf/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/armv7-unknown-linux-gnueabihf/parity.md5 --body parity.md5
|
||||||
@ -214,7 +214,7 @@ linux-arm:
|
|||||||
- md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5"
|
- md5sum "parity_"$VER"_armhf.deb" > "parity_"$VER"_armhf.deb.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/arm-unknown-linux-gnueabihf
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity --body target/arm-unknown-linux-gnueabihf/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabihf/parity.md5 --body parity.md5
|
||||||
@ -251,7 +251,7 @@ linux-armv6:
|
|||||||
- md5sum target/arm-unknown-linux-gnueabi/release/parity > parity.md5
|
- md5sum target/arm-unknown-linux-gnueabi/release/parity > parity.md5
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/arm-unknown-linux-gnueabi
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity --body target/arm-unknown-linux-gnueabi/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/arm-unknown-linux-gnueabi/parity.md5 --body parity.md5
|
||||||
@ -291,7 +291,7 @@ linux-aarch64:
|
|||||||
- md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5"
|
- md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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 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 --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.md5 --body parity.md5
|
||||||
@ -305,20 +305,20 @@ linux-aarch64:
|
|||||||
- target/aarch64-unknown-linux-gnu/release/parity
|
- target/aarch64-unknown-linux-gnu/release/parity
|
||||||
name: "aarch64-unknown-linux-gnu_parity"
|
name: "aarch64-unknown-linux-gnu_parity"
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
linux-alpine:
|
#linux-alpine:
|
||||||
stage: build
|
# stage: build
|
||||||
image: ethcore/rust-alpine:latest
|
# image: ethcore/rust-alpine:latest
|
||||||
only:
|
# only:
|
||||||
- beta
|
# - beta
|
||||||
- tags
|
# - tags
|
||||||
- stable
|
# - stable
|
||||||
- triggers
|
# - triggers
|
||||||
script:
|
# script:
|
||||||
- export HOST_CC=gcc
|
# - export HOST_CC=gcc
|
||||||
- export HOST_CXX=g++
|
# - export HOST_CXX=g++
|
||||||
- cargo build --release $CARGOFLAGS
|
# - cargo build --release $CARGOFLAGS
|
||||||
- strip target/release/parity
|
# - strip target/release/parity
|
||||||
- md5sum target/release/parity > parity.md5
|
# - md5sum target/release/parity > parity.md5
|
||||||
# - sh scripts/deb-build.sh arm64
|
# - sh scripts/deb-build.sh arm64
|
||||||
# - cp target/aarch64-unknown-linux-gnu/release/parity deb/usr/bin/parity
|
# - 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")
|
# - export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
|
||||||
@ -326,20 +326,20 @@ linux-alpine:
|
|||||||
# - md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5"
|
# - md5sum "parity_"$VER"_arm64.deb" > "parity_"$VER"_arm64.deb.md5"
|
||||||
# - aws configure set aws_access_key_id $s3_key
|
# - aws configure set aws_access_key_id $s3_key
|
||||||
# - aws configure set aws_secret_access_key $s3_secret
|
# - aws 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=parity-builds; fi
|
# - 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 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 --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.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" --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"
|
# - 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:
|
# tags:
|
||||||
- rust
|
# - rust
|
||||||
- rust-alpine
|
# - rust-alpine
|
||||||
# artifacts:
|
# artifacts:
|
||||||
# paths:
|
# paths:
|
||||||
# - target/aarch64-unknown-linux-gnu/release/parity
|
# - target/aarch64-unknown-linux-gnu/release/parity
|
||||||
# name: "aarch64-unknown-linux-gnu_parity"
|
# name: "aarch64-unknown-linux-gnu_parity"
|
||||||
allow_failure: true
|
# allow_failure: true
|
||||||
darwin:
|
darwin:
|
||||||
stage: build
|
stage: build
|
||||||
only:
|
only:
|
||||||
@ -348,15 +348,22 @@ darwin:
|
|||||||
- stable
|
- stable
|
||||||
- triggers
|
- triggers
|
||||||
script:
|
script:
|
||||||
|
- cargo build --release -p ethstore $CARGOFLAGS
|
||||||
- cargo build --release $CARGOFLAGS
|
- cargo build --release $CARGOFLAGS
|
||||||
- rm -rf parity.md5
|
- rm -rf parity.md5
|
||||||
- md5sum target/release/parity > parity.md5
|
- md5sum target/release/parity > parity.md5
|
||||||
|
- packagesbuild -v mac/Parity.pkgproj
|
||||||
|
- export VER=$(grep -m 1 version Cargo.toml | awk '{print $3}' | tr -d '"' | tr -d "\n")
|
||||||
|
- mv target/release/Parity\ Ethereum.pkg "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg"
|
||||||
|
- md5sum "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" >> "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5"
|
||||||
- aws configure set aws_access_key_id $s3_key
|
- aws configure set aws_access_key_id $s3_key
|
||||||
- aws configure set aws_secret_access_key $s3_secret
|
- aws 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=parity-builds; fi
|
- 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/x86_64-apple-darwin
|
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-apple-darwin
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity --body target/release/parity
|
||||||
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/parity.md5 --body parity.md5
|
||||||
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg"
|
||||||
|
- aws s3api put-object --bucket $S3_BUCKET --key $CI_BUILD_REF_NAME/x86_64-apple-darwin/"parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5" --body "parity-"$VER"-osx-installer-EXPERIMENTAL.pkg.md5"
|
||||||
tags:
|
tags:
|
||||||
- osx
|
- osx
|
||||||
artifacts:
|
artifacts:
|
||||||
@ -401,11 +408,11 @@ windows:
|
|||||||
- aws configure set aws_access_key_id %s3_key%
|
- aws configure set aws_access_key_id %s3_key%
|
||||||
- aws configure set aws_secret_access_key %s3_secret%
|
- aws configure set aws_secret_access_key %s3_secret%
|
||||||
- echo %CI_BUILD_REF_NAME%
|
- echo %CI_BUILD_REF_NAME%
|
||||||
- if %CI_BUILD_REF_NAME% == "master" set S3_BUCKET=builds-parity-published else (set S3_BUCKET=parity-builds)
|
- echo %CI_BUILD_REF_NAME% | findstr /R "master" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity
|
||||||
- if %CI_BUILD_REF_NAME% == "beta" set S3_BUCKET=builds-parity-published else (set S3_BUCKET=parity-builds)
|
- echo %CI_BUILD_REF_NAME% | findstr /R "beta" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity
|
||||||
- if %CI_BUILD_REF_NAME% == "stable" set S3_BUCKET=builds-parity-published else (set S3_BUCKET=parity-builds)
|
- echo %CI_BUILD_REF_NAME% | findstr /R "stable" >nul 2>&1 && set S3_BUCKET=builds-parity-published || set S3_BUCKET=builds-parity
|
||||||
- echo %S3_BUCKET%
|
- echo %S3_BUCKET%
|
||||||
- aws s3 rm --recursive s3://$S3_BUCKET/$CI_BUILD_REF_NAME/x86_64-pc-windows-msvc
|
- aws s3 rm --recursive s3://%S3_BUCKET%/%CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc
|
||||||
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe --body target\release\parity.exe
|
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe --body target\release\parity.exe
|
||||||
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe.md5 --body target\release\parity.exe.md5
|
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.exe.md5 --body target\release\parity.exe.md5
|
||||||
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip --body target\release\parity.zip
|
- aws s3api put-object --bucket %S3_BUCKET% --key %CI_BUILD_REF_NAME%/x86_64-pc-windows-msvc/parity.zip --body target\release\parity.zip
|
||||||
@ -451,13 +458,13 @@ test-rust-stable:
|
|||||||
image: ethcore/rust:stable
|
image: ethcore/rust:stable
|
||||||
before_script:
|
before_script:
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF $CI_BUILD_REF@{1} | grep \.js | wc -l)
|
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l)
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi
|
||||||
script:
|
script:
|
||||||
- export RUST_BACKTRACE=1
|
- export RUST_BACKTRACE=1
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi
|
||||||
tags:
|
tags:
|
||||||
- rust
|
- rust
|
||||||
- rust-stable
|
- rust-stable
|
||||||
@ -468,13 +475,13 @@ test-rust-beta:
|
|||||||
image: ethcore/rust:beta
|
image: ethcore/rust:beta
|
||||||
before_script:
|
before_script:
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF $CI_BUILD_REF@{1} | grep \.js | wc -l)
|
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l)
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi
|
||||||
script:
|
script:
|
||||||
- export RUST_BACKTRACE=1
|
- export RUST_BACKTRACE=1
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi
|
||||||
tags:
|
tags:
|
||||||
- rust
|
- rust
|
||||||
- rust-beta
|
- rust-beta
|
||||||
@ -486,28 +493,17 @@ test-rust-nightly:
|
|||||||
image: ethcore/rust:nightly
|
image: ethcore/rust:nightly
|
||||||
before_script:
|
before_script:
|
||||||
- git submodule update --init --recursive
|
- git submodule update --init --recursive
|
||||||
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF $CI_BUILD_REF@{1} | grep \.js | wc -l)
|
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l)
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"; else ./js/scripts/install-deps.sh;fi
|
||||||
script:
|
script:
|
||||||
- export RUST_BACKTRACE=1
|
- export RUST_BACKTRACE=1
|
||||||
- echo $JS_FILES_MODIFIED
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [ -z $JS_FILES_MODIFIED ]; then echo "skip js test"; else ./test.sh $CARGOFLAGS --no-release; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js test"&./test.sh $CARGOFLAGS --no-release; else echo "skip rust test"&./js/scripts/lint.sh&./js/scripts/test.sh&./js/scripts/build.sh; fi
|
||||||
tags:
|
tags:
|
||||||
- rust
|
- rust
|
||||||
- rust-nightly
|
- rust-nightly
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
js-tests:
|
|
||||||
stage: test
|
|
||||||
image: ethcore/rust:stable
|
|
||||||
before_script:
|
|
||||||
- ./js/scripts/install-deps.sh
|
|
||||||
script:
|
|
||||||
- ./js/scripts/lint.sh
|
|
||||||
- ./js/scripts/test.sh
|
|
||||||
- ./js/scripts/build.sh
|
|
||||||
tags:
|
|
||||||
- javascript-test
|
|
||||||
js-release:
|
js-release:
|
||||||
stage: js-build
|
stage: js-build
|
||||||
only:
|
only:
|
||||||
@ -516,9 +512,11 @@ js-release:
|
|||||||
- stable
|
- stable
|
||||||
image: ethcore/rust:stable
|
image: ethcore/rust:stable
|
||||||
before_script:
|
before_script:
|
||||||
- if [[ $NIGHTLY != "master" ]]; then ./js/scripts/install-deps.sh; fi
|
- export JS_FILES_MODIFIED=$(git --no-pager diff --name-only $CI_BUILD_REF^ $CI_BUILD_REF | grep \.js | wc -l)
|
||||||
|
- echo $JS_FILES_MODIFIED
|
||||||
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/install-deps.sh;fi
|
||||||
script:
|
script:
|
||||||
- if [[ $NIGHTLY != "master" ]]; then ./js/scripts/build.sh; fi
|
- echo $JS_FILES_MODIFIED
|
||||||
- if [[ $NIGHTLY != "master" ]]; then ./js/scripts/release.sh; fi
|
- if [ "$JS_FILES_MODIFIED" = 0 ]; then echo "skip js build"; else ./js/scripts/build.sh&./js/scripts/release.sh; fi
|
||||||
tags:
|
tags:
|
||||||
- javascript
|
- javascript
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1263,7 +1263,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "parity-ui-precompiled"
|
name = "parity-ui-precompiled"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
source = "git+https://github.com/ethcore/js-precompiled.git#55687884fd6bee1a9c34c518f8c8db8ecdda85d3"
|
source = "git+https://github.com/ethcore/js-precompiled.git#7cb42b0c636f76eb478c9270a1e507ac3c3ba434"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9028c4801fd39fbb71a9796979182549a24e81c8
|
Subproject commit e8f4624b7f1a15c63674eecf577c7ab76c3b16be
|
@ -276,14 +276,20 @@ impl AccountProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `true` if the password for `account` is `password`. `false` if not.
|
/// Returns `true` if the password for `account` is `password`. `false` if not.
|
||||||
pub fn test_password(&self, account: &Address, password: String) -> Result<bool, Error> {
|
pub fn test_password(&self, account: &Address, password: &str) -> Result<bool, Error> {
|
||||||
match self.sstore.sign(account, &password, &Default::default()) {
|
match self.sstore.sign(account, password, &Default::default()) {
|
||||||
Ok(_) => Ok(true),
|
Ok(_) => Ok(true),
|
||||||
Err(SSError::InvalidPassword) => Ok(false),
|
Err(SSError::InvalidPassword) => Ok(false),
|
||||||
Err(e) => Err(Error::SStore(e)),
|
Err(e) => Err(Error::SStore(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Permanently removes an account.
|
||||||
|
pub fn kill_account(&self, account: &Address, password: &str) -> Result<(), Error> {
|
||||||
|
try!(self.sstore.remove_account(account, &password));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given.
|
/// Changes the password of `account` from `password` to `new_password`. Fails if incorrect `password` given.
|
||||||
pub fn change_password(&self, account: &Address, password: String, new_password: String) -> Result<(), Error> {
|
pub fn change_password(&self, account: &Address, password: String, new_password: String) -> Result<(), Error> {
|
||||||
self.sstore.change_password(account, &password, &new_password).map_err(Error::SStore)
|
self.sstore.change_password(account, &password, &new_password).map_err(Error::SStore)
|
||||||
|
@ -34,7 +34,7 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
|
|||||||
Some(x) if x < 1_150_000 => &old_schedule,
|
Some(x) if x < 1_150_000 => &old_schedule,
|
||||||
Some(_) => &new_schedule
|
Some(_) => &new_schedule
|
||||||
};
|
};
|
||||||
let allow_network_id_of_one = number.map_or(false, |n| n >= 3_500_000);
|
let allow_network_id_of_one = number.map_or(false, |n| n >= 2_675_000);
|
||||||
|
|
||||||
let rlp: Vec<u8> = test.rlp.into();
|
let rlp: Vec<u8> = test.rlp.into();
|
||||||
let res = UntrustedRlp::new(&rlp)
|
let res = UntrustedRlp::new(&rlp)
|
||||||
|
@ -128,6 +128,9 @@ impl<T> TraceDB<T> where T: DatabaseExtras {
|
|||||||
/// Creates new instance of `TraceDB`.
|
/// Creates new instance of `TraceDB`.
|
||||||
pub fn new(config: Config, tracesdb: Arc<Database>, extras: Arc<T>) -> Self {
|
pub fn new(config: Config, tracesdb: Arc<Database>, extras: Arc<T>) -> Self {
|
||||||
let mut batch = DBTransaction::new(&tracesdb);
|
let mut batch = DBTransaction::new(&tracesdb);
|
||||||
|
let genesis = extras.block_hash(0)
|
||||||
|
.expect("Genesis block is always inserted upon extras db creation qed");
|
||||||
|
batch.write(db::COL_TRACE, &genesis, &FlatBlockTraces::default());
|
||||||
batch.put(db::COL_TRACE, b"version", TRACE_DB_VER);
|
batch.put(db::COL_TRACE, b"version", TRACE_DB_VER);
|
||||||
tracesdb.write(batch).expect("failed to update version");
|
tracesdb.write(batch).expect("failed to update version");
|
||||||
|
|
||||||
@ -413,8 +416,12 @@ mod tests {
|
|||||||
struct NoopExtras;
|
struct NoopExtras;
|
||||||
|
|
||||||
impl DatabaseExtras for NoopExtras {
|
impl DatabaseExtras for NoopExtras {
|
||||||
fn block_hash(&self, _block_number: BlockNumber) -> Option<H256> {
|
fn block_hash(&self, block_number: BlockNumber) -> Option<H256> {
|
||||||
unimplemented!();
|
if block_number == 0 {
|
||||||
|
Some(H256::default())
|
||||||
|
} else {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_hash(&self, _block_number: BlockNumber, _tx_position: usize) -> Option<H256> {
|
fn transaction_hash(&self, _block_number: BlockNumber, _tx_position: usize) -> Option<H256> {
|
||||||
@ -581,35 +588,21 @@ mod tests {
|
|||||||
let db = Arc::new(Database::open(&DatabaseConfig::with_columns(::db::NUM_COLUMNS), temp.as_str()).unwrap());
|
let db = Arc::new(Database::open(&DatabaseConfig::with_columns(::db::NUM_COLUMNS), temp.as_str()).unwrap());
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
config.enabled = true;
|
config.enabled = true;
|
||||||
let block_0 = H256::from(0xa1);
|
let block_1 = H256::from(0xa1);
|
||||||
let block_1 = H256::from(0xa2);
|
let block_2 = H256::from(0xa2);
|
||||||
let tx_0 = H256::from(0xff);
|
let tx_1 = H256::from(0xff);
|
||||||
let tx_1 = H256::from(0xaf);
|
let tx_2 = H256::from(0xaf);
|
||||||
|
|
||||||
let mut extras = Extras::default();
|
let mut extras = Extras::default();
|
||||||
extras.block_hashes.insert(0, block_0.clone());
|
extras.block_hashes.insert(0, H256::default());
|
||||||
|
|
||||||
extras.block_hashes.insert(1, block_1.clone());
|
extras.block_hashes.insert(1, block_1.clone());
|
||||||
extras.transaction_hashes.insert(0, vec![tx_0.clone()]);
|
extras.block_hashes.insert(2, block_2.clone());
|
||||||
extras.transaction_hashes.insert(1, vec![tx_1.clone()]);
|
extras.transaction_hashes.insert(1, vec![tx_1.clone()]);
|
||||||
|
extras.transaction_hashes.insert(2, vec![tx_2.clone()]);
|
||||||
|
|
||||||
let tracedb = TraceDB::new(config, db.clone(), Arc::new(extras));
|
let tracedb = TraceDB::new(config, db.clone(), Arc::new(extras));
|
||||||
|
|
||||||
// import block 0
|
|
||||||
let request = create_simple_import_request(0, block_0.clone());
|
|
||||||
let mut batch = DBTransaction::new(&db);
|
|
||||||
tracedb.import(&mut batch, request);
|
|
||||||
db.write(batch).unwrap();
|
|
||||||
|
|
||||||
let filter = Filter {
|
|
||||||
range: (0..0),
|
|
||||||
from_address: AddressesFilter::from(vec![Address::from(1)]),
|
|
||||||
to_address: AddressesFilter::from(vec![]),
|
|
||||||
};
|
|
||||||
|
|
||||||
let traces = tracedb.filter(&filter);
|
|
||||||
assert_eq!(traces.len(), 1);
|
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
|
|
||||||
|
|
||||||
// import block 1
|
// import block 1
|
||||||
let request = create_simple_import_request(1, block_1.clone());
|
let request = create_simple_import_request(1, block_1.clone());
|
||||||
let mut batch = DBTransaction::new(&db);
|
let mut batch = DBTransaction::new(&db);
|
||||||
@ -617,38 +610,56 @@ mod tests {
|
|||||||
db.write(batch).unwrap();
|
db.write(batch).unwrap();
|
||||||
|
|
||||||
let filter = Filter {
|
let filter = Filter {
|
||||||
range: (0..1),
|
range: (1..1),
|
||||||
|
from_address: AddressesFilter::from(vec![Address::from(1)]),
|
||||||
|
to_address: AddressesFilter::from(vec![]),
|
||||||
|
};
|
||||||
|
|
||||||
|
let traces = tracedb.filter(&filter);
|
||||||
|
assert_eq!(traces.len(), 1);
|
||||||
|
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
||||||
|
|
||||||
|
// import block 2
|
||||||
|
let request = create_simple_import_request(2, block_2.clone());
|
||||||
|
let mut batch = DBTransaction::new(&db);
|
||||||
|
tracedb.import(&mut batch, request);
|
||||||
|
db.write(batch).unwrap();
|
||||||
|
|
||||||
|
let filter = Filter {
|
||||||
|
range: (1..2),
|
||||||
from_address: AddressesFilter::from(vec![Address::from(1)]),
|
from_address: AddressesFilter::from(vec![Address::from(1)]),
|
||||||
to_address: AddressesFilter::from(vec![]),
|
to_address: AddressesFilter::from(vec![]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let traces = tracedb.filter(&filter);
|
let traces = tracedb.filter(&filter);
|
||||||
assert_eq!(traces.len(), 2);
|
assert_eq!(traces.len(), 2);
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
|
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
||||||
assert_eq!(traces[1], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
assert_eq!(traces[1], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
|
||||||
|
|
||||||
let traces = tracedb.block_traces(0).unwrap();
|
assert!(tracedb.block_traces(0).is_some(), "Genesis trace should be always present.");
|
||||||
assert_eq!(traces.len(), 1);
|
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
|
|
||||||
|
|
||||||
let traces = tracedb.block_traces(1).unwrap();
|
let traces = tracedb.block_traces(1).unwrap();
|
||||||
assert_eq!(traces.len(), 1);
|
assert_eq!(traces.len(), 1);
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
||||||
|
|
||||||
assert_eq!(None, tracedb.block_traces(2));
|
let traces = tracedb.block_traces(2).unwrap();
|
||||||
|
|
||||||
let traces = tracedb.transaction_traces(0, 0).unwrap();
|
|
||||||
assert_eq!(traces.len(), 1);
|
assert_eq!(traces.len(), 1);
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
|
assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
|
||||||
|
|
||||||
|
assert_eq!(None, tracedb.block_traces(3));
|
||||||
|
|
||||||
let traces = tracedb.transaction_traces(1, 0).unwrap();
|
let traces = tracedb.transaction_traces(1, 0).unwrap();
|
||||||
assert_eq!(traces.len(), 1);
|
assert_eq!(traces.len(), 1);
|
||||||
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
assert_eq!(traces[0], create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
||||||
|
|
||||||
assert_eq!(None, tracedb.transaction_traces(1, 1));
|
let traces = tracedb.transaction_traces(2, 0).unwrap();
|
||||||
|
assert_eq!(traces.len(), 1);
|
||||||
|
assert_eq!(traces[0], create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
|
||||||
|
|
||||||
|
assert_eq!(None, tracedb.transaction_traces(2, 1));
|
||||||
|
|
||||||
assert_eq!(tracedb.trace(0, 0, vec![]).unwrap(), create_simple_localized_trace(0, block_0.clone(), tx_0.clone()));
|
|
||||||
assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone()));
|
||||||
|
assert_eq!(tracedb.trace(2, 0, vec![]).unwrap(), create_simple_localized_trace(2, block_2.clone(), tx_2.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -660,8 +671,10 @@ mod tests {
|
|||||||
let block_0 = H256::from(0xa1);
|
let block_0 = H256::from(0xa1);
|
||||||
let tx_0 = H256::from(0xff);
|
let tx_0 = H256::from(0xff);
|
||||||
|
|
||||||
extras.block_hashes.insert(0, block_0.clone());
|
extras.block_hashes.insert(0, H256::default());
|
||||||
extras.transaction_hashes.insert(0, vec![tx_0.clone()]);
|
extras.transaction_hashes.insert(0, vec![]);
|
||||||
|
extras.block_hashes.insert(1, block_0.clone());
|
||||||
|
extras.transaction_hashes.insert(1, vec![tx_0.clone()]);
|
||||||
|
|
||||||
// set tracing on
|
// set tracing on
|
||||||
config.enabled = true;
|
config.enabled = true;
|
||||||
@ -669,8 +682,8 @@ mod tests {
|
|||||||
{
|
{
|
||||||
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone()));
|
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone()));
|
||||||
|
|
||||||
// import block 0
|
// import block 1
|
||||||
let request = create_simple_import_request(0, block_0.clone());
|
let request = create_simple_import_request(1, block_0.clone());
|
||||||
let mut batch = DBTransaction::new(&db);
|
let mut batch = DBTransaction::new(&db);
|
||||||
tracedb.import(&mut batch, request);
|
tracedb.import(&mut batch, request);
|
||||||
db.write(batch).unwrap();
|
db.write(batch).unwrap();
|
||||||
@ -678,8 +691,28 @@ mod tests {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras));
|
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras));
|
||||||
let traces = tracedb.transaction_traces(0, 0);
|
let traces = tracedb.transaction_traces(1, 0);
|
||||||
assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(0, block_0, tx_0)]);
|
assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(1, block_0, tx_0)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn query_genesis() {
|
||||||
|
let temp = RandomTempPath::new();
|
||||||
|
let db = new_db(temp.as_str());
|
||||||
|
let mut config = Config::default();
|
||||||
|
let mut extras = Extras::default();
|
||||||
|
let block_0 = H256::from(0xa1);
|
||||||
|
|
||||||
|
extras.block_hashes.insert(0, block_0.clone());
|
||||||
|
extras.transaction_hashes.insert(0, vec![]);
|
||||||
|
|
||||||
|
// set tracing on
|
||||||
|
config.enabled = true;
|
||||||
|
|
||||||
|
let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone()));
|
||||||
|
let traces = tracedb.block_traces(0).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(traces.len(), 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ impl Into<Vec<FlatTrace>> for FlatTransactionTraces {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Represents all traces produced by transactions in a single block.
|
/// Represents all traces produced by transactions in a single block.
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone, Default)]
|
||||||
pub struct FlatBlockTraces(Vec<FlatTransactionTraces>);
|
pub struct FlatBlockTraces(Vec<FlatTransactionTraces>);
|
||||||
|
|
||||||
impl HeapSizeOf for FlatBlockTraces {
|
impl HeapSizeOf for FlatBlockTraces {
|
||||||
|
@ -47,7 +47,7 @@ impl Random for [u8; 32] {
|
|||||||
pub fn random_phrase(words: usize) -> String {
|
pub fn random_phrase(words: usize) -> String {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref WORDS: Vec<String> = String::from_utf8_lossy(include_bytes!("../res/wordlist.txt"))
|
static ref WORDS: Vec<String> = String::from_utf8_lossy(include_bytes!("../res/wordlist.txt"))
|
||||||
.split("\n")
|
.lines()
|
||||||
.map(|s| s.to_owned())
|
.map(|s| s.to_owned())
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
@ -55,8 +55,19 @@ pub fn random_phrase(words: usize) -> String {
|
|||||||
(0..words).map(|_| rng.choose(&WORDS).unwrap()).join(" ")
|
(0..words).map(|_| rng.choose(&WORDS).unwrap()).join(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::random_phrase;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_produce_right_number_of_words() {
|
fn should_produce_right_number_of_words() {
|
||||||
let p = random_phrase(10);
|
let p = random_phrase(10);
|
||||||
assert_eq!(p.split(" ").count(), 10);
|
assert_eq!(p.split(" ").count(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_not_include_carriage_return() {
|
||||||
|
let p = random_phrase(10);
|
||||||
|
assert!(!p.contains('\r'), "Carriage return should be trimmed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "parity.js",
|
"name": "parity.js",
|
||||||
"version": "0.2.69",
|
"version": "0.2.74",
|
||||||
"main": "release/index.js",
|
"main": "release/index.js",
|
||||||
"jsnext:main": "src/index.js",
|
"jsnext:main": "src/index.js",
|
||||||
"author": "Parity Team <admin@parity.io>",
|
"author": "Parity Team <admin@parity.io>",
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import { range } from 'lodash';
|
|
||||||
|
|
||||||
import { isArray, isHex, isInstanceOf, isString } from '../util/types';
|
import { isArray, isHex, isInstanceOf, isString } from '../util/types';
|
||||||
|
import { padLeft } from '../util/format';
|
||||||
|
|
||||||
export function inAddress (address) {
|
export function inAddress (address) {
|
||||||
// TODO: address validation if we have upper-lower addresses
|
// TODO: address validation if we have upper-lower addresses
|
||||||
@ -51,19 +51,20 @@ export function inHash (hash) {
|
|||||||
return inHex(hash);
|
return inHex(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pad (input, length) {
|
|
||||||
const value = inHex(input).substr(2, length * 2);
|
|
||||||
return '0x' + value + range(length * 2 - value.length).map(() => '0').join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function inTopics (_topics) {
|
export function inTopics (_topics) {
|
||||||
let topics = (_topics || [])
|
let topics = (_topics || [])
|
||||||
.filter((topic) => topic === null || topic)
|
.filter((topic) => topic === null || topic)
|
||||||
.map((topic) => topic === null ? null : pad(topic, 32));
|
.map((topic) => {
|
||||||
|
if (topic === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// while (topics.length < 4) {
|
if (Array.isArray(topic)) {
|
||||||
// topics.push(null);
|
return inTopics(topic);
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
return padLeft(topic, 32);
|
||||||
|
});
|
||||||
|
|
||||||
return topics;
|
return topics;
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,11 @@ export default class Parity {
|
|||||||
.then((accounts) => (accounts || []).map(outAddress));
|
.then((accounts) => (accounts || []).map(outAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
killAccount (account, password) {
|
||||||
|
return this._transport
|
||||||
|
.execute('parity_killAccount', inAddress(account), password);
|
||||||
|
}
|
||||||
|
|
||||||
listGethAccounts () {
|
listGethAccounts () {
|
||||||
return this._transport
|
return this._transport
|
||||||
.execute('parity_listGethAccounts')
|
.execute('parity_listGethAccounts')
|
||||||
|
@ -59,6 +59,7 @@ export default class Personal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (data.method) {
|
switch (data.method) {
|
||||||
|
case 'parity_killAccount':
|
||||||
case 'parity_importGethAccounts':
|
case 'parity_importGethAccounts':
|
||||||
case 'personal_newAccount':
|
case 'personal_newAccount':
|
||||||
case 'parity_newAccountFromPhrase':
|
case 'parity_newAccountFromPhrase':
|
||||||
|
@ -36,7 +36,8 @@ export const ERROR_CODES = {
|
|||||||
REQUEST_NOT_FOUND: -32042,
|
REQUEST_NOT_FOUND: -32042,
|
||||||
COMPILATION_ERROR: -32050,
|
COMPILATION_ERROR: -32050,
|
||||||
ENCRYPTION_ERROR: -32055,
|
ENCRYPTION_ERROR: -32055,
|
||||||
FETCH_ERROR: -32060
|
FETCH_ERROR: -32060,
|
||||||
|
INVALID_PARAMS: -32602
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class TransportError extends ExtendableError {
|
export default class TransportError extends ExtendableError {
|
||||||
|
@ -79,7 +79,7 @@ export default class Ws extends JsonRpcBase {
|
|||||||
this._ws.onclose = this._onClose;
|
this._ws.onclose = this._onClose;
|
||||||
this._ws.onmessage = this._onMessage;
|
this._ws.onmessage = this._onMessage;
|
||||||
|
|
||||||
// Get counts in dev mode
|
// Get counts in dev mode only
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
this._count = 0;
|
this._count = 0;
|
||||||
this._lastCount = {
|
this._lastCount = {
|
||||||
@ -93,8 +93,13 @@ export default class Ws extends JsonRpcBase {
|
|||||||
const s = Math.round(1000 * n / t) / 1000;
|
const s = Math.round(1000 * n / t) / 1000;
|
||||||
|
|
||||||
if (this._debug) {
|
if (this._debug) {
|
||||||
console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`);
|
console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`, `(+${n})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._lastCount = {
|
||||||
|
timestamp: Date.now(),
|
||||||
|
count: this._count
|
||||||
|
};
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
window._parityWS = this;
|
window._parityWS = this;
|
||||||
@ -117,6 +122,7 @@ export default class Ws extends JsonRpcBase {
|
|||||||
this._connected = false;
|
this._connected = false;
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
|
|
||||||
|
event.timestamp = Date.now();
|
||||||
this._lastError = event;
|
this._lastError = event;
|
||||||
|
|
||||||
if (this._autoConnect) {
|
if (this._autoConnect) {
|
||||||
@ -144,6 +150,8 @@ export default class Ws extends JsonRpcBase {
|
|||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
if (this._connected) {
|
if (this._connected) {
|
||||||
console.error('ws:onError', event);
|
console.error('ws:onError', event);
|
||||||
|
|
||||||
|
event.timestamp = Date.now();
|
||||||
this._lastError = event;
|
this._lastError = event;
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import { range } from 'lodash';
|
||||||
|
import { inHex } from '../format/input';
|
||||||
|
|
||||||
export function bytesToHex (bytes) {
|
export function bytesToHex (bytes) {
|
||||||
return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join('');
|
return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join('');
|
||||||
}
|
}
|
||||||
@ -33,3 +36,13 @@ export function hex2Ascii (_hex) {
|
|||||||
export function asciiToHex (string) {
|
export function asciiToHex (string) {
|
||||||
return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join('');
|
return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function padRight (input, length) {
|
||||||
|
const value = inHex(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);
|
||||||
|
return '0x' + range(length * 2 - value.length).map(() => '0').join('') + value;
|
||||||
|
}
|
||||||
|
@ -50,12 +50,12 @@ export default class ButtonBar extends Component {
|
|||||||
key='delete'
|
key='delete'
|
||||||
label='Delete'
|
label='Delete'
|
||||||
warning
|
warning
|
||||||
disabled={ !this.dappsStore.currentApp.isOwner && !this.dappsStore.isContractOwner }
|
disabled={ !this.dappsStore.currentApp || (!this.dappsStore.currentApp.isOwner && !this.dappsStore.isContractOwner) }
|
||||||
onClick={ this.onDeleteClick } />,
|
onClick={ this.onDeleteClick } />,
|
||||||
<Button
|
<Button
|
||||||
key='edit'
|
key='edit'
|
||||||
label='Edit'
|
label='Edit'
|
||||||
disabled={ !this.dappsStore.currentApp.isOwner }
|
disabled={ !this.dappsStore.currentApp || !this.dappsStore.currentApp.isOwner }
|
||||||
onClick={ this.onEditClick } />,
|
onClick={ this.onEditClick } />,
|
||||||
<Button
|
<Button
|
||||||
key='new'
|
key='new'
|
||||||
|
@ -33,6 +33,10 @@ export default class Dapp extends Component {
|
|||||||
? this.dappsStore.wipApp
|
? this.dappsStore.wipApp
|
||||||
: this.dappsStore.currentApp;
|
: this.dappsStore.currentApp;
|
||||||
|
|
||||||
|
if (!app) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ styles.app }>
|
<div className={ styles.app }>
|
||||||
{ this.dappsStore.isNew ? this.renderOwnerSelect(app) : this.renderOwnerStatic(app) }
|
{ this.dappsStore.isNew ? this.renderOwnerSelect(app) : this.renderOwnerStatic(app) }
|
||||||
|
@ -36,6 +36,10 @@ export default class SelectDapp extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.dappsStore.currentApp) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
let overlayImg = null;
|
let overlayImg = null;
|
||||||
if (this.dappsStore.currentApp.imageHash) {
|
if (this.dappsStore.currentApp.imageHash) {
|
||||||
overlayImg = (
|
overlayImg = (
|
||||||
|
@ -136,7 +136,10 @@ export default class DappsStore {
|
|||||||
.sort((a, b) => a.name.localeCompare(b.name));
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
this.apps = ownApps.concat(otherApps);
|
this.apps = ownApps.concat(otherApps);
|
||||||
|
|
||||||
|
if (this.apps.length) {
|
||||||
this.currentApp = this.apps[0];
|
this.currentApp = this.apps[0];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +331,7 @@ export default class DappsStore {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.sortApps();
|
this.sortApps();
|
||||||
this.setLoading(this.count === 0);
|
this.setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Store:loadDapps', error);
|
console.error('Store:loadDapps', error);
|
||||||
|
@ -127,7 +127,7 @@ export const subscribeEvents = () => (dispatch, getState) => {
|
|||||||
const params = log.params;
|
const params = log.params;
|
||||||
|
|
||||||
if (event === 'Registered' && type === 'pending') {
|
if (event === 'Registered' && type === 'pending') {
|
||||||
return dispatch(setTokenData(params.id.toNumber(), {
|
return dispatch(setTokenData(params.id.value.toNumber(), {
|
||||||
tla: '...',
|
tla: '...',
|
||||||
base: -1,
|
base: -1,
|
||||||
address: params.addr.value,
|
address: params.addr.value,
|
||||||
|
@ -238,6 +238,24 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
killAccount: {
|
||||||
|
desc: 'Deletes an account',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
type: Address,
|
||||||
|
desc: 'The account to remove'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: String,
|
||||||
|
desc: 'Account password'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: Boolean,
|
||||||
|
desc: 'true on success'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
listGethAccounts: {
|
listGethAccounts: {
|
||||||
desc: 'Returns a list of the accounts available from Geth',
|
desc: 'Returns a list of the accounts available from Geth',
|
||||||
params: [],
|
params: [],
|
||||||
|
@ -54,8 +54,6 @@ export default class RecoveryPhrase extends Component {
|
|||||||
<Input
|
<Input
|
||||||
hint='the account recovery phrase'
|
hint='the account recovery phrase'
|
||||||
label='account recovery phrase'
|
label='account recovery phrase'
|
||||||
multiLine
|
|
||||||
rows={ 1 }
|
|
||||||
value={ recoveryPhrase }
|
value={ recoveryPhrase }
|
||||||
onChange={ this.onEditPhrase } />
|
onChange={ this.onEditPhrase } />
|
||||||
<Input
|
<Input
|
||||||
@ -112,17 +110,23 @@ export default class RecoveryPhrase extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onEditPhrase = (event) => {
|
onEditPhrase = (event) => {
|
||||||
const value = event.target.value;
|
const recoveryPhrase = event.target.value
|
||||||
let error = null;
|
.toLowerCase() // wordlists are lowercase
|
||||||
|
.trim() // remove whitespace at both ends
|
||||||
|
.replace(/\s/g, ' ') // replace any whitespace with single space
|
||||||
|
.replace(/ +/g, ' '); // replace multiple spaces with a single space
|
||||||
|
|
||||||
if (!value || value.trim().length < 25) {
|
const parts = recoveryPhrase.split(' ');
|
||||||
error = ERRORS.noPhrase;
|
let recoveryPhraseError = null;
|
||||||
|
|
||||||
|
if (!recoveryPhrase || recoveryPhrase.length < 25 || parts.length < 8) {
|
||||||
|
recoveryPhraseError = ERRORS.noPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
recoveryPhrase: value,
|
recoveryPhrase,
|
||||||
recoveryPhraseError: error,
|
recoveryPhraseError,
|
||||||
isValidPhrase: !error
|
isValidPhrase: !recoveryPhraseError
|
||||||
}, this.updateParent);
|
}, this.updateParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
54
js/src/modals/DeleteAccount/deleteAccount.css
Normal file
54
js/src/modals/DeleteAccount/deleteAccount.css
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.body {
|
||||||
|
.hero {
|
||||||
|
padding-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nameinfo {
|
||||||
|
display: inline-block;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 1.25em;
|
||||||
|
padding-bottom: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.address {
|
||||||
|
}
|
||||||
|
|
||||||
|
.description {
|
||||||
|
padding-top: 1em;
|
||||||
|
font-size: 0.75em;
|
||||||
|
color: #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password {
|
||||||
|
padding: 1em 5em;
|
||||||
|
}
|
||||||
|
}
|
125
js/src/modals/DeleteAccount/deleteAccount.js
Normal file
125
js/src/modals/DeleteAccount/deleteAccount.js
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import React, { Component, PropTypes } from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import { bindActionCreators } from 'redux';
|
||||||
|
|
||||||
|
import { ConfirmDialog, IdentityIcon, IdentityName, Input } from '../../ui';
|
||||||
|
import { newError } from '../../redux/actions';
|
||||||
|
|
||||||
|
import styles from './deleteAccount.css';
|
||||||
|
|
||||||
|
class DeleteAccount extends Component {
|
||||||
|
static contextTypes = {
|
||||||
|
api: PropTypes.object.isRequired,
|
||||||
|
router: PropTypes.object
|
||||||
|
}
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
account: PropTypes.object.isRequired,
|
||||||
|
onClose: PropTypes.func.isRequired,
|
||||||
|
newError: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
state = {
|
||||||
|
password: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { account } = this.props;
|
||||||
|
const { password } = this.state;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ConfirmDialog
|
||||||
|
className={ styles.body }
|
||||||
|
title='confirm removal'
|
||||||
|
visible
|
||||||
|
onDeny={ this.closeDeleteDialog }
|
||||||
|
onConfirm={ this.onDeleteConfirmed }>
|
||||||
|
<div className={ styles.hero }>
|
||||||
|
Are you sure you want to permanently delete the following account?
|
||||||
|
</div>
|
||||||
|
<div className={ styles.info }>
|
||||||
|
<IdentityIcon
|
||||||
|
className={ styles.icon }
|
||||||
|
address={ account.address } />
|
||||||
|
<div className={ styles.nameinfo }>
|
||||||
|
<div className={ styles.header }>
|
||||||
|
<IdentityName address={ account.address } unknown />
|
||||||
|
</div>
|
||||||
|
<div className={ styles.address }>
|
||||||
|
{ account.address }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={ styles.description }>
|
||||||
|
{ account.meta.description }
|
||||||
|
</div>
|
||||||
|
<div className={ styles.password }>
|
||||||
|
<Input
|
||||||
|
label='account password'
|
||||||
|
hint='provide the account password to confirm the account deletion'
|
||||||
|
type='password'
|
||||||
|
value={ password }
|
||||||
|
onChange={ this.onChangePassword } />
|
||||||
|
</div>
|
||||||
|
</ConfirmDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onChangePassword = (event, password) => {
|
||||||
|
this.setState({ password });
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteConfirmed = () => {
|
||||||
|
const { api, router } = this.context;
|
||||||
|
const { account, newError } = this.props;
|
||||||
|
const { password } = this.state;
|
||||||
|
|
||||||
|
api.parity
|
||||||
|
.killAccount(account.address, password)
|
||||||
|
.then((result) => {
|
||||||
|
if (result === true) {
|
||||||
|
router.push('/accounts');
|
||||||
|
this.closeDeleteDialog();
|
||||||
|
} else {
|
||||||
|
newError(new Error('Deletion failed.'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error('onDeleteConfirmed', error);
|
||||||
|
newError(new Error(`Deletion failed: ${error.message}`));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
closeDeleteDialog = () => {
|
||||||
|
this.props.onClose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapStateToProps (state) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapDispatchToProps (dispatch) {
|
||||||
|
return bindActionCreators({ newError }, dispatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(DeleteAccount);
|
17
js/src/modals/DeleteAccount/index.js
Normal file
17
js/src/modals/DeleteAccount/index.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
export default from './deleteAccount';
|
@ -17,6 +17,7 @@
|
|||||||
import AddAddress from './AddAddress';
|
import AddAddress from './AddAddress';
|
||||||
import AddContract from './AddContract';
|
import AddContract from './AddContract';
|
||||||
import CreateAccount from './CreateAccount';
|
import CreateAccount from './CreateAccount';
|
||||||
|
import DeleteAccount from './DeleteAccount';
|
||||||
import DeployContract from './DeployContract';
|
import DeployContract from './DeployContract';
|
||||||
import EditMeta from './EditMeta';
|
import EditMeta from './EditMeta';
|
||||||
import ExecuteContract from './ExecuteContract';
|
import ExecuteContract from './ExecuteContract';
|
||||||
@ -32,6 +33,7 @@ export {
|
|||||||
AddAddress,
|
AddAddress,
|
||||||
AddContract,
|
AddContract,
|
||||||
CreateAccount,
|
CreateAccount,
|
||||||
|
DeleteAccount,
|
||||||
DeployContract,
|
DeployContract,
|
||||||
EditMeta,
|
EditMeta,
|
||||||
ExecuteContract,
|
ExecuteContract,
|
||||||
|
@ -16,68 +16,63 @@
|
|||||||
|
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
|
|
||||||
import { getBalances, getTokens } from './balancesActions';
|
import { loadTokens, setTokenReg, fetchBalances, fetchTokens, fetchTokensBalances } from './balancesActions';
|
||||||
import { setAddressImage } from './imagesActions';
|
import { padRight } from '../../api/util/format';
|
||||||
|
|
||||||
import Contracts from '../../contracts';
|
import Contracts from '../../contracts';
|
||||||
import * as abis from '../../contracts/abi';
|
|
||||||
|
|
||||||
import imagesEthereum from '../../../assets/images/contracts/ethereum-black-64x64.png';
|
|
||||||
|
|
||||||
const ETH = {
|
|
||||||
name: 'Ethereum',
|
|
||||||
tag: 'ETH',
|
|
||||||
image: imagesEthereum
|
|
||||||
};
|
|
||||||
|
|
||||||
export default class Balances {
|
export default class Balances {
|
||||||
constructor (store, api) {
|
constructor (store, api) {
|
||||||
this._api = api;
|
this._api = api;
|
||||||
this._store = store;
|
this._store = store;
|
||||||
|
|
||||||
this._tokens = {};
|
|
||||||
this._images = {};
|
|
||||||
|
|
||||||
this._accountsInfo = null;
|
|
||||||
this._tokenreg = null;
|
|
||||||
this._fetchingBalances = false;
|
|
||||||
this._fetchingTokens = false;
|
|
||||||
this._fetchedTokens = false;
|
|
||||||
|
|
||||||
this._tokenregSubId = null;
|
this._tokenregSubId = null;
|
||||||
this._tokenregMetaSubId = null;
|
this._tokenregMetaSubId = null;
|
||||||
|
|
||||||
// Throttled `retrieveTokens` function
|
// Throttled `retrieveTokens` function
|
||||||
// that gets called max once every 20s
|
// that gets called max once every 40s
|
||||||
this._throttledRetrieveTokens = throttle(
|
this.longThrottledFetch = throttle(
|
||||||
this._retrieveTokens,
|
this.fetchBalances,
|
||||||
20 * 1000,
|
40 * 1000,
|
||||||
|
{ trailing: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
this.shortThrottledFetch = throttle(
|
||||||
|
this.fetchBalances,
|
||||||
|
2 * 1000,
|
||||||
|
{ trailing: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fetch all tokens every 2 minutes
|
||||||
|
this.throttledTokensFetch = throttle(
|
||||||
|
this.fetchTokens,
|
||||||
|
60 * 1000,
|
||||||
{ trailing: true }
|
{ trailing: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
this._subscribeBlockNumber();
|
this.subscribeBlockNumber();
|
||||||
this._subscribeAccountsInfo();
|
this.subscribeAccountsInfo();
|
||||||
this._retrieveTokens();
|
|
||||||
|
this.loadTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
_subscribeAccountsInfo () {
|
subscribeAccountsInfo () {
|
||||||
this._api
|
this._api
|
||||||
.subscribe('parity_accountsInfo', (error, accountsInfo) => {
|
.subscribe('parity_accountsInfo', (error, accountsInfo) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._accountsInfo = accountsInfo;
|
this.fetchBalances();
|
||||||
this._retrieveTokens();
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('_subscribeAccountsInfo', error);
|
console.warn('_subscribeAccountsInfo', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_subscribeBlockNumber () {
|
subscribeBlockNumber () {
|
||||||
this._api
|
this._api
|
||||||
.subscribe('eth_blockNumber', (error) => {
|
.subscribe('eth_blockNumber', (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -86,123 +81,63 @@ export default class Balances {
|
|||||||
|
|
||||||
const { syncing } = this._store.getState().nodeStatus;
|
const { syncing } = this._store.getState().nodeStatus;
|
||||||
|
|
||||||
|
this.throttledTokensFetch();
|
||||||
|
|
||||||
// If syncing, only retrieve balances once every
|
// If syncing, only retrieve balances once every
|
||||||
// few seconds
|
// few seconds
|
||||||
if (syncing) {
|
if (syncing) {
|
||||||
return this._throttledRetrieveTokens();
|
this.shortThrottledFetch();
|
||||||
|
return this.longThrottledFetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._throttledRetrieveTokens.cancel();
|
this.longThrottledFetch.cancel();
|
||||||
this._retrieveTokens();
|
return this.shortThrottledFetch();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('_subscribeBlockNumber', error);
|
console.warn('_subscribeBlockNumber', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchBalances () {
|
||||||
|
this._store.dispatch(fetchBalances());
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchTokens () {
|
||||||
|
this._store.dispatch(fetchTokensBalances());
|
||||||
|
}
|
||||||
|
|
||||||
getTokenRegistry () {
|
getTokenRegistry () {
|
||||||
if (this._tokenreg) {
|
return Contracts.get().tokenReg.getContract();
|
||||||
return Promise.resolve(this._tokenreg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Contracts.get().tokenReg
|
loadTokens () {
|
||||||
.getContract()
|
|
||||||
.then((tokenreg) => {
|
|
||||||
this._tokenreg = tokenreg;
|
|
||||||
this.attachToTokens();
|
|
||||||
|
|
||||||
return tokenreg;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
_retrieveTokens () {
|
|
||||||
if (this._fetchingTokens) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._fetchedTokens) {
|
|
||||||
return this._retrieveBalances();
|
|
||||||
}
|
|
||||||
|
|
||||||
this._fetchingTokens = true;
|
|
||||||
this._fetchedTokens = false;
|
|
||||||
|
|
||||||
this
|
this
|
||||||
.getTokenRegistry()
|
.getTokenRegistry()
|
||||||
.then((tokenreg) => {
|
.then((tokenreg) => {
|
||||||
return tokenreg.instance.tokenCount
|
this._store.dispatch(setTokenReg(tokenreg));
|
||||||
.call()
|
this._store.dispatch(loadTokens());
|
||||||
.then((numTokens) => {
|
|
||||||
const promises = [];
|
|
||||||
|
|
||||||
for (let i = 0; i < numTokens.toNumber(); i++) {
|
return this.attachToTokens(tokenreg);
|
||||||
promises.push(this.fetchTokenInfo(tokenreg, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Promise.all(promises);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this._fetchingTokens = false;
|
|
||||||
this._fetchedTokens = true;
|
|
||||||
|
|
||||||
this._store.dispatch(getTokens(this._tokens));
|
|
||||||
this._retrieveBalances();
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('balances::_retrieveTokens', error);
|
console.warn('balances::loadTokens', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_retrieveBalances () {
|
attachToTokens (tokenreg) {
|
||||||
if (this._fetchingBalances) {
|
return Promise
|
||||||
return;
|
.all([
|
||||||
|
this.attachToTokenMetaChange(tokenreg),
|
||||||
|
this.attachToNewToken(tokenreg)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._accountsInfo) {
|
attachToNewToken (tokenreg) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._fetchingBalances = true;
|
|
||||||
|
|
||||||
const addresses = Object
|
|
||||||
.keys(this._accountsInfo)
|
|
||||||
.filter((address) => {
|
|
||||||
const account = this._accountsInfo[address];
|
|
||||||
return !account.meta || !account.meta.deleted;
|
|
||||||
});
|
|
||||||
|
|
||||||
this._balances = {};
|
|
||||||
|
|
||||||
Promise
|
|
||||||
.all(addresses.map((a) => this.fetchAccountBalance(a)))
|
|
||||||
.then((balances) => {
|
|
||||||
addresses.forEach((a, idx) => {
|
|
||||||
this._balances[a] = balances[idx];
|
|
||||||
});
|
|
||||||
|
|
||||||
this._store.dispatch(getBalances(this._balances));
|
|
||||||
this._fetchingBalances = false;
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.warn('_retrieveBalances', error);
|
|
||||||
this._fetchingBalances = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
attachToTokens () {
|
|
||||||
this.attachToTokenMetaChange();
|
|
||||||
this.attachToNewToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
attachToNewToken () {
|
|
||||||
if (this._tokenregSubId) {
|
if (this._tokenregSubId) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tokenreg
|
return tokenreg.instance.Registered
|
||||||
.instance
|
|
||||||
.Registered
|
|
||||||
.subscribe({
|
.subscribe({
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
toBlock: 'latest',
|
toBlock: 'latest',
|
||||||
@ -212,138 +147,38 @@ export default class Balances {
|
|||||||
return console.error('balances::attachToNewToken', 'failed to attach to tokenreg Registered', error.toString(), error.stack);
|
return console.error('balances::attachToNewToken', 'failed to attach to tokenreg Registered', error.toString(), error.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
const promises = logs.map((log) => {
|
this.handleTokensLogs(logs);
|
||||||
const id = log.params.id.value.toNumber();
|
|
||||||
return this.fetchTokenInfo(this._tokenreg, id);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.all(promises);
|
|
||||||
})
|
})
|
||||||
.then((tokenregSubId) => {
|
.then((tokenregSubId) => {
|
||||||
this._tokenregSubId = tokenregSubId;
|
this._tokenregSubId = tokenregSubId;
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.warn('balances::attachToNewToken', e);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
attachToTokenMetaChange () {
|
attachToTokenMetaChange (tokenreg) {
|
||||||
if (this._tokenregMetaSubId) {
|
if (this._tokenregMetaSubId) {
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tokenreg
|
return tokenreg.instance.MetaChanged
|
||||||
.instance
|
|
||||||
.MetaChanged
|
|
||||||
.subscribe({
|
.subscribe({
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
toBlock: 'latest',
|
toBlock: 'latest',
|
||||||
topics: [ null, this._api.util.asciiToHex('IMG') ],
|
topics: [ null, padRight(this._api.util.asciiToHex('IMG'), 32) ],
|
||||||
skipInitFetch: true
|
skipInitFetch: true
|
||||||
}, (error, logs) => {
|
}, (error, logs) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return console.error('balances::attachToTokenMetaChange', 'failed to attach to tokenreg MetaChanged', error.toString(), error.stack);
|
return console.error('balances::attachToTokenMetaChange', 'failed to attach to tokenreg MetaChanged', error.toString(), error.stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case multiple logs for same token
|
this.handleTokensLogs(logs);
|
||||||
// in one block. Take the last value.
|
|
||||||
const tokens = logs
|
|
||||||
.filter((log) => log.type === 'mined')
|
|
||||||
.reduce((_tokens, log) => {
|
|
||||||
const id = log.params.id.value.toNumber();
|
|
||||||
const image = log.params.value.value;
|
|
||||||
|
|
||||||
const token = Object.values(this._tokens).find((c) => c.id === id);
|
|
||||||
const { address } = token;
|
|
||||||
|
|
||||||
_tokens[address] = { address, id, image };
|
|
||||||
return _tokens;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
Object
|
|
||||||
.values(tokens)
|
|
||||||
.forEach((token) => {
|
|
||||||
const { address, image } = token;
|
|
||||||
|
|
||||||
if (this._images[address] !== image.toString()) {
|
|
||||||
this._store.dispatch(setAddressImage(address, image));
|
|
||||||
this._images[address] = image.toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.then((tokenregMetaSubId) => {
|
.then((tokenregMetaSubId) => {
|
||||||
this._tokenregMetaSubId = tokenregMetaSubId;
|
this._tokenregMetaSubId = tokenregMetaSubId;
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.warn('balances::attachToTokenMetaChange', e);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchTokenInfo (tokenreg, tokenId) {
|
handleTokensLogs (logs) {
|
||||||
return Promise
|
const tokenIds = logs.map((log) => log.params.id.value.toNumber());
|
||||||
.all([
|
this._store.dispatch(fetchTokens(tokenIds));
|
||||||
tokenreg.instance.token.call({}, [tokenId]),
|
|
||||||
tokenreg.instance.meta.call({}, [tokenId, 'IMG'])
|
|
||||||
])
|
|
||||||
.then(([ tokenData, image ]) => {
|
|
||||||
const [ address, tag, format, name ] = tokenData;
|
|
||||||
const contract = this._api.newContract(abis.eip20, address);
|
|
||||||
|
|
||||||
if (this._images[address] !== image.toString()) {
|
|
||||||
this._store.dispatch(setAddressImage(address, image));
|
|
||||||
this._images[address] = image.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = {
|
|
||||||
format: format.toString(),
|
|
||||||
id: tokenId,
|
|
||||||
|
|
||||||
address,
|
|
||||||
tag,
|
|
||||||
name,
|
|
||||||
contract
|
|
||||||
};
|
|
||||||
|
|
||||||
this._tokens[address] = token;
|
|
||||||
|
|
||||||
return token;
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
console.warn('balances::fetchTokenInfo', `couldn't fetch token #${tokenId}`, e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO?: txCount is only shown on an address page, so we
|
|
||||||
* might not need to fetch it for each address for each block,
|
|
||||||
* but only for one address when the user is on the account
|
|
||||||
* view.
|
|
||||||
*/
|
|
||||||
fetchAccountBalance (address) {
|
|
||||||
const _tokens = Object.values(this._tokens);
|
|
||||||
const tokensPromises = _tokens
|
|
||||||
.map((token) => {
|
|
||||||
return token.contract.instance.balanceOf.call({}, [ address ]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise
|
|
||||||
.all([
|
|
||||||
this._api.eth.getTransactionCount(address),
|
|
||||||
this._api.eth.getBalance(address)
|
|
||||||
].concat(tokensPromises))
|
|
||||||
.then(([ txCount, ethBalance, ...tokensBalance ]) => {
|
|
||||||
const tokens = []
|
|
||||||
.concat(
|
|
||||||
{ token: ETH, value: ethBalance },
|
|
||||||
_tokens
|
|
||||||
.map((token, index) => ({
|
|
||||||
token,
|
|
||||||
value: tokensBalance[index]
|
|
||||||
}))
|
|
||||||
);
|
|
||||||
|
|
||||||
const balance = { txCount, tokens };
|
|
||||||
return balance;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,354 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export function getBalances (balances) {
|
import { range, uniq, isEqual } from 'lodash';
|
||||||
|
|
||||||
|
import { hashToImageUrl } from './imagesReducer';
|
||||||
|
import { setAddressImage } from './imagesActions';
|
||||||
|
|
||||||
|
import * as ABIS from '../../contracts/abi';
|
||||||
|
import imagesEthereum from '../../../assets/images/contracts/ethereum-black-64x64.png';
|
||||||
|
|
||||||
|
const ETH = {
|
||||||
|
name: 'Ethereum',
|
||||||
|
tag: 'ETH',
|
||||||
|
image: imagesEthereum
|
||||||
|
};
|
||||||
|
|
||||||
|
export function setBalances (balances) {
|
||||||
return {
|
return {
|
||||||
type: 'getBalances',
|
type: 'setBalances',
|
||||||
balances
|
balances
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTokens (tokens) {
|
export function setTokens (tokens) {
|
||||||
return {
|
return {
|
||||||
type: 'getTokens',
|
type: 'setTokens',
|
||||||
tokens
|
tokens
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setTokenReg (tokenreg) {
|
||||||
|
return {
|
||||||
|
type: 'setTokenReg',
|
||||||
|
tokenreg
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTokensFilter (tokensFilter) {
|
||||||
|
return {
|
||||||
|
type: 'setTokensFilter',
|
||||||
|
tokensFilter
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTokenImage (tokenAddress, image) {
|
||||||
|
return {
|
||||||
|
type: 'setTokenImage',
|
||||||
|
tokenAddress, image
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadTokens () {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { tokenreg } = getState().balances;
|
||||||
|
|
||||||
|
return tokenreg.instance.tokenCount
|
||||||
|
.call()
|
||||||
|
.then((numTokens) => {
|
||||||
|
const tokenIds = range(numTokens.toNumber());
|
||||||
|
dispatch(fetchTokens(tokenIds));
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::loadTokens', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchTokens (_tokenIds) {
|
||||||
|
const tokenIds = uniq(_tokenIds || []);
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { api, images, balances } = getState();
|
||||||
|
const { tokenreg } = balances;
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all(tokenIds.map((id) => fetchTokenInfo(tokenreg, id, api)))
|
||||||
|
.then((tokens) => {
|
||||||
|
// dispatch only the changed images
|
||||||
|
tokens
|
||||||
|
.forEach((token) => {
|
||||||
|
const { image, address } = token;
|
||||||
|
|
||||||
|
if (images[address] === image) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(setTokenImage(address, image));
|
||||||
|
dispatch(setAddressImage(address, image, true));
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(setTokens(tokens));
|
||||||
|
dispatch(fetchBalances());
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchTokens', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchBalances (_addresses) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { api, personal } = getState();
|
||||||
|
const { visibleAccounts } = personal;
|
||||||
|
|
||||||
|
const addresses = uniq(_addresses || visibleAccounts || []);
|
||||||
|
|
||||||
|
if (addresses.length === 0) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullFetch = addresses.length === 1;
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all(addresses.map((addr) => fetchAccount(addr, api, fullFetch)))
|
||||||
|
.then((accountsBalances) => {
|
||||||
|
const balances = {};
|
||||||
|
|
||||||
|
addresses.forEach((addr, idx) => {
|
||||||
|
balances[addr] = accountsBalances[idx];
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(setBalances(balances));
|
||||||
|
updateTokensFilter(addresses)(dispatch, getState);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchBalances', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateTokensFilter (_addresses, _tokens) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { api, balances, personal } = getState();
|
||||||
|
const { visibleAccounts } = personal;
|
||||||
|
const { tokensFilter } = balances;
|
||||||
|
|
||||||
|
const addresses = uniq(_addresses || visibleAccounts || []).sort();
|
||||||
|
const tokens = _tokens || Object.values(balances.tokens) || [];
|
||||||
|
const tokenAddresses = tokens.map((t) => t.address).sort();
|
||||||
|
|
||||||
|
if (tokensFilter.filterFromId || tokensFilter.filterToId) {
|
||||||
|
const sameTokens = isEqual(tokenAddresses, tokensFilter.tokenAddresses);
|
||||||
|
const sameAddresses = isEqual(addresses, tokensFilter.addresses);
|
||||||
|
|
||||||
|
if (sameTokens && sameAddresses) {
|
||||||
|
return queryTokensFilter(tokensFilter)(dispatch, getState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let promise = Promise.resolve();
|
||||||
|
|
||||||
|
if (tokensFilter.filterFromId) {
|
||||||
|
promise = promise.then(() => api.eth.uninstallFilter(tokensFilter.filterFromId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokensFilter.filterToId) {
|
||||||
|
promise = promise.then(() => api.eth.uninstallFilter(tokensFilter.filterToId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tokenAddresses.length === 0 || addresses.length === 0) {
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
const TRANSFER_SIGNATURE = api.util.sha3('Transfer(address,address,uint256)');
|
||||||
|
const topicsFrom = [ TRANSFER_SIGNATURE, addresses, null ];
|
||||||
|
const topicsTo = [ TRANSFER_SIGNATURE, null, addresses ];
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
fromBlock: 0,
|
||||||
|
toBlock: 'pending',
|
||||||
|
address: tokenAddresses
|
||||||
|
};
|
||||||
|
|
||||||
|
const optionsFrom = {
|
||||||
|
...options,
|
||||||
|
topics: topicsFrom
|
||||||
|
};
|
||||||
|
|
||||||
|
const optionsTo = {
|
||||||
|
...options,
|
||||||
|
topics: topicsTo
|
||||||
|
};
|
||||||
|
|
||||||
|
const newFilters = Promise.all([
|
||||||
|
api.eth.newFilter(optionsFrom),
|
||||||
|
api.eth.newFilter(optionsTo)
|
||||||
|
]);
|
||||||
|
|
||||||
|
promise
|
||||||
|
.then(() => newFilters)
|
||||||
|
.then(([ filterFromId, filterToId ]) => {
|
||||||
|
const nextTokensFilter = {
|
||||||
|
filterFromId, filterToId,
|
||||||
|
addresses, tokenAddresses
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch(setTokensFilter(nextTokensFilter));
|
||||||
|
fetchTokensBalances(addresses, tokens)(dispatch, getState);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::updateTokensFilter', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryTokensFilter (tokensFilter) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { api, personal, balances } = getState();
|
||||||
|
const { visibleAccounts } = personal;
|
||||||
|
const visibleAddresses = visibleAccounts.map((a) => a.toLowerCase());
|
||||||
|
|
||||||
|
Promise
|
||||||
|
.all([
|
||||||
|
api.eth.getFilterChanges(tokensFilter.filterFromId),
|
||||||
|
api.eth.getFilterChanges(tokensFilter.filterToId)
|
||||||
|
])
|
||||||
|
.then(([ logsFrom, logsTo ]) => {
|
||||||
|
const addresses = [];
|
||||||
|
const tokenAddresses = [];
|
||||||
|
|
||||||
|
logsFrom
|
||||||
|
.concat(logsTo)
|
||||||
|
.forEach((log) => {
|
||||||
|
const tokenAddress = log.address;
|
||||||
|
const fromAddress = '0x' + log.topics[1].slice(-40);
|
||||||
|
const toAddress = '0x' + log.topics[2].slice(-40);
|
||||||
|
|
||||||
|
const fromIdx = visibleAddresses.indexOf(fromAddress);
|
||||||
|
const toIdx = visibleAddresses.indexOf(toAddress);
|
||||||
|
|
||||||
|
if (fromIdx > -1) {
|
||||||
|
addresses.push(visibleAccounts[fromIdx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (toIdx > -1) {
|
||||||
|
addresses.push(visibleAccounts[toIdx]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tokenAddresses.push(tokenAddress);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (addresses.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tokens = balances.tokens.filter((t) => tokenAddresses.includes(t.address));
|
||||||
|
|
||||||
|
fetchTokensBalances(uniq(addresses), tokens)(dispatch, getState);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fetchTokensBalances (_addresses = null, _tokens = null) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { api, personal, balances } = getState();
|
||||||
|
const { visibleAccounts } = personal;
|
||||||
|
|
||||||
|
const addresses = _addresses || visibleAccounts;
|
||||||
|
const tokens = _tokens || Object.values(balances.tokens);
|
||||||
|
|
||||||
|
if (addresses.length === 0) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all(addresses.map((addr) => fetchTokensBalance(addr, tokens, api)))
|
||||||
|
.then((tokensBalances) => {
|
||||||
|
const balances = {};
|
||||||
|
|
||||||
|
addresses.forEach((addr, idx) => {
|
||||||
|
balances[addr] = tokensBalances[idx];
|
||||||
|
});
|
||||||
|
|
||||||
|
dispatch(setBalances(balances));
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchTokensBalances', error);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchAccount (address, api, full = false) {
|
||||||
|
const promises = [ api.eth.getBalance(address) ];
|
||||||
|
|
||||||
|
if (full) {
|
||||||
|
promises.push(api.eth.getTransactionCount(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all(promises)
|
||||||
|
.then(([ ethBalance, txCount ]) => {
|
||||||
|
const tokens = [ { token: ETH, value: ethBalance } ];
|
||||||
|
const balance = { tokens };
|
||||||
|
|
||||||
|
if (full) {
|
||||||
|
balance.txCount = txCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return balance;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchAccountBalance', `couldn't fetch balance for account #${address}`, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchTokensBalance (address, _tokens, api) {
|
||||||
|
const tokensPromises = _tokens
|
||||||
|
.map((token) => {
|
||||||
|
return token.contract.instance.balanceOf.call({}, [ address ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
return Promise
|
||||||
|
.all(tokensPromises)
|
||||||
|
.then((tokensBalance) => {
|
||||||
|
const tokens = _tokens
|
||||||
|
.map((token, index) => ({
|
||||||
|
token,
|
||||||
|
value: tokensBalance[index]
|
||||||
|
}));
|
||||||
|
|
||||||
|
const balance = { tokens };
|
||||||
|
return balance;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchTokensBalance', `couldn't fetch tokens balance for account #${address}`, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchTokenInfo (tokenreg, tokenId, api, dispatch) {
|
||||||
|
return Promise
|
||||||
|
.all([
|
||||||
|
tokenreg.instance.token.call({}, [tokenId]),
|
||||||
|
tokenreg.instance.meta.call({}, [tokenId, 'IMG'])
|
||||||
|
])
|
||||||
|
.then(([ tokenData, image ]) => {
|
||||||
|
const [ address, tag, format, name ] = tokenData;
|
||||||
|
const contract = api.newContract(ABIS.eip20, address);
|
||||||
|
|
||||||
|
const token = {
|
||||||
|
format: format.toString(),
|
||||||
|
id: tokenId,
|
||||||
|
image: hashToImageUrl(image),
|
||||||
|
address,
|
||||||
|
tag,
|
||||||
|
name,
|
||||||
|
contract
|
||||||
|
};
|
||||||
|
|
||||||
|
return token;
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.warn('balances::fetchTokenInfo', `couldn't fetch token #${tokenId}`, error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -15,22 +15,102 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
|
import BigNumber from 'bignumber.js';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
balances: {},
|
balances: {},
|
||||||
tokens: {}
|
tokens: {},
|
||||||
|
tokenreg: null,
|
||||||
|
tokensFilter: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
getBalances (state, action) {
|
setBalances (state, action) {
|
||||||
const { balances } = action;
|
const nextBalances = action.balances;
|
||||||
|
const prevBalances = state.balances;
|
||||||
|
const balances = { ...prevBalances };
|
||||||
|
|
||||||
|
Object.keys(nextBalances).forEach((address) => {
|
||||||
|
if (!balances[address]) {
|
||||||
|
balances[address] = Object.assign({}, nextBalances[address]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const balance = Object.assign({}, balances[address]);
|
||||||
|
const { tokens, txCount = balance.txCount } = nextBalances[address];
|
||||||
|
const nextTokens = [].concat(balance.tokens);
|
||||||
|
|
||||||
|
tokens.forEach((t) => {
|
||||||
|
const { token, value } = t;
|
||||||
|
const { tag } = token;
|
||||||
|
|
||||||
|
const tokenIndex = nextTokens.findIndex((tok) => tok.token.tag === tag);
|
||||||
|
|
||||||
|
if (tokenIndex === -1) {
|
||||||
|
nextTokens.push({
|
||||||
|
token,
|
||||||
|
value
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
nextTokens[tokenIndex] = { token, value };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
balances[address] = Object.assign({}, { txCount: txCount || new BigNumber(0), tokens: nextTokens });
|
||||||
|
});
|
||||||
|
|
||||||
return Object.assign({}, state, { balances });
|
return Object.assign({}, state, { balances });
|
||||||
},
|
},
|
||||||
|
|
||||||
getTokens (state, action) {
|
setTokens (state, action) {
|
||||||
const { tokens } = action;
|
const { tokens } = action;
|
||||||
|
|
||||||
|
if (Array.isArray(tokens)) {
|
||||||
|
const objTokens = tokens.reduce((_tokens, token) => {
|
||||||
|
_tokens[token.address] = token;
|
||||||
|
return _tokens;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
return Object.assign({}, state, { tokens: objTokens });
|
||||||
|
}
|
||||||
|
|
||||||
return Object.assign({}, state, { tokens });
|
return Object.assign({}, state, { tokens });
|
||||||
|
},
|
||||||
|
|
||||||
|
setTokenImage (state, action) {
|
||||||
|
const { tokenAddress, image } = action;
|
||||||
|
const { balances } = state;
|
||||||
|
const nextBalances = {};
|
||||||
|
|
||||||
|
Object.keys(balances).forEach((address) => {
|
||||||
|
const tokenIndex = balances[address].tokens.findIndex((t) => t.token.address === tokenAddress);
|
||||||
|
|
||||||
|
if (tokenIndex === -1 || balances[address].tokens[tokenIndex].value.equals(0)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const tokens = [].concat(balances[address].tokens);
|
||||||
|
tokens[tokenIndex].token = {
|
||||||
|
...tokens[tokenIndex].token,
|
||||||
|
image
|
||||||
|
};
|
||||||
|
|
||||||
|
nextBalances[address] = {
|
||||||
|
...balances[address],
|
||||||
|
tokens
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return Object.assign({}, state, { balance: { ...balances, nextBalances } });
|
||||||
|
},
|
||||||
|
|
||||||
|
setTokenReg (state, action) {
|
||||||
|
const { tokenreg } = action;
|
||||||
|
return Object.assign({}, state, { tokenreg });
|
||||||
|
},
|
||||||
|
|
||||||
|
setTokensFilter (state, action) {
|
||||||
|
const { tokensFilter } = action;
|
||||||
|
return Object.assign({}, state, { tokensFilter });
|
||||||
}
|
}
|
||||||
}, initialState);
|
}, initialState);
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export function setAddressImage (address, hashArray) {
|
export function setAddressImage (address, hashArray, converted = false) {
|
||||||
return {
|
return {
|
||||||
type: 'setAddressImage',
|
type: 'setAddressImage',
|
||||||
address,
|
address,
|
||||||
hashArray
|
hashArray,
|
||||||
|
converted
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,12 @@ export function hashToImageUrl (hashArray) {
|
|||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
setAddressImage (state, action) {
|
setAddressImage (state, action) {
|
||||||
const { address, hashArray } = action;
|
const { address, hashArray, converted } = action;
|
||||||
|
|
||||||
|
const image = converted ? hashArray : hashToImageUrl(hashArray);
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
[address]: hashToImageUrl(hashArray)
|
[address]: image
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, initialState);
|
}, initialState);
|
||||||
|
@ -14,9 +14,33 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
|
import { fetchBalances } from './balancesActions';
|
||||||
|
|
||||||
export function personalAccountsInfo (accountsInfo) {
|
export function personalAccountsInfo (accountsInfo) {
|
||||||
return {
|
return {
|
||||||
type: 'personalAccountsInfo',
|
type: 'personalAccountsInfo',
|
||||||
accountsInfo
|
accountsInfo
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function _setVisibleAccounts (addresses) {
|
||||||
|
return {
|
||||||
|
type: 'setVisibleAccounts',
|
||||||
|
addresses
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setVisibleAccounts (addresses) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const { visibleAccounts } = getState().personal;
|
||||||
|
|
||||||
|
if (isEqual(addresses.sort(), visibleAccounts.sort())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(fetchBalances(addresses));
|
||||||
|
dispatch(_setVisibleAccounts(addresses));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import { handleActions } from 'redux-actions';
|
import { handleActions } from 'redux-actions';
|
||||||
|
import { isEqual } from 'lodash';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
accountsInfo: {},
|
accountsInfo: {},
|
||||||
@ -23,7 +24,8 @@ const initialState = {
|
|||||||
contacts: {},
|
contacts: {},
|
||||||
hasContacts: false,
|
hasContacts: false,
|
||||||
contracts: {},
|
contracts: {},
|
||||||
hasContracts: false
|
hasContracts: false,
|
||||||
|
visibleAccounts: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
@ -55,5 +57,17 @@ export default handleActions({
|
|||||||
contracts,
|
contracts,
|
||||||
hasContracts: Object.keys(contracts).length !== 0
|
hasContracts: Object.keys(contracts).length !== 0
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
setVisibleAccounts (state, action) {
|
||||||
|
const addresses = (action.addresses || []).sort();
|
||||||
|
|
||||||
|
if (isEqual(addresses, state.addresses)) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
visibleAccounts: addresses
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, initialState);
|
}, initialState);
|
||||||
|
@ -30,6 +30,8 @@ export default class Status {
|
|||||||
|
|
||||||
this._pollPingTimeoutId = null;
|
this._pollPingTimeoutId = null;
|
||||||
this._longStatusTimeoutId = null;
|
this._longStatusTimeoutId = null;
|
||||||
|
|
||||||
|
this._timestamp = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
@ -131,10 +133,10 @@ export default class Status {
|
|||||||
secureToken
|
secureToken
|
||||||
};
|
};
|
||||||
|
|
||||||
const gotReconnected = !this._apiStatus.isConnected && apiStatus.isConnected;
|
const gotConnected = !this._apiStatus.isConnected && apiStatus.isConnected;
|
||||||
|
|
||||||
if (gotReconnected) {
|
if (gotConnected) {
|
||||||
this._pollLongStatus(true);
|
this._pollLongStatus();
|
||||||
this._store.dispatch(statusCollection({ isPingable: true }));
|
this._store.dispatch(statusCollection({ isPingable: true }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,20 +158,22 @@ export default class Status {
|
|||||||
|
|
||||||
const { refreshStatus } = this._store.getState().nodeStatus;
|
const { refreshStatus } = this._store.getState().nodeStatus;
|
||||||
|
|
||||||
const statusPromises = [ this._api.eth.syncing(), this._api.parity.netPeers() ];
|
const statusPromises = [ this._api.eth.syncing() ];
|
||||||
|
|
||||||
if (refreshStatus) {
|
if (refreshStatus) {
|
||||||
|
statusPromises.push(this._api.parity.netPeers());
|
||||||
statusPromises.push(this._api.eth.hashrate());
|
statusPromises.push(this._api.eth.hashrate());
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise
|
Promise
|
||||||
.all(statusPromises)
|
.all(statusPromises)
|
||||||
.then(([ syncing, netPeers, ...statusResults ]) => {
|
.then(([ syncing, ...statusResults ]) => {
|
||||||
const status = statusResults.length === 0
|
const status = statusResults.length === 0
|
||||||
? { syncing, netPeers }
|
? { syncing }
|
||||||
: {
|
: {
|
||||||
syncing, netPeers,
|
syncing,
|
||||||
hashrate: statusResults[0]
|
netPeers: statusResults[0],
|
||||||
|
hashrate: statusResults[1]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isEqual(status, this._status)) {
|
if (!isEqual(status, this._status)) {
|
||||||
@ -223,7 +227,7 @@ export default class Status {
|
|||||||
* fetched every 30s just in case, and whenever
|
* fetched every 30s just in case, and whenever
|
||||||
* the client got reconnected.
|
* the client got reconnected.
|
||||||
*/
|
*/
|
||||||
_pollLongStatus = (newConnection = false) => {
|
_pollLongStatus = () => {
|
||||||
if (!this._api.isConnected) {
|
if (!this._api.isConnected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -241,31 +245,33 @@ export default class Status {
|
|||||||
|
|
||||||
Promise
|
Promise
|
||||||
.all([
|
.all([
|
||||||
|
this._api.parity.netPeers(),
|
||||||
this._api.web3.clientVersion(),
|
this._api.web3.clientVersion(),
|
||||||
|
this._api.net.version(),
|
||||||
this._api.parity.defaultExtraData(),
|
this._api.parity.defaultExtraData(),
|
||||||
this._api.parity.netChain(),
|
this._api.parity.netChain(),
|
||||||
this._api.parity.netPort(),
|
this._api.parity.netPort(),
|
||||||
this._api.parity.rpcSettings(),
|
this._api.parity.rpcSettings(),
|
||||||
newConnection ? Promise.resolve(null) : this._api.parity.enode()
|
this._api.parity.enode()
|
||||||
])
|
])
|
||||||
.then(([
|
.then(([
|
||||||
clientVersion, defaultExtraData, netChain, netPort, rpcSettings, enode
|
netPeers, clientVersion, netVersion, defaultExtraData, netChain, netPort, rpcSettings, enode
|
||||||
]) => {
|
]) => {
|
||||||
const isTest = netChain === 'morden' || netChain === 'ropsten' || netChain === 'testnet';
|
const isTest =
|
||||||
|
netVersion === '2' || // morden
|
||||||
|
netVersion === '3'; // ropsten
|
||||||
|
|
||||||
const longStatus = {
|
const longStatus = {
|
||||||
|
netPeers,
|
||||||
clientVersion,
|
clientVersion,
|
||||||
defaultExtraData,
|
defaultExtraData,
|
||||||
netChain,
|
netChain,
|
||||||
netPort,
|
netPort,
|
||||||
rpcSettings,
|
rpcSettings,
|
||||||
isTest
|
isTest,
|
||||||
|
enode
|
||||||
};
|
};
|
||||||
|
|
||||||
if (enode) {
|
|
||||||
longStatus.enode = enode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isEqual(longStatus, this._longStatus)) {
|
if (!isEqual(longStatus, this._longStatus)) {
|
||||||
this._store.dispatch(statusCollection(longStatus));
|
this._store.dispatch(statusCollection(longStatus));
|
||||||
this._longStatus = longStatus;
|
this._longStatus = longStatus;
|
||||||
@ -275,7 +281,7 @@ export default class Status {
|
|||||||
console.error('_pollLongStatus', error);
|
console.error('_pollLongStatus', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
nextTimeout(newConnection ? 5000 : 30000);
|
nextTimeout(60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pollLogs = () => {
|
_pollLogs = () => {
|
||||||
|
@ -43,7 +43,7 @@ const initialState = {
|
|||||||
isConnected: false,
|
isConnected: false,
|
||||||
isConnecting: false,
|
isConnecting: false,
|
||||||
isPingable: false,
|
isPingable: false,
|
||||||
isTest: false,
|
isTest: undefined,
|
||||||
refreshStatus: false,
|
refreshStatus: false,
|
||||||
traceMode: undefined
|
traceMode: undefined
|
||||||
};
|
};
|
||||||
|
@ -77,6 +77,12 @@ export default class SecureApi extends Api {
|
|||||||
return this
|
return this
|
||||||
._checkNodeUp()
|
._checkNodeUp()
|
||||||
.then((isNodeUp) => {
|
.then((isNodeUp) => {
|
||||||
|
const { timestamp } = lastError;
|
||||||
|
|
||||||
|
if ((Date.now() - timestamp) > 250) {
|
||||||
|
return nextTick();
|
||||||
|
}
|
||||||
|
|
||||||
const nextToken = this._tokensToTry[0] || 'initial';
|
const nextToken = this._tokensToTry[0] || 'initial';
|
||||||
const nextState = nextToken !== 'initial' ? 0 : 1;
|
const nextState = nextToken !== 'initial' ? 0 : 1;
|
||||||
|
|
||||||
@ -89,7 +95,7 @@ export default class SecureApi extends Api {
|
|||||||
this.updateToken(nextToken, nextState);
|
this.updateToken(nextToken, nextState);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTick();
|
return nextTick();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -44,7 +44,7 @@ class BlockStatus extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!syncing.warpChunksAmount.eq(syncing.warpChunksProcessed)) {
|
if (syncing.warpChunksAmount && syncing.warpChunksProcessed && !syncing.warpChunksAmount.eq(syncing.warpChunksProcessed)) {
|
||||||
return (
|
return (
|
||||||
<div className={ styles.syncStatus }>
|
<div className={ styles.syncStatus }>
|
||||||
{ syncing.warpChunksProcessed.mul(100).div(syncing.warpChunksAmount).toFormat(2) }% warp restore
|
{ syncing.warpChunksProcessed.mul(100).div(syncing.warpChunksAmount).toFormat(2) }% warp restore
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: flex-end;
|
align-items: baseline;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,35 +144,17 @@ export default class Input extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderCopyButton () {
|
renderCopyButton () {
|
||||||
const { allowCopy, label, hint, floatCopy } = this.props;
|
const { allowCopy, hideUnderline } = this.props;
|
||||||
const { value } = this.state;
|
const { value } = this.state;
|
||||||
|
|
||||||
if (!allowCopy) {
|
if (!allowCopy) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = {
|
|
||||||
marginBottom: 13
|
|
||||||
};
|
|
||||||
|
|
||||||
const text = typeof allowCopy === 'string'
|
const text = typeof allowCopy === 'string'
|
||||||
? allowCopy
|
? allowCopy
|
||||||
: value;
|
: value;
|
||||||
|
|
||||||
if (!label) {
|
const style = hideUnderline ? {} : { position: 'relative', top: '2px' };
|
||||||
style.marginBottom = 2;
|
|
||||||
} else if (label && !hint) {
|
|
||||||
style.marginBottom = 4;
|
|
||||||
} else if (label && hint) {
|
|
||||||
style.marginBottom = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (floatCopy) {
|
|
||||||
style.position = 'absolute';
|
|
||||||
style.left = -24;
|
|
||||||
style.bottom = style.marginBottom;
|
|
||||||
style.marginBottom = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ styles.copy } style={ style }>
|
<div className={ styles.copy } style={ style }>
|
||||||
|
@ -28,20 +28,7 @@ export default class Header extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
account: PropTypes.object,
|
account: PropTypes.object,
|
||||||
balance: PropTypes.object,
|
balance: PropTypes.object
|
||||||
isTest: PropTypes.bool
|
|
||||||
}
|
|
||||||
|
|
||||||
state = {
|
|
||||||
name: null
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillMount () {
|
|
||||||
this.setName();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps () {
|
|
||||||
this.setName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -87,13 +74,13 @@ export default class Header extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderTxCount () {
|
renderTxCount () {
|
||||||
const { isTest, balance } = this.props;
|
const { balance } = this.props;
|
||||||
|
|
||||||
if (!balance) {
|
if (!balance) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const txCount = balance.txCount.sub(isTest ? 0x100000 : 0);
|
const { txCount } = balance;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ styles.infoline }>
|
<div className={ styles.infoline }>
|
||||||
@ -101,28 +88,4 @@ export default class Header extends Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmitName = (name) => {
|
|
||||||
const { api } = this.context;
|
|
||||||
const { account } = this.props;
|
|
||||||
|
|
||||||
this.setState({ name }, () => {
|
|
||||||
api.parity
|
|
||||||
.setAccountName(account.address, name)
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
setName () {
|
|
||||||
const { account } = this.props;
|
|
||||||
|
|
||||||
if (account && account.name !== this.propName) {
|
|
||||||
this.propName = account.name;
|
|
||||||
this.setState({
|
|
||||||
name: account.name
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,12 @@ class Transactions extends Component {
|
|||||||
getTransactions = (props) => {
|
getTransactions = (props) => {
|
||||||
const { isTest, address, traceMode } = props;
|
const { isTest, address, traceMode } = props;
|
||||||
|
|
||||||
|
// Don't fetch the transactions if we don't know in which
|
||||||
|
// network we are yet...
|
||||||
|
if (isTest === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
.fetchTransactions(isTest, address, traceMode)
|
.fetchTransactions(isTest, address, traceMode)
|
||||||
.then(transactions => {
|
.then(transactions => {
|
||||||
|
@ -17,18 +17,20 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
import ActionDelete from 'material-ui/svg-icons/action/delete';
|
||||||
import ContentCreate from 'material-ui/svg-icons/content/create';
|
import ContentCreate from 'material-ui/svg-icons/content/create';
|
||||||
import ContentSend from 'material-ui/svg-icons/content/send';
|
import ContentSend from 'material-ui/svg-icons/content/send';
|
||||||
import LockIcon from 'material-ui/svg-icons/action/lock';
|
import LockIcon from 'material-ui/svg-icons/action/lock';
|
||||||
import VerifyIcon from 'material-ui/svg-icons/action/verified-user';
|
import VerifyIcon from 'material-ui/svg-icons/action/verified-user';
|
||||||
|
|
||||||
import { EditMeta, Shapeshift, SMSVerification, Transfer, PasswordManager } from '../../modals';
|
import { EditMeta, DeleteAccount, Shapeshift, SMSVerification, Transfer, PasswordManager } from '../../modals';
|
||||||
import { Actionbar, Button, Page } from '../../ui';
|
import { Actionbar, Button, Page } from '../../ui';
|
||||||
|
|
||||||
import shapeshiftBtn from '../../../assets/images/shapeshift-btn.png';
|
import shapeshiftBtn from '../../../assets/images/shapeshift-btn.png';
|
||||||
|
|
||||||
import Header from './Header';
|
import Header from './Header';
|
||||||
import Transactions from './Transactions';
|
import Transactions from './Transactions';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import VerificationStore from '../../modals/SMSVerification/store';
|
import VerificationStore from '../../modals/SMSVerification/store';
|
||||||
|
|
||||||
@ -40,16 +42,18 @@ class Account extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
images: PropTypes.object.isRequired,
|
||||||
|
|
||||||
params: PropTypes.object,
|
params: PropTypes.object,
|
||||||
accounts: PropTypes.object,
|
accounts: PropTypes.object,
|
||||||
balances: PropTypes.object,
|
balances: PropTypes.object
|
||||||
images: PropTypes.object.isRequired,
|
|
||||||
isTest: PropTypes.bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
propName = null
|
propName = null
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
showDeleteDialog: false,
|
||||||
showEditDialog: false,
|
showEditDialog: false,
|
||||||
showFundDialog: false,
|
showFundDialog: false,
|
||||||
showVerificationDialog: false,
|
showVerificationDialog: false,
|
||||||
@ -62,12 +66,32 @@ class Account extends Component {
|
|||||||
const { api } = this.context;
|
const { api } = this.context;
|
||||||
const { address } = this.props.params;
|
const { address } = this.props.params;
|
||||||
|
|
||||||
const store = new VerificationStore(api, address);
|
const verificationStore = new VerificationStore(api, address);
|
||||||
this.setState({ verificationStore: store });
|
this.setState({ verificationStore });
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
const prevAddress = this.props.params.address;
|
||||||
|
const nextAddress = nextProps.params.address;
|
||||||
|
|
||||||
|
if (prevAddress !== nextAddress) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { params, setVisibleAccounts } = props;
|
||||||
|
const addresses = [ params.address ];
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { accounts, balances, isTest } = this.props;
|
const { accounts, balances } = this.props;
|
||||||
const { address } = this.props.params;
|
const { address } = this.props.params;
|
||||||
|
|
||||||
const account = (accounts || {})[address];
|
const account = (accounts || {})[address];
|
||||||
@ -79,6 +103,7 @@ class Account extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ styles.account }>
|
<div className={ styles.account }>
|
||||||
|
{ this.renderDeleteDialog(account) }
|
||||||
{ this.renderEditDialog(account) }
|
{ this.renderEditDialog(account) }
|
||||||
{ this.renderFundDialog() }
|
{ this.renderFundDialog() }
|
||||||
{ this.renderVerificationDialog() }
|
{ this.renderVerificationDialog() }
|
||||||
@ -87,7 +112,6 @@ class Account extends Component {
|
|||||||
{ this.renderActionbar() }
|
{ this.renderActionbar() }
|
||||||
<Page>
|
<Page>
|
||||||
<Header
|
<Header
|
||||||
isTest={ isTest }
|
|
||||||
account={ account }
|
account={ account }
|
||||||
balance={ balance } />
|
balance={ balance } />
|
||||||
<Transactions
|
<Transactions
|
||||||
@ -131,7 +155,12 @@ class Account extends Component {
|
|||||||
key='passwordManager'
|
key='passwordManager'
|
||||||
icon={ <LockIcon /> }
|
icon={ <LockIcon /> }
|
||||||
label='password'
|
label='password'
|
||||||
onClick={ this.onPasswordClick } />
|
onClick={ this.onPasswordClick } />,
|
||||||
|
<Button
|
||||||
|
key='delete'
|
||||||
|
icon={ <ActionDelete /> }
|
||||||
|
label='delete account'
|
||||||
|
onClick={ this.onDeleteClick } />
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -141,6 +170,20 @@ class Account extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderDeleteDialog (account) {
|
||||||
|
const { showDeleteDialog } = this.state;
|
||||||
|
|
||||||
|
if (!showDeleteDialog) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DeleteAccount
|
||||||
|
account={ account }
|
||||||
|
onClose={ this.onDeleteClose } />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
renderEditDialog (account) {
|
renderEditDialog (account) {
|
||||||
const { showEditDialog } = this.state;
|
const { showEditDialog } = this.state;
|
||||||
|
|
||||||
@ -228,6 +271,14 @@ class Account extends Component {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDeleteClick = () => {
|
||||||
|
this.setState({ showDeleteDialog: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeleteClose = () => {
|
||||||
|
this.setState({ showDeleteDialog: false });
|
||||||
|
}
|
||||||
|
|
||||||
onEditClick = () => {
|
onEditClick = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showEditDialog: !this.state.showEditDialog
|
showEditDialog: !this.state.showEditDialog
|
||||||
@ -277,10 +328,8 @@ function mapStateToProps (state) {
|
|||||||
const { accounts } = state.personal;
|
const { accounts } = state.personal;
|
||||||
const { balances } = state.balances;
|
const { balances } = state.balances;
|
||||||
const { images } = state;
|
const { images } = state;
|
||||||
const { isTest } = state.nodeStatus;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isTest,
|
|
||||||
accounts,
|
accounts,
|
||||||
balances,
|
balances,
|
||||||
images
|
images
|
||||||
@ -288,7 +337,9 @@ function mapStateToProps (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({}, dispatch);
|
return bindActionCreators({
|
||||||
|
setVisibleAccounts
|
||||||
|
}, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -117,14 +117,14 @@ export default class List extends Component {
|
|||||||
if (balanceA && !balanceB) return -1;
|
if (balanceA && !balanceB) return -1;
|
||||||
if (!balanceA && balanceB) return 1;
|
if (!balanceA && balanceB) return 1;
|
||||||
|
|
||||||
const ethA = balanceA.tokens
|
const ethA = balanceA.tokens.find(token => token.token.tag.toLowerCase() === 'eth');
|
||||||
.find(token => token.token.tag.toLowerCase() === 'eth')
|
const ethB = balanceB.tokens.find(token => token.token.tag.toLowerCase() === 'eth');
|
||||||
.value;
|
|
||||||
const ethB = balanceB.tokens
|
|
||||||
.find(token => token.token.tag.toLowerCase() === 'eth')
|
|
||||||
.value;
|
|
||||||
|
|
||||||
return -1 * ethA.comparedTo(ethB);
|
if (!ethA && !ethB) return 0;
|
||||||
|
if (ethA && !ethB) return -1;
|
||||||
|
if (!ethA && ethB) return 1;
|
||||||
|
|
||||||
|
return -1 * ethA.value.comparedTo(ethB.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'tags') {
|
if (key === 'tags') {
|
||||||
|
@ -38,10 +38,6 @@ export default class Summary extends Component {
|
|||||||
noLink: false
|
noLink: false
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
|
||||||
name: 'Unnamed'
|
|
||||||
};
|
|
||||||
|
|
||||||
shouldComponentUpdate (nextProps) {
|
shouldComponentUpdate (nextProps) {
|
||||||
const prev = {
|
const prev = {
|
||||||
link: this.props.link, name: this.props.name,
|
link: this.props.link, name: this.props.name,
|
||||||
@ -66,8 +62,8 @@ export default class Summary extends Component {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevValues = prevTokens.map((t) => t.value.toNumber());
|
const prevValues = prevTokens.map((t) => ({ value: t.value.toNumber(), image: t.token.image }));
|
||||||
const nextValues = nextTokens.map((t) => t.value.toNumber());
|
const nextValues = nextTokens.map((t) => ({ value: t.value.toNumber(), image: t.token.image }));
|
||||||
|
|
||||||
if (!isEqual(prevValues, nextValues)) {
|
if (!isEqual(prevValues, nextValues)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,11 +18,12 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import ContentAdd from 'material-ui/svg-icons/content/add';
|
import ContentAdd from 'material-ui/svg-icons/content/add';
|
||||||
import { uniq } from 'lodash';
|
import { uniq, isEqual } from 'lodash';
|
||||||
|
|
||||||
import List from './List';
|
import List from './List';
|
||||||
import { CreateAccount } from '../../modals';
|
import { CreateAccount } from '../../modals';
|
||||||
import { Actionbar, ActionbarExport, ActionbarSearch, ActionbarSort, Button, Page, Tooltip } from '../../ui';
|
import { Actionbar, ActionbarExport, ActionbarSearch, ActionbarSort, Button, Page, Tooltip } from '../../ui';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import styles from './accounts.css';
|
import styles from './accounts.css';
|
||||||
|
|
||||||
@ -32,6 +33,8 @@ class Accounts extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
|
||||||
accounts: PropTypes.object,
|
accounts: PropTypes.object,
|
||||||
hasAccounts: PropTypes.bool,
|
hasAccounts: PropTypes.bool,
|
||||||
balances: PropTypes.object
|
balances: PropTypes.object
|
||||||
@ -50,6 +53,27 @@ class Accounts extends Component {
|
|||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
this.setState({ show: true });
|
this.setState({ show: true });
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
const prevAddresses = Object.keys(this.props.accounts);
|
||||||
|
const nextAddresses = Object.keys(nextProps.accounts);
|
||||||
|
|
||||||
|
if (prevAddresses.length !== nextAddresses.length || !isEqual(prevAddresses.sort(), nextAddresses.sort())) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { accounts, setVisibleAccounts } = props;
|
||||||
|
const addresses = Object.keys(accounts);
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -206,7 +230,9 @@ function mapStateToProps (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({}, dispatch);
|
return bindActionCreators({
|
||||||
|
setVisibleAccounts
|
||||||
|
}, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -26,6 +26,7 @@ import { Actionbar, Button, Page } from '../../ui';
|
|||||||
import Header from '../Account/Header';
|
import Header from '../Account/Header';
|
||||||
import Transactions from '../Account/Transactions';
|
import Transactions from '../Account/Transactions';
|
||||||
import Delete from './Delete';
|
import Delete from './Delete';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import styles from './address.css';
|
import styles from './address.css';
|
||||||
|
|
||||||
@ -36,9 +37,10 @@ class Address extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
|
||||||
contacts: PropTypes.object,
|
contacts: PropTypes.object,
|
||||||
balances: PropTypes.object,
|
balances: PropTypes.object,
|
||||||
isTest: PropTypes.bool,
|
|
||||||
params: PropTypes.object
|
params: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,8 +49,31 @@ class Address extends Component {
|
|||||||
showEditDialog: false
|
showEditDialog: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidMount () {
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
const prevAddress = this.props.params.address;
|
||||||
|
const nextAddress = nextProps.params.address;
|
||||||
|
|
||||||
|
if (prevAddress !== nextAddress) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { params, setVisibleAccounts } = props;
|
||||||
|
const addresses = [ params.address ];
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { contacts, balances, isTest } = this.props;
|
const { contacts, balances } = this.props;
|
||||||
const { address } = this.props.params;
|
const { address } = this.props.params;
|
||||||
const { showDeleteDialog } = this.state;
|
const { showDeleteDialog } = this.state;
|
||||||
|
|
||||||
@ -70,7 +95,6 @@ class Address extends Component {
|
|||||||
onClose={ this.closeDeleteDialog } />
|
onClose={ this.closeDeleteDialog } />
|
||||||
<Page>
|
<Page>
|
||||||
<Header
|
<Header
|
||||||
isTest={ isTest }
|
|
||||||
account={ contact }
|
account={ contact }
|
||||||
balance={ balance } />
|
balance={ balance } />
|
||||||
<Transactions
|
<Transactions
|
||||||
@ -134,17 +158,17 @@ class Address extends Component {
|
|||||||
function mapStateToProps (state) {
|
function mapStateToProps (state) {
|
||||||
const { contacts } = state.personal;
|
const { contacts } = state.personal;
|
||||||
const { balances } = state.balances;
|
const { balances } = state.balances;
|
||||||
const { isTest } = state.nodeStatus;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isTest,
|
|
||||||
contacts,
|
contacts,
|
||||||
balances
|
balances
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({}, dispatch);
|
return bindActionCreators({
|
||||||
|
setVisibleAccounts
|
||||||
|
}, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -18,12 +18,13 @@ import React, { Component, PropTypes } from 'react';
|
|||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import ContentAdd from 'material-ui/svg-icons/content/add';
|
import ContentAdd from 'material-ui/svg-icons/content/add';
|
||||||
import { uniq } from 'lodash';
|
import { uniq, isEqual } from 'lodash';
|
||||||
|
|
||||||
import List from '../Accounts/List';
|
import List from '../Accounts/List';
|
||||||
import Summary from '../Accounts/Summary';
|
import Summary from '../Accounts/Summary';
|
||||||
import { AddAddress } from '../../modals';
|
import { AddAddress } from '../../modals';
|
||||||
import { Actionbar, ActionbarExport, ActionbarImport, ActionbarSearch, ActionbarSort, Button, Page } from '../../ui';
|
import { Actionbar, ActionbarExport, ActionbarImport, ActionbarSearch, ActionbarSort, Button, Page } from '../../ui';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import styles from './addresses.css';
|
import styles from './addresses.css';
|
||||||
|
|
||||||
@ -33,6 +34,8 @@ class Addresses extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
|
||||||
balances: PropTypes.object,
|
balances: PropTypes.object,
|
||||||
contacts: PropTypes.object,
|
contacts: PropTypes.object,
|
||||||
hasContacts: PropTypes.bool
|
hasContacts: PropTypes.bool
|
||||||
@ -45,6 +48,29 @@ class Addresses extends Component {
|
|||||||
searchTokens: []
|
searchTokens: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillMount () {
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
const prevAddresses = Object.keys(this.props.contacts);
|
||||||
|
const nextAddresses = Object.keys(nextProps.contacts);
|
||||||
|
|
||||||
|
if (prevAddresses.length !== nextAddresses.length || !isEqual(prevAddresses.sort(), nextAddresses.sort())) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { contacts, setVisibleAccounts } = props;
|
||||||
|
const addresses = Object.keys(contacts);
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { balances, contacts, hasContacts } = this.props;
|
const { balances, contacts, hasContacts } = this.props;
|
||||||
const { searchValues, sortOrder } = this.state;
|
const { searchValues, sortOrder } = this.state;
|
||||||
@ -231,7 +257,9 @@ function mapStateToProps (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({}, dispatch);
|
return bindActionCreators({
|
||||||
|
setVisibleAccounts
|
||||||
|
}, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -24,6 +24,8 @@ import EyeIcon from 'material-ui/svg-icons/image/remove-red-eye';
|
|||||||
import ContentClear from 'material-ui/svg-icons/content/clear';
|
import ContentClear from 'material-ui/svg-icons/content/clear';
|
||||||
|
|
||||||
import { newError } from '../../redux/actions';
|
import { newError } from '../../redux/actions';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import { EditMeta, ExecuteContract } from '../../modals';
|
import { EditMeta, ExecuteContract } from '../../modals';
|
||||||
import { Actionbar, Button, Page, Modal, Editor } from '../../ui';
|
import { Actionbar, Button, Page, Modal, Editor } from '../../ui';
|
||||||
|
|
||||||
@ -41,6 +43,8 @@ class Contract extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
|
||||||
accounts: PropTypes.object,
|
accounts: PropTypes.object,
|
||||||
balances: PropTypes.object,
|
balances: PropTypes.object,
|
||||||
contracts: PropTypes.object,
|
contracts: PropTypes.object,
|
||||||
@ -68,21 +72,29 @@ class Contract extends Component {
|
|||||||
|
|
||||||
this.attachContract(this.props);
|
this.attachContract(this.props);
|
||||||
this.setBaseAccount(this.props);
|
this.setBaseAccount(this.props);
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
|
||||||
api
|
api
|
||||||
.subscribe('eth_blockNumber', this.queryContract)
|
.subscribe('eth_blockNumber', this.queryContract)
|
||||||
.then(blockSubscriptionId => this.setState({ blockSubscriptionId }));
|
.then(blockSubscriptionId => this.setState({ blockSubscriptionId }));
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps (newProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
const { accounts, contracts } = newProps;
|
const { accounts, contracts } = nextProps;
|
||||||
|
|
||||||
if (Object.keys(contracts).length !== Object.keys(this.props.contracts).length) {
|
if (Object.keys(contracts).length !== Object.keys(this.props.contracts).length) {
|
||||||
this.attachContract(newProps);
|
this.attachContract(nextProps);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(accounts).length !== Object.keys(this.props.accounts).length) {
|
if (Object.keys(accounts).length !== Object.keys(this.props.accounts).length) {
|
||||||
this.setBaseAccount(newProps);
|
this.setBaseAccount(nextProps);
|
||||||
|
}
|
||||||
|
|
||||||
|
const prevAddress = this.props.params.address;
|
||||||
|
const nextAddress = nextProps.params.address;
|
||||||
|
|
||||||
|
if (prevAddress !== nextAddress) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +104,13 @@ class Contract extends Component {
|
|||||||
|
|
||||||
api.unsubscribe(blockSubscriptionId);
|
api.unsubscribe(blockSubscriptionId);
|
||||||
contract.unsubscribe(subscriptionId);
|
contract.unsubscribe(subscriptionId);
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { params, setVisibleAccounts } = props;
|
||||||
|
const addresses = [ params.address ];
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@ -112,7 +131,6 @@ class Contract extends Component {
|
|||||||
{ this.renderExecuteDialog() }
|
{ this.renderExecuteDialog() }
|
||||||
<Page>
|
<Page>
|
||||||
<Header
|
<Header
|
||||||
isTest={ isTest }
|
|
||||||
account={ account }
|
account={ account }
|
||||||
balance={ balance } />
|
balance={ balance } />
|
||||||
<Queries
|
<Queries
|
||||||
@ -430,7 +448,7 @@ function mapStateToProps (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({ newError }, dispatch);
|
return bindActionCreators({ newError, setVisibleAccounts }, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -20,10 +20,11 @@ import { connect } from 'react-redux';
|
|||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import ContentAdd from 'material-ui/svg-icons/content/add';
|
import ContentAdd from 'material-ui/svg-icons/content/add';
|
||||||
import FileIcon from 'material-ui/svg-icons/action/description';
|
import FileIcon from 'material-ui/svg-icons/action/description';
|
||||||
import { uniq } from 'lodash';
|
import { uniq, isEqual } from 'lodash';
|
||||||
|
|
||||||
import { Actionbar, ActionbarSearch, ActionbarSort, Button, Page } from '../../ui';
|
import { Actionbar, ActionbarSearch, ActionbarSort, Button, Page } from '../../ui';
|
||||||
import { AddContract, DeployContract } from '../../modals';
|
import { AddContract, DeployContract } from '../../modals';
|
||||||
|
import { setVisibleAccounts } from '../../redux/providers/personalActions';
|
||||||
|
|
||||||
import List from '../Accounts/List';
|
import List from '../Accounts/List';
|
||||||
|
|
||||||
@ -35,6 +36,8 @@ class Contracts extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
setVisibleAccounts: PropTypes.func.isRequired,
|
||||||
|
|
||||||
balances: PropTypes.object,
|
balances: PropTypes.object,
|
||||||
accounts: PropTypes.object,
|
accounts: PropTypes.object,
|
||||||
contracts: PropTypes.object,
|
contracts: PropTypes.object,
|
||||||
@ -49,6 +52,29 @@ class Contracts extends Component {
|
|||||||
searchTokens: []
|
searchTokens: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillMount () {
|
||||||
|
this.setVisibleAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps (nextProps) {
|
||||||
|
const prevAddresses = Object.keys(this.props.contracts);
|
||||||
|
const nextAddresses = Object.keys(nextProps.contracts);
|
||||||
|
|
||||||
|
if (prevAddresses.length !== nextAddresses.length || !isEqual(prevAddresses.sort(), nextAddresses.sort())) {
|
||||||
|
this.setVisibleAccounts(nextProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.setVisibleAccounts([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleAccounts (props = this.props) {
|
||||||
|
const { contracts, setVisibleAccounts } = props;
|
||||||
|
const addresses = Object.keys(contracts);
|
||||||
|
setVisibleAccounts(addresses);
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { contracts, hasContracts, balances } = this.props;
|
const { contracts, hasContracts, balances } = this.props;
|
||||||
const { searchValues, sortOrder } = this.state;
|
const { searchValues, sortOrder } = this.state;
|
||||||
@ -205,7 +231,9 @@ function mapStateToProps (state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mapDispatchToProps (dispatch) {
|
function mapDispatchToProps (dispatch) {
|
||||||
return bindActionCreators({}, dispatch);
|
return bindActionCreators({
|
||||||
|
setVisibleAccounts
|
||||||
|
}, dispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -63,7 +63,7 @@ export default class Dapp extends Component {
|
|||||||
className={ styles.frame }
|
className={ styles.frame }
|
||||||
frameBorder={ 0 }
|
frameBorder={ 0 }
|
||||||
name={ name }
|
name={ name }
|
||||||
sandbox='allow-same-origin allow-scripts'
|
sandbox='allow-forms allow-popups allow-same-origin allow-scripts'
|
||||||
scrolling='auto'
|
scrolling='auto'
|
||||||
src={ src }>
|
src={ src }>
|
||||||
</iframe>
|
</iframe>
|
||||||
|
@ -54,5 +54,15 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"visible": true,
|
"visible": true,
|
||||||
"secure": true
|
"secure": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "0x7bbc4f1a27628781b96213e781a1b8eec6982c1db8fac739af6e4c5a55862c03",
|
||||||
|
"url": "dappreg",
|
||||||
|
"name": "Dapp Registration",
|
||||||
|
"description": "Enables the registration and content management of dapps on the network",
|
||||||
|
"author": "Parity Team <admin@ethcore.io>",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"visible": false,
|
||||||
|
"secure": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -32,6 +32,8 @@ export default class DappsStore {
|
|||||||
@observable modalOpen = false;
|
@observable modalOpen = false;
|
||||||
@observable externalOverlayVisible = true;
|
@observable externalOverlayVisible = true;
|
||||||
|
|
||||||
|
_manifests = {};
|
||||||
|
|
||||||
constructor (api) {
|
constructor (api) {
|
||||||
this._api = api;
|
this._api = api;
|
||||||
|
|
||||||
@ -255,12 +257,27 @@ export default class DappsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_fetchManifest (manifestHash) {
|
_fetchManifest (manifestHash) {
|
||||||
|
if (/^(0x)?0+/.test(manifestHash)) {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._manifests[manifestHash]) {
|
||||||
|
return Promise.resolve(this._manifests[manifestHash]);
|
||||||
|
}
|
||||||
|
|
||||||
return fetch(`${this._getHost()}/api/content/${manifestHash}/`, { redirect: 'follow', mode: 'cors' })
|
return fetch(`${this._getHost()}/api/content/${manifestHash}/`, { redirect: 'follow', mode: 'cors' })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
return response.ok
|
return response.ok
|
||||||
? response.json()
|
? response.json()
|
||||||
: null;
|
: null;
|
||||||
})
|
})
|
||||||
|
.then((manifest) => {
|
||||||
|
if (manifest) {
|
||||||
|
this._manifests[manifestHash] = manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
return manifest;
|
||||||
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.warn('DappsStore:fetchManifest', error);
|
console.warn('DappsStore:fetchManifest', error);
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,9 +26,8 @@ extern crate time;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
use std::{env, thread};
|
use std::{env, thread, fs};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::fs::File;
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use isatty::{stderr_isatty, stdout_isatty};
|
use isatty::{stderr_isatty, stdout_isatty};
|
||||||
use env_logger::LogBuilder;
|
use env_logger::LogBuilder;
|
||||||
@ -80,9 +79,13 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
|
|||||||
let enable_color = config.color && isatty;
|
let enable_color = config.color && isatty;
|
||||||
let logs = Arc::new(RotatingLogger::new(levels));
|
let logs = Arc::new(RotatingLogger::new(levels));
|
||||||
let logger = logs.clone();
|
let logger = logs.clone();
|
||||||
|
let mut open_options = fs::OpenOptions::new();
|
||||||
|
|
||||||
let maybe_file = match config.file.as_ref() {
|
let maybe_file = match config.file.as_ref() {
|
||||||
Some(f) => Some(try!(File::create(f).map_err(|_| format!("Cannot write to log file given: {}", f)))),
|
Some(f) => Some(try!(open_options
|
||||||
|
.append(true).create(true).open(f)
|
||||||
|
.map_err(|_| format!("Cannot write to log file given: {}", f))
|
||||||
|
)),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ Miscellaneous Options:
|
|||||||
-l --logging LOGGING Specify the logging level. Must conform to the same
|
-l --logging LOGGING Specify the logging level. Must conform to the same
|
||||||
format as RUST_LOG. (default: {flag_logging:?})
|
format as RUST_LOG. (default: {flag_logging:?})
|
||||||
--log-file FILENAME Specify a filename into which logging should be
|
--log-file FILENAME Specify a filename into which logging should be
|
||||||
directed. (default: {flag_log_file:?})
|
appended. (default: {flag_log_file:?})
|
||||||
--no-config Don't load a configuration file.
|
--no-config Don't load a configuration file.
|
||||||
--no-color Don't use terminal color codes in output. (default: {flag_no_color})
|
--no-color Don't use terminal color codes in output. (default: {flag_no_color})
|
||||||
-v --version Show information about version.
|
-v --version Show information about version.
|
||||||
|
@ -104,7 +104,7 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
|
|||||||
let account: Address = account.into();
|
let account: Address = account.into();
|
||||||
|
|
||||||
take_weak!(self.accounts)
|
take_weak!(self.accounts)
|
||||||
.test_password(&account, password)
|
.test_password(&account, &password)
|
||||||
.map_err(|e| errors::account("Could not fetch account info.", e))
|
.map_err(|e| errors::account("Could not fetch account info.", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +117,15 @@ impl<C: 'static> ParityAccounts for ParityAccountsClient<C> where C: MiningBlock
|
|||||||
.map_err(|e| errors::account("Could not fetch account info.", e))
|
.map_err(|e| errors::account("Could not fetch account info.", e))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn kill_account(&self, account: RpcH160, password: String) -> Result<bool, Error> {
|
||||||
|
try!(self.active());
|
||||||
|
let account: Address = account.into();
|
||||||
|
take_weak!(self.accounts)
|
||||||
|
.kill_account(&account, &password)
|
||||||
|
.map(|_| true)
|
||||||
|
.map_err(|e| errors::account("Could not delete account.", e))
|
||||||
|
}
|
||||||
|
|
||||||
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool, Error> {
|
fn set_account_name(&self, addr: RpcH160, name: String) -> Result<bool, Error> {
|
||||||
try!(self.active());
|
try!(self.active());
|
||||||
let store = take_weak!(self.accounts);
|
let store = take_weak!(self.accounts);
|
||||||
|
@ -116,3 +116,25 @@ fn should_be_able_to_set_meta() {
|
|||||||
assert_eq!(res, Some(response));
|
assert_eq!(res, Some(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn should_be_able_to_kill_account() {
|
||||||
|
let tester = setup();
|
||||||
|
tester.accounts.new_account("password").unwrap();
|
||||||
|
let accounts = tester.accounts.accounts().unwrap();
|
||||||
|
assert_eq!(accounts.len(), 1);
|
||||||
|
let address = accounts[0];
|
||||||
|
|
||||||
|
let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0xf00baba2f00baba2f00baba2f00baba2f00baba2"], "id": 1}}"#);
|
||||||
|
let response = r#"{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params","data":null},"id":1}"#;
|
||||||
|
let res = tester.io.handle_request_sync(&request);
|
||||||
|
assert_eq!(res, Some(response.into()));
|
||||||
|
|
||||||
|
let request = format!(r#"{{"jsonrpc": "2.0", "method": "parity_killAccount", "params": ["0x{}", "password"], "id": 1}}"#, address.hex());
|
||||||
|
let response = r#"{"jsonrpc":"2.0","result":true,"id":1}"#;
|
||||||
|
let res = tester.io.handle_request_sync(&request);
|
||||||
|
assert_eq!(res, Some(response.into()));
|
||||||
|
|
||||||
|
let accounts = tester.accounts.accounts().unwrap();
|
||||||
|
assert_eq!(accounts.len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,11 @@ build_rpc_trait! {
|
|||||||
#[rpc(name = "parity_changePassword")]
|
#[rpc(name = "parity_changePassword")]
|
||||||
fn change_password(&self, H160, String, String) -> Result<bool, Error>;
|
fn change_password(&self, H160, String, String) -> Result<bool, Error>;
|
||||||
|
|
||||||
|
/// Permanently deletes an account.
|
||||||
|
/// Arguments: `account`, `password`.
|
||||||
|
#[rpc(name = "parity_killAccount")]
|
||||||
|
fn kill_account(&self, H160, String) -> Result<bool, Error>;
|
||||||
|
|
||||||
/// Set an account's name.
|
/// Set an account's name.
|
||||||
#[rpc(name = "parity_setAccountName")]
|
#[rpc(name = "parity_setAccountName")]
|
||||||
fn set_account_name(&self, H160, String) -> Result<bool, Error>;
|
fn set_account_name(&self, H160, String) -> Result<bool, Error>;
|
||||||
|
Loading…
Reference in New Issue
Block a user