Skip to content

Feature/multi party reveal#487

Open
dami-005 wants to merge 3 commits into
AtomicIP:mainfrom
dami-005:feature/multi-party-reveal
Open

Feature/multi party reveal#487
dami-005 wants to merge 3 commits into
AtomicIP:mainfrom
dami-005:feature/multi-party-reveal

Conversation

@dami-005
Copy link
Copy Markdown

closes #410

  • ContractError::NotAllSigned = 42 — reveal blocked until all signers have signed
  • ContractError::AlreadySigned = 43 — duplicate signature attempt
  • ContractError::NotARequiredSigner = 44 — outsider tries to sign
  • DataKey::SwapSigners(u64) — stores the Vec of required co-signers
  • DataKey::SwapSignatures(u64) — stores Vec of who has already signed
  • initiate_swap_with_signers(env, token, ip_id, seller, price, buyer, signers) — creates a swap with a required signer list; rejects empty lists
  • sign_swap_reveal(env, swap_id, signer) — any required signer calls this on an Accepted swap; rejects outsiders and duplicates
  • reveal_key — gated: if SwapSigners exists for the swap, checks SwapSignatures.len() >= SwapSigners.len() before proceeding

contracts/atomic_swap/src/multi_signer_tests.rs — 7 tests:

  1. Reveal blocked when only 1 of 2 signers has signed
  2. Reveal succeeds after all 2 signers sign
  3. Non-required signer cannot call sign_swap_reveal
  4. Duplicate signature from same signer is rejected
  5. 3-of-3 flow: blocked at 2, unblocked at 3
  6. sign_swap_reveal on a Pending swap is rejected (must be Accept

dami-005 added 3 commits May 27, 2026 10:44
- Add DataKey::UserReputation(Address) storing score 0-100
- Add DataKey::ReputationMultiplier(u64) for per-swap min buyer rep
- Implement get_reputation(env, address) -> u32 (default 50)
- Implement set_reputation_multiplier(env, swap_id, min_reputation)
- Update reputation on swap completion: +5 seller & buyer
- Update reputation on cancel_swap: -10 canceller
- Update reputation on cancel_expired_swap: -10 seller (defaulted)
- Enforce min reputation in accept_swap (InsufficientReputation error)
- Add ContractError::InsufficientReputation = 40
- Add reputation_tests.rs with 7 tests covering all behaviours
- Add arbitration_timeout_seconds to ProtocolConfig (default 14 days)
- Add DataKey::ArbitrationTimestamp(u64) to track request time
- Add ContractError::ArbitrationNotTimedOut = 41
- Update request_arbitration to record timestamp on first call
  (subsequent calls are no-ops for the timestamp — first wins)
- Add auto_refund_on_arbitration_timeout(env, swap_id): anyone can
  call after timeout elapses; refunds buyer and cancels swap
- Add arbitration_timeout_tests.rs with 7 tests covering:
  timestamp recording, early rejection, timeout success,
  no-request rejection, idempotency, third-party trigger,
  and timestamp immutability on second request
- Add DataKey::SwapSigners(u64) — required co-signer list
- Add DataKey::SwapSignatures(u64) — collected signatures
- Add ContractError::NotAllSigned = 42
- Add ContractError::AlreadySigned = 43
- Add ContractError::NotARequiredSigner = 44
- Add initiate_swap_with_signers(env, token, ip_id, seller, price,
  buyer, signers) — stores required signers alongside the swap
- Add sign_swap_reveal(env, swap_id, signer) — required signer
  records their approval; rejects outsiders and duplicates
- Gate reveal_key: if SwapSigners exist, all must have signed
  before the key can be revealed (NotAllSigned error otherwise)
- Add multi_signer_tests.rs with 7 tests covering:
  blocked until all sign, full flow success, outsider rejection,
  duplicate signature rejection, 3-of-3 flow, sign on pending
  rejection, and empty signers list rejection
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

@dami-005 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Swap Conditional Reveal with Multi-Party Signatures

1 participant