Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' into refactor/hashdb-generic
Browse files Browse the repository at this point in the history
* master:
  Hardware-wallets `Clean up things I missed in the latest PR` (#8890)
  Remove debian/.deb and centos/.rpm packaging scripts (#8887)
  Remove a weird emoji in new_social docs (#8913)
  • Loading branch information
dvdplm committed Jun 18, 2018
2 parents 60e7c90 + b472185 commit 1d7dc83
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 235 deletions.
48 changes: 7 additions & 41 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ variables:
RUSTFLAGS: ""
CARGOFLAGS: ""
CI_SERVER_NAME: "GitLab CI"
LIBSSL: "libssl1.0.0 (>=1.0.0)"
cache:
key: "$CI_BUILD_STAGE-$CI_BUILD_REF_NAME"
paths:
- target/
untracked: true
linux-ubuntu:
linux-amd64:
stage: build
image: parity/rust:gitlab-ci
only:
Expand All @@ -24,46 +23,13 @@ linux-ubuntu:
script:
- rustup default stable
# ARGUMENTS: 1. BUILD_PLATFORM (target for binaries) 2. PLATFORM (target for cargo) 3. ARC (architecture) 4. & 5. CC & CXX flags 6. binary identifier
- scripts/gitlab-build.sh x86_64-unknown-linux-gnu x86_64-unknown-linux-gnu amd64 gcc g++ ubuntu
- scripts/gitlab-build.sh x86_64-unknown-linux-gnu x86_64-unknown-linux-gnu amd64 gcc g++ linux
tags:
- rust-stable
artifacts:
paths:
- parity.zip
name: "stable-x86_64-unknown-linux-gnu_parity"
linux-debian:
stage: build
image: parity/rust-debian:gitlab-ci
only:
- beta
- tags
- stable
- triggers
script:
- export LIBSSL="libssl1.1 (>=1.1.0)"
- scripts/gitlab-build.sh x86_64-unknown-debian-gnu x86_64-unknown-linux-gnu amd64 gcc g++ debian
tags:
- rust-debian
artifacts:
paths:
- parity.zip
name: "stable-x86_64-unknown-debian-gnu_parity"
linux-centos:
stage: build
image: parity/rust-centos:gitlab-ci
only:
- beta
- tags
- stable
- triggers
script:
- scripts/gitlab-build.sh x86_64-unknown-centos-gnu x86_64-unknown-linux-gnu x86_64 gcc g++ centos
tags:
- rust-centos
artifacts:
paths:
- parity.zip
name: "x86_64-unknown-centos-gnu_parity"
linux-i686:
stage: build
image: parity/rust-i686:gitlab-ci
Expand All @@ -73,7 +39,7 @@ linux-i686:
- stable
- triggers
script:
- scripts/gitlab-build.sh i686-unknown-linux-gnu i686-unknown-linux-gnu i386 gcc g++ ubuntu
- scripts/gitlab-build.sh i686-unknown-linux-gnu i686-unknown-linux-gnu i386 gcc g++ linux
tags:
- rust-i686
artifacts:
Expand All @@ -90,15 +56,15 @@ linux-armv7:
- stable
- triggers
script:
- scripts/gitlab-build.sh armv7-unknown-linux-gnueabihf armv7-unknown-linux-gnueabihf armhf arm-linux-gnueabihf-gcc arm-linux-gnueabihf-g++ ubuntu
- scripts/gitlab-build.sh armv7-unknown-linux-gnueabihf armv7-unknown-linux-gnueabihf armhf arm-linux-gnueabihf-gcc arm-linux-gnueabihf-g++ linux
tags:
- rust-arm
artifacts:
paths:
- parity.zip
name: "armv7_unknown_linux_gnueabihf_parity"
allow_failure: true
linux-arm:
linux-armhf:
stage: build
image: parity/rust-arm:gitlab-ci
only:
Expand All @@ -107,7 +73,7 @@ linux-arm:
- stable
- triggers
script:
- scripts/gitlab-build.sh arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabihf armhf arm-linux-gnueabihf-gcc arm-linux-gnueabihf-g++ ubuntu
- scripts/gitlab-build.sh arm-unknown-linux-gnueabihf arm-unknown-linux-gnueabihf armhf arm-linux-gnueabihf-gcc arm-linux-gnueabihf-g++ linux
tags:
- rust-arm
artifacts:
Expand All @@ -124,7 +90,7 @@ linux-aarch64:
- stable
- triggers
script:
- scripts/gitlab-build.sh aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu arm64 aarch64-linux-gnu-gcc aarch64-linux-gnu-g++ ubuntu
- scripts/gitlab-build.sh aarch64-unknown-linux-gnu aarch64-unknown-linux-gnu arm64 aarch64-linux-gnu-gcc aarch64-linux-gnu-g++ linux
tags:
- rust-arm
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/ethereum/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn new_easthub<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/easthub.json"))
}

/// Create a new Ethereum Social mainnet chain spec ¯\_(ツ)_/¯ .
/// Create a new Ethereum Social mainnet chain spec.
pub fn new_social<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
load(params.into(), include_bytes!("../../res/ethereum/social.json"))
}
Expand Down
47 changes: 23 additions & 24 deletions hw/src/ledger.rs

Large diffs are not rendered by default.

38 changes: 21 additions & 17 deletions hw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

//! Hardware wallet management.

#[warn(missing_docs)]
#[warn(warnings)]
#![warn(missing_docs)]
#![warn(warnings)]

extern crate ethereum_types;
extern crate ethkey;
Expand All @@ -34,22 +34,24 @@ extern crate trezor_sys;
mod ledger;
mod trezor;

use ethkey::{Address, Signature};

use parking_lot::Mutex;
use std::{fmt, time::Duration};
use std::sync::{Arc, atomic, atomic::AtomicBool};
use std::{fmt, time::Duration};

use ethereum_types::U256;
use ethkey::{Address, Signature};
use parking_lot::Mutex;

const USB_DEVICE_CLASS_DEVICE: u8 = 0;
const POLLING_DURATION: Duration = Duration::from_millis(500);

/// `HardwareWallet` device
#[derive(Debug)]
pub struct Device {
path: String,
info: WalletInfo,
}

/// `Wallet` trait
pub trait Wallet<'a> {
/// Error
type Error;
Expand Down Expand Up @@ -109,7 +111,7 @@ pub enum Error {
}

/// This is the transaction info we need to supply to Trezor message. It's more
/// or less a duplicate of ethcore::transaction::Transaction, but we can't
/// or less a duplicate of `ethcore::transaction::Transaction`, but we can't
/// import ethcore here as that would be a circular dependency.
pub struct TransactionInfo {
/// Nonce
Expand Down Expand Up @@ -163,7 +165,7 @@ impl fmt::Display for Error {
}

impl From<ledger::Error> for Error {
fn from(err: ledger::Error) -> Error {
fn from(err: ledger::Error) -> Self {
match err {
ledger::Error::KeyNotFound => Error::KeyNotFound,
_ => Error::LedgerDevice(err),
Expand All @@ -172,7 +174,7 @@ impl From<ledger::Error> for Error {
}

impl From<trezor::Error> for Error {
fn from(err: trezor::Error) -> Error {
fn from(err: trezor::Error) -> Self {
match err {
trezor::Error::KeyNotFound => Error::KeyNotFound,
_ => Error::TrezorDevice(err),
Expand All @@ -181,16 +183,18 @@ impl From<trezor::Error> for Error {
}

impl From<libusb::Error> for Error {
fn from(err: libusb::Error) -> Error {
fn from(err: libusb::Error) -> Self {
Error::Usb(err)
}
}

/// Specifies the direction of the `HardwareWallet` i.e, whether it arrived or left
#[derive(Debug, Copy, Clone)]
pub enum DeviceDirection {
Arrived,
Left,
/// Device arrived
Arrived,
/// Device left
Left,
}

impl fmt::Display for DeviceDirection {
Expand All @@ -211,16 +215,16 @@ pub struct HardwareWalletManager {

impl HardwareWalletManager {
/// Hardware wallet constructor
pub fn new() -> Result<HardwareWalletManager, Error> {
pub fn new() -> Result<Self, Error> {
let exiting = Arc::new(AtomicBool::new(false));
let hidapi = Arc::new(Mutex::new(hidapi::HidApi::new().map_err(|e| Error::Hid(e.to_string().clone()))?));
let ledger = ledger::Manager::new(hidapi.clone(), exiting.clone())?;
let trezor = trezor::Manager::new(hidapi.clone(), exiting.clone())?;

Ok(HardwareWalletManager {
exiting: exiting,
ledger: ledger,
trezor: trezor,
Ok(Self {
exiting,
ledger,
trezor,
})
}

Expand Down
Loading

0 comments on commit 1d7dc83

Please sign in to comment.