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

UI update/fix stop validation #570

Merged
merged 2 commits into from
Nov 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function DelegatorStatus() {
const nav = useNavigate();

if (accountInfo?.type !== AccountInfoType.Delegator) {
return <Navigate to=".." />;
return <Navigate to={absoluteRoutes.settings.earn.path} />;
}

const { accountDelegation, accountCooldowns } = accountInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import { cpStakingCooldown } from '@shared/utils/chain-parameters-helpers';
import { submittedTransactionRoute } from '@popup/popupX/constants/routes';
import Text from '@popup/popupX/shared/Text';
import { useSelectedAccountInfo } from '@popup/shared/AccountInfoListenerContext/AccountInfoListenerContext';
import ErrorMessage from '@popup/popupX/shared/Form/ErrorMessage';
import {
isRange,
showCommissionRate,
showValidatorAmount,
showValidatorOpenStatus,
showValidatorRestake,
} from '../util';
import ErrorMessage from '@popup/popupX/shared/Form/ErrorMessage';

export type ValidationResultLocationState = {
payload: ConfigureBakerPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function ValidatorStatus() {
const chainParams = useBlockChainParametersAboveV0();

if (accountInfo?.type !== AccountInfoType.Baker) {
return <Navigate to=".." />;
return <Navigate to={absoluteRoutes.settings.earn.path} />;
}

const { accountBaker, accountCooldowns } = accountInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const t = {
root: {
validatorTitle: 'Validation',
validatorDescription:
'As a validator, you can participate in the network by baking blocks on the Concordium network. This requires a minimum of {{amount}} CCD and access to a dedicated node.',
'As a validator, you can participate in the network by validating blocks on the Concordium network. This requires a minimum of {{amount}} CCD and access to a dedicated node.',
validatorAction: 'Continue to validation setup',
delegationTitle: 'Delegation',
delegationDescription:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import {
DelegationStakeChangedEvent,
DelegatorEvent,
ConfigureDelegationSummary,
ConfigureBakerSummary,
BakerStakeChangedEvent,
BakerEvent,
} from '@concordium/web-sdk';
import { useAtomValue } from 'jotai';
import { grpcClientAtom } from '@popup/store/settings';
Expand Down Expand Up @@ -62,6 +65,32 @@ function DelegationBody({ events }: DelegationBodyProps) {
return <Text.Capture>{t('updated')}</Text.Capture>;
}

type ValidatorBodyProps = BaseAccountTransactionSummary & ConfigureBakerSummary;

function ValidatorBody({ events }: ValidatorBodyProps) {
const { t } = useTranslation('x', { keyPrefix: 'submittedTransaction.success.configureValidator' });

const stakeChange = events.find((e) =>
[TransactionEventTag.BakerStakeIncreased, TransactionEventTag.BakerStakeDecreased].includes(e.tag)
) as BakerStakeChangedEvent | undefined;
if (stakeChange !== undefined) {
return (
<>
<Text.Capture>{t('changeStake')}</Text.Capture>
<Text.HeadingLarge>{formatCcdAmount(stakeChange.newStake)}</Text.HeadingLarge>
<Text.Capture>CCD</Text.Capture>
</>
);
}

const removal = events.find((e) => [TransactionEventTag.BakerRemoved].includes(e.tag)) as BakerEvent | undefined;
if (removal !== undefined) {
return <Text.Capture>{t('removed')}</Text.Capture>;
}

return <Text.Capture>{t('updated')}</Text.Capture>;
}

type SuccessSummary = Exclude<AccountTransactionSummary, FailedTransactionSummary>;
type FailureSummary = BaseAccountTransactionSummary & FailedTransactionSummary;

Expand All @@ -87,6 +116,7 @@ function Success({ tx }: SuccessProps) {
</>
)}
{tx.transactionType === TransactionKindString.ConfigureDelegation && <DelegationBody {...tx} />}
{tx.transactionType === TransactionKindString.ConfigureBaker && <ValidatorBody {...tx} />}
</>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const t = {
removed: "You've removed your delegated stake",
updated: "You've updated your delegation settings",
},
configureValidator: {
changeStake: "You've validating with",
removed: "You've stopped validating",
updated: "You've updated your delegation settings",
},
transfer: {
label: "You've sent",
},
Expand Down
Loading