Skip to content

Commit eb68665

Browse files
committed
feat: stop handling appeals internally
the frontend will direct the user to the arbitrable interface to handle appealing, crowdfunding, etc.
1 parent 57d0dcc commit eb68665

File tree

8 files changed

+74
-271
lines changed

8 files changed

+74
-271
lines changed

src/hooks/appeal-time.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
import { useMemo } from 'react'
22
import { DISPUTE_STATUS } from '../utils/item-status'
3-
import { bigNumberify } from 'ethers/utils'
43

54
const useAppealTime = item =>
65
useMemo(() => {
76
if (!item || item.disputeStatus !== DISPUTE_STATUS.APPEALABLE) return {}
8-
const { appealStart, appealEnd } = item
9-
const appealDuration = appealEnd.sub(appealStart)
10-
const appealEndLoser = appealStart.add(appealDuration.div(bigNumberify(2)))
7+
const { appealEnd } = item
118

129
const appealRemainingTime =
1310
appealEnd.toNumber() * 1000 - Math.floor(Date.now())
14-
const appealRemainingTimeLoser =
15-
appealEndLoser.toNumber() * 1000 - Math.floor(Date.now())
1611

1712
return {
18-
appealRemainingTime,
19-
appealRemainingTimeLoser
13+
appealRemainingTime
2014
}
2115
}, [item])
2216

src/pages/item-details/crowdfunding-card.js

Lines changed: 28 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import React, { useContext } from 'react'
2-
import { Card, Typography, Progress } from 'antd'
2+
import { Card, Typography } from 'antd'
33
import styled from 'styled-components/macro'
44
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
55
import {
66
DISPUTE_STATUS,
7-
PARTY,
87
itemToStatusCode,
98
STATUS_CODE
109
} from 'utils/item-status'
1110
import { TCRViewContext } from 'contexts/tcr-view-context'
12-
import useRequiredFees from 'hooks/required-fees'
13-
import { formatEther } from 'ethers/utils'
1411
import itemPropType from 'prop-types/item'
1512
import BNPropType from 'prop-types/bn'
16-
import useNativeCurrency from 'hooks/native-currency'
13+
import { WalletContext } from 'contexts/wallet-context'
14+
import getNetworkEnv from 'utils/network-env'
1715

1816
const StyledCard = styled(Card)`
1917
background: linear-gradient(111.6deg, #4d00b4 46.25%, #6500b4 96.25%);
@@ -57,34 +55,14 @@ const StyledIcon = styled(FontAwesomeIcon)`
5755
margin: 12px;
5856
`
5957

60-
const CrowdfundingCard = ({ item, timestamp }) => {
61-
const {
62-
challengePeriodDuration,
63-
sharedStakeMultiplier,
64-
winnerStakeMultiplier,
65-
loserStakeMultiplier,
66-
MULTIPLIER_DIVISOR
67-
} = useContext(TCRViewContext)
68-
const nativeCurrency = useNativeCurrency()
69-
70-
const requesterFees = useRequiredFees({
71-
side: PARTY.REQUESTER,
72-
sharedStakeMultiplier,
73-
winnerStakeMultiplier,
74-
loserStakeMultiplier,
75-
currentRuling: item && item.currentRuling,
76-
item,
77-
MULTIPLIER_DIVISOR
78-
})
79-
const challengerFees = useRequiredFees({
80-
side: PARTY.CHALLENGER,
81-
sharedStakeMultiplier,
82-
winnerStakeMultiplier,
83-
loserStakeMultiplier,
84-
currentRuling: item && item.currentRuling,
85-
item,
86-
MULTIPLIER_DIVISOR
87-
})
58+
const CrowdfundingCard = ({ item, timestamp, request }) => {
59+
const { networkId } = useContext(WalletContext)
60+
const { arbitrator: klerosAddress, uiURL } =
61+
getNetworkEnv('REACT_APP_KLEROS_ADDRESSES', networkId) || {}
62+
63+
const { disputeID, arbitrator } = request || {}
64+
65+
const { challengePeriodDuration } = useContext(TCRViewContext)
8866

8967
if (
9068
!item ||
@@ -93,93 +71,37 @@ const CrowdfundingCard = ({ item, timestamp }) => {
9371
)
9472
return null
9573

96-
const { hasPaid, amountPaid, currentRuling } = item
97-
98-
if (
99-
!requesterFees ||
100-
!challengerFees ||
101-
!challengerFees.requiredForSide ||
102-
!challengerFees.potentialReward ||
103-
!requesterFees.requiredForSide ||
104-
!requesterFees.potentialReward
105-
)
106-
return null
107-
10874
const statusCode = itemToStatusCode(item, timestamp, challengePeriodDuration)
10975

11076
if (statusCode === STATUS_CODE.WAITING_ENFORCEMENT) return null
11177

112-
const requesterPercentage =
113-
amountPaid[PARTY.REQUESTER]
114-
.mul(MULTIPLIER_DIVISOR)
115-
.div(requesterFees.requiredForSide)
116-
.toNumber() / 100
117-
const challengerPercentage =
118-
amountPaid[PARTY.CHALLENGER]
119-
.mul(MULTIPLIER_DIVISOR)
120-
.div(challengerFees.requiredForSide)
121-
.toNumber() / 100
122-
12378
return (
12479
<StyledCard>
12580
<StyledContent>
12681
<StyledSection>
12782
<StyledTitle strong level={4}>
128-
Appeal Crowdfunding
83+
Appeal Phase
12984
</StyledTitle>
13085
<StyledIcon icon="coins" size="2x" />
13186
<StyledParagraph>
13287
Contribute appeal fees and earn rewards if the side you back wins
133-
the round
134-
</StyledParagraph>
135-
</StyledSection>
136-
<StyledSection>
137-
<StyledTitle strong level={4}>
138-
Submitter
139-
</StyledTitle>
140-
<Progress
141-
percent={hasPaid[PARTY.REQUESTER] ? 100 : requesterPercentage}
142-
status={hasPaid[PARTY.REQUESTER] ? 'success' : 'active'}
143-
showInfo={false}
144-
/>
145-
<br />
146-
<StyledParagraph>
147-
{hasPaid[PARTY.REQUESTER]
148-
? `Submitter funded. The challenger must now fully fund his side of the appeal before the deadline in order not to lose the dispute.`
149-
: `Contribute arbitration fees to the submitter's appeal for a chance to win at most ${formatEther(
150-
requesterFees.potentialReward
151-
)} ${nativeCurrency}.`}
152-
</StyledParagraph>
153-
</StyledSection>
154-
<StyledSection>
155-
<StyledTitle strong level={4}>
156-
Challenger
157-
</StyledTitle>
158-
<Progress
159-
percent={hasPaid[PARTY.CHALLENGER] ? 100 : challengerPercentage}
160-
status={hasPaid[PARTY.CHALLENGER] ? 'success' : 'active'}
161-
showInfo={false}
162-
/>
163-
<br />
164-
<StyledParagraph>
165-
{hasPaid[PARTY.CHALLENGER]
166-
? 'Challenger fully funded. The submitter must now fully fund his side of the appeal before the deadline in order not to lose the dispute.'
167-
: `Contribute arbitration fees to the challenger's appeal for a chance to win at most ${formatEther(
168-
challengerFees.potentialReward
169-
)} ${nativeCurrency}.`}
170-
</StyledParagraph>
171-
</StyledSection>
172-
<StyledSection>
173-
<StyledIcon icon="info-circle" size="2x" />
174-
<StyledParagraph>
175-
{currentRuling === PARTY.NONE
176-
? 'The arbitrator did not give a decisive ruling. If a party fully funds his side of an appeal, the other must also fund in order to not lose the dispute.'
177-
: `If the ${
178-
currentRuling === PARTY.REQUESTER ? 'challenger' : 'submitter'
179-
} fully funds his side of the appeal, the ${
180-
currentRuling === PARTY.REQUESTER ? 'submitter' : 'challenger'
181-
} must also fund his side of the appeal in order not to lose the case.`}
88+
the round.
18289
</StyledParagraph>
90+
{klerosAddress.toLowerCase() === arbitrator.toLowerCase() ? (
91+
<StyledParagraph>
92+
Please{' '}
93+
<a href={uiURL.replace(':disputeID', disputeID.toString())}>
94+
go to the Kleros Court
95+
</a>{' '}
96+
to manage this step.
97+
</StyledParagraph>
98+
) : (
99+
<StyledParagraph>
100+
The arbitrator that rules the inclusion of this item is not
101+
compatible with Kleros Court. If you wanted to appeal, please
102+
request assistance in Telegram.
103+
</StyledParagraph>
104+
)}
183105
</StyledSection>
184106
</StyledContent>
185107
</StyledCard>

src/pages/item-details/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,12 @@ const ItemDetails = ({ itemID, search }) => {
333333
itemMetaEvidence={itemMetaEvidence}
334334
/>
335335
{/* Crowdfunding card is only rendered if the item has an appealable dispute. */}
336-
<CrowdfundingCard item={decodedItem || item} timestamp={timestamp} />
336+
{/* V2 arbitrator handles appeals internally, so appeal logic is removed. */}
337+
<CrowdfundingCard
338+
item={decodedItem || item}
339+
timestamp={timestamp}
340+
request={requests[requests.length - 1]}
341+
/>
337342

338343
{/* Spread the `requests` parameter to convert elements from array to an object */}
339344
<RequestTimelines

src/pages/item-details/item-status-card.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ const ItemStatusCard = ({
9797
} = useContext(TCRViewContext)
9898

9999
// Get remaining appeal time, if any and build countdown.
100-
const { appealRemainingTime, appealRemainingTimeLoser } = useAppealTime(item)
100+
const { appealRemainingTime } = useAppealTime(item)
101101
const appealCountdown = useHumanizedCountdown(appealRemainingTime)
102-
const appealLoserCountdown = useHumanizedCountdown(appealRemainingTimeLoser)
103102
const { arbitrator: klerosAddress, uiURL } =
104103
getNetworkEnv('REACT_APP_KLEROS_ADDRESSES', networkId) || {}
105104

@@ -274,21 +273,6 @@ const ItemStatusCard = ({
274273
{appealCountdown}
275274
</Descriptions.Item>
276275
)}
277-
{/* Decisive ruling winner countdown. */}
278-
{currentRuling !== PARTY.NONE &&
279-
(statusCode === STATUS_CODE.CROWDFUNDING ||
280-
statusCode === STATUS_CODE.CROWDFUNDING_WINNER) && (
281-
<Descriptions.Item label="Winner Appeal Time">
282-
{appealCountdown}
283-
</Descriptions.Item>
284-
)}
285-
{/* Decisive ruling loser countdown. */}
286-
{currentRuling !== PARTY.NONE &&
287-
statusCode === STATUS_CODE.CROWDFUNDING && (
288-
<Descriptions.Item label="Loser Appeal Time">
289-
{appealLoserCountdown}
290-
</Descriptions.Item>
291-
)}
292276
</StyledDescriptions>
293277
</Card>
294278
{/* Only render modal if the item status requires it. */}

0 commit comments

Comments
 (0)