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: Standardization and cleanup #31

Merged
merged 3 commits into from
Mar 16, 2022
Merged

chore: Standardization and cleanup #31

merged 3 commits into from
Mar 16, 2022

Conversation

deluca-mike
Copy link
Contributor

Description

Integrations Checklist

  • Have any function signatures changed? If yes, outline below.
  • Have any features changed or been added? If yes, outline below.
  • Have any events changed or been added? If yes, outline below.
  • Has all documentation been updated?

Changelog

Function Signature Changes

Features

Events


// Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}.
require(
uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 &&
(v == 27 || v == 28),
uint256(s_) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0 &&
Copy link
Contributor

@vbidin vbidin Mar 15, 2022

Choose a reason for hiding this comment

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

You can also mark the limit explicitly as a uint256.

@@ -133,9 +133,9 @@ interface IERC20 {

/**
* @dev Returns the permit type hash.
* @return hash_ The permit type hash.
* @return permitTypeHash_ The permit type hash.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, should this be permitTypehash instead? Based on the name of the function.

@@ -10,240 +10,243 @@ import { MockERC20 } from "./mocks/MockERC20.sol";

contract ERC20BaseTest is TestUtils {

bytes constant ARITHMETIC_ERROR = abi.encodeWithSignature("Panic(uint256)", 0x11);
address internal immutable self = address(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK immutable should be all caps as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You'd think that, but check out issue 9554 in solidity's issues... They don't consider immutables constant.


function setUp() public virtual {
token = new MockERC20("Token", "TKN", 18);
function setUp() external virtual {
Copy link
Contributor

Choose a reason for hiding this comment

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

The style guide has the test functions marked as public, but not sure what the convention is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ight be just a copy and paste where it wasn't considered.

bytes32 digest = _getDigest(owner_, spender, value_, nonce, deadline_);
( uint8 v, bytes32 r, bytes32 s ) = vm.sign(ownerSk_, digest);
return (v, r, s);
function _getValidPermitSignature(uint256 amount_, address owner_, uint256 ownerSk_, uint256 deadline_) internal returns (uint8 v_, bytes32 r_, bytes32 s_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe reorder parameters based on order in the function call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, but I'll do one slightly better.

@lucas-manuel lucas-manuel merged commit 5f5d6c7 into main Mar 16, 2022
@lucas-manuel lucas-manuel deleted the chore/cleanup branch March 16, 2022 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants