mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-16 17:07:35 +00:00
Add our own alloy meta module to deduplicate alloy prefixes
This commit is contained in:
parent
af79586488
commit
ae8a27b876
6 changed files with 67 additions and 58 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -8068,11 +8068,13 @@ dependencies = [
|
|||
"curve25519-dalek",
|
||||
"dkg",
|
||||
"dockertest",
|
||||
"ethereum-serai",
|
||||
"hex",
|
||||
"monero-serai",
|
||||
"parity-scale-codec",
|
||||
"rand_core",
|
||||
"serai-client",
|
||||
"serai-db",
|
||||
"serai-docker-tests",
|
||||
"serai-message-queue",
|
||||
"serai-message-queue-tests",
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
use thiserror::Error;
|
||||
|
||||
pub use alloy_core;
|
||||
pub use alloy_sol_types;
|
||||
pub mod alloy {
|
||||
pub use alloy_core::primitives;
|
||||
pub use alloy_core as core;
|
||||
pub use alloy_sol_types as 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;
|
||||
pub use alloy_provider;
|
||||
pub use alloy_consensus as consensus;
|
||||
pub use alloy_network as network;
|
||||
pub use alloy_rpc_types as rpc_types;
|
||||
pub use alloy_simple_request_transport as simple_request_transport;
|
||||
pub use alloy_rpc_client as rpc_client;
|
||||
pub use alloy_provider as provider;
|
||||
}
|
||||
|
||||
pub mod crypto;
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ use ciphersuite::{group::GroupEncoding, Ciphersuite, Secp256k1};
|
|||
use frost::ThresholdKeys;
|
||||
|
||||
use ethereum_serai::{
|
||||
alloy_core::primitives::U256,
|
||||
alloy_rpc_types::{BlockNumberOrTag, Transaction},
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy::{
|
||||
primitives::U256,
|
||||
rpc_types::{BlockNumberOrTag, Transaction},
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
},
|
||||
crypto::{PublicKey, Signature},
|
||||
erc20::Erc20,
|
||||
deployer::Deployer,
|
||||
|
@ -23,7 +25,7 @@ use ethereum_serai::{
|
|||
machine::*,
|
||||
};
|
||||
#[cfg(test)]
|
||||
use ethereum_serai::alloy_core::primitives::B256;
|
||||
use ethereum_serai::alloy::primitives::B256;
|
||||
|
||||
use tokio::{
|
||||
time::sleep,
|
||||
|
@ -112,7 +114,7 @@ impl TryInto<Vec<u8>> for Address {
|
|||
|
||||
impl fmt::Display for Address {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
ethereum_serai::alloy_core::primitives::Address::from(self.0).fmt(f)
|
||||
ethereum_serai::alloy::primitives::Address::from(self.0).fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -181,7 +183,7 @@ impl<D: Db> Output<Ethereum<D>> for EthereumInInstruction {
|
|||
let mut id = [0; 40];
|
||||
id[.. 32].copy_from_slice(&self.id.0);
|
||||
id[32 ..].copy_from_slice(&self.id.1.to_le_bytes());
|
||||
*ethereum_serai::alloy_core::primitives::keccak256(id)
|
||||
*ethereum_serai::alloy::primitives::keccak256(id)
|
||||
}
|
||||
fn tx_id(&self) -> [u8; 32] {
|
||||
self.id.0
|
||||
|
@ -853,7 +855,7 @@ impl<D: Db> Network for Ethereum<D> {
|
|||
async fn test_send(&self, send_to: Self::Address) -> Self::Block {
|
||||
use rand_core::OsRng;
|
||||
use ciphersuite::group::ff::Field;
|
||||
use ethereum_serai::alloy_sol_types::SolCall;
|
||||
use ethereum_serai::alloy::sol_types::SolCall;
|
||||
|
||||
let key = <Secp256k1 as Ciphersuite>::F::random(&mut OsRng);
|
||||
let address = ethereum_serai::crypto::address(&(Secp256k1::generator() * key));
|
||||
|
@ -869,12 +871,12 @@ impl<D: Db> Network for Ethereum<D> {
|
|||
.unwrap();
|
||||
|
||||
let value = U256::from_str_radix("1000000000000000000", 10).unwrap();
|
||||
let tx = ethereum_serai::alloy_consensus::TxLegacy {
|
||||
let tx = ethereum_serai::alloy::consensus::TxLegacy {
|
||||
chain_id: None,
|
||||
nonce: 0,
|
||||
gas_price: 1_000_000_000u128,
|
||||
gas_limit: 200_000u128,
|
||||
to: ethereum_serai::alloy_core::primitives::TxKind::Call(send_to.0.into()),
|
||||
to: ethereum_serai::alloy::primitives::TxKind::Call(send_to.0.into()),
|
||||
// 1 ETH
|
||||
value,
|
||||
input: ethereum_serai::router::abi::inInstructionCall::new((
|
||||
|
@ -886,7 +888,7 @@ impl<D: Db> Network for Ethereum<D> {
|
|||
.into(),
|
||||
};
|
||||
|
||||
use ethereum_serai::alloy_consensus::SignableTransaction;
|
||||
use ethereum_serai::alloy::consensus::SignableTransaction;
|
||||
let sig = k256::ecdsa::SigningKey::from(k256::elliptic_curve::NonZeroScalar::new(key).unwrap())
|
||||
.sign_prehash_recoverable(tx.signature_hash().as_ref())
|
||||
.unwrap();
|
||||
|
|
|
@ -314,10 +314,12 @@ mod ethereum {
|
|||
) -> impl Fn(MemDb) -> Pin<Box<dyn Send + Future<Output = Ethereum<MemDb>>>> {
|
||||
use std::sync::Arc;
|
||||
use ethereum_serai::{
|
||||
alloy_core::primitives::U256,
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy::{
|
||||
primitives::U256,
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
},
|
||||
deployer::Deployer,
|
||||
};
|
||||
|
||||
|
|
|
@ -182,11 +182,11 @@ impl Coordinator {
|
|||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
use ethereum_serai::{
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
|
@ -293,12 +293,12 @@ impl Coordinator {
|
|||
(hash, block_buf)
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
use ethereum_serai::{
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_types::BlockNumberOrTag,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_types::BlockNumberOrTag,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
|
@ -395,11 +395,11 @@ impl Coordinator {
|
|||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
use ethereum_serai::{
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
|
@ -464,11 +464,11 @@ impl Coordinator {
|
|||
rpc.send_raw_transaction(&Transaction::consensus_decode(&mut &*tx).unwrap()).await.unwrap();
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
use ethereum_serai::{
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
|
@ -517,12 +517,12 @@ impl Coordinator {
|
|||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
use ethereum_serai::{
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_consensus::{TxLegacy, Signed},
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
consensus::{TxLegacy, Signed},
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
|
|
|
@ -156,12 +156,12 @@ impl Wallet {
|
|||
|
||||
NetworkId::Ethereum => {
|
||||
use ciphersuite::{group::ff::Field, Ciphersuite, Secp256k1};
|
||||
use ethereum_serai::{
|
||||
alloy_core::primitives::{U256, Address},
|
||||
alloy_simple_request_transport::SimpleRequest,
|
||||
alloy_rpc_client::ClientBuilder,
|
||||
alloy_provider::{Provider, RootProvider},
|
||||
alloy_network::Ethereum,
|
||||
use ethereum_serai::alloy::{
|
||||
primitives::{U256, Address},
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
provider::{Provider, RootProvider},
|
||||
network::Ethereum,
|
||||
};
|
||||
|
||||
let key = <Secp256k1 as Ciphersuite>::F::random(&mut OsRng);
|
||||
|
@ -330,7 +330,7 @@ impl Wallet {
|
|||
|
||||
Wallet::Ethereum { key, ref mut nonce } => {
|
||||
/*
|
||||
use ethereum_serai::alloy_core::primitives::U256;
|
||||
use ethereum_serai::alloy::primitives::U256;
|
||||
|
||||
let eight_decimals = U256::from(100_000_000u64);
|
||||
let nine_decimals = eight_decimals * U256::from(10u64);
|
||||
|
|
Loading…
Reference in a new issue