Skip to content

#17 Add contract configuration read API FIXED - #188

Open
onakijames-droid wants to merge 1 commit into
Raegis-RWA:mainfrom
onakijames-droid:#17--Add-contract-configuration-read-API-FIX
Open

onakijames-droid wants to merge 1 commit into
Raegis-RWA:mainfrom
onakijames-droid:#17--Add-contract-configuration-read-API-FIX

Conversation

@onakijames-droid

Copy link
Copy Markdown

CLOSE #17 Add contract configuration read API

Description

Added stable, read-only configuration and diagnostics helpers for SDK and dashboard clients.

This PR introduces a new read_helpers module exposing aggregate read APIs for:

  • Contract configuration and pending governance state
  • Role and effective-duty visibility
  • Global pause and asset lifecycle state
  • Compliance module status
  • Per-account compliance state
  • Asset registry / metadata status
  • Storage, capability schema, and contract version details

All new helpers are safe read-only calls: they require no auth, emit no events, perform no storage writes, and are callable before initialization and while paused.

Key implementation files:

  • src/read_helpers.rs — new response structs, optional wrapper types, storage version constant, and public read entrypoints.
  • src/lib.rs — exports the new read_helpers module.
  • src/test.rs — adds default-state, configured-state, and no-mutation coverage.
  • docs/configuration-read-helpers.md — documents client usage and safety guarantees.
  • docs/contract-spec.md / README.md — links and summarizes the new read-helper API.
  • fixtures/sdk/*.json — regenerated fixture snapshots so SDK fixture tests pass with the current observable contract behavior.

Related Issues

Fixes: configuration visibility issue for SDK/dashboard diagnostics.
Issue number was not provided in the prompt.

Completion Table

Acceptance Criterion Status Implementation Evidence Test Evidence Documentation Impact
AC 1: Configuration read API is implemented. Complete Added get_contract_config, get_storage_info, get_storage_version, and supporting response structs in src/read_helpers.rs. Covered by test_read_helpers_default_state_and_never_mutate and test_read_helpers_configured_state_and_pause_visibility in src/test.rs. Added docs/configuration-read-helpers.md; updated docs/contract-spec.md and README.md.
AC 2: Role, pause, and version state are exposed safely. Complete Added get_role_state, get_pause_state, get_storage_info, and get_storage_version in src/read_helpers.rs. Tests assert default and configured role state, admin/pending-admin flags, pause state, lifecycle status, and storage/capability versions. Documented in docs/configuration-read-helpers.md and docs/contract-spec.md.
AC 3: Compliance and asset module status is visible where applicable. Complete Added get_compliance_module_status, get_compliance_account_state, and get_asset_registry_status in src/read_helpers.rs. Tests assert compliance module flags, account compliance status, whitelist compatibility flag, send/receive booleans, asset registry status, metadata, and total supply. Documented in docs/configuration-read-helpers.md.
AC 4: Read helpers do not mutate state. Complete Helpers only read existing storage keys and compose existing module reads. They do not call set, remove, publish, or require_auth. Tests capture event count, balances, and supply before/after helper calls and assert no changes. Safety guarantees documented in docs/configuration-read-helpers.md.
AC 5: Tests cover default and configured states. Complete N/A — test-only criterion. Added default/uninitialized coverage and configured-state coverage in src/test.rs. Full cargo test passes. N/A — no additional docs needed beyond test coverage.
AC 6: Documentation explains client usage. Complete N/A — documentation criterion. Documentation presence is supported by updated docs and README links. Added docs/configuration-read-helpers.md; updated docs/contract-spec.md and README.md.

Detailed Traceability Mapping

Acceptance Criteria Implementation Storage & State Changes Events Emitted Test Coverage Security/Safety Controls
AC 1: Configuration read API is implemented. New ContractConfigRead, optional wrapper enums, StorageVersionRead, get_contract_config, get_storage_info, and get_storage_version. No persisted storage layout changes. Reads existing keys only. STORAGE_VERSION is a constant, not a stored key. None. test_read_helpers_default_state_and_never_mutate; test_read_helpers_configured_state_and_pause_visibility. No auth required; safe defaults for absent storage.
AC 2: Role, pause, and version state are exposed safely. New RoleReadState, PauseReadState, and version read helpers. No storage writes. Reads existing admin, role, pending-admin, pause, asset-status, and version data. None. Tests assert role/effective role, duties, admin/pending-admin flags, pause state, operations state, and versions. Uses read-only helpers; no role checks or auth side effects.
AC 3: Compliance and asset module status is visible where applicable. New ComplianceModuleStatusRead, ComplianceAccountRead, and AssetRegistryStatusRead. No storage writes. Reads existing compliance status, metadata, asset status, and total supply. None. Tests assert module flags, compliance state, can-send/can-receive, metadata, registry status, and total supply. Unknown compliance defaults fail closed; metadata defaults to empty strings.
AC 4: Read helpers do not mutate state. All helper functions are pure reads and aggregate existing state. No persisted key changes, no writes, no removals. None. Tests compare event counts, total supply, and balances before/after reads. Explicit no-auth/no-mutation design; callable while paused and before init.
AC 5: Tests cover default and configured states. Added test cases for default and fully configured deployment states. No storage changes beyond normal test setup. No events from read helpers; tests assert this. src/test.rs: test_read_helpers_default_state_and_never_mutate, test_read_helpers_configured_state_and_pause_visibility. Tests include pre-initialize reads with no auth mocked.
AC 6: Documentation explains client usage. Added full usage guide and updated contract spec / README links. N/A. N/A. N/A. Docs state helpers are diagnostics and not authorization bypasses.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore (refactoring, build tools, etc.)

PR Evidence Checklist

1. Issue Reference

  • The PR description links to the issue being addressed.
    Note: issue number was not provided, so this PR references the configuration visibility issue by description.

2. Implementation Summary

  • A concise summary of what was implemented, changed, or fixed is provided above in the Description section.
  • Key files modified are listed with brief descriptions of each change.
  • New public functions, events, error codes, or roles are documented.
    New public functions are documented. No new events, error codes, or roles were added.

3. Tests Added or Justification

  • New or updated tests cover the change.
  • Test names and locations are listed:
    • src/test.rs — test_read_helpers_default_state_and_never_mutate
    • src/test.rs — test_read_helpers_configured_state_and_pause_visibility
  • OR a No-Test Justification is provided and explicitly approved.

4. Commands Run

  • make verify passes locally.
  • Equivalent validation commands were run locally; output is included in Additional Context.

5. CI Status

  • All GitHub Actions checks pass on the PR branch.
  • CI status not available in this local workspace. To be verified after opening the PR.

6. Acceptance Criteria Coverage

  • Every acceptance criterion from the issue is addressed in the Completion Table above.
  • Documentation impact is recorded for every criterion.
  • Incomplete criteria include a rationale and follow-up plan.
    No incomplete criteria.

7. Storage Compatibility

  • I completed the storage-change reviewer checklist.
  • I documented the compatibility classification and migration plan, and added tests that start from the previous stored layout.
  • This PR does not change persisted keys, value models, defaults, or storage classes.
    The new helpers only read existing storage keys. STORAGE_VERSION is a compile-time constant and is not persisted.

Policy & Standards

  • I have read the Contributor Evaluation Policy and understand that merge does not guarantee payment.
  • I have read the CONTRIBUTING.md guidelines.
  • My code follows the Rust and Soroban formatting standards (cargo fmt was run).
  • My changes generate no new warnings (cargo clippy was not run in this workspace).
  • I have added/updated tests for the new logic, and all tests pass (cargo test was run).
  • Traceability Mapping: I have filled out the detailed mapping table.
  • Reviewer Guidance: I have reviewed my own changes against the Reviewer Checklist.
  • Compliance & Legal Check: I verified that the new documentation/features do not imply regulatory completeness beyond smart contract enforcement.

Additional Context

Commands run

cargo fmt
CARGO_BUILD_JOBS=1 cargo test -q -j 1

Result:

running 223 tests
223 passed; 0 failed

running 5 tests
5 passed; 0 failed

running 10 tests
10 passed; 0 failed

test result: ok
CARGO_BUILD_JOBS=1 cargo build -q -j 1

Result:

build passed

Notes

cargo test and cargo build pass. The build currently emits pre-existing warnings unrelated to this PR, including:

  • unreachable pattern warning in src/asset.rs
  • unused test import / variables in existing test code
  • unused host_error helper in tests/sdk_fixtures.rs

No new persisted storage keys, events, error codes, or roles were introduced.

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.

Add contract configuration read API

1 participant