From b2d4966814df9ea60d1bf208c248e046a0f83782 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Mon, 10 Jun 2024 20:48:24 +0200 Subject: [PATCH] rename --- .changeset/serious-carrots-provide.md | 2 +- contracts/token/ERC20/README.adoc | 10 +++++----- ...ft-ERC7674.sol => draft-ERC20TemporaryApproval.sol} | 9 +++++---- ...{ERC7674.test.js => ERC20TemporaryApproval.test.js} | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) rename contracts/token/ERC20/extensions/{draft-ERC7674.sol => draft-ERC20TemporaryApproval.sol} (92%) rename test/token/ERC20/extensions/{ERC7674.test.js => ERC20TemporaryApproval.test.js} (97%) diff --git a/.changeset/serious-carrots-provide.md b/.changeset/serious-carrots-provide.md index ffc49b6473a..f64221d95b5 100644 --- a/.changeset/serious-carrots-provide.md +++ b/.changeset/serious-carrots-provide.md @@ -2,4 +2,4 @@ 'openzeppelin-solidity': minor --- -`ERC7674`: Add an ERC-20 extension that implements temporary approval using transient storage (draft). +`ERC20TemporaryApproval`: Add an ERC-20 extension that implements temporary approval using transient storage (draft). diff --git a/contracts/token/ERC20/README.adoc b/contracts/token/ERC20/README.adoc index 6487bbb2143..faaacc57667 100644 --- a/contracts/token/ERC20/README.adoc +++ b/contracts/token/ERC20/README.adoc @@ -22,9 +22,9 @@ Additionally there are multiple custom extensions, including: * {ERC20FlashMint}: token level support for flash loans through the minting and burning of ephemeral tokens (standardized as ERC-3156). * {ERC20Votes}: support for voting and vote delegation. * {ERC20Wrapper}: wrapper to create an ERC-20 backed by another ERC-20, with deposit and withdraw methods. Useful in conjunction with {ERC20Votes}. +* {ERC20TemporaryApproval}: support for approvals lasting for only one transaction, as defined in ERC-7674. * {ERC1363}: support for calling the target of a transfer or approval, enabling code execution on the receiver within a single transaction. * {ERC4626}: tokenized vault that manages shares (represented as ERC-20) that are backed by assets (another ERC-20). -* {ERC7674}: support for approvals lasting for only one transaction, as defined in ERC-7674. Finally, there are some utilities to interact with ERC-20 contracts in various ways: @@ -56,18 +56,18 @@ NOTE: This core set of contracts is designed to be unopinionated, allowing devel {{ERC20Pausable}} -{{ERC20FlashMint}} - {{ERC20Votes}} {{ERC20Wrapper}} +{{ERC20FlashMint}} + +{{ERC20TemporaryApproval}} + {{ERC1363}} {{ERC4626}} -{{ERC7674}} - == Utilities {{SafeERC20}} diff --git a/contracts/token/ERC20/extensions/draft-ERC7674.sol b/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol similarity index 92% rename from contracts/token/ERC20/extensions/draft-ERC7674.sol rename to contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol index 6228c7c3bd5..ef3aba197eb 100644 --- a/contracts/token/ERC20/extensions/draft-ERC7674.sol +++ b/contracts/token/ERC20/extensions/draft-ERC20TemporaryApproval.sol @@ -13,13 +13,14 @@ import {StorageSlot} from "../../../utils/StorageSlot.sol"; * * WARNING: This is a draft contract. The corresponding ERC is still subject to changes. */ -abstract contract ERC7674 is ERC20, IERC7674 { +abstract contract ERC20TemporaryApproval is ERC20, IERC7674 { using SlotDerivation for bytes32; using StorageSlot for bytes32; using StorageSlot for StorageSlot.Uint256SlotType; - // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC7674")) - 1)) & ~bytes32(uint256(0xff)) - bytes32 private constant ERC7674_STORAGE = 0xf9459e0e3709f2b5aaa798666bbb2eb0d06d2c3958e71e4a32973e445fe1ce00; + // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20_TEMPORARY_APPROVAL_STORAGE")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant ERC20_TEMPORARY_APPROVAL_STORAGE = + 0xea2d0e77a01400d0111492b1321103eed560d8fe44b9a7c2410407714583c400; /** * @dev {allowance} override that includes the temporary allowance when looking up the current allowance. If @@ -110,6 +111,6 @@ abstract contract ERC7674 is ERC20, IERC7674 { address owner, address spender ) private pure returns (StorageSlot.Uint256SlotType) { - return ERC7674_STORAGE.deriveMapping(owner).deriveMapping(spender).asUint256(); + return ERC20_TEMPORARY_APPROVAL_STORAGE.deriveMapping(owner).deriveMapping(spender).asUint256(); } } diff --git a/test/token/ERC20/extensions/ERC7674.test.js b/test/token/ERC20/extensions/ERC20TemporaryApproval.test.js similarity index 97% rename from test/token/ERC20/extensions/ERC7674.test.js rename to test/token/ERC20/extensions/ERC20TemporaryApproval.test.js index 69e6a10289e..74551495c16 100644 --- a/test/token/ERC20/extensions/ERC7674.test.js +++ b/test/token/ERC20/extensions/ERC20TemporaryApproval.test.js @@ -14,7 +14,7 @@ async function fixture() { const accounts = await ethers.getSigners(); const [holder, recipient, other] = accounts; - const token = await ethers.deployContract('$ERC7674', [name, symbol]); + const token = await ethers.deployContract('$ERC20TemporaryApproval', [name, symbol]); await token.$_mint(holder, initialSupply); const spender = await ethers.deployContract('$Address'); @@ -24,7 +24,7 @@ async function fixture() { return { accounts, holder, recipient, other, token, spender, batch, getter }; } -describe('ERC7674', function () { +describe('ERC20TemporaryApproval', function () { beforeEach(async function () { Object.assign(this, await loadFixture(fixture)); });