11import React , { useContext } from 'react'
2- import { Card , Typography , Progress } from 'antd'
2+ import { Card , Typography } from 'antd'
33import styled from 'styled-components/macro'
44import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
55import {
66 DISPUTE_STATUS ,
7- PARTY ,
87 itemToStatusCode ,
98 STATUS_CODE
109} from 'utils/item-status'
1110import { TCRViewContext } from 'contexts/tcr-view-context'
12- import useRequiredFees from 'hooks/required-fees'
13- import { formatEther } from 'ethers/utils'
1411import itemPropType from 'prop-types/item'
1512import 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
1816const 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 >
0 commit comments