Feat/swap enhancements - #395
Merged
fejilaup-cloud merged 5 commits intoApr 27, 2026
Merged
Conversation
- Add insurance_premium field to SwapRecord - Add SwapInsurance DataKey for storing insurance premiums - Implement accept_swap_with_insurance() for buyer protection - Insurance premium transferred to contract escrow - Add InsurancePayoutEvent for tracking insurance payouts
- Add SwapRenegotiations DataKey for storing renegotiation offers - Add RenegotiationOffer struct for tracking proposals - Implement propose_renegotiation() for seller or buyer - Implement accept_renegotiation() for counterparty - Implement reject_renegotiation() for counterparty - Add RenegotiationProposedEvent for tracking proposals - Add tests for renegotiation flow
- Add escrow_agent field to SwapRecord for high-value swaps - Add SwapEscrowAgent DataKey for storing escrow agent addresses - Implement initiate_swap_with_escrow() for seller-initiated escrow - Implement escrow_release_funds() for escrow agent fund release - Add EscrowReleasedEvent for tracking escrow releases - Add tests for escrow flow
- Add SwapConditions DataKey for storing acceptance conditions - Implement accept_swap_conditional() for buyer-set conditions - Conditions stored as BytesN<32> hash on-chain - Add ConditionalAcceptanceEvent for tracking conditional accepts - Add tests for conditional acceptance flow
|
@famvilianity-eng 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Swap Enhancement Features: Insurance, Renegotiation, Escrow & Conditional Acceptance
Summary
This PR implements four critical swap enhancement features that improve buyer protection,
negotiation flexibility, fraud prevention, and conditional deal acceptance. These features
address real-world use cases in high-value IP transactions.
Changes
#354: Swap Insurance Option
insurance_premium: i128field to SwapRecordaccept_swap_with_insurance(swap_id, insurance_premium)#353: Swap Renegotiation Protocol
propose_renegotiation(swap_id, new_price)- seller or buyeraccept_renegotiation(swap_id)- counterparty acceptsreject_renegotiation(swap_id)- counterparty rejects#352: Swap Escrow Agent Support
escrow_agent: Option<Address>field to SwapRecordinitiate_swap_with_escrow(...)- seller-onlyescrow_release_funds(swap_id)- escrow-agent-only#351: Swap Conditional Acceptance
accept_swap_conditional(swap_id, conditions)- buyer-onlyTechnical Details
Data Structure Updates
New Functions (7 total)
Backward Compatibility
✅ All changes are backward compatible:
Security
✅ Authorization checks maintained
✅ Fund safety with contract escrow
✅ All operations maintain existing security patterns
Related Issues