Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine committed Oct 1, 2024
1 parent 3bca5f9 commit 1a21e25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/example/paid_service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ic_papi_guard::guards::{
caller_pays_icrc2_cycles::CallerPaysIcrc2CyclesPaymentGuard,
caller_pays_icrc2_tokens::CallerPaysIcrc2TokensPaymentGuard,
};
use ic_papi_guard::guards::{PaymentGuard, PaymentGuard2};
use ic_papi_guard::guards::PaymentGuard;
use state::{set_init_args, PAYMENT_GUARD};

#[init]
Expand Down
6 changes: 3 additions & 3 deletions src/guard/src/guards/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use super::{
caller_pays_icrc2_cycles::CallerPaysIcrc2CyclesPaymentGuard,
caller_pays_icrc2_tokens::CallerPaysIcrc2TokensPaymentGuard,
patron_pays_icrc2_cycles::PatronPaysIcrc2CyclesPaymentGuard,
patron_pays_icrc2_tokens::PatronPaysIcrc2TokensPaymentGuard, PaymentGuard, PaymentGuard2,
patron_pays_icrc2_tokens::PatronPaysIcrc2TokensPaymentGuard, PaymentGuard,
};

/// A guard that accepts a user-specified payment type, providing the vendor supports it.
Expand Down Expand Up @@ -45,8 +45,8 @@ pub enum PaymentWithConfig {
PatronPaysIcrc2Tokens(PatronPaysIcrc2Tokens),
}

impl<const CAP: usize> PaymentGuard2 for AnyPaymentGuard<CAP> {
async fn deduct(&self, payment: PaymentType, fee: TokenAmount) -> Result<(), PaymentError> {
impl<const CAP: usize> AnyPaymentGuard<CAP> {
pub async fn deduct(&self, payment: PaymentType, fee: TokenAmount) -> Result<(), PaymentError> {
let payment_config = self
.config(payment)
.ok_or(PaymentError::UnsupportedPaymentType)?;
Expand Down
9 changes: 2 additions & 7 deletions src/guard/src/guards/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Guards for specific flows
use ic_papi_api::{caller::TokenAmount, PaymentError, PaymentType};
use ic_papi_api::{caller::TokenAmount, PaymentError};
pub mod any;
pub mod attached_cycles;
pub mod caller_pays_icrc2_cycles;
Expand All @@ -11,9 +11,4 @@ pub mod patron_pays_icrc2_tokens;
#[allow(async_fn_in_trait)]
pub trait PaymentGuard {
async fn deduct(&self, fee: TokenAmount) -> Result<(), PaymentError>;
}

#[allow(async_fn_in_trait)]
pub trait PaymentGuard2 {
async fn deduct(&self, payment: PaymentType, fee: TokenAmount) -> Result<(), PaymentError>;
}
}

0 comments on commit 1a21e25

Please sign in to comment.