Skip to content

Commit ecec7b9

Browse files
Merge pull request #79 from argentlabs/release/1.5.0
Release 1.5.0
2 parents b555729 + 16be4ec commit ecec7b9

File tree

106 files changed

+13179
-8400
lines changed

Some content is hidden

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

106 files changed

+13179
-8400
lines changed

.circleci/config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 2
2+
3+
job_common: &job_common
4+
docker:
5+
- image: circleci/node:8.12-stretch
6+
working_directory: ~/argent-contracts
7+
step_save_cache: &step_save_cache
8+
save_cache:
9+
paths:
10+
- ~/.cache/package-lock
11+
key: node-modules-{{ checksum "package-lock.json" }}
12+
step_restore_cache: &step_restore_cache
13+
restore_cache:
14+
keys:
15+
- node-modules-{{ checksum "package-lock.json" }}
16+
step_setup_global_packages: &step_setup_global_packages
17+
run:
18+
name: "Set up global packages"
19+
command: |
20+
npm install
21+
22+
jobs:
23+
unit-test:
24+
<<: *job_common
25+
steps:
26+
- checkout
27+
- <<: *step_restore_cache
28+
- <<: *step_setup_global_packages
29+
- run:
30+
name: "Lint contracts"
31+
command: npm run lint:contracts
32+
- run:
33+
name: "Compiling external library contracts"
34+
command: npm run compile:lib
35+
- run:
36+
name: "Compiling contracts"
37+
command: npm run compile
38+
- run:
39+
name: "Running unit tests"
40+
command: npm run ganache >/dev/null 2>&1 & npm run test
41+
- run:
42+
name: "Testing deployment scripts"
43+
command: npm run ganache >/dev/null 2>&1 & npm run test:deployment
44+
- <<: *step_save_cache
45+
# Save test results to artifacts
46+
- store_test_results:
47+
path: test-results.xml
48+
- store_artifacts:
49+
path: test-results.xml
50+
51+
workflows:
52+
version: 2
53+
commit:
54+
jobs:
55+
- unit-test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ utils/config/*.json
3030

3131
## Etherlime
3232
**/.etherlime-store
33+
flat
3334

3435

3536

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8.12.0

.soliumignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
node_modules
2+
migrations
3+
openzeppelin-solidity
4+
lib
5+
contracts/test/CryptoKitties.sol
6+
contracts/test/KyberNetworkTest.sol
7+
contracts/test/TestContract.sol
8+
contracts/test/TestERC20.sol
9+
contracts/test/TestERC721.sol
10+
contracts/test/argent/legacy/LegacyBaseWallet.sol
11+
contracts/test/argent/legacy/TokenTransfer.sol
12+
contracts/test/argent/utils/ERC20Approver.sol
13+
contracts/test/argent/utils/NewTestModule.sol
14+
contracts/test/argent/utils/NonCompliantGuardian.sol
15+
contracts/test/argent/utils/OldTestModule.sol
16+
contracts/test/argent/utils/TestDapp.sol
17+
contracts/test/argent/utils/TestModule.sol
18+
contracts/test/argent/utils/TestOnlyOwnerModule.sol
19+
contracts/test/compound/CErc20.sol
20+
contracts/test/compound/CEther.sol
21+
contracts/test/compound/CToken.sol
22+
contracts/test/compound/CarefulMath.sol
23+
contracts/test/compound/Comptroller.sol
24+
contracts/test/compound/ComptrollerInterface.sol
25+
contracts/test/compound/ComptrollerStorage.sol
26+
contracts/test/compound/EIP20Interface.sol
27+
contracts/test/compound/EIP20NonStandardInterface.sol
28+
contracts/test/compound/ErrorReporter.sol
29+
contracts/test/compound/Exponential.sol
30+
contracts/test/compound/InterestRateModel.sol
31+
contracts/test/compound/Maximillion.sol
32+
contracts/test/compound/PriceOracle.sol
33+
contracts/test/compound/PriceOracleProxy.sol
34+
contracts/test/compound/ReentrancyGuard.sol
35+
contracts/test/compound/SimplePriceOracle.sol
36+
contracts/test/compound/Unitroller.sol
37+
contracts/test/compound/WhitePaperInterestRateModel.sol
38+
contracts/test/maker/DS/DSAuth.sol
39+
contracts/test/maker/DS/DSMath.sol
40+
contracts/test/maker/DS/DSNote.sol
41+
contracts/test/maker/DS/DSStop.sol
42+
contracts/test/maker/DS/DSThing.sol
43+
contracts/test/maker/DS/DSToken.sol
44+
contracts/test/maker/DS/DSValue.sol
45+
contracts/test/maker/MockScdMcdMigration.sol
46+
contracts/test/maker/SaiTub.sol
47+
contracts/test/maker/SaiVox.sol
48+
contracts/test/maker/WETH9.sol

.soliumrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "solium:all",
3+
"plugins": ["security"],
4+
"rules": {
5+
"arg-overflow": ["warning", 5],
6+
"variable-declarations": "error",
7+
"security/no-inline-assembly": 0,
8+
"error-reason": "error",
9+
"max-len": "error",
10+
"no-trailing-whitespace": "error",
11+
"blank-lines": 0
12+
}
13+
}
14+

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ npm install
1212
```
1313

1414
## Compile
15+
Compile the external contracts:
16+
```
17+
npm run compile:lib
18+
```
1519

1620
Compile the contracts:
1721
```
317 KB
Binary file not shown.

contracts/MultiSigWallet.sol

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
1+
// Copyright (C) 2018 Argent Labs Ltd. <https://argent.xyz>
2+
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
13+
// You should have received a copy of the GNU General Public License
14+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
116
pragma solidity ^0.5.4;
217

318
/**
419
* @title MultiSig
520
* @dev Simple MultiSig using off-chain signing.
6-
* @author Julien Niset - <julien@argent.im>
21+
* @author Julien Niset - <julien@argent.xyz>
722
*/
823
contract MultiSigWallet {
924

1025
uint constant public MAX_OWNER_COUNT = 10;
1126

1227
// Incrementing counter to prevent replay attacks
13-
uint256 public nonce;
14-
// The threshold
15-
uint256 public threshold;
28+
uint256 public nonce;
29+
// The threshold
30+
uint256 public threshold;
1631
// The number of owners
1732
uint256 public ownersCount;
1833
// Mapping to check if an address is an owner
19-
mapping (address => bool) public isOwner;
34+
mapping (address => bool) public isOwner;
2035

2136
// Events
2237
event OwnerAdded(address indexed owner);
@@ -26,7 +41,8 @@ contract MultiSigWallet {
2641
event Received(uint256 indexed value, address indexed from);
2742

2843
/**
29-
* @dev Throws is the calling account is not the multisig.
44+
* @dev Throws if the calling account is not the multisig.
45+
* @dev Mainly used for enforcing the use of internal functions through the "execute" function
3046
*/
3147
modifier onlyWallet() {
3248
require(msg.sender == address(this), "MSW: Calling account is not wallet");
@@ -36,23 +52,23 @@ contract MultiSigWallet {
3652
/**
3753
* @dev Constructor.
3854
* @param _threshold The threshold of the multisig.
39-
* @param _owners The owners of the multisig.
55+
* @param _owners The initial set of owners of the multisig.
4056
*/
4157
constructor(uint256 _threshold, address[] memory _owners) public {
4258
require(_owners.length > 0 && _owners.length <= MAX_OWNER_COUNT, "MSW: Not enough or too many owners");
4359
require(_threshold > 0 && _threshold <= _owners.length, "MSW: Invalid threshold");
4460
ownersCount = _owners.length;
4561
threshold = _threshold;
46-
for(uint256 i = 0; i < _owners.length; i++) {
62+
for (uint256 i = 0; i < _owners.length; i++) {
4763
isOwner[_owners[i]] = true;
4864
emit OwnerAdded(_owners[i]);
4965
}
5066
emit ThresholdChanged(_threshold);
5167
}
5268

5369
/**
54-
* @dev Only entry point of the multisig. The method will execute any transaction provided that it
55-
* receieved enough signatures from the wallet owners.
70+
* @dev Only entry point of the multisig. The method will execute any transaction provided that it
71+
* receieved enough signatures from the wallet owners.
5672
* @param _to The destination address for the transaction to execute.
5773
* @param _value The value parameter for the transaction to execute.
5874
* @param _data The data parameter for the transaction to execute.
@@ -68,27 +84,28 @@ contract MultiSigWallet {
6884
nonce += 1;
6985
uint256 valid = 0;
7086
address lastSigner = address(0);
71-
for(uint256 i = 0; i < count; i++) {
87+
for (uint256 i = 0; i < count; i++) {
7288
(v,r,s) = splitSignature(_signatures, i);
7389
address recovered = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32",txHash)), v, r, s);
7490
require(recovered > lastSigner, "MSW: Badly ordered signatures"); // make sure signers are different
7591
lastSigner = recovered;
76-
if(isOwner[recovered]) {
92+
if (isOwner[recovered]) {
7793
valid += 1;
78-
if(valid >= threshold) {
94+
if (valid >= threshold) {
95+
// solium-disable-next-line security/no-call-value
7996
(bool success,) = _to.call.value(_value)(_data);
8097
require(success, "MSW: External call failed");
8198
emit Executed(_to, _value, _data);
8299
return;
83100
}
84101
}
85102
}
86-
// If we reach that point then the transaction is not executed
103+
// If not enough signatures for threshold, then the transaction is not executed
87104
revert("MSW: Not enough valid signatures");
88105
}
89106

90107
/**
91-
* @dev Adds an owner to the multisig. This method can only be called by the multisig itself
108+
* @dev Adds an owner to the multisig. This method can only be called by the multisig itself
92109
* (i.e. it must go through the execute method and be confirmed by the owners).
93110
* @param _owner The address of the new owner.
94111
*/
@@ -101,9 +118,9 @@ contract MultiSigWallet {
101118
}
102119

103120
/**
104-
* @dev Removes an owner from the multisig. This method can only be called by the multisig itself
121+
* @dev Removes an owner from the multisig. This method can only be called by the multisig itself
105122
* (i.e. it must go through the execute method and be confirmed by the owners).
106-
* @param _owner The address of the removed owner.
123+
* @param _owner The address of the owner to be removed.
107124
*/
108125
function removeOwner(address _owner) public onlyWallet {
109126
require(ownersCount > threshold, "MSW: Too few owners left");
@@ -114,7 +131,7 @@ contract MultiSigWallet {
114131
}
115132

116133
/**
117-
* @dev Changes the threshold of the multisig. This method can only be called by the multisig itself
134+
* @dev Changes the threshold of the multisig. This method can only be called by the multisig itself
118135
* (i.e. it must go through the execute method and be confirmed by the owners).
119136
* @param _newThreshold The new threshold.
120137
*/
@@ -125,28 +142,29 @@ contract MultiSigWallet {
125142
}
126143

127144
/**
128-
* @dev Makes it possible for the multisig to receive ETH.
129-
*/
130-
function () external payable {
131-
emit Received(msg.value, msg.sender);
132-
}
133-
134-
/**
135145
* @dev Parses the signatures and extract (r, s, v) for a signature at a given index.
136-
* A signature is {bytes32 r}{bytes32 s}{uint8 v} in compact form and signatures are concatenated.
146+
* A signature is {bytes32 r}{bytes32 s}{uint8 v} in compact form where the signatures are concatenated.
137147
* @param _signatures concatenated signatures
138148
* @param _index which signature to read (0, 1, 2, ...)
139149
*/
140150
function splitSignature(bytes memory _signatures, uint256 _index) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
141151
// we jump 32 (0x20) as the first slot of bytes contains the length
142152
// we jump 65 (0x41) per signature
143153
// for v we load 32 bytes ending with v (the first 31 come from s) tehn apply a mask
154+
// solium-disable-next-line security/no-inline-assembly
144155
assembly {
145156
r := mload(add(_signatures, add(0x20,mul(0x41,_index))))
146157
s := mload(add(_signatures, add(0x40,mul(0x41,_index))))
147158
v := and(mload(add(_signatures, add(0x41,mul(0x41,_index)))), 0xff)
148159
}
149-
require(v == 27 || v == 28, "MSW: Invalid v");
160+
require(v == 27 || v == 28, "MSW: Invalid v");
161+
}
162+
163+
/**
164+
* @dev Fallback function to allow the multisig to receive ETH, which will fail if not implemented
165+
*/
166+
function () external payable {
167+
emit Received(msg.value, msg.sender);
150168
}
151169

152170
}

contracts/base/Managed.sol

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (C) 2018 Argent Labs Ltd. <https://argent.xyz>
2+
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
13+
// You should have received a copy of the GNU General Public License
14+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
116
pragma solidity ^0.5.4;
217
import "./Owned.sol";
318

@@ -23,15 +38,15 @@ contract Managed is Owned {
2338
event ManagerRevoked(address indexed _manager);
2439

2540
/**
26-
* @dev Adds a manager.
41+
* @dev Adds a manager.
2742
* @param _manager The address of the manager.
2843
*/
2944
function addManager(address _manager) external onlyOwner {
3045
require(_manager != address(0), "M: Address must not be null");
31-
if(managers[_manager] == false) {
46+
if (managers[_manager] == false) {
3247
managers[_manager] = true;
3348
emit ManagerAdded(_manager);
34-
}
49+
}
3550
}
3651

3752
/**

contracts/base/Owned.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
// Copyright (C) 2018 Argent Labs Ltd. <https://argent.xyz>
2+
3+
// This program is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
8+
// This program is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
13+
// You should have received a copy of the GNU General Public License
14+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
116
pragma solidity ^0.5.4;
217

318
/**

0 commit comments

Comments
 (0)