Decrease allowance on transferfrom

This commit is contained in:
lash 2023-01-07 07:00:31 +00:00
parent 4f1bd36c12
commit e49493def1
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 10 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -360,6 +360,12 @@ class TestBasic(TestDemurrageDefault):
balance = c.parse_balance_of(r)
self.assertEqual(balance, 500)
(tx_hash, o) = c.transfer_from(self.address, self.accounts[2], self.accounts[1], self.accounts[3], 1)
self.rpc.do(o)
o = receipt(tx_hash)
r = self.rpc.do(o)
self.assertEqual(r['status'], 0)
if __name__ == '__main__':
unittest.main()

View File

@ -442,7 +442,7 @@ contract DemurrageTokenSingleCap {
uint256 baseValue;
baseValue = toBaseAmount(_value);
require(allowance[msg.sender][_spender] <= baseValue);
require(allowance[msg.sender][_spender] >= baseValue);
changePeriod();
@ -487,7 +487,9 @@ contract DemurrageTokenSingleCap {
baseValue = toBaseAmount(_value);
require(allowance[_from][msg.sender] >= baseValue);
allowance[_from][msg.sender] -= baseValue;
result = transferBase(_from, _to, baseValue);
emit Transfer(_from, _to, _value);
return result;
}