Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
687dc19a
Unverified
Commit
687dc19a
authored
Dec 14, 2017
by
Tal Ater
Committed by
GitHub
Dec 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documented increaseApproval() and decreaseApproval()
parent
ddcae625
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
StandardToken.sol
contracts/token/StandardToken.sol
+14
-0
No files found.
contracts/token/StandardToken.sol
View file @
687dc19a
...
@@ -62,10 +62,14 @@ contract StandardToken is ERC20, BasicToken {
...
@@ -62,10 +62,14 @@ contract StandardToken is ERC20, BasicToken {
}
}
/**
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To increment
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* the first transaction is mined)
* From MonolithDAO Token.sol
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
*/
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
...
@@ -73,6 +77,16 @@ contract StandardToken is ERC20, BasicToken {
...
@@ -73,6 +77,16 @@ contract StandardToken is ERC20, BasicToken {
return true;
return true;
}
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
if (_subtractedValue > oldValue) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment