Skip to content

Repair src/lib.rs so the crate compiles — deduplicate the two #[contractimpl] blocks and conflicting StreamInfo definitions #134

Description

@greatest0fallt1me

Description

streampay-contracts does not build today. cargo build fails with error: this file contains an unclosed delimiter --> src/lib.rs:1459:3, pointing back to the impl StreamPayContract { opened at src/lib.rs:96 that is never closed. The file is a corrupted merge of several contract versions: it contains two #[contract] attributes (src/lib.rs:92 and src/lib.rs:225), two #[contractimpl] blocks (src/lib.rs:95 and src/lib.rs:228), three separate use soroban_sdk::{...} statements (src/lib.rs:44, :75, :178), a stray literal #### line at src/lib.rs:139, and module-level doc comments (//! ...) interleaved after code. This issue restores a single, coherent, compiling contract module.

Requirements and context

Functional

  • Collapse the file down to exactly one #[contract] pub struct StreamPayContract; and one #[contractimpl] impl StreamPayContract { ... } block with a single closing brace.
  • Remove the stray #### token at src/lib.rs:139 and the duplicate/partial first create_stream body (src/lib.rs:100138).
  • Consolidate the three use soroban_sdk::{...} lines (src/lib.rs:44, :75, :178) into one import set that names only the symbols actually used by the retained implementation.
  • Move all crate-level //! doc comments to the top of the file (a //! doc comment is only valid before any item) and keep them as inner docs.
  • Resolve which StreamInfo is authoritative: src/lib.rs:207 defines one shape (token, claimable_balance, no memo/paused_at), src/stream.rs:28 defines a different shape, and src/lib.rs:76 imports StreamInfo from crate::stream. Pick one canonical definition (coordinate with the StreamInfo-consolidation issue) and delete the duplicate so the type resolves unambiguously.

Non-functional / repo conventions

  • After the fix, cargo build, cargo fmt --all -- --check, and cargo clippy --all-targets --all-features -- -D warnings must all pass (clippy is enforced by .github/workflows/contracts.yml).
  • Do not silently drop public entry points that other docs promise (create_stream, start_stream, stop_stream, settle_stream, batch_settle, withdraw_stream, archive_stream, get_stream_info, version); if a referenced helper such as emit_stream_created or settle_stream_amount is still undefined, gate or stub it behind a follow-up issue rather than leaving an unresolved symbol.
  • Keep the release WASM within the budget verified by scripts/check-wasm-size.sh.

Acceptance criteria

  • cargo build succeeds with no errors and no warnings about unused imports.
  • Exactly one #[contract] and one #[contractimpl] block remain in src/lib.rs.
  • The #### line and all duplicate create_stream / StreamInfo / use fragments are removed.
  • StreamInfo resolves to a single definition (no “defined multiple times” or ambiguous-import error).
  • cargo fmt --all -- --check and cargo clippy --all-targets --all-features -- -D warnings pass.
  • cargo test compiles and the previously-green tests run (vesting/event tests may be deferred to their dedicated issues).

Suggested execution

1. Fork the repo and create a branchgit checkout -b feature/fix-lib-compilation.

2. Implement changes — edit src/lib.rs: hoist the //! docs to the top, delete the partial first impl block (:95:139), keep the second #[contractimpl] block, dedup the use lines, and align the StreamInfo type with src/stream.rs.

3. Write/extend tests — keep the inline #[cfg(test)] mod test in src/lib.rs; fix the duplicated create_stream call lines in tests (e.g. src/lib.rs:662663, :781:782) so each test calls the entry point exactly once with the canonical signature.

4. Test and commit

cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
cargo build
cargo test --features testutils
./scripts/check-wasm-size.sh

Example commit message

fix(contract): repair src/lib.rs corrupted merge so the crate compiles

Guidelines

  • Target 95% line coverage for changed logic (docs/coverage.sh, CONTRIBUTING.md §“Coverage guideline”).
  • Update /// doc-comments on every entry point you touch and reconcile docs/accrual-spec.md, docs/events.md, and docs/error-codes.md if the canonical surface shifts.
  • Timeframe: 96 hours.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    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