feat(contracts): implement nester protocol orchestrator contract#279
Merged
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom Apr 23, 2026
Conversation
…crest-Labs#234) packages/contracts/contracts/nester/ — was an empty crate with no #[contract] attribute, no entry points, and no storage definitions. Deploying it in that state would have produced a zero-function WASM and silently broken every integration that calls into it. What's added: lib.rs - NesterContract with initialize, upgrade, update_contract, and full set of address getters (vault_usdc, vault_xlm, vault_token_usdc, vault_token_xlm, treasury, yield_registry, allocation_strategy) - upgrade() calls env.deployer().update_current_contract_wasm() so the protocol can migrate to a new WASM without losing the contract ID; version counter is incremented on every successful upgrade - ContractKind enum allows atomic single-reference updates via update_contract() without touching the rest of the registry - Delegates RBAC to nester_access_control (Admin role required for all mutating calls); two-step admin transfer forwarded unchanged - All events use the existing (contract, action, entity) 3-topic structure from nester_common::emit_event test.rs — 15 unit tests covering: initialize: all addresses stored, version=1, admin role granted, double-init panics getters: panic before initialization (NotInitialized guard) update_contract: happy path, isolation across kinds, full enum coverage, non-admin rejection access control: grant/revoke, has_role negative case, two-step admin transfer Cargo.toml — renamed crate to nester-contract, added crate-type ["cdylib","rlib"], added soroban-sdk/nester-common/nester-access-control dependencies deploy-testnet.sh — adds build, optimize, deploy, and initialize steps for yield_registry, allocation_strategy, and nester (in correct dependency order); extends output .env file with the new contract IDs
|
@Salmatcre8 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! 🚀 |
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.
Closes #234
Summary
contracts/nester/src/lib.rs— implementsNesterContractwith#[contract]/#[contractimpl], replacing the previously empty filecontracts/nester/src/test.rs— 15 unit tests (all green viacargo test -p nester-contract)contracts/nester/Cargo.toml— renamed fromnester-snapshots→nester-contract, addedcdylib/rlibcrate types and proper dependenciesscripts/deploy-testnet.sh— extended to build, optimize, deploy, and initializeyield_registry,allocation_strategy, andnester(in dependency order)What the contract does
initializeupgradeupdate_current_contract_wasm; increments version counterupdate_contractContractKindenum)vault_usdc / vault_xlm / …NotInitializedbeforeinitializeversiongrant_role / revoke_role / transfer_admin / accept_admin / has_rolenester_access_controlUpgrade path (addresses accidental-deployment risk)
upgrade(admin, new_wasm_hash)callsenv.deployer().update_current_contract_wasm()so the protocol can fix bugs or add features without losing the deployed contract ID. The version counter and event are written before the WASM swap.Test plan
cargo check -p nester-contract— clean build (no pre-compiled WASM needed)cargo test -p nester-contract— 15/15 tests passAlreadyInitializedNotInitializedbeforeinitializeupdate_contractcovers all 7ContractKindvariantsUnauthorized