Skip to content

Commit

Permalink
s/value/amount/g
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Dafflon committed Feb 23, 2018
1 parent edc4873 commit 41e108c
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 101 deletions.
2 changes: 1 addition & 1 deletion contracts/ITokenRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ITokenRecipient {
address operator,
address from,
address to,
uint value,
uint amount,
bytes userData,
bytes operatorData
) public;
Expand Down
10 changes: 5 additions & 5 deletions contracts/Ierc20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ interface Ierc20 {
function decimals() public constant returns (uint8);
function totalSupply() public constant returns (uint256);
function balanceOf(address owner) public constant returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
function transfer(address to, uint256 amount) public returns (bool);
function transferFrom(address from, address to, uint256 amount) public returns (bool);
function approve(address spender, uint256 amount) public returns (bool);
function allowance(address owner, address spender) public constant returns (uint256);

// solhint-disable-next-line no-simple-event-func-name
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 amount);
event Approval(address indexed owner, address indexed spender, uint256 amount);
}
12 changes: 6 additions & 6 deletions contracts/Ierc777.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ interface Ierc777 {
function granularity() public constant returns (uint256);
function balanceOf(address owner) public constant returns (uint256);

function send(address to, uint256 value) public;
function send(address to, uint256 value, bytes userData) public;
function send(address to, uint256 amount) public;
function send(address to, uint256 amount, bytes userData) public;

function authorizeOperator(address operator) public;
function revokeOperator(address operator) public;
function isOperatorFor(address operator, address tokenHolder) public constant returns (bool);
function operatorSend(address from, address to, uint256 value, bytes userData, bytes operatorData) public;
function operatorSend(address from, address to, uint256 amount, bytes userData, bytes operatorData) public;

event Sent(
address indexed operator,
address indexed from,
address indexed to,
uint256 value,
uint256 amount,
bytes userData,
bytes operatorData
); // solhint-disable-next-line separate-by-one-line-in-contract
event Minted(address indexed operator, address indexed to, uint256 value, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 value, bytes userData, bytes operatorData);
event Minted(address indexed operator, address indexed to, uint256 amount, bytes operatorData);
event Burned(address indexed operator, address indexed from, uint256 amount, bytes userData, bytes operatorData);
event AuthorizedOperator(address indexed operator, address indexed tokenHolder);
event RevokedOperator(address indexed operator, address indexed tokenHolder);
}
118 changes: 59 additions & 59 deletions contracts/ReferenceToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {
/// @return the balance of `_tokenAddress`.
function balanceOf(address _tokenHolder) public constant returns (uint256) { return mBalances[_tokenHolder]; }

/// @notice Send `_value` amount of tokens to address `_to`
/// @notice Send `_amount` of tokens to address `_to`
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be sent
function send(address _to, uint256 _value) public {
doSend(msg.sender, _to, _value, "", msg.sender, "", true);
/// @param _amount The number of tokens to be sent
function send(address _to, uint256 _amount) public {
doSend(msg.sender, _to, _amount, "", msg.sender, "", true);
}

/// @notice Send `_value` amount of tokens to address `_to` passing `_userData` to the recipient
/// @notice Send `_amount` of tokens to address `_to` passing `_userData` to the recipient
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be sent
function send(address _to, uint256 _value, bytes _userData) public {
doSend(msg.sender, _to, _value, _userData, msg.sender, "", true);
/// @param _amount The number of tokens to be sent
function send(address _to, uint256 _amount, bytes _userData) public {
doSend(msg.sender, _to, _amount, _userData, msg.sender, "", true);
}

/// @notice Authorize a third party `_operator` to manage (send) `msg.sender`'s tokens.
Expand All @@ -114,48 +114,48 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {
return _operator == _tokenHolder || mAuthorized[_operator][_tokenHolder];
}

/// @notice Send `_value` amount of tokens on behalf of the address `from` to the address `to`.
/// @notice Send `_amount` of tokens on behalf of the address `from` to the address `to`.
/// @param _from The address holding the tokens being sent
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be sent
/// @param _amount The number of tokens to be sent
/// @param _userData Data generated by the user to be sent to the recipient
/// @param _operatorData Data generated by the operator to be sent to the recipient
function operatorSend(address _from, address _to, uint256 _value, bytes _userData, bytes _operatorData) public {
function operatorSend(address _from, address _to, uint256 _amount, bytes _userData, bytes _operatorData) public {
require(isOperatorFor(msg.sender, _from));
doSend(_from, _to, _value, _userData, msg.sender, _operatorData, true);
doSend(_from, _to, _amount, _userData, msg.sender, _operatorData, true);
}

/* -- Mint And Burn Functions (not part of the ERC777 standard, only the Events/tokensReceived are) -- */
//
/// @notice Generates `_value` tokens to be assigned to `_tokenHolder`
/// @notice Generates `_amount` tokens to be assigned to `_tokenHolder`
/// Sample mint function to showcase the use of the `Minted` event and the logic to notify the recipient.
/// @param _tokenHolder The address that will be assigned the new tokens
/// @param _value The quantity of tokens generated
/// @param _amount The quantity of tokens generated
/// @param _operatorData Data that will be passed to the recipient as a first transfer
function mint(address _tokenHolder, uint256 _value, bytes _operatorData) public onlyOwner {
requireMultiple(_value);
mTotalSupply = mTotalSupply.add(_value);
mBalances[_tokenHolder] = mBalances[_tokenHolder].add(_value);
function mint(address _tokenHolder, uint256 _amount, bytes _operatorData) public onlyOwner {
requireMultiple(_amount);
mTotalSupply = mTotalSupply.add(_amount);
mBalances[_tokenHolder] = mBalances[_tokenHolder].add(_amount);

callRecipient(msg.sender, 0x0, _tokenHolder, _value, "", _operatorData, true);
callRecipient(msg.sender, 0x0, _tokenHolder, _amount, "", _operatorData, true);

Minted(msg.sender, _tokenHolder, _value, _operatorData);
if (mErc20compatible) { Transfer(0x0, _tokenHolder, _value); }
Minted(msg.sender, _tokenHolder, _amount, _operatorData);
if (mErc20compatible) { Transfer(0x0, _tokenHolder, _amount); }
}

/// @notice Burns `_value` tokens from `_tokenHolder`
/// @notice Burns `_amount` tokens from `_tokenHolder`
/// Sample burn function to showcase the use of the `Burned` event.
/// @param _tokenHolder The address that will lose the tokens
/// @param _value The quantity of tokens to burn
function burn(address _tokenHolder, uint256 _value, bytes _userData, bytes _operatorData) public onlyOwner {
requireMultiple(_value);
require(balanceOf(_tokenHolder) >= _value);
/// @param _amount The quantity of tokens to burn
function burn(address _tokenHolder, uint256 _amount, bytes _userData, bytes _operatorData) public onlyOwner {
requireMultiple(_amount);
require(balanceOf(_tokenHolder) >= _amount);

mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_value);
mTotalSupply = mTotalSupply.sub(_value);
mBalances[_tokenHolder] = mBalances[_tokenHolder].sub(_amount);
mTotalSupply = mTotalSupply.sub(_amount);

Burned(msg.sender, _tokenHolder, _value, _userData, _operatorData);
if (mErc20compatible) { Transfer(_tokenHolder, 0x0, _value); }
Burned(msg.sender, _tokenHolder, _amount, _userData, _operatorData);
if (mErc20compatible) { Transfer(_tokenHolder, 0x0, _amount); }
}

/* -- ERC20 Compatible Methods -- */
Expand Down Expand Up @@ -188,35 +188,35 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {

/// @notice ERC20 backwards compatible transfer.
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be transferred
/// @param _amount The number of tokens to be transferred
/// @return `true`, if the transfer can't be done, it should fail.
function transfer(address _to, uint256 _value) public erc20 returns (bool success) {
doSend(msg.sender, _to, _value, "", msg.sender, "", false);
function transfer(address _to, uint256 _amount) public erc20 returns (bool success) {
doSend(msg.sender, _to, _amount, "", msg.sender, "", false);
return true;
}

/// @notice ERC20 backwards compatible transferFrom.
/// @param _from The address holding the tokens being transferred
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be transferred
/// @param _amount The number of tokens to be transferred
/// @return `true`, if the transfer can't be done, it should fail.
function transferFrom(address _from, address _to, uint256 _value) public erc20 returns (bool success) {
require(_value <= mAllowed[_from][msg.sender]);
function transferFrom(address _from, address _to, uint256 _amount) public erc20 returns (bool success) {
require(_amount <= mAllowed[_from][msg.sender]);

// Cannot be after doSend because of tokensReceived re-entry
mAllowed[_from][msg.sender] = mAllowed[_from][msg.sender].sub(_value);
doSend(_from, _to, _value, "", msg.sender, "", false);
mAllowed[_from][msg.sender] = mAllowed[_from][msg.sender].sub(_amount);
doSend(_from, _to, _amount, "", msg.sender, "", false);
return true;
}

/// @notice ERC20 backwards compatible approve.
/// `msg.sender` approves `_spender` to spend `_value` tokens on its behalf.
/// `msg.sender` approves `_spender` to spend `_amount` tokens on its behalf.
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @param _amount The number of tokens to be approved for transfer
/// @return `true`, if the approve can't be done, it should fail.
function approve(address _spender, uint256 _value) public erc20 returns (bool success) {
mAllowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
function approve(address _spender, uint256 _amount) public erc20 returns (bool success) {
mAllowed[msg.sender][_spender] = _amount;
Approval(msg.sender, _spender, _amount);
return true;
}

Expand All @@ -232,10 +232,10 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {

/* -- Helper Functions -- */
//
/// @notice Internal function that ensures `_value` is multiple of the granularity
/// @param _value The quantity that want's to be checked
function requireMultiple(uint256 _value) internal {
require(_value.div(mGranularity).mul(mGranularity) == _value);
/// @notice Internal function that ensures `_amount` is multiple of the granularity
/// @param _amount The quantity that want's to be checked
function requireMultiple(uint256 _amount) internal {
require(_amount.div(mGranularity).mul(mGranularity) == _amount);
}

/// @notice Check whether an address is a regular address or not.
Expand All @@ -251,7 +251,7 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {
/// @notice Helper function actually performing the sending of tokens.
/// @param _from The address holding the tokens being sent
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be sent
/// @param _amount The number of tokens to be sent
/// @param _userData Data generated by the user to be passed to the recipient
/// @param _operatorData Data generated by the operator to be passed to the recipient
/// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not
Expand All @@ -261,32 +261,32 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {
function doSend(
address _from,
address _to,
uint256 _value,
uint256 _amount,
bytes _userData,
address _operator,
bytes _operatorData,
bool _preventLocking
)
private
{
requireMultiple(_value);
requireMultiple(_amount);
require(_to != address(0)); // forbid sending to 0x0 (=burning)
require(mBalances[_from] >= _value); // ensure enough funds
require(mBalances[_from] >= _amount); // ensure enough funds

mBalances[_from] = mBalances[_from].sub(_value);
mBalances[_to] = mBalances[_to].add(_value);
mBalances[_from] = mBalances[_from].sub(_amount);
mBalances[_to] = mBalances[_to].add(_amount);

callRecipient(_operator, _from, _to, _value, _userData, _operatorData, _preventLocking);
callRecipient(_operator, _from, _to, _amount, _userData, _operatorData, _preventLocking);

Sent(_operator, _from, _to, _value, _userData, _operatorData);
if (mErc20compatible) { Transfer(_from, _to, _value); }
Sent(_operator, _from, _to, _amount, _userData, _operatorData);
if (mErc20compatible) { Transfer(_from, _to, _amount); }
}

/// @notice Helper function that checks for ITokenRecipient on the recipient and calls it.
/// May throw according to `_preventLocking`
/// @param _from The address holding the tokens being sent
/// @param _to The address of the recipient
/// @param _value The amount of tokens to be sent
/// @param _amount The number of tokens to be sent
/// @param _userData Data generated by the user to be passed to the recipient
/// @param _operatorData Data generated by the operator to be passed to the recipient
/// @param _preventLocking `true` if you want this function to throw when tokens are sent to a contract not
Expand All @@ -297,15 +297,15 @@ contract ReferenceToken is Owned, Ierc20, Ierc777, EIP820Implementer {
address _operator,
address _from,
address _to,
uint256 _value,
uint256 _amount,
bytes _userData,
bytes _operatorData,
bool _preventLocking
) private {
address recipientImplementation = interfaceAddr(_to, "ITokenRecipient");
if (recipientImplementation != 0) {
ITokenRecipient(recipientImplementation).tokensReceived(
_operator, _from, _to, _value, _userData, _operatorData);
_operator, _from, _to, _amount, _userData, _operatorData);
} else if (_preventLocking) {
require(isRegularAddress(_to));
}
Expand Down
Loading

0 comments on commit 41e108c

Please sign in to comment.