Skip to content

Commit cb5ccc8

Browse files
authored
Merge pull request #47 from kleros/refactor/extract-dispute-template-to-root
refactor: extract-dispute-templates-to-root
2 parents b5fbdd5 + 2bb2ca1 commit cb5ccc8

File tree

8 files changed

+117
-187
lines changed

8 files changed

+117
-187
lines changed

contracts/deploy/00-curate-v2.ts

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,99 +3,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
44
import { HomeChains, isSkipped } from "./utils";
55
import { CurateFactory, CurateV2 } from "../typechain-types";
6-
7-
const sharedTemplateProperties = `
8-
"policyURI": "{{{policyURI}}}",
9-
"frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}",
10-
"arbitrableChainID": "421614",
11-
"arbitrableAddress": "{{arbitrableAddress}}",
12-
"arbitratorChainID": "421614",
13-
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b",
14-
"metadata": {
15-
"itemName": "{{itemName}}",
16-
"itemDescription": "{{itemDescription}}",
17-
"registryTitle": "{{registryTitle}}",
18-
"registryDescription": "{{registryDescription}}"
19-
},
20-
"category": "Curated Lists",
21-
"version": "1.0"`;
22-
23-
const registrationTemplate = `{
24-
"$schema": "../NewDisputeTemplate.schema.json",
25-
"title": "Add a {{itemName}} to {{registryTitle}}",
26-
"description": "Someone requested to add an {{itemName}} to {{registryTitle}}",
27-
"question": "Does the {{itemName}} comply with the required criteria?",
28-
"answers": [
29-
{
30-
"title": "Yes, Add It",
31-
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added."
32-
},
33-
{
34-
"title": "No, Don't Add It",
35-
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added."
36-
}
37-
], ${sharedTemplateProperties}
38-
}
39-
`;
40-
41-
const removalTemplate = `{
42-
"$schema": "../NewDisputeTemplate.schema.json",
43-
"title": "Remove a {{itemName}} from {{registryTitle}}",
44-
"description": "Someone requested to remove a {{itemName}} from {{registryTitle}}",
45-
"question": "Does the {{itemName}} comply with the required criteria?",
46-
"answers": [
47-
{
48-
"title": "Yes, Remove It",
49-
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed."
50-
},
51-
{
52-
"title": "No, Don't Remove It",
53-
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed."
54-
}
55-
], ${sharedTemplateProperties}
56-
}
57-
`;
58-
59-
const dataMappings = `[
60-
{
61-
"type": "graphql",
62-
"endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv",
63-
"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 } } } }",
64-
"variables": {
65-
"externalDisputeID": "{{externalDisputeID}}"
66-
},
67-
"seek": [
68-
"requests[0].item.registry.title",
69-
"requests[0].item.registry.description",
70-
"requests[0].item.registry.policyURI",
71-
"requests[0].item.id",
72-
"requests[0].item.data",
73-
"requests[0].item.status",
74-
"requests[0].item.registry.id"
75-
],
76-
"populate": [
77-
"registryTitle",
78-
"registryDescription",
79-
"policyURI",
80-
"itemID",
81-
"itemData",
82-
"itemStatus",
83-
"listAddress"
84-
]
85-
},
86-
{
87-
"type": "json",
88-
"value": "{{{itemData}}}",
89-
"seek": [
90-
"columns[0].label",
91-
"columns[0].description"
92-
],
93-
"populate": [
94-
"itemName",
95-
"itemDescription"
96-
]
97-
}
98-
]`;
6+
import { registrationTemplate, removalTemplate, dataMappings } from "@kleros/curate-v2-templates";
997

1008
const listMetadata = `{
1019
"title": "Kleros Curate",

contracts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"typescript": "^5.1.3"
8686
},
8787
"dependencies": {
88+
"@kleros/curate-v2-templates": "workspace:^",
8889
"@kleros/kleros-v2-contracts": "^0.3.2"
8990
}
9091
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"web",
2323
"eslint-config",
2424
"prettier-config",
25-
"tsconfig"
25+
"tsconfig",
26+
"templates"
2627
],
2728
"packageManager": "[email protected]+sha256.825003a0f561ad09a3b1ac4a3b3ea6207af2796d54f62a9420520915721f5186",
2829
"volta": {

templates/index.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
const sharedTemplateProperties = `
2+
"policyURI": "{{{policyURI}}}",
3+
"frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}",
4+
"arbitrableChainID": "421614",
5+
"arbitrableAddress": "{{arbitrableAddress}}",
6+
"arbitratorChainID": "421614",
7+
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b",
8+
"metadata": {
9+
"itemName": "{{itemName}}",
10+
"itemDescription": "{{itemDescription}}",
11+
"registryTitle": "{{registryTitle}}",
12+
"registryDescription": "{{registryDescription}}"
13+
},
14+
"category": "Curated Lists",
15+
"version": "1.0"`;
16+
17+
export const registrationTemplate = `{
18+
"$schema": "../NewDisputeTemplate.schema.json",
19+
"title": "Add a {{itemName}} to {{registryTitle}}",
20+
"description": "Someone requested to add an {{itemName}} to {{registryTitle}}",
21+
"question": "Does the {{itemName}} comply with the required criteria?",
22+
"answers": [
23+
{
24+
"title": "Yes, Add It",
25+
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added."
26+
},
27+
{
28+
"title": "No, Don't Add It",
29+
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added."
30+
}
31+
], ${sharedTemplateProperties}
32+
}
33+
`;
34+
35+
export const removalTemplate = `{
36+
"$schema": "../NewDisputeTemplate.schema.json",
37+
"title": "Remove a {{itemName}} from {{registryTitle}}",
38+
"description": "Someone requested to remove a {{itemName}} from {{registryTitle}}",
39+
"question": "Does the {{itemName}} comply with the required criteria?",
40+
"answers": [
41+
{
42+
"title": "Yes, Remove It",
43+
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed."
44+
},
45+
{
46+
"title": "No, Don't Remove It",
47+
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed."
48+
}
49+
], ${sharedTemplateProperties}
50+
}
51+
`;
52+
53+
export const dataMappings = `[
54+
{
55+
"type": "graphql",
56+
"endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv",
57+
"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 } } } }",
58+
"variables": {
59+
"externalDisputeID": "{{externalDisputeID}}"
60+
},
61+
"seek": [
62+
"requests[0].item.registry.title",
63+
"requests[0].item.registry.description",
64+
"requests[0].item.registry.policyURI",
65+
"requests[0].item.id",
66+
"requests[0].item.data",
67+
"requests[0].item.status",
68+
"requests[0].item.registry.id"
69+
],
70+
"populate": [
71+
"registryTitle",
72+
"registryDescription",
73+
"policyURI",
74+
"itemID",
75+
"itemData",
76+
"itemStatus",
77+
"listAddress"
78+
]
79+
},
80+
{
81+
"type": "json",
82+
"value": "{{{itemData}}}",
83+
"seek": [
84+
"columns[0].label",
85+
"columns[0].description"
86+
],
87+
"populate": [
88+
"itemName",
89+
"itemDescription"
90+
]
91+
}
92+
]`;

templates/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@kleros/curate-v2-templates",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.ts",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
},
7474
"dependencies": {
7575
"@filebase/client": "^0.0.5",
76+
"@kleros/curate-v2-templates": "workspace:^",
7677
"@kleros/ui-components-library": "^2.13.1",
7778
"@middy/core": "^5.3.5",
7879
"@middy/http-json-body-parser": "^5.3.5",

web/src/utils/submitListUtils.ts

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isUndefined } from ".";
55
import { TEMPLATE_REGISTRY } from "consts/arbitration";
66
import { ItemDetailsFragment, Status } from "src/graphql/graphql";
77
import { arbitrum } from "viem/chains";
8+
import { registrationTemplate, removalTemplate, dataMappings } from "@kleros/curate-v2-templates";
89

910
export const constructListParams = (listData: IListData, listMetadata: IListMetadata) => {
1011
const baseTemplate = { ...listData } as IList;
@@ -112,96 +113,3 @@ const getMockValueForType = (type: string) => {
112113
return "Ethereum";
113114
}
114115
};
115-
116-
const sharedTemplateProperties = `
117-
"policyURI": "{{{policyURI}}}",
118-
"frontendUrl": "https://curate-v2.kleros.builders/#/lists/item/{{itemID}}",
119-
"arbitrableChainID": "421614",
120-
"arbitrableAddress": "{{arbitrableAddress}}",
121-
"arbitratorChainID": "421614",
122-
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b",
123-
"metadata": {
124-
"itemName": "{{itemName}}",
125-
"itemDescription": "{{itemDescription}}",
126-
"registryTitle": "{{registryTitle}}",
127-
"registryDescription": "{{registryDescription}}"
128-
},
129-
"category": "Curated Lists",
130-
"version": "1.0"`;
131-
132-
const registrationTemplate = `{
133-
"$schema": "../NewDisputeTemplate.schema.json",
134-
"title": "Add a {{itemName}} to {{registryTitle}}",
135-
"description": "Someone requested to add an {{itemName}} to {{registryTitle}}",
136-
"question": "Does the {{itemName}} comply with the required criteria?",
137-
"answers": [
138-
{
139-
"title": "Yes, Add It",
140-
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should be added."
141-
},
142-
{
143-
"title": "No, Don't Add It",
144-
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should not be added."
145-
}
146-
], ${sharedTemplateProperties}
147-
}
148-
`;
149-
150-
const removalTemplate = `{
151-
"$schema": "../NewDisputeTemplate.schema.json",
152-
"title": "Remove a {{itemName}} from {{registryTitle}}",
153-
"description": "Someone requested to remove a {{itemName}} from {{registryTitle}}",
154-
"question": "Does the {{itemName}} comply with the required criteria?",
155-
"answers": [
156-
{
157-
"title": "Yes, Remove It",
158-
"description": "Select this if you think that the {{itemName}} does not comply with the required criteria and should be removed."
159-
},
160-
{
161-
"title": "No, Don't Remove It",
162-
"description": "Select this if you think that the {{itemName}} does comply with the required criteria and should not be removed."
163-
}
164-
], ${sharedTemplateProperties}
165-
}
166-
`;
167-
168-
const dataMappings = `[
169-
{
170-
"type": "graphql",
171-
"endpoint": "https://gateway-arbitrum.network.thegraph.com/api/{{{graphApiKey}}}/subgraphs/id/H93eWJbDpYKAtkLmsMn7Su3ZLZwAwLN5VoyvQH4NbGAv",
172-
"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 } } } }",
173-
"variables": {
174-
"externalDisputeID": "{{externalDisputeID}}"
175-
},
176-
"seek": [
177-
"requests[0].item.registry.title",
178-
"requests[0].item.registry.description",
179-
"requests[0].item.registry.policyURI",
180-
"requests[0].item.id",
181-
"requests[0].item.data",
182-
"requests[0].item.status",
183-
"requests[0].item.registry.id"
184-
],
185-
"populate": [
186-
"registryTitle",
187-
"registryDescription",
188-
"policyURI",
189-
"itemID",
190-
"itemData",
191-
"itemStatus",
192-
"listAddress"
193-
]
194-
},
195-
{
196-
"type": "json",
197-
"value": "{{{itemData}}}",
198-
"seek": [
199-
"columns[0].label",
200-
"columns[0].description"
201-
],
202-
"populate": [
203-
"itemName",
204-
"itemDescription"
205-
]
206-
}
207-
]`;

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4696,6 +4696,7 @@ __metadata:
46964696
dependencies:
46974697
"@kleros/curate-v2-eslint-config": "workspace:^"
46984698
"@kleros/curate-v2-prettier-config": "workspace:^"
4699+
"@kleros/curate-v2-templates": "workspace:^"
46994700
"@kleros/curate-v2-tsconfig": "workspace:^"
47004701
"@kleros/kleros-v2-contracts": "npm:^0.3.2"
47014702
"@logtail/pino": "npm:^0.4.0"
@@ -4775,6 +4776,12 @@ __metadata:
47754776
languageName: unknown
47764777
linkType: soft
47774778

4779+
"@kleros/curate-v2-templates@workspace:^, @kleros/curate-v2-templates@workspace:templates":
4780+
version: 0.0.0-use.local
4781+
resolution: "@kleros/curate-v2-templates@workspace:templates"
4782+
languageName: unknown
4783+
linkType: soft
4784+
47784785
"@kleros/curate-v2-tsconfig@workspace:^, @kleros/curate-v2-tsconfig@workspace:tsconfig":
47794786
version: 0.0.0-use.local
47804787
resolution: "@kleros/curate-v2-tsconfig@workspace:tsconfig"
@@ -4790,6 +4797,7 @@ __metadata:
47904797
"@filebase/client": "npm:^0.0.5"
47914798
"@graphql-codegen/cli": "npm:^4.0.1"
47924799
"@graphql-codegen/client-preset": "npm:^4.2.0"
4800+
"@kleros/curate-v2-templates": "workspace:^"
47934801
"@kleros/kleros-v2-contracts": "npm:^0.3.2"
47944802
"@kleros/ui-components-library": "npm:^2.13.1"
47954803
"@middy/core": "npm:^5.3.5"

0 commit comments

Comments
 (0)