Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
oz vs oz upgrades (right)
作成日
3 年前
差分は期限切れになりません
クリア
エクスポート
共有
説明
10 削除
行
合計
削除
文字
合計
削除
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
165 行
すべてコピー
8 追加
行
合計
追加
文字
合計
追加
この機能を引き続き使用するには、アップグレードしてください
Diff
checker
Pro
価格を見る
165 行
すべてコピー
コピー
コピー済み
コピー
コピー済み
/ SPDX-License-Identifier: MIT
/
/ SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.
8
.0) (proxy/utils/Initializable.sol)
// OpenZeppelin Contracts (last updated v4.
7
.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
pragma solidity ^0.8.2;
コピー
コピー済み
コピー
コピー済み
import "../../utils/
Address
.sol";
import "../../utils/
AddressUpgradeable
.sol";
/**
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
* case an upgrade adds a module that needs to be initialized.
*
*
* For example:
* For example:
*
*
* [.hljs-theme-light.nopadding]
* [.hljs-theme-light.nopadding]
* ```
* ```
* 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");
* }
* }
* }
* }
* ```
* ```
*
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
*
* [CAUTION]
* [CAUTION]
* ====
* ====
* Avoid leaving a contract uninitialized.
* Avoid leaving a contract uninitialized.
*
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
*
* [.hljs-theme-light.nopadding]
* [.hljs-theme-light.nopadding]
* ```
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* constructor() {
* _disableInitializers();
* _disableInitializers();
* }
* }
* ```
* ```
* ====
* ====
*/
*/
abstract contract Initializable {
abstract contract Initializable {
/**
/**
* @dev Indicates that the contract has been initialized.
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
* @custom:oz-retyped-from bool
*/
*/
uint8 private _initialized;
uint8 private _initialized;
/**
/**
* @dev Indicates that the contract is in the process of being initialized.
* @dev Indicates that the contract is in the process of being initialized.
*/
*/
bool private _initializing;
bool private _initializing;
/**
/**
* @dev Triggered when the contract has been initialized or reinitialized.
* @dev Triggered when the contract has been initialized or reinitialized.
*/
*/
event Initialized(uint8 version);
event Initialized(uint8 version);
/**
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
* `onlyInitializing` functions can be used to initialize parent contracts.
*
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
* constructor.
*
*
* Emits an {Initialized} event.
* Emits an {Initialized} event.
*/
*/
modifier initializer() {
modifier initializer() {
bool isTopLevelCall = !_initializing;
bool isTopLevelCall = !_initializing;
require(
require(
コピー
コピー済み
コピー
コピー済み
(isTopLevelCall && _initialized < 1) || (!
Address
.isContract(address(this)) && _initialized == 1),
(isTopLevelCall && _initialized < 1) || (!
AddressUpgradeable
.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
"Initializable: contract is already initialized"
);
);
_initialized = 1;
_initialized = 1;
if (isTopLevelCall) {
if (isTopLevelCall) {
_initializing = true;
_initializing = true;
}
}
_;
_;
if (isTopLevelCall) {
if (isTopLevelCall) {
_initializing = false;
_initializing = false;
emit Initialized(1);
emit Initialized(1);
}
}
}
}
/**
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
* used to initialize parent contracts.
*
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
* are added through upgrades and that require initialization.
*
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
* a contract, executing them in the right order is up to the developer or operator.
*
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
*
* Emits an {Initialized} event.
* Emits an {Initialized} event.
*/
*/
modifier reinitializer(uint8 version) {
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initialized = version;
_initializing = true;
_initializing = true;
_;
_;
_initializing = false;
_initializing = false;
emit Initialized(version);
emit Initialized(version);
}
}
/**
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
*/
modifier onlyInitializing() {
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
require(_initializing, "Initializable: contract is not initializing");
_;
_;
}
}
/**
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
* through proxies.
*
*
* Emits an {Initialized} event the first time it is successfully executed.
* Emits an {Initialized} event the first time it is successfully executed.
*/
*/
function _disableInitializers() internal virtual {
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
emit Initialized(type(uint8).max);
}
}
}
}
/**
/**
コピー
コピー済み
コピー
コピー済み
* @dev
R
eturns the
highest version that has been
initialized
. See {reinitializer}.
* @dev
Internal function that r
eturns the
initialized
version. Returns `_initialized`
*/
*/
function _getInitializedVersion() internal view returns (uint8) {
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
return _initialized;
}
}
/**
/**
コピー
コピー済み
コピー
コピー済み
* @dev
R
eturns
`true` if
the
contract is currently
initializ
ing. See {onlyInitializing}.
* @dev
Internal function that r
eturns
the
initializ
ed version. Returns `_initializing`
*/
*/
function _isInitializing() internal view returns (bool) {
function _isInitializing() internal view returns (bool) {
return _initializing;
return _initializing;
}
}
}
}
保存された差分
原文
ファイルを開く
/ SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * 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"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
変更されたテキスト
ファイルを開く
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * 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"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
違いを見つける