From 5501de1f3af12589e6193bb881a1de49cccc7dab Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 10 May 2024 13:33:56 -0400 Subject: [PATCH] Update to the latest alloy Also makes various tweaks as necessary. --- Cargo.lock | 63 ++++++++++--------- coins/ethereum/Cargo.toml | 15 +++-- .../alloy-simple-request-transport/Cargo.toml | 4 +- coins/ethereum/src/crypto.rs | 5 +- coins/ethereum/src/erc20.rs | 23 ++----- coins/ethereum/src/lib.rs | 8 ++- coins/ethereum/src/router.rs | 31 ++++++--- coins/ethereum/src/tests/mod.rs | 11 +++- coins/ethereum/src/tests/schnorr.rs | 4 +- 9 files changed, 91 insertions(+), 73 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57e438de..66212c4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,7 +102,7 @@ checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" [[package]] name = "alloy-consensus" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-eips", "alloy-primitives", @@ -110,7 +110,6 @@ dependencies = [ "alloy-serde", "c-kzg", "serde", - "sha2", ] [[package]] @@ -125,7 +124,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -133,23 +132,25 @@ dependencies = [ "c-kzg", "once_cell", "serde", + "sha2", ] [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "alloy-serde", "serde", + "serde_json", ] [[package]] name = "alloy-json-abi" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a35ddfd27576474322a5869e4c123e5f3e7b2177297c18e4e82ea501cb125b" +checksum = "786689872ec4e7d354810ab0dffd48bb40b838c047522eb031cbd47d15634849" dependencies = [ "alloy-primitives", "alloy-sol-type-parser", @@ -159,7 +160,7 @@ dependencies = [ [[package]] name = "alloy-json-rpc" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "serde", @@ -171,7 +172,7 @@ dependencies = [ [[package]] name = "alloy-network" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-consensus", "alloy-eips", @@ -179,6 +180,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types", "alloy-signer", + "alloy-sol-types", "async-trait", "futures-utils-wasm", "thiserror", @@ -187,7 +189,7 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-genesis", "alloy-primitives", @@ -201,9 +203,9 @@ dependencies = [ [[package]] name = "alloy-primitives" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99bbad0a6b588ef4aec1b5ddbbfdacd9ef04e00b979617765b03174318ee1f3a" +checksum = "525448f6afc1b70dd0f9d0a8145631bf2f5e434678ab23ab18409ca264cae6b3" dependencies = [ "alloy-rlp", "bytes", @@ -224,7 +226,7 @@ dependencies = [ [[package]] name = "alloy-provider" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -271,7 +273,7 @@ dependencies = [ [[package]] name = "alloy-rpc-client" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-json-rpc", "alloy-transport", @@ -289,7 +291,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-consensus", "alloy-eips", @@ -307,7 +309,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types-trace" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -319,7 +321,7 @@ dependencies = [ [[package]] name = "alloy-serde" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "serde", @@ -329,7 +331,7 @@ dependencies = [ [[package]] name = "alloy-signer" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-primitives", "async-trait", @@ -352,9 +354,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "452d929748ac948a10481fff4123affead32c553cf362841c5103dd508bdfc16" +checksum = "89c80a2cb97e7aa48611cbb63950336f9824a174cdf670527cc6465078a26ea1" dependencies = [ "alloy-json-abi", "alloy-sol-macro-input", @@ -371,9 +373,9 @@ dependencies = [ [[package]] name = "alloy-sol-macro-input" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df64e094f6d2099339f9e82b5b38440b159757b6920878f28316243f8166c8d1" +checksum = "c58894b58ac50979eeac6249661991ac40b9d541830d9a725f7714cc9ef08c23" dependencies = [ "alloy-json-abi", "const-hex", @@ -388,18 +390,18 @@ dependencies = [ [[package]] name = "alloy-sol-type-parser" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "715f4d09a330cc181fc7c361b5c5c2766408fa59a0bac60349dcb7baabd404cc" +checksum = "7da8e71ea68e780cc203919e03f69f59e7afe92d2696fb1dcb6662f61e4031b6" dependencies = [ "winnow 0.6.6", ] [[package]] name = "alloy-sol-types" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43bc2d6dfc2a19fd56644494479510f98b1ee929e04cf0d4aa45e98baa3e545b" +checksum = "399287f68d1081ed8b1f4903c49687658b95b142207d7cb4ae2f4813915343ef" dependencies = [ "alloy-json-abi", "alloy-primitives", @@ -410,7 +412,7 @@ dependencies = [ [[package]] name = "alloy-transport" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-json-rpc", "base64 0.22.0", @@ -428,7 +430,7 @@ dependencies = [ [[package]] name = "alloy-transport-http" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6#037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6" +source = "git+https://github.com/alloy-rs/alloy?rev=b79db21734cffddc11753fe62ba571565c896f42#b79db21734cffddc11753fe62ba571565c896f42" dependencies = [ "alloy-transport", "url", @@ -2331,6 +2333,7 @@ version = "0.1.0" dependencies = [ "alloy-consensus", "alloy-core", + "alloy-network", "alloy-node-bindings", "alloy-provider", "alloy-rpc-client", @@ -3790,7 +3793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.4", ] [[package]] @@ -9341,9 +9344,9 @@ dependencies = [ [[package]] name = "syn-solidity" -version = "0.7.0" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4497156948bd342b52038035a6fa514a89626e37af9d2c52a5e8d8ebcc7ee479" +checksum = "5aa0cefd02f532035d83cfec82647c6eb53140b0485220760e669f4bad489e36" dependencies = [ "paste", "proc-macro2", diff --git a/coins/ethereum/Cargo.toml b/coins/ethereum/Cargo.toml index 4bb92fe4..dc30764e 100644 --- a/coins/ethereum/Cargo.toml +++ b/coins/ethereum/Cargo.toml @@ -29,18 +29,21 @@ frost = { package = "modular-frost", path = "../../crypto/frost", default-featur alloy-core = { version = "0.7", default-features = false } alloy-sol-types = { version = "0.7", default-features = false, features = ["json"] } -alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false, features = ["k256"] } -alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } -alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } +alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false, features = ["k256"] } +alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } +alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } +alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } alloy-simple-request-transport = { path = "./alloy-simple-request-transport", default-features = false } -alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } +alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } + +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false, optional = true } [dev-dependencies] frost = { package = "modular-frost", path = "../../crypto/frost", default-features = false, features = ["tests"] } tokio = { version = "1", features = ["macros"] } -alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } +alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } [features] -tests = [] +tests = ["alloy-node-bindings"] diff --git a/coins/ethereum/alloy-simple-request-transport/Cargo.toml b/coins/ethereum/alloy-simple-request-transport/Cargo.toml index 115998e4..0d9ea6b8 100644 --- a/coins/ethereum/alloy-simple-request-transport/Cargo.toml +++ b/coins/ethereum/alloy-simple-request-transport/Cargo.toml @@ -21,8 +21,8 @@ tower = "0.4" serde_json = { version = "1", default-features = false } simple-request = { path = "../../../common/request", default-features = false } -alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } -alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "037dd4b20ec8533d6b6d5cf5e9489bbb182c18c6", default-features = false } +alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } +alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "b79db21734cffddc11753fe62ba571565c896f42", default-features = false } [features] default = ["tls"] diff --git a/coins/ethereum/src/crypto.rs b/coins/ethereum/src/crypto.rs index ca228eb5..6ea6a0b0 100644 --- a/coins/ethereum/src/crypto.rs +++ b/coins/ethereum/src/crypto.rs @@ -31,7 +31,10 @@ pub fn address(point: &ProjectivePoint) -> [u8; 20] { keccak256(&encoded_point.as_ref()[1 .. 65])[12 ..].try_into().unwrap() } -pub(crate) fn deterministically_sign(tx: &TxLegacy) -> Signed { +/// Deterministically sign a transaction. +/// +/// This function panics if passed a transaction with a non-None chain ID. +pub fn deterministically_sign(tx: &TxLegacy) -> Signed { assert!( tx.chain_id.is_none(), "chain ID was Some when deterministically signing a TX (causing a non-deterministic signer)" diff --git a/coins/ethereum/src/erc20.rs b/coins/ethereum/src/erc20.rs index 86bd1b2d..1d874403 100644 --- a/coins/ethereum/src/erc20.rs +++ b/coins/ethereum/src/erc20.rs @@ -4,7 +4,7 @@ use alloy_core::primitives::{Address, B256, U256}; use alloy_sol_types::{SolInterface, SolEvent}; -use alloy_rpc_types::{BlockNumberOrTag, Filter}; +use alloy_rpc_types::Filter; use alloy_simple_request_transport::SimpleRequest; use alloy_provider::{Provider, RootProvider}; @@ -25,22 +25,8 @@ pub struct TopLevelErc20Transfer { pub struct Erc20(Arc>, Address); impl Erc20 { /// Construct a new view of the specified ERC20 contract. - /// - /// This checks a contract is deployed at that address yet does not check the contract is - /// actually an ERC20. - pub async fn new( - provider: Arc>, - address: [u8; 20], - ) -> Result, Error> { - let code = provider - .get_code_at(address.into(), BlockNumberOrTag::Finalized.into()) - .await - .map_err(|_| Error::ConnectionError)?; - // Contract has yet to be deployed - if code.is_empty() { - return Ok(None); - } - Ok(Some(Self(provider.clone(), Address::from(&address)))) + pub fn new(provider: Arc>, address: [u8; 20]) -> Self { + Self(provider, Address::from(&address)) } pub async fn top_level_transfers( @@ -65,7 +51,8 @@ impl Erc20 { } let tx_id = log.transaction_hash.ok_or(Error::ConnectionError)?; - let tx = self.0.get_transaction_by_hash(tx_id).await.map_err(|_| Error::ConnectionError)?; + let tx = + self.0.get_transaction_by_hash(tx_id).await.ok().flatten().ok_or(Error::ConnectionError)?; // If this is a top-level call... if tx.to == Some(self.1) { diff --git a/coins/ethereum/src/lib.rs b/coins/ethereum/src/lib.rs index 8d4a5312..eda54c72 100644 --- a/coins/ethereum/src/lib.rs +++ b/coins/ethereum/src/lib.rs @@ -1,8 +1,10 @@ use thiserror::Error; pub use alloy_core; -pub use alloy_consensus; +pub use alloy_sol_types; +pub use alloy_consensus; +pub use alloy_network; pub use alloy_rpc_types; pub use alloy_simple_request_transport; pub use alloy_rpc_client; @@ -18,8 +20,8 @@ pub mod router; pub mod machine; -#[cfg(test)] -mod tests; +#[cfg(any(test, feature = "tests"))] +pub mod tests; #[derive(Clone, Copy, PartialEq, Eq, Debug, Error)] pub enum Error { diff --git a/coins/ethereum/src/router.rs b/coins/ethereum/src/router.rs index d2750a02..8d46b24f 100644 --- a/coins/ethereum/src/router.rs +++ b/coins/ethereum/src/router.rs @@ -159,11 +159,12 @@ impl Router { #[cfg(test)] pub async fn serai_key(&self, at: [u8; 32]) -> Result { let call = TransactionRequest::default() - .to(Some(self.1)) + .to(self.1) .input(TransactionInput::new(abi::seraiKeyCall::new(()).abi_encode().into())); let bytes = self .0 - .call(&call, Some(BlockId::Hash(B256::from(at).into()))) + .call(&call) + .block(BlockId::Hash(B256::from(at).into())) .await .map_err(|_| Error::ConnectionError)?; let res = @@ -197,11 +198,12 @@ impl Router { #[cfg(test)] pub async fn nonce(&self, at: [u8; 32]) -> Result { let call = TransactionRequest::default() - .to(Some(self.1)) + .to(self.1) .input(TransactionInput::new(abi::nonceCall::new(()).abi_encode().into())); let bytes = self .0 - .call(&call, Some(BlockId::Hash(B256::from(at).into()))) + .call(&call) + .block(BlockId::Hash(B256::from(at).into())) .await .map_err(|_| Error::ConnectionError)?; let res = @@ -229,10 +231,13 @@ impl Router { } } - pub async fn key_at_end_of_block(&self, block: u64) -> Result { + pub async fn key_at_end_of_block(&self, block: u64) -> Result, Error> { let filter = Filter::new().from_block(0).to_block(block).address(self.1); let filter = filter.event_signature(SeraiKeyUpdated::SIGNATURE_HASH); let all_keys = self.0.get_logs(&filter).await.map_err(|_| Error::ConnectionError)?; + if all_keys.is_empty() { + return Ok(None); + }; let last_key_x_coordinate_log = all_keys.last().ok_or(Error::ConnectionError)?; let last_key_x_coordinate = last_key_x_coordinate_log @@ -246,7 +251,9 @@ impl Router { compressed_point[0] = u8::from(sec1::Tag::CompressedEvenY); compressed_point[1 ..].copy_from_slice(last_key_x_coordinate.as_slice()); - Option::from(ProjectivePoint::from_bytes(&compressed_point)).ok_or(Error::ConnectionError) + let key = + Option::from(ProjectivePoint::from_bytes(&compressed_point)).ok_or(Error::ConnectionError)?; + Ok(Some(key)) } pub async fn in_instructions( @@ -254,7 +261,9 @@ impl Router { block: u64, allowed_tokens: &HashSet<[u8; 20]>, ) -> Result, Error> { - let key_at_end_of_block = self.key_at_end_of_block(block).await?; + let Some(key_at_end_of_block) = self.key_at_end_of_block(block).await? else { + return Ok(vec![]); + }; let filter = Filter::new().from_block(block).to_block(block).address(self.1); let filter = filter.event_signature(InInstructionEvent::SIGNATURE_HASH); @@ -274,7 +283,13 @@ impl Router { ); let tx_hash = log.transaction_hash.ok_or(Error::ConnectionError)?; - let tx = self.0.get_transaction_by_hash(tx_hash).await.map_err(|_| Error::ConnectionError)?; + let tx = self + .0 + .get_transaction_by_hash(tx_hash) + .await + .ok() + .flatten() + .ok_or(Error::ConnectionError)?; let log = log.log_decode::().map_err(|_| Error::ConnectionError)?.inner.data; diff --git a/coins/ethereum/src/tests/mod.rs b/coins/ethereum/src/tests/mod.rs index 3a381d42..085ef3a2 100644 --- a/coins/ethereum/src/tests/mod.rs +++ b/coins/ethereum/src/tests/mod.rs @@ -11,16 +11,20 @@ use alloy_core::{ }; use alloy_consensus::{SignableTransaction, TxLegacy}; -use alloy_rpc_types::TransactionReceipt; +use alloy_rpc_types::{BlockNumberOrTag, TransactionReceipt}; use alloy_simple_request_transport::SimpleRequest; use alloy_provider::{Provider, RootProvider}; use crate::crypto::{address, deterministically_sign, PublicKey}; +#[cfg(test)] mod crypto; +#[cfg(test)] mod abi; +#[cfg(test)] mod schnorr; +#[cfg(test)] mod router; pub fn key_gen() -> (HashMap>, PublicKey) { @@ -53,14 +57,15 @@ pub async fn send( // let chain_id = provider.get_chain_id().await.unwrap(); // tx.chain_id = Some(chain_id); tx.chain_id = None; - tx.nonce = provider.get_transaction_count(address, None).await.unwrap(); + tx.nonce = + provider.get_transaction_count(address, BlockNumberOrTag::Latest.into()).await.unwrap(); // 100 gwei tx.gas_price = 100_000_000_000u128; let sig = wallet.sign_prehash_recoverable(tx.signature_hash().as_ref()).unwrap(); assert_eq!(address, tx.clone().into_signed(sig.into()).recover_signer().unwrap()); assert!( - provider.get_balance(address, None).await.unwrap() > + provider.get_balance(address, BlockNumberOrTag::Latest.into()).await.unwrap() > ((U256::from(tx.gas_price) * U256::from(tx.gas_limit)) + tx.value) ); diff --git a/coins/ethereum/src/tests/schnorr.rs b/coins/ethereum/src/tests/schnorr.rs index 9311c292..21d8b45a 100644 --- a/coins/ethereum/src/tests/schnorr.rs +++ b/coins/ethereum/src/tests/schnorr.rs @@ -56,12 +56,12 @@ pub async fn call_verify( let px: [u8; 32] = public_key.px.to_repr().into(); let c_bytes: [u8; 32] = signature.c.to_repr().into(); let s_bytes: [u8; 32] = signature.s.to_repr().into(); - let call = TransactionRequest::default().to(Some(contract)).input(TransactionInput::new( + let call = TransactionRequest::default().to(contract).input(TransactionInput::new( abi::verifyCall::new((px.into(), message.to_vec().into(), c_bytes.into(), s_bytes.into())) .abi_encode() .into(), )); - let bytes = provider.call(&call, None).await.map_err(|_| Error::ConnectionError)?; + let bytes = provider.call(&call).await.map_err(|_| Error::ConnectionError)?; let res = abi::verifyCall::abi_decode_returns(&bytes, true).map_err(|_| Error::ConnectionError)?;