Skip to content

Commit

Permalink
Merge pull request #632 from IntersectMBO/chore/573-link-to-cexplorer…
Browse files Browse the repository at this point in the history
…-to-review-the-submitted-transaction

chore/573-link-to-cexplorer-to-review-the-submitted-transaction
  • Loading branch information
Sworzen1 authored Apr 16, 2024
2 parents b239443 + 8923d97 commit b4f132f
Show file tree
Hide file tree
Showing 29 changed files with 5,019 additions and 5,604 deletions.
5,322 changes: 2,731 additions & 2,591 deletions govtool/frontend/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@emurgo/cardano-serialization-lib-asmjs": "12.0.0-alpha.19",
"@emurgo/cardano-serialization-lib-asmjs": "12.0.0-alpha.29",
"@hookform/resolvers": "^3.3.1",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/node_modules/@emurgo/cardano-serialization-lib-asmjs/package.json b/node_modules/@emurgo/cardano-serialization-lib-asmjs/package.json
index 7140a36..999ac42 100644
index f3f9dc2..5048761 100644
--- a/node_modules/@emurgo/cardano-serialization-lib-asmjs/package.json
+++ b/node_modules/@emurgo/cardano-serialization-lib-asmjs/package.json
@@ -18,6 +18,7 @@
"cardano_serialization_lib.js.flow"
@@ -19,6 +19,7 @@
],
"module": "cardano_serialization_lib.js",
+ "main":"cardano_serialization_lib.js",
"types": "cardano_serialization_lib.d.ts",
+ "main":"cardano_serialization_lib.js",
"sideEffects": [
"./cardano_serialization_lib.js",
"./snippets/*"
7 changes: 1 addition & 6 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
CreateGovernanceAction,
Dashboard,
DashboardGovernanceActionsCategory,
DelegateTodRep,
DRepDetails,
DRepDirectory,
DRepDirectoryContent,
Expand Down Expand Up @@ -123,16 +122,12 @@ export default () => {
path={PATHS.dRepDirectory}
element={<DRepDirectoryContent />}
/>
<Route
path={PATHS.dRepDirectoryDRep}
element={<DRepDetails />}
/>
<Route path={PATHS.dRepDirectoryDRep} element={<DRepDetails />} />
</Route>
<Route
path={PATHS.createGovernanceAction}
element={<CreateGovernanceAction />}
/>
<Route path={PATHS.delegateTodRep} element={<DelegateTodRep />} />
<Route path={PATHS.registerAsdRep} element={<RegisterAsdRep />} />
<Route path={PATHS.retireAsDrep} element={<RetireAsDrep />} />
<Route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type DashboardActionCardProps = {
isInProgressOnCard?: boolean;
state?: "active" | "inProgress" | "default";
title?: ReactNode;
transactionId?: string;
transactionId?: string | null;
isSpaceBetweenButtons?: boolean;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { useTranslation } from "@hooks";
import { Vote } from "@models";

type Props = {
voteTxHash: string;
vote: Vote;
};

export const GovernanceActionCardMyVote = ({ vote }: Props) => {
export const GovernanceActionCardMyVote = ({ voteTxHash, vote }: Props) => {
const { t } = useTranslation();

return (
Expand Down Expand Up @@ -41,8 +42,7 @@ export const GovernanceActionCardMyVote = ({ vote }: Props) => {
</Box>
<Button
onClick={() =>
// TODO: Confirm/change the link
openInNewTab("https://adanordic.com/latest_transactions")
openInNewTab(`https://sancho.cexplorer.io/tx/${voteTxHash}`)
}
variant="text"
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => {
isCopyButton
isSliderCard
/>
<GovernanceActionCardMyVote vote={vote.vote} />
<GovernanceActionCardMyVote voteTxHash={vote.txHash} vote={vote.vote} />
</Box>
<Box
bgcolor="white"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useTranslation } from "@hooks";
import { AutomatedVotingCard } from "@molecules";

type AutomatedVotingOptionsProps = {
currentDelegation: string | undefined;
currentDelegation?: string | null;
delegate: (delegateTo: string) => void;
votingPower: string;
delegationInProgress?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const DRepDashboardCard = ({
state: "inProgress",
...(pendingTransaction.registerAsDrep && {
description: t("dashboard.cards.drep.registrationInProgress"),
transactionId: pendingTransaction?.registerAsDrep.transactionHash,
title: t("dashboard.cards.drep.dRepRegistration"),
}),
...(pendingTransaction.retireAsDrep && {
Expand All @@ -61,10 +62,12 @@ export const DRepDashboardCard = ({
values={{ deposit: correctAdaFormat(voter?.deposit) }}
/>
),
transactionId: pendingTransaction?.retireAsDrep.transactionHash,
title: t("dashboard.cards.drep.dRepRetirement"),
}),
...(pendingTransaction.updateMetaData && {
description: t("dashboard.cards.drep.metadataUpdateInProgress"),
transactionId: pendingTransaction?.updateMetaData.transactionHash,
title: t("dashboard.cards.drep.dRepUpdate"),
}),
};
Expand All @@ -90,6 +93,7 @@ export const DRepDashboardCard = ({
],
description: t("dashboard.cards.drep.registeredDescription"),
state: "active",
transactionId: voter?.dRepRegisterTxHash,
title: t("dashboard.cards.drep.registeredTitle"),
};
}
Expand Down Expand Up @@ -117,6 +121,7 @@ export const DRepDashboardCard = ({
description: (
<Trans i18nKey="dashboard.cards.drep.notRegisteredWasRegisteredDescription" />
),
transactionId: voter?.dRepRetireTxHash,
title: t("dashboard.cards.drep.notRegisteredWasRegisteredTitle"),
};
}
Expand All @@ -132,10 +137,6 @@ export const DRepDashboardCard = ({
return (
<DashboardActionCard
imageURL={IMAGES.govActionRegisterImage}
transactionId={
pendingTransaction.registerAsDrep?.transactionHash ||
pendingTransaction.retireAsDrep?.transactionHash
}
{...cardProps}
>
{voter?.isRegisteredAsDRep && !pendingTransaction?.retireAsDrep && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import { useNavigate } from "react-router-dom";
import { Trans } from "react-i18next";

import { IMAGES, PATHS } from "@consts";
import { PendingTransaction } from "@context";
import { useTranslation } from "@hooks";
import { CurrentDelegation } from "@models";
import {
DashboardActionCard,
DashboardActionCardProps,
DelegationAction,
} from "@molecules";
import { correctAdaFormat, formHexToBech32, openInNewTab } from "@utils";
import { PendingTransaction } from "@/context/pendingTransaction";

type DelegateDashboardCardProps = {
currentDelegation: string;
currentDelegation: CurrentDelegation;
delegateTx: PendingTransaction["delegate"];
dRepID: string;
votingPower: number;
Expand All @@ -38,11 +39,11 @@ export const DelegateDashboardCard = ({
sx: { backgroundColor: "arcticWhite" },
};

const displayedDelegationId = getDisplayedDelegationId(
currentDelegation,
delegateTx?.resourceId,
const displayedDelegationId = getDisplayedDelegationId({
currentDelegation: currentDelegation?.dRepView,
delegateTo: delegateTx?.resourceId,
dRepID,
);
});

const onClickDelegateToAnotherDRep = () =>
navigate(PATHS.dashboardDRepDirectory);
Expand All @@ -63,7 +64,7 @@ export const DelegateDashboardCard = ({
// current delegation
if (currentDelegation) {
return {
buttons: displayedDelegationId
buttons: currentDelegation?.dRepView
? [
learnMoreButton,
{
Expand All @@ -74,9 +75,9 @@ export const DelegateDashboardCard = ({
},
]
: [learnMoreButton],
description: getDelegationDescription(currentDelegation),
description: getDelegationDescription(currentDelegation.dRepView),
state: "active",
title: getDelegationTitle(currentDelegation, ada),
title: getDelegationTitle(currentDelegation.dRepView, ada),
};
}

Expand Down Expand Up @@ -110,8 +111,8 @@ export const DelegateDashboardCard = ({
return (
<DashboardActionCard
imageURL={IMAGES.govActionDelegateImage}
isSpaceBetweenButtons
transactionId={delegateTx?.resourceId}
isSpaceBetweenButtons={!!currentDelegation?.dRepView}
transactionId={delegateTx?.resourceId || currentDelegation?.txHash}
{...cardProps}
>
{displayedDelegationId && (
Expand All @@ -127,7 +128,7 @@ export const DelegateDashboardCard = ({
);
};

const getDelegationTitle = (currentDelegation: string, ada: number) => {
const getDelegationTitle = (currentDelegation: string | null, ada: number) => {
const key =
currentDelegation === "drep_always_no_confidence"
? "dashboard.cards.delegation.noConfidenceDelegationTitle"
Expand All @@ -138,7 +139,7 @@ const getDelegationTitle = (currentDelegation: string, ada: number) => {
return <Trans i18nKey={key} values={{ ada }} />;
};

const getDelegationDescription = (currentDelegation: string) => {
const getDelegationDescription = (currentDelegation: string | null) => {
const key =
currentDelegation === "drep_always_no_confidence"
? "dashboard.cards.delegation.noDescription"
Expand All @@ -163,11 +164,15 @@ const getProgressDescription = (delegateTo: string, ada: number) => {
return <Trans i18nKey={key} values={{ ada }} />;
};

const getDisplayedDelegationId = (
currentDelegation: string,
delegateTo: string | undefined,
dRepID: string,
) => {
const getDisplayedDelegationId = ({
dRepID,
currentDelegation,
delegateTo,
}: {
dRepID: string;
currentDelegation?: string | null;
delegateTo?: string;
}) => {
const restrictedNames = [
dRepID,
"drep_always_abstain",
Expand All @@ -183,8 +188,9 @@ const getDisplayedDelegationId = (
}
return undefined;
}
if (!restrictedNames.includes(currentDelegation)) {
return formHexToBech32(currentDelegation);

if (!restrictedNames.includes(currentDelegation ?? "")) {
return formHexToBech32(currentDelegation ?? "");
}
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ export const SoleVoterDashboardCard = ({
state: "inProgress",
...(pendingTransaction.registerAsSoleVoter && {
description: t("dashboard.cards.soleVoter.registrationInProgress"),
transactionId:
pendingTransaction?.registerAsSoleVoter?.transactionHash,
title: t("dashboard.cards.soleVoter.registration"),
transactionId: pendingTransaction.registerAsSoleVoter.resourceId,
}),
...(pendingTransaction.retireAsSoleVoter && {
description: t("dashboard.cards.soleVoter.retirementInProgress"),
transactionId: pendingTransaction?.retireAsSoleVoter?.transactionHash,
title: t("dashboard.cards.soleVoter.retirement"),
}),
};
Expand All @@ -75,6 +77,7 @@ export const SoleVoterDashboardCard = ({
/>
),
state: "active",
transactionId: voter?.soleVoterRegisterTxHash,
title: t("dashboard.cards.soleVoter.youAreSoleVoterTitle"),
};
}
Expand All @@ -97,6 +100,7 @@ export const SoleVoterDashboardCard = ({
values={{ votingPower: ada }}
/>
),
transactionId: voter?.soleVoterRetireTxHash,
title: t("dashboard.cards.soleVoter.wasSoleVoterTitle"),
};
}
Expand All @@ -123,14 +127,6 @@ export const SoleVoterDashboardCard = ({
})();

return (
<DashboardActionCard
imageURL={IMAGES.soleVoterImage}
{...cardProps}
// TODO: add transaction which registes ada holder as sole voter as well
transactionId={
pendingTransaction?.registerAsSoleVoter?.transactionHash ||
pendingTransaction?.retireAsSoleVoter?.transactionHash
}
/>
<DashboardActionCard imageURL={IMAGES.soleVoterImage} {...cardProps} />
);
};
Loading

0 comments on commit b4f132f

Please sign in to comment.