-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add ERC1363 implementation #4631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 87 commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
84fe15d
Add ERC1363 contracts
vittominacori 67d6fcd
Add ERC1363 tests
vittominacori 4cbb703
Add changeset
vittominacori fdd322b
Improve documentation
vittominacori f8bd003
Add ERC1363Holder
vittominacori 381387c
Update changeset
vittominacori 83baa53
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori a07c77c
Move mint out of test behavior and rename const to avoid confusion
vittominacori cf3c377
migrate Ownable tests to ethers
Amxx 673ff79
fix lint
Amxx c9b4e8d
Update hardhat.config.js
Amxx c46a45e
add Ownable2Step
Amxx 328a344
remove deploy helper
Amxx 7c12232
add deprecation notices
Amxx 517ad87
up
Amxx 9002e5f
up
Amxx 16731a9
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori 89ab4c9
Rename wrong file
vittominacori 74558f8
remove .address when doing ethers call that support addressable
Amxx 0e6e84c
Update pragma to 0.8.20
vittominacori 9ea2db1
Fix flaky test in ERC2981.behavior
ernestognw fd7100a
Update test/access/Ownable.test.js
Amxx 1a9a046
Update test/access/Ownable.test.js
Amxx b569ca8
Fix lint
ernestognw b24fec4
Fix upgradeable tests
ernestognw 5e96021
redesign signers/fixture
Amxx f382329
Fix vanilla tests by overriding require and readArtifact with sync an…
ernestognw 95be46d
Revert "redesign signers/fixture"
Amxx 55b0406
Optimize ethers.getSigners call by passing a promise to use within fi…
ernestognw e45e482
Slice ethers accounts
ernestognw b391c2f
rename
Amxx 74bab81
override hre.ethers.getSigners
Amxx 98e5ecd
unify coding style/naming between env-contracts.js and env-artifacts.js
Amxx 4db1800
Attempt to fix tests by avoid overriding `this` in Truffle require
ernestognw 0a8a69d
Revert "Attempt to fix tests by avoid overriding `this` in Truffle re…
Amxx ec3bfc5
Merge branch 'master' into test/migration/ownable
Amxx 5d5a150
Force compile on upgradeable and coverage workflows
Amxx 300fa1e
use cached getSigners() in fixtures
Amxx ae4381e
use describe instead of contract for ethers test that don't need the …
Amxx b02770e
add enviornment sanity check
Amxx 4e6a1ca
skip signer slice when running coverage
Amxx 69b91a0
up
Amxx 5162e98
Move non standardized error definition to the implementation file
Amxx 2668934
Add "relaxed" helpers for ERC1363 in SafeERC20
Amxx 5b84827
Merge branch 'test/migration/ownable' into feat/eip1363-v5.x
Amxx da0d4ff
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori f269fa7
rewrite tests using ethers
Amxx 8a4cae5
Merge branch 'master' into feat/eip1363-v5.x
Amxx 46858a7
Remove ERC1363 Spender and Receiver interface from introspection test
vittominacori c07c414
addapt erc165 verification to ethers
Amxx 24e8e89
Add a test to check that events are emitted
vittominacori f781db4
minor fixes
Amxx 17b697b
Merge branch 'feat/eip1363-v5.x' of https://github.com/vittominacori/…
Amxx 80930e8
migrate ERC1363Holder test to ethers + lint:fix
Amxx a844207
improve SupportInterface.behavior.js
Amxx 178ff7d
codespell
Amxx 34a7a8d
test SafeERC20 relaxed functions
Amxx 7fde72d
fix lint
Amxx 5ec39cb
Apply suggestions from code review
Amxx eb0fb78
remove ERC1363Holder
Amxx b893eec
add changeset
Amxx e137121
Fix documentation reference
vittominacori 07bdbfd
Use external instead of public in mock (as it is in interface)
vittominacori 4440345
Typo
vittominacori 3dff6e2
Update contracts/interfaces/IERC1363Spender.sol
vittominacori c2f27c8
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori 81d191f
Apply suggestions from code review
Amxx c3fa314
test coverage
Amxx 09049d3
lint
Amxx 0ac39e4
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori 341a687
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori 938a92b
Merge branch 'master' into feat/eip1363-v5.x
Amxx 924b50d
re-enable shouldBehaveLikeERC20 + minor test cleanup
Amxx 7d5e66e
document the 1363 functions not passing the standardized tests
Amxx f0d3a17
fix lint
Amxx 7629147
Merge branch 'master' into feat/eip1363-v5.x
Amxx 8f7c2bf
fix merge
Amxx feb824e
fix lint
Amxx af285c6
add notices
Amxx 08c8eff
Merge branch 'master' into feat/eip1363-v5.x
Amxx d9cba07
forge update
Amxx ed594f0
Update .changeset/friendly-nails-push.md
Amxx 72b0271
Merge branch 'master' into feat/eip1363-v5.x
ernestognw ab19eff
Optionally evaluate return value when calling ERC1363 using `transfer…
ernestognw 5efabe6
Apply review comments
ernestognw 07f1e4d
Update test/token/ERC20/utils/SafeERC20.test.js
Amxx fb78a86
Update test/token/ERC20/utils/SafeERC20.test.js
Amxx 8639885
check values
Amxx 10f4d1d
test SafeERC20 against non compliant ERC1363 tokens
Amxx 327aca5
lint
Amxx cba6a94
Nits
ernestognw 6747cb8
Add note for usdt-like approval requirements in approveAndCallRelaxed
ernestognw 96551b0
Moar nits
ernestognw 54f06e7
Improve ERC1363 tests
ernestognw 12e2952
Fix codespell
ernestognw 2c85474
final cleanup (minimize changes)
Amxx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`ERC1363`: Add implementation of the token payable standard allowing execution of contract code after transfers and approvals. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`SafeERC20`: Add "relaxed" function for interacting with ERC-1363 functions in a way that is compatible with EOAs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {IERC1363Receiver} from "../../interfaces/IERC1363Receiver.sol"; | ||
|
||
contract ERC1363ReceiverMock is IERC1363Receiver { | ||
enum RevertType { | ||
None, | ||
RevertWithoutMessage, | ||
RevertWithMessage, | ||
RevertWithCustomError, | ||
Panic | ||
} | ||
|
||
bytes4 private _retval; | ||
RevertType private _error; | ||
|
||
event Received(address operator, address from, uint256 value, bytes data); | ||
error CustomError(bytes4); | ||
|
||
constructor() { | ||
_retval = IERC1363Receiver.onTransferReceived.selector; | ||
_error = RevertType.None; | ||
} | ||
|
||
function setUp(bytes4 retval, RevertType error) public { | ||
_retval = retval; | ||
_error = error; | ||
} | ||
|
||
function onTransferReceived( | ||
address operator, | ||
address from, | ||
uint256 value, | ||
bytes calldata data | ||
) external override returns (bytes4) { | ||
if (_error == RevertType.RevertWithoutMessage) { | ||
revert(); | ||
} else if (_error == RevertType.RevertWithMessage) { | ||
revert("ERC1363ReceiverMock: reverting"); | ||
} else if (_error == RevertType.RevertWithCustomError) { | ||
revert CustomError(_retval); | ||
} else if (_error == RevertType.Panic) { | ||
uint256 a = uint256(0) / uint256(0); | ||
a; | ||
} | ||
|
||
emit Received(operator, from, value, data); | ||
return _retval; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
import {IERC1363Spender} from "../../interfaces/IERC1363Spender.sol"; | ||
|
||
contract ERC1363SpenderMock is IERC1363Spender { | ||
enum RevertType { | ||
None, | ||
RevertWithoutMessage, | ||
RevertWithMessage, | ||
RevertWithCustomError, | ||
Panic | ||
} | ||
|
||
bytes4 private _retval; | ||
RevertType private _error; | ||
|
||
event Approved(address owner, uint256 value, bytes data); | ||
error CustomError(bytes4); | ||
|
||
constructor() { | ||
_retval = IERC1363Spender.onApprovalReceived.selector; | ||
_error = RevertType.None; | ||
} | ||
|
||
function setUp(bytes4 retval, RevertType error) public { | ||
_retval = retval; | ||
_error = error; | ||
} | ||
|
||
function onApprovalReceived(address owner, uint256 value, bytes calldata data) external override returns (bytes4) { | ||
if (_error == RevertType.RevertWithoutMessage) { | ||
revert(); | ||
} else if (_error == RevertType.RevertWithMessage) { | ||
revert("ERC1363SpenderMock: reverting"); | ||
} else if (_error == RevertType.RevertWithCustomError) { | ||
revert CustomError(_retval); | ||
} else if (_error == RevertType.Panic) { | ||
uint256 a = uint256(0) / uint256(0); | ||
a; | ||
} | ||
|
||
emit Approved(owner, value, data); | ||
return _retval; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.