Skip to content

Commit 0e3fb9c

Browse files
committed
chore(web): rabbit-review
1 parent 83a21bd commit 0e3fb9c

File tree

6 files changed

+17
-28
lines changed

6 files changed

+17
-28
lines changed

web/src/components/DisputeFeatures/Features/ClassicVote.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react";
22

3+
import { Features } from "consts/disputeFeature";
34
import { useNewDisputeContext } from "context/NewDisputeContext";
45

56
import { useCourtDetails } from "queries/useCourtDetails";
@@ -22,6 +23,7 @@ const ClassicVote: React.FC<RadioInput> = (props) => {
2223
: `The jurors' votes are not hidden.
2324
Everybody can see the justification and voted choice before the voting period completes.`
2425
}
26+
key={Features.ClassicVote}
2527
>
2628
<StyledRadio label={isCommitEnabled ? "Two-steps commit-reveal" : "Classic one step voting"} small {...props} />
2729
</WithHelpTooltip>

web/src/components/DisputeFeatures/Features/GatedErc1155.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React, { useEffect, useMemo } from "react";
1+
import React, { Fragment, useEffect, useMemo } from "react";
22
import styled from "styled-components";
33

44
import { Field } from "@kleros/ui-components-library";
55

6+
import { Features } from "consts/disputeFeature";
67
import { IGatedDisputeData, useNewDisputeContext } from "context/NewDisputeContext";
78
import { useERC1155Validation } from "hooks/useTokenAddressValidation";
89

@@ -38,7 +39,7 @@ const GatedErc1155: React.FC<RadioInput> = (props) => {
3839
error: validationError,
3940
} = useERC1155Validation({
4041
address: tokenGateAddress,
41-
enabled: validationEnabled,
42+
enabled: validationEnabled && props.checked,
4243
});
4344

4445
const [validationMessage, variant] = useMemo(() => {
@@ -89,7 +90,7 @@ const GatedErc1155: React.FC<RadioInput> = (props) => {
8990
};
9091

9192
return (
92-
<>
93+
<Fragment key={Features.GatedErc1155}>
9394
<WithHelpTooltip
9495
tooltipMsg="Only jurors who possess the token or NFT indicated below can be selected as jurors for this case.
9596
Add the token address below."
@@ -114,7 +115,7 @@ const GatedErc1155: React.FC<RadioInput> = (props) => {
114115
/>
115116
</FieldContainer>
116117
) : null}
117-
</>
118+
</Fragment>
118119
);
119120
};
120121

web/src/components/DisputeFeatures/Features/GatedErc20.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React, { useEffect, useMemo } from "react";
1+
import React, { Fragment, useEffect, useMemo } from "react";
22
import styled from "styled-components";
33

44
import { Field } from "@kleros/ui-components-library";
55

6+
import { Features } from "consts/disputeFeature";
67
import { IGatedDisputeData, useNewDisputeContext } from "context/NewDisputeContext";
78
import { useERC20ERC721Validation } from "hooks/useTokenAddressValidation";
89

@@ -79,7 +80,7 @@ const GatedErc20: React.FC<RadioInput> = (props) => {
7980
};
8081

8182
return (
82-
<>
83+
<Fragment key={Features.GatedErc20}>
8384
<WithHelpTooltip
8485
tooltipMsg="Only jurors who possess the token or NFT indicated below can be selected as jurors for this case.
8586
Add the token address below."
@@ -98,7 +99,7 @@ const GatedErc20: React.FC<RadioInput> = (props) => {
9899
/>
99100
</FieldContainer>
100101
) : null}
101-
</>
102+
</Fragment>
102103
);
103104
};
104105

web/src/components/DisputeFeatures/Features/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type RadioInput = {
1919
onClick: () => void;
2020
};
2121

22-
export type FeatureUI = (props: RadioInput) => JSX.Element;
22+
export type FeatureUI = React.FC<RadioInput>;
2323

2424
export const StyledRadio = styled(Radio)`
2525
font-size: 14px;
@@ -33,6 +33,7 @@ export const FeatureUIs: Record<Features, FeatureUI> = {
3333
tooltipMsg={`The jurors' votes are hidden.
3434
Nobody can see them before the voting period completes.
3535
(It takes place in one step via Shutter Network)`}
36+
key={Features.ShieldedVote}
3637
>
3738
<StyledRadio label="Single-step via Shutter Network" small {...props} />
3839
</WithHelpTooltip>
@@ -41,7 +42,7 @@ export const FeatureUIs: Record<Features, FeatureUI> = {
4142
[Features.ClassicVote]: (props: RadioInput) => <ClassicVote {...props} />,
4243

4344
[Features.ClassicEligibility]: (props: RadioInput) => (
44-
<StyledRadio label="All the jurors in this court" small {...props} />
45+
<StyledRadio key={Features.ClassicEligibility} label="All the jurors in this court" small {...props} />
4546
),
4647

4748
[Features.GatedErc20]: (props: RadioInput) => <GatedErc20 {...props} />,

web/src/consts/disputeFeature.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ export interface DisputeKit {
2525
* if either subset matches the selected feature array this dispute kit is selected
2626
*/
2727
featureSets: Features[][];
28-
/**
29-
* If true => kit accepts any subset of a featureSet.
30-
* If false => must be an exact match.
31-
*/
32-
allowSubset?: boolean;
3328

3429
type: "general" | "gated";
3530
}
@@ -62,7 +57,6 @@ export const disputeKits: DisputeKits = [
6257
[Features.ClassicVote, Features.GatedErc20],
6358
[Features.ClassicVote, Features.GatedErc1155],
6459
],
65-
allowSubset: true,
6660
type: "gated",
6761
},
6862
{
@@ -71,7 +65,6 @@ export const disputeKits: DisputeKits = [
7165
[Features.ShieldedVote, Features.GatedErc20],
7266
[Features.ShieldedVote, Features.GatedErc1155],
7367
],
74-
allowSubset: true,
7568
type: "gated",
7669
},
7770
];
@@ -86,12 +79,6 @@ function arraysEqual(a: Features[], b: Features[]): boolean {
8679
return normalize(a) === normalize(b);
8780
}
8881

89-
/** Check if `a` is a superset of `b` */
90-
function includesAll(a: Features[], b: Features[]): boolean {
91-
const setA = new Set(a);
92-
return b.every((x) => setA.has(x));
93-
}
94-
9582
/**
9683
* Toggle a feature, ensuring radio behavior per group
9784
* @returns the updated selected features array
@@ -119,10 +106,7 @@ export function toggleFeature(selected: Features[], feature: Features, groups: F
119106
export function findMatchingKits(selected: Features[], kits: DisputeKits): DisputeKit[] {
120107
return kits.filter((kit) =>
121108
kit.featureSets.some(
122-
(set) =>
123-
kit.allowSubset
124-
? includesAll(selected, set) // kit allows subset
125-
: arraysEqual(set, selected) // strict exact match
109+
(set) => arraysEqual(set, selected) // strict exact match
126110
)
127111
);
128112
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const FeatureSelection: React.FC = () => {
5959
if (!defaultKit) return;
6060

6161
// some kits like gated can have two feature sets, one for gatedERC20 and other for ERC1155
62-
if (defaultKit?.allowSubset) {
62+
if (defaultKit?.featureSets.length > 0) {
6363
if ((disputeData?.disputeKitData as IGatedDisputeData)?.isERC1155) {
6464
// defaultKit.featureSets[0][0] - is either Classic or Shutter
6565
setSelected([defaultKit.featureSets[0][0], Features.GatedErc1155]);
@@ -141,7 +141,7 @@ const FeatureSelection: React.FC = () => {
141141
<>
142142
{GroupsUI[groupName]({
143143
children: (
144-
<Fragment>
144+
<Fragment key={groupName}>
145145
{features.map((feature) =>
146146
FeatureUIs[feature]({
147147
name: groupName,

0 commit comments

Comments
 (0)