Skip to content

Commit

Permalink
Clean up comments on checkAllowances.ts (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipe.fuerback authored Apr 11, 2024
1 parent f911b65 commit 4323e35
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chaincode/src/allowances/checkAllowances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,22 @@ export async function checkAllowances(
action: AllowanceType,
callingOnBehalf: string
): Promise<BigNumber> {
// Sum the quantity applicable
let totalAllowance: BigNumber = new BigNumber(0);

const validAllowances = await cleanAllowances(ctx, applicableAllowances, callingOnBehalf);

validAllowances.forEach((allowance: TokenAllowance) => {
// Check if the token instance matches
// Check if the action matches
// Check if the swap has expired
// Check if allowance is expired
if (
allowance.collection === tokenInstanceKey.collection &&
allowance.category === tokenInstanceKey.category &&
allowance.type === tokenInstanceKey.type &&
allowance.additionalKey === tokenInstanceKey.additionalKey &&
allowance.instance.isEqualTo(tokenInstanceKey.instance) &&
allowance.allowanceType === action &&
(allowance.expires === 0 || (allowance.expires && allowance.expires >= ctx.txUnixTime))
(allowance.expires === 0 || isAllowanceExpired(ctx, allowance))
) {
totalAllowance = totalAllowance.plus(allowance.quantity).minus(allowance.quantitySpent);
}
Expand Down

0 comments on commit 4323e35

Please sign in to comment.