Readability of overflow check

This commit is contained in:
Jordi Baylina 2017-07-30 17:14:56 +02:00
parent 9b31d6493e
commit 31b6bf3001
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
6 changed files with 15 additions and 12 deletions

View File

@ -417,9 +417,9 @@ contract MiniMeToken is Controlled {
) onlyController returns (bool) { ) onlyController returns (bool) {
uint curTotalSupply = totalSupply(); uint curTotalSupply = totalSupply();
if (curTotalSupply + _amount < curTotalSupply) throw; // Check for overflow if (curTotalSupply + _amount < curTotalSupply) throw; // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); uint previousBalanceTo = balanceOf(_owner);
var previousBalanceTo = balanceOf(_owner);
if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
updateValueAtNow(balances[_owner], previousBalanceTo + _amount); updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
Transfer(0, _owner, _amount); Transfer(0, _owner, _amount);
return true; return true;
@ -434,9 +434,9 @@ contract MiniMeToken is Controlled {
) onlyController returns (bool) { ) onlyController returns (bool) {
uint curTotalSupply = totalSupply(); uint curTotalSupply = totalSupply();
if (curTotalSupply < _amount) throw; if (curTotalSupply < _amount) throw;
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); uint previousBalanceFrom = balanceOf(_owner);
var previousBalanceFrom = balanceOf(_owner);
if (previousBalanceFrom < _amount) throw; if (previousBalanceFrom < _amount) throw;
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
Transfer(_owner, 0, _amount); Transfer(_owner, 0, _amount);
return true; return true;

File diff suppressed because one or more lines are too long

3
dist/minimetoken.js vendored
View File

@ -237,7 +237,9 @@ module.exports = function () {
async.series([function (cb1) { async.series([function (cb1) {
params.abi = MiniMeTokenFactoryAbi; params.abi = MiniMeTokenFactoryAbi;
params.byteCode = MiniMeTokenFactoryByteCode; params.byteCode = MiniMeTokenFactoryByteCode;
console.log("yyyy");
_deploy(web3, params, function (err, _tokenFactory) { _deploy(web3, params, function (err, _tokenFactory) {
console.log("ERROR2: ", err);
if (err) { if (err) {
cb1(err); cb1(err);
return; return;
@ -246,6 +248,7 @@ module.exports = function () {
cb1(); cb1();
}); });
}, function (cb1) { }, function (cb1) {
console.log("zzzz");
params.abi = MiniMeTokenAbi; params.abi = MiniMeTokenAbi;
params.byteCode = MiniMeTokenByteCode; params.byteCode = MiniMeTokenByteCode;
_deploy(web3, params, cb1); _deploy(web3, params, cb1);

View File

@ -244,4 +244,4 @@ module.exports = class MiniMeToken {
}); });
}, _cb); }, _cb);
} }
} };

6
package-lock.json generated
View File

@ -4020,9 +4020,9 @@
"integrity": "sha1-nbOE/0uJqPYVY9kjldhiWxjzr7A=" "integrity": "sha1-nbOE/0uJqPYVY9kjldhiWxjzr7A="
}, },
"runethtx": { "runethtx": {
"version": "0.0.6", "version": "0.0.7",
"resolved": "https://registry.npmjs.org/runethtx/-/runethtx-0.0.6.tgz", "resolved": "https://registry.npmjs.org/runethtx/-/runethtx-0.0.7.tgz",
"integrity": "sha1-1Phg3dvJwfn1kNxLkIayYbRe3mM=", "integrity": "sha1-kUXXp4Po44O/CVgN7ahzYx5vwpM=",
"requires": { "requires": {
"async": "2.5.0" "async": "2.5.0"
} }

View File

@ -36,7 +36,7 @@
"bignumber.js": "^4.0.0", "bignumber.js": "^4.0.0",
"ethconnector": "0.0.24", "ethconnector": "0.0.24",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"runethtx": "0.0.6" "runethtx": "0.0.7"
}, },
"devDependencies": { "devDependencies": {
"babel-cli": "^6.22.2", "babel-cli": "^6.22.2",