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

Fix/1856 missing off chain data #2093

Merged
merged 2 commits into from
Oct 2, 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
3 changes: 3 additions & 0 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SELECT
newestRegister.time AS last_register_time,
COALESCE(latestDeposit.deposit, 0),
non_deregister_voting_anchor.url IS NOT NULL AS has_non_deregister_voting_anchor,
off_chain_vote_fetch_error.fetch_error,
off_chain_vote_drep_data.payment_address,
off_chain_vote_drep_data.given_name,
off_chain_vote_drep_data.objectives,
Expand Down Expand Up @@ -96,6 +97,7 @@ FROM
AND DRepDistr.rn = 1
LEFT JOIN voting_anchor va ON va.id = dr_voting_anchor.voting_anchor_id
LEFT JOIN voting_anchor non_deregister_voting_anchor on non_deregister_voting_anchor.id = dr_non_deregister_voting_anchor.voting_anchor_id
LEFT JOIN off_chain_vote_fetch_error ON off_chain_vote_fetch_error.voting_anchor_id = va.id
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = va.id
LEFT JOIN off_chain_vote_drep_data on off_chain_vote_drep_data.off_chain_vote_data_id = off_chain_vote_data.id
CROSS JOIN DRepActivity
Expand Down Expand Up @@ -138,6 +140,7 @@ GROUP BY
newestRegister.time,
latestDeposit.deposit,
non_deregister_voting_anchor.url,
off_chain_vote_fetch_error.fetch_error,
off_chain_vote_drep_data.payment_address,
off_chain_vote_drep_data.given_name,
off_chain_vote_drep_data.objectives,
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ drepRegistrationToDrep Types.DRepRegistration {..} =
dRepType = mapDRepType dRepRegistrationType,
dRepLatestTxHash = HexText <$> dRepRegistrationLatestTxHash,
dRepLatestRegistrationDate = dRepRegistrationLatestRegistrationDate,
dRepMetadataError = dRepRegistrationMetadataError,
dRepPaymentAddress = dRepRegistrationPaymentAddress,
dRepGivenName = dRepRegistrationGivenName,
dRepObjectives = dRepRegistrationObjectives,
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ data DRep
, dRepType :: DRepType
, dRepLatestTxHash :: Maybe HexText
, dRepLatestRegistrationDate :: UTCTime
, dRepMetadataError :: Maybe Text
, dRepPaymentAddress :: Maybe Text
, dRepGivenName :: Maybe Text
, dRepObjectives :: Maybe Text
Expand Down
3 changes: 2 additions & 1 deletion govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ listDReps = withPool $ \conn -> do
results <- liftIO $ SQL.query_ conn listDRepsSql
timeZone <- liftIO getCurrentTimeZone
return
[ DRepRegistration drepHash drepView url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) paymentAddress givenName objectives motivations qualifications imageUrl imageHash
[ DRepRegistration drepHash drepView url dataHash (floor @Scientific deposit) votingPower status drepType txHash (localTimeToUTC timeZone date) metadataError paymentAddress givenName objectives motivations qualifications imageUrl imageHash
| ( drepHash
, drepView
, url
Expand All @@ -73,6 +73,7 @@ listDReps = withPool $ \conn -> do
, date
, latestDeposit
, latestNonDeregisterVotingAnchorWasNotNull
, metadataError
, paymentAddress
, givenName
, objectives
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ data DRepRegistration
, dRepRegistrationType :: DRepType
, dRepRegistrationLatestTxHash :: Maybe Text
, dRepRegistrationLatestRegistrationDate :: UTCTime
, dRepRegistrationMetadataError :: Maybe Text
, dRepRegistrationPaymentAddress :: Maybe Text
, dRepRegistrationGivenName :: Maybe Text
, dRepRegistrationObjectives :: Maybe Text
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/consts/dRepActions/jsonContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const CIP_119 =
"https://github.com/cardano-foundation/CIPs/blob/master/CIP-0119/README.md#";

export const DREP_CONTEXT = {
"@language": "en-us",
CIP100:
"https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#",
CIP119: CIP_119,
Expand Down
2 changes: 1 addition & 1 deletion govtool/metadata-validation/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AppService {
if (hashedMetadata !== hash) {
// Optionally validate on a parsed metadata
const hashedParsedMetadata = blake.blake2bHex(
JSON.stringify(parsedData),
JSON.stringify(parsedData, null, 2),
undefined,
32,
);
Expand Down
9 changes: 5 additions & 4 deletions govtool/metadata-validation/src/utils/getFieldValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const getFieldValue = (
body: Record<string, unknown>,
field: string,
): unknown => {
if (body[field] && body[field]['@value']) {
return body[field]['@value'];
const fieldValue = body[field];
if (fieldValue.hasOwnProperty('@value')) {
return fieldValue['@value'];
}

if (body[field]) {
return body[field];
if (fieldValue) {
return fieldValue;
}

return undefined;
Expand Down
7 changes: 6 additions & 1 deletion govtool/metadata-validation/src/utils/parseMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export const parseMetadata = (body: Record<string, unknown>) => {
const metadata = {};

Object.keys(body).forEach((key) => {
metadata[key] = getFieldValue(body, key);
if (key === 'references') {
const parsedReferences = (body[key] as Record<string, unknown>[]).map((reference) => parseMetadata(reference));
metadata[key] = parsedReferences;
} else {
metadata[key] = getFieldValue(body, key);
}
});
return metadata;
};
Loading