CheckpointsMock.sol 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // SPDX-License-Identifier: MIT
  2. // This file was procedurally generated from scripts/generate/templates/CheckpointsMock.js.
  3. pragma solidity ^0.8.0;
  4. import "../utils/Checkpoints.sol";
  5. contract CheckpointsMock {
  6. using Checkpoints for Checkpoints.History;
  7. Checkpoints.History private _totalCheckpoints;
  8. function latest() public view returns (uint256) {
  9. return _totalCheckpoints.latest();
  10. }
  11. function push(uint256 value) public returns (uint256, uint256) {
  12. return _totalCheckpoints.push(value);
  13. }
  14. function getAtBlock(uint256 blockNumber) public view returns (uint256) {
  15. return _totalCheckpoints.getAtBlock(blockNumber);
  16. }
  17. function getAtRecentBlock(uint256 blockNumber) public view returns (uint256) {
  18. return _totalCheckpoints.getAtRecentBlock(blockNumber);
  19. }
  20. function length() public view returns (uint256) {
  21. return _totalCheckpoints._checkpoints.length;
  22. }
  23. }
  24. contract Checkpoints224Mock {
  25. using Checkpoints for Checkpoints.Trace224;
  26. Checkpoints.Trace224 private _totalCheckpoints;
  27. function latest() public view returns (uint224) {
  28. return _totalCheckpoints.latest();
  29. }
  30. function push(uint32 key, uint224 value) public returns (uint224, uint224) {
  31. return _totalCheckpoints.push(key, value);
  32. }
  33. function lowerLookup(uint32 key) public view returns (uint224) {
  34. return _totalCheckpoints.lowerLookup(key);
  35. }
  36. function upperLookup(uint32 key) public view returns (uint224) {
  37. return _totalCheckpoints.upperLookup(key);
  38. }
  39. function upperLookupRecent(uint32 key) public view returns (uint224) {
  40. return _totalCheckpoints.upperLookupRecent(key);
  41. }
  42. function length() public view returns (uint256) {
  43. return _totalCheckpoints._checkpoints.length;
  44. }
  45. }
  46. contract Checkpoints160Mock {
  47. using Checkpoints for Checkpoints.Trace160;
  48. Checkpoints.Trace160 private _totalCheckpoints;
  49. function latest() public view returns (uint160) {
  50. return _totalCheckpoints.latest();
  51. }
  52. function push(uint96 key, uint160 value) public returns (uint160, uint160) {
  53. return _totalCheckpoints.push(key, value);
  54. }
  55. function lowerLookup(uint96 key) public view returns (uint160) {
  56. return _totalCheckpoints.lowerLookup(key);
  57. }
  58. function upperLookup(uint96 key) public view returns (uint160) {
  59. return _totalCheckpoints.upperLookup(key);
  60. }
  61. function upperLookupRecent(uint96 key) public view returns (uint224) {
  62. return _totalCheckpoints.upperLookupRecent(key);
  63. }
  64. function length() public view returns (uint256) {
  65. return _totalCheckpoints._checkpoints.length;
  66. }
  67. }