Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Core single-issue bounty escrow.

```rust
fn initialize(env, admin: Address, treasury: Address, fee_bps: u32) -> Result<(), Error>;
fn fund(env, issue_id: u64, sponsor: Address, token: Address, amount: i128, deadline: u64) -> Result<(), Error>;
fn fund(env, issue_id: u64, sponsor: Address, token: Address, amount: i128, deadline: u64, target: Option<i128>) -> Result<(), Error>;
fn contribute(env, issue_id: u64, sponsor: Address, amount: i128) -> Result<(), Error>;
fn release(env, issue_id: u64, recipients: Vec<(Address, u32)>) -> Result<(), Error>;
fn refund(env, issue_id: u64) -> Result<(), Error>;
Expand All @@ -159,10 +159,12 @@ fn get_fee_bps(env) -> Result<u32, Error>;
```

- `fund`: `sponsor.require_auth()`. Transfers `amount` of `token` from the
sponsor into the contract and *creates* the escrow. One escrow per
`issue_id` — a second `fund` call on the same id is rejected
(`AlreadyFunded`); every sponsor after the first uses `contribute`
instead.
sponsor into the contract and *creates* the escrow. `target` is an
optional funding goal stored on the escrow and read-only thereafter —
informational only, so it does not block `contribute` past it and does not
change `release`/`refund` behavior. One escrow per `issue_id` — a second
`fund` call on the same id is rejected (`AlreadyFunded`); every sponsor
after the first uses `contribute` instead.
- `contribute`: `sponsor.require_auth()`. Adds an additional sponsor's
funds to an already-`fund`ed escrow — this is how crowdfunding a single
`issue_id` across several sponsors works. Uses the token already
Expand Down
13 changes: 9 additions & 4 deletions contracts/escrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ impl EscrowContract {
/// Sponsor deposits `amount` of `token` into escrow for `issue_id`,
/// creating it. Requires the sponsor's authorization. `deadline` is a
/// unix timestamp (ledger time) after which, if unpaid, contributors
/// may reclaim their funds. One escrow per `issue_id` — a second `fund`
/// call on the same id is rejected (`AlreadyFunded`); every sponsor
/// after the first uses `contribute` instead. See
/// `docs/escrow-crowdfunding-design.md` for why creation and
/// may reclaim their funds. `target` is an optional funding goal that is
/// stored verbatim and never mutated afterward — it is informational
/// only, so it does not block `contribute` from pushing `amount` past it
/// and does not change `release`/`refund` behavior. One escrow per
/// `issue_id` — a second `fund` call on the same id is rejected
/// (`AlreadyFunded`); every sponsor after the first uses `contribute`
/// instead. See `docs/escrow-crowdfunding-design.md` for why creation and
/// contribution are kept as two separate entrypoints.
///
/// Note: this contract has no visibility into `mergefi-milestones` —
Expand All @@ -90,6 +93,7 @@ impl EscrowContract {
token: Address,
amount: i128,
deadline: u64,
target: Option<i128>,
) -> Result<(), Error> {
sponsor.require_auth();

Expand All @@ -114,6 +118,7 @@ impl EscrowContract {
let escrow = Escrow {
token,
amount,
target,
status: EscrowStatus::Funded,
created_at: env.ledger().timestamp(),
deadline,
Expand Down
Loading