-
Notifications
You must be signed in to change notification settings - Fork 127
Namadillo: Optimistically updating staking rewards balance #1115
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
Conversation
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.
Nice!
}; | ||
|
||
useTransactionEventListener("Bond.Success", onBalanceUpdate); | ||
useTransactionEventListener("Unbond.Success", onBalanceUpdate); | ||
useTransactionEventListener("Withdraw.Success", onBalanceUpdate); | ||
useTransactionEventListener("Redelegate.Success", onBalanceUpdate); | ||
useTransactionEventListener("ClaimRewards.Success", onBalanceUpdate); | ||
useTransactionEventListener("ClaimRewards.Success", onBalanceUpdate, [ | ||
account, |
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.
nice idea! I'm asking myself if this object changes for whatever reason and if we should use account?.address
instead
@@ -159,3 +160,7 @@ export const createClaimAndStakeTx = async ( | |||
account.address | |||
); | |||
}; | |||
|
|||
export const clearClaimRewards = (accountAddress: string): void => { | |||
queryClient.setQueryData(["claim-rewards", accountAddress], () => ({})); |
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.
Did you try this as invalidateQueries
https://tanstack.com/query/latest/docs/framework/react/guides/query-invalidation ? I think this is the "correct way" to clear queries for react-query
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.
Actually not. I'm overriding the result of the claim-rewards query, so no rewards are available :) . But maybe I can be more explicit on this. Will make a small change before merging
When you claim rewards, the indexer will need to wait for the next block to sync the new amount. This process might take a few seconds, depending on network configuration. This PR sets the available rewards balance to zero as soon as the claim rewards success event gets fired.