From ce0396ea18148c1a11fc9a3dbe1dd3ce577fd676 Mon Sep 17 00:00:00 2001 From: Dan Cline <6798349+Rjected@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:41:44 -0500 Subject: [PATCH] fix(core): prevent chain_id from serializing for requests (#879) * fix(core): prevent chain_id from serializing * add default chainid for deserialization --- ethers-core/src/types/transaction/eip1559.rs | 3 ++- ethers-core/src/types/transaction/request.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ethers-core/src/types/transaction/eip1559.rs b/ethers-core/src/types/transaction/eip1559.rs index 38d1d705..1b0f9a47 100644 --- a/ethers-core/src/types/transaction/eip1559.rs +++ b/ethers-core/src/types/transaction/eip1559.rs @@ -58,7 +58,8 @@ pub struct Eip1559TransactionRequest { /// baseFeePerGas + maxPriorityFeePerGas is “refunded” to the user. pub max_fee_per_gas: Option, - #[serde(rename = "chainId", default, skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing)] + #[serde(default, rename = "chainId")] /// Chain ID (None for mainnet) pub chain_id: Option, } diff --git a/ethers-core/src/types/transaction/request.rs b/ethers-core/src/types/transaction/request.rs index 12f579cc..a581eb4c 100644 --- a/ethers-core/src/types/transaction/request.rs +++ b/ethers-core/src/types/transaction/request.rs @@ -42,7 +42,8 @@ pub struct TransactionRequest { pub nonce: Option, /// Chain ID (None for mainnet) - #[serde(skip_serializing_if = "Option::is_none")] + #[serde(skip_serializing)] + #[serde(default, rename = "chainId")] pub chain_id: Option, ///////////////// Celo-specific transaction fields /////////////////