Protocal initalization - #128
Merged
Merged
Conversation
Contributor
Author
|
@Nabeelahh pr sent please review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a summary of all changes made to address issue closes #127 :
Changes Summary
Shared Module (shared/src/)
errors.rs: Removed 3 unused error variants (InvalidAsset, ZeroShares, InvalidReserveFactor) to stay within Soroban's 50-variant #[contracterror] limit. Added 3 new governance error variants: AdminTransferPending, NoAdminTransferPending, CannotTransferToSelf.
events.rs: Added 3 new governance event types with topic methods: ContractInitialized, AdminTransferPending, AdminTransferred. Also added a topic method for the existing RewardsPoolFunded event.
Vault Contract (vault/src/)
state.rs: Added PendingAdmin variant to VaultKey enum.
lib.rs:
initialize() now requires an admin parameter and calls admin.require_auth(). Returns Result<(), Error> instead of panicking.
Added get_admin(), transfer_admin(), accept_admin() for two-step admin rotation.
Added ContractInitialized event emission on init.
Lending Contract (lending/src/lib.rs)
Added ContractAdmin and PendingAdmin variants to PoolKey enum.
Added initialize() function (one-time, requires admin auth).
Added get_contract_admin(), transfer_admin(), accept_admin() for two-step admin rotation.
create_pool() now requires contract admin authorization.
grant_admin() now requires contract admin authorization.
set_rate_limit() now requires contract admin authorization.
Borrowing Contract (borrowing/src/lib.rs)
Added ContractAdmin and PendingAdmin variants to BorrowingKey enum.
initialize() now requires an admin parameter and calls admin.require_auth().
Added get_contract_admin(), transfer_admin(), accept_admin() for two-step admin rotation.
configure_collateral() now requires contract admin authorization.
Rewards Contract (rewards/src/lib.rs)
Added PendingAdmin variant to RewardsKey enum.
initialize() now returns Result<(), Error>, requires admin.require_auth(), and emits ContractInitialized.
initialize_rewards() now returns Result<(), Error>, requires admin.require_auth(), prevents double-init, and emits ContractInitialized.
grant_admin() now requires current admin authorization.
fund_rewards_pool() now requires admin authorization via pool.admin.require_auth().
add_milestone() now requires admin authorization.
Added transfer_admin() and accept_admin() for two-step admin rotation.
Deployment Script (scripts/initialize.sh)
Requires ADMIN environment variable for all contracts.
Added per-contract admin variables (STREAKS_ADMIN, LENDING_ADMIN, etc.).
All initialization calls now pass --admin parameter.
Improved error messages and validation.
Post-initialization summary prints all admin addresses.
Tests
vault/tests/test_vault_governance.rs (new): 13 tests covering initialization, double-init prevention, admin auth for config, two-step admin transfer, unauthorized access prevention, and backward-compatible vault operations.
rewards/tests/test_rewards_governance.rs (new): 12 tests covering initialization, double-init prevention, admin auth for grant_admin/fund/add_milestone, two-step admin transfer, and full reward flow.
rewards/tests/test_rewards.rs (updated): Added mock_all_auths() to all tests to support new require_auth() calls.
vault/tests/progression_integration.rs (updated): Added mock_all_auths() and updated vault.initialize() call to include admin parameter.