Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Add solidity linter #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "default",
"rules": {
"avoid-call-value": "warn",
"const-name-snakecase": "warn",
"func-name-mixedcase": "warn",
"func-order": "warn",
"func-param-name-mixedcase": "warn",
"var-name-mixedcase": "warn",
"visibility-modifier-order": "warn"
}
}
1 change: 1 addition & 0 deletions contracts/Factory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.4.15;


contract Factory {

/*
Expand Down
31 changes: 16 additions & 15 deletions contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
pragma solidity ^0.4.15;


contract Migrations {
address public owner;
uint public last_completed_migration;
address public owner;
uint public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _;
}
modifier restricted() {
if (msg.sender == owner) _;
}

function Migrations() {
owner = msg.sender;
}
function Migrations() {
owner = msg.sender;
}

function setCompleted(uint completed) restricted {
last_completed_migration = completed;
}
function setCompleted(uint completed) restricted {
last_completed_migration = completed;
}

function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
35 changes: 17 additions & 18 deletions contracts/MultiSigWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract MultiSigWallet {
public
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
for (uint i = 0; i < _owners.length; i++) {
require(!isOwner[_owners[i]] && _owners[i] != 0);
isOwner[_owners[i]] = true;
}
Expand Down Expand Up @@ -139,7 +139,7 @@ contract MultiSigWallet {
ownerExists(owner)
{
isOwner[owner] = false;
for (uint i=0; i<owners.length - 1; i++)
for (uint i = 0; i < owners.length - 1; i++)
if (owners[i] == owner) {
owners[i] = owners[owners.length - 1];
break;
Expand All @@ -159,7 +159,7 @@ contract MultiSigWallet {
ownerExists(owner)
ownerDoesNotExist(newOwner)
{
for (uint i=0; i<owners.length; i++)
for (uint i = 0; i < owners.length; i++)
if (owners[i] == owner) {
owners[i] = newOwner;
break;
Expand Down Expand Up @@ -244,12 +244,14 @@ contract MultiSigWallet {
function external_call(address destination, uint value, uint dataLength, bytes data) private returns (bool) {
bool result;
assembly {
let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory"
// pointer is stored by convention)
let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
result := call(
sub(gas, 34710), // 34710 is the value that solidity is currently emitting
// It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
// callNewAccountGas (25000, in case the destination address does not exist and needs creating)
// It includes callGas (700) + callVeryLow (3, to pay for SUB) +
// callValueTransferGas (9000) + callNewAccountGas (25000, in case
// the destination address does not exist and needs creating)
destination,
value,
d,
Expand All @@ -270,7 +272,7 @@ contract MultiSigWallet {
returns (bool)
{
uint count = 0;
for (uint i=0; i<owners.length; i++) {
for (uint i = 0; i < owners.length; i++) {
if (confirmations[transactionId][owners[i]])
count += 1;
if (count == required)
Expand Down Expand Up @@ -313,7 +315,7 @@ contract MultiSigWallet {
constant
returns (uint count)
{
for (uint i=0; i<owners.length; i++)
for (uint i = 0; i < owners.length; i++)
if (confirmations[transactionId][owners[i]])
count += 1;
}
Expand All @@ -327,9 +329,8 @@ contract MultiSigWallet {
constant
returns (uint count)
{
for (uint i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
for (uint i = 0; i < transactionCount; i++)
if (pending && !transactions[i].executed || executed && transactions[i].executed)
count += 1;
}

Expand All @@ -354,13 +355,13 @@ contract MultiSigWallet {
address[] memory confirmationsTemp = new address[](owners.length);
uint count = 0;
uint i;
for (i=0; i<owners.length; i++)
for (i = 0; i < owners.length; i++)
if (confirmations[transactionId][owners[i]]) {
confirmationsTemp[count] = owners[i];
count += 1;
}
_confirmations = new address[](count);
for (i=0; i<count; i++)
for (i = 0; i < count; i++)
_confirmations[i] = confirmationsTemp[i];
}

Expand All @@ -378,15 +379,13 @@ contract MultiSigWallet {
uint[] memory transactionIdsTemp = new uint[](transactionCount);
uint count = 0;
uint i;
for (i=0; i<transactionCount; i++)
if ( pending && !transactions[i].executed
|| executed && transactions[i].executed)
{
for (i = 0; i < transactionCount; i++)
if (pending && !transactions[i].executed || executed && transactions[i].executed) {
transactionIdsTemp[count] = i;
count += 1;
}
_transactionIds = new uint[](to - from);
for (i=from; i<to; i++)
for (i = from; i < to; i++)
_transactionIds[i - from] = transactionIdsTemp[i];
}
}
56 changes: 28 additions & 28 deletions contracts/TestCalls.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ pragma solidity ^0.4.15;
/// @title Contract for testing low-level calls issued from the multisig wallet
contract TestCalls {

// msg.data.length of the latest call to "receive" methods
uint public lastMsgDataLength;
// msg.data.length of the latest call to "receive" methods
uint public lastMsgDataLength;

// msg.value of the latest call to "receive" methods
uint public lastMsgValue;
// msg.value of the latest call to "receive" methods
uint public lastMsgValue;

uint public uint1;
uint public uint2;
bytes public byteArray1;
uint public uint1;
uint public uint2;
bytes public byteArray1;

modifier setMsgFields {
lastMsgDataLength = msg.data.length;
lastMsgValue = msg.value;
_;
}
modifier setMsgFields {
lastMsgDataLength = msg.data.length;
lastMsgValue = msg.value;
_;
}

function TestCalls() setMsgFields public {
// This constructor will be used to test the creation via multisig wallet
}
function TestCalls() setMsgFields public {
// This constructor will be used to test the creation via multisig wallet
}

function receive1uint(uint a) setMsgFields payable public {
uint1 = a;
}
function receive1uint(uint a) setMsgFields payable public {
uint1 = a;
}

function receive2uints(uint a, uint b) setMsgFields payable public {
uint1 = a;
uint2 = b;
}
function receive2uints(uint a, uint b) setMsgFields payable public {
uint1 = a;
uint2 = b;
}

function receive1bytes(bytes c) setMsgFields payable public {
byteArray1 = c;
}
function receive1bytes(bytes c) setMsgFields payable public {
byteArray1 = c;
}

function nonPayable() setMsgFields public {
}
function nonPayable() setMsgFields public {
}

}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"test-dapp": "cd dapp && npm test",
"test": "sh truffle_test_runner.sh",
"lint-contracts": "solhint contracts/**/*.sol",
"install": "cd dapp && npm install",
"start": "cd dapp && npm start"
},
Expand Down Expand Up @@ -36,6 +37,7 @@
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0"
"eslint-plugin-react": "^7.3.0",
"solhint": "^1.1.10"
}
}