From 0406b8c6fe07f4d3558d8c9994a7e96ed6220b30 Mon Sep 17 00:00:00 2001 From: Juan Manuel Rodriguez Defago Date: Mon, 18 Apr 2022 23:19:00 -0300 Subject: [PATCH] Swapped fromBytes to try_fromBytes in fetchGraphAccountMetadata --- src/mappings/metadataHelpers.template.ts | 49 +++++++++++++----------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/mappings/metadataHelpers.template.ts b/src/mappings/metadataHelpers.template.ts index 9864d91c..382b0fea 100644 --- a/src/mappings/metadataHelpers.template.ts +++ b/src/mappings/metadataHelpers.template.ts @@ -7,31 +7,34 @@ export function fetchGraphAccountMetadata(graphAccount: GraphAccount, ipfsHash: {{#ipfs}} let ipfsData = ipfs.cat(ipfsHash) if (ipfsData !== null) { - let data = json.fromBytes(ipfsData as Bytes).toObject() - graphAccount.codeRepository = jsonToString(data.get('codeRepository')) - graphAccount.description = jsonToString(data.get('description')) - graphAccount.image = jsonToString(data.get('image')) - graphAccount.displayName = jsonToString(data.get('displayName')) - let isOrganization = data.get('isOrganization') - if (isOrganization != null && isOrganization.kind === JSONValueKind.BOOL) { - graphAccount.isOrganization = isOrganization.toBool() - } - graphAccount.website = jsonToString(data.get('website')) - graphAccount.save() - - // Update all associated vesting contract addresses - let tlws = graphAccount.tokenLockWallets - for (let i = 0; i < tlws.length; i++) { - let tlw = GraphAccount.load(tlws[i])! - tlw.codeRepository = graphAccount.codeRepository - tlw.description = graphAccount.description - tlw.image = graphAccount.image - tlw.displayName = graphAccount.displayName + let tryData = json.try_fromBytes(ipfsData as Bytes) + if(tryData.isOk) { + let data = tryData.value.toObject() + graphAccount.codeRepository = jsonToString(data.get('codeRepository')) + graphAccount.description = jsonToString(data.get('description')) + graphAccount.image = jsonToString(data.get('image')) + graphAccount.displayName = jsonToString(data.get('displayName')) + let isOrganization = data.get('isOrganization') if (isOrganization != null && isOrganization.kind === JSONValueKind.BOOL) { - tlw.isOrganization = isOrganization.toBool() + graphAccount.isOrganization = isOrganization.toBool() + } + graphAccount.website = jsonToString(data.get('website')) + graphAccount.save() + + // Update all associated vesting contract addresses + let tlws = graphAccount.tokenLockWallets + for (let i = 0; i < tlws.length; i++) { + let tlw = GraphAccount.load(tlws[i])! + tlw.codeRepository = graphAccount.codeRepository + tlw.description = graphAccount.description + tlw.image = graphAccount.image + tlw.displayName = graphAccount.displayName + if (isOrganization != null && isOrganization.kind === JSONValueKind.BOOL) { + tlw.isOrganization = isOrganization.toBool() + } + tlw.website = graphAccount.website + tlw.save() } - tlw.website = graphAccount.website - tlw.save() } } {{/ipfs}}