-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: add new contracts-periphery package #2536
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@eth-optimism/contracts-periphery': minor | ||
| --- | ||
|
|
||
| Releases the first version of the contracts-periphery package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ignores: [ | ||
| "@openzeppelin/contracts", | ||
| "@rari-capital/solmate", | ||
| "@types/node", | ||
| "hardhat-deploy", | ||
| "ts-node", | ||
| "typescript", | ||
| "prettier-plugin-solidity", | ||
| "solhint-plugin-prettier", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Etherscan API key for Ethereum and Ethereum testnets | ||
| ETHERSCAN_API_KEY= | ||
|
|
||
| # Etherscan API key for Optimism and Optimism testnets | ||
| OPTIMISTIC_ETHERSCAN_API_KEY= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| extends: '../../.eslintrc.js', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.sol linguist-language=Solidity |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| "*.{ts,js}": | ||
| - eslint | ||
| "*.sol": | ||
| - yarn solhint -f table |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| coverage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| ...require('../../.prettierrc.js'), | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| module.exports = { | ||
| skipFiles: [ | ||
| './test-libraries', | ||
| ], | ||
| mocha: { | ||
| grep: "@skip-on-coverage", | ||
| invert: true | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "extends": "solhint:recommended", | ||
| "plugins": ["prettier"], | ||
| "rules": { | ||
| "prettier/prettier": "error", | ||
| "compiler-version": "off", | ||
| "code-complexity": ["warn", 5], | ||
| "max-line-length": ["error", 100], | ||
| "func-param-name-mixedcase": "error", | ||
| "modifier-name-mixedcase": "error", | ||
| "ordering": "warn", | ||
| "not-rely-on-time": "off", | ||
| "no-complex-fallback": "off", | ||
| "not-rely-on-block-hash": "off", | ||
| "reentrancy": "off", | ||
| "contract-name-camelcase": "off" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| (The MIT License) | ||
|
|
||
| Copyright 2020-2021 Optimism | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| "Software"), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Optimism Peripheral Smart Contracts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| checks: | ||
| - name: eth-gas-reporter/codechecks | ||
| settings: | ||
| speculativeBranchSelection: false | ||
| branches: | ||
| - develop | ||
| - master |
12 changes: 12 additions & 0 deletions
12
packages/contracts-periphery/contracts/testing/helpers/TestERC20.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.9; | ||
|
|
||
| import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
|
|
||
| contract TestERC20 is ERC20 { | ||
| constructor() ERC20("TEST", "TST") {} | ||
|
|
||
| function mint(address to, uint256 value) public { | ||
| _mint(to, value); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
packages/contracts-periphery/contracts/testing/helpers/TestERC721.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.9; | ||
|
|
||
| import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
|
|
||
| contract TestERC721 is ERC721 { | ||
| constructor() ERC721("TEST", "TST") {} | ||
|
|
||
| function mint(address to, uint256 tokenId) public { | ||
| _mint(to, tokenId); | ||
| } | ||
| } |
117 changes: 117 additions & 0 deletions
117
packages/contracts-periphery/contracts/universal/RetroReceiver.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.9; | ||
|
|
||
| import { Owned } from "@rari-capital/solmate/src/auth/Owned.sol"; | ||
| import { ERC20 } from "@rari-capital/solmate/src/tokens/ERC20.sol"; | ||
| import { ERC721 } from "@rari-capital/solmate/src/tokens/ERC721.sol"; | ||
|
|
||
| /** | ||
| * @title RetroReceiver | ||
| * @notice RetroReceiver is a minimal contract for receiving funds, meant to be deployed at the | ||
| * same address on every chain that supports EIP-2470. | ||
| */ | ||
| contract RetroReceiver is Owned { | ||
| /** | ||
| * Emitted when ETH is received by this address. | ||
| */ | ||
| event ReceivedETH(address indexed from, uint256 amount); | ||
|
|
||
| /** | ||
| * Emitted when ETH is withdrawn from this address. | ||
| */ | ||
| event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount); | ||
|
|
||
| /** | ||
| * Emitted when ERC20 tokens are withdrawn from this address. | ||
| */ | ||
| event WithdrewERC20( | ||
| address indexed withdrawer, | ||
| address indexed recipient, | ||
| address indexed asset, | ||
| uint256 amount | ||
| ); | ||
|
|
||
| /** | ||
| * Emitted when ERC721 tokens are withdrawn from this address. | ||
| */ | ||
| event WithdrewERC721( | ||
| address indexed withdrawer, | ||
| address indexed recipient, | ||
| address indexed asset, | ||
| uint256 id | ||
| ); | ||
|
|
||
| /** | ||
| * @param _owner Address to initially own the contract. | ||
| */ | ||
| constructor(address _owner) Owned(_owner) {} | ||
|
|
||
| /** | ||
| * Make sure we can receive ETH. | ||
| */ | ||
| receive() external payable { | ||
| emit ReceivedETH(msg.sender, msg.value); | ||
| } | ||
|
|
||
| /** | ||
| * Withdraws full ETH balance to the recipient. | ||
| * | ||
| * @param _to Address to receive the ETH balance. | ||
| */ | ||
| function withdrawETH(address payable _to) public onlyOwner { | ||
| withdrawETH(_to, address(this).balance); | ||
| } | ||
|
|
||
| /** | ||
| * Withdraws partial ETH balance to the recipient. | ||
| * | ||
| * @param _to Address to receive the ETH balance. | ||
| * @param _amount Amount of ETH to withdraw. | ||
| */ | ||
| function withdrawETH(address payable _to, uint256 _amount) public onlyOwner { | ||
| _to.transfer(_amount); | ||
| emit WithdrewETH(msg.sender, _to, _amount); | ||
| } | ||
|
|
||
| /** | ||
| * Withdraws full ERC20 balance to the recipient. | ||
| * | ||
| * @param _asset ERC20 token to withdraw. | ||
| * @param _to Address to receive the ERC20 balance. | ||
| */ | ||
| function withdrawERC20(ERC20 _asset, address _to) public onlyOwner { | ||
| withdrawERC20(_asset, _to, _asset.balanceOf(address(this))); | ||
| } | ||
|
|
||
| /** | ||
| * Withdraws partial ERC20 balance to the recipient. | ||
| * | ||
| * @param _asset ERC20 token to withdraw. | ||
| * @param _to Address to receive the ERC20 balance. | ||
| * @param _amount Amount of ERC20 to withdraw. | ||
| */ | ||
| function withdrawERC20( | ||
| ERC20 _asset, | ||
| address _to, | ||
| uint256 _amount | ||
| ) public onlyOwner { | ||
| _asset.transfer(_to, _amount); | ||
| emit WithdrewERC20(msg.sender, _to, address(_asset), _amount); | ||
| } | ||
|
|
||
| /** | ||
| * Withdraws ERC721 token to the recipient. | ||
| * | ||
| * @param _asset ERC721 token to withdraw. | ||
| * @param _to Address to receive the ERC721 token. | ||
| * @param _id Token ID of the ERC721 token to withdraw. | ||
| */ | ||
| function withdrawERC721( | ||
| ERC721 _asset, | ||
| address _to, | ||
| uint256 _id | ||
| ) public onlyOwner { | ||
| _asset.transferFrom(address(this), _to, _id); | ||
| emit WithdrewERC721(msg.sender, _to, address(_asset), _id); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.