From 8d5f0652082ac7e1f1b2a1c415af2b7b02832810 Mon Sep 17 00:00:00 2001 From: evalir Date: Mon, 2 Sep 2024 07:22:39 -0400 Subject: [PATCH] feat(`json-rpc`): implement From U256 and String for SubId (#1226) feat(json-rpc): implement From U256 and String for SubId --- crates/json-rpc/src/notification.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/json-rpc/src/notification.rs b/crates/json-rpc/src/notification.rs index e1af087127b..d6f6a9ab4be 100644 --- a/crates/json-rpc/src/notification.rs +++ b/crates/json-rpc/src/notification.rs @@ -15,6 +15,18 @@ pub enum SubId { String(String), } +impl From for SubId { + fn from(value: U256) -> Self { + Self::Number(value) + } +} + +impl From for SubId { + fn from(value: String) -> Self { + Self::String(value) + } +} + /// An ethereum-style notification, not to be confused with a JSON-RPC /// notification. #[derive(Clone, Debug, Serialize, Deserialize)]