-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build UI for claiming unbonding tokens (#659)
* Account for undelegate claims in txn classifications * Add getters for getting an epoch index * Create an SCT client * Create a getter for a validator identity key from a metadata * Add asIdentityKey getter * Build out undelegateClaim actions * Account for undelegate claims in the planner * Install missing dep * Fix merge conflict issue * Put all claims into one transaction * Remove unnecessary loader call * Fix typo * Account for more errors from tendermint * Make the entire unbonding amount a tooltip * Update deps to take advantage of TransactionPlanner RPC change * Add validatorPenalty to the Staking querier * Add a validatorPenalty method handler to our impl of Staking * Create ActionDetails component * Add getters for undelegate claims * Display undelegate claims * Fix layout issue * Extract Separator component * Tweak comment * Fix bug with loading proving key * Extract a helper * Put staking slice in its own directory and extract a helper * Fix Rust tests * Run delegate script synchronously to avoid conflicts etc. * Polyfill Array.fromAsync in our test environment * Fix mock paths * Revert "Polyfill Array.fromAsync in our test environment" This reverts commit bb27e46.
- Loading branch information
1 parent
29d7b2a
commit f06c2a8
Showing
37 changed files
with
641 additions
and
106 deletions.
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.