Skip to content

Commit fa2520c

Browse files
committed
fix: cosmetic and rabbit review
1 parent 6eb5bc6 commit fa2520c

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

web/src/consts/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ export const RPC_ERROR = `RPC Error: Unable to fetch dispute data. Please avoid
4444
export const spamEvidencesIds: string[] = (import.meta.env.REACT_APP_SPAM_EVIDENCES_IDS ?? "").split(",");
4545

4646
export enum DisputeKits {
47-
Classic = "Classic Dispute Kit",
48-
Shutter = "Shutter Dispute Kit",
49-
Gated = "Gated Dispute Kit",
50-
GatedShutter = "Gated Shutter Dispute Kit",
47+
Classic = "Classic",
48+
Shutter = "Shutter",
49+
Gated = "Token Gated",
50+
GatedShutter = "Token Gated Shutter",
5151
}

web/src/pages/Resolver/Parameters/Court.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ const Court: React.FC = () => {
115115
return disputeData.disputeKitId ?? -1;
116116
}, [disputeKitOptions, disputeData.disputeKitId]);
117117

118+
const isGatedDisputeKit = useMemo(() => {
119+
const options = disputeKitOptions.find((dk) => String(dk.value) === String(selectedDisputeKitId));
120+
return options?.gated ?? false;
121+
}, [disputeKitOptions, selectedDisputeKitId]);
122+
118123
const handleCourtChange = (courtId: string) => {
119124
if (disputeData.courtId !== courtId) {
120125
setDisputeData({ ...disputeData, courtId, disputeKitId: undefined });
@@ -123,23 +128,18 @@ const Court: React.FC = () => {
123128

124129
const handleDisputeKitChange = (newValue: string | number) => {
125130
const options = disputeKitOptions.find((dk) => String(dk.value) === String(newValue));
126-
const isNewValueGated = options?.gated ?? false;
127-
const gatedDisputeKitData: IGatedDisputeData | undefined = isNewValueGated
128-
? {
129-
type: "gated",
130-
tokenGate: "",
131-
isERC1155: false,
132-
tokenId: "0",
133-
}
134-
: undefined;
131+
const gatedDisputeKitData: IGatedDisputeData | undefined =
132+
(options?.gated ?? false)
133+
? {
134+
type: "gated",
135+
tokenGate: "",
136+
isERC1155: false,
137+
tokenId: "0",
138+
}
139+
: undefined;
135140
setDisputeData({ ...disputeData, disputeKitId: Number(newValue), disputeKitData: gatedDisputeKitData });
136141
};
137142

138-
const isGatedDisputeKit = useMemo(() => {
139-
const options = disputeKitOptions.find((dk) => String(dk.value) === String(selectedDisputeKitId));
140-
return options?.gated ?? false;
141-
}, [disputeKitOptions, selectedDisputeKitId]);
142-
143143
const handleTokenAddressChange = (event: React.ChangeEvent<HTMLInputElement>) => {
144144
const currentData = disputeData.disputeKitData as IGatedDisputeData;
145145
setDisputeData({

web/src/utils/prepareArbitratorExtradata.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ import { IDisputeKitData, IGatedDisputeData, ISomeFutureDisputeData } from "cont
1010
const encodeGatedDisputeData = (data: IGatedDisputeData): string => {
1111
// Packing of tokenGate and isERC1155
1212
// uint88 (padding 11 bytes) + bool (1 byte) + address (20 bytes) = 32 bytes
13-
const packed = ethers.utils.solidityPack(["uint88", "bool", "address"], [0, data.isERC1155, data.tokenGate]);
14-
if (!data.tokenId || !data.isERC1155) data.tokenId = "0";
15-
return ethers.utils.defaultAbiCoder.encode(["bytes32", "uint256"], [packed, data.tokenId]);
13+
const normalizedData = {
14+
...data,
15+
tokenId: !data.tokenId || !data.isERC1155 ? "0" : data.tokenId,
16+
};
17+
const packed = ethers.utils.solidityPack(
18+
["uint88", "bool", "address"],
19+
[0, normalizedData.isERC1155, normalizedData.tokenGate]
20+
);
21+
return ethers.utils.defaultAbiCoder.encode(["bytes32", "uint256"], [packed, normalizedData.tokenId]);
1622
};
1723

1824
/**
@@ -45,7 +51,7 @@ export const prepareArbitratorExtradata = (
4551
disputeKit: number = 1,
4652
disputeKitData?: IDisputeKitData
4753
) => {
48-
let extraData = ethers.utils.defaultAbiCoder.encode(
54+
const extraData = ethers.utils.defaultAbiCoder.encode(
4955
["uint256", "uint256", "uint256"],
5056
[subcourtID, noOfVotes, disputeKit]
5157
) as `0x{string}`;
@@ -58,6 +64,5 @@ export const prepareArbitratorExtradata = (
5864
throw new Error(`Unknown dispute kit data type: ${disputeKitData.type}`);
5965
}
6066
const encodedDisputeKitData = encoder(disputeKitData as any);
61-
extraData = ethers.utils.hexConcat([extraData, encodedDisputeKitData]) as `0x{string}`;
62-
return extraData;
67+
return ethers.utils.hexConcat([extraData, encodedDisputeKitData]) as `0x{string}`;
6368
};

0 commit comments

Comments
 (0)