This implementation addresses Issue #16: [Admin] Update Admin Key, providing a secure two-step ownership transfer mechanism for the Vesting Vault contract.
- Added
ADMIN_ADDRESSstorage key to track current admin - Added
PROPOSED_ADMINstorage key for two-step transfer process - Updated
initialize()function to store initial admin address
- Access Control: Only current admin can propose new admin
- Functionality: Stores the proposed admin address in contract storage
- Security: Prevents accidental lockout by requiring explicit proposal
- Access Control: Only the proposed admin can accept ownership
- Functionality: Transfers admin rights to proposed admin
- Cleanup: Removes proposed admin from storage after successful transfer
require_admin(): Internal function to validate admin accessget_admin(): Returns current admin addressget_proposed_admin(): Returns proposed admin (if any)
Added admin access control to all privileged functions:
create_vault_full()create_vault_lazy()batch_create_vaults_lazy()batch_create_vaults_full()
Created tests covering:
- Complete ownership transfer flow
- Unauthorized access prevention
- Admin access control on all functions
- Batch operations with admin validation
- Two-step process ensures both current and new admin must participate
- Current admin proposes, new admin accepts
- No single point of failure
- All privileged operations require admin authentication
- Unauthorized users cannot access admin functions
- Clear error messages for unauthorized access attempts
- Clean state transitions between admin changes
- Proper cleanup of proposed admin after transfer
- Immutable audit trail of admin changes
// Initialize contract with admin
contract.initialize(&admin_address, &initial_supply);
// Step 1: Current admin proposes new admin
contract.propose_new_admin(&new_admin_address);
// Step 2: New admin accepts ownership
contract.accept_ownership();
// Verify transfer
assert_eq!(contract.get_admin(), new_admin_address);✅ transfer_ownership(new_admin): Implemented via two-step process
✅ Two-step process: propose_new_admin -> accept_ownership prevents accidental lockout
✅ Security: Proper access controls and validation throughout
-
contracts/vesting_contracts/src/lib.rs:- Added admin storage keys
- Implemented admin management functions
- Added access control to privileged functions
-
contracts/vesting_contracts/src/test.rs:- Comprehensive test suite for admin functionality
- Security validation tests
- Access control verification
The implementation includes comprehensive tests that verify:
- Proper admin initialization
- Two-step ownership transfer flow
- Unauthorized access prevention
- Admin access control on all functions
- Batch operations security
Run tests with: cargo test (requires Rust/Soroban toolchain)
- Contract must be re-deployed with new admin functionality
- Existing deployments will need migration
- Admin address is set during contract initialization
- All subsequent admin operations follow the two-step process
- Admin address should be a multisig wallet for DAO governance
- Consider implementing time delays for admin changes (future enhancement)
- Monitor admin change events for governance transparency
- Ensure proper key management for admin addresses