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(#minor); Aave Governance; Parse non-json proposal data #2316

Merged
merged 2 commits into from
Aug 8, 2023
Merged
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
24 changes: 17 additions & 7 deletions subgraphs/aave-governance/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ import {
DelegateChange,
} from "../generated/schema";

// eslint-disable-next-line @typescript-eslint/no-magic-numbers
export const SECONDS_PER_DAY = 60 * 60 * 24;

// eslint-disable-next-line @typescript-eslint/no-magic-numbers
export function toDecimal(value: BigInt, decimals: number = 18): BigDecimal {
return value.divDecimal(
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
BigInt.fromI32(10)
.pow(<u8>decimals)
.toBigDecimal()
Expand Down Expand Up @@ -272,13 +275,20 @@ export function _handleProposalCreated(
"1220" + ipfsHash.toHexString().slice(2)
).toBase58();
const data = ipfs.cat(hash);
const proposalData = json.try_fromBytes(data as Bytes);
let descriptionJSON: JSONValue | null = null;
if (proposalData.isOk && proposalData.value.kind == JSONValueKind.OBJECT) {
const jsonData = proposalData.value.toObject();
descriptionJSON = jsonData.get("description");
if (descriptionJSON) {
description = descriptionJSON.toString();
if (data) {
const proposalData = json.try_fromBytes(data as Bytes);
let descriptionJSON: JSONValue | null = null;
if (proposalData.isOk) {
// proposalData is either a JSON object or a raw string
if (proposalData.value.kind == JSONValueKind.OBJECT) {
const jsonData = proposalData.value.toObject();
descriptionJSON = jsonData.get("description");
if (descriptionJSON) {
description = descriptionJSON.toString();
}
}
} else {
description = data.toString();
}
}
proposal.description = description;
Expand Down
Loading