Skip to content

Commit e941ec4

Browse files
authored
Merge pull request #154 from kleros/feat/etherscan-links-in-timeline
feat: etherscan links in timeline
2 parents f69cb5c + 02389aa commit e941ec4

8 files changed

Lines changed: 72 additions & 34 deletions

File tree

subgraph/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/escrow-v2-subgraph",
3-
"version": "2.2.1",
3+
"version": "2.2.2",
44
"license": "MIT",
55
"scripts": {
66
"update:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia",
@@ -15,7 +15,7 @@
1515
"deploy:arbitrum": "graph deploy escrow-v2-neo -l v$npm_package_version",
1616
"deploy-goldsky:arbitrum-sepolia-devnet": "goldsky subgraph deploy escrow-v2-devnet/v$npm_package_version --path .",
1717
"deploy-goldsky:arbitrum-sepolia": "goldsky subgraph deploy escrow-v2-testnet/v$npm_package_version --path .",
18-
"deploy-goldsky:arbitrum": "goldsky subgraph deploy escrow-v2-mainnet/v$npm_package_version --path .",
18+
"deploy-goldsky:arbitrum": "goldsky subgraph deploy escrow-v2-neo/v$npm_package_version --path .",
1919
"create-local": "graph create --node http://localhost:8020/ kleros/escrow-v2-local",
2020
"remove-local": "graph remove --node http://localhost:8020/ kleros/escrow-v2-local",
2121
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 kleros/escrow-v2-local --version-label v$(date +%s)",

subgraph/schema.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,32 +65,37 @@ type Payment @entity {
6565
amount: BigInt!
6666
party: Bytes!
6767
timestamp: BigInt
68+
transactionHash: Bytes!
6869
}
6970

7071
type HasToPayFee @entity {
7172
id: ID!
7273
escrow: Escrow!
7374
party: String
7475
timestamp: BigInt
76+
transactionHash: Bytes!
7577
}
7678

7779
type DisputeRequest @entity {
7880
id: ID!
7981
escrow: Escrow!
8082
timestamp: BigInt
8183
from: Bytes
84+
transactionHash: Bytes!
8285
}
8386

8487
type TransactionCreated @entity {
8588
id: ID!
8689
escrow: Escrow!
90+
transactionHash: Bytes!
8791
}
8892

8993
type TransactionResolved @entity {
9094
id: ID!
9195
escrow: Escrow!
9296
resolution: Int!
9397
timestamp: BigInt
98+
transactionHash: Bytes!
9499
}
95100

96101
type SettlementProposal @entity {
@@ -99,6 +104,7 @@ type SettlementProposal @entity {
99104
party: String
100105
amount: BigInt!
101106
timestamp: BigInt!
107+
transactionHash: Bytes!
102108
}
103109

104110
type EscrowParameters @entity {

subgraph/src/escrow.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function handlePayment(event: PaymentEvent): void {
8686
payment.amount = event.params._amount;
8787
payment.timestamp = event.block.timestamp;
8888
payment.party = Bytes.fromHexString(event.params._party.toHex());
89+
payment.transactionHash = event.transaction.hash;
8990

9091
payment.save();
9192
}
@@ -124,6 +125,7 @@ export function handleHasToPayFee(event: HasToPayFeeEvent): void {
124125
hasToPayFee.escrow = escrowId;
125126
hasToPayFee.party = partyValue.toString();
126127
hasToPayFee.timestamp = event.block.timestamp;
128+
hasToPayFee.transactionHash = event.transaction.hash;
127129
hasToPayFee.save();
128130

129131
escrow.save();
@@ -157,6 +159,7 @@ export function handleNativeTransactionCreated(event: NativeTransactionCreatedEv
157159
let transactionCreatedId = event.transaction.hash.toHex() + "-" + event.logIndex.toString();
158160
let transactionCreated = new TransactionCreated(transactionCreatedId);
159161
transactionCreated.escrow = escrowId;
162+
transactionCreated.transactionHash = event.transaction.hash;
160163

161164
transactionCreated.save();
162165
}
@@ -190,6 +193,7 @@ export function handleERC20TransactionCreated(event: ERC20TransactionCreatedEven
190193
let transactionCreatedId = event.transaction.hash.toHex() + "-" + event.logIndex.toString();
191194
let transactionCreated = new TransactionCreated(transactionCreatedId);
192195
transactionCreated.escrow = escrowId;
196+
transactionCreated.transactionHash = event.transaction.hash;
193197

194198
transactionCreated.save();
195199
}
@@ -207,6 +211,7 @@ export function handleTransactionResolved(event: TransactionResolvedEvent): void
207211
transactionResolved.escrow = escrowId;
208212
transactionResolved.resolution = event.params._resolution;
209213
transactionResolved.timestamp = event.block.timestamp;
214+
transactionResolved.transactionHash = event.transaction.hash;
210215
transactionResolved.save();
211216

212217
let buyerId = escrow.buyer.toHex();
@@ -257,6 +262,7 @@ export function handleDisputeRequest(event: DisputeRequestEvent): void {
257262
disputeRequest.escrow = escrow.id;
258263
disputeRequest.timestamp = event.block.timestamp;
259264
disputeRequest.from = Bytes.fromHexString(event.transaction.from.toHex());
265+
disputeRequest.transactionHash = event.transaction.hash;
260266
disputeRequest.save();
261267

262268
let buyer = getUser(escrow.buyer.toHex());
@@ -303,6 +309,7 @@ export function handleSettlementProposed(event: SettlementProposedEvent): void {
303309
proposal.party = partyValue;
304310
proposal.amount = event.params._amount;
305311
proposal.timestamp = event.block.timestamp;
312+
proposal.transactionHash = event.transaction.hash;
306313

307314
proposal.save();
308315
escrow.save();

web/src/components/PreviewCard/EscrowTimeline/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { DisputeRequest, HasToPayFee, Payment, SettlementProposal, TransactionRe
66
interface IEscrowTimeline {
77
isPreview: boolean;
88
transactionCreationTimestamp: number;
9-
status: boolean;
9+
transactionHash: string;
10+
status: string;
1011
assetSymbol: string;
1112
isNativeTransaction: boolean;
1213
tokenDecimals?: number;
@@ -17,11 +18,14 @@ interface IEscrowTimeline {
1718
hasToPayFees: HasToPayFee[];
1819
disputeRequest: DisputeRequest;
1920
resolvedEvents: TransactionResolved[];
21+
feeTimeout: number;
22+
settlementTimeout: number;
2023
}
2124

2225
const EscrowTimeline: React.FC<IEscrowTimeline> = ({
2326
isPreview,
2427
transactionCreationTimestamp,
28+
transactionHash,
2529
status,
2630
assetSymbol,
2731
isNativeTransaction,
@@ -39,10 +43,10 @@ const EscrowTimeline: React.FC<IEscrowTimeline> = ({
3943
const items = useEscrowTimelineItems(
4044
isPreview,
4145
transactionCreationTimestamp,
46+
transactionHash,
4247
status,
4348
assetSymbol,
4449
isNativeTransaction,
45-
tokenDecimals,
4650
buyerAddress,
4751
sellerAddress,
4852
payments,
@@ -51,7 +55,8 @@ const EscrowTimeline: React.FC<IEscrowTimeline> = ({
5155
disputeRequest,
5256
resolvedEvents,
5357
feeTimeout,
54-
settlementTimeout
58+
settlementTimeout,
59+
tokenDecimals,
5560
);
5661

5762
return <CustomTimeline className="w-full" items={items} />;

web/src/components/PreviewCard/Header.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
import React from "react";
2-
import { SUPPORTED_CHAINS, DEFAULT_CHAIN } from "consts/chains";
32
import { isUndefined } from "utils/index";
43
import { mapStatusToEnum } from "utils/mapStatusToEnum";
54
import StatusBanner from "../TransactionCard/StatusBanner";
6-
import EtherscanIcon from "svgs/icons/etherscan.svg";
75
import Skeleton from "react-loading-skeleton";
6+
import { Statuses } from "~src/consts/statuses";
87

98
interface IHeader {
109
escrowType: string;
1110
escrowTitle?: string;
12-
id: string;
1311
status: string;
14-
transactionHash: string;
15-
isCard: boolean;
1612
}
1713

18-
const Header: React.FC<IHeader> = ({ escrowType, escrowTitle, id, status, transactionHash, isCard }) => {
19-
const currentStatusEnum = mapStatusToEnum(status);
20-
const etherscanUrl = `${SUPPORTED_CHAINS[DEFAULT_CHAIN].blockExplorers?.default.url}/tx/${transactionHash}`;
14+
const Header: React.FC<IHeader> = ({ escrowType, escrowTitle, status }) => {
15+
const currentStatusEnum = mapStatusToEnum(status) ?? Statuses.inProgress;
2116

2217
return (
2318
<div className="flex flex-wrap justify-between gap-3">
@@ -32,11 +27,6 @@ const Header: React.FC<IHeader> = ({ escrowType, escrowTitle, id, status, transa
3227
)}
3328
</div>
3429
<div className="flex items-center gap-4 lg:shrink-0 lg:gap-y-0 lg:gap-x-fluid-24-32-900">
35-
{transactionHash ? (
36-
<a href={etherscanUrl} target="_blank" rel="noreferrer">
37-
<EtherscanIcon width={16} height={16} />
38-
</a>
39-
) : null}
4030
<StatusBanner status={currentStatusEnum} isPreview={true} />
4131
</div>
4232
</div>

web/src/components/PreviewCard/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const PreviewCard: React.FC<IPreviewCard> = ({
6666
arbitrationCost,
6767
}) => (
6868
<Card className={clsx("flex flex-col gap-4 lg:gap-6", "w-full h-auto p-4 pt-5 lg:p-8", isPreview && "pb-9")}>
69-
<Header {...{ escrowType, escrowTitle, status, transactionHash, isCard: false }} />
69+
<Header {...{ escrowType, escrowTitle, status }} />
7070
<div className="flex flex-col gap-6">
7171
<hr className={dividerStyle} />
7272
<TransactionInfo
@@ -98,6 +98,7 @@ const PreviewCard: React.FC<IPreviewCard> = ({
9898
isNativeTransaction,
9999
tokenDecimals,
100100
transactionCreationTimestamp,
101+
transactionHash,
101102
buyerAddress,
102103
sellerAddress,
103104
payments,

web/src/hooks/queries/useTransactionsQuery.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ export const transactionFragment = graphql(`
2424
amount
2525
party
2626
timestamp
27+
transactionHash
2728
}
2829
hasToPayFees {
2930
id
3031
party
3132
timestamp
33+
transactionHash
3234
}
3335
createdEvents {
3436
id
@@ -37,12 +39,14 @@ export const transactionFragment = graphql(`
3739
id
3840
resolution
3941
timestamp
42+
transactionHash
4043
}
4144
settlementProposals(orderBy: timestamp, orderDirection: asc) {
4245
id
4346
amount
4447
party
4548
timestamp
49+
transactionHash
4650
}
4751
disputeRequest {
4852
id
@@ -51,6 +55,7 @@ export const transactionFragment = graphql(`
5155
id
5256
}
5357
timestamp
58+
transactionHash
5459
}
5560
}
5661
`);

0 commit comments

Comments
 (0)