Skip to content

feat(contracts): retire asset, audit log, owner registry and admin fu…#725

Merged
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
Uyoxy:feature/issues-645-646-647-649-smart-contract-core
Apr 26, 2026
Merged

feat(contracts): retire asset, audit log, owner registry and admin fu…#725
yusuftomilola merged 1 commit intoDistinctCodes:mainfrom
Uyoxy:feature/issues-645-646-647-649-smart-contract-core

Conversation

@Uyoxy
Copy link
Copy Markdown
Contributor

@Uyoxy Uyoxy commented Apr 26, 2026

Summary
Implements four core smart contract features for DistinctCodes/AssetsUp
inside `contracts/contrib/src/` only. No files outside this path were modified.

Changes

#645 — retire_asset and get_asset_info [SC-05]

  • File: `contracts/contrib/src/lib.rs`
  • `retire_asset(env, asset_id)`
    • Requires auth from asset owner
    • Sets status to `AssetStatus::Retired`
    • Panics if already retired
    • Emits retirement event
  • `get_asset_info(env, asset_id) -> Asset`
    • Reads asset from storage
    • Panics with `Asset not found` if missing
  • Both check contract is not paused before executing
  • Tests: retire success, already-retired panic, asset found, asset not found

#649 — On-Chain Audit Log System [SC-09]

  • File: `contracts/contrib/src/audit.rs`
  • `AuditLog` struct: `log_id`, `asset_id`, `action`, `actor`, `timestamp`, `details`
  • `append_audit_log()` — creates entry, appends to asset log list, increments global counter
  • `get_audit_logs(env, asset_id) -> Vec` — returns all logs per asset
  • Called internally by `register_asset`, `transfer_asset`, `retire_asset`
  • Tests: log recorded on each action, counter increments, correct asset scoping

#646 — Owner Registry [SC-06]

  • File: `contracts/contrib/src/owner_registry.rs`
  • `get_assets_by_owner(env, owner) -> Vec<BytesN<32>>`
  • `add_to_owner_registry()` — internal helper, appends asset ID to owner list
  • `remove_from_owner_registry()` — internal helper, removes asset ID from list
  • Both helpers wired into `register_asset` and `transfer_asset` automatically
  • Stored under `DataKey::OwnerAssets(Address)`

#647 — Contract Initialization & Admin Functions [SC-07]

  • File: `contracts/contrib/src/admin.rs`
  • `initialize(env, admin)` — sets admin, panics if already initialized
  • `get_admin(env) -> Address`
  • `add_registrar()` — admin-only, adds to authorized registrars list
  • `remove_registrar()` — admin-only, removes from registrars list
  • `is_authorized_registrar(env, address) -> bool`
  • `get_total_asset_count(env) -> u64`

Test Coverage

  • retire_asset: success, already-retired panic, paused contract panic
  • get_asset_info: found, not-found panic, paused contract panic
  • audit log: entry recorded, counter increments, asset-scoped retrieval
  • owner registry: add on register, remove on transfer, correct owner lookup
  • admin: initialize once, re-init panic, registrar add/remove, auth enforcement

Checklist

  • All files inside `contracts/contrib/src/` only
  • No files outside contribution folder modified
  • Pause guard on all public functions
  • Auth checks on owner and admin restricted functions
  • PR targets main

Closes

Closes #645
Closes #646
Closes #647
Closes #649

…nctions

- feat(DistinctCodes#645): implement retire_asset and get_asset_info functions
  · retire_asset(env, asset_id) — requires auth from asset owner
  · Sets status to AssetStatus::Retired on successful call
  · Panics if asset is already retired — no double-retire allowed
  · Emits retirement event on successful state change
  · get_asset_info(env, asset_id) -> Asset — reads asset from storage
  · Panics with 'Asset not found' if asset_id does not exist in storage
  · Both functions check contract is not paused before executing
  · Unit tests for retire success, already-retired panic, get found, get not found

- feat(DistinctCodes#649): implement on-chain audit log system
  · AuditLog struct: log_id: u64, asset_id: BytesN<32>, action: String,
    actor: Address, timestamp: u64, details: String in audit.rs
  · append_audit_log(env, asset_id, action, actor, details) creates entry,
    appends to asset log list in storage, increments global log counter
  · get_audit_logs(env, asset_id) -> Vec<AuditLog> returns all logs per asset
  · Called internally by register_asset, transfer_asset and retire_asset
  · Unit tests verifying log entries recorded correctly per action

- feat(DistinctCodes#646): implement owner registry address-to-asset-IDs index
  · get_assets_by_owner(env, owner) -> Vec<BytesN<32>> returns all asset IDs
  · add_to_owner_registry(env, owner, asset_id) appends asset ID to owner list
  · remove_from_owner_registry(env, owner, asset_id) removes asset ID from list
  · Both helpers called automatically in register_asset and transfer_asset
  · Registry stored under DataKey::OwnerAssets(Address) in contract storage

- feat(DistinctCodes#647): implement contract initialization and admin functions
  · initialize(env, admin: Address) sets admin under DataKey::Admin in storage
  · Panics if contract already initialized — no re-init allowed
  · get_admin(env) -> Address returns stored admin address
  · add_registrar(env, registrar: Address) admin-only, adds to registrars list
  · remove_registrar(env, registrar: Address) admin-only, removes from list
  · is_authorized_registrar(env, address: Address) -> bool checks registrar status
  · get_total_asset_count(env) -> u64 returns total registered asset count

Closes DistinctCodes#645, Closes DistinctCodes#646, Closes DistinctCodes#647, Closes DistinctCodes#649
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@lynaDev2 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
Copy link
Copy Markdown

drips-wave Bot commented Apr 26, 2026

@Uyoxy 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 c2f7654 into DistinctCodes:main Apr 26, 2026
1 of 8 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

3 participants