Skip to content

refactor: split contracts crate into separate packages #44

@snowrugar-beep

Description

@snowrugar-beep

Problem Statement

All contracts (GistRegistry, BatchWallet, MultiSig, Governance) live in a single Rust crate. This couples their versioning, compilation, testing, and deployment lifecycles. Independent contract upgrades are impossible without affecting other contracts.

Evidence

  • contracts/Cargo.toml — Single crate with all code
  • contracts/src/lib.rs — GistRegistry
  • contracts/src/multi.rs — MultiSig + Governance code
  • contracts/src/ops.rs, rollback.rs — BatchWallet tests

Impact

Monolithic crate couples unrelated contract lifecycles. Versioning is tied together. Testing one contract requires compiling all contracts.

Proposed Solution

  1. Create directory structure: contracts/gist-registry/, contracts/multisig/, contracts/governance/, contracts/batch-wallet/
  2. Each gets its own Cargo.toml, src/lib.rs
  3. Move relevant code to each package
  4. Create workspace Cargo.toml at contracts/ root
  5. Update CI/CD deployment pipeline to target specific contracts

Technical Requirements

  • Each contract must compile independently to WASM
  • Each contract must have its own test suite
  • Workspace must support shared dev-dependencies
  • CI must build and test each contract independently

Acceptance Criteria

  1. contracts/ is a Cargo workspace
  2. Each contract builds independently: cargo build -p gist-registry --target wasm32-unknown-unknown --release
  3. Each contract's tests pass independently
  4. Workspace build builds all contracts
  5. CI pipeline updated to build/test/deploy individual contracts
  6. WASM binary sizes are not regressed

File Inventory

  • contracts/Cargo.toml
  • contracts/src/lib.rs
  • contracts/src/multi.rs
  • contracts/src/vault.rs
  • contracts/src/ops.rs
  • contracts/src/rollback.rs
  • infrastructure/ci/contract-deployment.yml

Dependencies

Issue #1 (deduplicate contracts) must be completed first.

Testing Strategy

  • Build and test each contract independently
  • Verify workspace build produces same total output

Security Considerations

Independent contracts reduce blast radius of a vulnerability in one contract.

Definition of Done

  • Contracts split into workspace packages
  • Independent builds working
  • All tests passing
  • CI updated

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions