diff --git a/subgraph/build/Contract/Contract.wasm b/subgraph/build/Contract/Contract.wasm index d77e7db..75f1c00 100644 Binary files a/subgraph/build/Contract/Contract.wasm and b/subgraph/build/Contract/Contract.wasm differ diff --git a/subgraph/src/helpers/ignore.ts b/subgraph/src/helpers/ignore.ts new file mode 100644 index 0000000..a480961 --- /dev/null +++ b/subgraph/src/helpers/ignore.ts @@ -0,0 +1,2 @@ +export let skipBlocks: number[] = [6891630] + diff --git a/subgraph/src/helpers/json.ts b/subgraph/src/helpers/json.ts new file mode 100644 index 0000000..6efbb46 --- /dev/null +++ b/subgraph/src/helpers/json.ts @@ -0,0 +1,7 @@ +import { Bytes } from "@graphprotocol/graph-ts" + +export function isJson(manifest: Bytes): boolean { + let manifestString = manifest.toHexString() + let first = manifestString.slice(0, 4) + return first == '0x7b' +} diff --git a/subgraph/src/mapping.ts b/subgraph/src/mapping.ts index a7902a6..4bb105d 100644 --- a/subgraph/src/mapping.ts +++ b/subgraph/src/mapping.ts @@ -15,6 +15,8 @@ import { DonateCall, } from "../generated/Contract/Contract" import { Profile, PledgesInfo, Pledge, ProjectInfo } from "../generated/schema" +import { skipBlocks } from "./helpers/ignore" +import { isJson } from "./helpers/json" export function handleAddGiver(call: AddGiverCall): void { @@ -66,12 +68,11 @@ export function handleUpdateProject(call: UpdateProjectCall): void { function createProjectInfo(content: String, profile: Profile, isFile: boolean = false): void { let hash = content.split('/').slice(-1)[0] let contentHash = isFile ? hash : hash + '/manifest.json' - let manifest = ipfs.cat(contentHash) + let manifest: Bytes | null = ipfs.cat(contentHash) if (manifest == null) { - log.info('manifest is null', []) if (!isFile) createProjectInfo(content, profile, true) - } else { + } else if (isJson(manifest as Bytes)) { let parsed = json.fromBytes(manifest as Bytes).toObject() log.info( 'ipfs title: {}',