Skip to content

Commit

Permalink
fix: use > instead of >= in solidity amount VC first assertion clause…
Browse files Browse the repository at this point in the history
…, only use > 0 in clause when amount = 0 for solidity amount assertion
  • Loading branch information
higherordertech committed Aug 5, 2024
1 parent d5447d2 commit 96576ee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ abstract contract TokenHoldingAmount is DynamicAssertion {
string[] memory assertions = assembleAssertions(
min,
max,
balance,
tokenLowercaseName
);

Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,7 +113,7 @@ describe('TokenHoldingAmount', () => {
},
{
src: '$holding_amount',
op: Op.GTE,
op: Op.GT,
dst: '0',
},
{
Expand Down

0 comments on commit 96576ee

Please sign in to comment.