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

Integrate Smooth Fee recipient changes #283

Merged
merged 15 commits into from
Jan 24, 2024

Conversation

mateumiralles
Copy link
Contributor

  • Adding stepper on editing FR from selected validators when "Set Dappnode MEV Smoothing Pool Fee Recipient" is checked in ValidatorsList

@mateumiralles mateumiralles requested a review from a team as a code owner January 9, 2024 09:13
@mateumiralles mateumiralles linked an issue Jan 9, 2024 that may be closed by this pull request
packages/ui/src/utils/addresses.ts Outdated Show resolved Hide resolved
@@ -23,3 +23,23 @@ export interface TagSelectOption {
value: Tag;
label: string;
}

export const alertTypes = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are all of these alerts related to Smooth? Maybe we could rename this to smoothAlertTypes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all of them, (successAlert, errorAlert, onlyEditableFeesAlert, feeAlreadySetToAllAlert) are related to the process of changing the FR. Those can appear without checking the join Smooth switch. Would be better to split it in two? (generalAlertTypes and smoothAlertTypes)

const handleSubscriptionClick = async () => {
try {
await updateValidators();
window.open("https://smooth.dappnode.io/", "_blank");
Copy link
Contributor

@Marketen Marketen Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should open https://smooth-goerli.dappnode.io/ if in testnet (prater). These hardcoded URLs could be inside params.ts

};

const handleUnsubscriptionClick = async () => {
window.open("https://smooth.dappnode.io/", "_blank");
Copy link
Contributor

@Marketen Marketen Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should open https://smooth-goerli.dappnode.io/ if in testnet (prater). These hardcoded URLs could be inside params.ts

packages/ui/src/components/ValidatorList/ValidatorList.tsx Outdated Show resolved Hide resolved
packages/ui/src/utils/addresses.ts Outdated Show resolved Hide resolved
const [errorMessage, setErrorMessage] = useState("");
const [successMessage, setSuccessMessage] = useState("");
const [loading, setLoading] = useState(false);
const [isMevSpAddressSelected, setIsMevSpAddressSelected] = useState(false);
const [activeStep, setActiveStep] = React.useState(0);
const [isUnsubUndestood, setIsUnsubUndestood] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood misspelled here

const [isMevSpAddressSelected, setIsMevSpAddressSelected] = useState(false);
const [activeStep, setActiveStep] = React.useState(0);
const [isUnsubUndestood, setIsUnsubUndestood] = useState(false);
const [NonEcdsaValidatorsData, setNonEcdsaValidatorsData] = useState<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A variable should always start with non-capital letters

.map((rowId) => rows[parseInt(rowId.toString())].feeRecipient)
.flat();

console.log(oldFeeRecipients);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These logs should not be included in the prod code

let isAnyGiven = false;
for (const row of selectedRows) {
const withdrawalFormat =
rows[parseInt(row.toString())].withdrawalCredentials.format;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would divide this

);
}

const isAnyFormatValidatorSelected = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say this function needs to be much clearer

return isAnyGiven;
};

const getSmoothValidatorsSelected = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do something like:

const getSmoothValidatorsSelected = (): void => {
  const smoothValidatorsPubkeys = selectedRows
    .map(row => rows[+row].feeRecipient === mevSpAddress ? rows[+row].pubkey : null)
    .filter(pubkey => pubkey !== null);

  setSmoothValidatorsPubkeys(smoothValidatorsPubkeys);
};

(Try it first)

setSmoothValidatorsPubkeys(auxList);
};

const nonEcdsaValidatorsData = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, you can try:

const nonEcdsaValidatorsData = (): void => {
  const filteredValidators = selectedRows
    .map(row => {
      const rowData = rows[+row];
      return rowData.withdrawalCredentials.format !== "ecdsa" 
        ? { pubkey: rowData.pubkey, withdrawalFormat: rowData.withdrawalCredentials.format }
        : null;
    })
    .filter(item => item !== null);

  setNonEcdsaValidatorsData(filteredValidators);
};

You can make any changes, it is just a suggestion


function SubscriptionCard(): JSX.Element {
return (
// TODO: Set proper link to the Dappnode Smoothing Pool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done right?

@@ -9,6 +10,12 @@ export const getSmoothAddressByNetwork = (network: Network) => {
return MEV_SP_ADDRESS_PRATER;
} else if (network == "mainnet") {
return MEV_SP_ADDRESS_MAINNET;
} else if (network == "holesky") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all networks different than mainnet or prater, this should return "null". its easier if you do

export const getSmoothAddressByNetwork = (network: Network) => {
  if (network == "prater") {
    return MEV_SP_ADDRESS_PRATER;
  } else if (network == "mainnet") {
    return MEV_SP_ADDRESS_MAINNET;
  } else {
    return null;
  }
}

since we treat smooth address as null when outside prater or mainnet, there is no need to return error in this method anymore

packages/ui/src/params.ts Outdated Show resolved Hide resolved
@pablomendezroyo pablomendezroyo merged commit 3f2a022 into main Jan 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Smooth Fee recipient changes
4 participants