Skip to content

Commit 985646f

Browse files
Add visibility modifiers for each functions
Summary: Reduce lint warnings Reviewers: barath Reviewed By: barath Differential Revision: https://phabricator.bitgo.com/D7175
1 parent 01e86e3 commit 985646f

File tree

4 files changed

+57
-32
lines changed

4 files changed

+57
-32
lines changed

contracts/ERC20Interface.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pragma solidity ^0.4.11;
55

66
contract ERC20Interface {
77
// Send _value amount of tokens to address _to
8-
function transfer(address _to, uint256 _value) returns (bool success);
8+
function transfer(address _to, uint256 _value) public returns (bool success);
99
// Get the account balance of another account with address _owner
10-
function balanceOf(address _owner) constant returns (uint256 balance);
10+
function balanceOf(address _owner) public constant returns (uint256 balance);
1111
}

contracts/FixedSupplyToken.sol

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ pragma solidity ^0.4.11;
99
// https://github.com/ethereum/EIPs/issues/20
1010
contract ERC20Interface {
1111
// Get the total token supply
12-
function totalSupply() constant returns (uint256 totalSupply);
12+
function totalSupply() public constant returns (uint256 totalSupply);
1313

1414
// Get the account balance of another account with address _owner
15-
function balanceOf(address _owner) constant returns (uint256 balance);
15+
function balanceOf(address _owner) public constant returns (uint256 balance);
1616

1717
// Send _value amount of tokens to address _to
18-
function transfer(address _to, uint256 _value) returns (bool success);
18+
function transfer(address _to, uint256 _value) public returns (bool success);
1919

2020
// Send _value amount of tokens from address _from to address _to
21-
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
21+
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
2222

2323
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
2424
// If this function is called again it overwrites the current allowance with _value.
2525
// this function is required for some DEX functionality
26-
function approve(address _spender, uint256 _value) returns (bool success);
26+
function approve(address _spender, uint256 _value) public returns (bool success);
2727

2828
// Returns the amount which _spender is still allowed to withdraw from _owner
29-
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
29+
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
3030

3131
// Triggered when tokens are transferred.
3232
event Transfer(address indexed _from, address indexed _to, uint256 _value);
@@ -59,22 +59,22 @@ contract FixedSupplyToken is ERC20Interface {
5959
}
6060

6161
// Constructor
62-
function FixedSupplyToken() {
62+
function FixedSupplyToken() public {
6363
owner = msg.sender;
6464
balances[owner] = _totalSupply;
6565
}
6666

67-
function totalSupply() constant returns (uint256 totalSupply) {
67+
function totalSupply() public constant returns (uint256 totalSupply) {
6868
totalSupply = _totalSupply;
6969
}
7070

7171
// What is the balance of a particular account?
72-
function balanceOf(address _owner) constant returns (uint256 balance) {
72+
function balanceOf(address _owner) public constant returns (uint256 balance) {
7373
return balances[_owner];
7474
}
7575

7676
// Transfer the balance from owner's account to another account
77-
function transfer(address _to, uint256 _amount) returns (bool success) {
77+
function transfer(address _to, uint256 _amount) public returns (bool success) {
7878
if (balances[msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) {
7979
balances[msg.sender] -= _amount;
8080
balances[_to] += _amount;
@@ -95,7 +95,7 @@ contract FixedSupplyToken is ERC20Interface {
9595
address _from,
9696
address _to,
9797
uint256 _amount
98-
) returns (bool success) {
98+
) public returns (bool success) {
9999
if (balances[_from] >= _amount && allowed[_from][msg.sender] >= _amount && _amount > 0 && balances[_to] + _amount > balances[_to]) {
100100
balances[_from] -= _amount;
101101
allowed[_from][msg.sender] -= _amount;
@@ -109,13 +109,13 @@ contract FixedSupplyToken is ERC20Interface {
109109

110110
// Allow _spender to withdraw from your account, multiple times, up to the _value amount.
111111
// If this function is called again it overwrites the current allowance with _value.
112-
function approve(address _spender, uint256 _amount) returns (bool success) {
112+
function approve(address _spender, uint256 _amount) public returns (bool success) {
113113
allowed[msg.sender][_spender] = _amount;
114114
Approval(msg.sender, _spender, _amount);
115115
return true;
116116
}
117117

118-
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
118+
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
119119
return allowed[_owner][_spender];
120120
}
121121
}

contracts/Forwarder.sol

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,26 @@ contract Forwarder {
1111
/**
1212
* Create the contract, and set the destination address to `target`
1313
*/
14-
function Forwarder(address target) {
14+
function Forwarder(address target) public {
1515
targetAddress = target;
1616
}
1717

1818
/**
1919
* Default function; Gets called when Ether is deposited, and forwards it to the target address
2020
*/
21-
function() payable {
22-
if (!targetAddress.call.value(msg.value)(msg.data))
21+
function() public payable {
22+
if (!targetAddress.call.value(msg.value)(msg.data)) {
2323
throw;
24-
// Fire off the deposited event if we can forward it
24+
}
25+
// Fire off the deposited event if we can forward it
2526
ForwarderDeposited(msg.sender, msg.value, msg.data);
2627
}
2728

2829
/**
2930
* Execute a token transfer of the full balance from the forwarder token to the target address
3031
* @param tokenContractAddress the address of the erc20 token contract
3132
*/
32-
function flushTokens(address tokenContractAddress) {
33+
function flushTokens(address tokenContractAddress) public {
3334
ERC20Interface instance = ERC20Interface(tokenContractAddress);
3435
var forwarderAddress = address(this);
3536
var forwarderBalance = instance.balanceOf(forwarderAddress);
@@ -45,8 +46,9 @@ contract Forwarder {
4546
* It is possible that funds were sent to this address before the contract was deployed.
4647
* We can flush those funds to the target address.
4748
*/
48-
function flush() {
49-
if (!targetAddress.call.value(this.balance)())
49+
function flush() public {
50+
if (!targetAddress.call.value(this.balance)()) {
5051
throw;
52+
}
5153
}
5254
}

contracts/WalletSimple.sol

+33-10
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ contract WalletSimple {
4444
*
4545
* @param allowedSigners An array of signers on the wallet
4646
*/
47-
function WalletSimple(address[] allowedSigners) {
47+
function WalletSimple(address[] allowedSigners) public {
4848
if (allowedSigners.length != 3) {
4949
// Invalid number of signers
5050
throw;
@@ -55,7 +55,7 @@ contract WalletSimple {
5555
/**
5656
* Gets called when a transaction is received without calling a method
5757
*/
58-
function() payable {
58+
function() public payable {
5959
if (msg.value > 0) {
6060
// Fire deposited event if we are receiving funds
6161
Deposited(msg.sender, msg.value, msg.data);
@@ -74,7 +74,14 @@ contract WalletSimple {
7474
* @param sequenceId the unique sequence id obtainable from getNextSequenceId
7575
* @param signature the result of eth.sign on the operationHash sha3(toAddress, value, data, expireTime, sequenceId)
7676
*/
77-
function sendMultiSig(address toAddress, uint value, bytes data, uint expireTime, uint sequenceId, bytes signature) onlysigner {
77+
function sendMultiSig(
78+
address toAddress,
79+
uint value,
80+
bytes data,
81+
uint expireTime,
82+
uint sequenceId,
83+
bytes signature
84+
) public onlysigner {
7885
// Verify the other signer
7986
var operationHash = sha3("ETHER", toAddress, value, data, expireTime, sequenceId);
8087

@@ -100,7 +107,14 @@ contract WalletSimple {
100107
* @param sequenceId the unique sequence id obtainable from getNextSequenceId
101108
* @param signature the result of eth.sign on the operationHash sha3(toAddress, value, tokenContractAddress, expireTime, sequenceId)
102109
*/
103-
function sendMultiSigToken(address toAddress, uint value, address tokenContractAddress, uint expireTime, uint sequenceId, bytes signature) onlysigner {
110+
function sendMultiSigToken(
111+
address toAddress,
112+
uint value,
113+
address tokenContractAddress,
114+
uint expireTime,
115+
uint sequenceId,
116+
bytes signature
117+
) public onlysigner {
104118
// Verify the other signer
105119
var operationHash = sha3("ERC20", toAddress, value, tokenContractAddress, expireTime, sequenceId);
106120

@@ -122,7 +136,13 @@ contract WalletSimple {
122136
* @param sequenceId the unique sequence id obtainable from getNextSequenceId
123137
* returns address of the address to send tokens or eth to
124138
*/
125-
function verifyMultiSig(address toAddress, bytes32 operationHash, bytes signature, uint expireTime, uint sequenceId) private returns (address) {
139+
function verifyMultiSig(
140+
address toAddress,
141+
bytes32 operationHash,
142+
bytes signature,
143+
uint expireTime,
144+
uint sequenceId
145+
) private returns (address) {
126146

127147
var otherSigner = recoverAddressFromSignature(operationHash, signature);
128148

@@ -155,7 +175,7 @@ contract WalletSimple {
155175
/**
156176
* Irrevocably puts contract into safe mode. When in this mode, transactions may only be sent to signing addresses.
157177
*/
158-
function activateSafeMode() onlysigner {
178+
function activateSafeMode() public onlysigner {
159179
safeMode = true;
160180
SafeModeActivated(msg.sender);
161181
}
@@ -165,7 +185,7 @@ contract WalletSimple {
165185
* @param signer address to check
166186
* returns boolean indicating whether address is signer or not
167187
*/
168-
function isSigner(address signer) returns (bool) {
188+
function isSigner(address signer) public view returns (bool) {
169189
// Iterate through all signers on the wallet and
170190
for (uint i = 0; i < signers.length; i++) {
171191
if (signers[i] == signer) {
@@ -181,7 +201,10 @@ contract WalletSimple {
181201
* @param signature the tightly packed signature of r, s, and v as an array of 65 bytes (returned by eth.sign)
182202
* returns address recovered from the signature
183203
*/
184-
function recoverAddressFromSignature(bytes32 operationHash, bytes signature) private returns (address) {
204+
function recoverAddressFromSignature(
205+
bytes32 operationHash,
206+
bytes signature
207+
) private pure returns (address) {
185208
if (signature.length != 65) {
186209
throw;
187210
}
@@ -206,7 +229,7 @@ contract WalletSimple {
206229
* greater than the minimum element in the window.
207230
* @param sequenceId to insert into array of stored ids
208231
*/
209-
function tryInsertSequenceId(uint sequenceId) onlysigner private {
232+
function tryInsertSequenceId(uint sequenceId) private onlysigner {
210233
// Keep a pointer to the lowest value element in the window
211234
uint lowestValueIndex = 0;
212235
for (uint i = 0; i < SEQUENCE_ID_WINDOW_SIZE; i++) {
@@ -235,7 +258,7 @@ contract WalletSimple {
235258
* Gets the next available sequence ID for signing when using executeAndConfirm
236259
* returns the sequenceId one higher than the highest currently stored
237260
*/
238-
function getNextSequenceId() returns (uint) {
261+
function getNextSequenceId() public view returns (uint) {
239262
uint highestSequenceId = 0;
240263
for (uint i = 0; i < SEQUENCE_ID_WINDOW_SIZE; i++) {
241264
if (recentSequenceIds[i] > highestSequenceId) {

0 commit comments

Comments
 (0)