FleetTreasuryPaymaster — whitelisted contract destinations#102
Open
Douglasacost wants to merge 1 commit intomainfrom
Open
FleetTreasuryPaymaster — whitelisted contract destinations#102Douglasacost wants to merge 1 commit intomainfrom
Douglasacost wants to merge 1 commit intomainfrom
Conversation
…nd validation improvements - Introduced `isWhitelistedContract` mapping to manage allowed destinations for gas sponsorship. - Added functions to add and remove whitelisted contracts, with checks to prevent removal of `fleetIdentity`. - Updated validation logic in `_validateAndPayGeneralFlow` to accommodate new contract whitelist. - Enhanced documentation in the swarm specification to reflect these changes. - Added tests for whitelisted contract functionality and validation scenarios.
LCOV of commit
|
aliXsed
reviewed
Mar 27, 2026
Comment on lines
+133
to
+140
| if (to == address(this)) { | ||
| if (!hasRole(WHITELIST_ADMIN_ROLE, from)) { | ||
| revert DestinationNotAllowed(); | ||
| } | ||
| } else if (isWhitelistedContract[to]) { | ||
| if (!isWhitelistedUser[from]) { | ||
| revert UserIsNotWhitelisted(); | ||
| } |
Collaborator
There was a problem hiding this comment.
Suggest a simplification as follows
Suggested change
| if (to == address(this)) { | |
| if (!hasRole(WHITELIST_ADMIN_ROLE, from)) { | |
| revert DestinationNotAllowed(); | |
| } | |
| } else if (isWhitelistedContract[to]) { | |
| if (!isWhitelistedUser[from]) { | |
| revert UserIsNotWhitelisted(); | |
| } | |
| if (!isWhitelistedUser[from]) { | |
| revert UserIsNotWhitelisted(); | |
| } else if (!isWhitelistedContract[to]) { | |
| revert DestinationNotAllowed(); | |
| } |
Then make sure that in the constructor you add address(this) to the whitelisted contracts and admin to the whitelisted users.
aliXsed
reviewed
Mar 27, 2026
| constructor( | ||
| address admin, | ||
| address withdrawer, | ||
| address fleetIdentity_, |
Collaborator
There was a problem hiding this comment.
Since it's possible to add any contract to white listed contracts then you can remove fleetIdentity here
aliXsed
reviewed
Mar 27, 2026
| /// @dev Only callable by the FleetIdentity contract during claimUuidSponsored. | ||
| /// The actual NODL transfer is done separately by FleetIdentity via transferFrom. | ||
| function consumeSponsoredBond(address user, uint256 amount) external { | ||
| if (msg.sender != fleetIdentity) revert NotFleetIdentity(); |
Collaborator
There was a problem hiding this comment.
In the more general case you can here check if (isWhitelistedContract(msg.sender)
aliXsed
reviewed
Mar 27, 2026
| /// Gas sponsorship: `fleetIdentity` is seeded into `isWhitelistedContract` at | ||
| /// deploy; admins add more destinations the same way. Admin-only calls to this | ||
| /// contract use `WHITELIST_ADMIN_ROLE` instead of user whitelist. | ||
| contract FleetTreasuryPaymaster is BasePaymaster, QuotaControl { |
Collaborator
There was a problem hiding this comment.
If you take my other suggestions, then consider renaming FleetTreasuryPaymaster to TreasuryPaymaster or use your AI assistant to suggest a better name that matches the contract logic.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Extends
FleetTreasuryPaymasterso gas sponsorship is not limited tofleetIdentityonly: allowedtoaddresses are tracked inisWhitelistedContract.fleetIdentityis seeded at deploy and cannot be removed. Documentation and tests are updated accordingly.Sponsors need to pay gas for user transactions targeting other protocol contracts (for example
SwarmRegistryUniversal) while keeping the same user whitelist and ETH balance checks, without deploying a separateWhitelistPaymaster.isWhitelistedContractmapping to manage allowed destinations for gas sponsorship.fleetIdentity._validateAndPayGeneralFlowto accommodate new contract whitelist.