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

Build UI for claiming unbonding tokens #659

Merged
merged 31 commits into from
Mar 12, 2024

Conversation

jessepinho
Copy link
Contributor

@jessepinho jessepinho commented Mar 2, 2024

Initial UI for claiming unbonding tokens.

undelegate-claim.mov

🚨 This will automatically attempt to claim all unbonding tokens that the current address holds, even if some of them are not yet eligible for claiming. In that case, an error will show up, saying that we're not yet in the right epoch for claiming unbonding tokens. At the moment, there's no RPC method to detect which unbonding tokens are eligible for claiming and which aren't . When there is, we can automatically select just the eligible tokens and claim those. Until then, we'll just cross our fingers :D

In this PR

  • Create an undelegateClaim action in the Staking slice, as well as in the WASM planner.
  • Create a client for the SCT service (to get the current epoch).
  • Implement the ValidatorPenalty method of StakingService, which is required for an undelegation claim.
  • Fix a bug with how proving keys were being loaded.
  • Move staking slice into its own directory.

Closes #655

@jessepinho jessepinho force-pushed the jessepinho/web-588-unbonding-tokens branch from 4729534 to 8f90a65 Compare March 4, 2024 20:41
Base automatically changed from jessepinho/web-588-unbonding-tokens to main March 4, 2024 20:56
@jessepinho jessepinho force-pushed the jessepinho/web-655-undelegate-claims branch 10 times, most recently from 09def59 to 0661d14 Compare March 5, 2024 22:12
package.json Outdated
Comment on lines 21 to 22
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.7.2-20240304191729-7e25957407d1.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240304191729-7e25957407d1.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating to the version that includes undelegation claims in TransactionPlannerRequest

{unbondingTokens?.tokens.map(token => (
<ValueViewComponent key={getDisplayDenomFromView(token)} view={token} />
))}
<TooltipProvider>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All I did here was make the entire unbonding amount ValueViewComponent the tooltip trigger, rather than having the little (i) icon as the trigger

Comment on lines +13 to +14
'cannot claim unbonding tokens before the end epoch',
'undelegation was prepared for next epoch',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to this PR, see penumbra-zone/penumbra#3961.

These messages are actually in the core repo — not Tendermint itself. Thus, they can (and probably should) be changed to include a machine-readable error code, rather than us having to parse human-readable text.

@jessepinho jessepinho force-pushed the jessepinho/web-655-undelegate-claims branch 4 times, most recently from 0e494ae to 03d9871 Compare March 8, 2024 21:39
* </ActionDetails>
* ```
*/
export const ActionDetails = ({ children }: { children: ReactNode }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@@ -13,7 +13,7 @@ export const ViewBox = ({ label, visibleContent }: ViewBoxProps) => {
return (
<div
className={cn(
'bg-background px-4 pt-3 pb-4 rounded-lg border flex flex-col gap-1 break-all',
'bg-background px-4 pt-3 pb-4 rounded-lg border flex flex-col gap-1 break-all overflow-hidden',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes an issue where the view box would stretch beyond its parents bounds if its children were too big.

penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.2", package = "penumbra-stake", default-features = false }
penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.2", package = "penumbra-tct" }
penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.2", package = "penumbra-transaction", default-features = false }
penumbra-asset = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.68.3", package = "penumbra-asset" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to get the latest version of TransactionPlannerRequest, which now includes undelegation claims

@jessepinho jessepinho force-pushed the jessepinho/web-655-undelegate-claims branch from 024cbbb to b0c1e3e Compare March 8, 2024 23:25
@@ -59,6 +59,6 @@ export const buildActionParallel = async (
const loadProvingKey = async (actionType: ActionType) => {
const keyType = provingKeys[actionType];
if (!keyType) return;
const keyBin = (await fetch(`bin/${actionType}_pk.bin`)).arrayBuffer();
const keyBin = (await fetch(`bin/${keyType}_pk.bin`)).arrayBuffer();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixes a bug where the proving key wasn't being fetched correctly. We didn't notice this earlier because actionType and keyType are the same for the more common actions, but I noticed it while working on undelegation claims because the undelegateClaim action uses a convert key.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh! Good catch.

@@ -279,6 +284,50 @@ export const createStakingSlice = (): SliceCreator<StakingSlice> => (set, get) =
});
}
},
undelegateClaim: async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These state methods that build and submit a transaction, as well as manage toasts, are quite repetitive. I want to DRY them up, but this PR is already pretty huge (sorry), so I'll do that in a future PR.

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 create an issue for that 🙏 ?

@jessepinho jessepinho marked this pull request as ready for review March 9, 2024 02:10
@jessepinho jessepinho changed the title WIP: Build UI for claiming unbonding tokens Build UI for claiming unbonding tokens Mar 9, 2024
@jessepinho jessepinho requested review from grod220 and turbocrime March 9, 2024 02:10
Copy link
Contributor

@grod220 grod220 left a comment

Choose a reason for hiding this comment

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

Good job!

At the moment, there's no RPC method to detect which unbonding tokens are eligible for claiming and which aren't

Can you create an issue for this and add it to the staking tracking issue?

@@ -279,6 +284,50 @@ export const createStakingSlice = (): SliceCreator<StakingSlice> => (set, get) =
});
}
},
undelegateClaim: 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 create an issue for that 🙏 ?

@@ -59,6 +59,6 @@ export const buildActionParallel = async (
const loadProvingKey = async (actionType: ActionType) => {
const keyType = provingKeys[actionType];
if (!keyType) return;
const keyBin = (await fetch(`bin/${actionType}_pk.bin`)).arrayBuffer();
const keyBin = (await fetch(`bin/${keyType}_pk.bin`)).arrayBuffer();
Copy link
Contributor

Choose a reason for hiding this comment

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

oh! Good catch.

@jessepinho jessepinho force-pushed the jessepinho/web-655-undelegate-claims branch from 2ce6a77 to 4552ea7 Compare March 12, 2024 14:15
@jessepinho
Copy link
Contributor Author

@grod:

At the moment, there's no RPC method to detect which unbonding tokens are eligible for claiming and which aren't

Can you create an issue for this and add it to the staking tracking issue?

I believe @erwanor was already working on this... @erwanor , is there a ticket for this RPC method?

@jessepinho jessepinho merged commit f06c2a8 into main Mar 12, 2024
6 checks passed
@jessepinho jessepinho deleted the jessepinho/web-655-undelegate-claims branch March 12, 2024 14:25
@jessepinho
Copy link
Contributor Author

@grod220 Nevermind — just created the ticket after discussing with @erwanor . penumbra-zone/penumbra#4006

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.

Create UI for undelegate claim actions
2 participants