Skip to content

feat(contracts): implement nester protocol orchestrator contract#279

Merged
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
Salmatcre8:feature/issue-234-nester-orchestrator-contract
Apr 23, 2026
Merged

feat(contracts): implement nester protocol orchestrator contract#279
0xDeon merged 1 commit intoSuncrest-Labs:mainfrom
Salmatcre8:feature/issue-234-nester-orchestrator-contract

Conversation

@Salmatcre8
Copy link
Copy Markdown
Contributor

@Salmatcre8 Salmatcre8 commented Apr 23, 2026

Closes #234

Summary

  • contracts/nester/src/lib.rs — implements NesterContract with #[contract] / #[contractimpl], replacing the previously empty file
  • contracts/nester/src/test.rs — 15 unit tests (all green via cargo test -p nester-contract)
  • contracts/nester/Cargo.toml — renamed from nester-snapshotsnester-contract, added cdylib/rlib crate types and proper dependencies
  • scripts/deploy-testnet.sh — extended to build, optimize, deploy, and initialize yield_registry, allocation_strategy, and nester (in dependency order)

What the contract does

Entry point Access Description
initialize admin (once) Stores addresses of all 7 protocol contracts, sets version=1
upgrade Admin Swaps WASM via update_current_contract_wasm; increments version counter
update_contract Admin Updates a single contract reference (typed ContractKind enum)
vault_usdc / vault_xlm / … Public Address getters; panic with NotInitialized before initialize
version Public Returns 0 before init, 1 after, +1 per upgrade
grant_role / revoke_role / transfer_admin / accept_admin / has_role Admin Delegated to nester_access_control

Upgrade path (addresses accidental-deployment risk)

upgrade(admin, new_wasm_hash) calls env.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 pass
  • initialize stores all 7 addresses and sets version=1
  • Double-initialize panics AlreadyInitialized
  • Getters panic NotInitialized before initialize
  • update_contract covers all 7 ContractKind variants
  • Non-admin calls to mutating functions panic Unauthorized
  • Two-step admin transfer transfers and revokes cleanly

…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 Salmatcre8 requested a review from 0xDeon as a code owner April 23, 2026 13:41
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@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! 🚀

Learn more about application limits

Copy link
Copy Markdown
Contributor

@0xDeon 0xDeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@0xDeon 0xDeon merged commit fd53cb3 into Suncrest-Labs:main Apr 23, 2026
6 checks passed
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.

[Smart Contract] Main nester orchestrator contract is completely empty — no entry points, no logic

2 participants