Skip to content

Conversation

@LorranSutter
Copy link
Member

No description provided.

@linear
Copy link

linear bot commented Oct 27, 2025

@LorranSutter LorranSutter marked this pull request as ready for review October 28, 2025 04:59
@LorranSutter LorranSutter requested a review from elffjs October 28, 2025 13:21
Copy link
Member

@elffjs elffjs left a comment

Choose a reason for hiding this comment

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

My only serious comment is about the event PermissionsSet. The rest are nitpicks.

templateId
);

emit PermissionsSet(address(0), 0, permissions, grantee, expiration, templateId, source);
Copy link
Member

@elffjs elffjs Oct 29, 2025

Choose a reason for hiding this comment

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

From the perspective of an event listener: I think we're losing msg.sender (the "grantor") here. We could use that instead of address(0) in the event arguments, although it seems strange to me to do a new function but not a new event. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. My main concern was to keep the same event to not break anything. Now that I found out the asset is the same as the grantor in other places, makes sense to add that

return false;
}

return (pr.permissions & permissions) == permissions;
Copy link
Member

Choose a reason for hiding this comment

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

It seems like hasAccountPermission and getAccountPermissions share a lot of code. Any opportunity for consolidation?

@LorranSutter LorranSutter requested a review from elffjs October 29, 2025 19:48
if (!_isTemplateActive(pr.templateId)) {
return false;
if (_isPermissionValid(pr.expiration, $.templateContract, pr.templateId)) {
return (pr.permissions >> (2 * permissionIndex)) & 3 == 3;
Copy link
Member

@elffjs elffjs Oct 30, 2025

Choose a reason for hiding this comment

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

My feeling was that you could call hasPermissions with 3 << (2 * permissionIndex). Am I wrong? Does it cost more gas?

Total code golf at this point, don't worry about it too much.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any extra function call costs more gas, but it is quite cheap. And I think this is nice and clean solution

@LorranSutter LorranSutter merged commit 5f1eb26 into main Nov 5, 2025
1 check passed
@LorranSutter LorranSutter deleted the feature/pr-3945-account-permission branch November 5, 2025 15:26
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.

5 participants