Skip to content

Commit

Permalink
✨ Fix Dispute modal doesnt show wallet balance
Browse files Browse the repository at this point in the history
- Added error handling for empty dispute reason
- Introduced a new state variable to handle errors
- Modified the condition for totalStake calculation
- Adjusted textarea layout and added an error message display area
  • Loading branch information
Corantin committed Oct 18, 2024
1 parent ca21da0 commit 5f38b90
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
41 changes: 25 additions & 16 deletions apps/web/components/DisputeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const DisputeButton: FC<Props> = ({ proposalData }) => {
const [isDisputeCreateLoading, setIsDisputeCreateLoading] = useState(false);
const chainId = useChainIdFromPath();
const [rulingLoading, setisRulingLoading] = useState<number | false>(false);
const [error, setError] = useState("");

const arbitrationConfig = proposalData.arbitrableConfig;

Expand Down Expand Up @@ -113,7 +114,7 @@ export const DisputeButton: FC<Props> = ({ proposalData }) => {
});

const totalStake =
arbitrationCost && arbitrationConfig ?
arbitrationCost != null && arbitrationConfig ?
arbitrationCost + BigInt(arbitrationConfig.challengerCollateralAmount)
: undefined;
const lastDispute =
Expand Down Expand Up @@ -175,14 +176,18 @@ export const DisputeButton: FC<Props> = ({ proposalData }) => {
});

async function handleSubmit() {
setIsDisputeCreateLoading(true);
const reasonHash = await ipfsJsonUpload({ reason }, "disputeReason");
if (!reasonHash) {
return;
if (!reason) {
setError("The dispute reason is required.");
} else {
setIsDisputeCreateLoading(true);
const reasonHash = await ipfsJsonUpload({ reason }, "disputeReason");
if (!reasonHash) {
return;
}
await writeDisputeProposalAsync({
args: [BigInt(proposalData.proposalNumber), reasonHash, "0x0"],
});
}
await writeDisputeProposalAsync({
args: [BigInt(proposalData.proposalNumber), reasonHash, "0x0"],
});
}

const { write: writeSubmitRuling } = useContractWriteWithConfirmations({
Expand Down Expand Up @@ -275,14 +280,18 @@ export const DisputeButton: FC<Props> = ({ proposalData }) => {
))}
</div>
: <div>
<textarea
id="reason"
value={reason}
onChange={(e) => setReason(e.target.value)}
placeholder="Enter your dispute reason here"
className="textarea textarea-accent w-full mb-4"
rows={5}
/>
<div className="w-full mb-4">
<textarea
id="reason"
value={reason}
onChange={(e) => setReason(e.target.value)}
placeholder="Enter your dispute reason here"
className="textarea textarea-accent w-full"
rows={5}
required
/>
<div className="text-error ml-4 mt-1">{error}</div>
</div>
<InfoBox
infoBoxType="info"
content={`Disputing this proposal stops it from being executed but not from growing in support. The Tribunal has ${rulingTimeout.value} ${rulingTimeout.unit} to settle any disputes before it can be closed and collateral is returned.`}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/configs/chains.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const chainConfigMap: {
subgraphUrl: `${process.env.NEXT_PUBLIC_SUBGRAPH_URL_GNOSIS?.replace("/version/latest", "")}/${SUBGRAPH_PRODNET_VERSION}`,
globalTribunal: "0x1B8C7f06F537711A7CAf6770051A43B4F3E69A7e",
allo: "0x1133eA7Af70876e64665ecD07C0A0476d09465a1",
arbitrator: "0x4d858f327d63bbf693291b96f9e585cac64895a9",
arbitrator: "0x450967c1497ab95df8530a9a8eaae5e951171dee",
passportScorer: "0xd7b72fcb6a4e2857685175f609d1498ff5392e46",
isTestnet: false,
},
Expand Down

0 comments on commit 5f38b90

Please sign in to comment.