Skip to content

Commit

Permalink
apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Feb 18, 2024
1 parent 063d03b commit 5e7c5a5
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use ethereum_types::H256;
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg_attr(not(feature = "std"), no_std)]

#[cfg(not(feature = "std"))]
extern crate alloc;

mod account;
Expand All @@ -13,10 +12,7 @@ mod transaction;
pub mod util;

// Alias for `Vec<u8>`. This type alias is necessary for rlp-derive to work correctly.
#[cfg(not(feature = "std"))]
type Bytes = alloc::vec::Vec<u8>;
#[cfg(feature = "std")]
type Bytes = Vec<u8>;

pub use crate::account::Account;
pub use crate::block::*;
Expand Down
1 change: 0 additions & 1 deletion src/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use ethereum_types::{H160, H256};
Expand Down
1 change: 0 additions & 1 deletion src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use bytes::BytesMut;
Expand Down
7 changes: 2 additions & 5 deletions src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#[cfg(not(feature = "std"))]
use alloc::vec;

use ethereum_types::{H256, U256};
use rlp::{DecoderError, Rlp, RlpStream};
use sha3::{Digest, Keccak256};
Expand Down Expand Up @@ -34,7 +31,7 @@ pub struct EIP1559Transaction {
impl EIP1559Transaction {
pub fn hash(&self) -> H256 {
let encoded = rlp::encode(self);
let mut out = vec![0; 1 + encoded.len()];
let mut out = alloc::vec![0; 1 + encoded.len()];
out[0] = 2;
out[1..].copy_from_slice(&encoded);
H256::from_slice(Keccak256::digest(&out).as_slice())
Expand Down Expand Up @@ -120,7 +117,7 @@ pub struct EIP1559TransactionMessage {
impl EIP1559TransactionMessage {
pub fn hash(&self) -> H256 {
let encoded = rlp::encode(self);
let mut out = vec![0; 1 + encoded.len()];
let mut out = alloc::vec![0; 1 + encoded.len()];
out[0] = 2;
out[1..].copy_from_slice(&encoded);
H256::from_slice(Keccak256::digest(&out).as_slice())
Expand Down
7 changes: 3 additions & 4 deletions src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#[cfg(not(feature = "std"))]
use alloc::{vec, vec::Vec};
use alloc::vec::Vec;

use ethereum_types::{Address, H256, U256};
use rlp::{DecoderError, Rlp, RlpStream};
Expand Down Expand Up @@ -64,7 +63,7 @@ pub struct EIP2930Transaction {
impl EIP2930Transaction {
pub fn hash(&self) -> H256 {
let encoded = rlp::encode(self);
let mut out = vec![0; 1 + encoded.len()];
let mut out = alloc::vec![0; 1 + encoded.len()];
out[0] = 1;
out[1..].copy_from_slice(&encoded);
H256::from_slice(Keccak256::digest(&out).as_slice())
Expand Down Expand Up @@ -146,7 +145,7 @@ pub struct EIP2930TransactionMessage {
impl EIP2930TransactionMessage {
pub fn hash(&self) -> H256 {
let encoded = rlp::encode(self);
let mut out = vec![0; 1 + encoded.len()];
let mut out = alloc::vec![0; 1 + encoded.len()];
out[0] = 1;
out[1..].copy_from_slice(&encoded);
H256::from_slice(Keccak256::digest(&out).as_slice())
Expand Down
1 change: 0 additions & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Utility functions for Ethereum.
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

use ethereum_types::H256;
Expand Down

0 comments on commit 5e7c5a5

Please sign in to comment.