Skip to content

Commit

Permalink
fix(realitio): use arbitrable and arbitrator chain ids in priority, w…
Browse files Browse the repository at this point in the history
…hen missing use chainID
  • Loading branch information
0xferit committed Oct 15, 2021
1 parent 8a9c088 commit d43eded
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/containers/realitio.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,28 @@ class RealitioDisplayInterface extends Component {
const message = JSON.parse(decodeURIComponent(window.location.search.substring(1)));
console.debug(message);

const { arbitrableContractAddress, arbitratorContractAddress, disputeID, chainID, arbitratorJsonRpcUrl, arbitrableJsonRpcUrl, jsonRpcUrl } = message;
const {
arbitrableContractAddress,
arbitratorContractAddress,
disputeID,
arbitratorChainID,
arbitrableChainID,
chainID,
arbitratorJsonRpcUrl,
arbitrableJsonRpcUrl,
jsonRpcUrl,
} = message;

const web3 = new Web3(
(arbitratorJsonRpcUrl && decodeURIComponent(arbitratorJsonRpcUrl)) ||
(arbitrableJsonRpcUrl && decodeURIComponent(arbitrableJsonRpcUrl)) ||
(jsonRpcUrl && decodeURIComponent(jsonRpcUrl))
);
const rpcURL = arbitrableJsonRpcUrl || arbitratorJsonRpcUrl || jsonRpcUrl;
const cid = arbitrableChainID || arbitratorChainID || chainID;

if (!arbitrableContractAddress || !disputeID || !arbitratorContractAddress || (!arbitrableJsonRpcUrl && !arbitrableJsonRpcUrl && !jsonRpcUrl)) {
if (!rpcURL || !disputeID || !arbitratorContractAddress || !cid) {
console.error("Evidence display is missing critical information.");
return;
}

const web3 = new Web3(rpcURL && decodeURIComponent(rpcURL));

const realitioProxyContractInstance = new web3.eth.Contract(RealitioProxyContract.abi, arbitrableContractAddress);

const realitioContractAddress = await realitioProxyContractInstance.methods.realitio().call();
Expand Down Expand Up @@ -64,7 +73,7 @@ class RealitioDisplayInterface extends Component {

this.setState({
questionID,
chainID,
chainID: cid,
realitioContractAddress,
rawQuestion: questionEventLog[0].returnValues.question,
rawTemplate: templateEventLog[0].returnValues.question_text,
Expand Down

0 comments on commit d43eded

Please sign in to comment.