Remove "available since" comments (#4424)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
@ -13,8 +13,6 @@ import {Math} from "../math/Math.sol";
|
||||
*
|
||||
* To create a history of checkpoints define a variable type \`Checkpoints.Trace*\` in your contract, and store a new
|
||||
* checkpoint for the current transaction block using the {push} function.
|
||||
*
|
||||
* _Available since v4.5._
|
||||
*/
|
||||
`;
|
||||
|
||||
|
||||
@ -1,65 +1,8 @@
|
||||
const assert = require('assert');
|
||||
const format = require('../format-lines');
|
||||
const { range } = require('../../helpers');
|
||||
|
||||
const LENGTHS = range(8, 256, 8).reverse(); // 248 → 8 (in steps of 8)
|
||||
|
||||
// Returns the version of OpenZeppelin Contracts in which a particular function was introduced.
|
||||
// This is used in the docs for each function.
|
||||
const version = (selector, length) => {
|
||||
switch (selector) {
|
||||
case 'toUint(uint)': {
|
||||
switch (length) {
|
||||
case 8:
|
||||
case 16:
|
||||
case 32:
|
||||
case 64:
|
||||
case 128:
|
||||
return '2.5';
|
||||
case 96:
|
||||
case 224:
|
||||
return '4.2';
|
||||
default:
|
||||
assert(LENGTHS.includes(length));
|
||||
return '4.7';
|
||||
}
|
||||
}
|
||||
case 'toInt(int)': {
|
||||
switch (length) {
|
||||
case 8:
|
||||
case 16:
|
||||
case 32:
|
||||
case 64:
|
||||
case 128:
|
||||
return '3.1';
|
||||
default:
|
||||
assert(LENGTHS.includes(length));
|
||||
return '4.7';
|
||||
}
|
||||
}
|
||||
case 'toUint(int)': {
|
||||
switch (length) {
|
||||
case 256:
|
||||
return '3.0';
|
||||
default:
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
case 'toInt(uint)': {
|
||||
switch (length) {
|
||||
case 256:
|
||||
return '3.0';
|
||||
default:
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
};
|
||||
|
||||
const header = `\
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
@ -109,8 +52,6 @@ const toUintDownCast = length => `\
|
||||
* Requirements:
|
||||
*
|
||||
* - input must fit into ${length} bits
|
||||
*
|
||||
* _Available since v${version('toUint(uint)', length)}._
|
||||
*/
|
||||
function toUint${length}(uint256 value) internal pure returns (uint${length}) {
|
||||
if (value > type(uint${length}).max) {
|
||||
@ -132,8 +73,6 @@ const toIntDownCast = length => `\
|
||||
* Requirements:
|
||||
*
|
||||
* - input must fit into ${length} bits
|
||||
*
|
||||
* _Available since v${version('toInt(int)', length)}._
|
||||
*/
|
||||
function toInt${length}(int256 value) internal pure returns (int${length} downcasted) {
|
||||
downcasted = int${length}(value);
|
||||
@ -151,8 +90,6 @@ const toInt = length => `\
|
||||
* Requirements:
|
||||
*
|
||||
* - input must be less than or equal to maxInt${length}.
|
||||
*
|
||||
* _Available since v${version('toInt(uint)', length)}._
|
||||
*/
|
||||
function toInt${length}(uint${length} value) internal pure returns (int${length}) {
|
||||
// Note: Unsafe cast below is okay because \`type(int${length}).max\` is guaranteed to be positive
|
||||
@ -170,8 +107,6 @@ const toUint = length => `\
|
||||
* Requirements:
|
||||
*
|
||||
* - input must be greater than or equal to 0.
|
||||
*
|
||||
* _Available since v${version('toUint(int)', length)}._
|
||||
*/
|
||||
function toUint${length}(int${length} value) internal pure returns (uint${length}) {
|
||||
if (value < 0) {
|
||||
|
||||
@ -1,22 +1,15 @@
|
||||
const format = require('../format-lines');
|
||||
const { capitalize, unique } = require('../../helpers');
|
||||
const { capitalize } = require('../../helpers');
|
||||
|
||||
const TYPES = [
|
||||
{ type: 'address', isValueType: true, version: '4.1' },
|
||||
{ type: 'bool', isValueType: true, name: 'Boolean', version: '4.1' },
|
||||
{ type: 'bytes32', isValueType: true, version: '4.1' },
|
||||
{ type: 'uint256', isValueType: true, version: '4.1' },
|
||||
{ type: 'string', isValueType: false, version: '4.9' },
|
||||
{ type: 'bytes', isValueType: false, version: '4.9' },
|
||||
{ type: 'address', isValueType: true },
|
||||
{ type: 'bool', isValueType: true, name: 'Boolean' },
|
||||
{ type: 'bytes32', isValueType: true },
|
||||
{ type: 'uint256', isValueType: true },
|
||||
{ type: 'string', isValueType: false },
|
||||
{ type: 'bytes', isValueType: false },
|
||||
].map(type => Object.assign(type, { struct: (type.name ?? capitalize(type.type)) + 'Slot' }));
|
||||
|
||||
const VERSIONS = unique(TYPES.map(t => t.version)).map(
|
||||
version =>
|
||||
`_Available since v${version} for ${TYPES.filter(t => t.version == version)
|
||||
.map(t => `\`${t.type}\``)
|
||||
.join(', ')}._`,
|
||||
);
|
||||
|
||||
const header = `\
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
@ -43,8 +36,6 @@ pragma solidity ^0.8.19;
|
||||
* }
|
||||
* }
|
||||
* \`\`\`
|
||||
*
|
||||
${VERSIONS.map(s => ` * ${s}`).join('\n')}
|
||||
*/
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user