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

feat: Use @openzeppelin/[email protected] contracts in contracts we can upgrade #598

Closed
wants to merge 8 commits into from

Conversation

nicholaspai
Copy link
Member

Imports an aliased npm package so we can use multiple oz libraries in the same solidity contracts.

This way we get access to new and improved contracts. I make changes to all contracts that we can upgrade, such as SpokePools and NOT the HubPool.

For example, I can use the new SafeERC20 method forceApprove instead of safeIncreaseAllowance which ensures compatibility with tokens like USDT that make sure all approvals are set to 0 before granting a new approval. This hasn't been an issue so far because we always safeIncreaseAllowance to some number and use the complete allowance, but its worth safety checking.

Other changes:

  • Moved MerkleDistributor out of uma/core into this repo to reduce dependency on this external repo
  • Replaced isCode() call with now recommended explicit .code.length check
  • Explicitly set SpokePoolVerifier pragma to 0.8.19 and removed the overrides in hardhat.config.ts
  • Removed unused import in PolygonERC20Test

…pgrade

Imports an [aliased npm package](https://forum.openzeppelin.com/t/coexist-of-v5-and-v4-contracts/38030/5) so we can use multiple oz libraries in the same solidity contracts.

This way we get access to new and improved contracts. I make changes to all contracts that we can upgrade, such as SpokePools and NOT the HubPool.

For example, I can use the new SafeERC20 method `forceApprove` instead of `safeIncreaseAllowance` which ensures [compatibility with tokens like USDT](OpenZeppelin/openzeppelin-contracts#4231) that make sure all approvals are set to 0 before granting a new approval. This hasn't been an issue so far because we always safeIncreaseAllowance to some number and use the complete allowance, but its worth safety checking.

Other changes:
- Moved `MerkleDistributor` out of uma/core into this repo to reduce dependency on this external repo
- Replaced isCode() call with now [recommended](OpenZeppelin/openzeppelin-contracts#3945) explicit .code.length check
- Explicitly set SpokePoolVerifier pragma to 0.8.19 and removed the overrides in hardhat.config.ts
- Removed unused import in PolygonERC20Test
@nicholaspai nicholaspai requested review from bmzig and pxrl September 11, 2024 12:40
pragma solidity ^0.8.0;
// NOTE: Linea and Arbitrum only support 0.8.19, so keep this contract at 19 so create2 addressses for all chains are
// the same.
pragma solidity ^0.8.19;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be =0.8.19?

Copy link
Member Author

Choose a reason for hiding this comment

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

i think that's right

@nicholaspai
Copy link
Member Author

I need to revise this PR and remove all the contracts5 imports into SpokePool because Arbitrum/Linea_SpokePool can't use those new contracts because they must be compiled with 8.19 while contracts5 uses 8.20

@nicholaspai nicholaspai marked this pull request as draft September 24, 2024 00:36
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.

2 participants