CheckpointsMock.sol 3.0 KB

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