From 4d6b516583a2de5bd6ec0377d84d66d758a89b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Wed, 9 Oct 2024 15:03:25 +0200 Subject: [PATCH 1/2] Update screens mentioning stake cooldown --- .../ConfirmTransfer/TransactionMessage.tsx | 19 ++++++++++++------ .../src/popup/pages/Account/i18n/da.ts | 19 +++++++++--------- .../src/popup/pages/Account/i18n/en.ts | 20 +++++++++---------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/packages/browser-wallet/src/popup/pages/Account/ConfirmTransfer/TransactionMessage.tsx b/packages/browser-wallet/src/popup/pages/Account/ConfirmTransfer/TransactionMessage.tsx index c2439511..b985ab60 100644 --- a/packages/browser-wallet/src/popup/pages/Account/ConfirmTransfer/TransactionMessage.tsx +++ b/packages/browser-wallet/src/popup/pages/Account/ConfirmTransfer/TransactionMessage.tsx @@ -3,10 +3,9 @@ import { useTranslation } from 'react-i18next'; import { AccountTransactionPayload, AccountTransactionType, - isBakerAccount, - isDelegatorAccount, ConfigureBakerPayload, ConfigureDelegationPayload, + AccountInfoType, } from '@concordium/web-sdk'; import { useSelectedAccountInfo } from '@popup/shared/AccountInfoListenerContext/AccountInfoListenerContext'; import { useBlockChainParametersAboveV0 } from '@popup/shared/BlockChainParametersProvider'; @@ -31,10 +30,19 @@ export function TransactionMessage({ transactionType, payload }: Props) { return undefined; } + let cooldownParam = 0n; + if (parametersV1 !== undefined) { + // From protocol version 7, the lower of the two values is the value that counts. + cooldownParam = + parametersV1.poolOwnerCooldown < parametersV1.delegatorCooldown + ? parametersV1.poolOwnerCooldown + : parametersV1.delegatorCooldown; + } + const cooldownPeriod = secondsToDaysRoundedDown(cooldownParam); + switch (transactionType) { case AccountTransactionType.ConfigureBaker: { - const cooldownPeriod = secondsToDaysRoundedDown(parametersV1?.poolOwnerCooldown); - if (isBakerAccount(accountInfo)) { + if (accountInfo.type === AccountInfoType.Baker) { const newStake = (payload as ConfigureBakerPayload).stake?.microCcdAmount; if (newStake === 0n) { return t('configureBaker.removeBaker', { cooldownPeriod }); @@ -47,8 +55,7 @@ export function TransactionMessage({ transactionType, payload }: Props) { return t('configureBaker.registerBaker', { cooldownPeriod }); } case AccountTransactionType.ConfigureDelegation: { - const cooldownPeriod = secondsToDaysRoundedDown(parametersV1?.delegatorCooldown); - if (isDelegatorAccount(accountInfo)) { + if (accountInfo.type === AccountInfoType.Delegator) { const newStake = (payload as ConfigureDelegationPayload).stake?.microCcdAmount; if (newStake === 0n) { return t('configureDelegation.remove', { diff --git a/packages/browser-wallet/src/popup/pages/Account/i18n/da.ts b/packages/browser-wallet/src/popup/pages/Account/i18n/da.ts index e687ffe9..5ff5de32 100644 --- a/packages/browser-wallet/src/popup/pages/Account/i18n/da.ts +++ b/packages/browser-wallet/src/popup/pages/Account/i18n/da.ts @@ -146,13 +146,13 @@ const t: typeof en = { }, '3': { title: 'Opdateringer med længere cool-downs', - body: 'Hvis du vælger at formindske din delegation saldo, så vil ændringen træde i kraft efter en cool-down periode.\n\nI løbet af denne cool-down periode, vil delegation saldoen være låst og kan ikke ændres, og du vil ikke kunne stoppe delegation.\n\nDu vil stadig kunne ændre andre delegationindstillinger.\n\nHvis du laver andre ændringer samtidigt med at du formindsker delegation saldoen, vil disse ændringer træde i kraft ved den næste pay day, som beskrevet på sidste side.', + body: 'Hvis du vælger at formindske din delegation saldo, så vil ændringen træde i kraft efter en cool-down periode.\n\nI løbet af denne cool-down periode, vil delegation saldoen være låst.\n\nDu vil stadig kunne ændre andre delegationindstillinger.\n\nHvis du laver andre ændringer samtidigt med at du formindsker delegation saldoen, vil disse ændringer træde i kraft ved den næste pay day, som beskrevet på sidste side.', }, }, removeIntro: { '1': { title: 'Stop delegation', - body: 'Hvis du vælger at stoppe delegation, så er der en længere cool-down periode.\n\nI slutningen af cool-down perioden bliver det delegeret CCD låst op på din offentlige saldo, og kan bruges igen.', + body: 'Hvis du vælger at stoppe delegation er der en cool-down periode.\n\nI slutningen af cool-down perioden bliver det delegeret CCD låst op på din offentlige saldo, og kan bruges igen.', }, '2': { title: 'Opdateringer i en cool-down periode', @@ -181,7 +181,7 @@ const t: typeof en = { 'Transaktionen indeholder ikke nogen ændringer i forhold til de nuværende delegationindstillinger.', }, remove: { - notice: 'At stoppe en validator træder i kraft efter en cool-down periode på {{cooldownPeriod}} dage. I løbet af denne periode er validator stake låst og kan ikke ændres.', + notice: 'At stoppe en validator træder i kraft efter en cool-down periode på {{cooldownPeriod}} dage. I løbet af denne periode er validator stake låst.', }, configure: { pool: { @@ -213,7 +213,7 @@ const t: typeof en = { overStakeThresholdWarning: 'Du er ved at låse mere end {{ threshold }}% af din totale saldo som din delegation saldo.\n\nHvis du ikke har nok ulåste CCD, vil du ikke kunne betale for transaktionsomkostninger.', decreaseWarning: - 'At formindske din delegation saldo låser hele delegation saldoen i en cool-down periode. Det er ikke muligt at ændre mængden i denne periode og flytningen af CCD træder ikke i kraft indtil cool-down perioden er afsluttet.', + 'At reducere din delegation saldo resulterer i at mængden der reduceres med er i cool-down. I denne periode kan mængden ikke bruges til overførsler.', enterNewStake: 'Indtast ny delegation saldo', }, }, @@ -284,7 +284,7 @@ const t: typeof en = { noChanges: 'Transaktionen indeholder ikke nogen ændringer i forhold til de nuværende puljeindstillinger.', }, remove: { - notice: 'At stoppe delegation træder i kraft efter en cool-down periode på {{cooldownPeriod}} dage. I løbet af denne periode er validator stake låst og kan ikke ændres.', + notice: 'At stoppe delegation træder i kraft efter en cool-down periode på {{cooldownPeriod}} dage. I løbet af denne periode er validator stake låst.', }, details: { heading: 'Din validator er registreret.', @@ -311,7 +311,7 @@ const t: typeof en = { overStakeThresholdWarning: 'Du er ved at låse mere end {{ threshold }}% af din totale saldo som din validator stake.\n\nHvis du ikke har nok ulåste CCD, vil du ikke kunne betale for transaktionsomkostninger.', decreaseWarning: - 'At formindske din validator stake låser hele din validator stake i en cool-down periode. Det er ikke muligt at ændre mængden i denne periode og flytningen af CCD træder ikke i kraft indtil cool-down perioden er afsluttet.', + 'At reducere din validator stake resulterer i at mængden der reduceres med er i cool-down. I denne periode kan mængden ikke bruges til overførsler.', enterNewStake: 'Indtast ny validator stake', }, openForDelegation: { @@ -344,14 +344,15 @@ const t: typeof en = { registerBaker: 'Du er ved at indsende en transaktion som registrerer dig som en validator, hvillket som låser nogle af dine CCD som validator stake. Hvis du vil frigøre din stake, vil der være en cool-down periode.', lowerBakerStake: - 'Du er ved at indsende en transaktion som formindsker din validator stake. At formindske din validator stake har en cool-down periode, hvilket betyder at ændringen ikke træder i kraft med det samme.\n\nValidatoren kan ikke fjernes og din validator stake kan ikke ændres indtil cool-down perioden er overstået.', - removeBaker: 'Er du sikker du vil lave denne transaktion som stopper validation?', + 'Du er ved at indsende en transaktion som formindsker din validator stake. At formindske din validator stake har en cool-down periode, hvilket betyder at ændringen ikke træder i kraft med det samme.', + removeBaker: + 'Er du sikker du vil lave denne transaktion som stopper validation? Dette vil træde i kraft efter en cool-down periode på {{ cooldownPeriod }} dage', }, configureDelegation: { register: 'Du er ved at indsende en transaktion som registrerer dig som en delegator, hvillket som låser nogle af dine CCD som delegation stake. Hvis du vil frigøre din stake, vil der være en cool-down periode på {{ cooldownPeriod }} dage.', lowerDelegationStake: - 'Du er ved at indsende en transaktion som formindsker din delegation stake. Det vil træde i kraft efter {{ cooldownPeriod }} dage og din delegation saldo kan ikke ændres i denne periode.', + 'Du er ved at indsende en transaktion som formindsker din delegation stake. Det vil træde i kraft efter {{ cooldownPeriod }} dage.', remove: 'Er du sikker du vil fjerne din delegation?', }, }, diff --git a/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts b/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts index 5e3073eb..d3a8dc7e 100644 --- a/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts +++ b/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts @@ -126,7 +126,7 @@ const t = { updateIntro: { '2': { title: 'Update validator stake', - body: 'When updating your validator stake you can choose to increase or decrease your stake. If you increase your stake, this is most often effective from the next pay day. If the transaction occurs too close to the next pay day, the update will be effective from the following pay day.\n\nIf you decrease your stake, there is a longer cool-down period.\n\nYou can also adjust whether you want rewards restaked or not. If the transaction occurs too close to the next pay day, the update will be effective from the following pay day.', + body: 'When updating your validator stake you can choose to increase or decrease your stake. If you increase your stake, this is most often effective from the next pay day. If the transaction occurs too close to the next pay day, the update will be effective from the following pay day.\n\nIf you decrease your stake, there is a cool-down period.\n\nYou can also adjust whether you want rewards restaked or not. If the transaction occurs too close to the next pay day, the update will be effective from the following pay day.', }, '3': { title: 'Update pool settings', @@ -180,7 +180,7 @@ const t = { overStakeThresholdWarning: 'You are about to lock more than {{ threshold }}% of your total balance in a validator stake.\n\nIf you don’t have enough unlocked CCD at your disposal, you might not be able to pay future transaction fees.', decreaseWarning: - 'Reducing the validator stake will lock the total validator stake for a cool-down period. No changes can be made to the amount during this period, and the withdrawal will not take effect before the cool-down period is over.', + 'Reducing your stake is subject to a cool-down period, in which the stake cannot be spent or transferred.', enterNewStake: 'Enter new validator stake', }, openForDelegation: { @@ -250,13 +250,13 @@ const t = { }, '3': { title: 'Updates with longer cool-downs', - body: 'If you decrease your stake, the change will take effect after a cool-down period.\n\nWhile in this cool-down period, the stake is locked and cannot be changed, and you will not be able to stop your delegation.\n\nWhile in the cool-down period you can update other delegation settings, but not the amount.\n\nIf you made any other changes to your delegation while also decreasing your delegation amount, the other changes will take effect from the next pay day as described on the previous page.', + body: 'If you decrease your stake, you will continue to earh rewards on it until the next pay day.\n\nHowever, the stake will not immediately be at disposal. Instead it is subject to a cool-down period during which it cannot be spent or transferred, and no longer earns rewards.\n\nOnce the cool-down period elapses, the removed stake can be spent.\n\nWhile yo uhave stake in cool-down, you can still make changes to your delegation or validator settings.\n\nIncreasing your setake will take preferentially from the stake in cool-down, rather than your balance at disposal.', }, }, removeIntro: { '1': { title: 'Stop your delegation', - body: 'If you decide to stop your delegation, there is a longer cool-down period.\n\nAt the end of the cool-down period, the delegated amount is unlocked on your public balance, and the funds will be at disposal again.', + body: 'If you decide to stop your delegation there is a cool-down period.\n\nAt the end of the cool-down period, the delegated amount is unlocked on your public balance, and the funds will be at disposal again.', }, '2': { title: 'Update during the cool-down period', @@ -264,7 +264,7 @@ const t = { }, }, remove: { - notice: 'Stopping delegation will take effect at the first pay day after a cool-down period of {{cooldownPeriod}} days. During the cool-down period the delegation amount is locked and cannot be changed.', + notice: 'Stopping delegation will take effect at the first pay day after a cool-down period of {{cooldownPeriod}} days. During the cool-down period the delegation amount is locked.', }, details: { heading: 'Your delegation is registered.', @@ -316,7 +316,7 @@ const t = { overStakeThresholdWarning: 'You are about to lock more than {{ threshold }}% of your total balance in a delegation stake.\n\nIf you don’t have enough unlocked CCD at your disposal, you might not be able to pay future transaction fees.', decreaseWarning: - 'Reducing the delegation amount will lock the total delegation amount for a cool-down period. No changes can be made to the amount during this period, and the withdrawal will not take effect before the cool-down period is over.', + 'Reducing your stake is subject to a cool-down period, in which the stake cannot be spent or transferred.', enterNewStake: 'Enter new delegation stake', }, }, @@ -341,16 +341,16 @@ const t = { registerBaker: 'You are about to submit a register validator transaction that locks some of your funds in a stake. If you want to unlock the stake again, there will be a cool-down period of {{ cooldownPeriod }} days.', lowerBakerStake: - 'You are about to submit a validator transaction that lowers your validator stake. It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days and the validator stake cannot be changed during this period of time.', + 'You are about to submit a validator transaction that lowers your validator stake. It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days.', removeBaker: - 'Are you sure you want to make the following transaction to stop validation? It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days and the validator stake cannot be changed during this period of time.', + 'Are you sure you want to make the following transaction to stop validation? It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days.', }, configureDelegation: { register: 'You are about to submit a register delegation transaction that locks some of your funds in a stake. If you want to unlock the stake again, there will be a cool-down period of {{ cooldownPeriod }} days.', lowerDelegationStake: - 'You are about to submit a delegation transaction that lowers your delegation amount. It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days and the delegation amount cannot be changed during this period of time.', - remove: 'Are you sure you want to make the following transaction to stop delegation? It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days and the delegation amount cannot be changed during this period of time.', + 'You are about to submit a delegation transaction that lowers your delegation amount. It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days.', + remove: 'Are you sure you want to make the following transaction to stop delegation? It will take effect at the first pay day after a cool-down period of {{ cooldownPeriod }} days.', }, }, transactionPopup: { From 925931c8aca6710f872a80b22ffe76d9e52a8cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Wed, 9 Oct 2024 15:06:34 +0200 Subject: [PATCH 2/2] Changelog update --- packages/browser-wallet/CHANGELOG.md | 6 ++++++ packages/browser-wallet/src/popup/pages/Account/i18n/en.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/browser-wallet/CHANGELOG.md b/packages/browser-wallet/CHANGELOG.md index 54a24336..cf4154ea 100644 --- a/packages/browser-wallet/CHANGELOG.md +++ b/packages/browser-wallet/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Changed + +- Updated screens mentioning stake cooldowns to reflect protocol version 7 cooldown changes + ## 1.7.0 ### Added diff --git a/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts b/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts index d3a8dc7e..ee757ce5 100644 --- a/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts +++ b/packages/browser-wallet/src/popup/pages/Account/i18n/en.ts @@ -250,7 +250,7 @@ const t = { }, '3': { title: 'Updates with longer cool-downs', - body: 'If you decrease your stake, you will continue to earh rewards on it until the next pay day.\n\nHowever, the stake will not immediately be at disposal. Instead it is subject to a cool-down period during which it cannot be spent or transferred, and no longer earns rewards.\n\nOnce the cool-down period elapses, the removed stake can be spent.\n\nWhile yo uhave stake in cool-down, you can still make changes to your delegation or validator settings.\n\nIncreasing your setake will take preferentially from the stake in cool-down, rather than your balance at disposal.', + body: 'If you decrease your stake, you will continue to earn rewards on it until the next pay day.\n\nHowever, the stake will not immediately be at disposal. Instead it is subject to a cool-down period during which it cannot be spent or transferred, and no longer earns rewards.\n\nOnce the cool-down period elapses, the removed stake can be spent.\n\nWhile you have stake in cool-down, you can still make changes to your delegation or validator settings.\n\nIncreasing your stake will take preferentially from the stake in cool-down, rather than your balance at disposal.', }, }, removeIntro: {