Skip to content

Commit 9db10be

Browse files
committed
wip
1 parent e757ccf commit 9db10be

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
@@ -129,14 +129,14 @@ pub struct SequencerNodeArgs {
129129
#[command(flatten)]
130130
pub explorer: ExplorerOptions,
131131

132-
#[cfg(feature = "cartridge")]
133-
#[command(flatten)]
134-
pub cartridge: CartridgeOptions,
135-
136132
#[cfg(feature = "paymaster")]
137133
#[command(flatten)]
138134
pub paymaster: PaymasterOptions,
139135

136+
#[cfg(feature = "cartridge")]
137+
#[command(flatten)]
138+
pub cartridge: CartridgeOptions,
139+
140140
#[cfg(feature = "tee")]
141141
#[command(flatten)]
142142
pub tee: TeeOptions,
@@ -211,13 +211,13 @@ impl SequencerNodeArgs {
211211
};
212212

213213
#[cfg(feature = "vrf")]
214-
let mut vrf = if self.paymaster.vrf.is_external() {
214+
let mut vrf = if self.cartridge.vrf.is_external() {
215215
None
216216
} else {
217217
use crate::sidecar::bootstrap_vrf;
218218

219219
let vrf = bootstrap_vrf(
220-
&self.paymaster.vrf,
220+
&self.cartridge.vrf,
221221
handle.rpc().addr().clone(),
222222
&handle.node().config().chain,
223223
)
@@ -332,7 +332,7 @@ impl SequencerNodeArgs {
332332
// We put it here so that even when the individual api are explicitly specified
333333
// (ie `--rpc.api`) we guarantee that the cartridge rpc is enabled.
334334
#[cfg(feature = "cartridge")]
335-
if self.paymaster.enabled || self.paymaster.vrf.enabled {
335+
if self.cartridge.paymaster {
336336
modules.add(RpcModuleKind::Cartridge);
337337
}
338338

@@ -412,7 +412,7 @@ impl SequencerNodeArgs {
412412
}
413413

414414
#[cfg(feature = "vrf")]
415-
if self.paymaster.vrf.enabled {
415+
if self.cartridge.vrf.enabled {
416416
katana_slot_controller::add_vrf_account_class(&mut chain_spec.genesis);
417417
katana_slot_controller::add_vrf_consumer_class(&mut chain_spec.genesis);
418418
}
@@ -550,7 +550,7 @@ impl SequencerNodeArgs {
550550
};
551551

552552
#[cfg(feature = "cartridge")]
553-
if self.paymaster.cartridge_paymaster {
553+
if self.cartridge.paymaster {
554554
#[cfg(feature = "vrf")]
555555
let vrf = self.vrf_config(chain_spec)?;
556556

@@ -579,7 +579,7 @@ impl SequencerNodeArgs {
579579
vrf,
580580
controller_deployer_address: address,
581581
controller_deployer_private_key: private_key,
582-
cartridge_api_url: self.paymaster.cartridge_api.clone(),
582+
cartridge_api_url: self.cartridge.cartridge_api.clone(),
583583
});
584584
}
585585

@@ -588,7 +588,7 @@ impl SequencerNodeArgs {
588588

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

593593
if !options.enabled {
594594
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)