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

Disable delegation for validators, groups and their signers #135

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

shazarre
Copy link
Contributor

This PR disables option to delegate when connected account is either validator or a group (or a vote signer for any of the two). Otherwise allowing to call the contract anyway was resulting in an error and bad experience.

Now - if delegation is not possible - the delegation button will be disabled and the user will be informed about this as per the screenshot:

Screenshot 2025-01-10 at 13 53 09

as opposed to state where delegation is possible:

Screenshot 2025-01-10 at 13 54 11

Fixes #110

@shazarre shazarre requested a review from a team as a code owner January 10, 2025 13:04
Copy link

vercel bot commented Jan 10, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
celo-mondo ✅ Ready (Inspect) Visit Preview Jan 13, 2025 11:49am

@shazarre shazarre self-assigned this Jan 10, 2025
@@ -43,7 +43,9 @@ export const wagmiConfig = createConfig({
chains: [config.chain],
connectors,
transports: {
[celo.id]: fallback([http(config.chain.rpcUrls.default.http[0]), http(infuraRpcUrl)]),
[celo.id]: fallback([http(config.chain.rpcUrls.default.http[0]), http(infuraRpcUrl)], {
rank: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to pick the currently best provider as per documentation

isAccountResult.isLoading || isValidatorResult.isLoading || isValidatorGroupResult.isLoading,
refetch: () =>
Promise.all([
isAccountResult.refetch,
Copy link
Member

Choose a reason for hiding this comment

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

dont these need to be called?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's correct, they need to be recalled and probably forward the options

    refetch: (options) =>
      Promise.all([
        isAccountResult.refetch(options),

onClick={() => showTxModal()}
>{`️🗳️ Delegate voting power`}</SolidButton>
{(isValidator || isValidatorGroup) && (
Copy link
Member

Choose a reason for hiding this comment

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

UI guy hat on:

We have another red text that can also occur. but that one is a warning whereas this one is a hard NO. It is also theoretically possible for both to show and take up a lot of space.

IDEA:

dont disable here. rather allow delegate modal to open and then display then disable the button in the modal and dislay this explanation in the white blank space above button.

Screenshot 2025-01-10 at 2 20 03 PM

address: Addresses.Validators,
abi: validatorsABI,
functionName: 'isValidator',
args: [addressOrVoteSigner || ZERO_ADDRESS],
query: { enabled: !!addressOrVoteSigner },
});

const isValidatorGroupResult = useReadContract({
const isValidatorGroupOrVoteSignerResult = useReadContract({
Copy link
Member

Choose a reason for hiding this comment

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

nit: slightly prefer the old name. voteSigners in general CAN Delegate just not those who sign for validators/groups.

but i could have a locked gold contract that and add a signer that can vote o proposals.

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.

Failing to delegate
3 participants