Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into EPROD-1086-block-vali…
Browse files Browse the repository at this point in the history
…dation-with-a-single-reth-node
  • Loading branch information
veeso committed Dec 4, 2024
2 parents 33905d2 + 1dd33ab commit a0e57f6
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 238 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ homepage = "https://github.com/bitfinity-network/bitfinity-evm-sdk"
include = ["src/**/*", "LICENSE", "README.md"]
license = "MIT"
repository = "https://github.com/bitfinity-network/bitfinity-evm-sdk"
version = "0.36.0"
version = "0.37.0"

[workspace.dependencies]
alloy-primitives-07 = { package = "alloy-primitives", version = "0.7", default-features = false }
alloy-primitives-08 = { package = "alloy-primitives", version = "0.8", default-features = false }
alloy-primitives = { version = "0.8", default-features = false }
anyhow = "1.0"
async-trait = "0.1"
bincode = "1.3"
Expand Down
2 changes: 0 additions & 2 deletions just/test.just
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
[group('test')]
test test_name="":
cargo test {{test_name}}
cargo test {{test_name}} -p did --features "alloy-primitives-07"
cargo test {{test_name}} -p did --features "alloy-primitives-08"
cargo test {{test_name}} --all-features


Expand Down
9 changes: 1 addition & 8 deletions src/did/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ repository.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
alloy-primitives-07 = { workspace = true, optional = true }
alloy-primitives-08 = { workspace = true, optional = true }
alloy-primitives = { workspace = true }
bincode = { workspace = true }
bytes = { workspace = true }
candid = { workspace = true }
Expand All @@ -40,9 +39,3 @@ thiserror = { workspace = true }
eth-signer = { path = "../eth-signer" }
rand = { workspace = true }
tokio = { workspace = true }

[features]
# Enable the type conversion support between did and alloy-primitives 0.7
"alloy-primitives-07" = ["dep:alloy-primitives-07"]
# Enable the type conversion support between did and alloy-primitives 0.8
"alloy-primitives-08" = ["dep:alloy-primitives-08"]
Original file line number Diff line number Diff line change
@@ -1,85 +1,86 @@
use crate::{Bytes, H160, H256, H64, U256, U64};

impl From<alloy_primitives_07::Bytes> for Bytes {
fn from(value: alloy_primitives_07::Bytes) -> Self {
impl From<alloy_primitives::Bytes> for Bytes {
fn from(value: alloy_primitives::Bytes) -> Self {
Bytes(value.0)
}
}

impl From<Bytes> for alloy_primitives_07::Bytes {
impl From<Bytes> for alloy_primitives::Bytes {
fn from(value: Bytes) -> Self {
alloy_primitives_07::Bytes(value.0)
alloy_primitives::Bytes(value.0)
}
}

impl From<alloy_primitives_07::Address> for H160 {
fn from(value: alloy_primitives_07::Address) -> Self {
impl From<alloy_primitives::Address> for H160 {
fn from(value: alloy_primitives::Address) -> Self {
H160::from_slice(value.as_slice())
}
}

impl From<H160> for alloy_primitives_07::Address {
impl From<H160> for alloy_primitives::Address {
fn from(value: H160) -> Self {
alloy_primitives_07::Address::from_slice(value.0.as_bytes())
alloy_primitives::Address::from_slice(value.0.as_bytes())
}
}

impl From<alloy_primitives_07::B64> for H64 {
fn from(value: alloy_primitives_07::B64) -> Self {
impl From<alloy_primitives::B64> for H64 {
fn from(value: alloy_primitives::B64) -> Self {
H64::from_slice(value.as_slice())
}
}

impl From<H64> for alloy_primitives_07::B64 {
impl From<H64> for alloy_primitives::B64 {
fn from(value: H64) -> Self {
alloy_primitives_07::B64::from_slice(value.0.as_bytes())
alloy_primitives::B64::from_slice(value.0.as_bytes())
}
}

impl From<alloy_primitives_07::B256> for H256 {
fn from(value: alloy_primitives_07::B256) -> Self {
impl From<alloy_primitives::B256> for H256 {
fn from(value: alloy_primitives::B256) -> Self {
H256::from_slice(value.as_slice())
}
}

impl From<H256> for alloy_primitives_07::B256 {
impl From<H256> for alloy_primitives::B256 {
fn from(value: H256) -> Self {
alloy_primitives_07::B256::from_slice(value.0.as_bytes())
alloy_primitives::B256::from_slice(value.0.as_bytes())
}
}

impl From<alloy_primitives_07::U256> for U256 {
fn from(value: alloy_primitives_07::U256) -> Self {
impl From<alloy_primitives::U256> for U256 {
fn from(value: alloy_primitives::U256) -> Self {
U256::from_little_endian(value.as_le_slice())
}
}

impl From<U256> for alloy_primitives_07::U256 {
impl From<U256> for alloy_primitives::U256 {
fn from(value: U256) -> Self {
let mut bytes = [0u8; U256::BYTE_SIZE];
value.0.to_little_endian(&mut bytes);
alloy_primitives_07::U256::from_le_bytes(bytes)
alloy_primitives::U256::from_le_bytes(bytes)
}
}

impl From<alloy_primitives_07::U64> for U64 {
fn from(value: alloy_primitives_07::U64) -> Self {
impl From<alloy_primitives::U64> for U64 {
fn from(value: alloy_primitives::U64) -> Self {
U64::from_little_endian(value.as_le_slice())
}
}

impl From<U64> for alloy_primitives_07::U64 {
impl From<U64> for alloy_primitives::U64 {
fn from(value: U64) -> Self {
let mut bytes = [0u8; U64::BYTE_SIZE];
value.0.to_little_endian(&mut bytes);
alloy_primitives_07::U64::from_le_bytes(bytes)
alloy_primitives::U64::from_le_bytes(bytes)
}
}

#[cfg(test)]
mod test {

use super::*;
use crate::{U256, U64};

#[test]
fn test_alloy_bytes_roundtrip() {
Expand All @@ -89,7 +90,7 @@ mod test {
rand::random::<u8>(),
]));

let alloy_bytes = alloy_primitives_07::Bytes::from(value.clone());
let alloy_bytes = alloy_primitives::Bytes::from(value.clone());
let decoded_value = Bytes::from(alloy_bytes);

assert_eq!(value, decoded_value);
Expand All @@ -99,7 +100,7 @@ mod test {
fn test_alloy_address_roundtrip() {
let value: H160 = ethereum_types::H160::random().into();

let alloy_address = alloy_primitives_07::Address::from(value.clone());
let alloy_address = alloy_primitives::Address::from(value.clone());
let decoded_value = H160::from(alloy_address);

assert_eq!(value, decoded_value);
Expand All @@ -109,7 +110,7 @@ mod test {
fn test_alloy_h256_roundtrip() {
let value: H256 = ethereum_types::H256::random().into();

let alloy_h256 = alloy_primitives_07::B256::from(value.clone());
let alloy_h256 = alloy_primitives::B256::from(value.clone());
let decoded_value = H256::from(alloy_h256);

assert_eq!(value, decoded_value);
Expand All @@ -119,7 +120,7 @@ mod test {
fn test_alloy_h64_roundtrip() {
let value: H64 = ethereum_types::H64::random().into();

let alloy_h64 = alloy_primitives_07::B64::from(value.clone());
let alloy_h64 = alloy_primitives::B64::from(value.clone());
let decoded_value = H64::from(alloy_h64);

assert_eq!(value, decoded_value);
Expand All @@ -129,7 +130,7 @@ mod test {
fn test_alloy_u256_roundtrip() {
let value: U256 = ethereum_types::U256::from(rand::random::<u128>()).into();

let alloy_u256: alloy_primitives_07::U256 = value.clone().into();
let alloy_u256: alloy_primitives::U256 = value.clone().into();
let decoded_value: U256 = alloy_u256.into();

assert_eq!(value, decoded_value);
Expand All @@ -139,7 +140,7 @@ mod test {
fn test_alloy_u64_roundtrip() {
let value: U64 = ethereum_types::U64::from(rand::random::<u64>()).into();

let alloy_u64: alloy_primitives_07::U64 = value.into();
let alloy_u64: alloy_primitives::U64 = value.into();
let decoded_value: U64 = alloy_u64.into();

assert_eq!(value, decoded_value);
Expand Down
156 changes: 0 additions & 156 deletions src/did/src/alloy_primitives_08.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/did/src/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub trait FeeCalculation {
Some(TRANSACTION_TYPE_EIP2930) | Some(TRANSACTION_TYPE_LEGACY) | None => {
self.gas_price().unwrap_or_default()
}
_ => panic!("invalid transaction type"),
tx_type => panic!("invalid transaction type: {tx_type:?}"),
}
}

Expand All @@ -74,7 +74,7 @@ pub trait FeeCalculation {
Some(TRANSACTION_TYPE_EIP2930) | Some(TRANSACTION_TYPE_LEGACY) | None => {
self.gas_price().unwrap_or_default()
}
_ => panic!("invalid transaction type"),
tx_type => panic!("invalid transaction type: {tx_type:?}"),
}
}
}
Expand Down
Loading

0 comments on commit a0e57f6

Please sign in to comment.