Add solidity language to missing code snippets (#3992)
This commit is contained in:
@ -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.
|
* Internal or private state variables or functions should have an underscore prefix.
|
||||||
|
|
||||||
```
|
```solidity
|
||||||
contract TestContract {
|
contract TestContract {
|
||||||
uint256 private _privateVar;
|
uint256 private _privateVar;
|
||||||
uint256 internal _internalVar;
|
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
|
* Events should be emitted immediately after the state change that they
|
||||||
represent, and should be named in the past tense.
|
represent, and should be named in the past tense.
|
||||||
|
|
||||||
```
|
```solidity
|
||||||
function _burn(address who, uint256 value) internal {
|
function _burn(address who, uint256 value) internal {
|
||||||
super._burn(who, value);
|
super._burn(who, value);
|
||||||
emit TokensBurned(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.
|
* Interface names should have a capital I prefix.
|
||||||
|
|
||||||
```
|
```solidity
|
||||||
interface IERC777 {
|
interface IERC777 {
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -19,14 +19,14 @@ import "../utils/introspection/ERC165.sol";
|
|||||||
* in the external API and be unique. The best way to achieve this is by
|
* in the external API and be unique. The best way to achieve this is by
|
||||||
* using `public constant` hash digests:
|
* using `public constant` hash digests:
|
||||||
*
|
*
|
||||||
* ```
|
* ```solidity
|
||||||
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
|
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Roles can be used to represent a set of permissions. To restrict access to a
|
* Roles can be used to represent a set of permissions. To restrict access to a
|
||||||
* function call, use {hasRole}:
|
* function call, use {hasRole}:
|
||||||
*
|
*
|
||||||
* ```
|
* ```solidity
|
||||||
* function foo() public {
|
* function foo() public {
|
||||||
* require(hasRole(MY_ROLE, msg.sender));
|
* require(hasRole(MY_ROLE, msg.sender));
|
||||||
* ...
|
* ...
|
||||||
|
|||||||
@ -18,12 +18,13 @@ import "../../utils/Address.sol";
|
|||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
* [.hljs-theme-light.nopadding]
|
* [.hljs-theme-light.nopadding]
|
||||||
* ```
|
* ```solidity
|
||||||
* contract MyToken is ERC20Upgradeable {
|
* contract MyToken is ERC20Upgradeable {
|
||||||
* function initialize() initializer public {
|
* function initialize() initializer public {
|
||||||
* __ERC20_init("MyToken", "MTK");
|
* __ERC20_init("MyToken", "MTK");
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
*
|
||||||
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
|
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
|
||||||
* function initializeV2() reinitializer(2) public {
|
* function initializeV2() reinitializer(2) public {
|
||||||
* __ERC20Permit_init("MyToken");
|
* __ERC20Permit_init("MyToken");
|
||||||
|
|||||||
@ -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.
|
* 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:
|
* Example usage to set ERC1967 implementation slot:
|
||||||
* ```
|
* ```solidity
|
||||||
* contract ERC1967 {
|
* contract ERC1967 {
|
||||||
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
||||||
*
|
*
|
||||||
|
|||||||
@ -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
|
* 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.
|
* used in storage, and not in memory.
|
||||||
* ```
|
* ```solidity
|
||||||
* DoubleEndedQueue.Bytes32Deque queue;
|
* DoubleEndedQueue.Bytes32Deque queue;
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|||||||
@ -17,7 +17,7 @@ import "./EnumerableSet.sol";
|
|||||||
* (O(1)).
|
* (O(1)).
|
||||||
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
|
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
|
||||||
*
|
*
|
||||||
* ```
|
* ```solidity
|
||||||
* contract Example {
|
* contract Example {
|
||||||
* // Add the library methods
|
* // Add the library methods
|
||||||
* using EnumerableMap for EnumerableMap.UintToAddressMap;
|
* using EnumerableMap for EnumerableMap.UintToAddressMap;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ pragma solidity ^0.8.0;
|
|||||||
* (O(1)).
|
* (O(1)).
|
||||||
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
|
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
|
||||||
*
|
*
|
||||||
* ```
|
* ```solidity
|
||||||
* contract Example {
|
* contract Example {
|
||||||
* // Add the library methods
|
* // Add the library methods
|
||||||
* using EnumerableSet for EnumerableSet.AddressSet;
|
* using EnumerableSet for EnumerableSet.AddressSet;
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import "./EnumerableSet.sol";
|
|||||||
* (O(1)).
|
* (O(1)).
|
||||||
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
|
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
|
||||||
*
|
*
|
||||||
* \`\`\`
|
* \`\`\`solidity
|
||||||
* contract Example {
|
* contract Example {
|
||||||
* // Add the library methods
|
* // Add the library methods
|
||||||
* using EnumerableMap for EnumerableMap.UintToAddressMap;
|
* using EnumerableMap for EnumerableMap.UintToAddressMap;
|
||||||
|
|||||||
@ -22,7 +22,7 @@ pragma solidity ^0.8.0;
|
|||||||
* (O(1)).
|
* (O(1)).
|
||||||
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
|
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
|
||||||
*
|
*
|
||||||
* \`\`\`
|
* \`\`\`solidity
|
||||||
* contract Example {
|
* contract Example {
|
||||||
* // Add the library methods
|
* // Add the library methods
|
||||||
* using EnumerableSet for EnumerableSet.AddressSet;
|
* using EnumerableSet for EnumerableSet.AddressSet;
|
||||||
|
|||||||
Reference in New Issue
Block a user