-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from kleros/feat/fix-request-requester
Chore/migrate to file data source and fix request requester
- Loading branch information
Showing
11 changed files
with
180 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Bytes, dataSource, json, log } from '@graphprotocol/graph-ts'; | ||
import { LRegistryMetadata } from '../../generated/schema'; | ||
import { JSONValueToBool, JSONValueToMaybeString } from '../utils'; | ||
|
||
export function handleLRegistryMetadata(content: Bytes): void { | ||
const ipfsHash = dataSource.stringParam(); | ||
|
||
const value = json.fromBytes(content).toObject(); | ||
|
||
const context = dataSource.context(); | ||
const count = context.getBigInt('count'); | ||
const address = context.getString('address'); | ||
|
||
const id = `${ipfsHash}-${address}-${count.toString()}`; | ||
|
||
const metadata = new LRegistryMetadata(id); | ||
|
||
log.debug(`ipfs hash : {}, content : {}`, [ipfsHash, content.toString()]); | ||
|
||
if (!value) { | ||
log.warning(`Error converting object for hash {}`, [ipfsHash]); | ||
metadata.save(); | ||
return; | ||
} | ||
|
||
const metadataValue = value.get('metadata'); | ||
if (!metadataValue) { | ||
log.error(`Error getting metadata values from ipfs hash {}`, [ipfsHash]); | ||
metadata.save(); | ||
return; | ||
} | ||
|
||
const data = metadataValue.toObject(); | ||
|
||
const title = data.get('tcrTitle'); | ||
const description = data.get('tcrDescription'); | ||
const itemName = data.get('itemName'); | ||
const itemNamePlural = data.get('itemNamePlural'); | ||
const isConnectedTCR = data.get('isConnectedTCR'); | ||
const requireRemovalEvidence = data.get('requireRemovalEvidence'); | ||
const isTCRofTcrs = data.get('isTCRofTcrs'); | ||
const parentTCRAddress = data.get('parentTCRAddress'); | ||
const relTcrDisabled = data.get('relTcrDisabled'); | ||
|
||
metadata.title = JSONValueToMaybeString(title); | ||
metadata.description = JSONValueToMaybeString(description); | ||
metadata.itemName = JSONValueToMaybeString(itemName); | ||
metadata.parentTCRAddress = JSONValueToMaybeString(parentTCRAddress); | ||
metadata.itemNamePlural = JSONValueToMaybeString(itemNamePlural); | ||
metadata.isConnectedTCR = JSONValueToBool(isConnectedTCR); | ||
metadata.requireRemovalEvidence = JSONValueToBool(requireRemovalEvidence); | ||
metadata.isTCRofTcrs = JSONValueToBool(isTCRofTcrs); | ||
metadata.relTcrDisabled = JSONValueToBool(relTcrDisabled); | ||
|
||
metadata.save(); | ||
} |
Oops, something went wrong.