Skip to content

Commit e2d59c7

Browse files
authored
feat: use sessionId for server-side RPCs (#956)
* feat: use sessionId for server-side RPCs * chore: fix types * chore: bump yttrium * fix: add orchestration_id to export * chore: bump cerberus * fix: handle unwrap * chore: bump yttrium & add st & sv to CA analytics * fix: order * chore: pin yttrium
1 parent 10deab9 commit e2d59c7

17 files changed

+458
-330
lines changed

Cargo.lock

+244-214
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+9-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build = "build.rs"
1313
[dependencies]
1414
wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.9.0", features = ["alloc", "analytics", "future", "http", "metrics", "geoip", "geoblock", "rate_limit"] }
1515
relay_rpc = { git = "https://github.com/WalletConnect/WalletConnectRust.git", tag = "v0.32.0", features = ["cacao"] }
16-
yttrium = { git = "https://github.com/reown-com/yttrium.git", rev = "4f9def1" }
16+
yttrium = { git = "https://github.com/reown-com/yttrium.git", rev = "e2c6984" }
1717

1818
# Async
1919
async-trait = "0.1.82"
@@ -68,7 +68,7 @@ pnet_datalink = "0.31"
6868
tracing = "0.1"
6969
tracing-subscriber = { version = "0.3", features = ["json", "ansi", "env-filter"] }
7070

71-
cerberus = { git = "https://github.com/WalletConnect/cerberus.git", tag = "v0.13.1" }
71+
cerberus = { git = "https://github.com/WalletConnect/cerberus.git", rev = "251233e" }
7272
parquet = { git = "https://github.com/WalletConnect/arrow-rs.git", rev = "99a1cc3", default-features = false, features = ["flate2"] }
7373
parquet_derive = { git = "https://github.com/WalletConnect/arrow-rs.git", rev = "99a1cc3" }
7474
chrono = { version = "0.4", features = ["serde"] }
@@ -80,7 +80,7 @@ rand = "0.8.5"
8080
rand_core = "0.6"
8181
prometheus-http-query = "0.6.6"
8282
ethers = { version = "2.0.11", git = "https://github.com/gakonst/ethers-rs" } # using Git version because crates.io version fails clippy
83-
alloy = { version = "0.9.2", features = ["providers", "json-rpc"] }
83+
alloy = { version = "0.11.1", features = ["providers", "json-rpc"] }
8484
fastlz-rs = "0.0.3"
8585

8686
bytes = "1.7.1"
@@ -89,7 +89,7 @@ base64 = "0.22"
8989
bs58 = "0.5"
9090
regex = "1.10"
9191
sha256 = "1.5"
92-
uuid = { version = "1.10", features = ["serde"] }
92+
uuid = { version = "1.13.1", features = ["serde"] }
9393

9494
# System CPU and Memory metrics
9595
sysinfo = "0.30"
@@ -113,4 +113,8 @@ lto = "thin"
113113
debug = 1
114114

115115
# [patch.'https://github.com/reown-com/yttrium.git']
116-
# yttrium = { path = "../yttrium/crates/yttrium" }
116+
# yttrium = { path = "../../reown-com/yttrium/crates/yttrium" }
117+
118+
[patch.crates-io]
119+
alloy = { git = "https://github.com/alloy-rs/alloy.git", rev = "5dcdf0f" }
120+
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "5dcdf0f" }

src/analytics/chain_abstraction_info.rs

+48
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ pub struct ChainAbstractionFundingInfo {
1010
pub country: Option<Arc<str>>,
1111
pub continent: Option<Arc<str>>,
1212

13+
// Sdk info
14+
pub sv: Option<String>,
15+
pub st: Option<String>,
16+
17+
pub orchestration_id: String,
18+
1319
pub chain_id: String,
1420
pub token_contract: String,
1521
pub token_symbol: String,
@@ -26,6 +32,11 @@ impl ChainAbstractionFundingInfo {
2632
country: Option<Arc<str>>,
2733
continent: Option<Arc<str>>,
2834

35+
sv: Option<String>,
36+
st: Option<String>,
37+
38+
orchestration_id: String,
39+
2940
chain_id: String,
3041
token_contract: String,
3142
token_symbol: String,
@@ -40,6 +51,11 @@ impl ChainAbstractionFundingInfo {
4051
country,
4152
continent,
4253

54+
sv,
55+
st,
56+
57+
orchestration_id,
58+
4359
chain_id,
4460
token_contract,
4561
token_symbol,
@@ -58,6 +74,12 @@ pub struct ChainAbstractionBridgingInfo {
5874
pub country: Option<Arc<str>>,
5975
pub continent: Option<Arc<str>>,
6076

77+
// Sdk info
78+
pub sv: Option<String>,
79+
pub st: Option<String>,
80+
81+
pub orchestration_id: String,
82+
6183
pub src_chain_id: String,
6284
pub src_token_contract: String,
6385
pub src_token_symbol: String,
@@ -80,6 +102,11 @@ impl ChainAbstractionBridgingInfo {
80102
country: Option<Arc<str>>,
81103
continent: Option<Arc<str>>,
82104

105+
sv: Option<String>,
106+
st: Option<String>,
107+
108+
orchestration_id: String,
109+
83110
src_chain_id: String,
84111
src_token_contract: String,
85112
src_token_symbol: String,
@@ -100,6 +127,11 @@ impl ChainAbstractionBridgingInfo {
100127
country,
101128
continent,
102129

130+
st,
131+
sv,
132+
133+
orchestration_id,
134+
103135
src_chain_id,
104136
src_token_contract,
105137
src_token_symbol,
@@ -124,6 +156,12 @@ pub struct ChainAbstractionInitialTxInfo {
124156
pub country: Option<Arc<str>>,
125157
pub continent: Option<Arc<str>>,
126158

159+
// Sdk info
160+
pub sv: Option<String>,
161+
pub st: Option<String>,
162+
163+
pub orchestration_id: String,
164+
127165
pub transfer_from: String,
128166
pub transfer_to: String,
129167
pub amount: String,
@@ -142,6 +180,11 @@ impl ChainAbstractionInitialTxInfo {
142180
country: Option<Arc<str>>,
143181
continent: Option<Arc<str>>,
144182

183+
sv: Option<String>,
184+
st: Option<String>,
185+
186+
orchestration_id: String,
187+
145188
transfer_from: String,
146189
transfer_to: String,
147190
amount: String,
@@ -158,6 +201,11 @@ impl ChainAbstractionInitialTxInfo {
158201
country,
159202
continent,
160203

204+
sv,
205+
st,
206+
207+
orchestration_id,
208+
161209
transfer_from,
162210
transfer_to,
163211
amount,

src/handlers/balance.rs

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ async fn handler_internal(
313313
parsed_address,
314314
rpc_project_id,
315315
MessageSource::Balance,
316+
None,
316317
)
317318
.await?;
318319
if let Some(balance) = response

src/handlers/chain_agnostic/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub async fn check_erc20_balances(
9494
address: Address,
9595
chain_id: String,
9696
erc2_contracts: Vec<Address>,
97+
session_id: Option<String>,
9798
) -> Result<Vec<(Address, U256)>, RpcError> {
9899
let mut balances = Vec::new();
99100
// Check the ERC20 tokens balance for each of supported assets
@@ -105,6 +106,7 @@ pub async fn check_erc20_balances(
105106
EthersH160::from(<[u8; 20]>::from(address)),
106107
&project_id,
107108
MessageSource::ChainAgnosticCheck,
109+
session_id.clone(),
108110
)
109111
.await?;
110112
balances.push((contract, U256::from_be_bytes(erc20_balance.into())));
@@ -125,6 +127,7 @@ pub struct BridgingAsset {
125127
/// same symbol to avoid unnecessary swapping
126128
pub async fn check_bridging_for_erc20_transfer(
127129
rpc_project_id: String,
130+
session_id: Option<String>,
128131
value: U256,
129132
sender: Address,
130133
// Exclude the initial transaction asset from the check
@@ -161,6 +164,7 @@ pub async fn check_bridging_for_erc20_transfer(
161164
.iter()
162165
.map(|c| Address::from_str(c).unwrap_or_default())
163166
.collect(),
167+
session_id.clone(),
164168
)
165169
.await?;
166170
for (contract_address, current_balance) in erc20_balances {

src/handlers/chain_agnostic/route.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,20 @@ async fn handler_internal(
8383
.validate_project_access_and_quota(rpc_project_id.as_ref())
8484
.await?;
8585

86+
let first_call = if let Some(first) = request_payload.transaction.calls.into_calls().first() {
87+
first.clone()
88+
} else {
89+
return Err(RpcError::InvalidParameter(
90+
"The transaction calls are empty".to_string(),
91+
));
92+
};
93+
8694
let mut initial_transaction = Transaction {
8795
from: request_payload.transaction.from,
88-
to: request_payload.transaction.to,
89-
value: request_payload.transaction.value,
96+
to: first_call.to,
97+
value: first_call.value,
98+
input: first_call.input.clone(),
9099
gas_limit: U64::ZERO,
91-
input: request_payload.transaction.input.clone(),
92100
nonce: U64::ZERO,
93101
chain_id: request_payload.transaction.chain_id.clone(),
94102
};
@@ -103,6 +111,7 @@ async fn handler_internal(
103111
from_address,
104112
rpc_project_id.as_ref(),
105113
MessageSource::ChainAgnosticCheck,
114+
query_params.session_id.clone(),
106115
)
107116
.await?;
108117
initial_transaction.nonce = intial_transaction_nonce;
@@ -274,6 +283,7 @@ async fn handler_internal(
274283
convert_alloy_address_to_h160(from_address),
275284
rpc_project_id.as_ref(),
276285
MessageSource::ChainAgnosticCheck,
286+
query_params.session_id.clone(),
277287
)
278288
.await?;
279289
let erc20_balance = U256::from_be_bytes(erc20_balance.into());
@@ -289,6 +299,7 @@ async fn handler_internal(
289299
// or return an insufficient funds error
290300
let Some(bridging_asset) = check_bridging_for_erc20_transfer(
291301
rpc_project_id.as_ref().to_string(),
302+
query_params.session_id.clone(),
292303
erc20_topup_value,
293304
from_address,
294305
initial_transaction.chain_id.clone(),
@@ -417,6 +428,7 @@ async fn handler_internal(
417428
from_address,
418429
rpc_project_id.as_ref(),
419430
MessageSource::ChainAgnosticCheck,
431+
query_params.session_id.clone(),
420432
)
421433
.await?;
422434

@@ -565,6 +577,9 @@ async fn handler_internal(
565577
region.clone(),
566578
country.clone(),
567579
continent.clone(),
580+
query_params.sdk_version.clone(),
581+
query_params.sdk_type.clone(),
582+
orchestration_id.clone(),
568583
bridge_chain_id.clone(),
569584
bridge_contract.to_string(),
570585
bridge_token_symbol.clone(),
@@ -578,6 +593,9 @@ async fn handler_internal(
578593
region.clone(),
579594
country.clone(),
580595
continent.clone(),
596+
query_params.sdk_version.clone(),
597+
query_params.sdk_type.clone(),
598+
orchestration_id.clone(),
581599
bridge_chain_id.clone(),
582600
bridge_contract.to_string(),
583601
bridge_token_symbol.clone(),
@@ -595,6 +613,9 @@ async fn handler_internal(
595613
region,
596614
country,
597615
continent,
616+
query_params.sdk_version,
617+
query_params.sdk_type,
618+
orchestration_id.clone(),
598619
from_address.to_string(),
599620
to_address.to_string(),
600621
asset_transfer_value.to_string(),

src/handlers/chain_agnostic/status.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use {
1919
wc::future::FutureExt,
2020
yttrium::chain_abstraction::api::status::{
2121
StatusQueryParams, StatusResponse, StatusResponseCompleted, StatusResponseError,
22-
StatusResponsePending,
22+
StatusResponsePendingObject,
2323
},
2424
};
2525

@@ -81,6 +81,7 @@ async fn handler_internal(
8181
EthersH160::from(<[u8; 20]>::from(bridging_status_item.wallet)),
8282
query_params.project_id.as_ref(),
8383
MessageSource::ChainAgnosticCheck,
84+
query_params.session_id.clone(),
8485
)
8586
.await?;
8687

@@ -144,7 +145,7 @@ async fn handler_internal(
144145
}
145146

146147
// The balance was not fullfilled return the pending status
147-
return Ok(Json(StatusResponse::Pending(StatusResponsePending {
148+
return Ok(Json(StatusResponse::Pending(StatusResponsePendingObject {
148149
created_at: bridging_status_item.created_at,
149150
check_in: STATUS_POLLING_INTERVAL,
150151
}))

src/handlers/profile/address.rs

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub async fn handler_internal(
116116
&chain_id_caip2,
117117
rpc_project_id,
118118
MessageSource::ProfileAddressSigValidate,
119+
None,
119120
)
120121
.await
121122
{

src/handlers/profile/attributes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ pub async fn handler_internal(
9292
&chain_id_caip2,
9393
rpc_project_id,
9494
MessageSource::ProfileAttributesSigValidate,
95+
None,
9596
)
9697
.await
9798
{

src/handlers/profile/register.rs

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub async fn handler_internal(
140140
&chain_id_caip2,
141141
rpc_project_id,
142142
MessageSource::ProfileRegisterSigValidate,
143+
None,
143144
)
144145
.await
145146
{

src/handlers/sessions/cosign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ async fn handler_internal(
129129
&chain_id_caip2,
130130
contract_address,
131131
user_op.clone(),
132+
None,
132133
)
133134
.await?;
134135
let eip191_user_op_hash = to_eip191_message(&user_op_hash);

src/handlers/wallet/call_id.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::primitives::{Bytes, B256, U64};
1+
use alloy::primitives::{Bytes, U64};
22
use serde::{Deserialize, Serialize};
33

44
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -7,7 +7,7 @@ pub struct CallId(pub CallIdInner);
77
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88
pub struct CallIdInner {
99
pub chain_id: U64,
10-
pub user_op_hash: B256,
10+
pub user_op_hash: Bytes,
1111
}
1212

1313
impl Serialize for CallId {

0 commit comments

Comments
 (0)