更新合约文档,翻译为中文以增强可读性,包括 AccessControl、Ownable、ERC20 和 IERC20 的相关说明。修正了一些注释以确保准确性和一致性。
Some checks failed
transpile upgradeable / transpile (push) Has been cancelled
Some checks failed
transpile upgradeable / transpile (push) Has been cancelled
This commit is contained in:
@ -6,29 +6,27 @@ pragma solidity ^0.8.20;
|
||||
import {Errors} from "./Errors.sol";
|
||||
|
||||
/**
|
||||
* @dev Collection of functions related to the address type
|
||||
* @dev 与地址类型相关的函数集合
|
||||
*/
|
||||
library Address {
|
||||
/**
|
||||
* @dev There's no code at `target` (it is not a contract).
|
||||
* @dev 在 `target` 处没有代码(它不是一个合约)。
|
||||
*/
|
||||
error AddressEmptyCode(address target);
|
||||
|
||||
/**
|
||||
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
|
||||
* `recipient`, forwarding all available gas and reverting on errors.
|
||||
* @dev Solidity 的 `transfer` 的替代品:向 `recipient` 发送 `amount` wei,
|
||||
* 转发所有可用的 gas 并在出错时回退。
|
||||
*
|
||||
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
|
||||
* of certain opcodes, possibly making contracts go over the 2300 gas limit
|
||||
* imposed by `transfer`, making them unable to receive funds via
|
||||
* `transfer`. {sendValue} removes this limitation.
|
||||
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] 增加了某些操作码的 gas 成本,
|
||||
* 可能使合约超过 `transfer` 施加的 2300 gas 限制,使它们无法通过 `transfer` 接收资金。
|
||||
* {sendValue} 移除了这个限制。
|
||||
*
|
||||
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
|
||||
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[了解更多]。
|
||||
*
|
||||
* IMPORTANT: because control is transferred to `recipient`, care must be
|
||||
* taken to not create reentrancy vulnerabilities. Consider using
|
||||
* {ReentrancyGuard} or the
|
||||
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
|
||||
* 重要:因为控制权转移到 `recipient`,必须注意不要创建重入漏洞。
|
||||
* 考虑使用 {ReentrancyGuard} 或
|
||||
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[检查-效果-交互模式]。
|
||||
*/
|
||||
function sendValue(address payable recipient, uint256 amount) internal {
|
||||
if (address(this).balance < amount) {
|
||||
@ -42,22 +40,19 @@ library Address {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Performs a Solidity function call using a low level `call`. A
|
||||
* plain `call` is an unsafe replacement for a function call: use this
|
||||
* function instead.
|
||||
* @dev 使用低级 `call` 执行 Solidity 函数调用。普通的 `call` 是函数调用的不安全替代品:
|
||||
* 请使用此函数替代。
|
||||
*
|
||||
* If `target` reverts with a revert reason or custom error, it is bubbled
|
||||
* up by this function (like regular Solidity function calls). However, if
|
||||
* the call reverted with no returned reason, this function reverts with a
|
||||
* {Errors.FailedCall} error.
|
||||
* 如果 `target` 使用回退原因或自定义错误回退,则此函数会将其冒泡(如常规 Solidity 函数调用)。
|
||||
* 但是,如果调用没有返回原因就回退,则此函数会使用 {Errors.FailedCall} 错误回退。
|
||||
*
|
||||
* Returns the raw returned data. To convert to the expected return value,
|
||||
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
|
||||
* 返回原始返回数据。要转换为期望的返回值,请使用
|
||||
* https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]。
|
||||
*
|
||||
* Requirements:
|
||||
* 要求:
|
||||
*
|
||||
* - `target` must be a contract.
|
||||
* - calling `target` with `data` must not revert.
|
||||
* - `target` 必须是一个合约。
|
||||
* - 使用 `data` 调用 `target` 不能回退。
|
||||
*/
|
||||
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
|
||||
return functionCallWithValue(target, data, 0);
|
||||
|
||||
Reference in New Issue
Block a user