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

Cardano GovTool v1.0.22 #2205

Merged
merged 36 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
249a5dc
chore: update test-metrics-api dependencies
kneerose Oct 7, 2024
21da87c
chore: update test-metadata-api dependencies
kneerose Oct 7, 2024
e2ff999
chore: update test-govtool-frontend dependencies
kneerose Oct 7, 2024
46aa788
chore: update requests package version on test-govtool-backend
kneerose Oct 7, 2024
fb994d7
chore: update bouncycastle dependency version on test-load-testing
kneerose Oct 7, 2024
7a3bc90
fix: correct testId for CC committee yes votes
kneerose Oct 16, 2024
c065deb
chore: add workflow to assign project to new issues
Ryun1 Oct 17, 2024
e3595ed
[#1897] fix unwanted horizontal page scroll on Governance Actions page
j-dyczka Oct 17, 2024
abffc20
Merge pull request #2127 from IntersectMBO/fix/test-dependabot-alerts
kneerose Oct 18, 2024
899fa98
Merge pull request #2159 from IntersectMBO/fix/vote-count-issue
kneerose Oct 18, 2024
5372420
Merge pull request #2179 from IntersectMBO/fix/1897-GAs-page-horizont…
jdyczka Oct 18, 2024
537ebbc
[#1965] fix duplicate testIds for reference errors and hints
j-dyczka Oct 17, 2024
d5c42a8
Merge pull request #2180 from IntersectMBO/fix/1965-duplicate-testids…
jdyczka Oct 18, 2024
e2b5f92
[#2171] eliminate duplicate DReps
j-dyczka Oct 17, 2024
27915e9
Merge pull request #2172 from IntersectMBO/fix/2171-duplicated-dreps
jdyczka Oct 18, 2024
daedc37
[#1951] return isScriptBased flag from BE for listDReps and getDRepInfo
j-dyczka Oct 15, 2024
a57e43f
[#1951] handle scripe based DReps on FE
j-dyczka Oct 18, 2024
7f9ff90
chore: add get genesis params on kuber api
kneerose Oct 18, 2024
0406770
test: gov action expiry epoch and date validation
kneerose Oct 18, 2024
6181c4d
fix: ga epoch boundary for preprod
MSzalowski Oct 21, 2024
7ba23cc
[#1951] fix delegation cert hash for script DReps
j-dyczka Oct 21, 2024
5eac3f2
[#1951] add workaround for multiple rows for one drep view in drep_ha…
j-dyczka Oct 21, 2024
2b1feeb
[#1951] remove calculating view on FE
j-dyczka Oct 21, 2024
c627813
Merge pull request #2182 from IntersectMBO/fix/1951-script-based-dreps
jdyczka Oct 21, 2024
d6398d2
Merge pull request #2185 from IntersectMBO/backend-test/epoch-boundary
kneerose Oct 22, 2024
4c550d6
feat: set markdown alignment unset
MSzalowski Oct 21, 2024
a316950
Merge pull request #2188 from IntersectMBO/feat/reset-markdown-alignment
MSzalowski Oct 22, 2024
41a5391
Merge pull request #2186 from IntersectMBO/fix/fix-ga-epoch-boundary-…
MSzalowski Oct 22, 2024
14f95de
chore: bump Cardano node to 10.0.0-pre
Ryun1 Oct 22, 2024
efc4cb8
chore: update cookie dependencies version on test-metrics-api and te…
kneerose Oct 23, 2024
c53b4c0
chore: update @types/node version in govtool-frontend
kneerose Oct 23, 2024
91c2214
Merge pull request #2197 from IntersectMBO/fix/test-dependabot-alerts
kneerose Oct 23, 2024
19dc4b4
fix: use logger import from helper instead of cypress logger
kneerose Oct 23, 2024
571e269
Merge pull request #2200 from IntersectMBO/bugfix/logger-import
kneerose Oct 23, 2024
960e4d9
Merge pull request #2198 from IntersectMBO/develop
MSzalowski Oct 23, 2024
257440d
Merge pull request #2201 from IntersectMBO/test
MSzalowski Oct 23, 2024
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
Prev Previous commit
Next Next commit
[#1951] handle scripe based DReps on FE
  • Loading branch information
j-dyczka committed Oct 18, 2024
commit a57e43ff6d0fbd058123521879d58ca4be1cf7b6
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ changes.
- Fix unwanted horizontal page scroll on Governance Actions page [Issue 1897](https://github.com/IntersectMBO/govtool/issues/1897)
- Fix duplicate testIds for reference errors and hints in DRep metadata form [Issue 1965](https://github.com/IntersectMBO/govtool/issues/1965)
- Eliminate duplicate DReps in the DRep Directory [Issue 2171](https://github.com/IntersectMBO/govtool/issues/2171)
- Handle script based DReps [Issue 1951](https://github.com/IntersectMBO/govtool/issues/1951)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@molecules";
import {
correctAdaFormat,
formHexToBech32,
getMetadataDataMissingStatusTranslation,
openInNewTab,
} from "@utils";
Expand Down Expand Up @@ -236,9 +235,7 @@ const getDisplayedDelegationId = ({
];
if (delegateTo) {
if (!restrictedNames.includes(delegateTo)) {
return delegateTo.includes("drep")
? delegateTo
: formHexToBech32(delegateTo);
return delegateTo;
}
return undefined;
}
Expand Down
4 changes: 3 additions & 1 deletion govtool/frontend/src/context/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,10 @@ const CardanoProvider = (props: Props) => {
targetDRep = DRep.new_always_abstain();
} else if (target === AutomatedVotingOptionDelegationId.no_confidence) {
targetDRep = DRep.new_always_no_confidence();
} else if (target.includes("drep")) {
} else if (target.includes("drep1")) {
targetDRep = DRep.new_key_hash(Ed25519KeyHash.from_bech32(target));
} else if (target.includes("drep_script1")) {
targetDRep = DRep.new_script_hash(Ed25519KeyHash.from_bech32(target));
} else {
targetDRep = DRep.new_key_hash(Ed25519KeyHash.from_hex(target));
}
Expand Down
1 change: 0 additions & 1 deletion govtool/frontend/src/hooks/forms/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./useCreateGovernanceActionForm";
export * from "./useDelegateTodRepForm";
export * from "./useEditDRepInfoForm";
export * from "./useRegisterAsdRepForm";
export * from "./useVoteActionForm";
Expand Down
105 changes: 0 additions & 105 deletions govtool/frontend/src/hooks/forms/useDelegateTodRepForm.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions govtool/frontend/src/models/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export enum DRepListSort {
export type DrepDataDTO = {
deposit: number;
drepId: string;
isScriptBased: boolean;
latestRegistrationDate: string;
latestTxHash?: string;
metadataHash?: string;
Expand Down Expand Up @@ -198,6 +199,7 @@ export type VotedProposal = {
export type CurrentDelegation = {
dRepHash: string | null;
dRepView: string | null;
isDRepScriptBased: boolean;
txHash: string | null;
} | null;

Expand Down
6 changes: 2 additions & 4 deletions govtool/frontend/src/pages/DRepDirectoryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "@hooks";
import { DataActionsBar, EmptyStateDrepDirectory } from "@molecules";
import { AutomatedVotingOptions, DRepCard } from "@organisms";
import { correctAdaFormat, formHexToBech32, isSameDRep } from "@utils";
import { correctAdaFormat, isSameDRep } from "@utils";
import { DRepListSort, DRepStatus } from "@models";
import {
AutomatedVotingOptionCurrentDelegation,
Expand Down Expand Up @@ -59,9 +59,7 @@ export const DRepDirectoryContent: FC<DRepDirectoryContentProps> = ({

const { dRepData: myDRepList } = useGetDRepListInfiniteQuery(
{
searchPhrase: currentDelegation?.dRepView?.startsWith("drep")
? currentDelegation.dRepView
: formHexToBech32(currentDelegation?.dRepHash ?? ""),
searchPhrase: currentDelegation?.dRepView ?? "",
},
{ enabled: !!inProgressDelegation || !!currentDelegation },
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CurrentDelegation } from "@models";

import { API } from "../API";
import { fixViewForScriptBasedDRep } from "@/utils";

export const getAdaHolderCurrentDelegation = async ({
stakeKey,
Expand All @@ -11,5 +12,16 @@ export const getAdaHolderCurrentDelegation = async ({
`/ada-holder/get-current-delegation/${stakeKey}`,
);

return response.data;
if (!response.data) return response.data;

// DBSync contains wrong representation of DRep view for script based DReps
const view = response.data.dRepView && fixViewForScriptBasedDRep(
response.data.dRepView,
response.data.isDRepScriptBased,
);

return {
...response.data,
dRepView: view,
};
};
17 changes: 15 additions & 2 deletions govtool/frontend/src/services/requests/getDRepList.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { bech32 } from "bech32";

import {
type Infinite,
type DRepStatus,
Expand All @@ -22,9 +24,19 @@ export const getDRepList = async ({
filters = [],
page = 0,
pageSize = 10,
searchPhrase = "",
searchPhrase: rawSearchPhrase = "",
status = [],
}: GetDRepListArguments): Promise<Infinite<DRepData>> => {
// DBSync contains wrong representation of DRep view for script based DReps,
// but it's still used by BE
const searchPhrase = (() => {
if (rawSearchPhrase.startsWith("drep_script")) {
const { words } = bech32.decode(rawSearchPhrase);
return bech32.encode("drep", words);
}
return rawSearchPhrase;
})();

const response = await API.get<Infinite<DrepDataDTO>>("/drep/list", {
params: {
page,
Expand All @@ -39,7 +51,8 @@ export const getDRepList = async ({
const validatedResponse = {
...response.data,
elements: await Promise.all(
response.data.elements.map(async (drep) => mapDtoToDrep(drep)),
response.data.elements
.map(async (drep) => mapDtoToDrep(drep)),
),
};

Expand Down
10 changes: 10 additions & 0 deletions govtool/frontend/src/utils/dRep.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { bech32 } from "bech32";
import { DRepData } from "@/models";

export const isSameDRep = (
Expand All @@ -9,3 +10,12 @@ export const isSameDRep = (
}
return drepId === dRepIdOrView || view === dRepIdOrView;
};

// DBSync contains wrong representation of DRep view for script based DReps
export const fixViewForScriptBasedDRep = (view: string, isScriptBased: boolean) => {
if (isScriptBased && !view.startsWith("drep_script")) {
const { words } = bech32.decode(view);
return bech32.encode("drep_script", words);
}
return view;
};
10 changes: 8 additions & 2 deletions govtool/frontend/src/utils/getDRepID.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { bech32 } from "bech32";

import { CardanoApiWallet } from "@models";

export const formHexToBech32 = (dRepID?: string) => {
// TODO: How do we know if DRep is script based if we have no DRep data?
export const formHexToBech32 = (dRepID?: string, isScript?: boolean) => {
if (!dRepID) return;
const words = bech32.toWords(Buffer.from(dRepID, "hex"));
const dRepIDBech32 = bech32.encode("drep", words);
let dRepIDBech32;
if (isScript) {
dRepIDBech32 = bech32.encode("drep_script", words);
} else {
dRepIDBech32 = bech32.encode("drep", words);
}
return dRepIDBech32;
};

Expand Down
6 changes: 6 additions & 0 deletions govtool/frontend/src/utils/mapDtoToDrep.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DRepData, DRepMetadata, DrepDataDTO } from "@/models";
import { postValidate } from "@/services";
import { fixViewForScriptBasedDRep } from "./dRep";

export const mapDtoToDrep = async (dto: DrepDataDTO): Promise<DRepData> => {
const emptyMetadata = {
Expand All @@ -15,6 +16,9 @@ export const mapDtoToDrep = async (dto: DrepDataDTO): Promise<DRepData> => {
metadataValid: true,
};

// DBSync contains wrong representation of DRep view for script based DReps
const view = fixViewForScriptBasedDRep(dto.view, dto.isScriptBased);

if (dto.metadataHash && dto.url) {
const validationResponse = await postValidate<DRepMetadata>({
url: dto.url,
Expand All @@ -26,11 +30,13 @@ export const mapDtoToDrep = async (dto: DrepDataDTO): Promise<DRepData> => {
...validationResponse.metadata,
metadataStatus: validationResponse.status || null,
metadataValid: validationResponse.valid,
view,
};
}

return {
...dto,
...emptyMetadata,
view,
};
};
1 change: 1 addition & 0 deletions govtool/frontend/src/utils/tests/dRep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const EXAMPLE_DREP: DRepData = {
motivations: null,
qualifications: null,
doNotList: false,
isScriptBased: false,
};

describe("isSameDRep function", () => {
Expand Down
Loading