Skip to content

Support for Reality v3.2 #71

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

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "always",
"quickfix.biome": "always"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
}
}
1 change: 1 addition & 0 deletions biome.json
1 change: 1 addition & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Refresh the list of deployed contracts by running `./scripts/populateReadme.sh`.

| Version | Name | Home Proxy | Foreign Proxy | CourtID | MinJurors | Reality | Policy | Comment |
|---------|------|------------|---------------|---------|-----------|---------|---------|---------|
| v1.3.0 | [Chiado default](deployments/chiado/RealitioProxy-v1.3.0.json#L6) | [0x87f58F..e2EAf9](https://gnosis-chiado.blockscout.com/address/0x87f58F0dCF3c99BA2F3eB0604e5c335893e2EAf9) | [0x781Bfb..904aE0](https://sepolia.etherscan.io/address/0x781Bfb3A7179e27D78c6d18bCc54A2af61904aE0) | 3 | 1 | [RealityUnverified](https://gnosis-chiado.blockscout.com/address/0x012fb3aDce7D60672cF634e730927Fa5822b3cAb) | [default](https://cdn.kleros.link/ipfs/QmNV5NWwCudYKfiHuhdWxccrPyxs4DnbLGQace2oMKHkZv/Question_Resolution_Policy.pdf) | |
| v1.1.0 | [Default](deployments/chiado/RealitioProxy-v1.1.0.json#L6) | [0xE62094..FffeD7](https://gnosis-chiado.blockscout.com/address/0xE620947519E8102aa625BBB4669fE317c9FffeD7) | [0x5d7cB7..969D42](https://sepolia.etherscan.io/address/0x5d7cB72B31C080CF2de5f57fd38DedBeaf969D42) | 0 | 0 | [RealityUnverified](https://gnosis-chiado.blockscout.com/address/0x1E732a1C5e9181622DD5A931Ec6801889ce66185) | [default](https://cdn.kleros.link/ipfs/QmNV5NWwCudYKfiHuhdWxccrPyxs4DnbLGQace2oMKHkZv/Question_Resolution_Policy.pdf) | :warning: bad metadata |


Expand Down
33 changes: 1 addition & 32 deletions contracts/deploy/shared/consts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const chains = require("./chains");
const { generateMetadata } = require("./utils");

const { mainnet, sepolia } = chains.foreignChains;

Expand All @@ -23,43 +24,11 @@ const courts = {
},
};

const policies = {
default: "QmNV5NWwCudYKfiHuhdWxccrPyxs4DnbLGQace2oMKHkZv/Question_Resolution_Policy.pdf",
noAnswerTooSoon: "QmaUr6hnSVxYD899xdcn2GUVtXVjXoSXKZbce3zFtGWw4H/Question_Resolution_Policy.pdf",
butter: "QmSv9ohhChMtyqwqsvfgeJtZQBWkwAboBc1n3UGvprfdd7/Conditional_Funding_Markets_-_Question_Resolution_Policy.pdf",
seer: "QmPmRkXFUmzP4rq2YfD3wNwL8bg3WDxkYuvTP9A9UZm9gJ/seer-markets-resolution-policy.pdf",
omen: "QmZM12kkguXFk2C94ykrKpambt4iUVKsVsxGxDEdLS68ws/omen-rules.pdf",
zodiac:
"QmXyo9M4Z2XY6Nw9UfuuUNzKXXNhvt24q6pejuN9RYWPMr/Reality_Module_Governance_Oracle-Question_Resolution_Policy.pdf",
};

function generatePolicyUri(policy = "default") {
const policyPath = policies[policy];
if (!policyPath) {
throw new Error(`Policy not found: ${policy}. Valid options are: ${Object.keys(policies).join(", ")}.`);
}
return `/ipfs/${policyPath}`; // for Kleros: https://multiformats.io/multiaddr/
}

function generateMetadata(policy = "default") {
const policyPath = policies[policy];
if (!policyPath) {
throw new Error(`Policy not found: ${policy}. Valid options are: ${Object.keys(policies).join(", ")}.`);
}
const tosUri = `ipfs://${policyPath}`; // URI format for Reality: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs
return `{"tos":"${tosUri}", "foreignProxy":true}`;
}

const metadata = generateMetadata("default");
const metadataButter = generateMetadata("butter");

module.exports = {
arbitrators,
wNatives,
courts,
policies,
generatePolicyUri,
generateMetadata,
metadata,
metadataButter,
};
24 changes: 24 additions & 0 deletions contracts/deploy/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ const toBytes32 = (number) => ethers.zeroPadValue(ethers.toBeHex(number), 32);
const encodeExtraData = (courtId, minJurors) =>
ethers.AbiCoder.defaultAbiCoder().encode(["uint96", "uint96"], [courtId, minJurors]);

function getPolicy(policyName = "default") {
const policies = require("../../policies.json");
const policyPath = policies[policyName];
if (!policyPath) {
const validPolicies = Object.keys(policies).join(", ");
throw new Error(`Policy not found: ${policyName}. Valid options are: ${validPolicies}`);
}
return policyPath;
}

function generatePolicyUri(policyName = "default") {
const policyPath = getPolicy(policyName);
return `/ipfs/${policyPath}`; // for Kleros: https://multiformats.io/multiaddr/
}

function generateMetadata(policyName = "default") {
const policyPath = getPolicy(policyName);
const tosUri = `ipfs://${policyPath}`; // URI format for Reality: https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs
return `{"tos":"${tosUri}", "foreignProxy":true}`;
}

const getMetaEvidenceFilename = (homeNetworkName, termsOfService) => {
const termsOfServiceValidated = termsOfService ? termsOfService.toLowerCase() : "default";
return `metaevidence-${homeNetworkName}-${termsOfServiceValidated}.json`;
Expand All @@ -29,6 +50,9 @@ module.exports = {
eth,
toBytes32,
encodeExtraData,
getPolicy,
generatePolicyUri,
generateMetadata,
getMetaEvidenceFilename,
getMetaEvidenceCID,
};
Loading