-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Wallet validator staking #6825
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
ad4e711
to
4c5757f
Compare
💳 Wallet Extension has been built, you can download the packaged extension here: https://github.com/MystenLabs/sui/actions/runs/3707482672#artifacts |
The wallet build doesn't seem to have the Staking feature working. |
@mystie711 The PR is broken into smaller chunks for review. So this PR has the detail and landing section. |
850b376
to
1453e1a
Compare
There was a problem hiding this 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.
@@ -67,3 +67,8 @@ textarea { | |||
textarea { | |||
font-family: InterVariable, sans-serif; | |||
} | |||
|
|||
#floating-ui-root { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
6a953cb
to
a856081
Compare
@mystie711 see the video and image update |
f8c69a4
to
cb788a9
Compare
'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', |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
apps/wallet/src/ui/app/staking/validator-detail/ValidatorDetailCard.tsx
Outdated
Show resolved
Hide resolved
size: 'heading4' | 'body'; | ||
} | ||
|
||
function StakeAmount({ |
There was a problem hiding this comment.
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.
@Jibz1 could you upload an updated walkthrough video? |
4b033f4
to
e6b22c6
Compare
variant="heading4" | ||
/> | ||
</CardItem> | ||
{/* TODO: show the actual Rewards Collected value https://github.com/MystenLabs/sui/issues/3605 */} |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why memo?
There was a problem hiding this 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
There was a problem hiding this 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} |
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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?
76647d8
to
ced2111
Compare
Screen.Recording.2022-12-20.at.10.24.26.AM.mov
adjusted
Unstake All SUI
position