Skip to content

feat(vault): add close_vault so an owner can remove a vault entry #8

Description

@0dillon

Summary

open creates a vault and withdraw takes funds out, but nothing removes the entry
(contracts/rent_vault/src/lib.rs). An owner who is finished with a target can drain the balance to
zero and still leaves a DataKey::Vault entry behind, which they keep paying rent on and which
open will refuse to replace.

Acceptance Criteria

  • close_vault(env, target) exists, authorized by the vault owner.
  • It refuses to close a vault with a non-zero balance, with its own error code in the 2xx
    range, so funds cannot be stranded.
  • It removes the persistent entry rather than zeroing it.
  • After closing, get_vault returns None and open succeeds for the same target.
  • A #[contractevent] is emitted.
  • Tests cover the happy path, the non-zero-balance rejection, and a close attempted by someone
    who is not the owner.

Tech Stack

Rust (edition 2021, toolchain 1.93.0 pinned in rust-toolchain.toml), soroban-sdk 27.0.4,
target wasm32v1-none. Build with stellar contract build, never cargo build. Tests are
#[cfg(test)] modules on Env::default(); run them with cargo test --all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: rent_vaultcontracts/rent_vaultcomplexity: mediumHalf a day, some design judgement neededtype: featureAdds behaviour that does not exist yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions