From 526f40e88f6a24e113077e9a413f75a34b0e8688 Mon Sep 17 00:00:00 2001 From: oblique Date: Fri, 27 May 2022 17:11:18 +0300 Subject: [PATCH] feat(core): Add `as_*_mut` methods on `TypedTransaction` (#1310) --- CHANGELOG.md | 2 ++ ethers-core/src/types/transaction/eip2718.rs | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8b2a0ac..543fd391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Unreleased +- Add `as_*_mut` methods on `TypedTransaction` + [#1310](https://github.com/gakonst/ethers-rs/pull/1310) - AWS EIP712 data signing no longer signs with EIP155 - Added Cronos testnet to etherscan options [1276](https://github.com/gakonst/ethers-rs/pull/1276) - Fix parsing of a pending block diff --git a/ethers-core/src/types/transaction/eip2718.rs b/ethers-core/src/types/transaction/eip2718.rs index b87f0abf..6c5fe479 100644 --- a/ethers-core/src/types/transaction/eip2718.rs +++ b/ethers-core/src/types/transaction/eip2718.rs @@ -417,6 +417,25 @@ impl TypedTransaction { _ => None, } } + + pub fn as_legacy_mut(&mut self) -> Option<&mut TransactionRequest> { + match self { + Legacy(tx) => Some(tx), + _ => None, + } + } + pub fn as_eip2930_mut(&mut self) -> Option<&mut Eip2930TransactionRequest> { + match self { + Eip2930(tx) => Some(tx), + _ => None, + } + } + pub fn as_eip1559_mut(&mut self) -> Option<&mut Eip1559TransactionRequest> { + match self { + Eip1559(tx) => Some(tx), + _ => None, + } + } } impl TypedTransaction {