Skip to content

Commit 714d764

Browse files
committed
wip
1 parent 290dd31 commit 714d764

File tree

2 files changed

+68
-74
lines changed

2 files changed

+68
-74
lines changed

crates/cli/src/args.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ pub struct SequencerNodeArgs {
131131
#[command(flatten)]
132132
pub explorer: ExplorerOptions,
133133

134-
#[cfg(feature = "cartridge")]
135-
#[command(flatten)]
136-
pub cartridge: CartridgeOptions,
137-
138134
#[cfg(feature = "paymaster")]
139135
#[command(flatten)]
140136
pub paymaster: PaymasterOptions,
141137

138+
#[cfg(feature = "cartridge")]
139+
#[command(flatten)]
140+
pub cartridge: CartridgeOptions,
141+
142142
#[cfg(feature = "tee")]
143143
#[command(flatten)]
144144
pub tee: TeeOptions,
@@ -217,13 +217,13 @@ impl SequencerNodeArgs {
217217
};
218218

219219
#[cfg(feature = "vrf")]
220-
let mut vrf = if self.paymaster.vrf.is_external() {
220+
let mut vrf = if self.cartridge.vrf.is_external() {
221221
None
222222
} else {
223223
use crate::sidecar::bootstrap_vrf;
224224

225225
let vrf = bootstrap_vrf(
226-
&self.paymaster.vrf,
226+
&self.cartridge.vrf,
227227
handle.rpc().addr().clone(),
228228
&handle.node().config().chain,
229229
)
@@ -342,7 +342,7 @@ impl SequencerNodeArgs {
342342
// We put it here so that even when the individual api are explicitly specified
343343
// (ie `--rpc.api`) we guarantee that the cartridge rpc is enabled.
344344
#[cfg(feature = "cartridge")]
345-
if self.paymaster.enabled || self.paymaster.vrf.enabled {
345+
if self.cartridge.paymaster {
346346
modules.add(RpcModuleKind::Cartridge);
347347
}
348348

@@ -422,7 +422,7 @@ impl SequencerNodeArgs {
422422
}
423423

424424
#[cfg(feature = "vrf")]
425-
if self.paymaster.vrf.enabled {
425+
if self.cartridge.vrf.enabled {
426426
katana_slot_controller::add_vrf_account_class(&mut chain_spec.genesis);
427427
katana_slot_controller::add_vrf_consumer_class(&mut chain_spec.genesis);
428428
}
@@ -575,7 +575,7 @@ impl SequencerNodeArgs {
575575
};
576576

577577
#[cfg(feature = "cartridge")]
578-
if self.paymaster.cartridge_paymaster {
578+
if self.cartridge.paymaster {
579579
#[cfg(feature = "vrf")]
580580
let vrf = self.vrf_config(chain_spec)?;
581581

@@ -604,7 +604,7 @@ impl SequencerNodeArgs {
604604
vrf,
605605
controller_deployer_address: address,
606606
controller_deployer_private_key: private_key,
607-
cartridge_api_url: self.paymaster.cartridge_api.clone(),
607+
cartridge_api_url: self.cartridge.cartridge_api.clone(),
608608
});
609609
}
610610

@@ -613,7 +613,7 @@ impl SequencerNodeArgs {
613613

614614
#[cfg(feature = "vrf")]
615615
fn vrf_config(&self, chain: &ChainSpec) -> Result<Option<VrfConfig>> {
616-
let options = &self.paymaster.vrf;
616+
let options = &self.cartridge.vrf;
617617

618618
if !options.enabled {
619619
return Ok(None);

crates/cli/src/options.rs

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,6 @@ pub struct GasPriceOracleOptions {
536536
pub l1_strk_data_gas_price: Option<GasPrice>,
537537
}
538538

539-
#[cfg(feature = "cartridge")]
540-
#[derive(Debug, Args, Clone, Serialize, Deserialize, PartialEq)]
541-
#[command(next_help_heading = "Cartridge options")]
542-
pub struct CartridgeOptions {
543-
/// Declare all versions of the Controller class at genesis.
544-
#[arg(long = "cartridge.controllers")]
545-
pub controllers: bool,
546-
}
547-
548539
#[cfg(feature = "paymaster")]
549540
#[derive(Debug, Args, Clone, Serialize, Deserialize, PartialEq)]
550541
#[command(next_help_heading = "Paymaster options")]
@@ -589,29 +580,6 @@ pub struct PaymasterOptions {
589580
#[arg(long = "paymaster.bin", value_name = "PATH", id = "paymaster_bin")]
590581
#[serde(default)]
591582
pub bin: Option<PathBuf>,
592-
593-
/// Enable Cartridge paymaster
594-
#[cfg(feature = "cartridge")]
595-
#[arg(requires = "paymaster_enabled")]
596-
#[arg(long = "paymaster.cartridge")]
597-
#[serde(default)]
598-
pub cartridge_paymaster: bool,
599-
600-
/// The base URL for the Cartridge API.
601-
///
602-
/// This is used to fetch the calldata for the constructor of the given controller
603-
/// address (at the moment). Must be configurable for local development
604-
/// with local cartridge API.
605-
#[cfg(feature = "cartridge")]
606-
#[arg(long = "paymaster.cartridge-api")]
607-
#[arg(default_value = "https://api.cartridge.gg")]
608-
#[arg(requires_all = ["paymaster_enabled", "cartridge_paymaster"])]
609-
#[serde(default = "default_api_url")]
610-
pub cartridge_api: Url,
611-
612-
#[cfg(feature = "vrf")]
613-
#[command(flatten)]
614-
pub vrf: VrfOptions,
615583
}
616584

617585
#[cfg(feature = "paymaster")]
@@ -642,6 +610,47 @@ impl PaymasterOptions {
642610
if self.bin.is_none() {
643611
self.bin = other.bin.clone();
644612
}
613+
}
614+
}
615+
}
616+
617+
#[cfg(feature = "cartridge")]
618+
#[derive(Debug, Args, Clone, Serialize, Deserialize, PartialEq)]
619+
#[command(next_help_heading = "Cartridge options")]
620+
pub struct CartridgeOptions {
621+
/// Declare all versions of the Controller class at genesis.
622+
#[arg(long = "cartridge.controllers")]
623+
pub controllers: bool,
624+
625+
/// Enable Cartridge paymaster
626+
#[arg(requires = "paymaster_enabled")]
627+
#[arg(long = "cartridge.paymaster", id = "cartridge_paymaster")]
628+
#[serde(default)]
629+
pub paymaster: bool,
630+
631+
/// The base URL for the Cartridge API.
632+
///
633+
/// This is used to fetch the calldata for the constructor of the given controller
634+
/// address (at the moment). Must be configurable for local development
635+
/// with local cartridge API.
636+
#[arg(long = "cartridge.api")]
637+
#[arg(default_value = "https://api.cartridge.gg")]
638+
#[arg(requires = "cartridge_paymaster")]
639+
#[serde(default = "default_api_url")]
640+
pub cartridge_api: Url,
641+
642+
#[cfg(feature = "vrf")]
643+
#[command(flatten)]
644+
pub vrf: VrfOptions,
645+
}
646+
647+
#[cfg(feature = "cartridge")]
648+
impl CartridgeOptions {
649+
pub fn merge(&mut self, other: Option<&Self>) {
650+
if let Some(other) = other {
651+
if !self.controllers {
652+
self.controllers = other.controllers;
653+
}
645654

646655
if self.vrf == VrfOptions::default() {
647656
self.vrf = other.vrf.clone();
@@ -650,11 +659,24 @@ impl PaymasterOptions {
650659
}
651660
}
652661

662+
#[cfg(feature = "cartridge")]
663+
impl Default for CartridgeOptions {
664+
fn default() -> Self {
665+
CartridgeOptions {
666+
controllers: false,
667+
paymaster: false,
668+
cartridge_api: default_api_url(),
669+
#[cfg(feature = "vrf")]
670+
vrf: VrfOptions::default(),
671+
}
672+
}
673+
}
674+
653675
#[cfg(feature = "vrf")]
654676
#[derive(Debug, Default, Args, Clone, Serialize, Deserialize, PartialEq)]
655-
#[command(next_help_heading = "VRF options")]
677+
#[command(next_help_heading = "Cartridge VRF options")]
656678
pub struct VrfOptions {
657-
/// Enable the VRF service.
679+
/// Enable the Cartridge VRF service.
658680
///
659681
/// By default, the VRF runs as a sidecar process. If `--vrf.url` is provided,
660682
/// it will connect to an external VRF service instead.
@@ -712,38 +734,10 @@ impl VrfOptions {
712734
}
713735
}
714736

715-
#[cfg(feature = "cartridge")]
716-
impl CartridgeOptions {
717-
pub fn merge(&mut self, other: Option<&Self>) {
718-
if let Some(other) = other {
719-
if !self.controllers {
720-
self.controllers = other.controllers;
721-
}
722-
}
723-
}
724-
}
725-
726-
#[cfg(feature = "cartridge")]
727-
impl Default for CartridgeOptions {
728-
fn default() -> Self {
729-
CartridgeOptions { controllers: false }
730-
}
731-
}
732-
733737
#[cfg(feature = "paymaster")]
734738
impl Default for PaymasterOptions {
735739
fn default() -> Self {
736-
Self {
737-
enabled: false,
738-
url: None,
739-
api_key: None,
740-
bin: None,
741-
price_api_key: None,
742-
cartridge_paymaster: false,
743-
cartridge_api: default_api_url(),
744-
#[cfg(feature = "vrf")]
745-
vrf: VrfOptions::default(),
746-
}
740+
Self { enabled: false, url: None, api_key: None, bin: None, price_api_key: None }
747741
}
748742
}
749743

0 commit comments

Comments
 (0)