Skip to content

Commit d90a2f3

Browse files
committed
fix: improve NatSpec and a few other details (C4 QA)
1 parent 23f9dad commit d90a2f3

15 files changed

+213
-129
lines changed

contracts/gateway/BridgeEscrow.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ import "../token/IGraphToken.sol";
1616
*/
1717
contract BridgeEscrow is Initializable, GraphUpgradeable, Managed {
1818
/**
19-
* @dev Initialize this contract.
19+
* @notice Initialize the BridgeEscrow contract.
2020
* @param _controller Address of the Controller that manages this contract
2121
*/
2222
function initialize(address _controller) external onlyImpl initializer {
2323
Managed._initialize(_controller);
2424
}
2525

2626
/**
27-
* @dev Approve a spender (i.e. a bridge that manages the GRT funds held by the escrow)
27+
* @notice Approve a spender (i.e. a bridge that manages the GRT funds held by the escrow)
2828
* @param _spender Address of the spender that will be approved
2929
*/
3030
function approveAll(address _spender) external onlyGovernor {
3131
graphToken().approve(_spender, type(uint256).max);
3232
}
3333

3434
/**
35-
* @dev Revoke a spender (i.e. a bridge that will no longer manage the GRT funds held by the escrow)
35+
* @notice Revoke a spender (i.e. a bridge that will no longer manage the GRT funds held by the escrow)
3636
* @param _spender Address of the spender that will be revoked
3737
*/
3838
function revokeAll(address _spender) external onlyGovernor {

contracts/gateway/GraphTokenGateway.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import "../governance/Managed.sol";
1212
* @dev This includes everything that's shared between the L1 and L2 sides of the bridge.
1313
*/
1414
abstract contract GraphTokenGateway is GraphUpgradeable, Pausable, Managed, ITokenGateway {
15-
// Storage gap added in case we need to add state variables to this contract
15+
/// @dev Storage gap added in case we need to add state variables to this contract
1616
uint256[50] private __gap;
1717

1818
/**
@@ -56,6 +56,7 @@ abstract contract GraphTokenGateway is GraphUpgradeable, Pausable, Managed, ITok
5656

5757
/**
5858
* @notice Getter to access paused state of this contract
59+
* @return True if the contract is paused, false otherwise
5960
*/
6061
function paused() external view returns (bool) {
6162
return _paused;

contracts/gateway/ICallhookReceiver.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pragma solidity ^0.7.6;
1010

1111
interface ICallhookReceiver {
1212
/**
13-
* @dev Receive tokens with a callhook from the bridge
13+
* @notice Receive tokens with a callhook from the bridge
1414
* @param _from Token sender in L1
1515
* @param _amount Amount of tokens that were transferred
1616
* @param _data ABI-encoded callhook data

contracts/gateway/L1GraphTokenGateway.sol

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ import "./GraphTokenGateway.sol";
2222
contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMessenger {
2323
using SafeMath for uint256;
2424

25-
// Address of the Graph Token contract on L2
25+
/// Address of the Graph Token contract on L2
2626
address public l2GRT;
27-
// Address of the Arbitrum Inbox
27+
/// Address of the Arbitrum Inbox
2828
address public inbox;
29-
// Address of the Arbitrum Gateway Router on L1
29+
/// Address of the Arbitrum Gateway Router on L1
3030
address public l1Router;
31-
// Address of the L2GraphTokenGateway on L2 that is the counterpart of this gateway
31+
/// Address of the L2GraphTokenGateway on L2 that is the counterpart of this gateway
3232
address public l2Counterpart;
33-
// Address of the BridgeEscrow contract that holds the GRT in the bridge
33+
/// Address of the BridgeEscrow contract that holds the GRT in the bridge
3434
address public escrow;
35-
// Addresses for which this mapping is true are allowed to send callhooks in outbound transfers
35+
/// Addresses for which this mapping is true are allowed to send callhooks in outbound transfers
3636
mapping(address => bool) public callhookWhitelist;
3737

38-
// Emitted when an outbound transfer is initiated, i.e. tokens are deposited from L1 to L2
38+
/// Emitted when an outbound transfer is initiated, i.e. tokens are deposited from L1 to L2
3939
event DepositInitiated(
4040
address l1Token,
4141
address indexed from,
@@ -44,7 +44,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
4444
uint256 amount
4545
);
4646

47-
// Emitted when an incoming transfer is finalized, i.e tokens are withdrawn from L2 to L1
47+
/// Emitted when an incoming transfer is finalized, i.e tokens are withdrawn from L2 to L1
4848
event WithdrawalFinalized(
4949
address l1Token,
5050
address indexed from,
@@ -53,17 +53,17 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
5353
uint256 amount
5454
);
5555

56-
// Emitted when the Arbitrum Inbox and Gateway Router addresses have been updated
56+
/// Emitted when the Arbitrum Inbox and Gateway Router addresses have been updated
5757
event ArbitrumAddressesSet(address inbox, address l1Router);
58-
// Emitted when the L2 GRT address has been updated
58+
/// Emitted when the L2 GRT address has been updated
5959
event L2TokenAddressSet(address l2GRT);
60-
// Emitted when the counterpart L2GraphTokenGateway address has been updated
60+
/// Emitted when the counterpart L2GraphTokenGateway address has been updated
6161
event L2CounterpartAddressSet(address l2Counterpart);
62-
// Emitted when the escrow address has been updated
62+
/// Emitted when the escrow address has been updated
6363
event EscrowAddressSet(address escrow);
64-
// Emitted when an address is added to the callhook whitelist
64+
/// Emitted when an address is added to the callhook whitelist
6565
event AddedToCallhookWhitelist(address newWhitelisted);
66-
// Emitted when an address is removed from the callhook whitelist
66+
/// Emitted when an address is removed from the callhook whitelist
6767
event RemovedFromCallhookWhitelist(address notWhitelisted);
6868

6969
/**
@@ -86,8 +86,8 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
8686
}
8787

8888
/**
89-
* @dev Initialize this contract.
90-
* The contract will be paused.
89+
* @notice Initialize the L1GraphTokenGateway contract.
90+
* @dev The contract will be paused.
9191
* Note some parameters have to be set separately as they are generally
9292
* not expected to be available at initialization time:
9393
* - inbox and l1Router using setArbitrumAddresses
@@ -104,7 +104,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
104104
}
105105

106106
/**
107-
* @dev Sets the addresses for L1 contracts provided by Arbitrum
107+
* @notice Sets the addresses for L1 contracts provided by Arbitrum
108108
* @param _inbox Address of the Inbox that is part of the Arbitrum Bridge
109109
* @param _l1Router Address of the Gateway Router
110110
*/
@@ -119,7 +119,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
119119
}
120120

121121
/**
122-
* @dev Sets the address of the L2 Graph Token
122+
* @notice Sets the address of the L2 Graph Token
123123
* @param _l2GRT Address of the GRT contract on L2
124124
*/
125125
function setL2TokenAddress(address _l2GRT) external onlyGovernor {
@@ -129,7 +129,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
129129
}
130130

131131
/**
132-
* @dev Sets the address of the counterpart gateway on L2
132+
* @notice Sets the address of the counterpart gateway on L2
133133
* @param _l2Counterpart Address of the corresponding L2GraphTokenGateway on Arbitrum
134134
*/
135135
function setL2CounterpartAddress(address _l2Counterpart) external onlyGovernor {
@@ -139,7 +139,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
139139
}
140140

141141
/**
142-
* @dev Sets the address of the escrow contract on L1
142+
* @notice Sets the address of the escrow contract on L1
143143
* @param _escrow Address of the BridgeEscrow
144144
*/
145145
function setEscrowAddress(address _escrow) external onlyGovernor {
@@ -150,7 +150,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
150150
}
151151

152152
/**
153-
* @dev Adds an address to the callhook whitelist.
153+
* @notice Adds an address to the callhook whitelist.
154154
* This address will be allowed to include callhooks when transferring tokens.
155155
* @param _newWhitelisted Address to add to the whitelist
156156
*/
@@ -163,7 +163,7 @@ contract L1GraphTokenGateway is Initializable, GraphTokenGateway, L1ArbitrumMess
163163
}
164164

165165
/**
166-
* @dev Removes an address from the callhook whitelist.
166+
* @notice Removes an address from the callhook whitelist.
167167
* This address will no longer be allowed to include callhooks when transferring tokens.
168168
* @param _notWhitelisted Address to remove from the whitelist
169169
*/

contracts/governance/Controller.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import "./Pausable.sol";
1313
* https://github.com/livepeer/protocol/blob/streamflow/contracts/Controller.sol
1414
*/
1515
contract Controller is Governed, Pausable, IController {
16-
// Track contract ids to contract proxy address
16+
/// @dev Track contract ids to contract proxy address
1717
mapping(bytes32 => address) private registry;
1818

19+
/// Emitted when the proxy address for a protocol contract has been set
1920
event SetContractProxy(bytes32 indexed id, address contractAddress);
2021

2122
/**
22-
* @dev Contract constructor.
23+
* @notice Controller contract constructor.
2324
*/
2425
constructor() {
2526
Governed._initialize(msg.sender);
@@ -74,6 +75,7 @@ contract Controller is Governed, Pausable, IController {
7475
/**
7576
* @notice Get contract proxy address by its id
7677
* @param _id Contract id
78+
* @return Address of the proxy contract for the provided id
7779
*/
7880
function getContractProxy(bytes32 _id) public view override returns (address) {
7981
return registry[_id];
@@ -120,13 +122,15 @@ contract Controller is Governed, Pausable, IController {
120122

121123
/**
122124
* @notice Getter to access paused
125+
* @return True if the contracts are paused, false otherwise
123126
*/
124127
function paused() external view override returns (bool) {
125128
return _paused;
126129
}
127130

128131
/**
129132
* @notice Getter to access partial pause status
133+
* @return True if the contracts are partially paused, false otherwise
130134
*/
131135
function partialPaused() external view override returns (bool) {
132136
return _partialPaused;

contracts/governance/Governed.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ pragma solidity ^0.7.6;
99
contract Governed {
1010
// -- State --
1111

12+
/// Address of the governor
1213
address public governor;
14+
/// Address of the new governor that is pending acceptance
1315
address public pendingGovernor;
1416

1517
// -- Events --
1618

19+
/// Emitted when a new owner/governor has been set, but is pending acceptance
1720
event NewPendingOwnership(address indexed from, address indexed to);
21+
/// Emitted when a new owner/governor has accepted their role
1822
event NewOwnership(address indexed from, address indexed to);
1923

2024
/**
@@ -26,14 +30,15 @@ contract Governed {
2630
}
2731

2832
/**
29-
* @dev Initialize the governor to the contract caller.
33+
* @dev Initialize the governor for this contract
34+
* @param _initGovernor Address of the governor
3035
*/
3136
function _initialize(address _initGovernor) internal {
3237
governor = _initGovernor;
3338
}
3439

3540
/**
36-
* @dev Admin function to begin change of governor. The `_newGovernor` must call
41+
* @notice Admin function to begin change of governor. The `_newGovernor` must call
3742
* `acceptOwnership` to finalize the transfer.
3843
* @param _newGovernor Address of new `governor`
3944
*/
@@ -47,7 +52,7 @@ contract Governed {
4752
}
4853

4954
/**
50-
* @dev Admin function for pending governor to accept role and update governor.
55+
* @notice Admin function for pending governor to accept role and update governor.
5156
* This function must called by the pending governor.
5257
*/
5358
function acceptOwnership() external {

0 commit comments

Comments
 (0)