Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5d44e69
Optimism L2 integration
krebernisak Apr 6, 2021
557b4f2
Add more LinkTokenChild tests
krebernisak Apr 28, 2021
9b30fba
Update with latest upstream changes
krebernisak May 4, 2021
242a046
Introduce contract versioning
krebernisak May 5, 2021
94f2aa3
Change v0.6 contracts code style
krebernisak May 7, 2021
a712092
Remove export of JS helper functions
krebernisak May 7, 2021
9a0e59c
Include vendor contract source
krebernisak May 7, 2021
27ecfda
Add CI network teardown step
krebernisak May 9, 2021
8731d53
Replace OZ AccessControl with CL SimpleWriteAccessController
krebernisak May 10, 2021
4413c43
Polish tests
krebernisak May 11, 2021
bf2e2f7
Rename IERC20Child deposit/withdraw as mint/burn
krebernisak May 11, 2021
0c557cc
Use submodules for vendor contracts
krebernisak May 11, 2021
3b0ca75
Rename interfaces and flatten contracts
krebernisak May 12, 2021
7c41212
Fix the L2 gasPrice to 1 gwei
krebernisak May 12, 2021
e317c66
Fix tests error handling (avoid TX_OVERRIDES_BUG)
krebernisak May 13, 2021
6c37ec6
Revert token name change
krebernisak Jun 2, 2021
9e0dcd8
Update to latest deps + compiler config bug fix
krebernisak Jul 12, 2021
70fca4f
Add README docs (NOTICE) for LinkTokenChild contract
krebernisak Jun 28, 2021
07371f6
Remove Optimism 1 gwei fixed price
krebernisak Jul 15, 2021
426f174
Update to latest upstream changes
krebernisak Jul 15, 2021
f8a0f44
Merge branch 'master' into feature/oe-token
krebernisak Jul 15, 2021
b641420
Revert to before merge updated deps
krebernisak Jul 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/changelog.yml
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
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ coverage.json

# Misc
.DS_STORE

# Optimism monorepo used for integration tests
/optimism
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node 14.16.0
yarn 1.22.4
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

34 changes: 34 additions & 0 deletions CHANGELOG.md
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!
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,73 @@
# LINK Token Contracts [![Build Status](https://travis-ci.org/smartcontractkit/LinkToken.svg?branch=master)](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
```
5 changes: 5 additions & 0 deletions contracts/v0.7/README.md
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.
3 changes: 3 additions & 0 deletions contracts/v0.7/bridge/README.md
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.
25 changes: 25 additions & 0 deletions contracts/v0.7/bridge/token/IERC20Child.sol
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;
}
70 changes: 70 additions & 0 deletions contracts/v0.7/bridge/token/LinkTokenChild.sol
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";
Comment thread
krebernisak marked this conversation as resolved.
Outdated
import { LinkToken } from "../../../v0.6/LinkToken.sol";
Comment thread
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
Comment thread
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);
}
}
5 changes: 5 additions & 0 deletions env/.env.kovan
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
4 changes: 4 additions & 0 deletions env/.env.local
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
Loading