Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeruCodes committed Nov 23, 2024
1 parent 2c7ca74 commit b388e97
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/canister/individual_user_template/src/api/cdao/swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ pub async fn swap_request(token_pairs: TokenPairs) -> Result<(), SwapError>{
return Err(SwapError::IsNotTokenCreator);
}


// todo: replace this by a frontend server function instead because this uses the caller to infer the from field in approve...
let previous_approval_amt = get_previous_approval_amount(ic_cdk::caller(), ic_cdk::id(), token_a.ledger).await?;

let allocation_res: (Result<Nat, ApproveError>, ) = ic_cdk::call(token_a.ledger, "icrc2_approve", (ApproveArgs{
from_subaccount: None,
spender: ic_cdk::id().into(),
Expand All @@ -40,6 +41,8 @@ pub async fn swap_request(token_pairs: TokenPairs) -> Result<(), SwapError>{
fee: None,
created_at_time: None
}, )).await?;
// ....


allocation_res.0.map_err(SwapError::ApproveError)?;
// TODO: Push notifications
Expand Down

0 comments on commit b388e97

Please sign in to comment.