diff --git a/contracts/deploy/00-curate-v2.ts b/contracts/deploy/00-curate-v2.ts index 5a16458..44a0bd7 100644 --- a/contracts/deploy/00-curate-v2.ts +++ b/contracts/deploy/00-curate-v2.ts @@ -3,99 +3,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { DeployFunction } from "hardhat-deploy/types"; import { HomeChains, isSkipped } from "./utils"; import { CurateFactory, CurateV2 } from "../typechain-types"; - -const sharedTemplateProperties = ` - "policyURI": "{{{policyURI}}}", - "frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}", - "arbitrableChainID": "421614", - "arbitrableAddress": "{{arbitrableAddress}}", - "arbitratorChainID": "421614", - "arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b", - "metadata": { - "itemName": "{{itemName}}", - "itemDescription": "{{itemDescription}}", - "registryTitle": "{{registryTitle}}", - "registryDescription": "{{registryDescription}}" - }, - "category": "Curated Lists", - "version": "1.0"`; - -const registrationTemplate = `{ - "$schema": "../NewDisputeTemplate.schema.json", - "title": "Add a {{itemName}} to {{registryTitle}}", - "description": "Someone requested to add an {{itemName}} to {{registryTitle}}", - "question": "Does the {{itemName}} comply with the required criteria?", - "answers": [ - { - "title": "Yes, Add It", - "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added." - }, - { - "title": "No, Don't Add It", - "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added." - } - ], ${sharedTemplateProperties} -} -`; - -const removalTemplate = `{ - "$schema": "../NewDisputeTemplate.schema.json", - "title": "Remove a {{itemName}} from {{registryTitle}}", - "description": "Someone requested to remove a {{itemName}} from {{registryTitle}}", - "question": "Does the {{itemName}} comply with the required criteria?", - "answers": [ - { - "title": "Yes, Remove It", - "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed." - }, - { - "title": "No, Don't Remove It", - "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed." - } - ], ${sharedTemplateProperties} -} -`; - -const dataMappings = `[ - { - "type": "graphql", - "endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv", - "query": "query SearchRequestByDisputeID($externalDisputeID: BigInt!) { requests(where: { externalDisputeID: $externalDisputeID }) { id disputeID submissionTime resolved requester { id } challenger { id } arbitrator arbitratorExtraData deposit disputeOutcome requestType item { id itemID data status registry { id title description policyURI } } } }", - "variables": { - "externalDisputeID": "{{externalDisputeID}}" - }, - "seek": [ - "requests[0].item.registry.title", - "requests[0].item.registry.description", - "requests[0].item.registry.policyURI", - "requests[0].item.id", - "requests[0].item.data", - "requests[0].item.status", - "requests[0].item.registry.id" - ], - "populate": [ - "registryTitle", - "registryDescription", - "policyURI", - "itemID", - "itemData", - "itemStatus", - "listAddress" - ] - }, - { - "type": "json", - "value": "{{{itemData}}}", - "seek": [ - "columns[0].label", - "columns[0].description" - ], - "populate": [ - "itemName", - "itemDescription" - ] - } -]`; +import { registrationTemplate, removalTemplate, dataMappings } from "@kleros/curate-v2-templates"; const listMetadata = `{ "title": "Kleros Curate", diff --git a/contracts/package.json b/contracts/package.json index 5495c66..4d19250 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -85,6 +85,7 @@ "typescript": "^5.1.3" }, "dependencies": { + "@kleros/curate-v2-templates": "workspace:^", "@kleros/kleros-v2-contracts": "^0.3.2" } } diff --git a/package.json b/package.json index 0f085d9..961ead0 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "web", "eslint-config", "prettier-config", - "tsconfig" + "tsconfig", + "templates" ], "packageManager": "yarn@4.0.2+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186", "volta": { diff --git a/templates/index.ts b/templates/index.ts new file mode 100644 index 0000000..0b6c41e --- /dev/null +++ b/templates/index.ts @@ -0,0 +1,92 @@ +const sharedTemplateProperties = ` + "policyURI": "{{{policyURI}}}", + "frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}", + "arbitrableChainID": "421614", + "arbitrableAddress": "{{arbitrableAddress}}", + "arbitratorChainID": "421614", + "arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b", + "metadata": { + "itemName": "{{itemName}}", + "itemDescription": "{{itemDescription}}", + "registryTitle": "{{registryTitle}}", + "registryDescription": "{{registryDescription}}" + }, + "category": "Curated Lists", + "version": "1.0"`; + +export const registrationTemplate = `{ + "$schema": "../NewDisputeTemplate.schema.json", + "title": "Add a {{itemName}} to {{registryTitle}}", + "description": "Someone requested to add an {{itemName}} to {{registryTitle}}", + "question": "Does the {{itemName}} comply with the required criteria?", + "answers": [ + { + "title": "Yes, Add It", + "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added." + }, + { + "title": "No, Don't Add It", + "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added." + } + ], ${sharedTemplateProperties} +} +`; + +export const removalTemplate = `{ + "$schema": "../NewDisputeTemplate.schema.json", + "title": "Remove a {{itemName}} from {{registryTitle}}", + "description": "Someone requested to remove a {{itemName}} from {{registryTitle}}", + "question": "Does the {{itemName}} comply with the required criteria?", + "answers": [ + { + "title": "Yes, Remove It", + "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed." + }, + { + "title": "No, Don't Remove It", + "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed." + } + ], ${sharedTemplateProperties} +} +`; + +export const dataMappings = `[ + { + "type": "graphql", + "endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv", + "query": "query SearchRequestByDisputeID($externalDisputeID: BigInt!) { requests(where: { externalDisputeID: $externalDisputeID }) { id disputeID submissionTime resolved requester { id } challenger { id } arbitrator arbitratorExtraData deposit disputeOutcome requestType item { id itemID data status registry { id title description policyURI } } } }", + "variables": { + "externalDisputeID": "{{externalDisputeID}}" + }, + "seek": [ + "requests[0].item.registry.title", + "requests[0].item.registry.description", + "requests[0].item.registry.policyURI", + "requests[0].item.id", + "requests[0].item.data", + "requests[0].item.status", + "requests[0].item.registry.id" + ], + "populate": [ + "registryTitle", + "registryDescription", + "policyURI", + "itemID", + "itemData", + "itemStatus", + "listAddress" + ] + }, + { + "type": "json", + "value": "{{{itemData}}}", + "seek": [ + "columns[0].label", + "columns[0].description" + ], + "populate": [ + "itemName", + "itemDescription" + ] + } +]`; diff --git a/templates/package.json b/templates/package.json new file mode 100644 index 0000000..0547054 --- /dev/null +++ b/templates/package.json @@ -0,0 +1,11 @@ +{ + "name": "@kleros/curate-v2-templates", + "version": "1.0.0", + "description": "", + "main": "index.ts", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/web/package.json b/web/package.json index 4a7edab..863f1fc 100644 --- a/web/package.json +++ b/web/package.json @@ -73,6 +73,7 @@ }, "dependencies": { "@filebase/client": "^0.0.5", + "@kleros/curate-v2-templates": "workspace:^", "@kleros/ui-components-library": "^2.13.1", "@middy/core": "^5.3.5", "@middy/http-json-body-parser": "^5.3.5", diff --git a/web/src/utils/submitListUtils.ts b/web/src/utils/submitListUtils.ts index c3cdb29..bad2701 100644 --- a/web/src/utils/submitListUtils.ts +++ b/web/src/utils/submitListUtils.ts @@ -5,6 +5,7 @@ import { isUndefined } from "."; import { TEMPLATE_REGISTRY } from "consts/arbitration"; import { ItemDetailsFragment, Status } from "src/graphql/graphql"; import { arbitrum } from "viem/chains"; +import { registrationTemplate, removalTemplate, dataMappings } from "@kleros/curate-v2-templates"; export const constructListParams = (listData: IListData, listMetadata: IListMetadata) => { const baseTemplate = { ...listData } as IList; @@ -112,96 +113,3 @@ const getMockValueForType = (type: string) => { return "Ethereum"; } }; - -const sharedTemplateProperties = ` - "policyURI": "{{{policyURI}}}", - "frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}", - "arbitrableChainID": "421614", - "arbitrableAddress": "{{arbitrableAddress}}", - "arbitratorChainID": "421614", - "arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b", - "metadata": { - "itemName": "{{itemName}}", - "itemDescription": "{{itemDescription}}", - "registryTitle": "{{registryTitle}}", - "registryDescription": "{{registryDescription}}" - }, - "category": "Curated Lists", - "version": "1.0"`; - -const registrationTemplate = `{ - "$schema": "../NewDisputeTemplate.schema.json", - "title": "Add a {{itemName}} to {{registryTitle}}", - "description": "Someone requested to add an {{itemName}} to {{registryTitle}}", - "question": "Does the {{itemName}} comply with the required criteria?", - "answers": [ - { - "title": "Yes, Add It", - "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added." - }, - { - "title": "No, Don't Add It", - "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added." - } - ], ${sharedTemplateProperties} -} -`; - -const removalTemplate = `{ - "$schema": "../NewDisputeTemplate.schema.json", - "title": "Remove a {{itemName}} from {{registryTitle}}", - "description": "Someone requested to remove a {{itemName}} from {{registryTitle}}", - "question": "Does the {{itemName}} comply with the required criteria?", - "answers": [ - { - "title": "Yes, Remove It", - "description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed." - }, - { - "title": "No, Don't Remove It", - "description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed." - } - ], ${sharedTemplateProperties} -} -`; - -const dataMappings = `[ - { - "type": "graphql", - "endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv", - "query": "query SearchRequestByDisputeID($externalDisputeID: BigInt!) { requests(where: { externalDisputeID: $externalDisputeID }) { id disputeID submissionTime resolved requester { id } challenger { id } arbitrator arbitratorExtraData deposit disputeOutcome requestType item { id itemID data status registry { id title description policyURI } } } }", - "variables": { - "externalDisputeID": "{{externalDisputeID}}" - }, - "seek": [ - "requests[0].item.registry.title", - "requests[0].item.registry.description", - "requests[0].item.registry.policyURI", - "requests[0].item.id", - "requests[0].item.data", - "requests[0].item.status", - "requests[0].item.registry.id" - ], - "populate": [ - "registryTitle", - "registryDescription", - "policyURI", - "itemID", - "itemData", - "itemStatus", - "listAddress" - ] - }, - { - "type": "json", - "value": "{{{itemData}}}", - "seek": [ - "columns[0].label", - "columns[0].description" - ], - "populate": [ - "itemName", - "itemDescription" - ] - } -]`; diff --git a/yarn.lock b/yarn.lock index f22d09d..a334849 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4696,6 +4696,7 @@ __metadata: dependencies: "@kleros/curate-v2-eslint-config": "workspace:^" "@kleros/curate-v2-prettier-config": "workspace:^" + "@kleros/curate-v2-templates": "workspace:^" "@kleros/curate-v2-tsconfig": "workspace:^" "@kleros/kleros-v2-contracts": "npm:^0.3.2" "@logtail/pino": "npm:^0.4.0" @@ -4775,6 +4776,12 @@ __metadata: languageName: unknown linkType: soft +"@kleros/curate-v2-templates@workspace:^, @kleros/curate-v2-templates@workspace:templates": + version: 0.0.0-use.local + resolution: "@kleros/curate-v2-templates@workspace:templates" + languageName: unknown + linkType: soft + "@kleros/curate-v2-tsconfig@workspace:^, @kleros/curate-v2-tsconfig@workspace:tsconfig": version: 0.0.0-use.local resolution: "@kleros/curate-v2-tsconfig@workspace:tsconfig" @@ -4790,6 +4797,7 @@ __metadata: "@filebase/client": "npm:^0.0.5" "@graphql-codegen/cli": "npm:^4.0.1" "@graphql-codegen/client-preset": "npm:^4.2.0" + "@kleros/curate-v2-templates": "workspace:^" "@kleros/kleros-v2-contracts": "npm:^0.3.2" "@kleros/ui-components-library": "npm:^2.13.1" "@middy/core": "npm:^5.3.5"