Skip to content

Commit

Permalink
Swapped fromBytes to try_fromBytes in fetchGraphAccountMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmardefago committed Apr 26, 2022
1 parent 74d9cd5 commit 0406b8c
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/mappings/metadataHelpers.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 0406b8c

Please sign in to comment.