Skip to content

Commit

Permalink
chore(eips): Add serde to Authorization types (alloy-rs#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 and ben186 committed Jul 27, 2024
1 parent ef9579f commit 2f732f1
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 2f732f1

Please sign in to comment.