-
Notifications
You must be signed in to change notification settings - Fork 21
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
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
81bddf1
Account for undelegate claims in txn classifications
jessepinho 979fa0d
Add getters for getting an epoch index
jessepinho 7fa5ec8
Create an SCT client
jessepinho 247ad26
Create a getter for a validator identity key from a metadata
jessepinho a2c7569
Add asIdentityKey getter
jessepinho 930f30c
Build out undelegateClaim actions
jessepinho 335a391
Account for undelegate claims in the planner
jessepinho 42c73d6
Install missing dep
jessepinho a3f1f54
Fix merge conflict issue
jessepinho 74ff78a
Put all claims into one transaction
jessepinho 045d6f8
Remove unnecessary loader call
jessepinho d647e68
Fix typo
jessepinho 7ffce35
Account for more errors from tendermint
jessepinho a5f1343
Make the entire unbonding amount a tooltip
jessepinho b23c832
Update deps to take advantage of TransactionPlanner RPC change
jessepinho 444b630
Add validatorPenalty to the Staking querier
jessepinho 45fd748
Add a validatorPenalty method handler to our impl of Staking
jessepinho a45c3bc
Create ActionDetails component
jessepinho d1b3ba3
Add getters for undelegate claims
jessepinho abe99e7
Display undelegate claims
jessepinho 0e67178
Fix layout issue
jessepinho 50027a5
Extract Separator component
jessepinho 99fec08
Tweak comment
jessepinho c5c3211
Fix bug with loading proving key
jessepinho ca1b118
Extract a helper
jessepinho 51965f5
Put staking slice in its own directory and extract a helper
jessepinho 2173cf5
Fix Rust tests
jessepinho 5568c61
Run delegate script synchronously to avoid conflicts etc.
jessepinho 07ad652
Polyfill Array.fromAsync in our test environment
jessepinho 035a065
Fix mock paths
jessepinho 4552ea7
Revert "Polyfill Array.fromAsync in our test environment"
jessepinho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/minifront/src/state/staking/assemble-undelegate-claim-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { ValueView } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/asset/v1/asset_pb'; | ||
import { | ||
TransactionPlannerRequest_UndelegateClaim, | ||
TransactionPlannerRequest, | ||
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; | ||
import { | ||
getStartEpochIndexFromValueView, | ||
getValidatorIdentityKeyAsBech32StringFromValueView, | ||
asIdentityKey, | ||
getAmount, | ||
} from '@penumbra-zone/getters'; | ||
import { stakeClient, viewClient, sctClient } from '../../clients'; | ||
|
||
const getUndelegateClaimPlannerRequest = | ||
(endEpochIndex: bigint) => async (unbondingToken: ValueView) => { | ||
const startEpochIndex = getStartEpochIndexFromValueView(unbondingToken); | ||
const validatorIdentityKeyAsBech32String = | ||
getValidatorIdentityKeyAsBech32StringFromValueView(unbondingToken); | ||
const identityKey = asIdentityKey(validatorIdentityKeyAsBech32String); | ||
|
||
const { penalty } = await stakeClient.validatorPenalty({ | ||
startEpochIndex, | ||
endEpochIndex, | ||
identityKey, | ||
}); | ||
|
||
return new TransactionPlannerRequest_UndelegateClaim({ | ||
validatorIdentity: identityKey, | ||
startEpochIndex, | ||
penalty, | ||
unbondingAmount: getAmount(unbondingToken), | ||
}); | ||
}; | ||
|
||
export const assembleUndelegateClaimRequest = async ({ | ||
account, | ||
unbondingTokens, | ||
}: { | ||
account: number; | ||
unbondingTokens: ValueView[]; | ||
}) => { | ||
const { fullSyncHeight } = await viewClient.status({}); | ||
const { epoch } = await sctClient.epochByHeight({ height: fullSyncHeight }); | ||
const endEpochIndex = epoch?.index; | ||
if (!endEpochIndex) return; | ||
|
||
return new TransactionPlannerRequest({ | ||
undelegationClaims: await Promise.all( | ||
unbondingTokens.map(getUndelegateClaimPlannerRequest(endEpochIndex)), | ||
), | ||
source: { account }, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"test": "vitest run" | ||
}, | ||
"dependencies": { | ||
"@penumbra-zone/constants": "workspace:*", | ||
"bech32": "^2.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
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 create an issue for that 🙏 ?