fix: reschedule waker if receipt is immediately available (#103)

* fix: reschedule waker if receipt is immediately available

* chore: update minor deps

`cargo update`

* chore: make clippy happy
This commit is contained in:
Georgios Konstantopoulos 2020-12-16 14:05:16 +02:00 committed by GitHub
parent 873cf099b6
commit b0bfd550fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 368 additions and 292 deletions

636
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -17,10 +17,10 @@ ethabi = { package = "ethabi-next", version = "12.0.0", default-features = false
arrayvec = { version = "0.5.1", default-features = false }
# crypto
ecdsa = { version = "0.8.0", features = ["std"] }
elliptic-curve = { version = "0.6.1", features = ["arithmetic"] }
ecdsa = { version = "0.9.0", features = ["std"] }
elliptic-curve = { version = "0.7.1", features = ["arithmetic"] }
generic-array = "0.14.4"
k256 = { version = "0.5.2", features = ["keccak256", "ecdsa"] }
k256 = { version = "0.6.0", default-features = false, features = ["keccak256", "ecdsa"] }
rand = "0.7.2"
tiny-keccak = { version = "2.0.2", default-features = false }

View File

@ -105,8 +105,8 @@ impl Signature {
recoverable_sig.recover_verify_key_from_digest_bytes(message_hash.as_ref().into())?;
let uncompressed_pub_key = K256PublicKey::from(&verify_key).decompress();
if uncompressed_pub_key.is_some().into() {
let public_key = uncompressed_pub_key.unwrap().to_bytes();
if let Some(public_key) = uncompressed_pub_key {
let public_key = public_key.to_bytes();
debug_assert_eq!(public_key[0], 0x04);
let hash = crate::utils::keccak256(&public_key[1..]);
Ok(Address::from_slice(&hash[12..]))

View File

@ -75,6 +75,7 @@ impl<'a, P: JsonRpcClient> Future for PendingTransaction<'a, P> {
PendingTxState::GettingReceipt(fut) => {
if let Ok(receipt) = futures_util::ready!(fut.as_mut().poll(ctx)) {
if let Some(receipt) = receipt {
ctx.waker().wake_by_ref();
*this.state = PendingTxState::CheckingReceipt(Box::new(receipt))
} else {
*this.state = PendingTxState::PausedGettingReceipt

View File

@ -23,16 +23,15 @@ serde = { version = "1.0.112", default-features = false }
coins-ledger = { git = "https://github.com/summa-tx/bitcoins-rs", optional = true }
rustc-hex = { version = "2.1.0" }
async-trait = "0.1.40"
elliptic-curve = { version = "0.6.1", features = ["arithmetic"] }
elliptic-curve = { version = "0.7.1", features = ["arithmetic"] }
sha2 = { version = "0.9.1" }
rand = "0.7.3"
# todo: update to latest once published
yubihsm = { git = "https://github.com/iqlusioninc/yubihsm.rs.git", branch = "develop", features = ["secp256k1", "http", "usb"], optional = true }
yubihsm = { version = "0.36.0", features = ["secp256k1", "http", "usb"], optional = true }
[dev-dependencies]
ethers = { version = "0.1.3", path = "../ethers" }
yubihsm = { git = "https://github.com/iqlusioninc/yubihsm.rs.git", branch = "develop", features = ["secp256k1", "usb", "mockhsm"] }
yubihsm = { version = "0.36.0", features = ["secp256k1", "usb", "mockhsm"] }
tokio = { version = "0.2.21", features = ["macros"] }
serde_json = "1.0.55"

View File

@ -16,7 +16,7 @@ impl Clone for Wallet<SigningKey> {
fn clone(&self) -> Self {
Self {
// TODO: Can we have a better way to clone here?
signer: SigningKey::new(&*self.signer.to_bytes()).unwrap(),
signer: SigningKey::from_bytes(&*self.signer.to_bytes()).unwrap(),
address: self.address,
chain_id: self.chain_id,
}
@ -71,7 +71,7 @@ use ethers_core::k256::SecretKey as K256SecretKey;
impl From<K256SecretKey> for Wallet<SigningKey> {
fn from(key: K256SecretKey) -> Self {
let signer = SigningKey::new(&*key.to_bytes())
let signer = SigningKey::from_bytes(&*key.to_bytes())
.expect("private key should always be convertible to signing key");
let address = key_to_address(&signer);
@ -90,7 +90,7 @@ impl FromStr for Wallet<SigningKey> {
let src = src
.from_hex::<Vec<u8>>()
.expect("invalid hex when reading PrivateKey");
let sk = SigningKey::new(&src).unwrap(); // TODO
let sk = SigningKey::from_bytes(&src).unwrap(); // TODO
Ok(sk.into())
}
}