Skip to content
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

Update screens mentioning stake cooldown #531

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/browser-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Changed

- Updated screens mentioning stake cooldowns to reflect protocol version 7 cooldown changes

## 1.7.0

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 });
Expand All @@ -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', {
Expand Down
19 changes: 10 additions & 9 deletions packages/browser-wallet/src/popup/pages/Account/i18n/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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',
},
},
Expand Down Expand Up @@ -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.',
Expand All @@ -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: {
Expand Down Expand Up @@ -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?',
},
},
Expand Down
20 changes: 10 additions & 10 deletions packages/browser-wallet/src/popup/pages/Account/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -250,21 +250,21 @@ 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 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: {
'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',
body: 'Only the delegation amount is locked during the cool-down period.\n\nThis means that you can still change restake status and target staking pool during the cool-down.',
},
},
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.',
Expand Down Expand Up @@ -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',
},
},
Expand All @@ -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: {
Expand Down
Loading