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

Wallet validator staking #6825

Merged
merged 54 commits into from
Jan 14, 2023
Merged

Wallet validator staking #6825

merged 54 commits into from
Jan 14, 2023

Conversation

Jibz1
Copy link
Contributor

@Jibz1 Jibz1 commented Dec 15, 2022

  • Combined previous PRs
Screen.Recording.2022-12-20.at.10.24.26.AM.mov

adjusted Unstake All SUI position
Screenshot 2022-12-20 at 10 27 10 AM

@vercel
Copy link

vercel bot commented Dec 15, 2022

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

3 Ignored Deployments
Name Status Preview Comments Updated
explorer ⬜️ Ignored (Inspect) Jan 14, 2023 at 1:11AM (UTC)
explorer-storybook ⬜️ Ignored (Inspect) Jan 14, 2023 at 1:11AM (UTC)
wallet-adapter ⬜️ Ignored (Inspect) Jan 14, 2023 at 1:11AM (UTC)

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from ad4e711 to 4c5757f Compare December 15, 2022 13:21
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2022

💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/3707482672#artifacts

@Jibz1 Jibz1 marked this pull request as ready for review December 15, 2022 13:30
@mystie711
Copy link
Collaborator

The wallet build doesn't seem to have the Staking feature working.
Is there a way to check it out?

@Jibz1
Copy link
Contributor Author

Jibz1 commented Dec 15, 2022

The wallet build doesn't seem to have the Staking feature working.
Is there a way to check it out?

@mystie711 The PR is broken into smaller chunks for review. So this PR has the detail and landing section.

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from 850b376 to 1453e1a Compare December 15, 2022 19:57
Copy link
Contributor

@Jordan-Mysten Jordan-Mysten left a comment

Choose a reason for hiding this comment

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

Some small things. In general this is reminding me that we really need to invest more in good base UI components for the wallet. So much of this UI is built ad-hoc which will make it a pain to keep visually updated.

apps/wallet/tailwind.config.js Show resolved Hide resolved
@@ -67,3 +67,8 @@ textarea {
textarea {
font-family: InterVariable, sans-serif;
}

#floating-ui-root {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need to set this when using floating UI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes floating UI appears behind the modal.

apps/wallet/src/ui/app/staking/home/Stake.tsx Outdated Show resolved Hide resolved
apps/wallet/src/ui/app/staking/home/Stake.tsx Outdated Show resolved Hide resolved
apps/wallet/src/ui/app/staking/validator-detail/index.tsx Outdated Show resolved Hide resolved
apps/wallet/src/ui/app/staking/validator-detail/index.tsx Outdated Show resolved Hide resolved
apps/wallet/src/ui/app/staking/validator-detail/index.tsx Outdated Show resolved Hide resolved
apps/wallet/src/ui/app/staking/validator-detail/index.tsx Outdated Show resolved Hide resolved
@mystie711
Copy link
Collaborator

stake_and_Earn_SUI

@mystie711
Copy link
Collaborator

Stake___Earn_SUI

@mystie711
Copy link
Collaborator

Please add a video wherever relevant. It's hard to provide feedback on some interaction and visual details without it. Happy to not have video as requirement if you pull me into Slack huddle sessions or just share it with me there.

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from 6a953cb to a856081 Compare December 20, 2022 15:18
@Jibz1
Copy link
Contributor Author

Jibz1 commented Dec 20, 2022

@mystie711 see the video and image update

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from f8c69a4 to cb788a9 Compare January 6, 2023 21:00
'sui-dark': 'text-sui-dark',
sui: 'text-sui',
'sui-light': 'text-sui-light',
steel: 'text-steel',
'steel-dark': 'text-steel-dark',
'steel-darker': 'text-steel-darker',
'hero-dark': 'text-hero-dark',
'success-dark': 'text-success-dark',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also add these changes to Text over in the explorer so that these components are in-sync?

const accountAddress = useAppSelector(({ account }) => account.address);
const { data, isLoading } = useGetObject(STATE_OBJECT);

const validatorsData =
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think this probably would be a better fit for living in the ValidatorsCard itself vs having it fetched here then passed down. The only thing that it's actually used for here is conditional rendering of ValidatorsCard vs SelectValidatorCard, but you could even do that in the ValidatorCard itself.

weight="semibold"
color="steel-darker"
>
STAKING ON {numOfValidators}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't all-caps any copy, use uppercase variants (which I think this already is.

size: 'heading4' | 'body';
}

function StakeAmount({
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love this component, I feel like instead of all of the props there probably are just a few known variations (from looking at usage):

  • body / steel-darker / steel-darker
  • heading4 / gray-90 / steel
  • heading4 / gray-60 / gray-60 (although in the wallet figma this one actually looks like the symbol color is wrong and actually should be steel, and it looks like the earned is only gray-60 because the value is 0, which we can actually solve in the component itself by inspecting balance)

Assuming we cut this down to two, I think the prop interface really should be something closer to:

interface props {
  balance: bigint;
  variant: 'heading' | 'body'
}

I also don't think you need this to accept type, since it's statically known for staking.

@mystie711
Copy link
Collaborator

@Jibz1 could you upload an updated walkthrough video?

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from 4b033f4 to e6b22c6 Compare January 12, 2023 00:58
variant="heading4"
/>
</CardItem>
{/* TODO: show the actual Rewards Collected value https://github.com/MystenLabs/sui/issues/3605 */}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this actually still relevant? I thought we could actually compute the rewards now?

>
Staking on {stakeValidators.length}
{stakeValidators.length > 1
? ' VALIDATORS'
Copy link
Contributor

Choose a reason for hiding this comment

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

Caps issues


const STAKE_DELEGATOR_STALE_TIME = 5 * 1000;

const getDelegatedStakes = async (
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just add SDK support instead of doing this custom JSON RPC method?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can also push devx to do this.


// keeping the query parent key the same to invalidate all related queries
return useQuery(['validator', 'all'], async () => {
const response = await fetch(rpcEndPoint, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, can we add this to the SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the goal. I will create a separate Jira task for all this

);
}

export default memo(StakeAmount);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why memo?

Copy link
Contributor

@Jordan-Mysten Jordan-Mysten left a comment

Choose a reason for hiding this comment

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

There's some follow up needed but approving to unblock

Copy link
Contributor

@pchrysochoidis pchrysochoidis left a comment

Choose a reason for hiding this comment

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

Left a few comments and seems there are a few components that are very similar (we should try to minimise the duplication whenever possible).

Rather than that lgtm.

</Text>
<Text
variant="body"
weight="medium"
color="steel-darker"
>
{gasBudgetEstimation} {GAS_SYMBOL}
{gasBudgetEstimation} {symbol}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be GAS_SYMBOL as it was or use the symbol from here

const [gasBudgetEstimation] = useFormatCoin(
        DEFAULT_GAS_BUDGET_FOR_STAKE,	        DEFAULT_GAS_BUDGET_FOR_STAKE,
        SUI_TYPE_ARG	        SUI_TYPE_ARG
    );	    );
    ```

);
}, [delegationData]);

const apy = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we use apps/wallet/src/ui/app/staking/calculateAPY.ts here? it's the same thing right?

@@ -46,12 +46,12 @@ export function SelectValidatorCard() {
} = av.fields.delegation_staking_pool.fields;

const num_epochs_participated =
validatorsData.epoch - starting_epoch;
+validatorsData.epoch - +starting_epoch;

const APY = Math.pow(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this as well, why not use apps/wallet/src/ui/app/staking/calculateAPY.ts?

@Jibz1 Jibz1 force-pushed the wallet-validator-staking branch from 76647d8 to ced2111 Compare January 14, 2023 00:23
@Jibz1 Jibz1 merged commit 3acef24 into main Jan 14, 2023
@Jibz1 Jibz1 deleted the wallet-validator-staking branch January 14, 2023 01:20
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.

4 participants