Skip to content

Commit 1f6b22c

Browse files
authored
Merge pull request #18 from kleros/feat/new-list-metadata-flow
feat: new-list-metadata-flow
2 parents 971bcb2 + 1e4d3b2 commit 1f6b22c

17 files changed

+477
-589
lines changed

contracts/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
1616

1717
#### Arbitrum Sepolia
1818

19-
- [CurateFactory](https://sepolia.arbiscan.io/address/0x5D03d22229899cd7Af84a3F0f9c39B24F51c8E21)
20-
- [CurateV2](https://sepolia.arbiscan.io/address/0x091Ba21a03aab5b4cfee5A770667cc53EF2cB1bc)
21-
- [CurateView](https://sepolia.arbiscan.io/address/0x7152126B8F9f9A9Bd20A37072D198F59773E61dA)
19+
- [CurateFactory](https://sepolia.arbiscan.io/address/0x6b6Df30De48cC7737138ed7531D85aFcffDe9b44)
20+
- [CurateV2](https://sepolia.arbiscan.io/address/0x90c415B8E515E9376A89ED52A11c667843D3e199)
21+
- [CurateView](https://sepolia.arbiscan.io/address/0x5c7695A48202E2F7dBCeAe264072E4a0792C23e5)
2222

2323
#### Sepolia
2424

contracts/deploy/00-curate-v2.ts

+31-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,34 @@ const removalTemplate = `{
5454
}
5555
`;
5656

57+
const listMetadata = `{
58+
"title": "Kleros Storytelling - Standard Impact",
59+
"description": "A list of Standard Tier submissions for the Kleros Storytelling Reward Program.",
60+
"columns": [
61+
{
62+
"label": "Title",
63+
"description": "The submission title.",
64+
"type": "text",
65+
"isIdentifier": true
66+
},
67+
{
68+
"label": "Author",
69+
"description": "To easily search submissions by author. This can be a social media handle or a nickname.",
70+
"type": "text",
71+
"isIdentifier": true
72+
},
73+
{
74+
"label": "Link",
75+
"description": "A link to the submission.",
76+
"type": "link"
77+
}
78+
],
79+
"itemName": "story",
80+
"itemNamePlural": "stories",
81+
"logoURI": "/ipfs/QmQN9ZPubns9kpW3jxZefyt8sNbeUzj8KEcsT7i81SiXFf/standard-impact-logo-.png",
82+
"isTCRofTCRs": false
83+
}`;
84+
5785
// General court, 3 jurors
5886
const extraData =
5987
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003";
@@ -87,12 +115,13 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
87115
extraData,
88116
evidenceModule.address,
89117
ethers.ZeroAddress, // _connectedTCR
118+
disputeTemplateRegistry.address,
90119
[registrationTemplate, ""],
91120
[removalTemplate, ""],
92-
disputeTemplateRegistry.address,
93121
[fee, fee, fee, fee],
94122
timeout,
95-
deployer
123+
deployer,
124+
listMetadata
96125
);
97126

98127
await deploy("CurateFactory", {

contracts/deployments/arbitrumSepoliaDevnet/CurateFactory.json

+52-41
Large diffs are not rendered by default.

contracts/deployments/arbitrumSepoliaDevnet/CurateV2.json

+150-101
Large diffs are not rendered by default.

contracts/deployments/arbitrumSepoliaDevnet/CurateView.json

+14-14
Large diffs are not rendered by default.

contracts/src/CurateFactory.sol

+22-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
/// @custom:authors: [@mtsalenc*, @unknownunknown1]
3+
/// @custom:authors: [@mtsalenc, @unknownunknown1]
44
/// @custom:reviewers: []
55
/// @custom:auditors: []
66
/// @custom:bounties: []
@@ -17,9 +17,9 @@ contract CurateFactory {
1717
// * Events * //
1818
// ************************************* //
1919

20-
/// @dev Emitted when a new Curate contract is deployed using this factory. TODO: change TCR mentions.
20+
/// @dev Emitted when a new Curate contract is deployed using this factory.
2121
/// @param _address The address of the newly deployed Curate contract.
22-
event NewGTCR(CurateV2 indexed _address);
22+
event NewList(CurateV2 indexed _address);
2323

2424
// ************************************* //
2525
// * Storage * //
@@ -47,46 +47,50 @@ contract CurateFactory {
4747
/// @param _arbitrator Arbitrator to resolve potential disputes. The arbitrator is trusted to support appeal periods and not reenter.
4848
/// @param _arbitratorExtraData Extra data for the trusted arbitrator contract.
4949
/// @param _evidenceModule The evidence contract for the arbitrator.
50-
/// @param _connectedTCR The address of the Curate contract that stores related Curate addresses. This parameter can be left empty.
51-
/// @param _registrationTemplateParameters Template and data mappings json for registration requests.
52-
/// @param _removalTemplateParameters Template and data mappings json for removal requests.
53-
/// @param _templateRegistry The dispute template registry.
50+
/// @param _connectedList The address of the Curate contract that stores related Curate addresses. This parameter can be left empty.
51+
/// @param _templateRegistryParams The dispute template registry.
52+
/// - templateRegistry : The dispute template registry.
53+
/// - registrationTemplateParameters : Template and data mappings json for registration requests.
54+
/// - removalTemplateParameters : Template and data mappings json for removal requests.
5455
/// @param _baseDeposits The base deposits for requests/challenges as follows:
5556
/// - The base deposit to submit an item.
5657
/// - The base deposit to remove an item.
5758
/// - The base deposit to challenge a submission.
5859
/// - The base deposit to challenge a removal request.
5960
/// @param _challengePeriodDuration The time in seconds parties have to challenge a request.
6061
/// @param _relayerContract The address of the relay contract to add/remove items directly.
62+
/// @param _listMetadata Stringified JSON object containing list metadata (title, description, isListOfLists, etc.). Example at :- https://cloudflare-ipfs.com/ipfs/QmekLsbXtQfm2jJjdeC5TF1cJcr5qxarZ9bhKmCS9s3ebK/list-metadata.json
6163
function deploy(
6264
address _governor,
6365
IArbitratorV2 _arbitrator,
6466
bytes calldata _arbitratorExtraData,
6567
EvidenceModule _evidenceModule,
66-
address _connectedTCR,
67-
string[2] calldata _registrationTemplateParameters,
68-
string[2] calldata _removalTemplateParameters,
69-
address _templateRegistry,
68+
address _connectedList,
69+
CurateV2.TemplateRegistryParams calldata _templateRegistryParams,
7070
uint256[4] calldata _baseDeposits,
7171
uint256 _challengePeriodDuration,
72-
address _relayerContract
72+
address _relayerContract,
73+
string memory _listMetadata
7374
) public {
7475
CurateV2 instance = clone(curate);
7576
instance.initialize(
7677
_governor,
7778
_arbitrator,
7879
_arbitratorExtraData,
7980
_evidenceModule,
80-
_connectedTCR,
81-
_registrationTemplateParameters,
82-
_removalTemplateParameters,
83-
_templateRegistry,
81+
_connectedList,
82+
CurateV2.TemplateRegistryParams(
83+
_templateRegistryParams.templateRegistry,
84+
_templateRegistryParams.registrationTemplateParameters,
85+
_templateRegistryParams.removalTemplateParameters
86+
),
8487
_baseDeposits,
8588
_challengePeriodDuration,
86-
_relayerContract
89+
_relayerContract,
90+
_listMetadata
8791
);
8892
instances.push(instance);
89-
emit NewGTCR(instance);
93+
emit NewList(instance);
9094
}
9195

9296
/// @notice Adaptation of https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/proxy/Clones.sol.

contracts/src/CurateV2.sol

+46-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
/// @custom:authors: [@unknownunknown1, @mtsalenc*, @hbarcelos*]
3+
/// @custom:authors: [@unknownunknown1, @mtsalenc, @hbarcelos]
44
/// @custom:reviewers: []
55
/// @custom:auditors: []
66
/// @custom:bounties: []
@@ -72,6 +72,12 @@ contract CurateV2 is IArbitrableV2 {
7272
EvidenceModule evidenceModule; // The evidence module for the arbitrator.
7373
}
7474

75+
struct TemplateRegistryParams {
76+
address templateRegistry; // Dispute Template registry address
77+
string[2] registrationTemplateParameters; // Template and data mappings json for registration requests.
78+
string[2] removalTemplateParameters; // Template and data mappings json for removal requests.
79+
}
80+
7581
// ************************************* //
7682
// * Storage * //
7783
// ************************************* //
@@ -119,7 +125,7 @@ contract CurateV2 is IArbitrableV2 {
119125

120126
/// @dev Emitted when someone submits an item for the first time.
121127
/// @param _itemID The ID of the new item.
122-
/// @param _data The item data URI.
128+
/// @param _data Stringified JSON Object containing item data. Example at :- https://cloudflare-ipfs.com/ipfs/QmTypFX9416z5V87Fsnf6A89rrskh2X8BSVdaKhwzXNiDb/item.json.
123129
/// @param _addedDirectly Whether the item was added via `addItemDirectly`.
124130
event NewItem(bytes32 indexed _itemID, string _data, bool _addedDirectly);
125131

@@ -129,8 +135,12 @@ contract CurateV2 is IArbitrableV2 {
129135
event RequestSubmitted(bytes32 indexed _itemID, uint256 _requestID);
130136

131137
/// @dev Emitted when the address of the connected Curate contract is set. The Curate is an instance of the Curate contract where each item is the address of a Curate contract related to this one.
132-
/// @param _connectedTCR The address of the connected Curate. TODO: change TCR mentions.
133-
event ConnectedTCRSet(address indexed _connectedTCR);
138+
/// @param _connectedList The address of the connected Curate.
139+
event ConnectedListSet(address indexed _connectedList);
140+
141+
/// @dev Emitted when the list metadata ipfs uri is updated.
142+
/// @param _listMetadata Ipfs uri to list metadata.
143+
event ListMetadataSet(string _listMetadata);
134144

135145
// ************************************* //
136146
// * Initializer * //
@@ -141,29 +151,30 @@ contract CurateV2 is IArbitrableV2 {
141151
/// @param _arbitrator Arbitrator to resolve potential disputes. The arbitrator is trusted to support appeal periods and not reenter.
142152
/// @param _arbitratorExtraData Extra data for the trusted arbitrator contract.
143153
/// @param _evidenceModule The evidence contract for the arbitrator.
144-
/// @param _connectedTCR The address of the Curate contract that stores related Curate addresses. This parameter can be left empty.
145-
/// @param _registrationTemplateParameters Template and data mappings json for registration requests.
146-
/// @param _removalTemplateParameters Template and data mappings json for removal requests.
147-
/// @param _templateRegistry The dispute template registry.
154+
/// @param _connectedList The address of the Curate contract that stores related Curate addresses. This parameter can be left empty.
155+
/// @param _templateRegistryParams The dispute template registry.
156+
/// - templateRegistry : The dispute template registry.
157+
/// - registrationTemplateParameters : Template and data mappings json for registration requests.
158+
/// - removalTemplateParameters : Template and data mappings json for removal requests.
148159
/// @param _baseDeposits The base deposits for requests/challenges as follows:
149160
/// - The base deposit to submit an item.
150161
/// - The base deposit to remove an item.
151162
/// - The base deposit to challenge a submission.
152163
/// - The base deposit to challenge a removal request.
153164
/// @param _challengePeriodDuration The time in seconds parties have to challenge a request.
154165
/// @param _relayerContract The address of the relayer contract to add/remove items directly.
166+
/// @param _listMetadata Stringified JSON object containing list metadata (title, description, isListOfLists, etc.). Example at :- https://cloudflare-ipfs.com/ipfs/QmekLsbXtQfm2jJjdeC5TF1cJcr5qxarZ9bhKmCS9s3ebK/list-metadata.json
155167
function initialize(
156168
address _governor,
157169
IArbitratorV2 _arbitrator,
158170
bytes calldata _arbitratorExtraData,
159171
EvidenceModule _evidenceModule,
160-
address _connectedTCR,
161-
string[2] calldata _registrationTemplateParameters,
162-
string[2] calldata _removalTemplateParameters,
163-
address _templateRegistry,
172+
address _connectedList,
173+
TemplateRegistryParams calldata _templateRegistryParams,
164174
uint256[4] calldata _baseDeposits,
165175
uint256 _challengePeriodDuration,
166-
address _relayerContract
176+
address _relayerContract,
177+
string calldata _listMetadata
167178
) external {
168179
require(!initialized, "Already initialized.");
169180
initialized = true;
@@ -176,16 +187,16 @@ contract CurateV2 is IArbitrableV2 {
176187
challengePeriodDuration = _challengePeriodDuration;
177188
relayerContract = _relayerContract;
178189

179-
templateRegistry = IDisputeTemplateRegistry(_templateRegistry);
190+
templateRegistry = IDisputeTemplateRegistry(_templateRegistryParams.templateRegistry);
180191
templateIdRegistration = templateRegistry.setDisputeTemplate(
181192
"Registration",
182-
_registrationTemplateParameters[0],
183-
_registrationTemplateParameters[1]
193+
_templateRegistryParams.registrationTemplateParameters[0],
194+
_templateRegistryParams.registrationTemplateParameters[1]
184195
);
185196
templateIdRemoval = templateRegistry.setDisputeTemplate(
186197
"Removal",
187-
_removalTemplateParameters[0],
188-
_removalTemplateParameters[1]
198+
_templateRegistryParams.removalTemplateParameters[0],
199+
_templateRegistryParams.removalTemplateParameters[1]
189200
);
190201

191202
arbitrationParamsChanges.push(
@@ -196,9 +207,11 @@ contract CurateV2 is IArbitrableV2 {
196207
})
197208
);
198209

199-
if (_connectedTCR != address(0)) {
200-
emit ConnectedTCRSet(_connectedTCR);
210+
if (_connectedList != address(0)) {
211+
emit ConnectedListSet(_connectedList);
201212
}
213+
214+
emit ListMetadataSet(_listMetadata);
202215
}
203216

204217
// ************************************* //
@@ -241,10 +254,16 @@ contract CurateV2 is IArbitrableV2 {
241254
governor = _governor;
242255
}
243256

244-
/// @dev Change the address of connectedTCR, the Curate instance that stores addresses of Curate contracts related to this one.
245-
/// @param _connectedTCR The address of the connectedTCR contract to use.
246-
function changeConnectedTCR(address _connectedTCR) external onlyGovernor {
247-
emit ConnectedTCRSet(_connectedTCR);
257+
/// @dev Change the address of connectedList, the Curate instance that stores addresses of Curate contracts related to this one.
258+
/// @param _connectedList The address of the connectedList contract to use.
259+
function changeConnectedList(address _connectedList) external onlyGovernor {
260+
emit ConnectedListSet(_connectedList);
261+
}
262+
263+
/// @dev Update list metadata ipfs uri.
264+
/// @param _listMetadata Ipfs uri to list metadata
265+
function changeListMetadata(string calldata _listMetadata) external onlyGovernor {
266+
emit ListMetadataSet(_listMetadata);
248267
}
249268

250269
/// @dev Change the address of the relay contract.
@@ -307,7 +326,7 @@ contract CurateV2 is IArbitrableV2 {
307326
// ************************************* //
308327

309328
/// @dev Directly add an item to the list bypassing request-challenge. Can only be used by the relayer contract.
310-
/// @param _item The URI to the item data.
329+
/// @param _item Stringified JSON Object containing Item data
311330
function addItemDirectly(string calldata _item) external onlyRelayer {
312331
bytes32 itemID = keccak256(abi.encodePacked(_item));
313332
Item storage item = items[itemID];
@@ -324,7 +343,7 @@ contract CurateV2 is IArbitrableV2 {
324343
}
325344

326345
/// @dev Directly remove an item from the list bypassing request-challenge. Can only be used by the relayer contract.
327-
/// @param _itemID The ID of the item to remove.
346+
/// @param _itemID The ID of the item to remove. Example at :- https://cloudflare-ipfs.com/ipfs/QmTypFX9416z5V87Fsnf6A89rrskh2X8BSVdaKhwzXNiDb/item.json
328347
function removeItemDirectly(bytes32 _itemID) external onlyRelayer {
329348
Item storage item = items[_itemID];
330349
require(item.status == Status.Registered, "Item must be registered to be removed.");
@@ -335,7 +354,7 @@ contract CurateV2 is IArbitrableV2 {
335354
}
336355

337356
/// @dev Submit a request to register an item. Accepts enough ETH to cover the deposit, reimburses the rest.
338-
/// @param _item The URI to the item data.
357+
/// @param _item Stringified JSON object containing item data. Example at :- https://cloudflare-ipfs.com/ipfs/QmTypFX9416z5V87Fsnf6A89rrskh2X8BSVdaKhwzXNiDb/item.json
339358
function addItem(string calldata _item) external payable {
340359
bytes32 itemID = keccak256(abi.encodePacked(_item));
341360
Item storage item = items[itemID];

contracts/src/CurateView.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
/// @custom:authors: [@unknownunknown1, @mtsalenc*]
3+
/// @custom:authors: [@unknownunknown1, @mtsalenc]
44
/// @custom:reviewers: []
55
/// @custom:auditors: []
66
/// @custom:bounties: []

subgraph/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"node": "20.11.0"
2525
},
2626
"dependencies": {
27-
"@graphprotocol/graph-ts": "^0.32.0"
27+
"@graphprotocol/graph-ts": "^0.33.0"
2828
},
2929
"devDependencies": {
30-
"@graphprotocol/graph-cli": "0.64.0",
30+
"@graphprotocol/graph-cli": "0.68.5",
3131
"@kleros/curate-v2-eslint-config": "workspace:^",
3232
"@kleros/curate-v2-prettier-config": "workspace:^",
3333
"gluegun": "^5.1.2",

0 commit comments

Comments
 (0)