Skip to content

Implement Asset#288

Merged
truthixify merged 2 commits intoDistinctCodes:mainfrom
LaGodxy:Implement-Asset
Oct 1, 2025
Merged

Implement Asset#288
truthixify merged 2 commits intoDistinctCodes:mainfrom
LaGodxy:Implement-Asset

Conversation

@LaGodxy
Copy link
Contributor

@LaGodxy LaGodxy commented Sep 30, 2025

Description

Develop a Soroban contract (asset.rs) to manage asset registration and retrieval, storing asset details securely on the Stellar ledger.

Related Issues

Closes #

Changes Made

  • Created src/asset.rs with:

    • DataKey enum (e.g., Asset(BytesN<32>)).

    • Asset struct with fields:

      • id, name, asset_type, category, branch_id, department_id, status,
        purchase_date, purchase_cost, current_value, warranty_expiry, stellar_token_id, owner.
  • Implemented functions:

    • register_asset(...) → validates and registers a new asset.
    • get_asset(asset_id: BytesN<32>) → retrieves stored asset details.
  • Integrated with types.rs for AssetType and AssetStatus.

  • Used errors.rs for error handling (e.g., AssetAlreadyExists).

  • Enforced access control with Address::require_auth().

  • Added unit tests for registration and retrieval logic.

  • Updated lib.rs to include asset.rs as a module.

How to Test

  1. Build and deploy the Soroban contract.

  2. Call register_asset with a unique asset ID and valid parameters.

    • Verify that the asset is stored on the ledger.
  3. Call get_asset(asset_id) with the registered ID.

    • Ensure all stored details match the registration input.
  4. Attempt to register an asset with a duplicate ID.

    • Verify that the contract returns AssetAlreadyExists error.
  5. Attempt registration without required authorization.

    • Verify that the contract rejects the operation.
  6. Run all unit tests → confirm they pass.

Screenshots (if applicable)

N/A

Checklist

  • My code follows the project's coding style.
  • I have tested these changes locally.
  • Documentation has been updated where necessary.

closes #246

@vercel
Copy link

vercel bot commented Sep 30, 2025

@LaGodxy is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@truthixify
Copy link
Collaborator

@LaGodxy

make the CI pass and your PR will be merged.

@truthixify truthixify merged commit e98708a into DistinctCodes:main Oct 1, 2025
4 of 5 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

Development

Successfully merging this pull request may close these issues.

[CONTRACT] Implement Asset Contract for Registration

2 participants