From b07b3024107e4dc81be285a684974afd5b3c568b Mon Sep 17 00:00:00 2001 From: Alexis Robert Date: Thu, 10 Feb 2022 19:03:46 +0100 Subject: [PATCH] Fixes a parsing issue of EIP712 chain_id (chain_id = 80001 parsed as chain_id = 0x80001) (#892) * Parsing U256 from base10_parse::() instead of directly to U256 This fixes a bug for chain_ids that are > 10, base10_parse::() was somehow parsing into hex. When using the derive macro, chain_id = 10 was parsed as chain_id = 0x10 = 16, causing an issue for some chains like Polygon. * chore: fmt Co-authored-by: Georgios Konstantopoulos --- ethers-core/src/types/transaction/eip712.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ethers-core/src/types/transaction/eip712.rs b/ethers-core/src/types/transaction/eip712.rs index 61a6b9a1..c1875707 100644 --- a/ethers-core/src/types/transaction/eip712.rs +++ b/ethers-core/src/types/transaction/eip712.rs @@ -267,16 +267,17 @@ impl TryFrom<&syn::DeriveInput> for EIP712Domain { .to_compile_error()) } - domain.chain_id = lit_int - .base10_digits() - .parse() - .map_err(|_| { - Error::new( - meta.path.span(), - "failed to parse chain id", - ) - .to_compile_error() - })?; + domain.chain_id = U256::from( + lit_int.base10_parse::().map_err( + |_| { + Error::new( + meta.path.span(), + "failed to parse chain id", + ) + .to_compile_error() + }, + )?, + ); } _ => { return Err(Error::new(