From 2e7fb6e34ad8ac5a1b795524079a3bee0aaed6db Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Tue, 14 Jan 2025 14:29:36 +0000 Subject: [PATCH] feat(auth): add fund command to support user account funding (#159) Introduced a new "Fund" command for authenticated users. This command opens the browser to direct users to the funding page. --- cli/src/command/auth/fund.rs | 18 ++++++++++++++++++ cli/src/command/auth/mod.rs | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 cli/src/command/auth/fund.rs diff --git a/cli/src/command/auth/fund.rs b/cli/src/command/auth/fund.rs new file mode 100644 index 0000000..1181341 --- /dev/null +++ b/cli/src/command/auth/fund.rs @@ -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(()) + } +} diff --git a/cli/src/command/auth/mod.rs b/cli/src/command/auth/mod.rs index 5bb4c7f..3d12750 100644 --- a/cli/src/command/auth/mod.rs +++ b/cli/src/command/auth/mod.rs @@ -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; @@ -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), @@ -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, } } }