Skip to content

Commit 4448c13

Browse files
authored
Move the Checkpoints library to utils/structs (#4275)
1 parent 25edd3c commit 4448c13

File tree

10 files changed

+20
-15
lines changed

10 files changed

+20
-15
lines changed

.changeset/fresh-birds-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': major
3+
---
4+
5+
`Checkpoints`: library moved from `utils` to `utils/structs`

contracts/governance/extensions/GovernorVotesQuorumFraction.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
pragma solidity ^0.8.0;
55

66
import "./GovernorVotes.sol";
7-
import "../../utils/Checkpoints.sol";
87
import "../../utils/math/SafeCast.sol";
8+
import "../../utils/structs/Checkpoints.sol";
99

1010
/**
1111
* @dev Extension of {Governor} for voting weight extraction from an {ERC20Votes} token and a quorum expressed as a

contracts/governance/utils/Votes.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pragma solidity ^0.8.0;
55
import "../../interfaces/IERC5805.sol";
66
import "../../utils/Context.sol";
77
import "../../utils/Nonces.sol";
8-
import "../../utils/Checkpoints.sol";
98
import "../../utils/cryptography/EIP712.sol";
9+
import "../../utils/structs/Checkpoints.sol";
1010

1111
/**
1212
* @dev This is a base abstract contract that tracks voting units, which are a measure of voting power that can be

contracts/token/ERC721/extensions/ERC721Consecutive.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pragma solidity ^0.8.1;
55

66
import "../ERC721.sol";
77
import "../../../interfaces/IERC2309.sol";
8-
import "../../../utils/Checkpoints.sol";
98
import "../../../utils/structs/BitMaps.sol";
9+
import "../../../utils/structs/Checkpoints.sol";
1010

1111
/**
1212
* @dev Implementation of the ERC2309 "Consecutive Transfer Extension" as defined in

contracts/utils/Checkpoints.sol renamed to contracts/utils/structs/Checkpoints.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
2-
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Checkpoints.sol)
2+
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/Checkpoints.sol)
33
// This file was procedurally generated from scripts/generate/templates/Checkpoints.js.
44

55
pragma solidity ^0.8.0;
66

7-
import "./math/Math.sol";
8-
import "./math/SafeCast.sol";
7+
import "../math/Math.sol";
8+
import "../math/SafeCast.sol";
99

1010
/**
1111
* @dev This library defines the `History` struct, for checkpointing values as they change at different points in

scripts/generate/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ for (const [file, template] of Object.entries({
3535
'utils/math/SafeCast.sol': './templates/SafeCast.js',
3636
'utils/structs/EnumerableSet.sol': './templates/EnumerableSet.js',
3737
'utils/structs/EnumerableMap.sol': './templates/EnumerableMap.js',
38-
'utils/Checkpoints.sol': './templates/Checkpoints.js',
38+
'utils/structs/Checkpoints.sol': './templates/Checkpoints.js',
3939
'utils/StorageSlot.sol': './templates/StorageSlot.js',
4040
})) {
4141
generateFromTemplate(file, template, './contracts/');
4242
}
4343

4444
// Tests
4545
for (const [file, template] of Object.entries({
46-
'utils/Checkpoints.t.sol': './templates/Checkpoints.t.js',
46+
'utils/structs/Checkpoints.t.sol': './templates/Checkpoints.t.js',
4747
})) {
4848
generateFromTemplate(file, template, './test/');
4949
}

scripts/generate/templates/Checkpoints.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ const { OPTS } = require('./Checkpoints.opts.js');
55
const header = `\
66
pragma solidity ^0.8.0;
77
8-
import "./math/Math.sol";
9-
import "./math/SafeCast.sol";
8+
import "../math/Math.sol";
9+
import "../math/SafeCast.sol";
1010
1111
/**
1212
* @dev This library defines the \`History\` struct, for checkpointing values as they change at different points in

scripts/generate/templates/Checkpoints.t.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const header = `\
77
pragma solidity ^0.8.0;
88
99
import "forge-std/Test.sol";
10-
import "../../contracts/utils/Checkpoints.sol";
11-
import "../../contracts/utils/math/SafeCast.sol";
10+
import "../../../contracts/utils/math/SafeCast.sol";
11+
import "../../../contracts/utils/structs/Checkpoints.sol";
1212
`;
1313

1414
/* eslint-disable max-len */

test/utils/Checkpoints.t.sol renamed to test/utils/structs/Checkpoints.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
pragma solidity ^0.8.0;
55

66
import "forge-std/Test.sol";
7-
import "../../contracts/utils/Checkpoints.sol";
8-
import "../../contracts/utils/math/SafeCast.sol";
7+
import "../../../contracts/utils/math/SafeCast.sol";
8+
import "../../../contracts/utils/structs/Checkpoints.sol";
99

1010
contract CheckpointsTrace224Test is Test {
1111
using Checkpoints for Checkpoints.Trace224;

test/utils/Checkpoints.test.js renamed to test/utils/structs/Checkpoints.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { expectRevert } = require('@openzeppelin/test-helpers');
22
const { expect } = require('chai');
33

4-
const { VALUE_SIZES } = require('../../scripts/generate/templates/Checkpoints.opts.js');
4+
const { VALUE_SIZES } = require('../../../scripts/generate/templates/Checkpoints.opts.js');
55

66
const $Checkpoints = artifacts.require('$Checkpoints');
77

0 commit comments

Comments
 (0)