Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 0 additions & 56 deletions scripts/generate/templates/SafeCast.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,6 @@ 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;

Expand Down
14 changes: 7 additions & 7 deletions scripts/generate/templates/StorageSlot.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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 header = `\
Expand Down