Skip to content

Commit

Permalink
feat(auth): add fund command to support user account funding (#159)
Browse files Browse the repository at this point in the history
Introduced a new "Fund" command for authenticated users. This
command opens the browser to direct users to the funding page.
  • Loading branch information
steebchen authored Jan 14, 2025
1 parent aade0e8 commit 2e7fb6e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cli/src/command/auth/fund.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use anyhow::Result;
use clap::Args;
use slot::{browser, vars};

#[derive(Debug, Args)]
pub struct FundArgs;

impl FundArgs {
pub async fn run(&self) -> Result<()> {
let url = vars::get_cartridge_keychain_url();

let url = format!("{url}/slot/fund");

browser::open(&url)?;

Ok(())
}
}
6 changes: 6 additions & 0 deletions cli/src/command/auth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use self::{email::EmailArgs, info::InfoArgs, login::LoginArgs};
use crate::command::auth::billing::BillingArgs;
use crate::command::auth::fund::FundArgs;
use anyhow::Result;
use clap::Subcommand;

mod billing;
mod email;
mod fund;
mod info;
mod login;
mod session;
Expand All @@ -23,6 +25,9 @@ pub enum Auth {
#[command(about = "Manage slot billing for the authenticated user.")]
EnableSlotBilling(BillingArgs),

#[command(about = "Fund the authenticated user's account.")]
Fund(FundArgs),

// Mostly for testing purposes, will eventually turn it into a library call from `sozo`.
#[command(hide = true)]
CreateSession(session::CreateSession),
Expand All @@ -36,6 +41,7 @@ impl Auth {
Auth::CreateSession(args) => args.run().await,
Auth::SetEmail(args) => args.run().await,
Auth::EnableSlotBilling(args) => args.run().await,
Auth::Fund(args) => args.run().await,
}
}
}

0 comments on commit 2e7fb6e

Please sign in to comment.