From 96576ee2039d7337c28f431784c9ddf43c8133b5 Mon Sep 17 00:00:00 2001 From: higherordertech Date: Mon, 5 Aug 2024 19:27:09 +1000 Subject: [PATCH] fix: use > instead of >= in solidity amount VC first assertion clause, only use > 0 in clause when amount = 0 for solidity amount assertion --- .../token_holding_amount/TokenHoldingAmount.sol | 10 +++++++--- .../src/dynamic/tests/token-holding-amount.ts | 9 ++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/TokenHoldingAmount.sol b/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/TokenHoldingAmount.sol index 0369cd2f5a..ecfed404da 100644 --- a/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/TokenHoldingAmount.sol +++ b/tee-worker/litentry/core/assertion-build/src/dynamic/contracts/token_holding_amount/TokenHoldingAmount.sol @@ -68,6 +68,7 @@ abstract contract TokenHoldingAmount is DynamicAssertion { string[] memory assertions = assembleAssertions( min, max, + balance, tokenLowercaseName ); @@ -134,12 +135,13 @@ abstract contract TokenHoldingAmount is DynamicAssertion { function assembleAssertions( uint256 min, int256 max, + uint256 balance, string memory tokenName ) private pure returns (string[] memory) { string memory variable = "$holding_amount"; AssertionLogic.CompositeCondition memory cc = AssertionLogic .CompositeCondition( - new AssertionLogic.Condition[](max > 0 ? 3 : 2), + new AssertionLogic.Condition[](max > 0 && balance > 0 ? 3 : 2), true ); AssertionLogic.andOp( @@ -153,10 +155,12 @@ abstract contract TokenHoldingAmount is DynamicAssertion { cc, 1, variable, - AssertionLogic.Op.GreaterEq, + min == 0 + ? AssertionLogic.Op.GreaterThan + : AssertionLogic.Op.GreaterEq, StringShift.toShiftedString(min, Constants.decimals_factor) ); - if (max > 0) { + if (max > 0 && balance > 0) { AssertionLogic.andOp( cc, 2, diff --git a/tee-worker/litentry/core/assertion-build/src/dynamic/tests/token-holding-amount.ts b/tee-worker/litentry/core/assertion-build/src/dynamic/tests/token-holding-amount.ts index d422acbc9f..cd7963518e 100644 --- a/tee-worker/litentry/core/assertion-build/src/dynamic/tests/token-holding-amount.ts +++ b/tee-worker/litentry/core/assertion-build/src/dynamic/tests/token-holding-amount.ts @@ -54,14 +54,9 @@ describe('TokenHoldingAmount', () => { }, { src: '$holding_amount', - op: Op.GTE, + op: Op.GT, dst: '0', }, - { - src: '$holding_amount', - op: Op.LT, - dst: '1', - }, ], }, false @@ -118,7 +113,7 @@ describe('TokenHoldingAmount', () => { }, { src: '$holding_amount', - op: Op.GTE, + op: Op.GT, dst: '0', }, {