forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend Checkpoints with new sizes and lookup mechanisms (OpenZeppelin…
- Loading branch information
1 parent
09b5ecf
commit 9f9afcf
Showing
20 changed files
with
1,183 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../utils/Arrays.sol"; | ||
|
||
contract Uint256ArraysMock { | ||
using Arrays for uint256[]; | ||
|
||
uint256[] private _array; | ||
|
||
constructor(uint256[] memory array) { | ||
_array = array; | ||
} | ||
|
||
function findUpperBound(uint256 element) external view returns (uint256) { | ||
return _array.findUpperBound(element); | ||
} | ||
|
||
function unsafeAccess(uint256 pos) external view returns (uint256) { | ||
return _array.unsafeAccess(pos).value; | ||
} | ||
} | ||
|
||
contract AddressArraysMock { | ||
using Arrays for address[]; | ||
|
||
address[] private _array; | ||
|
||
constructor(address[] memory array) { | ||
_array = array; | ||
} | ||
|
||
function unsafeAccess(uint256 pos) external view returns (address) { | ||
return _array.unsafeAccess(pos).value; | ||
} | ||
} | ||
|
||
contract Bytes32ArraysMock { | ||
using Arrays for bytes32[]; | ||
|
||
bytes32[] private _array; | ||
|
||
constructor(bytes32[] memory array) { | ||
_array = array; | ||
} | ||
|
||
function unsafeAccess(uint256 pos) external view returns (bytes32) { | ||
return _array.unsafeAccess(pos).value; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: MIT | ||
// This file was procedurally generated from scripts/generate/templates/CheckpointsMock.js. | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "../utils/Checkpoints.sol"; | ||
|
||
contract CheckpointsMock { | ||
using Checkpoints for Checkpoints.History; | ||
|
||
Checkpoints.History private _totalCheckpoints; | ||
|
||
function latest() public view returns (uint256) { | ||
return _totalCheckpoints.latest(); | ||
} | ||
|
||
function push(uint256 value) public returns (uint256, uint256) { | ||
return _totalCheckpoints.push(value); | ||
} | ||
|
||
function getAtBlock(uint256 blockNumber) public view returns (uint256) { | ||
return _totalCheckpoints.getAtBlock(blockNumber); | ||
} | ||
|
||
function getAtRecentBlock(uint256 blockNumber) public view returns (uint256) { | ||
return _totalCheckpoints.getAtRecentBlock(blockNumber); | ||
} | ||
|
||
function length() public view returns (uint256) { | ||
return _totalCheckpoints._checkpoints.length; | ||
} | ||
} | ||
|
||
contract Checkpoints224Mock { | ||
using Checkpoints for Checkpoints.Trace224; | ||
|
||
Checkpoints.Trace224 private _totalCheckpoints; | ||
|
||
function latest() public view returns (uint224) { | ||
return _totalCheckpoints.latest(); | ||
} | ||
|
||
function push(uint32 key, uint224 value) public returns (uint224, uint224) { | ||
return _totalCheckpoints.push(key, value); | ||
} | ||
|
||
function lowerLookup(uint32 key) public view returns (uint224) { | ||
return _totalCheckpoints.lowerLookup(key); | ||
} | ||
|
||
function upperLookup(uint32 key) public view returns (uint224) { | ||
return _totalCheckpoints.upperLookup(key); | ||
} | ||
|
||
function upperLookupRecent(uint32 key) public view returns (uint224) { | ||
return _totalCheckpoints.upperLookupRecent(key); | ||
} | ||
|
||
function length() public view returns (uint256) { | ||
return _totalCheckpoints._checkpoints.length; | ||
} | ||
} | ||
|
||
contract Checkpoints160Mock { | ||
using Checkpoints for Checkpoints.Trace160; | ||
|
||
Checkpoints.Trace160 private _totalCheckpoints; | ||
|
||
function latest() public view returns (uint160) { | ||
return _totalCheckpoints.latest(); | ||
} | ||
|
||
function push(uint96 key, uint160 value) public returns (uint160, uint160) { | ||
return _totalCheckpoints.push(key, value); | ||
} | ||
|
||
function lowerLookup(uint96 key) public view returns (uint160) { | ||
return _totalCheckpoints.lowerLookup(key); | ||
} | ||
|
||
function upperLookup(uint96 key) public view returns (uint160) { | ||
return _totalCheckpoints.upperLookup(key); | ||
} | ||
|
||
function upperLookupRecent(uint96 key) public view returns (uint224) { | ||
return _totalCheckpoints.upperLookupRecent(key); | ||
} | ||
|
||
function length() public view returns (uint256) { | ||
return _totalCheckpoints._checkpoints.length; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.