Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
geode interface
생성일
4년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
10 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
140 행
복사
38 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
164 행
복사
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol)
pragma solidity =0.8.7;
pragma solidity =0.8.7;
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
복사
복사됨
복사
복사됨
import "
@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "
../helpers/ERC20InterfaceUpgradable.sol";
/**
* @dev differences between ERC20InterfacePermitUpgradable and Openzeppelin's implementation of ERC20PermitUpgradable is:
* -> pragma set to =0.8.7;
* -> using ERC20InterfaceUpgradable instead of ERC20Upgradeable
* -> added initialize
*/
/**
/**
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
* need to send a transaction, and thus is not required to hold Ether at all.
*
*
* _Available since v3.4._
* _Available since v3.4._
*
*
* @custom:storage-size 51
* @custom:storage-size 51
*/
*/
복사
복사됨
복사
복사됨
abstract
contract ERC20
PermitUpgrad
e
able is
contract ERC20
Interface
PermitUpgrad
able is
Initializable,
Initializable,
복사
복사됨
복사
복사됨
ERC20
Upgrad
e
able,
ERC20
Interface
Upgrad
able,
IERC20PermitUpgradeable,
IERC20PermitUpgradeable,
EIP712Upgradeable
EIP712Upgradeable
{
{
using CountersUpgradeable for CountersUpgradeable.Counter;
using CountersUpgradeable for CountersUpgradeable.Counter;
mapping(address => CountersUpgradeable.Counter) private _nonces;
mapping(address => CountersUpgradeable.Counter) private _nonces;
// solhint-disable-next-line var-name-mixedcase
// solhint-disable-next-line var-name-mixedcase
bytes32 private constant _PERMIT_TYPEHASH =
bytes32 private constant _PERMIT_TYPEHASH =
keccak256(
keccak256(
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
);
);
/**
/**
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`.
* However, to ensure consistency with the upgradeable transpiler, we will continue
* However, to ensure consistency with the upgradeable transpiler, we will continue
* to reserve a slot.
* to reserve a slot.
* @custom:oz-renamed-from _PERMIT_TYPEHASH
* @custom:oz-renamed-from _PERMIT_TYPEHASH
*/
*/
// solhint-disable-next-line var-name-mixedcase
// solhint-disable-next-line var-name-mixedcase
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT;
/**
/**
복사
복사됨
복사
복사됨
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
*/
function initialize(
uint256 id_,
string calldata name_,
string calldata symbol_,
address gETH_1155
) public virtual initializer {
__ERC20interfacePermit_init(id_, name_, symbol_, gETH_1155);
}
/**
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
* @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
*
*
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
* It's a good idea to use the same `name` that is defined as the ERC20 token name.
*/
*/
복사
복사됨
복사
복사됨
function __ERC20
Permit_init(
string
memory
name
) internal onlyInitializing {
function __ERC20
interface
Permit_init(
__EIP712_init_unchained(name
, "1");
uint256 id_,
string
calldata
name
_,
string calldata symbol_,
address gETH_1155
) internal onlyInitializing {
__ERC20interface_init_unchained(id_, name_, symbol_, gETH_1155);
__EIP712_init_unchained(name
_
, "1");
}
}
복사
복사됨
복사
복사됨
function __ERC20Permit_init_unchained(string memory)
internal
onlyInitializing
{}
/**
/**
* @dev See {IERC20Permit-permit}.
* @dev See {IERC20Permit-permit}.
*/
*/
function permit(
function permit(
address owner,
address owner,
address spender,
address spender,
uint256 value,
uint256 value,
uint256 deadline,
uint256 deadline,
uint8 v,
uint8 v,
bytes32 r,
bytes32 r,
bytes32 s
bytes32 s
) public virtual override {
) public virtual override {
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
require(block.timestamp <= deadline, "ERC20Permit: expired deadline");
bytes32 structHash = keccak256(
bytes32 structHash = keccak256(
abi.encode(
abi.encode(
_PERMIT_TYPEHASH,
_PERMIT_TYPEHASH,
owner,
owner,
spender,
spender,
value,
value,
_useNonce(owner),
_useNonce(owner),
deadline
deadline
)
)
);
);
bytes32 hash = _hashTypedDataV4(structHash);
bytes32 hash = _hashTypedDataV4(structHash);
address signer = ECDSAUpgradeable.recover(hash, v, r, s);
address signer = ECDSAUpgradeable.recover(hash, v, r, s);
require(signer == owner, "ERC20Permit: invalid signature");
require(signer == owner, "ERC20Permit: invalid signature");
_approve(owner, spender, value);
_approve(owner, spender, value);
}
}
/**
/**
* @dev See {IERC20Permit-nonces}.
* @dev See {IERC20Permit-nonces}.
*/
*/
function nonces(address owner)
function nonces(address owner)
public
public
view
view
virtual
virtual
override
override
returns (uint256)
returns (uint256)
{
{
return _nonces[owner].current();
return _nonces[owner].current();
}
}
/**
/**
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
* @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
*/
*/
// solhint-disable-next-line func-name-mixedcase
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
function DOMAIN_SEPARATOR() external view override returns (bytes32) {
return _domainSeparatorV4();
return _domainSeparatorV4();
}
}
/**
/**
* @dev "Consume a nonce": return the current value and increment.
* @dev "Consume a nonce": return the current value and increment.
*
*
* _Available since v4.1._
* _Available since v4.1._
*/
*/
function _useNonce(address owner)
function _useNonce(address owner)
internal
internal
virtual
virtual
returns (uint256 current)
returns (uint256 current)
{
{
CountersUpgradeable.Counter storage nonce = _nonces[owner];
CountersUpgradeable.Counter storage nonce = _nonces[owner];
current = nonce.current();
current = nonce.current();
nonce.increment();
nonce.increment();
}
}
/**
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
*/
uint256[49] private __gap;
uint256[49] private __gap;
}
}
저장된 비교 결과
원본
파일 열기
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity =0.8.7; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ * * @custom:storage-size 51 */ abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20Permit_init(string memory name) internal onlyInitializing { __EIP712_init_unchained(name, "1"); } function __ERC20Permit_init_unchained(string memory) internal onlyInitializing {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
수정본
파일 열기
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity =0.8.7; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "../helpers/ERC20InterfaceUpgradable.sol"; /** * @dev differences between ERC20InterfacePermitUpgradable and Openzeppelin's implementation of ERC20PermitUpgradable is: * -> pragma set to =0.8.7; * -> using ERC20InterfaceUpgradable instead of ERC20Upgradeable * -> added initialize */ /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ * * @custom:storage-size 51 */ contract ERC20InterfacePermitUpgradable is Initializable, ERC20InterfaceUpgradable, IERC20PermitUpgradeable, EIP712Upgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; mapping(address => CountersUpgradeable.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); /** * @dev In previous versions `_PERMIT_TYPEHASH` was declared as `immutable`. * However, to ensure consistency with the upgradeable transpiler, we will continue * to reserve a slot. * @custom:oz-renamed-from _PERMIT_TYPEHASH */ // solhint-disable-next-line var-name-mixedcase bytes32 private _PERMIT_TYPEHASH_DEPRECATED_SLOT; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * */ function initialize( uint256 id_, string calldata name_, string calldata symbol_, address gETH_1155 ) public virtual initializer { __ERC20interfacePermit_init(id_, name_, symbol_, gETH_1155); } /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ function __ERC20interfacePermit_init( uint256 id_, string calldata name_, string calldata symbol_, address gETH_1155 ) internal onlyInitializing { __ERC20interface_init_unchained(id_, name_, symbol_, gETH_1155); __EIP712_init_unchained(name_, "1"); } /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256( abi.encode( _PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline ) ); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSAUpgradeable.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view override returns (bytes32) { return _domainSeparatorV4(); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { CountersUpgradeable.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
비교하기