Skip to content

Commit 8f7320b

Browse files
committed
fix: broken unit-test due to the serde(rename_all = "camelCase") attribute of type ethereum::AccessListItem has been deleted
refer to this commit: rust-ethereum/ethereum@b160820#diff-2a6a2a5c32456901be5ffa0e2d0354f2d48d96a89e486270ae62808c34b6e96f
1 parent 74406a6 commit 8f7320b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

client/rpc-core/src/types/transaction_request.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub struct TransactionRequest {
5353
pub data: Data,
5454

5555
/// EIP-2930 access list
56+
#[serde(with = "access_list_item_camelcase")]
5657
pub access_list: Option<Vec<AccessListItem>>,
5758
/// Chain ID that this transaction is valid on
5859
pub chain_id: Option<U64>,
@@ -62,6 +63,36 @@ pub struct TransactionRequest {
6263
pub transaction_type: Option<U256>,
6364
}
6465

66+
mod access_list_item_camelcase {
67+
use ethereum::AccessListItem;
68+
use ethereum_types::{Address, H256};
69+
use serde::{Deserialize, Deserializer};
70+
71+
#[derive(Deserialize)]
72+
struct AccessListItemDef {
73+
address: Address,
74+
#[serde(rename = "storageKeys")]
75+
storage_keys: Vec<H256>,
76+
}
77+
78+
pub fn deserialize<'de, D>(deserializer: D) -> Result<Option<Vec<AccessListItem>>, D::Error>
79+
where
80+
D: Deserializer<'de>,
81+
{
82+
let access_item_defs_opt: Option<Vec<AccessListItemDef>> =
83+
Option::deserialize(deserializer)?;
84+
Ok(access_item_defs_opt.map(|access_item_defs| {
85+
access_item_defs
86+
.into_iter()
87+
.map(|access_item_def| AccessListItem {
88+
address: access_item_def.address,
89+
storage_keys: access_item_def.storage_keys,
90+
})
91+
.collect()
92+
}))
93+
}
94+
}
95+
6596
impl TransactionRequest {
6697
// We accept "data" and "input" for backwards-compatibility reasons.
6798
// "input" is the newer name and should be preferred by clients.

0 commit comments

Comments
 (0)