CheckpointsMock.sol 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 latestCheckpoint() public view returns (bool, uint256, uint256) {
  12. return _totalCheckpoints.latestCheckpoint();
  13. }
  14. function length() public view returns (uint256) {
  15. return _totalCheckpoints.length();
  16. }
  17. function push(uint256 value) public returns (uint256, uint256) {
  18. return _totalCheckpoints.push(value);
  19. }
  20. function getAtBlock(uint256 blockNumber) public view returns (uint256) {
  21. return _totalCheckpoints.getAtBlock(blockNumber);
  22. }
  23. function getAtProbablyRecentBlock(uint256 blockNumber) public view returns (uint256) {
  24. return _totalCheckpoints.getAtProbablyRecentBlock(blockNumber);
  25. }
  26. }
  27. contract Checkpoints224Mock {
  28. using Checkpoints for Checkpoints.Trace224;
  29. Checkpoints.Trace224 private _totalCheckpoints;
  30. function latest() public view returns (uint224) {
  31. return _totalCheckpoints.latest();
  32. }
  33. function latestCheckpoint() public view returns (bool, uint32, uint224) {
  34. return _totalCheckpoints.latestCheckpoint();
  35. }
  36. function length() public view returns (uint256) {
  37. return _totalCheckpoints.length();
  38. }
  39. function push(uint32 key, uint224 value) public returns (uint224, uint224) {
  40. return _totalCheckpoints.push(key, value);
  41. }
  42. function lowerLookup(uint32 key) public view returns (uint224) {
  43. return _totalCheckpoints.lowerLookup(key);
  44. }
  45. function upperLookup(uint32 key) public view returns (uint224) {
  46. return _totalCheckpoints.upperLookup(key);
  47. }
  48. }
  49. contract Checkpoints160Mock {
  50. using Checkpoints for Checkpoints.Trace160;
  51. Checkpoints.Trace160 private _totalCheckpoints;
  52. function latest() public view returns (uint160) {
  53. return _totalCheckpoints.latest();
  54. }
  55. function latestCheckpoint() public view returns (bool, uint96, uint160) {
  56. return _totalCheckpoints.latestCheckpoint();
  57. }
  58. function length() public view returns (uint256) {
  59. return _totalCheckpoints.length();
  60. }
  61. function push(uint96 key, uint160 value) public returns (uint160, uint160) {
  62. return _totalCheckpoints.push(key, value);
  63. }
  64. function lowerLookup(uint96 key) public view returns (uint160) {
  65. return _totalCheckpoints.lowerLookup(key);
  66. }
  67. function upperLookup(uint96 key) public view returns (uint160) {
  68. return _totalCheckpoints.upperLookup(key);
  69. }
  70. }