feat: add DerefMut for OtherFields (#2109)

This commit is contained in:
Matthias Seitz 2023-02-02 20:12:52 +01:00 committed by GitHub
parent 24163412f8
commit a544d4076c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -1,7 +1,10 @@
//! Support for capturing other fields
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Map;
use std::{collections::BTreeMap, ops::Deref};
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
/// A type that is supposed to capture additional fields that are not native to ethereum but included in ethereum adjacent networks, for example fields the [optimism `eth_getTransactionByHash` request](https://docs.alchemy.com/alchemy/apis/optimism/eth-gettransactionbyhash) returns additional fields that this type will capture
///
@ -138,6 +141,12 @@ impl Deref for OtherFields {
}
}
impl DerefMut for OtherFields {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.inner
}
}
impl AsRef<BTreeMap<String, serde_json::Value>> for OtherFields {
fn as_ref(&self) -> &BTreeMap<String, serde_json::Value> {
&self.inner