Skip to content

feat: enforce asset#41

Open
Agbeleshe wants to merge 7 commits intoNeko-Protocol:devfrom
Agbeleshe:Enforce-Asset
Open

feat: enforce asset#41
Agbeleshe wants to merge 7 commits intoNeko-Protocol:devfrom
Agbeleshe:Enforce-Asset

Conversation

@Agbeleshe
Copy link

PR: Enforce Asset Existence Before Setting Metadata

close #30

Rationale and Background

The previous implementation of the set_rwa_metadata function allowed for a silent inconsistency where metadata could be created for assets not yet registered in the internal assets vector. This led to a state where query functions like get_all_rwa_assets() could return IDs that weren't properly searchable via price feed functions, causing issues for integrators relying on a consistent registry. By enforcing registration before metadata assignment, we ensure that every asset with metadata is a valid, queryable part of the oracle ecosystem.

Implementation Details

To address this, we added a new AssetNotRegistered error variant with code 10 to the contract's error enum. The set_rwa_metadata function now proactively validates that any incoming asset_id exists in the system's storage before applying updates. Furthermore, the logic was refactored to unconditionally synchronize the asset_types mapping once an asset is verified as registered, eliminating the previous conditional block that occasionally failed to update mapping values even when the asset existed.

Testing and Verification

The test suite in test.rs was significantly expanded to cover all edge cases associated with this refactor, including four specific new tests for registration rejection and post-registration acceptance. We also updated all legacy tests to ensure they now perform the required registration steps before setting metadata, maintaining a clean green-build state. These tests verify that the contract now correctly rejects unregistered symbols while maintaining full compatibility with assets added via both the constructor and the add_assets administrative function.

Final Results and Impact

Following the refactor, the contract successfully passes all 14 unit tests and compiles to a release WASM profile without errors. The primary benefit of this change is the elimination of "ghost" metadata entries, ensuring that get_rwa_asset_type() and get_rwa_metadata() are always perfectly synchronized for any asset registered in the oracle. This leads to a more predictable and robust experience for downstream applications and protocols integrating with the Neko RWA infrastructure.

@vercel
Copy link

vercel bot commented Jan 30, 2026

@Agbeleshe is attempting to deploy a commit to the fabianalejandrosanchezduran-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Agbeleshe
Copy link
Author

@aguilar1x patiently waiting for your review 👋🙂

@Agbeleshe
Copy link
Author

@FabianSanchezD . Pattiently waiting for yout review

@Agbeleshe
Copy link
Author

@aguilar1x still waiting for your review

Copy link
Contributor

@aguilar1x aguilar1x left a comment

Choose a reason for hiding this comment

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

Make the changes based on the context of the changes made in test_ttl_extended_on_metadata_update().

Delete the test_snapshots and fix the conflicts in your branch.

@Agbeleshe Agbeleshe requested a review from aguilar1x February 2, 2026 15:52
added a test that expects metadata updates to extend storage TTL, but your contract doesn’t consistently call env.storage().persistent().extend_ttl(...) on updates, so the TTL isn’t being renewed and the test fails.
@Agbeleshe
Copy link
Author

Agbeleshe commented Feb 2, 2026

@aguilar1x still waiting for your review

1 similar comment
@Agbeleshe
Copy link
Author

@aguilar1x still waiting for your review

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.

[refactor] Enforce Asset Existence Before Setting Metadata

2 participants