Skip to content
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

Add ERC1363 implementation #4631

Merged
merged 96 commits into from
Jan 24, 2024
Merged
Changes from 1 commit
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
84fe15d
Add ERC1363 contracts
vittominacori Sep 27, 2023
67d6fcd
Add ERC1363 tests
vittominacori Sep 27, 2023
4cbb703
Add changeset
vittominacori Sep 27, 2023
fdd322b
Improve documentation
vittominacori Sep 27, 2023
f8bd003
Add ERC1363Holder
vittominacori Sep 27, 2023
381387c
Update changeset
vittominacori Sep 27, 2023
83baa53
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Sep 29, 2023
a07c77c
Move mint out of test behavior and rename const to avoid confusion
vittominacori Sep 29, 2023
cf3c377
migrate Ownable tests to ethers
Amxx Oct 5, 2023
673ff79
fix lint
Amxx Oct 5, 2023
c9b4e8d
Update hardhat.config.js
Amxx Oct 5, 2023
c46a45e
add Ownable2Step
Amxx Oct 5, 2023
328a344
remove deploy helper
Amxx Oct 5, 2023
7c12232
add deprecation notices
Amxx Oct 5, 2023
517ad87
up
Amxx Oct 5, 2023
9002e5f
up
Amxx Oct 5, 2023
16731a9
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Oct 6, 2023
89ab4c9
Rename wrong file
vittominacori Oct 6, 2023
74558f8
remove .address when doing ethers call that support addressable
Amxx Oct 6, 2023
0e6e84c
Update pragma to 0.8.20
vittominacori Oct 6, 2023
9ea2db1
Fix flaky test in ERC2981.behavior
ernestognw Oct 10, 2023
fd7100a
Update test/access/Ownable.test.js
Amxx Oct 10, 2023
1a9a046
Update test/access/Ownable.test.js
Amxx Oct 10, 2023
b569ca8
Fix lint
ernestognw Oct 10, 2023
b24fec4
Fix upgradeable tests
ernestognw Oct 10, 2023
5e96021
redesign signers/fixture
Amxx Oct 10, 2023
f382329
Fix vanilla tests by overriding require and readArtifact with sync an…
ernestognw Oct 10, 2023
95be46d
Revert "redesign signers/fixture"
Amxx Oct 10, 2023
55b0406
Optimize ethers.getSigners call by passing a promise to use within fi…
ernestognw Oct 10, 2023
e45e482
Slice ethers accounts
ernestognw Oct 11, 2023
b391c2f
rename
Amxx Oct 11, 2023
74bab81
override hre.ethers.getSigners
Amxx Oct 11, 2023
98e5ecd
unify coding style/naming between env-contracts.js and env-artifacts.js
Amxx Oct 11, 2023
4db1800
Attempt to fix tests by avoid overriding `this` in Truffle require
ernestognw Oct 12, 2023
0a8a69d
Revert "Attempt to fix tests by avoid overriding `this` in Truffle re…
Amxx Oct 12, 2023
ec3bfc5
Merge branch 'master' into test/migration/ownable
Amxx Oct 12, 2023
5d5a150
Force compile on upgradeable and coverage workflows
Amxx Oct 12, 2023
300fa1e
use cached getSigners() in fixtures
Amxx Oct 13, 2023
ae4381e
use describe instead of contract for ethers test that don't need the …
Amxx Oct 13, 2023
b02770e
add enviornment sanity check
Amxx Oct 16, 2023
4e6a1ca
skip signer slice when running coverage
Amxx Oct 16, 2023
69b91a0
up
Amxx Oct 16, 2023
5162e98
Move non standardized error definition to the implementation file
Amxx Oct 17, 2023
2668934
Add "relaxed" helpers for ERC1363 in SafeERC20
Amxx Oct 17, 2023
5b84827
Merge branch 'test/migration/ownable' into feat/eip1363-v5.x
Amxx Oct 17, 2023
da0d4ff
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Oct 17, 2023
f269fa7
rewrite tests using ethers
Amxx Oct 17, 2023
8a4cae5
Merge branch 'master' into feat/eip1363-v5.x
Amxx Oct 17, 2023
46858a7
Remove ERC1363 Spender and Receiver interface from introspection test
vittominacori Oct 17, 2023
c07c414
addapt erc165 verification to ethers
Amxx Oct 17, 2023
24e8e89
Add a test to check that events are emitted
vittominacori Oct 17, 2023
f781db4
minor fixes
Amxx Oct 17, 2023
17b697b
Merge branch 'feat/eip1363-v5.x' of https://github.com/vittominacori/…
Amxx Oct 17, 2023
80930e8
migrate ERC1363Holder test to ethers + lint:fix
Amxx Oct 17, 2023
a844207
improve SupportInterface.behavior.js
Amxx Oct 17, 2023
178ff7d
codespell
Amxx Oct 17, 2023
34a7a8d
test SafeERC20 relaxed functions
Amxx Oct 17, 2023
7fde72d
fix lint
Amxx Oct 17, 2023
5ec39cb
Apply suggestions from code review
Amxx Oct 17, 2023
eb0fb78
remove ERC1363Holder
Amxx Oct 17, 2023
b893eec
add changeset
Amxx Oct 17, 2023
e137121
Fix documentation reference
vittominacori Oct 18, 2023
07bdbfd
Use external instead of public in mock (as it is in interface)
vittominacori Oct 20, 2023
4440345
Typo
vittominacori Oct 26, 2023
3dff6e2
Update contracts/interfaces/IERC1363Spender.sol
vittominacori Oct 27, 2023
c2f27c8
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Oct 27, 2023
81d191f
Apply suggestions from code review
Amxx Oct 27, 2023
c3fa314
test coverage
Amxx Oct 27, 2023
09049d3
lint
Amxx Oct 27, 2023
0ac39e4
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Nov 14, 2023
341a687
Merge branch 'master' of https://github.com/OpenZeppelin/openzeppelin…
vittominacori Dec 8, 2023
938a92b
Merge branch 'master' into feat/eip1363-v5.x
Amxx Dec 15, 2023
924b50d
re-enable shouldBehaveLikeERC20 + minor test cleanup
Amxx Dec 15, 2023
7d5e66e
document the 1363 functions not passing the standardized tests
Amxx Dec 15, 2023
f0d3a17
fix lint
Amxx Dec 15, 2023
7629147
Merge branch 'master' into feat/eip1363-v5.x
Amxx Jan 2, 2024
8f7c2bf
fix merge
Amxx Jan 2, 2024
feb824e
fix lint
Amxx Jan 2, 2024
af285c6
add notices
Amxx Jan 2, 2024
08c8eff
Merge branch 'master' into feat/eip1363-v5.x
Amxx Jan 18, 2024
d9cba07
forge update
Amxx Jan 18, 2024
ed594f0
Update .changeset/friendly-nails-push.md
Amxx Jan 18, 2024
72b0271
Merge branch 'master' into feat/eip1363-v5.x
ernestognw Jan 18, 2024
ab19eff
Optionally evaluate return value when calling ERC1363 using `transfer…
ernestognw Jan 18, 2024
5efabe6
Apply review comments
ernestognw Jan 18, 2024
07f1e4d
Update test/token/ERC20/utils/SafeERC20.test.js
Amxx Jan 19, 2024
fb78a86
Update test/token/ERC20/utils/SafeERC20.test.js
Amxx Jan 19, 2024
8639885
check values
Amxx Jan 23, 2024
10f4d1d
test SafeERC20 against non compliant ERC1363 tokens
Amxx Jan 23, 2024
327aca5
lint
Amxx Jan 23, 2024
cba6a94
Nits
ernestognw Jan 23, 2024
6747cb8
Add note for usdt-like approval requirements in approveAndCallRelaxed
ernestognw Jan 23, 2024
96551b0
Moar nits
ernestognw Jan 23, 2024
54f06e7
Improve ERC1363 tests
ernestognw Jan 23, 2024
12e2952
Fix codespell
ernestognw Jan 23, 2024
2c85474
final cleanup (minimize changes)
Amxx Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test SafeERC20 relaxed functions
  • Loading branch information
Amxx committed Oct 17, 2023
commit 34a7a8de6e290807fbdd1a58cba7159668dd0957
80 changes: 79 additions & 1 deletion test/token/ERC20/utils/SafeERC20.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ const ERC20ReturnFalseMock = artifacts.require('$ERC20ReturnFalseMock');
const ERC20ReturnTrueMock = artifacts.require('$ERC20'); // default implementation returns true
const ERC20NoReturnMock = artifacts.require('$ERC20NoReturnMock');
const ERC20ForceApproveMock = artifacts.require('$ERC20ForceApproveMock');
const ERC1363 = artifacts.require('$ERC1363');

const { expectRevertCustomError } = require('../../../helpers/customError');

const name = 'ERC20Mock';
const symbol = 'ERC20Mock';

contract('SafeERC20', function (accounts) {
const [hasNoCode, receiver, spender] = accounts;
const [hasNoCode, owner, receiver, spender, other] = accounts;

before(async function () {
this.mock = await SafeERC20.new();
Expand Down Expand Up @@ -144,6 +145,83 @@ contract('SafeERC20', function (accounts) {
});
});
});

describe('with ERC1363', function () {
const value = web3.utils.toBN(100);

beforeEach(async function () {
this.token = await ERC1363.new(name, symbol);
});

shouldOnlyRevertOnErrors(accounts);

describe('transferAndCall', function () {
it('cannot transferAndCall to an EOA directly', async function () {
await this.token.$_mint(owner, 100);

await expectRevertCustomError(
this.token.methods['transferAndCall(address,uint256,bytes)'](receiver, value, '0x', { from: owner }),
'ERC1363InvalidReceiver',
[receiver],
);
});

it('can transferAndCall to an EOA using helper', async function () {
await this.token.$_mint(this.mock.address, value);

const { tx } = await this.mock.$transferAndCallRelaxed(this.token.address, receiver, value, '0x');
await expectEvent.inTransaction(tx, this.token, 'Transfer', {
from: this.mock.address,
to: receiver,
value,
});
});
});

describe('transferFromAndCall', function () {
it('cannot transferFromAndCall to an EOA directly', async function () {
await this.token.$_mint(owner, value);
await this.token.approve(other, constants.MAX_UINT256, { from: owner });

await expectRevertCustomError(
this.token.methods['transferFromAndCall(address,address,uint256,bytes)'](owner, receiver, value, '0x', { from: other }),
'ERC1363InvalidReceiver',
[receiver],
);
});

it('can transferFromAndCall to an EOA using helper', async function () {
await this.token.$_mint(owner, value);
await this.token.approve(this.mock.address, constants.MAX_UINT256, { from: owner });

const { tx } = await this.mock.$transferFromAndCallRelaxed(this.token.address, owner, receiver, value, '0x');
await expectEvent.inTransaction(tx, this.token, 'Transfer', {
from: owner,
to: receiver,
value,
});
});
});

describe('approveAndCall', function () {
it('cannot approveAndCall to an EOA directly', async function () {
await expectRevertCustomError(
this.token.methods['approveAndCall(address,uint256,bytes)'](receiver, value, '0x'),
'ERC1363InvalidSpender',
[receiver],
);
});

it('can approveAndCall to an EOA using helper', async function () {
const { tx } = await this.mock.$approveAndCallRelaxed(this.token.address, receiver, value, '0x');
await expectEvent.inTransaction(tx, this.token, 'Approval', {
owner: this.mock.address,
spender: receiver,
value,
});
});
});
});
});

function shouldOnlyRevertOnErrors([owner, receiver, spender]) {
Expand Down
Loading