Skip to content

Commit

Permalink
Use config.dispense_amount (#51)
Browse files Browse the repository at this point in the history
* feat: use config.dispense_amount

* chore: apply cargo fmt
  • Loading branch information
DefiCake committed Dec 22, 2023
1 parent 51b6fae commit 35e7e12
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ fn check_and_mark_dispense_limit(
Ok(())
}

async fn get_coin_output(wallet: &WalletUnlocked) -> Result<CoinOutput, DispenseError> {
async fn get_coin_output(
wallet: &WalletUnlocked,
amount: u64,
) -> Result<CoinOutput, DispenseError> {
let resources = wallet
.get_spendable_resources(AssetId::BASE, THE_BIGGEST_AMOUNT)
.get_spendable_resources(AssetId::BASE, amount)
.await
.map_err(|e| {
error(
Expand Down Expand Up @@ -250,10 +253,12 @@ pub async fn dispense_tokens(
let coin_output = if let Some(previous_coin_output) = &guard.last_output {
*previous_coin_output
} else {
get_coin_output(&wallet).await.map_err(|e| {
cleanup();
e
})?
get_coin_output(&wallet, config.dispense_amount)
.await
.map_err(|e| {
cleanup();
e
})?
};

let coin_type = CoinType::Coin(Coin {
Expand Down

0 comments on commit 35e7e12

Please sign in to comment.