Skip to content

Commit e2c61e4

Browse files
authored
Migration to hardhat (safe-fndn#256)
1 parent 760f634 commit e2c61e4

File tree

105 files changed

+10193
-4768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+10193
-4768
lines changed

.env.sample

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
MNEMONIC=""
2-
INFURA_TOKEN=""
2+
INFURA_KEY=""
3+
ETHERSCAN_API_KEY=""

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3-
4-
name: Node.js Package
1+
name: safe-contracts
52
on: [push, pull_request]
63

74
jobs:
@@ -11,11 +8,15 @@ jobs:
118
- uses: actions/checkout@v2
129
- uses: actions/setup-node@v2
1310
with:
14-
node-version: 12
11+
node-version: 15
1512
- uses: actions/cache@v2
1613
with:
1714
path: '**/node_modules'
1815
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
1916
- run: yarn
20-
- run: yarn truffle compile
21-
- run: yarn test
17+
- run: yarn build
18+
- run: yarn coverage
19+
- name: Coveralls
20+
uses: coverallsapp/github-action@master
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ node_modules/
66
env/
77
.env
88
bin/
9-
solc
9+
solc
10+
coverage/
11+
coverage.json
12+
yarn-error.log

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v12.20.1
1+
v15.6.0

.solcover.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
skipFiles: [
3+
'test/Token.sol',
4+
'test/ERC1155Token.sol',
5+
],
6+
mocha: {
7+
grep: "@skip-on-coverage", // Find everything with this tag
8+
invert: true // Run the grep's inverse set.
9+
}
10+
};

.solhint.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"plugins": [
4+
"prettier"
5+
],
6+
"rules": {
7+
"compiler-version": "off",
8+
"func-visibility": [
9+
"warn",
10+
{
11+
"ignoreConstructors": true
12+
}
13+
],
14+
"prettier/prettier": "error",
15+
"not-rely-on-time": "off",
16+
"reason-string": "off",
17+
"no-empty-blocks": "off",
18+
"avoid-low-level-calls": "off"
19+
}
20+
}

README.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Gnosis Safe Contracts
22
=====================
33

44
[![npm version](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-contracts.svg)](https://badge.fury.io/js/%40gnosis.pm%2Fsafe-contracts)
5-
[![Build Status](https://travis-ci.org/gnosis/safe-contracts.svg?branch=development)](https://travis-ci.org/gnosis/safe-contracts)
5+
[![Build Status](https://github.com/gnosis/safe-contracts/workflows/safe-contracts/badge.svg?branch=development)](https://github.com/gnosis/safe-contracts/actions)
6+
[![Coverage Status](https://coveralls.io/repos/github/gnosis/safe-contracts/badge.svg?branch=feature/hardhat)](https://coveralls.io/github/gnosis/safe-contracts?branch=feature/hardhat)
67

78
Install
89
-------
@@ -12,44 +13,49 @@ Install
1213
yarn
1314
```
1415

15-
### Run all tests (requires Node version >=7 for `async/await`):
16+
### Run all tests:
1617

1718
```bash
18-
yarn truffle compile
19+
yarn build
1920
yarn test
2021
```
2122

22-
`yarn test` will start a ganache-cli with the correct configuration. If you want to run `yarn truffle test` you need to start a [ganache-cli](https://github.com/trufflesuite/ganache-cli) instance. For this it is required to use the [`--noVMErrorsOnRPCResponse`](https://github.com/trufflesuite/ganache-cli#options) option. This option will make sure that ganache-cli behaves the same as other clients (e.g. geth and parity) when handling reverting calls to contracts. This is required as some flows parse the error message (see https://gnosis-safe.readthedocs.io/en/latest/contracts/transactions.html#safe-transaction-gas-limit-estimation).
23-
2423
### Deploy
2524

2625
Some contracts require that the Solidity compile target is at least `petersburg` (e.g. GnosisSafeProxyFactory and MultiSend). This is default since [Solidity 0.5.5](https://github.com/ethereum/solidity/releases/tag/v0.5.5).
2726

2827
Note: The formal verification was performed using the contract compiled with solcjs 0.5.0.
2928

30-
Preparation:
31-
- Set `INFURA_TOKEN` in `.env`
32-
- Set `NETWORK` in `.env`
33-
- Run `yarn truffle compile`
29+
This will deploy the contracts deterministically and verify the contracts on etherscan.
3430

35-
Truffle:
31+
Preparation:
3632
- Set `MNEMONIC` in `.env`
33+
- Set `INFURA_KEY` in `.env`
3734

3835
```bash
39-
yarn truffle deploy
36+
yarn deploy-all <network>
4037
```
4138

42-
### Verify contract
43-
44-
Note: To completely replicate the bytecode that has been deployed it is required that the project path is `/gnosis-safe` this can be archived using `sudo mkdir /gnosis-safe && sudo mount -B <your_repo_path> /gnosis-safe`. Make sure the run `yarn` again if the path has been changed after the inital `yarn install`. If you use a different path you will only get partial matches.
39+
This will perform the following steps
4540

46-
You can locally verify contract using the scripts `generate_meta.js` and `verify_deployment.js`.
41+
```bash
42+
yarn build
43+
yarn deploy --network <network>
44+
yarn hardhat --network <network> etherscan-verify
45+
yarn hardhat --network <network> local-verify
46+
```
4747

48-
With `node scripts/generate_meta.js` a `meta` folder is created in the `build` folder that contains all files required to verify the source code on https://verification.komputing.org/ and https://etherscan.io/
48+
### Verify contract
4949

50-
For Etherscan only the `GnosisSafeEtherscan.json` file is required. For sourcify the `GnosisSafeMeta.json` and all the `.sol` files are required.
50+
This command will use the deployment artifacts to compile the contracts and compare them to the onchain code
51+
```bash
52+
yarn hardhat --network <network> local-verify
53+
```
5154

52-
Once the meta data has been generated you can verify that your local compiled code corresponds to the version deployed by Gnosis with `yarn do <network> scripts/verify_deployment.js`.
55+
This command will upload the contract source to Etherescan
56+
```bash
57+
yarn hardhat --network <network> etherscan-verify
58+
```
5359

5460
Documentation
5561
-------------
@@ -69,12 +75,4 @@ All contracts are WITHOUT ANY WARRANTY; without even the implied warranty of MER
6975

7076
License
7177
-------
72-
All smart contracts are released under LGPL v.3.
73-
74-
Contributors
75-
------------
76-
- Stefan George ([Georgi87](https://github.com/Georgi87))
77-
- Richard Meissner ([rmeissner](https://github.com/rmeissner))
78-
- Christian Lundkvist ([christianlundkvist](https://github.com/christianlundkvist))
79-
- Nick Dodson ([SilentCicero](https://github.com/SilentCicero))
80-
- Gonçalo Sá ([GNSPS](https://github.com/GNSPS))
78+
All smart contracts are released under LGPL-3.0

contracts/GnosisSafe.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity >=0.5.0 <0.7.0;
1+
pragma solidity >=0.5.0 <0.6.0;
22
import "./base/ModuleManager.sol";
33
import "./base/OwnerManager.sol";
44
import "./base/FallbackManager.sol";
@@ -106,7 +106,7 @@ contract GnosisSafe
106106
/// @param data Data payload of Safe transaction.
107107
/// @param operation Operation type of Safe transaction.
108108
/// @param safeTxGas Gas that should be used for the Safe transaction.
109-
/// @param baseGas Gas costs for that are indipendent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
109+
/// @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
110110
/// @param gasPrice Gas price that should be used for the payment calculation.
111111
/// @param gasToken Token address (or 0 if ETH) that is used for the payment.
112112
/// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
@@ -359,8 +359,8 @@ contract GnosisSafe
359359
/// @param value Ether value.
360360
/// @param data Data payload.
361361
/// @param operation Operation type.
362-
/// @param safeTxGas Fas that should be used for the safe transaction.
363-
/// @param baseGas Gas costs for data used to trigger the safe transaction.
362+
/// @param safeTxGas Gas that should be used for the safe transaction.
363+
/// @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
364364
/// @param gasPrice Maximum gas price that should be used for this transaction.
365365
/// @param gasToken Token address (or 0 if ETH) that is used for the payment.
366366
/// @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).

contracts/Migrations.sol

Lines changed: 0 additions & 31 deletions
This file was deleted.

contracts/base/Executor.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity >=0.5.0 <0.7.0;
1+
pragma solidity >=0.5.0 <0.6.0;
22
import "../common/Enum.sol";
33

44

0 commit comments

Comments
 (0)