From ae1f88633ef6a97be33281d8ec487fe6f402000e Mon Sep 17 00:00:00 2001 From: sveitser Date: Wed, 29 May 2024 12:23:43 +0200 Subject: [PATCH] Remove dead code This code is no longer used after #1443 (genesis file) --- Cargo.lock | 1 - utils/Cargo.toml | 3 --- utils/src/lib.rs | 62 ------------------------------------------------ 3 files changed, 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7a39dfcb..cf80154f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8544,7 +8544,6 @@ dependencies = [ "anyhow", "ark-serialize", "async-std", - "bincode", "clap", "committable", "contract-bindings", diff --git a/utils/Cargo.toml b/utils/Cargo.toml index 4fa109041..bee687076 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -23,6 +23,3 @@ surf = "2.3.2" tempfile = "3.9.0" tracing = "0.1.37" url = "2.3.1" - -[dev-dependencies] -bincode = { workspace = true } diff --git a/utils/src/lib.rs b/utils/src/lib.rs index 672c3b8cf..b3ecadee4 100644 --- a/utils/src/lib.rs +++ b/utils/src/lib.rs @@ -11,7 +11,6 @@ use ethers::{ signers::{coins_bip39::English, Signer as _}, types::U256, }; -use serde::{Deserialize as _, Serialize as _}; use std::path::{Path, PathBuf}; use std::time::Duration; use std::{ @@ -350,31 +349,6 @@ macro_rules! impl_to_fixed_bytes { }; } -/// Serialize a U256 type as a decimal string for human readable serialization -pub fn serialize_as_decimal(value: &U256, serializer: S) -> Result -where - S: serde::Serializer, -{ - if serializer.is_human_readable() { - serializer.serialize_str(&value.to_string()) - } else { - value.serialize(serializer) - } -} - -/// Deserialize a U256 type from a decimal string for human readable serialization -pub fn deserialize_from_decimal<'de, D>(deserializer: D) -> Result -where - D: serde::Deserializer<'de>, -{ - if deserializer.is_human_readable() { - let s = String::deserialize(deserializer)?; - U256::from_dec_str(&s).map_err(serde::de::Error::custom) - } else { - U256::deserialize(deserializer) - } -} - /// send a transaction and wait for confirmation before returning the tx receipt and block included. pub async fn contract_send( call: &ContractCall, @@ -467,8 +441,6 @@ async fn wait_for_transaction_to_be_mined( mod test { use super::*; use committable::RawCommitmentBuilder; - use serde::{Deserialize, Serialize}; - use serde_json::Value; struct TestCommittable; @@ -485,38 +457,4 @@ mod test { u256_to_commitment(commitment_to_u256(TestCommittable.commit())).unwrap() ); } - #[derive(Debug, Serialize, Deserialize, PartialEq)] - struct AsDecimal( - #[serde( - serialize_with = "serialize_as_decimal", - deserialize_with = "deserialize_from_decimal" - )] - U256, - ); - - #[test] - fn test_serde_json_as_decimal() { - let value = AsDecimal(U256::from(123)); - let serialized = serde_json::to_string(&value).unwrap(); - - // The value is serialized as decimal string - let json_value: Value = serde_json::from_str(&serialized).unwrap(); - assert_eq!(json_value.as_str().unwrap(), "123"); - - // Deserialization produces the original value - let deserialized: AsDecimal = serde_json::from_str(&serialized).unwrap(); - assert_eq!(deserialized, value); - } - - #[test] - fn test_serde_bincode_unchanged() { - #[derive(Debug, Serialize, Deserialize, PartialEq)] - struct AsDefault(U256); - let custom = AsDecimal(U256::from(123)); - let default = AsDefault(U256::from(123)); - assert_eq!( - bincode::serialize(&custom).unwrap(), - bincode::serialize(&default).unwrap(), - ); - } }