Skip to content

feat(Escrow): add custom buyer to universal contract #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 2, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
107 changes: 0 additions & 107 deletions contracts/src/EscrowCustomBuyer.sol

This file was deleted.

13 changes: 8 additions & 5 deletions contracts/src/EscrowUniversal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
function createNativeTransaction(
uint256 _deadline,
string memory _transactionUri,
address payable _buyer,
address payable _seller
) external payable override shouldNotExceedCap(NATIVE, msg.value) returns (uint256 transactionID) {
Transaction storage transaction = transactions.push();
transaction.buyer = payable(msg.sender);
transaction.buyer = _buyer;
transaction.seller = _seller;
transaction.amount = msg.value;
transaction.token = NATIVE;
Expand All @@ -149,7 +150,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
emit NativeTransactionCreated(
transactionID,
_transactionUri,
msg.sender,
_buyer,
_seller,
msg.value,
transaction.deadline
Expand All @@ -162,12 +163,13 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
IERC20 _token,
uint256 _deadline,
string memory _transactionUri,
address payable _buyer,
address payable _seller
) external override shouldNotExceedCap(_token, _amount) returns (uint256 transactionID) {
// Transfers token from sender wallet to contract.
if (!_token.safeTransferFrom(msg.sender, address(this), _amount)) revert TokenTransferFailed();
Transaction storage transaction = transactions.push();
transaction.buyer = payable(msg.sender);
transaction.buyer = _buyer;
transaction.seller = _seller;
transaction.amount = _amount;
transaction.token = _token;
Expand All @@ -178,7 +180,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
emit ERC20TransactionCreated(
transactionID,
_transactionUri,
msg.sender,
_buyer,
_seller,
_token,
_amount,
Expand Down Expand Up @@ -446,7 +448,8 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
arbitratorExtraData
);
disputeIDtoTransactionID[transaction.disputeID] = _transactionID;
emit DisputeRequest(arbitrator, transaction.disputeID, _transactionID, templateId, "");
uint256 externalDisputeID = uint256(keccak256(abi.encodePacked(address(this), _transactionID)));
emit DisputeRequest(arbitrator, transaction.disputeID, externalDisputeID, templateId, "");

// Refund buyer if he overpaid.
if (transaction.buyerFee > _arbitrationCost) {
Expand Down
4 changes: 4 additions & 0 deletions contracts/src/interfaces/IEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ interface IEscrow {
/// @dev Create a transaction.
/// @param _deadline Time after which a party can automatically execute the arbitrable transaction.
/// @param _transactionUri The IPFS Uri Hash of the transaction.
/// @param _buyer Party that pays for the transaction. Note that msg.sender can provide finds on their behalf.
/// @param _seller The recipient of the transaction.
/// @return transactionID The index of the transaction.
function createNativeTransaction(
uint256 _deadline,
string memory _transactionUri,
address payable _buyer,
address payable _seller
) external payable returns (uint256 transactionID);

Expand All @@ -89,13 +91,15 @@ interface IEscrow {
/// @param _token The ERC20 token contract.
/// @param _deadline Time after which a party can automatically execute the arbitrable transaction.
/// @param _transactionUri The IPFS Uri Hash of the transaction.
/// @param _buyer Party that pays for the transaction. Note that msg.sender can provide finds on their behalf.
/// @param _seller The recipient of the transaction.
/// @return transactionID The index of the transaction.
function createERC20Transaction(
uint256 _amount,
IERC20 _token,
uint256 _deadline,
string memory _transactionUri,
address payable _buyer,
address payable _seller
) external returns (uint256 transactionID);

Expand Down
Loading