Skip to content

Commit 25d186b

Browse files
committed
fix: no-std for scroll-alloy-consensus
Signed-off-by: Gregory Edison <gregory.edison1993@gmail.com>
1 parent 4f17749 commit 25d186b

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

crates/scroll/alloy/consensus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std = [
6363
"rand/std",
6464
"derive_more/std",
6565
"serde_json/std",
66-
"serde_with/std",
66+
"serde_with?/std",
6767
]
6868
k256 = [
6969
"alloy-primitives/k256",

crates/scroll/alloy/consensus/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
88
#![cfg_attr(not(feature = "std"), no_std)]
99

10-
use serde_with as _;
10+
#[cfg(not(feature = "std"))]
11+
extern crate alloc as std;
1112

1213
mod transaction;
1314
pub use transaction::{

crates/scroll/alloy/consensus/src/receipt/envelope.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Receipt envelope types for Scroll.
22
33
use crate::ScrollTxType;
4+
use std::vec::Vec;
5+
46
use alloy_consensus::{Eip658Value, Receipt, ReceiptWithBloom, TxReceipt};
57
use alloy_eips::{
68
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},

crates/scroll/alloy/consensus/src/transaction/l1_message.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Scroll L1 message transaction
22
33
use crate::ScrollTxType;
4+
use std::vec::Vec;
5+
46
use alloy_consensus::{Sealable, Transaction, Typed2718};
57
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718};
68
use alloy_primitives::{
@@ -9,7 +11,6 @@ use alloy_primitives::{
911
Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256,
1012
};
1113
use alloy_rlp::Decodable;
12-
use serde::{Deserialize, Serialize};
1314
#[cfg(any(test, feature = "reth-codec"))]
1415
use {reth_codecs::Compact, reth_codecs_derive::add_arbitrary_tests};
1516

@@ -301,11 +302,12 @@ impl Sealable for TxL1Message {
301302
}
302303

303304
/// Scroll specific transaction fields
304-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
305-
#[serde(rename_all = "camelCase")]
305+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
306+
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
307+
#[cfg_attr(any(test, feature = "serde"), serde(rename_all = "camelCase"))]
306308
pub struct ScrollL1MessageTransactionFields {
307309
/// The index of the transaction in the message queue.
308-
#[serde(with = "alloy_serde::quantity")]
310+
#[cfg_attr(any(test, feature = "serde"), serde(with = "alloy_serde::quantity"))]
309311
pub queue_index: u64,
310312
/// The sender of the transaction on the L1.
311313
pub sender: Address,

crates/scroll/alloy/consensus/src/transaction/tx_type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use alloy_eips::eip2718::Eip2718Error;
55
use alloy_primitives::{U64, U8};
66
use alloy_rlp::{BufMut, Decodable, Encodable};
77
use derive_more::Display;
8+
#[cfg(feature = "reth-codec")]
89
use reth_codecs::{
910
__private::bytes,
1011
txtype::{
@@ -122,6 +123,7 @@ impl Decodable for ScrollTxType {
122123
}
123124
}
124125

126+
#[cfg(feature = "reth-codec")]
125127
impl Compact for ScrollTxType {
126128
fn to_compact<B>(&self, buf: &mut B) -> usize
127129
where

crates/scroll/alloy/consensus/src/transaction/typed.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ use alloy_consensus::{
44
};
55
use alloy_eips::eip2930::AccessList;
66
use alloy_primitives::{Address, Bytes, TxKind, B256};
7-
use reth_codecs::{Compact, __private::bytes};
8-
use reth_codecs_derive::generate_tests;
7+
#[cfg(feature = "reth-codec")]
8+
use {
9+
reth_codecs::{Compact, __private::bytes},
10+
reth_codecs_derive::generate_tests,
11+
};
912

1013
/// The `TypedTransaction` enum represents all Ethereum transaction request types, modified for
1114
/// Scroll
@@ -300,6 +303,7 @@ impl Transaction for ScrollTypedTransaction {
300303
}
301304
}
302305

306+
#[cfg(feature = "reth-codec")]
303307
impl Compact for ScrollTypedTransaction {
304308
fn to_compact<B>(&self, out: &mut B) -> usize
305309
where
@@ -338,6 +342,7 @@ impl Compact for ScrollTypedTransaction {
338342
}
339343
}
340344

345+
#[cfg(feature = "reth-codec")]
341346
generate_tests!(
342347
#[compact]
343348
ScrollTypedTransaction,

0 commit comments

Comments
 (0)