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:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user