Context
contracts/escrow/src/lib.rs has no upgrade mechanism. When the escrow logic needs to change (e.g., adding partial release), all existing escrows using the old contract address are frozen in the old version. Soroban supports env.deployer().update_current_contract_wasm() for in-place upgrades.
Technical Requirements
- Add
DataKey::Admin and an admin: Address parameter to initialize
- Add
pub fn upgrade(env: Env, admin: Address, new_wasm_hash: BytesN<32>) requiring admin.require_auth() and admin == stored_admin
- The upgrade should only be allowed when
Released == false (funds still locked) — otherwise there is nothing to migrate
- Add tests:
test_upgrade_by_admin_succeeds, test_upgrade_by_non_admin_panics, test_upgrade_after_release_panics
Definition of Done
upgrade function exists in lib.rs
DataKey::Admin is a new storage key
- ≥ 3 tests pass
Context
contracts/escrow/src/lib.rshas no upgrade mechanism. When the escrow logic needs to change (e.g., adding partial release), all existing escrows using the old contract address are frozen in the old version. Soroban supportsenv.deployer().update_current_contract_wasm()for in-place upgrades.Technical Requirements
DataKey::Adminand anadmin: Addressparameter toinitializepub fn upgrade(env: Env, admin: Address, new_wasm_hash: BytesN<32>)requiringadmin.require_auth()andadmin == stored_adminReleased == false(funds still locked) — otherwise there is nothing to migratetest_upgrade_by_admin_succeeds,test_upgrade_by_non_admin_panics,test_upgrade_after_release_panicsDefinition of Done
upgradefunction exists inlib.rsDataKey::Adminis a new storage key