Skip to content

Commit

Permalink
fix static unbonding periods cosmos (#5669)
Browse files Browse the repository at this point in the history
  • Loading branch information
hedi-edelbloute authored Dec 11, 2023
1 parent 554f409 commit aa110c2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
6 changes: 6 additions & 0 deletions .changeset/neat-emus-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": minor
"live-mobile": minor
---

Fix cosmos static unbonding periods
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import DelegateIcon from "~/renderer/icons/Delegate";
import TableContainer, { TableHeader } from "~/renderer/components/TableContainer";
import { CosmosAccount } from "@ledgerhq/live-common/families/cosmos/types";
import { DelegationActionsModalName } from "../modals";
import cryptoFactory from "@ledgerhq/live-common/families/cosmos/chain/chain";

const Wrapper = styled(Box).attrs(() => ({
p: 3,
Expand Down Expand Up @@ -97,6 +98,7 @@ const Delegation = ({ account }: { account: CosmosAccount }) => {
const hasDelegations = delegations.length > 0;
const hasUnbondings = unbondings && unbondings.length > 0;
const hasRewards = _pendingRewardsBalance.gt(0);
const crypto = cryptoFactory(account.currency.id);
return (
<>
<TableContainer mb={6}>
Expand Down Expand Up @@ -214,7 +216,12 @@ const Delegation = ({ account }: { account: CosmosAccount }) => {
titleProps={{
"data-e2e": "title_Undelegation",
}}
tooltip={<Trans i18nKey="cosmos.undelegation.headerTooltip" />}
tooltip={
<Trans
i18nKey="cosmos.undelegation.headerTooltip"
values={{ numberOfDays: crypto.unbondingPeriod }}
/>
}
/>
<UnbondingHeader />
{mappedUnbondings.map((delegation, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import Alert from "~/renderer/components/Alert";
import LinkWithExternalIcon from "~/renderer/components/LinkWithExternalIcon";
import { urls } from "~/config/urls";
import { openURL } from "~/renderer/linking";
import cryptoFactory from "@ledgerhq/live-common/families/cosmos/chain/chain";

const RewardImg = styled.img.attrs(() => ({
src: Rewards,
}))`
Expand All @@ -20,6 +22,7 @@ const RewardImg = styled.img.attrs(() => ({
`;
export default function StepStarter({ account, transaction }: StepProps) {
invariant(account && account.cosmosResources && transaction, "account and transaction required");
const crypto = cryptoFactory(account.currency.id);
return (
<Box flow={4}>
<TrackPage
Expand All @@ -43,7 +46,10 @@ export default function StepStarter({ account, transaction }: StepProps) {
lineHeight: 1.57,
}}
>
<Trans i18nKey="cosmos.redelegation.flow.steps.starter.description" />
<Trans
i18nKey="cosmos.redelegation.flow.steps.starter.description"
values={{ numberOfDays: crypto.unbondingPeriod }}
/>
</Text>
</Box>
<Alert type="primary">
Expand Down
4 changes: 2 additions & 2 deletions apps/ledger-live-desktop/static/i18n/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -3073,7 +3073,7 @@
"steps": {
"starter": {
"title": "Redelegation",
"description": "Use redelegation to easily change from one validator to another. But if you change your mind again, you will then have to wait because redelegation triggers a 21-day timelock.",
"description": "Use redelegation to easily change from one validator to another. But if you change your mind again, you will then have to wait because redelegation triggers a {{ numberOfDays }}-day timelock.",
"warning": "Choose your validator wisely: Part of your delegated assets may be irrevocably lost if the validator does not behave appropriately. You can have a maximum of <0>7 pending redelegations</0>.",
"howDelegationWorks": "How delegation works?"
},
Expand Down Expand Up @@ -3102,7 +3102,7 @@
},
"undelegation": {
"header": "Undelegation(s)",
"headerTooltip": "Available after the 21-day timelock",
"headerTooltip": "Available after the {{numberOfDays}}-day timelock",
"inactiveTooltip": "Undelegated amounts do not generate rewards.",
"flow": {
"title": "Undelegate assets",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTheme } from "@react-navigation/native";
import LText from "../../components/LText";
import { DataRow, TextValueField } from "../../components/ValidateOnDeviceDataRow";
import Info from "../../icons/Info";
import cryptoFactory from "@ledgerhq/live-common/families/cosmos/chain/chain";

type FieldProps = {
account: Account;
Expand Down Expand Up @@ -66,10 +67,11 @@ function CosmosSourceValidatorNameField({
return <TextValueField label={field.label} value={validator?.name ?? sourceValidator} />;
}

function Warning({ transaction }: FieldProps) {
function Warning({ account, transaction }: FieldProps) {
invariant(transaction.family === "cosmos", "cosmos transaction");
const { colors } = useTheme();
const { t } = useTranslation();
const crypto = cryptoFactory(account.currency.id);

switch (transaction.mode) {
case "redelegate":
Expand All @@ -79,7 +81,9 @@ function Warning({ transaction }: FieldProps) {
<DataRow>
<Info size={22} color={colors.live} />
<LText semiBold style={[styles.text, styles.infoText]} color="live" numberOfLines={3}>
{t(`ValidateOnDevice.infoWording.cosmos.${transaction.mode}`)}
{t(`ValidateOnDevice.infoWording.cosmos.${transaction.mode}`, {
numberOfDays: crypto.unbondingPeriod,
})}
</LText>
</DataRow>
);
Expand Down
9 changes: 2 additions & 7 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -5936,13 +5936,8 @@
"claimReward": "Rewards can be claimed every 24 hours.",
"cosmos": {
"claimReward": "If the selected validator has pending rewards, they will automatically be claimed.",
"redelegate": "You will have to wait 21 days for undelegated assets to return to the available balance.",
"undelegate": "You will have to wait 21 days for undelegated assets to return to the available balance."
},
"osmosis": {
"claimReward": "If the selected validator has pending rewards, they will automatically be claimed.",
"redelegate": "You will have to wait 14 days for undelegated assets to return to the available balance.",
"undelegate": "You will have to wait 14 days for undelegated assets to return to the available balance."
"redelegate": "You will have to wait {{numberOfDays}} days for undelegated assets to return to the available balance.",
"undelegate": "You will have to wait {{numberOfDays}} days for undelegated assets to return to the available balance."
},
"lending": "Verify the operation details on your device before sending it."
},
Expand Down

0 comments on commit aa110c2

Please sign in to comment.