-
Notifications
You must be signed in to change notification settings - Fork 74
Optimism L2 - token [Hardhat - v2] #33
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 1 commit
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5d44e69
Optimism L2 integration
krebernisak 557b4f2
Add more LinkTokenChild tests
krebernisak 9b30fba
Update with latest upstream changes
krebernisak 242a046
Introduce contract versioning
krebernisak 94f2aa3
Change v0.6 contracts code style
krebernisak a712092
Remove export of JS helper functions
krebernisak 9a0e59c
Include vendor contract source
krebernisak 27ecfda
Add CI network teardown step
krebernisak 8731d53
Replace OZ AccessControl with CL SimpleWriteAccessController
krebernisak 4413c43
Polish tests
krebernisak bf2e2f7
Rename IERC20Child deposit/withdraw as mint/burn
krebernisak 0c557cc
Use submodules for vendor contracts
krebernisak 3b0ca75
Rename interfaces and flatten contracts
krebernisak 7c41212
Fix the L2 gasPrice to 1 gwei
krebernisak e317c66
Fix tests error handling (avoid TX_OVERRIDES_BUG)
krebernisak 6c37ec6
Revert token name change
krebernisak 9e0dcd8
Update to latest deps + compiler config bug fix
krebernisak 70fca4f
Add README docs (NOTICE) for LinkTokenChild contract
krebernisak 07371f6
Remove Optimism 1 gwei fixed price
krebernisak 426f174
Update to latest upstream changes
krebernisak f8a0f44
Merge branch 'master' into feature/oe-token
krebernisak b641420
Revert to before merge updated deps
krebernisak 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,27 @@ | ||
| # | ||
| # This action checks PRs to see if any CHANGELOG* files were updated. | ||
| # If none were, it will add a message to the PR asking if it would make sense to do so. | ||
| # | ||
| name: Changelog | ||
|
|
||
| on: pull_request | ||
|
|
||
| jobs: | ||
| changelog: | ||
| name: Changelog checker | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check for changed files | ||
| id: changedfiles | ||
| uses: futuratrepadeira/changed-files@186b5b30b1f5e44ed655a59652746c3ce00d53ef # Version v3.1.1 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| pattern: '^CHANGELOG.*$' | ||
| - name: Make a comment | ||
| uses: unsplash/comment-on-pr@d1a1d5dd1eb1bb657a01f4d92dd5e4d5bb7857d3 # Version v1.2.0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| if: contains(steps.changedfiles.outputs.files_updated, 'CHANGELOG') != true && contains(steps.changedfiles.outputs.files_created, 'CHANGELOG') != true | ||
| with: | ||
| msg: "I see that you haven't updated any CHANGELOG files. Would it make sense to do so?" | ||
| check_for_duplicate_msg: false |
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,37 @@ | ||
| name: Main | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: ~ | ||
|
|
||
| jobs: | ||
| run-basic-checks: | ||
| name: Run linters and unit tests | ||
| runs-on: [self-hosted] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '14.x' | ||
| - run: npm install -g yarn | ||
| - run: yarn install | ||
| - run: yarn setup | ||
| - run: yarn lint | ||
| - run: yarn test | ||
| run-integration: | ||
| name: Setup and run integration tests | ||
| needs: [run-basic-checks] | ||
| runs-on: [self-hosted] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '14.x' | ||
| - run: npm install -g yarn | ||
| - run: yarn install | ||
| - run: yarn setup | ||
| - name: Setup Optimism L2 local network | ||
| run: yarn script:oe:up | ||
| - run: yarn test --network optimism |
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 |
|---|---|---|
|
|
@@ -8,3 +8,6 @@ coverage.json | |
|
|
||
| # Misc | ||
| .DS_STORE | ||
|
|
||
| # Optimism monorepo used for integration tests | ||
| /optimism | ||
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,2 @@ | ||
| node 14.16.0 | ||
| yarn 1.22.4 |
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
| # Changelog LinkToken | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] - Apr 2021 | ||
|
|
||
| ### Added | ||
|
|
||
| - Access controlled mintable & burnable LinkToken, for use on sidechains and L2 networks. | ||
|
|
||
| ### Changed | ||
|
|
||
| - Migrated to Hardhat and Waffle | ||
|
|
||
| ### Fixed | ||
|
|
||
| ### Removed | ||
|
|
||
| - Truffle framework and tests dependencies | ||
|
|
||
| ## [1.1.0] - Mar 2021 | ||
|
|
||
| Initial @chainlink/token release! | ||
|
|
||
| ### Added | ||
|
|
||
| - Solidity 0.6 support | ||
| - Simple token swapping contract | ||
|
|
||
| ## [1.0.6] - Sep 2018 | ||
|
|
||
| Initial link_token release! |
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 |
|---|---|---|
| @@ -1,41 +1,73 @@ | ||
| # LINK Token Contracts [](https://travis-ci.org/smartcontractkit/LinkToken) | ||
| # LINK Token Contracts | ||
|
|
||
| The LINK token is an [EIP20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md) token with additional [ERC677](https://github.com/ethereum/EIPs/issues/677) functionality. | ||
|
|
||
| The total supply of the token is 1,000,000,000, and each token is divisible up to 18 decimal places. | ||
|
|
||
| To prevent accidental burns, the token does not allow transfers to the contract itself and to 0x0. | ||
|
|
||
| Security audit for [v0.4 version of the contracts](./contracts/v0.4/) is available [here](https://gist.github.com/Arachnid/4aa88041bd6e34835b8c0fd051245e79). | ||
| Security audit for [0.4 version of the contracts](./contracts/v0.4/) is available [here](https://gist.github.com/Arachnid/4aa88041bd6e34835b8c0fd051245e79). | ||
|
|
||
| ## Details | ||
|
|
||
| - Deployments: | ||
| - Ethereum Mainnet [LinkToken v0.4](./flat/v0.4/LinkToken.sol): [0x514910771AF9Ca656af840dff83E8264EcF986CA](https://etherscan.io/address/0x514910771af9ca656af840dff83e8264ecf986ca) | ||
| - Ethereum Mainnet [LinkToken 0.4](./flat/v0.4/LinkToken.sol): [0x514910771AF9Ca656af840dff83E8264EcF986CA](https://etherscan.io/address/0x514910771af9ca656af840dff83e8264ecf986ca) | ||
| - Decimals: 18 | ||
| - Name: ChainLink Token | ||
| - Symbol: LINK | ||
|
|
||
| ## Installation | ||
| ## Setup | ||
|
|
||
| The project contains [v0.4 contracts](./contracts/v0.4/) that were used for LINK Ethereum Mainnet deployment in 2017. For deployments moving forward, we use the updated [v0.6 contracts](./contracts/v0.6/) which use a more recent version of solc and the OpenZeppelin token standards. These updates include a minor ABI change around approval/allowance naming. | ||
| The project contains [0.4 contracts](./contracts/v0.4/) that were used for LINK Ethereum Mainnet deployment in 2017. For deployments moving forward, we use the updated [0.6 contracts](./contracts/v0.6/) which use a more recent version of solc and the OpenZeppelin token standards. These updates include a minor ABI change around approval/allowance naming. | ||
|
|
||
| ```bash | ||
| yarn install | ||
| ``` | ||
|
|
||
| ## Testing | ||
|
|
||
| Setup contracts: | ||
|
|
||
| ```bash | ||
| yarn setup | ||
| ``` | ||
|
|
||
| This will compile all versions of the contracts. | ||
|
|
||
| ## Testing | ||
|
|
||
| Run tests: | ||
|
|
||
| ```bash | ||
| yarn test | ||
| ``` | ||
|
|
||
| This will test both v0.4 and v0.6 versions of the contracts. | ||
| This will run unit tests for all versions of the contracts. | ||
|
|
||
| ## Integration testing | ||
|
|
||
| Integration tests are currently setup for Optimism contracts, and to run them make sure you have a local network running first. | ||
|
|
||
| The network can be started using a helpful script, which will clone the [Optimism monorepo](https://github.com/ethereum-optimism/optimism), build the : | ||
|
|
||
| ```bash | ||
| yarn script:oe:up | ||
| ``` | ||
|
|
||
| Run tests: | ||
|
|
||
| ```bash | ||
| yarn test --network optimism | ||
| ``` | ||
|
|
||
| This will run unit tests for all versions of the contracts, plus supported integration tests against the local L1 & L2 networks. | ||
|
|
||
| The network can be stopped using another script: | ||
|
|
||
| ```bash | ||
| yarn script:oe:down | ||
| ``` | ||
|
|
||
| Or use the clean script, which will also delete all the images: | ||
|
|
||
| ```bash | ||
| yarn script:oe:clean | ||
| ``` |
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 @@ | ||
| # LINK Token Contracts v0.7 | ||
|
|
||
| ## Token bridge contracts | ||
|
|
||
| LinkToken bridge contracts can be found in the [./bridge](./bridge) directory. |
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 @@ | ||
| # LINK Token Bridge v0.7 | ||
|
|
||
| - `./LinkTokenChild.sol`: A mintable & burnable child LinkToken contract to be used on child networks. |
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,25 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity >0.6.0 <0.8.0; | ||
|
|
||
| /* Interface Imports */ | ||
| import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
|
|
||
| /// @dev Interface of the child ERC20 token, for use on sidechains and L2 networks. | ||
| interface IERC20Child is IERC20 { | ||
| /** | ||
| * @notice called by bridge gateway when tokens are deposited on root chain | ||
| * Should handle deposits by minting the required amount for the recipient | ||
| * | ||
| * @param recipient an address for whom deposit is being done | ||
| * @param amount total amount to deposit/mint | ||
| */ | ||
| function deposit(address recipient, uint256 amount) external; | ||
|
|
||
| /** | ||
| * @notice called by bridge gateway when tokens are withdrawn back to root chain | ||
| * @dev Should burn recipient's tokens. | ||
| * | ||
| * @param amount total amount to withdraw/burn | ||
| */ | ||
| function withdraw(uint256 amount) external; | ||
| } |
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,70 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity >0.6.0 <0.8.0; | ||
|
|
||
| /* Interface Imports */ | ||
| import { IERC20Child } from "./IERC20Child.sol"; | ||
|
|
||
| /* Contract Imports */ | ||
| import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol"; | ||
| import { LinkToken } from "../../../v0.6/LinkToken.sol"; | ||
|
krebernisak marked this conversation as resolved.
|
||
|
|
||
| /// @dev Access controlled mintable & burnable LinkToken, for use on sidechains and L2 networks. | ||
| contract LinkTokenChild is IERC20Child, AccessControl, LinkToken { | ||
|
|
||
| // Using this role the bridge gateway can deposit/withdraw (mint/burn) | ||
| bytes32 public constant BRIDGE_GATEWAY_ROLE = keccak256("BRIDGE_GATEWAY_ROLE"); | ||
|
|
||
| /** | ||
| * @dev Overrides parent contract so no tokens are minted on deployment. | ||
| * @inheritdoc LinkToken | ||
| */ | ||
| function _onCreate() | ||
| internal | ||
| override | ||
| { | ||
| _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Modifier to check access by role. | ||
| * | ||
| * @param role the required role | ||
| */ | ||
| modifier onlyRole( | ||
| bytes32 role | ||
| ) { | ||
| require(hasRole(role, _msgSender()), "LinkTokenChild: missing role"); | ||
| _; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Only callable by account with BRIDGE_GATEWAY_ROLE | ||
| * @inheritdoc IERC20Child | ||
| */ | ||
| function deposit( | ||
| address recipient, | ||
| uint256 amount | ||
|
krebernisak marked this conversation as resolved.
|
||
| ) | ||
| external | ||
| override | ||
| virtual | ||
| onlyRole(BRIDGE_GATEWAY_ROLE) | ||
| { | ||
| _mint(recipient, amount); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Only callable by account with BRIDGE_GATEWAY_ROLE | ||
| * @inheritdoc IERC20Child | ||
| */ | ||
| function withdraw( | ||
| uint256 amount | ||
| ) | ||
| external | ||
| override | ||
| virtual | ||
| onlyRole(BRIDGE_GATEWAY_ROLE) | ||
| { | ||
| _burn(_msgSender(), amount); | ||
| } | ||
| } | ||
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 @@ | ||
| ### KOVAN | ||
| # make sure this private key has Kovan ETH! | ||
| PRIVATE_KEY= | ||
| L1_WEB3_URL=https://kovan.infura.io/v3/API_KEY | ||
| L2_WEB3_URL=https://kovan.optimism.io |
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 @@ | ||
| ### LOCAL (optimism-integration repo) | ||
| PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
| L1_WEB3_URL=http://127.0.0.1:9545 | ||
| L2_WEB3_URL=http://127.0.0.1:8545 |
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.