Skip to content

Commit

Permalink
migrate to hardhat (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
ralph-pichler authored Mar 17, 2021
1 parent 2ebab00 commit 9748522
Show file tree
Hide file tree
Showing 10 changed files with 6,465 additions and 8,229 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '12'

# Restore the yarn cache
- uses: c-hive/gha-yarn-cache@v1

- name: Yarn install
run: yarn install

- name: Linter
run: yarn lint

- name: Compile
run: yarn compile

- name: Test
run: yarn test

- name: Coverage
run: yarn coverage
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ The `master` branch only contains the `SimpleSwap` contract for now. Everything

## Tests

This is a regular truffle project. You can either use `truffle test` (if installed) or `npm test` which will use a locally installed truffle.
This is a hardhat project using the truffle plugin (for tests as this used to be truffle-based). You can run tests using `yarn test`.

```sh
npm install
npm test
yarn
yarn test
```

To also generate coverage information use `npm run coverage` instead.
To also generate coverage information use `yarn coverage` instead.

## Linting

This repo currently uses `solhint` as linter. It can be called through npm:
This repo currently uses `solhint` as linter. It can be called through yarn:
```sh
npm run solhint
yarn lint
```

## Go-bindings

To generate go bindings use
```sh
npm run abigen
yarn abigen
```

This will generate the bindings in the `bindings/` directory. Suitable versions of `solc` and `abigen` have to be installed for this to work.
Alternatively this can also be done through docker:

```sh
docker build -t sw3 -f Dockerfile.abigen .
docker run -v $(pwd)/bindings:/sw3/bindings sw3 npm run abigen
docker run -v $(pwd)/bindings:/sw3/bindings sw3 yarn abigen
```

In addition to the file from `abigen` this will also generate a go file that includes the runtime bytecode.
Expand Down
35 changes: 35 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require("@nomiclabs/hardhat-truffle5");
require("solidity-coverage")


// Define mnemonic for accounts.
let mnemonic = process.env.MNEMONIC;
if (!mnemonic) {
// NOTE: this fallback is for development only!
// When using other networks, set the secret in .env.
// DO NOT commit or share your mnemonic with others!
mnemonic = 'test test test test test test test test test test test test';
}

const accounts = { mnemonic };

// Config for hardhat.
module.exports = {
solidity: { version: '0.6.12' },
networks: {
hardhat: {
accounts,
},
localhost: {
url: 'http://localhost:8545',
accounts,
},
staging: {
url: 'https://goerli.infura.io/v3/' + process.env.INFURA_TOKEN,
accounts,
},
},
paths: {
sources: 'contracts',
},
};
Loading

0 comments on commit 9748522

Please # to comment.