Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adding decreaseAllowance() and increaseAllowance() #9

Open
GriffGreen opened this issue May 1, 2017 · 2 comments
Open

Consider adding decreaseAllowance() and increaseAllowance() #9

GriffGreen opened this issue May 1, 2017 · 2 comments

Comments

@GriffGreen
Copy link
Member

GriffGreen commented May 1, 2017

Also taken from the Token Card Token Contract:

https://github.com/MonolithDAO/token/blob/master/src/Token.sol#L98

I'm not sure on the style choices but I do have a strong opinion on the name ;-) so i changed that. but i expect the other details might change as well. (like I hope to implement Dani's version of ds-math so we will use add() and subtract() instead of safeAdd() and safeSub())

The point of this addition to the contract is to avoid the race condition further by allow the UI to avoid using approve a second time... in fact, with these two functions, we can avoid using approve all together, but yet it can stay there for ol' times sake ;-)

    function increaseAllowance (address _spender, uint _addedValue) 
    onlyPayloadSize(2)
    returns (bool success) {
        uint oldValue = allowance[msg.sender][_spender];
        allowance[msg.sender][_spender] = safeAdd(oldValue, _addedValue);
        return true;
    }

    function decreaseAllowance (address _spender, uint _subtractedValue) 
    onlyPayloadSize(2)
    returns (bool success) {
        uint oldValue = allowance[msg.sender][_spender];
        if (_subtractedValue > oldValue) {
            allowance[msg.sender][_spender] = 0;
        } else {
            allowance[msg.sender][_spender] = safeSub(oldValue, _subtractedValue);
        }
        return true;
    }
@jbaylina
Copy link
Contributor

jbaylina commented May 1, 2017

Looks like the world is going to ERC223, so the approve will make no sense.

@Janther
Copy link

Janther commented Jun 6, 2017

Not sure if ERC223 is a long term option though, since Vitalik himself doesn't approve and in the future, all addresses will be contracts regardless of them being or not a wallet.
Here is an response from @Dexaran to Vitalik speech.

https://medium.com/@dexaran820/response-to-vitaliks-speech-about-erc-23-ad240a27490f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants