Skip to content

refactor: extract-dispute-templates-to-root #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 1 addition & 93 deletions contracts/deploy/00-curate-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"typescript": "^5.1.3"
},
"dependencies": {
"@kleros/curate-v2-templates": "workspace:^",
"@kleros/kleros-v2-contracts": "^0.3.2"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"web",
"eslint-config",
"prettier-config",
"tsconfig"
"tsconfig",
"templates"
],
"packageManager": "[email protected]+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186",
"volta": {
Expand Down
92 changes: 92 additions & 0 deletions templates/index.ts
Original file line number Diff line number Diff line change
@@ -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"
]
}
]`;
11 changes: 11 additions & 0 deletions templates/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
94 changes: 1 addition & 93 deletions web/src/utils/submitListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"
]
}
]`;
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Loading