From e98288d0d5246f221c4d4fe6d8d264b22e03eef2 Mon Sep 17 00:00:00 2001 From: James Prestwich <10149425+prestwich@users.noreply.github.com> Date: Mon, 16 Aug 2021 14:12:30 -0700 Subject: [PATCH] bugfix: disable type serialization when legacy feature is set (#383) --- Cargo.lock | 2 +- ethers-core/Cargo.toml | 2 +- ethers-core/src/types/transaction/eip2718.rs | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d154de4d..61b7aeb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -867,7 +867,7 @@ dependencies = [ [[package]] name = "ethers-core" -version = "0.4.6" +version = "0.4.7" dependencies = [ "arrayvec 0.7.1", "bincode", diff --git a/ethers-core/Cargo.toml b/ethers-core/Cargo.toml index 0a844a8a..7dc7e902 100644 --- a/ethers-core/Cargo.toml +++ b/ethers-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ethers-core" license = "MIT OR Apache-2.0" -version = "0.4.6" +version = "0.4.7" authors = ["Georgios Konstantopoulos "] edition = "2018" description = "Core structures for the ethers-rs crate" diff --git a/ethers-core/src/types/transaction/eip2718.rs b/ethers-core/src/types/transaction/eip2718.rs index 1ae93f25..c70ab99e 100644 --- a/ethers-core/src/types/transaction/eip2718.rs +++ b/ethers-core/src/types/transaction/eip2718.rs @@ -5,8 +5,21 @@ use crate::{ }; use serde::{Deserialize, Serialize}; +/// The TypedTransaction enum represents all Ethereum transaction types. +/// +/// Its variants correspond to specific allowed transactions: +/// 1. Legacy (pre-EIP2718) [`TransactionRequest`] +/// 2. EIP2930 (state access lists) [`Eip2930TransactionRequest`] +/// 3. EIP1559 [`Eip1559TransactionRequest`] +/// +/// To support Kovan and other non-London-compatbile networks, please enable +/// the `legacy` crate feature. This will disable the `type` flag in the +/// serialized transaction, and cause contract calls and other common actions +/// to default to using the legacy transaction type. +/// #[derive(Serialize, Deserialize, Clone, PartialEq, Debug)] -#[serde(tag = "type")] +#[cfg_attr(not(feature = "legacy"), serde(tag = "type"))] +#[cfg_attr(feature = "legacy", serde(untagged))] pub enum TypedTransaction { // 0x00 #[serde(rename = "0x00")]