Remove unnecessary SafeMath call (#1610)

* Refactor Counter to support increment and decrement.

* Move Counter out of drafts.

* Refactor ERC721 to use Counter.

* Rollback Counter returning the current value in increment and decrement.

* Update test/drafts/Counter.test.js

Co-Authored-By: nventuro <nicolas.venturo@gmail.com>

* Improve Counter documentation.

* Move Counter.test to utils.

* Move back Counter to drafts.
This commit is contained in:
Nicolás Venturo
2019-01-21 17:24:51 -03:00
committed by GitHub
parent 3a5da75876
commit 07603d5875
5 changed files with 89 additions and 47 deletions

View File

@ -5,13 +5,17 @@ import "../drafts/Counters.sol";
contract CountersImpl {
using Counters for Counters.Counter;
uint256 public theId;
Counters.Counter private _counter;
// use whatever key you want to track your counters
mapping(string => Counters.Counter) private _counters;
function current() public view returns (uint256) {
return _counter.current();
}
function doThing(string memory key) public returns (uint256) {
theId = _counters[key].next();
return theId;
function increment() public {
_counter.increment();
}
function decrement() public {
_counter.decrement();
}
}