-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GIX-1890: Check tx fee to disable disburse maturity button (#3329)
# Motivation Check the fee to enable the disburse maturity button. # Changes * DisburseMaturityButton: Change prop to `disabledText`. * Add prop feeE8s to SnsDisburseMaturityButton * Add prop feeE8s to SnsAvailableMaturityItemAction. * Add prop feeE8s to SnsNeuronMaturitySection. * New sns neuron util hasEnoughMaturityToDisburse * Rename hasEnoughMaturityToStakeOrDisburse to hasEnoughMaturityToStake * Use new util `hasEnoughMaturityToDisburse` and new prop `disabledText` in SnsDisburseMaturityButton. * Change copy in "disburse_maturity_disabled_tooltip" i18n key. # Tests * Adapt tests to new props. * Adapt tests to `disabledText` prop name. * Change test case in SnsDisburseMaturityButton.spec to check agains a maturity less than fee. * New test case in SnsAvailableMaturityItemAction # Todos - [ ] Add entry to changelog (if necessary). Not worth an entry. Covered by disburse maturity entry.
- Loading branch information
Showing
14 changed files
with
135 additions
and
46 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
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
18 changes: 15 additions & 3 deletions
18
frontend/src/lib/components/sns-neuron-detail/actions/SnsDisburseMaturityButton.svelte
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 |
---|---|---|
@@ -1,15 +1,27 @@ | ||
<script lang="ts"> | ||
import { hasEnoughMaturityToStakeOrDisburse } from "$lib/utils/sns-neuron.utils"; | ||
import { hasEnoughMaturityToDisburse } from "$lib/utils/sns-neuron.utils"; | ||
import { openSnsNeuronModal } from "$lib/utils/modals.utils"; | ||
import type { SnsNeuron } from "@dfinity/sns"; | ||
import DisburseMaturityButton from "$lib/components/neuron-detail/actions/DisburseMaturityButton.svelte"; | ||
import { replacePlaceholders } from "$lib/utils/i18n.utils"; | ||
import { formatToken } from "$lib/utils/token.utils"; | ||
import { i18n } from "$lib/stores/i18n"; | ||
export let neuron: SnsNeuron; | ||
export let feeE8s: bigint; | ||
let enoughMaturity: boolean; | ||
$: enoughMaturity = hasEnoughMaturityToStakeOrDisburse(neuron); | ||
$: enoughMaturity = hasEnoughMaturityToDisburse({ neuron, feeE8s }); | ||
let disabledText: string | undefined = undefined; | ||
$: disabledText = !enoughMaturity | ||
? replacePlaceholders( | ||
$i18n.neuron_detail.disburse_maturity_disabled_tooltip, | ||
{ $fee: formatToken({ value: feeE8s }) } | ||
) | ||
: undefined; | ||
const showModal = () => openSnsNeuronModal({ type: "disburse-maturity" }); | ||
</script> | ||
|
||
<DisburseMaturityButton {enoughMaturity} on:click={showModal} /> | ||
<DisburseMaturityButton {disabledText} on:click={showModal} /> |
4 changes: 2 additions & 2 deletions
4
frontend/src/lib/components/sns-neuron-detail/actions/SnsStakeMaturityButton.svelte
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
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
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
Oops, something went wrong.