Skip to content

Commit

Permalink
Merge pull request #1165 from kleros/feat(sdk)/data-mappings
Browse files Browse the repository at this point in the history
SDK: data mappings (WIP)
  • Loading branch information
jaybuidl authored Jan 23, 2024
2 parents e31f829 + 7001003 commit ab6dabd
Show file tree
Hide file tree
Showing 62 changed files with 3,317 additions and 272 deletions.
2 changes: 1 addition & 1 deletion bot-pinner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"node": ">=16.13.0"
},
"devDependencies": {
"@dappnode/dappnodesdk": "^0.3.8"
"@dappnode/dappnodesdk": "^0.3.11"
}
}
6 changes: 3 additions & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@typechain/hardhat": "^7.0.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^16.18.68",
"@types/node": "^16.18.70",
"@wagmi/cli": "^1.5.2",
"abitype": "^0.10.3",
"chai": "^4.3.10",
Expand All @@ -79,8 +79,8 @@
"graphql-request": "^6.1.0",
"hardhat": "2.15.0",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-deploy": "^0.11.42",
"hardhat-deploy-ethers": "^0.4.0-next.1",
"hardhat-deploy": "0.11.42",
"hardhat-deploy-ethers": "0.4.0-next.1",
"hardhat-deploy-tenderly": "^0.2.0",
"hardhat-docgen": "^1.3.0",
"hardhat-gas-reporter": "^1.0.9",
Expand Down
8 changes: 4 additions & 4 deletions contracts/scripts/disputeCreatorBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ export default async function main() {
"000000000000000000000000000000000000000000000000000000000000000B" + // minJurors 11
"0000000000000000000000000000000000000000000000000000000000000002"; // disputeKitId 2
const templates = [
`{"title":"A reality.eth question","description":"A reality.eth question has been raised to arbitration.","question":"**Kleros Moderate:** Did the user, **degenape6** (ID: 1554345080), break the Telegram group, ***[Kleros Trading Group]()*** (ID: -1001151472172), ***[rules](https://ipfs.kleros.io/ipfs/Qme3Qbj9rKUNHUe9vj9rqCLnTVUCWKy2YfveQF8HiuWQSu/Kleros%20Moderate%20Community%20Rules.pdf)*** due to conduct related to the ***[message](https://t.me/c/1151472172/116662)*** (***[backup](https://ipfs.kleros.io/ipfs/QmVbFrZR1bcyQzZjvLyXwL9ekDxrqHERykdreRxXrw4nqg/animations_file_23.mp4)***)?","answers":[{"id":"0x01","title":"Yes","reserved":false},{"id":"0x02","title":"No","reserved":false},{"id":"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","title":"Answered Too Soon","reserved":true}],"policyURI":"/ipfs/QmZ5XaV2RVgBADq5qMpbuEwgCuPZdRgCeu8rhGtJWLV6yz","frontendUrl":"https://reality.eth.limo/app/#!/question/0xe78996a233895be74a66f451f1019ca9734205cc-0xe2a3bd38e3ad4e22336ac35b221bbbdd808d716209f84014c7bc3bf62f8e3b39","arbitrableChainID":"100","arbitrableAddress":"0x2e39b8f43d0870ba896f516f78f57cde773cf805","arbitratorChainID":"421614","arbitratorAddress":"0xD08Ab99480d02bf9C092828043f611BcDFEA917b","category":"Oracle","lang":"en_US","specification":"KIP99"}`,
`{"title":"Add an entry to Ledger Contract Domain Name registry v2","description":"Someone requested to add an entry to Ledger Contract Domain Name registry v2","question":"Does the entry comply with the required criteria?","answers":[{"title":"Yes, Add It","description":"Select this if you think the entry complies with the required criteria and should be added."},{"title":"No, Don't Add It","description":"Select this if you think the entry does not comply with the required criteria and should not be added."}],"policyURI":"/ipfs/QmW3nQcMW2adyqe6TujRTYkyq26PiDqcmmTjdgKiz9ynPV","frontendUrl":"https://curate.kleros.io/tcr/100/0x957a53a994860be4750810131d9c876b2f52d6e1/0xc2c1aa705632f53051f22a9f65967c0944370020a7489aba608bd0d755ca1234","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Curation","specification":"KIP0X","lang":"en_US"}`,
`{"title":"Omen Question: News & Politics","description":"This reality dispute has been created by Omen, we advise you to read [the Omen Rules](https://cdn.kleros.link/ipfs/QmU1oZzsduGwtC7vCUQPw1QcBP6BDNDkg4t6zkowPucVcx) and consult the evidence provided in [the Market Comments](https://omen.eth.limo/#/0x95b2271039b020aba31b933039e042b60b063800).","question":"**Assuming that today is December 20th 2020, will Joe Biden win the 2020 United States presidential election?**","answers":[{"title":"Yes"},{"title":"No"}],"policyURI":"/ipfs/QmU1oZzsduGwtC7vCUQPw1QcBP6BDNDkg4t6zkowPucVcx","frontendUrl":"https://omen.eth.limo/#/0x95b2271039b020aba31b933039e042b60b063800","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Oracle","specification":"KIP0X","lang":"en_US"}`,
`{"title":"Proof of Humanity Registration Request","description":"A request to register the specified entry to a list of provable humans.","question":"Should the request to register be accepted?","answers":[{"title":"Yes","description":"Accept the request to register the entry."},{"title":"No","description":"Deny the request."}],"policyURI":"/ipfs/QmYPf2fdSyr9BiSy6pJFUmB1oTUPwg6dhEuFqL1n4ZosgH","frontendUrl":"https://app.proofofhumanity.id/profile/0x00de4b13153673bcae2616b67bf822500d325fc3?network=mainnet","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Curated List","specification":"KIP0X","lang":"en_US"}`,
`{"title":"A reality.eth question","description":"A reality.eth question has been raised to arbitration.","question":"**Kleros Moderate:** Did the user, **degenape6** (ID: 1554345080), break the Telegram group, ***[Kleros Trading Group]()*** (ID: -1001151472172), ***[rules](https://ipfs.kleros.io/ipfs/Qme3Qbj9rKUNHUe9vj9rqCLnTVUCWKy2YfveQF8HiuWQSu/Kleros%20Moderate%20Community%20Rules.pdf)*** due to conduct related to the ***[message](https://t.me/c/1151472172/116662)*** (***[backup](https://ipfs.kleros.io/ipfs/QmVbFrZR1bcyQzZjvLyXwL9ekDxrqHERykdreRxXrw4nqg/animations_file_23.mp4)***)?","answers":[{"id":"0x01","title":"Yes","reserved":false},{"id":"0x02","title":"No","reserved":false},{"id":"0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","title":"Answered Too Soon","reserved":true}],"policyURI":"/ipfs/QmZ5XaV2RVgBADq5qMpbuEwgCuPZdRgCeu8rhGtJWLV6yz","frontendUrl":"https://reality.eth.limo/app/#!/question/0xe78996a233895be74a66f451f1019ca9734205cc-0xe2a3bd38e3ad4e22336ac35b221bbbdd808d716209f84014c7bc3bf62f8e3b39","arbitrableChainID":"100","arbitrableAddress":"0x2e39b8f43d0870ba896f516f78f57cde773cf805","arbitratorChainID":"421614","arbitratorAddress":"0xD08Ab99480d02bf9C092828043f611BcDFEA917b","category":"Oracle","lang":"en_US","specification":"KIP99","version": "1.0"}`,
`{"title":"Add an entry to Ledger Contract Domain Name registry v2","description":"Someone requested to add an entry to Ledger Contract Domain Name registry v2","question":"Does the entry comply with the required criteria?","answers":[{"title":"Yes, Add It","description":"Select this if you think the entry complies with the required criteria and should be added."},{"title":"No, Don't Add It","description":"Select this if you think the entry does not comply with the required criteria and should not be added."}],"policyURI":"/ipfs/QmW3nQcMW2adyqe6TujRTYkyq26PiDqcmmTjdgKiz9ynPV","frontendUrl":"https://curate.kleros.io/tcr/100/0x957a53a994860be4750810131d9c876b2f52d6e1/0xc2c1aa705632f53051f22a9f65967c0944370020a7489aba608bd0d755ca1234","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Curation","specification":"KIP0X","lang":"en_US","version": "1.0"}`,
`{"title":"Omen Question: News & Politics","description":"This reality dispute has been created by Omen, we advise you to read [the Omen Rules](https://cdn.kleros.link/ipfs/QmU1oZzsduGwtC7vCUQPw1QcBP6BDNDkg4t6zkowPucVcx) and consult the evidence provided in [the Market Comments](https://omen.eth.limo/#/0x95b2271039b020aba31b933039e042b60b063800).","question":"**Assuming that today is December 20th 2020, will Joe Biden win the 2020 United States presidential election?**","answers":[{"title":"Yes"},{"title":"No"}],"policyURI":"/ipfs/QmU1oZzsduGwtC7vCUQPw1QcBP6BDNDkg4t6zkowPucVcx","frontendUrl":"https://omen.eth.limo/#/0x95b2271039b020aba31b933039e042b60b063800","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Oracle","specification":"KIP0X","lang":"en_US","version": "1.0"}`,
`{"title":"Proof of Humanity Registration Request","description":"A request to register the specified entry to a list of provable humans.","question":"Should the request to register be accepted?","answers":[{"title":"Yes","description":"Accept the request to register the entry."},{"title":"No","description":"Deny the request."}],"policyURI":"/ipfs/QmYPf2fdSyr9BiSy6pJFUmB1oTUPwg6dhEuFqL1n4ZosgH","frontendUrl":"https://app.proofofhumanity.id/profile/0x00de4b13153673bcae2616b67bf822500d325fc3?network=mainnet","arbitratorChainID":"421614","arbitratorAddress":"0x791812B0B9f2ba260B2DA432BB02Ee23BC1bB509","category":"Curated List","specification":"KIP0X","lang":"en_US","version": "1.0"}`,
];
const randomTemplate = templates[Math.floor(Math.random() * templates.length)];
const nbOfChoices = 2;
Expand Down
1 change: 1 addition & 0 deletions kleros-sdk/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALCHEMY_API_KEY=
7 changes: 6 additions & 1 deletion kleros-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

_Archon's successor_

\
Make sure to set the environment variables first by copying the file `.env.example`, pasting it, renaming it to `.env`, and then setting the variables.
To run the data mappings tests:

```bash
yarn run test-data-mappings
```

🚧 ⚖️ 🚧
39 changes: 39 additions & 0 deletions kleros-sdk/config/v1-metaevidence/escrow3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"subCategory": "General Service",
"arbitrableAddress": "0x0d67440946949fe293b45c52efd8a9b3d51e2522",
"title": "Liquidity Withdrawal Transfer Ownership Agreement ",
"description": "PARTIES:\nParty 1 (hereinafter referred to as the \"Seller\"):\n* Ethereum Address: 0xc4c4e8144823000d97310756d3237B305E967a09\n\nParty 2 (hereinafter referred to as the \"Buyer\"):\n* Ethereum Address: 0x213fea050A0dA676E97B4dc40e37E985008EA1a0\n\nRECITALS\n\nA. The Seller is the owner of an ERC-20 token contract, whose liquidity is locked on the UNCX.network platform.\nB. The \"Rights'' herein refer to the ability to demand liquidity withdrawal of the aforementioned ERC-20 token through the UNCX.network service by having the designated rights-holder's address assigned to the Gudetama in the contract 0x257EeF05f232B566cD0aF298Ec0B45C2C18d16c7 on the Ethereum chain.\n\nAGREEMENT\n\nTransfer of Rights:\n1.1. The transfer shall be completed by 12:00, Wednesday 20, December 2023 EDT, to the Buyer at the ETH wallet address: 0x8e6f7b23Cdf06db96FD96F4aF8369c0131FAf0F6.\n\nPayment:\n2.1. Upon successful fulfillment of 1.1, the Buyer shall transfer the full amount of 1,4 ETH to the Seller.\n\nNo Partial Payment:\n3.1. There shall be no conditions under which partial payment can be demanded by the Seller, unless the Buyer chooses to do so voluntarily through the Escrow contract.\n\nKleros Escrow:\n4.1. Any disputes arising from this Agreement shall be automatically escalated to the Court of Kleros after both parties fund the dispute resolution deposit. Should one side fail to do so in full, the other party will automatically win the dispute.",
"sender": "0x213fea050A0dA676E97B4dc40e37E985008EA1a0",
"receiver": "0xc4c4e8144823000d97310756d3237B305E967a09",
"amount": "1.4",
"timeout": 8640000000000000,
"token": {
"name": "Ethereum",
"ticker": "ETH",
"symbolURI": "/static/media/eth.33901ab6.png",
"address": null,
"decimals": 18
},
"extraData": {
"Contract Information": "PARTIES:\nParty 1 (hereinafter referred to as the \"Seller\"):\n* Ethereum Address: 0xc4c4e8144823000d97310756d3237B305E967a09\n\nParty 2 (hereinafter referred to as the \"Buyer\"):\n* Ethereum Address: 0x213fea050A0dA676E97B4dc40e37E985008EA1a0\n\nRECITALS\n\nA. The Seller is the owner of an ERC-20 token contract, whose liquidity is locked on the UNCX.network platform.\nB. The \"Rights'' herein refer to the ability to demand liquidity withdrawal of the aforementioned ERC-20 token through the UNCX.network service by having the designated rights-holder's address assigned to the Gudetama in the contract 0x257EeF05f232B566cD0aF298Ec0B45C2C18d16c7 on the Ethereum chain.\n\nAGREEMENT\n\nTransfer of Rights:\n1.1. The transfer shall be completed by 12:00, Wednesday 20, December 2023 EDT, to the Buyer at the ETH wallet address: 0x8e6f7b23Cdf06db96FD96F4aF8369c0131FAf0F6.\n\nPayment:\n2.1. Upon successful fulfillment of 1.1, the Buyer shall transfer the full amount of 1,4 ETH to the Seller.\n\nNo Partial Payment:\n3.1. There shall be no conditions under which partial payment can be demanded by the Seller, unless the Buyer chooses to do so voluntarily through the Escrow contract.\n\nKleros Escrow:\n4.1. Any disputes arising from this Agreement shall be automatically escalated to the Court of Kleros after both parties fund the dispute resolution deposit. Should one side fail to do so in full, the other party will automatically win the dispute."
},
"invoice": false,
"category": "Escrow",
"question": "Which party abided by terms of the contract?",
"rulingOptions": {
"type": "single-select",
"titles": [
"Refund Sender",
"Pay Receiver"
],
"descriptions": [
"Select to return funds to the Sender",
"Select to release funds to the Receiver"
]
},
"evidenceDisplayInterfaceURI": "/ipfs/QmfPnVdcCjApHdiCC8wAmyg5iR246JvVuQGQjQYgtF8gZU/index.html",
"aliases": {
"0x213fea050A0dA676E97B4dc40e37E985008EA1a0": "sender",
"0xc4c4e8144823000d97310756d3237B305E967a09": "receiver"
}
}
99 changes: 83 additions & 16 deletions kleros-sdk/config/v2-disputetemplate/NewDisputeTemplate.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@
"type": "string",
"default": "NewDisputeTemplate.schema.json"
},
"category": {
"type": "string",
"default": "",
"title": "The category Schema",
"examples": [
"Oracle"
]
},
"lang": {
"type": "string",
"default": "",
"title": "The lang Schema",
"examples": [
"en_US"
]
},
"title": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -302,6 +286,32 @@
"/ipfs/QmeTBY7jZe2ut5WjifNASADo3E4zBxkMd62WwBpXtwP9pg"
]
},
"attachment": {
"type": "object",
"default": {},
"title": "The attachment Schema",
"required": [
"uri"
],
"properties": {
"label": {
"type": "string",
"default": "",
"title": "The label Schema",
"examples": [
"Terms"
]
},
"uri": {
"type": "string",
"default": "",
"title": "The uri Schema",
"examples": [
"/ipfs//QmZ7R..7889/terms.json"
]
}
}
},
"arbitrableChainID": {
"type": "string",
"default": "",
Expand Down Expand Up @@ -335,6 +345,55 @@
"0xD08Ab99480d02bf9C092828043f611BcDFEA917b"
]
},
"metadata": {
"type": "object",
"default": {},
"title": "The metadata Schema",
"required": [],
"properties": {},
"examples": [
{}
]
},
"aliases": {
"type": "object",
"default": {},
"title": "The aliases Schema",
"properties": {
"Party1": {
"type": "string",
"default": "",
"title": "The Party1 Schema",
"examples": [
"0x1234...CDEF"
]
},
"Party2": {
"type": "string",
"default": "",
"title": "The Party2 Schema",
"examples": [
"0xFEDC...4321"
]
}
}
},
"category": {
"type": "string",
"default": "",
"title": "The category Schema",
"examples": [
"Oracle"
]
},
"lang": {
"type": "string",
"default": "",
"title": "The lang Schema",
"examples": [
"en_US"
]
},
"specification": {
"type": "string",
"default": "",
Expand All @@ -343,6 +402,14 @@
"KIP00",
"KIP99"
]
},
"version": {
"type": "string",
"default": "1.0",
"title": "The version Schema",
"examples": [
"1.0"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"arbitratorChainID": "421614",
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b", // KlerosCore
"category": "Curated Lists",
"specification": "KIP88"
"specification": "KIP88",
"version": "1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"category": "Curated Lists",
"lang": "en_US",
"specification": "KIP88",
"version": "1.0",
"metadata": {
"tcrTitle": "Ledger Contract Domain Name registry v2",
"tcrDescription": "A list of contract addresses and the domain names they are meant to be used from .",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"type": "abi/event",
"abi": "event TransactionCreated(uint256 indexed _transactionID, string _transactionUri, address indexed _buyer, address indexed _seller, uint256 _amount, string _asset, uint256 _deadline)",
"address": "[FIX AFTER DEPLOY]",
"eventFilter": {
"fromBlock": "[FIX AFTER DEPLOY]",
"toBlock": "latest",
"args": {
"_transactionID": "[FROM EXTERNAL DISPUTE ID]"
}
},
"seek": [
"transactionUri",
"buyer",
"seller",
"amount",
"asset",
"deadline"
],
"populate": [
"_transactionUri",
"_buyer",
"_seller",
"_amount",
"_asset",
"_deadline"
]
},
{
"type":"fetch/ipfsJson",
"todo": "get title, description, extraDescriptionUri from _transactionUri"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "../NewDisputeTemplate.schema.json",
"title": "{{title}}", // from the form
"description": "{{description}}", // from the contract terms form
"question": "Which party abided by the terms of the contract?",
"answers": [
{
"title": "Refund the Buyer",
"description": "Select this to return the funds to the Buyer."
},
{
"title": "Pay the Seller",
"description": "Select this to release the funds to the Seller."
}
],
"policyURI": "/ipfs/XxxxxXXX/escrow-general-policy.pdf", // not transaction-specific
"attachment": { // transaction-specific
"label": "Transaction Terms",
"uri": "{{extraDescriptionUri}}"
},
"frontendUrl": "https://escrow-v2.kleros.builders/#/myTransactions/%s", // deployment specific, might break over time
"arbitrableChainID": "421614",
"arbitrableAddress": "0x??", // Escrow, hardcode after deploy-time
"arbitratorChainID": "421614",
"arbitratorAddress": "0x??", // KlerosCore, hardcode after deploy-time
"metadata": {
"buyer": "{{buyer}}",
"seller": "{{seller}}",
"amount": "{{amount}}", // in Wei or ERC20 units
"asset": "{{asset}}", // "0" or "native" or "0x1234..." or "erc20:0x1234...", cf. CAIP-19,20,21
"deadline": "{{deadline}}",
"transactionUri": "{{transactionUri}}" // transaction-specific
},
"category": "Escrow",
"specification": "KIPXXX",
"aliases": {
"Buyer": "{{buyer}}",
"Seller": "{{seller}}"
},
"version": "1.0"
}
7 changes: 7 additions & 0 deletions kleros-sdk/config/v2-disputetemplate/escrow/DisputeRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type DisputeRequest = {
arbitrator: string; // klerosCore address
arbitrableDisputeID: number; // dispute id
externalDisputeID: number; // Escrow transaction id
templateId: number; // Escrow configuration
templateUri: string; // empty
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"arbitratorChainID": "421614",
"arbitratorAddress": "0xD08Ab99480d02bf9C092828043f611BcDFEA917b", // KlerosCore
"category": "Translation",
"specification": "KIP999"
"specification": "KIP999",
"version": "1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"category": "Translation",
"lang": "en_US",
"specification": "KIP999",
"version": "1.0",
"metadata": {
"linguoAddress": "0xe78996a233895be74a66f451f1019ca9734205cc",
"linguoTranslationID": "76",
Expand Down
Loading

0 comments on commit ab6dabd

Please sign in to comment.