* fixed visibility warnings * solved visibility and line length warning * change a test assertion that fails due to chai dependence update * linter, constructor style and solved visibility warnings * Changed Windows line endings to Unix.
45 lines
858 B
Solidity
45 lines
858 B
Solidity
pragma solidity ^0.4.24;
|
|
|
|
import "./ERC20Basic.sol";
|
|
import "./ERC20.sol";
|
|
|
|
|
|
/**
|
|
* @title SafeERC20
|
|
* @dev Wrappers around ERC20 operations that throw on failure.
|
|
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
|
|
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
|
|
*/
|
|
library SafeERC20 {
|
|
function safeTransfer(
|
|
ERC20Basic _token,
|
|
address _to,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.transfer(_to, _value));
|
|
}
|
|
|
|
function safeTransferFrom(
|
|
ERC20 _token,
|
|
address _from,
|
|
address _to,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.transferFrom(_from, _to, _value));
|
|
}
|
|
|
|
function safeApprove(
|
|
ERC20 _token,
|
|
address _spender,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.approve(_spender, _value));
|
|
}
|
|
}
|