Skip to content

Commit

Permalink
Merge branch 'master' into feat/pay-improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybuidl authored Jun 19, 2024
2 parents 3d08d7a + 7fc6397 commit 24d0a04
Show file tree
Hide file tree
Showing 49 changed files with 600 additions and 216 deletions.
2 changes: 1 addition & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments

- [Escrow](https://sepolia.arbiscan.io/address/0x250AB0477346aDFC010585b58FbF61cff1d8f3ea)
- [EscrowToken](https://sepolia.arbiscan.io/address/0xe7B52a7Bc50cb4Ff13d057629082844780b6E28D)
- [EscrowUniversal](https://sepolia.arbiscan.io/address/0x5c4B2Cff2998529f9d405A9b6EbB44BC537c8D7F)
- [EscrowUniversal](https://sepolia.arbiscan.io/address/0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De)

#### Sepolia

Expand Down
120 changes: 60 additions & 60 deletions contracts/deployments/arbitrumSepoliaDevnet/EscrowUniversal.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contracts/src/Escrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contract Escrow is IEscrow, IArbitrableV2 {

/// @inheritdoc IEscrow
function createNativeTransaction(
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand All @@ -124,7 +124,7 @@ contract Escrow is IEscrow, IArbitrableV2 {
transaction.buyer = payable(msg.sender);
transaction.seller = _seller;
transaction.amount = msg.value;
transaction.deadline = block.timestamp + _timeoutPayment;
transaction.deadline = _deadline;
transaction.templateData = _templateData;
transaction.templateDataMappings = _templateDataMappings;

Expand Down
4 changes: 2 additions & 2 deletions contracts/src/EscrowToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ contract EscrowToken is IEscrow, IArbitrableV2 {
function createERC20Transaction(
uint256 _amount,
IERC20 _token,
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand All @@ -149,7 +149,7 @@ contract EscrowToken is IEscrow, IArbitrableV2 {
transaction.amount = _amount;
transaction.token = _token;
// transaction.paymentType = PaymentType.ERC20;
transaction.deadline = block.timestamp + _timeoutPayment;
transaction.deadline = _deadline;
transaction.templateData = _templateData;
transaction.templateDataMappings = _templateDataMappings;

Expand Down
8 changes: 4 additions & 4 deletions contracts/src/EscrowUniversal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {

/// @inheritdoc IEscrow
function createNativeTransaction(
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand All @@ -134,7 +134,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
transaction.seller = _seller;
transaction.amount = msg.value;
transaction.token = NATIVE;
transaction.deadline = block.timestamp + _timeoutPayment;
transaction.deadline = _deadline;
transaction.templateData = _templateData;
transaction.templateDataMappings = _templateDataMappings;

Expand All @@ -154,7 +154,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
function createERC20Transaction(
uint256 _amount,
IERC20 _token,
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand All @@ -167,7 +167,7 @@ contract EscrowUniversal is IEscrow, IArbitrableV2 {
transaction.seller = _seller;
transaction.amount = _amount;
transaction.token = _token;
transaction.deadline = block.timestamp + _timeoutPayment;
transaction.deadline = _deadline;
transaction.templateData = _templateData;
transaction.templateDataMappings = _templateDataMappings;

Expand Down
8 changes: 4 additions & 4 deletions contracts/src/interfaces/IEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ interface IEscrow {
// ************************************* //

/// @dev Create a transaction.
/// @param _timeoutPayment Time after which a party can automatically execute the arbitrable transaction.
/// @param _deadline Time after which a party can automatically execute the arbitrable transaction.
/// @param _transactionUri The IPFS Uri Hash of the transaction.
/// @param _seller The recipient of the transaction.
/// @param _templateData The dispute template data.
/// @param _templateDataMappings The dispute template data mappings.
/// @return transactionID The index of the transaction.
function createNativeTransaction(
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand All @@ -91,7 +91,7 @@ interface IEscrow {
/// @dev Create a transaction.
/// @param _amount The amount of tokens in this transaction.
/// @param _token The ERC20 token contract.
/// @param _timeoutPayment Time after which a party can automatically execute the arbitrable transaction.
/// @param _deadline Time after which a party can automatically execute the arbitrable transaction.
/// @param _transactionUri The IPFS Uri Hash of the transaction.
/// @param _seller The recipient of the transaction.
/// @param _templateData The dispute template data.
Expand All @@ -100,7 +100,7 @@ interface IEscrow {
function createERC20Transaction(
uint256 _amount,
IERC20 _token,
uint256 _timeoutPayment,
uint256 _deadline,
string memory _transactionUri,
address payable _seller,
string memory _templateData,
Expand Down
15 changes: 8 additions & 7 deletions subgraph/mappings/escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from "../generated/EscrowUniversal/EscrowUniversal";
import { ZERO, ONE } from "./utils";

function createEscrow(id: string): Escrow {
function createEscrow(id: string, transactionHash: Bytes): Escrow {
let escrow = new Escrow(id);
escrow.buyer = Bytes.empty();
escrow.seller = Bytes.empty();
Expand All @@ -34,6 +34,7 @@ function createEscrow(id: string): Escrow {
escrow.templateData = "";
escrow.templateDataMappings = "";
escrow.status = "NoDispute";
escrow.transactionHash = transactionHash;
return escrow;
}

Expand Down Expand Up @@ -95,7 +96,7 @@ export function handleHasToPayFee(event: HasToPayFeeEvent): void {
let escrow = Escrow.load(escrowId);

if (!escrow) {
escrow = createEscrow(escrowId);
return;
}

let seller = getUser(escrow.seller.toHex());
Expand Down Expand Up @@ -131,7 +132,7 @@ export function handleHasToPayFee(event: HasToPayFeeEvent): void {

export function handleNativeTransactionCreated(event: NativeTransactionCreatedEvent): void {
let escrowId = event.params._transactionID.toString();
let escrow = Escrow.load(escrowId) || createEscrow(escrowId);
let escrow = Escrow.load(escrowId) || createEscrow(escrowId, event.transaction.hash);

escrow!.buyer = event.params._buyer;
escrow!.seller = event.params._seller;
Expand Down Expand Up @@ -163,7 +164,7 @@ export function handleNativeTransactionCreated(event: NativeTransactionCreatedEv

export function handleERC20TransactionCreated(event: ERC20TransactionCreatedEvent): void {
let escrowId = event.params._transactionID.toString();
let escrow = Escrow.load(escrowId) || createEscrow(escrowId);
let escrow = Escrow.load(escrowId) || createEscrow(escrowId, event.transaction.hash);

escrow!.buyer = event.params._buyer;
escrow!.seller = event.params._seller;
Expand Down Expand Up @@ -199,7 +200,7 @@ export function handleTransactionResolved(event: TransactionResolvedEvent): void
let escrow = Escrow.load(escrowId);

if (!escrow) {
escrow = createEscrow(escrowId);
return;
}

let transactionResolvedId = event.transaction.hash.toHex() + "-" + event.logIndex.toString();
Expand Down Expand Up @@ -248,7 +249,7 @@ export function handleDisputeRequest(event: DisputeRequestEvent): void {

let escrow = Escrow.load(transactionID);
if (!escrow) {
escrow = createEscrow(transactionID);
return;
}

disputeRequest.escrow = escrow.id;
Expand Down Expand Up @@ -284,7 +285,7 @@ export function handleSettlementProposed(event: SettlementProposedEvent): void {

let escrow = Escrow.load(transactionID);
if (!escrow) {
escrow = createEscrow(transactionID);
return;
}
escrow.lastFeePaymentTime = event.block.timestamp;

Expand Down
2 changes: 1 addition & 1 deletion subgraph/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kleros/escrow-v2-subgraph",
"version": "2.0.0",
"version": "2.0.1",
"license": "MIT",
"scripts": {
"update:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia",
Expand Down
1 change: 1 addition & 0 deletions subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Escrow @entity {
token: Bytes
status: Status
timestamp: BigInt
transactionHash: Bytes!
payments: [Payment!]! @derivedFrom(field: "escrow")
hasToPayFees: [HasToPayFee!]! @derivedFrom(field: "escrow")
createdEvents: [TransactionCreated!]! @derivedFrom(field: "escrow")
Expand Down
4 changes: 2 additions & 2 deletions subgraph/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ dataSources:
name: EscrowUniversal
network: arbitrum-sepolia
source:
address: '0x5c4B2Cff2998529f9d405A9b6EbB44BC537c8D7F'
address: '0xBa2cC03e2e34C5DEDaEbC481b2531e06946353De'
abi: EscrowUniversal
startBlock: 42653663
startBlock: 53588833
mapping:
kind: ethereum/events
apiVersion: 0.0.6
Expand Down
Binary file removed web/src/assets/svgs/icons/eth-token-icon.png
Binary file not shown.
10 changes: 10 additions & 0 deletions web/src/assets/svgs/icons/etherscan.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions web/src/assets/svgs/icons/tokens/arb.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions web/src/assets/svgs/icons/tokens/dai.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions web/src/assets/svgs/icons/tokens/eth.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions web/src/assets/svgs/icons/tokens/gno.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions web/src/assets/svgs/icons/tokens/matic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 24d0a04

Please sign in to comment.