Skip to content

Commit 4e32c41

Browse files
authored
Merge branch 'dev' into feat(web)/graph-and-rpc-error-toasts
2 parents 0aa381a + e2a18cc commit 4e32c41

22 files changed

+381
-10
lines changed

subgraph/core/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ type ClassicContribution implements Contribution @entity {
305305

306306
localRound: ClassicRound!
307307
amount: BigInt!
308+
rewardAmount: BigInt
308309
choice: BigInt!
309310
rewardWithdrawn: Boolean!
310311
}

subgraph/core/src/DisputeKitClassic.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,6 @@ export function handleWithdrawal(event: Withdrawal): void {
126126
const contribution = ensureClassicContributionFromEvent(event);
127127
if (!contribution) return;
128128
contribution.rewardWithdrawn = true;
129+
contribution.rewardAmount = event.params._amount;
129130
contribution.save();
130131
}

subgraph/core/src/entities/ClassicContribution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { Contribution as ContributionEvent, Withdrawal } from "../../generated/D
33
import { DISPUTEKIT_ID } from "../DisputeKitClassic";
44

55
export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribution | null {
6-
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) {
7-
return null;
8-
}
6+
if (!(event instanceof ContributionEvent) && !(event instanceof Withdrawal)) return null;
97
const coreDisputeID = event.params._coreDisputeID.toString();
108
const coreRoundIndex = event.params._coreRoundID.toString();
119
const roundID = `${DISPUTEKIT_ID}-${coreDisputeID}-${coreRoundIndex}`;
@@ -25,9 +23,11 @@ export function ensureClassicContributionFromEvent<T>(event: T): ClassicContribu
2523
classicContribution.rewardWithdrawn = false;
2624
} else {
2725
const currentAmount = classicContribution.amount;
28-
classicContribution.amount = currentAmount.plus(event.params._amount);
26+
// we dont want to increase amount on withdraw event, the amount in that event is reward/reimburse amount
27+
if (event instanceof ContributionEvent) {
28+
classicContribution.amount = currentAmount.plus(event.params._amount);
29+
}
2930
}
30-
3131
classicContribution.save();
3232
return classicContribution;
3333
}

subgraph/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kleros/kleros-v2-subgraph",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"license": "MIT",
55
"scripts": {
66
"update:core:arbitrum-sepolia-devnet": "./scripts/update.sh arbitrumSepoliaDevnet arbitrum-sepolia core/subgraph.yaml",

web/src/assets/svgs/icons/eth.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React, { useMemo } from "react";
2+
import styled, { Theme, useTheme } from "styled-components";
3+
4+
const COLORS: Record<string, Array<keyof Theme>> = {
5+
red: ["error", "errorLight"],
6+
green: ["success", "successLight"],
7+
blue: ["primaryBlue", "mediumBlue"],
8+
purple: ["secondaryPurple", "mediumPurple"],
9+
lightPurple: ["tint", "mediumPurple"],
10+
grey: ["secondaryText", "lightGrey"],
11+
};
12+
13+
export type IColors = keyof typeof COLORS;
14+
15+
const LabelContainer = styled.div<{ backgroundColor: string }>`
16+
display: inline-flex;
17+
padding: 4px 8px;
18+
align-items: center;
19+
gap: 10px;
20+
border-radius: 300px;
21+
background-color: ${({ backgroundColor }) => backgroundColor};
22+
`;
23+
24+
const IconContainer = styled.div<{ contentColor: string }>`
25+
height: 14px;
26+
width: 14px;
27+
display: flex;
28+
align-items: center;
29+
justify-content: center;
30+
> svg {
31+
fill: ${({ contentColor }) => contentColor};
32+
}
33+
`;
34+
35+
const StyledText = styled.label<{ contentColor: string }>`
36+
font-size: 12px;
37+
font-weight: 400;
38+
color: ${({ contentColor }) => contentColor};
39+
`;
40+
41+
export interface ILabelProps {
42+
text: string;
43+
icon: React.FC<React.SVGAttributes<SVGElement>>;
44+
color: keyof typeof COLORS;
45+
}
46+
47+
const Label: React.FC<ILabelProps> = ({ text, icon: Icon, color }) => {
48+
const theme = useTheme();
49+
const [contentColor, backgroundColor] = useMemo(() => {
50+
return COLORS[color].map((color) => theme[color]);
51+
}, [theme, color]);
52+
53+
return (
54+
<LabelContainer {...{ backgroundColor }}>
55+
<IconContainer {...{ contentColor }}>
56+
<Icon />
57+
</IconContainer>
58+
<StyledText {...{ contentColor }}>{text}</StyledText>
59+
</LabelContainer>
60+
);
61+
};
62+
63+
export default Label;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from "react";
2+
import styled, { useTheme } from "styled-components";
3+
import EthIcon from "assets/svgs/icons/eth.svg";
4+
import PnkIcon from "assets/svgs/icons/kleros.svg";
5+
import NumberDisplay from "components/NumberDisplay";
6+
7+
const Container = styled.div`
8+
display: flex;
9+
gap: 4px;
10+
align-items: center;
11+
flex-wrap: wrap;
12+
`;
13+
14+
const StyledIcon = styled.div<{ color: string }>`
15+
width: 12px;
16+
height: 12px;
17+
18+
path {
19+
fill: ${({ color }) => color};
20+
}
21+
`;
22+
23+
const StyledLabel = styled.label<{ color: string }>`
24+
color: ${({ color }) => color};
25+
`;
26+
interface IRewardsAndFundLabel {
27+
value: string;
28+
unit: "ETH" | "PNK";
29+
isFund?: boolean;
30+
}
31+
32+
const RewardsAndFundLabel: React.FC<IRewardsAndFundLabel> = ({ value, unit = "ETH", isFund = false }) => {
33+
const theme = useTheme();
34+
const isWon = Number(value) > 0;
35+
const color = isWon ? theme.success : theme.error;
36+
return Number(value) !== 0 ? (
37+
<Container>
38+
<StyledLabel color={isFund ? theme.tint : color}>
39+
<NumberDisplay {...{ value, unit }} showUnitInDisplay={false} />
40+
</StyledLabel>
41+
<StyledIcon as={unit === "ETH" ? EthIcon : PnkIcon} color={isFund ? theme.tint : color} />
42+
</Container>
43+
) : null;
44+
};
45+
46+
export default RewardsAndFundLabel;

0 commit comments

Comments
 (0)