Skip to content

feat(#748): add RBAC storage migration scripts and tests - #861

Open
VeronicDev wants to merge 3 commits into
BCPathway:mainfrom
VeronicDev:feature/rbac-storage-migration-748
Open

feat(#748): add RBAC storage migration scripts and tests#861
VeronicDev wants to merge 3 commits into
BCPathway:mainfrom
VeronicDev:feature/rbac-storage-migration-748

Conversation

@VeronicDev

@VeronicDev VeronicDev commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Resolves #748 — Implements storage migration scripts for RBAC to ensure seamless transition from legacy Admin state to the new RBAC format.

Changes

Contract Tests (Rust)

  • Added 5 new integration tests in contracts/admin/tests/upgrade_e2e.rs:
    • test_migrate_admin_preserves_original_admin_entry — Verifies original admin entry unchanged after migration
    • test_migrate_admin_enables_super_admin_guard — Confirms SuperAdmin guard is enabled post-migration
    • test_migrate_admin_allows_role_delegation — Tests role granting works after migration
    • test_migrate_admin_uninitialized_contract_is_noop — Ensures migration is safe on uninitialized contracts
    • test_full_lifecycle_init_migrate_rbac_enforcement — Full init → migrate → RBAC enforcement flow
  • Enhanced existing tests with additional assertions for admin preservation and role delegation

TypeScript SDK

  • Added migrateAdmin() method to sdk/src/client.ts
  • Added tests for migrateAdmin, grantMinter, revokeMinter in sdk/src/client.test.ts

Standalone Migration Script

  • Created migrations/rbac-migration.ts with:
    • migrateContract() — Full migration with verification
    • dryRunMigration() — Simulate without submitting
    • CLI interface: --rpc-url, --network-passphrase, --contract-id, --admin-secret, --dry-run

Documentation

  • Updated docs/UPGRADE_GUIDE.md with migration instructions for CLI, SDK, and standalone script

Storage Migration Process

  1. Reads current admin from AdminKey::Admin (instance storage)
  2. Creates AdminKey::SuperAdmin(admin) persistent entry
  3. Extends TTL of the new storage entry
  4. Original admin entry remains unchanged

The migration is idempotent — safe to call multiple times.

Acceptance Criteria

  • ✅ Code compiles and adheres to Soroban/Rust/TypeScript best practices
  • ✅ Unit tests cover both happy paths and expected error states
  • ✅ All CI/CD pipelines pass (TypeScript compilation and tests verified locally)

closes #748

Add standalone migration script, SDK method, and comprehensive tests for
migrating legacy Admin contracts to the new RBAC format with SuperAdmin
role mapping. The migration is idempotent and maps the singular admin
address to the SuperAdmin persistent storage entry.

- Add `migrateAdmin()` to TypeScript SDK client
- Create `migrations/rbac-migration.ts` with CLI and library interfaces
- Add 5 new Rust integration tests for migration happy paths and edge cases
- Update UPGRADE_GUIDE.md with migration script usage (CLI, SDK, standalone)
- Add TypeScript tests for migrateAdmin, grantMinter, revokeMinter

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

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

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.

[Storage] Write storage migration scripts for RBAC

1 participant