Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Breaking change ] Remove fee recipient as global env #1691

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ import Button from "components/Button";
import { disclaimer } from "../data";
import Loading from "components/Loading";
import { responseInterface } from "swr";
import { Alert, Form } from "react-bootstrap";
import { Alert } from "react-bootstrap";
import "./columns.scss";
import { AppContext } from "App";
import LaunchpadValidators from "./launchpad/LaunchpadValidators";
import { FaEthereum } from "react-icons/fa";
import Input from "components/Input";
import { Network } from "@dappnode/types";
import { useStakerConfig } from "./useStakerConfig";
import { AlertDismissible } from "components/AlertDismissible";
Expand All @@ -45,11 +44,8 @@ export default function StakerNetwork<T extends Network>({
showLaunchpadValidators,
setShowLaunchpadValidators,
allStakerItemsOk,
feeRecipientError,
reqStatus,
setReqStatus,
newFeeRecipient,
setNewFeeRecipient,
newExecClient,
setNewExecClient,
newConsClient,
Expand Down Expand Up @@ -108,7 +104,6 @@ export default function StakerNetwork<T extends Network>({
api.stakerConfigSet({
stakerConfig: {
network,
feeRecipient: newFeeRecipient,
executionClient:
newExecClient?.status === "ok"
? { ...newExecClient, data: undefined }
Expand Down Expand Up @@ -177,21 +172,6 @@ export default function StakerNetwork<T extends Network>({

<p>{description}</p>

<>
<Input
value={newFeeRecipient || ""}
onValueChange={setNewFeeRecipient}
isInvalid={Boolean(feeRecipientError)}
prepend="Default Fee Recipient"
placeholder="Default fee recipient to be used as a fallback in case you have not set a fee recipient for a validator"
/>
{newFeeRecipient && feeRecipientError && (
<Form.Text className="text-danger" as="span">
{feeRecipientError}
</Form.Text>
)}
</>

<Row className="staker-network">
<Col>
<SubTitle>Execution Clients</SubTitle>
Expand Down Expand Up @@ -302,15 +282,12 @@ export default function StakerNetwork<T extends Network>({
}
setNewConfig={setNewConfig}
setShowLaunchpadValidators={setShowLaunchpadValidators}
setNewFeeRecipient={setNewFeeRecipient}
newFeeRecipient={newFeeRecipient}
setNewExecClient={setNewExecClient}
setNewConsClient={setNewConsClient}
setNewMevBoost={setNewMevBoost}
newExecClient={newExecClient}
newConsClient={newConsClient}
newMevBoost={newMevBoost}
feeRecipientError={feeRecipientError}
/>
)}
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,24 @@ import MevBoost from "../columns/MevBoost";
import { StakerConfigGetOk, StakerItemOk } from "@dappnode/common";
import { disclaimer } from "pages/stakers/data";
import RenderMarkdown from "components/RenderMarkdown";
import { InputForm } from "components/InputForm";
import Input from "components/Input";
import { Network } from "@dappnode/types";

export const launchpadSteps = <T extends Network>({
network,
stakerConfig,
setNewConfig,
setShowLaunchpadValidators,
setNewFeeRecipient,
newFeeRecipient,
setNewExecClient,
newExecClient,
setNewConsClient,
newConsClient,
setNewMevBoost,
newMevBoost,
feeRecipientError
newMevBoost
}: {
network: T;
stakerConfig: StakerConfigGetOk<T>;
setNewConfig(isLaunchpad: boolean): Promise<void>;
setShowLaunchpadValidators: React.Dispatch<React.SetStateAction<boolean>>;
setNewFeeRecipient: React.Dispatch<React.SetStateAction<string>>;
newFeeRecipient: string;
setNewExecClient: React.Dispatch<
React.SetStateAction<StakerItemOk<T, "execution"> | undefined>
>;
Expand All @@ -43,7 +36,6 @@ export const launchpadSteps = <T extends Network>({
setNewMevBoost: React.Dispatch<
React.SetStateAction<StakerItemOk<T, "mev-boost"> | undefined>
>;
feeRecipientError: string | null;
}) => [
{
title: "Create the validator keystores and do the deposit",
Expand Down Expand Up @@ -105,28 +97,6 @@ export const launchpadSteps = <T extends Network>({
</div>
)
},
{
title: "Set the default Fee Recipient",
description:
"Set the default fee recipient for the validator(s). The fee recipient is the address that will receive the validator's fees. You can change it at any time.",
component: (
<InputForm
fields={[
{
label: `Default Fee Recipient`,
labelId: "new-feeRecipient",
name: "new-fee-recipient",
autoComplete: "new-feeRecipient",
value: newFeeRecipient || "",
onValueChange: setNewFeeRecipient,
error: feeRecipientError,
placeholder:
"Default fee recipient to be used as a fallback in case you have not set a fee recipient for a validator"
}
]}
/>
)
},
{
title: "Enable MEV boost and select its relays",
description:
Expand All @@ -146,13 +116,6 @@ export const launchpadSteps = <T extends Network>({
description: `This is a summary of the staker configuration you have selected. If you are happy with it, click on the "next" button.`,
component: (
<div className="launchpad-summary">
{newFeeRecipient && (
<Input
aria-disabled={true}
value={newFeeRecipient}
onValueChange={() => {}}
/>
)}
{newExecClient && (
<ExecutionClient<T>
executionClient={newExecClient}
Expand Down Expand Up @@ -189,7 +152,7 @@ export const launchpadSteps = <T extends Network>({
</div>
<Button
variant="dappnode"
disabled={!newExecClient || !newConsClient || !newFeeRecipient}
disabled={!newExecClient || !newConsClient}
onClick={() => {
setNewConfig(true);
setShowLaunchpadValidators(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,17 @@ export default function LaunchpadValidators<T extends Network>({
stakerConfig,
setNewConfig,
setShowLaunchpadValidators,
setNewFeeRecipient,
newFeeRecipient,
setNewExecClient,
newExecClient,
setNewConsClient,
newConsClient,
setNewMevBoost,
newMevBoost,
feeRecipientError
newMevBoost
}: {
network: T;
stakerConfig: StakerConfigGetOk<T>;
setNewConfig(isLaunchpad: boolean): Promise<void>;
setShowLaunchpadValidators: React.Dispatch<React.SetStateAction<boolean>>;
setNewFeeRecipient: React.Dispatch<React.SetStateAction<string>>;
newFeeRecipient: string;
setNewExecClient: React.Dispatch<
React.SetStateAction<StakerItemOk<T, "execution"> | undefined>
>;
Expand All @@ -39,7 +34,6 @@ export default function LaunchpadValidators<T extends Network>({
setNewMevBoost: React.Dispatch<
React.SetStateAction<StakerItemOk<T, "mev-boost"> | undefined>
>;
feeRecipientError: string | null;
}) {
const [stepIndex, setStepIndex] = useState(0);
const [nextEnabled, setNextEnabled] = useState(false);
Expand All @@ -51,30 +45,21 @@ export default function LaunchpadValidators<T extends Network>({
};

useEffect(() => {
if (
newExecClient &&
newConsClient &&
newFeeRecipient &&
!Boolean(feeRecipientError)
)
setNextEnabled(true);
if (newExecClient && newConsClient) setNextEnabled(true);
else setNextEnabled(false);
}, [newExecClient, newConsClient, newFeeRecipient, feeRecipientError]);
}, [newExecClient, newConsClient]);

const steps = launchpadSteps<T>({
network,
stakerConfig,
setNewConfig,
setShowLaunchpadValidators,
setNewFeeRecipient,
newFeeRecipient,
setNewExecClient,
newExecClient,
setNewConsClient,
newConsClient,
setNewMevBoost,
newMevBoost,
feeRecipientError
newMevBoost
});

const currentStep = steps[stepIndex];
Expand Down
Loading
Loading