Skip to content

Commit 89b4a19

Browse files
authored
Merge pull request #2584 from IntersectMBO/fix/2509-legacy-drep-metadata-format-transition-to-cip-0119
fix(#2509): fix nested @value in metadatas
2 parents a2fa857 + af84ddc commit 89b4a19

File tree

12 files changed

+37
-76
lines changed

12 files changed

+37
-76
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ changes.
2020
- Fix link and description validation [Issue 2403](https://github.com/IntersectMBO/govtool/issues/2403)
2121
- Revert to drep_distr for providing active voting power
2222
- Add rewards amount in the ada holder voting power
23+
- Fix nested @value in jsonld metadatas [Issue 2509](https://github.com/IntersectMBO/govtool/issues/2509)
2324

2425
### Changed
2526

govtool/frontend/src/consts/governanceAction/fields.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export const GOVERNANCE_ACTION_FIELDS: GovernanceActionFields = {
126126
} as const;
127127

128128
export const GOVERNANCE_ACTION_CONTEXT = {
129+
"@language": "en-us",
129130
CIP100:
130131
"https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#",
131132
CIP108:

govtool/frontend/src/context/featureFlag.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ const FeatureFlagProvider = ({ children }: PropsWithChildren) => {
127127
() => ({
128128
isProposalDiscussionForumEnabled:
129129
import.meta.env.VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED === "true" ||
130+
import.meta.env.VITE_IS_PROPOSAL_DISCUSSION_FORUM_ENABLED === true ||
130131
false,
131132
isVotingOnGovernanceActionEnabled,
132133
areDRepVoteTotalsDisplayed,

govtool/frontend/src/context/governanceAction.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe("GovernanceActionProvider", () => {
8080
const hash = await createHash(jsonld!);
8181
expect(hash).toBeDefined();
8282
expect(hash).toBe(
83-
"72b37e2f5e64e7de57b85558ba00885c848f700fbb37fbed3197e603873fa976",
83+
"816b63124f5c5d5bdfc016ad0aea238baf374fecbdadd389eab2dab94bc2383c",
8484
);
8585
};
8686
test();

govtool/frontend/src/context/governanceAction.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { NodeObject } from "jsonld";
1010
import { blake2bHex } from "blakejs";
1111
import * as Sentry from "@sentry/react";
1212

13-
import { CIP_108, GOVERNANCE_ACTION_CONTEXT } from "@/consts";
13+
import { GOVERNANCE_ACTION_CONTEXT } from "@/consts";
1414
import { generateJsonld, generateMetadataBody } from "@/utils";
1515

1616
type GovActionMetadata = {
@@ -53,7 +53,6 @@ const GovernanceActionProvider = ({ children }: PropsWithChildren) => {
5353
const metadataBody = generateMetadataBody({
5454
data: govActionMetadata,
5555
acceptedKeys: ["title", "abstract", "motivation", "rationale"],
56-
standardReference: CIP_108,
5756
});
5857

5958
const jsonLD = await generateJsonld(

govtool/frontend/src/hooks/forms/useCreateGovernanceActionForm.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { useTranslation } from "react-i18next";
77
import { NodeObject } from "jsonld";
88

99
import {
10-
CIP_108,
1110
GOVERNANCE_ACTION_CONTEXT,
1211
PATHS,
1312
storageInformationErrorModals,
@@ -104,7 +103,6 @@ export const useCreateGovernanceActionForm = (
104103
const body = generateMetadataBody({
105104
data: getValues(),
106105
acceptedKeys: ["title", "motivation", "abstract", "rationale"],
107-
standardReference: CIP_108,
108106
});
109107

110108
const jsonld = await generateJsonld(body, GOVERNANCE_ACTION_CONTEXT);

govtool/frontend/src/hooks/forms/useEditDRepInfoForm.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ import { blake2bHex } from "blakejs";
66
import * as Sentry from "@sentry/react";
77
import { NodeObject } from "jsonld";
88

9-
import {
10-
CIP_119,
11-
DREP_CONTEXT,
12-
PATHS,
13-
storageInformationErrorModals,
14-
} from "@consts";
9+
import { DREP_CONTEXT, PATHS, storageInformationErrorModals } from "@consts";
1510
import { useCardano, useModal, useAppContext } from "@context";
1611
import { downloadJson, generateJsonld, generateMetadataBody } from "@utils";
1712
import { MetadataValidationStatus } from "@models";
@@ -92,13 +87,11 @@ export const useEditDRepInfoForm = (
9287
"motivations",
9388
"qualifications",
9489
"paymentAddress",
95-
"references",
9690
"doNotList",
9791
],
98-
standardReference: CIP_119,
9992
});
10093

101-
const jsonld = await generateJsonld(body, DREP_CONTEXT, CIP_119);
94+
const jsonld = await generateJsonld(body, DREP_CONTEXT);
10295

10396
const jsonHash = blake2bHex(JSON.stringify(jsonld, null, 2), undefined, 32);
10497

govtool/frontend/src/hooks/forms/useRegisterAsdRepForm.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import * as Sentry from "@sentry/react";
77
import { NodeObject } from "jsonld";
88
import { CertificatesBuilder } from "@emurgo/cardano-serialization-lib-asmjs";
99

10-
import {
11-
CIP_119,
12-
DREP_CONTEXT,
13-
PATHS,
14-
storageInformationErrorModals,
15-
} from "@consts";
10+
import { DREP_CONTEXT, PATHS, storageInformationErrorModals } from "@consts";
1611
import { useCardano, useModal, useAppContext } from "@context";
1712
import { MetadataValidationStatus } from "@models";
1813
import {
@@ -108,12 +103,11 @@ export const useRegisterAsdRepForm = (
108103
"motivations",
109104
"qualifications",
110105
"paymentAddress",
111-
"references",
112106
"doNotList",
113107
],
114-
standardReference: CIP_119,
115108
});
116-
const jsonld = await generateJsonld(body, DREP_CONTEXT, CIP_119);
109+
110+
const jsonld = await generateJsonld(body, DREP_CONTEXT);
117111

118112
const jsonHash = blake2bHex(JSON.stringify(jsonld, null, 2), undefined, 32);
119113

govtool/frontend/src/hooks/forms/useVoteContextForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { NodeObject } from "jsonld";
66

77
import { downloadJson, generateJsonld, generateMetadataBody } from "@utils";
88
import { MetadataValidationStatus } from "@models";
9-
import { CIP_100, CIP_100_CONTEXT } from "@/consts";
9+
import { CIP_100_CONTEXT } from "@/consts";
1010

1111
import { useValidateMutation } from "../mutations";
1212

@@ -43,9 +43,8 @@ export const useVoteContextForm = (
4343
comment: voteContextText,
4444
},
4545
acceptedKeys: ["comment"],
46-
standardReference: CIP_100,
4746
});
48-
const jsonld = await generateJsonld(body, CIP_100_CONTEXT, CIP_100);
47+
const jsonld = await generateJsonld(body, CIP_100_CONTEXT);
4948

5049
const jsonHash = blake2bHex(JSON.stringify(jsonld, null, 2), undefined, 32);
5150

govtool/frontend/src/utils/generateJsonld.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import * as jsonld from "jsonld";
22

3-
import { CIP_100, CIP_108 } from "@/consts";
4-
53
/**
64
* Generates a JSON-LD document by compacting the given body and context.
75
*
@@ -17,12 +15,11 @@ export const generateJsonld = async <
1715
>(
1816
body: T,
1917
context: C,
20-
bodyCip: string = CIP_108,
2118
) => {
2219
const doc = {
23-
[`${bodyCip}body`]: body,
24-
[`${CIP_100}hashAlgorithm`]: "blake2b-256",
25-
[`${CIP_100}authors`]: [],
20+
"@context": context,
21+
hashAlgorithm: "blake2b-256",
22+
body,
2623
};
2724

2825
const json = await jsonld.compact(doc, context);

0 commit comments

Comments
 (0)