Skip to content

feat: Implement bounty creation, claim, deadline support + tests (#1, #2, #3, #5)#7

Closed
aglichandrap wants to merge 1 commit into
issueflow-buidl:mainfrom
aglichandrap:feat/bounty-full-implementation
Closed

feat: Implement bounty creation, claim, deadline support + tests (#1, #2, #3, #5)#7
aglichandrap wants to merge 1 commit into
issueflow-buidl:mainfrom
aglichandrap:feat/bounty-full-implementation

Conversation

@aglichandrap

Copy link
Copy Markdown

Summary

This PR implements the complete bounty lifecycle for the Soroban contract, addressing issues #1, #2, #3, and #5.

Changes

**** — Full contract implementation:

**** (Closes #5) — 25+ comprehensive tests:

  • create_bounty: success, auto-increment IDs, zero/negative amount, past deadline, equal deadline, edge cases
  • claim_bounty: success, wrong claimer, already claimed, nonexistent bounty
  • cancel_bounty: success after deadline, before deadline, exactly at deadline, wrong account, already claimed, already cancelled
  • tip: backward compatibility preserved
  • get_bounty: nonexistent, state reflection
  • Full lifecycle: create→claim and create→cancel flows
  • Multi-bounty with different deadlines

**** — Matching Solidity implementation with ERC-20 escrow pattern.

Design Decisions

  • Deadline uses strict comparison (must be in the future at creation time)
  • Cancel uses comparison (can cancel exactly at deadline)
  • Only the bounty creator can claim or cancel (simplified from potential governance model)
  • Auto-incrementing bounty IDs stored in instance storage
  • Bounty records stored in persistent storage for durability

… + comprehensive tests

Implements issueflow-buidl#1: create_bounty function that locks USDC in the contract
Implements issueflow-buidl#2: claim_bounty (releases USDC to solver) and cancel_bounty
Implements issueflow-buidl#3: deadline support with strict validation
Implements issueflow-buidl#5: comprehensive test suite covering all functions, edge cases, error scenarios

Contract changes (lib.rs):
- Added Bounty struct with creator, token, amount, deadline, state fields
- Added BountyState enum (Open, Claimed, Cancelled)
- create_bounty: locks funds from creator, validates amount/deadline
- claim_bounty: creator authorizes release to solver
- cancel_bounty: creator reclaims after deadline expiry
- get_bounty: read-only query
- Events for all state transitions
- Preserved tip() for backward compatibility

Test coverage (test.rs):
- 25+ tests covering create, claim, cancel, tip, get_bounty
- Edge cases: zero/negative amounts, past deadlines, double-claim/cancel
- Full lifecycle tests: create→claim and create→cancel flows
- Multi-bounty tests with different deadlines
- Authorization failure scenarios

Also updated Bounty.sol with matching Solidity implementation.
@aglichandrap

Copy link
Copy Markdown
Author

Closing — cleaning up PR portfolio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant