Skip to content

Commit

Permalink
feat: wallet get calls status
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 committed Oct 7, 2024
1 parent 7595412 commit 456d5a9
Show file tree
Hide file tree
Showing 21 changed files with 714 additions and 120 deletions.
14 changes: 8 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build = "build.rs"
[dependencies]
wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.9.0", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] }
relay_rpc = { git = "https://github.com/WalletConnect/WalletConnectRust.git", tag = "v0.32.0", features = ["cacao"] }
yttrium = { git = "https://github.com/reown-com/yttrium.git", rev = "5b0c319" }
yttrium = { git = "https://github.com/reown-com/yttrium.git", branch = "fix/support-get-calls-status" }

# Async
async-trait = "0.1.82"
Expand Down
1 change: 1 addition & 0 deletions src/analytics/message_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub enum MessageSource {
SessionCoSignSigValidate,
WalletPrepareCalls,
WalletSendPreparedCalls,
WalletGetCallsStatus,
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ mod test {
pimlico_api_key: "PIMLICO_API_KEY".to_string(),
solscan_api_v1_token: "SOLSCAN_API_V1_TOKEN".to_string(),
solscan_api_v2_token: "SOLSCAN_API_V2_TOKEN".to_string(),
override_bundler_urls: None,
},
rate_limiting: RateLimitingConfig {
max_tokens: Some(100),
Expand Down
2 changes: 1 addition & 1 deletion src/env/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::{utils, utils::network::NetworkInterfaceError},
crate::utils::{self, network::NetworkInterfaceError},
serde::Deserialize,
serde_piecewise_default::DeserializePiecewiseDefault,
std::net::IpAddr,
Expand Down
7 changes: 4 additions & 3 deletions src/handlers/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use {
error::RpcError, providers::SupportedBundlerOps, state::AppState,
utils::crypto::disassemble_caip2,
},
alloy::rpc::json_rpc::Id,
axum::{
extract::{Query, State},
response::{IntoResponse, Response},
Expand All @@ -30,8 +31,8 @@ pub struct BundlerQueryParams {

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BundlerJsonRpcRequest {
pub id: u64,
pub jsonrpc: String,
pub id: Id,
pub jsonrpc: Arc<str>,
pub method: SupportedBundlerOps,
pub params: serde_json::Value,
}
Expand Down Expand Up @@ -62,7 +63,7 @@ async fn handler_internal(
.bundler_rpc_call(
&evm_chain_id,
request_payload.id,
&request_payload.jsonrpc,
request_payload.jsonrpc,
&request_payload.method,
request_payload.params,
)
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ impl JsonRpcClient for SelfProvider {
self.query.clone(),
self.headers.clone(),
serde_json::to_vec(&crypto::JsonRpcRequest {
id,
id: id.into(),
jsonrpc: crypto::JSON_RPC_VERSION.clone(),
method: method.to_owned().into(),
params,
Expand Down
26 changes: 26 additions & 0 deletions src/handlers/wallet/call_id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use alloy::primitives::{Bytes, B256, U64};
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CallId(pub CallIdInner);

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct CallIdInner {
pub chain_id: U64,
pub user_op_hash: B256,
}

impl Serialize for CallId {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
Bytes::from(serde_json::to_vec(&self.0).map_err(serde::ser::Error::custom)?)
.serialize(serializer)
}
}

impl<'de> Deserialize<'de> for CallId {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let bytes = Bytes::deserialize(deserializer)?;
let inner = serde_json::from_slice(&bytes).map_err(serde::de::Error::custom)?;
Ok(Self(inner))
}
}
Loading

0 comments on commit 456d5a9

Please sign in to comment.