Skip to content

Commit

Permalink
chore(eips): Add serde to Authorization types (#964)
Browse files Browse the repository at this point in the history
* chore(eips): Add serde to Authorization types

* Add Eq and PartialEq

* added nits
  • Loading branch information
rakita authored Jun 24, 2024
1 parent 2d26b05 commit a1c9f8a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/eips/src/eip7702/auth_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use alloy_rlp::{BufMut, Decodable, Encodable, Header, RlpDecodable, RlpEncodable

/// An unsigned EIP-7702 authorization.
#[derive(Debug, Clone, RlpEncodable, RlpDecodable, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "camelCase"))]
pub struct Authorization {
/// The chain ID of the authorization.
pub chain_id: ChainId,
Expand Down Expand Up @@ -71,8 +73,10 @@ impl Authorization {
}

/// A signed EIP-7702 authorization.
#[derive(Debug, Clone, RlpEncodable, RlpDecodable)]
#[derive(Debug, Clone, RlpEncodable, RlpDecodable, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SignedAuthorization<S> {
#[cfg_attr(feature = "serde", serde(flatten))]
inner: Authorization,
signature: S,
}
Expand Down Expand Up @@ -113,7 +117,9 @@ impl<S> Deref for SignedAuthorization<S> {

/// A recovered authorization.
#[derive(Debug, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RecoveredAuthorization {
#[cfg_attr(feature = "serde", serde(flatten))]
inner: Authorization,
authority: Option<Address>,
}
Expand Down Expand Up @@ -142,6 +148,7 @@ impl Deref for RecoveredAuthorization {
///
/// The wrapper type is used for RLP encoding and decoding.
#[derive(Default, Debug, Copy, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct OptionalNonce(Option<u64>);

impl OptionalNonce {
Expand Down

0 comments on commit a1c9f8a

Please sign in to comment.