Skip to content

Commit 709e130

Browse files
committed
add custom network arg
1 parent a86bf1e commit 709e130

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

batcher/aligned-sdk/src/core/types.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ pub enum Network {
409409
Holesky,
410410
HoleskyStage,
411411
Mainnet,
412+
Custom(String, String)
412413
}
413414

414415
impl Network {
@@ -420,6 +421,7 @@ impl Network {
420421
H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_HOLESKY_STAGE).unwrap()
421422
}
422423
Self::Mainnet => H160::from_str(BATCHER_PAYMENT_SERVICE_ADDRESS_MAINNET).unwrap(),
424+
Self::Custom(s, _) => H160::from_str(s.as_str()).unwrap(),
423425
}
424426
}
425427

@@ -429,6 +431,7 @@ impl Network {
429431
Self::Holesky => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY).unwrap(),
430432
Self::HoleskyStage => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_STAGE).unwrap(),
431433
Self::Mainnet => H160::from_str(ALIGNED_SERVICE_MANAGER_HOLESKY_MAINNET).unwrap(),
434+
Self::Custom(_, s) => H160::from_str(s.as_str()).unwrap(),
432435
}
433436
}
434437
}
@@ -442,10 +445,29 @@ impl FromStr for Network {
442445
"holesky-stage" => Ok(Network::HoleskyStage),
443446
"devnet" => Ok(Network::Devnet),
444447
"mainnet" => Ok(Network::Mainnet),
445-
_ => Err(
446-
"Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\""
447-
.to_string(),
448-
),
448+
s => {
449+
if !s.contains("custom") {
450+
return Err(
451+
"Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom <BATCHER_PAYMENT_SERVICE_ADDRESS> <ALIGNED_SERVICE_MANAGER_ADDRESS>'\""
452+
.to_string(),
453+
)
454+
}
455+
let parts: Vec<&str> = s.split_whitespace().collect();
456+
457+
if parts.len() == 3 {
458+
Ok(Network::Custom(
459+
parts[1].to_string(),
460+
parts[2].to_string()
461+
))
462+
} else {
463+
Err(
464+
"Invalid network, possible values are: \"holesky\", \"holesky-stage\", \"devnet\", \"mainnet\", \"'custom <BATCHER_PAYMENT_SERVICE_ADDRESS, ALIGNED_SERVICE_MANAGER_ADDRESS>'\""
465+
.to_string()
466+
)
467+
}
468+
469+
470+
}
449471
}
450472
}
451473
}

0 commit comments

Comments
 (0)