From a34dd8bb1b8e941f6e7f65c58df0b3b994afbc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20Garc=C3=ADa?= Date: Tue, 24 Jan 2023 15:00:03 -0600 Subject: [PATCH] Add `solidity` language to missing code snippets (#3992) --- GUIDELINES.md | 6 +++--- contracts/access/AccessControl.sol | 4 ++-- contracts/proxy/utils/Initializable.sol | 3 ++- contracts/utils/StorageSlot.sol | 2 +- contracts/utils/structs/DoubleEndedQueue.sol | 2 +- contracts/utils/structs/EnumerableMap.sol | 2 +- contracts/utils/structs/EnumerableSet.sol | 2 +- scripts/generate/templates/EnumerableMap.js | 2 +- scripts/generate/templates/EnumerableSet.js | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/GUIDELINES.md b/GUIDELINES.md index cdeddb90c..bac94be6f 100644 --- a/GUIDELINES.md +++ b/GUIDELINES.md @@ -72,7 +72,7 @@ In addition to the official Solidity Style Guide we have a number of other conve * Internal or private state variables or functions should have an underscore prefix. - ``` + ```solidity contract TestContract { uint256 private _privateVar; uint256 internal _internalVar; @@ -84,7 +84,7 @@ In addition to the official Solidity Style Guide we have a number of other conve * Events should be emitted immediately after the state change that they represent, and should be named in the past tense. - ``` + ```solidity function _burn(address who, uint256 value) internal { super._burn(who, value); emit TokensBurned(who, value); @@ -96,7 +96,7 @@ In addition to the official Solidity Style Guide we have a number of other conve * Interface names should have a capital I prefix. - ``` + ```solidity interface IERC777 { ``` diff --git a/contracts/access/AccessControl.sol b/contracts/access/AccessControl.sol index 386b85c03..5f2829e74 100644 --- a/contracts/access/AccessControl.sol +++ b/contracts/access/AccessControl.sol @@ -19,14 +19,14 @@ import "../utils/introspection/ERC165.sol"; * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * - * ``` + * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * - * ``` + * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... diff --git a/contracts/proxy/utils/Initializable.sol b/contracts/proxy/utils/Initializable.sol index b454b5d95..638dbe353 100644 --- a/contracts/proxy/utils/Initializable.sol +++ b/contracts/proxy/utils/Initializable.sol @@ -18,12 +18,13 @@ import "../../utils/Address.sol"; * For example: * * [.hljs-theme-light.nopadding] - * ``` + * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } + * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); diff --git a/contracts/utils/StorageSlot.sol b/contracts/utils/StorageSlot.sol index 6ab8f5dc6..d23363bd6 100644 --- a/contracts/utils/StorageSlot.sol +++ b/contracts/utils/StorageSlot.sol @@ -12,7 +12,7 @@ pragma solidity ^0.8.0; * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: - * ``` + * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * diff --git a/contracts/utils/structs/DoubleEndedQueue.sol b/contracts/utils/structs/DoubleEndedQueue.sol index eae79ada7..6b3ea70e3 100644 --- a/contracts/utils/structs/DoubleEndedQueue.sol +++ b/contracts/utils/structs/DoubleEndedQueue.sol @@ -12,7 +12,7 @@ import "../math/SafeCast.sol"; * * The struct is called `Bytes32Deque`. Other types can be cast to and from `bytes32`. This data structure can only be * used in storage, and not in memory. - * ``` + * ```solidity * DoubleEndedQueue.Bytes32Deque queue; * ``` * diff --git a/contracts/utils/structs/EnumerableMap.sol b/contracts/utils/structs/EnumerableMap.sol index 8b188c734..fb21f02cf 100644 --- a/contracts/utils/structs/EnumerableMap.sol +++ b/contracts/utils/structs/EnumerableMap.sol @@ -17,7 +17,7 @@ import "./EnumerableSet.sol"; * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * - * ``` + * ```solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; diff --git a/contracts/utils/structs/EnumerableSet.sol b/contracts/utils/structs/EnumerableSet.sol index 4c701c26c..a01f82d41 100644 --- a/contracts/utils/structs/EnumerableSet.sol +++ b/contracts/utils/structs/EnumerableSet.sol @@ -15,7 +15,7 @@ pragma solidity ^0.8.0; * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * - * ``` + * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; diff --git a/scripts/generate/templates/EnumerableMap.js b/scripts/generate/templates/EnumerableMap.js index dbd502a0b..2bbb69e3e 100644 --- a/scripts/generate/templates/EnumerableMap.js +++ b/scripts/generate/templates/EnumerableMap.js @@ -25,7 +25,7 @@ import "./EnumerableSet.sol"; * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * - * \`\`\` + * \`\`\`solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; diff --git a/scripts/generate/templates/EnumerableSet.js b/scripts/generate/templates/EnumerableSet.js index a3af2c304..2b6a9c64d 100644 --- a/scripts/generate/templates/EnumerableSet.js +++ b/scripts/generate/templates/EnumerableSet.js @@ -22,7 +22,7 @@ pragma solidity ^0.8.0; * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * - * \`\`\` + * \`\`\`solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet;