Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: running forge update and fixing OZ related methods #98

Merged
merged 6 commits into from
Jul 11, 2024

Conversation

wei3erHase
Copy link

@wei3erHase wei3erHase commented Jul 9, 2024

As a second step from #97 in order to improve contracts inheritability from an external repo, this PR aims to update OZ to the latest version (5.0.2), which brought incompatibilities with repos using this version (as Math rounding enum was modified, for example).

Proposed changes:

  • run forge update to fetch latest packages (OZ and UniV2)
  • replaced safeApprove with forceApprove (note: different behaviour)
  • replaced Math.Rounding.Up/Down for Ceil/Floor

Pending:

  • testDeploymentRevertsIfApprovalReverts test is failing with a different expectation than written on the test, this must come from the different behaviour that forceApprove has over safeApprove, this test expectation should be fixed before merging

fedgiac pushed a commit that referenced this pull request Jul 9, 2024
This PR aims to make the `GetTradeableOrder` library easily inherited by
other repos.
Also it removes the unused `tradedAmountToken0` from the library.

Pending issues addressed in [draft] #98:
- [ ] installed OpenZeppelin is 4.9.0, Math Rounding enum are different
than 5.0.2
([latest](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/05f218fb6617932e56bf5388c3b389c3028a7b73/contracts/utils/math/Math.sol#L13))
- [ ] OZ 5.0.2 deprecated `safeApprove` (which brings tests errors on
the "when approve returns false" expectations)
Copy link
Collaborator

@fedgiac fedgiac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!

lib/openzeppelin Outdated Show resolved Hide resolved
@wei3erHase wei3erHase marked this pull request as ready for review July 10, 2024 10:06
@wei3erHase wei3erHase requested a review from fedgiac July 10, 2024 10:07
abi.encodeCall(IERC20.approve, (spenderBadApproval, type(uint256).max)),
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notice: making the approve call generically revert when called with spenderBadApproval (reverts for every amount, instead of for type(uint256).max)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abi.encodeCall(IERC20.approve, (spenderBadApproval, type(uint256).max)),
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),
// Notice: we intentionally don't match the approved amount.
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),

abi.encodeCall(IERC20.approve, (spenderBadApproval, type(uint256).max)),
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abi.encodeCall(IERC20.approve, (spenderBadApproval, type(uint256).max)),
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),
// Notice: we intentionally don't match the approved amount.
abi.encodeWithSelector(IERC20.approve.selector, spenderBadApproval),

@fedgiac fedgiac merged commit 6566128 into cowprotocol:test-interface Jul 11, 2024
3 checks passed
@wei3erHase wei3erHase deleted the chore/forge-update branch July 11, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants