Skip to content

Commit

Permalink
fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
alyn509 committed Feb 1, 2025
1 parent db16cf1 commit af83540
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions contracts/examples/digital-cash/src/pay_fee_and_fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ pub trait PayFeeAndFund: storage::StorageModule + helpers::HelpersModule {
#[payable]
fn pay_fee_and_fund(&self, address: ManagedAddress, valability: u64) {
let mut payments = self.call_value().all_transfers().clone_value();
require!(!payments.is_empty(), "no payment was provided");

let mut fee_token = payments.get(0).clone();
let fee_value_mapper = self.fee(&fee_token.token_identifier);

let provided_fee_token = payments.get(0).clone();
require!(!fee_value_mapper.is_empty(), "invalid fee toke provided");

fee_token.amount = fee_value_mapper.get();
let nr_of_payments = payments.len();

let fee_with_first_token = fee_token.amount.clone() * payments.len() as u32;
let fee_without_first_token = fee_token.amount.clone() * (payments.len() as u32 - 1);
let fee_with_first_token = fee_token.amount.clone() * nr_of_payments as u32;
let fee_without_first_token = fee_token.amount.clone() * (nr_of_payments as u32 - 1);

require!(
(provided_fee_token.amount == fee_without_first_token || // case when the first token is the exact fee amount
Expand Down

0 comments on commit af83540

Please sign in to comment.