diff --git a/README.md b/README.md index cfcfebf4..c9564c2a 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ Check that the websocket is working: ``` $ websocat ws://127.0.0.1:8544 +{"jsonrpc":"2.0","method":"web3_clientVersion","id":1} + {"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newHeads"]} {"jsonrpc": "2.0", "id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]} diff --git a/config/development_polygon.toml b/config/development_polygon.toml index 5f6d80e7..b07f7811 100644 --- a/config/development_polygon.toml +++ b/config/development_polygon.toml @@ -11,6 +11,8 @@ db_url = "mysql://root:dev_web3_proxy@127.0.0.1:13306/dev_web3_proxy" deposit_factory_contract = "0x4e3BC2054788De923A04936C6ADdB99A05B0Ea36" deposit_topic = "0x45fdc265dc29885b9a485766b03e70978440d38c7c328ee0a14fa40c76c6af54" +free_subscriptions = true + # a timeseries database is optional. it is used for making pretty graphs influxdb_host = "http://127.0.0.1:18086" influxdb_org = "dev_org" diff --git a/web3_proxy/src/jsonrpc.rs b/web3_proxy/src/jsonrpc.rs index f7591f32..17f87987 100644 --- a/web3_proxy/src/jsonrpc.rs +++ b/web3_proxy/src/jsonrpc.rs @@ -6,6 +6,7 @@ use axum::response::Response; use derive_more::From; use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor}; use serde::{Deserialize, Serialize}; +use serde_inline_default::serde_inline_default; use serde_json::json; use serde_json::value::{to_raw_value, RawValue}; use std::borrow::Cow; @@ -19,13 +20,14 @@ pub trait JsonRpcResultData = serde::Serialize + serde::de::DeserializeOwned + f // TODO: &str here instead of String should save a lot of allocations // TODO: generic type for params? +#[serde_inline_default] #[derive(Clone, Deserialize, Serialize)] pub struct JsonRpcRequest { pub jsonrpc: String, /// id could be a stricter type, but many rpcs do things against the spec pub id: Box, pub method: String, - /// TODO: skip serializing if serde_json::Value::Null + #[serde_inline_default(serde_json::Value::Null)] pub params: serde_json::Value, }