Skip to content

Commit

Permalink
refactor: change ERROR_CODE public
Browse files Browse the repository at this point in the history
  • Loading branch information
detectivekim committed Jan 9, 2024
1 parent ff5307b commit 4007139
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/MinBitMap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ library MinBitMap {
using SignificantBit for uint256;

error MinBitMapError(uint256 errorCode);
uint256 private constant _EMPTY_ERROR = 0;
uint256 private constant _ALREADY_EXISTS_ERROR = 1;
uint256 public constant EMPTY_ERROR = 0;
uint256 public constant ALREADY_EXISTS_ERROR = 1;

struct Core {
uint256 bitmap;
Expand Down Expand Up @@ -42,7 +42,7 @@ library MinBitMap {
}

function root(Core storage core) internal view returns (uint24) {
if (isEmpty(core)) revert MinBitMapError(_EMPTY_ERROR);
if (isEmpty(core)) revert MinBitMapError(EMPTY_ERROR);

(uint256 wordIndex, uint256 bitIndex) = _root(core);
return uint24((wordIndex << 8) | bitIndex);
Expand All @@ -53,7 +53,7 @@ library MinBitMap {
uint256 mask = 1 << bitIndex;
uint256 word = core.bitmapMapping[wordIndex];
if (word & mask > 0) {
revert MinBitMapError(_ALREADY_EXISTS_ERROR);
revert MinBitMapError(ALREADY_EXISTS_ERROR);
}

core.bitmapMapping[wordIndex] = word | mask;
Expand All @@ -67,6 +67,8 @@ library MinBitMap {
}

function pop(Core storage core) internal {
if (isEmpty(core)) revert MinBitMapError(EMPTY_ERROR);

(uint256 wordIndex, uint256 bitIndex) = _root(core);
uint256 mask = 1 << bitIndex;
uint256 word = core.bitmapMapping[wordIndex];
Expand Down

0 comments on commit 4007139

Please sign in to comment.