@@ -15,6 +15,7 @@ import ipfsPublish from "./ipfs-publish";
1515import Archon from "@kleros/archon" ;
1616import UnsupportedNetwork from "./components/unsupportedNetwork" ;
1717import { urlNormalize } from "./urlNormalizer" ;
18+ import { fetchDataFromScript } from "./utils" ;
1819
1920// Constants to avoid magic numbers
2021const HEX_PADDING_WIDTH = 64 ;
@@ -1311,7 +1312,7 @@ class App extends React.Component {
13111312 throw new Error ( `HTTP error! status: ${ response . status } ` ) ;
13121313 }
13131314
1314- const metaEvidenceJSON = await response . json ( ) ;
1315+ let metaEvidenceJSON = await response . json ( ) ;
13151316 console . debug ( `📋 [getMetaEvidence] MetaEvidence JSON content:` , metaEvidenceJSON ) ;
13161317
13171318 console . log ( { dispute : { metaEvidenceID, blockNumber : disputeEvent . blockNumber } } ) ;
@@ -1333,13 +1334,55 @@ class App extends React.Component {
13331334 //Do not assume cross-chain for POH_V2, otherwise the iframe won't work
13341335 const isPOH_V2 = networkMap [ this . state . network ] . POH_V2_CONTRACTS . includes ( arbitrableAddress ) ;
13351336
1336- // For cross-chain disputes where arbitrable is on Gnosis, ensure correct chainID
1337+ //For cross-chain disputes where arbitrable is on Gnosis, ensure correct chainID
13371338 if ( ! isPOH_V2 && ! metaEvidenceJSON . arbitrableChainID && network === '1' ) {
13381339 console . debug ( `🔧 [getMetaEvidence] Adding arbitrableChainID for cross-chain dispute` ) ;
13391340 metaEvidenceJSON . arbitrableChainID = '100' ; // Gnosis chain
13401341 metaEvidenceJSON . arbitratorChainID = '1' ; // Ethereum mainnet
13411342 }
13421343
1344+ //Check for the dynamicScriptURI and fetch data if available
1345+ if ( metaEvidenceJSON . dynamicScriptURI ) {
1346+ const scriptURI = urlNormalize ( metaEvidenceJSON . dynamicScriptURI ) ;
1347+
1348+ console . debug ( `🔧 [getMetaEvidence] Fetching dynamic script from URI: ${ scriptURI } ` ) ;
1349+
1350+ const response = await fetch ( scriptURI ) ;
1351+ if ( ! response . ok ) throw new Error ( `Unable to fetch dynamic script file at ${ scriptURI } .` ) ;
1352+
1353+ const scriptData = await response . text ( ) ;
1354+ const injectedParameters = {
1355+ arbitratorChainID : metaEvidenceJSON . arbitratorChainID || network ,
1356+ arbitrableChainID : metaEvidenceJSON . arbitrableChainID || network ,
1357+ disputeID : arbitratorDisputeID ,
1358+ } ;
1359+
1360+ injectedParameters . arbitrableContractAddress = arbitrableAddress ;
1361+ injectedParameters . arbitratorJsonRpcUrl = getReadOnlyRpcUrl ( { chainId : injectedParameters . arbitratorChainID } ) ;
1362+ injectedParameters . arbitrableChainID = injectedParameters . arbitrableChainID || metaEvidenceJSON . arbitrableChainID ;
1363+ injectedParameters . arbitrableJsonRpcUrl = getReadOnlyRpcUrl ( { chainId : injectedParameters . arbitrableChainID } ) ;
1364+
1365+ if (
1366+ injectedParameters . arbitratorChainID !== undefined &&
1367+ injectedParameters . arbitratorJsonRpcUrl === undefined
1368+ ) {
1369+ console . debug ( `🔧 [getMetaEvidence] Could not obtain a valid 'arbitratorJsonRpcUrl' for chain ID ${ injectedParameters . arbitratorChainID } on the Arbitrator side.` ) ;
1370+ }
1371+
1372+ if (
1373+ injectedParameters . arbitrableChainID !== undefined &&
1374+ injectedParameters . arbitrableJsonRpcUrl === undefined
1375+ ) {
1376+ console . debug ( `🔧 [getMetaEvidence] Could not obtain a valid 'arbitrableJsonRpcUrl' for chain ID ${ injectedParameters . arbitrableChainID } on the Arbitrable side.` ) ;
1377+ }
1378+
1379+ const metaEvidenceEdits = await fetchDataFromScript ( scriptData , injectedParameters ) ;
1380+ metaEvidenceJSON = {
1381+ ...metaEvidenceJSON ,
1382+ ...metaEvidenceEdits ,
1383+ } ;
1384+ }
1385+
13431386 // Note: Block range parameters removed - evidence display interfaces
13441387 // should handle their own RPC optimization internally (follows Kleros Court approach)
13451388
0 commit comments