Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-7702: change chain_id type to U256 #21

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions crates/eip7702/src/auth_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl RecoveredAuthority {
pub struct Authorization {
/// The chain ID of the authorization.
#[cfg_attr(feature = "serde", serde(with = "quantity"))]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this attribute is no longer necessary

pub chain_id: u64,
pub chain_id: U256,
/// The address of the authorization.
pub address: Address,
/// The nonce for the authorization.
Expand All @@ -62,7 +62,7 @@ impl Authorization {
/// # Note
///
/// Implementers should check that this matches the current `chain_id` *or* is 0.
pub const fn chain_id(&self) -> u64 {
pub const fn chain_id(&self) -> U256 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather return an &U256 here and leave the copy up to the caller

self.chain_id
}

Expand Down Expand Up @@ -496,16 +496,19 @@ mod tests {
fn test_encode_decode_auth() {
// fully filled
test_encode_decode_roundtrip(Authorization {
chain_id: 1u64,
chain_id: U256::from(1),
address: Address::left_padding_from(&[6]),
nonce: 1,
});
}

#[test]
fn test_encode_decode_signed_auth() {
let auth =
Authorization { chain_id: 1u64, address: Address::left_padding_from(&[6]), nonce: 1 };
let auth = Authorization {
chain_id: U256::from(1),
address: Address::left_padding_from(&[6]),
nonce: 1,
};

let auth = auth.into_signed(PrimitiveSignature::from_str("48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c8041b").unwrap());
let mut buf = Vec::new();
Expand Down
Loading