Skip to content

Commit

Permalink
Merge pull request #570 from Concordium/ui-update/fix-stop-validation
Browse files Browse the repository at this point in the history
UI update/fix stop validation
  • Loading branch information
soerenbf authored Nov 18, 2024
2 parents 2d819f1 + bec3b33 commit a9bd90b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
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 @@ -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

0 comments on commit a9bd90b

Please sign in to comment.