-
Notifications
You must be signed in to change notification settings - Fork 38
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: move token receiver functions into account #124
feat: move token receiver functions into account #124
Conversation
7b02860
to
e58f45c
Compare
b79fb5e
to
4593415
Compare
- [Modular Account implementation](src/account) | ||
- [Modular Account factory](src/factory) | ||
- 2 ERC-6900 compatible plugins: | ||
- [MultiOwnerPlugin](src/plugins/owner) is a plugin supporting 1+ ECDSA owners. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably not the PR for it, but we do support contract owners too.
2d3c9c8
to
f4ed920
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, tests reviewed in the stacked PR
if (interfaceId == type(IPlugin).interfaceId) { | ||
revert IPluginInterfaceNotAllowed(); | ||
if (interfaceId == type(IPlugin).interfaceId || interfaceId == _INVALID_INTERFACE_ID) { | ||
revert InterfaceNotAllowed(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following interface types are also not relevant, although it doesn't really hurt to add them
- type(IERC721Receiver).interfaceId
- type(IERC777Recipient).interfaceId
- type(IERC1155Receiver).interfaceId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I'll probably leave this one as is since it doesn't hurt, and adding this in will increase contract size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to reduce the contract size || interfaceId == _INVALID_INTERFACE_ID
is also not really neccesary as it also checked in supportsInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! But I think this is ever so slightly different, which may justify this one.
- Without this check, a plugin wanting to add
_INVALID_INTERFACE_ID
will successfully install but always fail whensupportsInterface(_INVALID_INTERFACE_ID)
is called, which could be unexpected. - Without the token receiver interface checks here, a plugin wanting to add
type(IERC721Receiver).interfaceId
will successfully install, andsupportsInterface(type(IERC721Receiver).interfaceId)
will return true as expected.
_doPreExecHooks(_getAccountStorage().selectorData[msg.sig], ""); | ||
selector = IERC721Receiver.onERC721Received.selector; | ||
_postNativeFunction(postExecHooks, postHookArgs); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to override
onERC721Received()
, while still keeping the hooks, it might be useful
that onERC721Received()
calls another function (which is initially empty), that can be overriden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Addressed in #127 !
Motivation
Opening this to collect feedback and consensus around merging the token receiver functions into the account as native functions vs. installing them from a plugin. Motivation is to decrease the amount of gas spent on account creation.
Solution
TokenReceiverPlugin
.MultiOwnerTokenReceiverMSCAFactory
.tokensReceived
,onERC721Received
,onERC1155Received
,onERC1155BatchReceived
toUpgradeableModularAccount
.supportsInterface
.tokensReceived
,onERC721Received
,onERC1155Received
,onERC1155BatchReceived
toKnownSelectors.isNativeFunction
.Tests in #126