Skip to content

Authorize transfer-restriction, whitelist and token-unlock entrypoints - #1860

Merged
yusuftomilola merged 12 commits into
DistinctCodes:mainfrom
memplethee-lab:feature/restriction-and-lock-authorization
Nov 24, 2026
Merged

yusuftomilola merged 12 commits into
DistinctCodes:mainfrom
memplethee-lab:feature/restriction-and-lock-authorization

Conversation

@memplethee-lab

Copy link
Copy Markdown
Contributor

Summary

Four AssetUpContract entrypoints in lib.rs checked the emergency pause but never authenticated anyone, and the module functions they delegate to contain no require_auth of their own. Each now takes caller: Address as its last parameter and passes it through a single shared helper, require_asset_admin_or_tokenizer, which calls caller.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 typed Error::Unauthorized. Module-function signatures are unchanged, so existing direct-module unit tests keep compiling.

Tests and docs

  • Added success and negative authorization tests in contracts/assetsup/src/tests/auth.rs: an unmocked try_* call proves require_auth is enforced, and a mock_all_auths call by a signed intruder asserts Error::Unauthorized, proving authentication alone is insufficient. Success cases run with mocked auths for the tokenizer.
  • Updated every affected client call site in contracts/assetsup/src/tests/integration_full.rs and contracts/assetsup/src/tests/pause.rs for the new signatures.
  • Updated 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 the assetsup README with the new rules.

Tests were not run locally per the task instructions.

Closes #1789
Closes #1788
Closes #1787
Closes #1782

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.
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@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.

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@yusuftomilola
yusuftomilola merged commit 8ca4a40 into DistinctCodes:main Nov 24, 2026
1 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants