Repository navigation
Authorize transfer-restriction, whitelist and token-unlock entrypoints - #1860
Merged
yusuftomilola merged 12 commits intoNov 24, 2026
Conversation
Introduce a single helper that authenticates the caller and checks they are the tokenized asset's tokenizer or the contract admin. Restriction and lock entrypoints will use it before delegating to auth-free module functions.
Add caller: Address as the last parameter and enforce require_auth plus the tokenizer-or-admin role before delegating to transfer_restrictions::set_geographic_restriction. Fixes an entrypoint that was callable by anyone. Closes DistinctCodes#1789
Add caller: Address as the last parameter of add_to_whitelist and remove_from_whitelist, enforce require_auth and the tokenizer-or-admin role, and update every existing client call site. A compliance officer role is deliberately not introduced; the tokenizer and admin are the authorized principals. Closes DistinctCodes#1788
Add caller: Address as the last parameter and enforce require_auth plus the tokenizer-or-admin role before delegating to transfer_restrictions::set_transfer_restriction. The existing transfer-restriction value logic is unchanged; only authorization is added. Update the integration call site. Closes DistinctCodes#1787
Add caller: Address as the last parameter and enforce require_auth plus the tokenizer-or-admin (lock setter) role before delegating to tokenization::unlock_tokens. Unlocking stays gated even after until_timestamp; an expired lock is already inert for transfers. Update the integration and pause call sites. Closes DistinctCodes#1782
For each of set_geographic_restriction, add_to_whitelist, remove_from_whitelist, set_transfer_restriction and unlock_tokens: an unmocked try_ call proving require_auth is enforced, a mock_all_auths call by an intruder asserting Error::Unauthorized (role check, not just authentication), and a tokenizer success case. Also add a shared tokenized-asset fixture that clears auths after setup.
Add the entrypoint to the 'Fixed in this change' table and mark its tokenization-table row as requiring the tokenizer/admin caller. Closes DistinctCodes#1789
Mark add_to_whitelist and remove_from_whitelist as requiring the tokenizer/admin caller and record the decision not to add a separate compliance-officer role. Closes DistinctCodes#1788
Mark set_transfer_restriction as requiring the tokenizer/admin caller and note that the existing restriction-value logic was left untouched. Closes DistinctCodes#1787
Mark unlock_tokens as requiring the tokenizer/admin caller, record the decision to keep the lock gated even after until_timestamp, and update the remaining-open-gaps wording. Closes DistinctCodes#1782
Update the tokenization and transfer-restriction tables/prose that still described unlock_tokens and the restriction setters as unauthenticated.
The new authorization tests use a fixed lock timestamp and do not need the Ledger testutils trait.
|
@memplethee-lab is attempting to deploy a commit to the naijabuz's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@memplethee-lab Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
3 tasks
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.
Summary
Four
AssetUpContractentrypoints inlib.rschecked the emergency pause but never authenticated anyone, and the module functions they delegate to contain norequire_authof their own. Each now takescaller: Addressas its last parameter and passes it through a single shared helper,require_asset_admin_or_tokenizer, which callscaller.require_auth(), loads the tokenized asset, and requires the caller to be its tokenizer or the contract admin. An authenticated caller with neither role receives the typedError::Unauthorized. Module-function signatures are unchanged, so existing direct-module unit tests keep compiling.set_geographic_restriction: now authenticatescallerand restricts the jurisdiction allow-list setter to the asset's tokenizer or the admin. Previously anyone could rewrite the allow-list while the contract was unpaused.Closes #1789add_to_whitelist/remove_from_whitelist: both entrypoints authenticatecallerand require the tokenizer or admin role. A separate compliance-officer role was considered but not added; the tokenizer/admin roles already cover the authorized principals without widening the ABI or storage layout.Closes #1788set_transfer_restriction: authenticated and restricted to the tokenizer or admin. The existing restriction-value logic (includinggeographic_allowed) was deliberately left untouched — only authorization was added.Closes #1787unlock_tokens: authenticated and restricted to the tokenizer/admin that set the lock. The lock is intentionally not permissionless afteruntil_timestamp: an expired lock is already inert for transfers viais_tokens_locked, so allowing anyone to clear the stored record would only let an outsider rewrite the lock setter's state with no liveness benefit.Closes #1782Tests and docs
contracts/assetsup/src/tests/auth.rs: an unmockedtry_*call provesrequire_authis enforced, and amock_all_authscall by a signed intruder assertsError::Unauthorized, proving authentication alone is insufficient. Success cases run with mocked auths for the tokenizer.contracts/assetsup/src/tests/integration_full.rsandcontracts/assetsup/src/tests/pause.rsfor the new signatures.contracts/AUTHORIZATION.md(new "Fixed in this change" rows, required-signer table entries, and notes on the unlock design and whitelist-role decision) and aligned theassetsupREADME with the new rules.Tests were not run locally per the task instructions.
Closes #1789
Closes #1788
Closes #1787
Closes #1782