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

feat(erc777): <- add custom function call when minting #1

Merged
merged 7 commits into from
Feb 29, 2024

Conversation

oliviera9
Copy link

Since ERC777 hooks have been removed, it's impossible to have a contract called when minting the pToken.

This PR adds a IPReceiver interface which exposes a receiveUserData() function that is called when minting the pToken.

@oliviera9 oliviera9 force-pushed the feat/call-with-user-data branch 3 times, most recently from 59e3e37 to 37ac0d0 Compare January 29, 2024 16:04
Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of minor changes, otherwise LGTM.

contracts/interfaces/IPReceiver.sol Show resolved Hide resolved
test/05-ptoken.test.js Outdated Show resolved Hide resolved
test/upgradeability.test.js Outdated Show resolved Hide resolved
contracts/pTokenNoGSN.sol Outdated Show resolved Hide resolved
contracts/pTokenNoGSN.sol Outdated Show resolved Hide resolved
contracts/pToken.sol Show resolved Hide resolved
test/05-ptoken.test.js Outdated Show resolved Hide resolved
@oliviera9 oliviera9 force-pushed the feat/call-with-user-data branch 5 times, most recently from 37a1354 to 9b4e719 Compare January 30, 2024 10:44
Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible changes requested - feel free to argue against if you have strong preferences.

contracts/pTokenNoGSN.sol Outdated Show resolved Hide resolved
contracts/test-contracts/PReceiver.sol Show resolved Hide resolved
test/05-ptoken.test.js Outdated Show resolved Hide resolved
test/05-ptoken.test.js Show resolved Hide resolved
contracts/pToken.sol Outdated Show resolved Hide resolved
contracts/pToken.sol Outdated Show resolved Hide resolved
@oliviera9 oliviera9 force-pushed the feat/call-with-user-data branch 2 times, most recently from efa78c0 to 3c6f1ca Compare January 30, 2024 12:35
@oliviera9
Copy link
Author

I just added a test where the recipient contract does not implement the IPReceiver interface.

Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final tweaks

contracts/pToken.sol Outdated Show resolved Hide resolved
contracts/pTokenNoGSN.sol Outdated Show resolved Hide resolved
contracts/test-contracts/PReceiver.sol Outdated Show resolved Hide resolved
test/05-ptoken.test.js Show resolved Hide resolved
Contrary to try/catch, the low-level call to a non-contract address
does not revert, thus allowing to write user data in the transaction.
Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk LGTM!

@gskapka
Copy link

gskapka commented Feb 14, 2024

Update: Decision has been made to use excessivelySafeCall for this.

@gskapka gskapka marked this pull request as draft February 14, 2024 15:26
@oliviera9 oliviera9 marked this pull request as ready for review February 15, 2024 22:04
@oliviera9
Copy link
Author

oliviera9 commented Feb 15, 2024

In order, I added unit tests for return bombing in 54549d2, and verified they fail.
Then implemented excessivelySafeCall, and now the tests pass.

Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the comments below need tweaking.

test/05-ptoken.test.js Show resolved Hide resolved
contracts/pTokenNoGSN.sol Outdated Show resolved Hide resolved
contracts/pToken.sol Outdated Show resolved Hide resolved
contracts/pToken.sol Outdated Show resolved Hide resolved
@oliviera9 oliviera9 force-pushed the feat/call-with-user-data branch 2 times, most recently from b372ee7 to 64b2929 Compare February 21, 2024 17:52
Copy link

@gskapka gskapka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gskapka
Copy link

gskapka commented Feb 29, 2024

Approved in pvt with @themetaseq & @wernervoncroy.

@gskapka gskapka merged commit 4c48651 into master Feb 29, 2024
1 check passed
@gskapka gskapka deleted the feat/call-with-user-data branch February 29, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants