Skip to content

Commit 6150800

Browse files
committed
docs: add return docs + error messages
1 parent f2f2ba3 commit 6150800

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

contracts/tokens/WrappedPinakion.sol

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,14 @@ contract WrappedPinakion is Initializable {
165165
* @notice Moves `_amount` tokens from the caller's account to `_recipient`.
166166
* @param _recipient The entity receiving the funds.
167167
* @param _amount The amount to tranfer in base units.
168+
* @return True on success.
168169
*/
169170
function transfer(address _recipient, uint256 _amount) public returns (bool) {
170171
if (isContract(controller)) {
171-
require(TokenController(controller).onTransfer(msg.sender, _recipient, _amount));
172+
require(
173+
TokenController(controller).onTransfer(msg.sender, _recipient, _amount),
174+
"Token controller rejects transfer."
175+
);
172176
}
173177
balances[msg.sender] = balances[msg.sender].sub(_amount); // ERC20: transfer amount exceeds balance
174178
balances[_recipient] = balances[_recipient].add(_amount);
@@ -182,14 +186,18 @@ contract WrappedPinakion is Initializable {
182186
* @param _sender The entity to take the funds from.
183187
* @param _recipient The entity receiving the funds.
184188
* @param _amount The amount to tranfer in base units.
189+
* @return True on success.
185190
*/
186191
function transferFrom(
187192
address _sender,
188193
address _recipient,
189194
uint256 _amount
190195
) public returns (bool) {
191196
if (isContract(controller)) {
192-
require(TokenController(controller).onTransfer(_sender, _recipient, _amount));
197+
require(
198+
TokenController(controller).onTransfer(_sender, _recipient, _amount),
199+
"Token controller rejects transfer."
200+
);
193201
}
194202

195203
/** The controller of this contract can move tokens around at will,
@@ -211,6 +219,7 @@ contract WrappedPinakion is Initializable {
211219
* @notice Approves `_spender` to spend `_amount`.
212220
* @param _spender The entity allowed to spend funds.
213221
* @param _amount The amount of base units the entity will be allowed to spend.
222+
* @return True on success.
214223
*/
215224
function approve(address _spender, uint256 _amount) public returns (bool) {
216225
// Alerts the token controller of the approve function call
@@ -230,6 +239,7 @@ contract WrappedPinakion is Initializable {
230239
* @notice Increases the `_spender` allowance by `_addedValue`.
231240
* @param _spender The entity allowed to spend funds.
232241
* @param _addedValue The amount of extra base units the entity will be allowed to spend.
242+
* @return True on success.
233243
*/
234244
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
235245
uint256 newAllowance = allowance[msg.sender][_spender].add(_addedValue);
@@ -250,6 +260,7 @@ contract WrappedPinakion is Initializable {
250260
* @notice Decreases the `_spender` allowance by `_subtractedValue`.
251261
* @param _spender The entity whose spending allocation will be reduced.
252262
* @param _subtractedValue The reduction of spending allocation in base units.
263+
* @return True on success.
253264
*/
254265
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool) {
255266
uint256 newAllowance = allowance[msg.sender][_spender].sub(_subtractedValue); // ERC20: decreased allowance below zero
@@ -287,7 +298,10 @@ contract WrappedPinakion is Initializable {
287298
*/
288299
function _burn(uint256 _amount) internal {
289300
if (isContract(controller)) {
290-
require(TokenController(controller).onTransfer(msg.sender, address(0x0), _amount));
301+
require(
302+
TokenController(controller).onTransfer(msg.sender, address(0x0), _amount),
303+
"Token controller rejects transfer."
304+
);
291305
}
292306
balances[msg.sender] = balances[msg.sender].sub(_amount); // ERC20: burn amount exceeds balance
293307
totalSupply = totalSupply.sub(_amount);

0 commit comments

Comments
 (0)