Skip to content

feat: document store ownership#20

Merged
rongquan1 merged 4 commits intomainfrom
feat/document-store-ownership
Feb 26, 2026
Merged

feat: document store ownership#20
rongquan1 merged 4 commits intomainfrom
feat/document-store-ownership

Conversation

@RishabhS7
Copy link
Copy Markdown
Contributor

@RishabhS7 RishabhS7 commented Feb 26, 2026

Document Store Ownership Management Commands

Summary

Implemented comprehensive role-based access control and ownership management commands for document store contracts, enabling granular permission management across blockchain networks.

Features

Role Management

  • Grant Role - Assign ISSUER_ROLE, REVOKER_ROLE, or DEFAULT_ADMIN_ROLE to accounts
  • Revoke Role - Remove roles from accounts
  • Transfer Ownership - Seamlessly transfer admin rights to new owner

Capabilities

  • ✅ Interactive prompts for document file or manual address input
  • ✅ Support for all three role types (ISSUER, REVOKER, ADMIN)
  • ✅ Dry-run functionality with gas estimation
  • ✅ Transaction confirmation and explorer link display
  • ✅ Comprehensive error handling
  • ✅ Multi-network support (Ethereum, Polygon, XDC, Stability, Astron)

Test Coverage

All tests passing ✅ (58 tests total for document-store)

Usage Examples

# Grant issuer role to an account
trustvc document-store grant-role

# Revoke revoker role from an account
trustvc document-store revoke-role

# Transfer ownership to a new admin
trustvc document-store transfer-ownership

Summary by CodeRabbit

Release Notes

  • New Features

    • Added three new document-store commands: grant-role for assigning roles, revoke-role for removing roles, and transfer-ownership for transferring ownership to new accounts
  • Documentation

    • Updated documentation to reflect new document-store role management and ownership transfer commands
  • Tests

    • Added test coverage for new role management and ownership transfer commands

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 26, 2026

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between e5a05ab and 7c0acca.

📒 Files selected for processing (1)
  • tests/commands/document-store/deploy.test.ts
💤 Files with no reviewable changes (1)
  • tests/commands/document-store/deploy.test.ts

📝 Walkthrough

Walkthrough

This change introduces three new CLI commands for managing document store roles and ownership: grant-role, revoke-role, and transfer-ownership. Each command handles user input prompting, wallet resolution, gas estimation, and blockchain transaction execution with comprehensive error handling. Supporting test files are added for the new commands, and existing test mocks are updated to align with new module structures.

Changes

Cohort / File(s) Summary
New Document Store Role Management Commands
src/commands/document-store/grant-role.ts, src/commands/document-store/revoke-role.ts, src/commands/document-store/transfer-ownership.ts
Three new CLI command modules for role and ownership management. Each exports a command constant, description, handler function, input prompter, and core execution function. All handle wallet selection (encrypted wallet, keyFile, or direct key), role/address validation, dry-run confirmation, gas estimation (EIP-1559 where supported), transaction execution, and result logging with etherscan links.
Test Suite for New Commands
tests/commands/document-store/grant-role.test.ts, tests/commands/document-store/revoke-role.test.ts, tests/commands/document-store/transfer-ownership.test.ts
Comprehensive unit tests for the three new command modules. Tests cover promptForInputs across multiple role/wallet combinations, successful and error execution paths, dry-run handling, and handler error propagation. Extensive mocking of inquirer, wallet utilities, trustvc, and transaction workflows.
Existing Issue Command Update
src/commands/document-store/issue.ts
Minor reordering: transaction receipt wait moved after logging statement for operational clarity; no functional change.
Test Fixture Updates for Existing Commands
tests/commands/document-store/issue.test.ts, tests/commands/document-store/revoke.test.ts, tests/commands/document-store/deploy.test.ts
Updates to mock structures and type imports. TransactionReceipt type import switched from @ethersproject/providers to ethers. Mock transaction objects refactored to use hash field instead of transactionHash; CHAIN_ID and SUPPORTED_CHAINS mocks simplified by removing non-mainnet entries. DocumentStore__factory.connect added to trustvc mocks.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI
    participant Wallet
    participant Contract as Document Store Contract
    participant Blockchain

    User->>CLI: Initiate command (grant/revoke role or transfer ownership)
    CLI->>CLI: Prompt for document info, network, role/owner details
    CLI->>CLI: Prompt for wallet (encrypted path, keyFile, or key)
    CLI->>Wallet: Resolve and unlock wallet
    
    CLI->>CLI: Compute role hash (keccak256)
    CLI->>Contract: populateTransaction (dry-run via callStatic)
    
    alt Dry-run succeeds and user confirms
        CLI->>CLI: Check if network supports EIP-1559
        alt EIP-1559 supported
            CLI->>CLI: Fetch gas fees (maxFeePerGas, maxPriorityFeePerGas)
        end
        
        CLI->>Contract: Execute transaction (grant/revoke/transfer)
        Contract->>Blockchain: Send signed transaction
        Blockchain-->>CLI: Transaction hash
        
        CLI->>Blockchain: Wait for transaction receipt
        Blockchain-->>CLI: Receipt with confirmations
        
        CLI->>User: Display success, price, etherscan link
    else Dry-run fails or user declines
        CLI->>User: Log error or cancellation
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Three new commands hop into the warren,
Granting roles and shifting ownership with care,
Wallets unlocked, gas fees wisely shared,
Document stores dance on the blockchain fair!


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

@rongquan1 rongquan1 merged commit a3906da into main Feb 26, 2026
5 checks passed
@rongquan1 rongquan1 deleted the feat/document-store-ownership branch February 26, 2026 06:38
tradetrustimda pushed a commit that referenced this pull request Mar 10, 2026
# 1.0.0 (2026-03-10)

### Bug Fixes

* add tamper check for all blockchain functions ([#21](#21)) ([ea64760](ea64760))
* base64 file format removal ([514f18b](514f18b))
* ether signer compatibility ([a3c36de](a3c36de))
* handle network selection and add new fixtures ([#15](#15)) ([62b2031](62b2031))
* one line command and interactive terminal fix ([23fb955](23fb955))
* package lock ([2e40722](2e40722))
* remove test output files ([f63a4b3](f63a4b3))
* remove the base64 encoding for the file encryption ([#23](#23)) ([d4600e4](d4600e4))
* remove unnecessary details in the readme ([6a9b8a2](6a9b8a2))
* update cli process ([#8](#8)) ([472a9e6](472a9e6))
* updated the file handling error and folder creation for outputs ([a07c6a3](a07c6a3))
* wallet creation ([#14](#14)) ([6499276](6499276))

### Features

* add mint function command ([#1](#1)) ([22ea11f](22ea11f))
* add verify command ([#7](#7)) ([da85177](da85177))
* add w3c sign function ([#4](#4)) ([ea31015](ea31015))
* added encrypt/decrypt functions to the OA feature ([6dab3e7](6dab3e7))
* added functionality for transaction cancel ([33d73f2](33d73f2))
* added husky for lint checks ([70f3ea5](70f3ea5))
* added the gracefull error handling ([27ef0cf](27ef0cf))
* credential status command ([fb83698](fb83698))
* deploy document store command ([#16](#16)) ([bee4e7a](bee4e7a))
* document store ownership ([#20](#20)) ([a3906da](a3906da))
* fixed the prettier formats ([661c27e](661c27e))
* issue and revoke command ([#17](#17)) ([1df37ff](1df37ff))
* oa sign command ([6fc14cb](6fc14cb))
* reject commands ([#5](#5)) ([f50ce1b](f50ce1b))
* remove example files ([eecf1fb](eecf1fb))
* return commands ([#6](#6)) ([d999e6c](d999e6c))
* token registry command ([#19](#19)) ([0f5c523](0f5c523))
* transfer commands ([#3](#3)) ([8414130](8414130))
* update command process and tests ([#12](#12)) ([97986f5](97986f5))
* update the transfer commands with new input process ([#10](#10)) ([603e534](603e534))
* updated package version for trustvc ([995b43f](995b43f))
* updated packages ([7f9712c](7f9712c))
* updated the readme ([8fa493a](8fa493a))
* wallet creation encryption ([#13](#13)) ([e4d368c](e4d368c))
* wrap unwrap oa command ([#9](#9)) ([4ca75f0](4ca75f0))
@tradetrustimda
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants