File tree 11 files changed +41
-16
lines changed
11 files changed +41
-16
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ export REACT_APP_DEPLOYMENT=devnet
3
3
export REACT_APP_CORE_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-coreneo-devnet/version/latest
4
4
export REACT_APP_DRT_ARBSEPOLIA_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-drt-arbisep-devnet/version/latest
5
5
export REACT_APP_STATUS_URL=https://kleros-v2-devnet.betteruptime.com/badge
6
- export REACT_APP_GENESIS_BLOCK_ARBSEPOLIA=3084598
7
6
export REACT_APP_DEVTOOLS_URL=https://dev--kleros-v2-neo-devtools.netlify.app
8
7
export REACT_APP_ARBITRATOR_TYPE=neo
9
8
export REACT_APP_ATLAS_URI=http://localhost:3000
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ export REACT_APP_DEPLOYMENT=devnet
3
3
export REACT_APP_CORE_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-coreuni-devnet/version/latest
4
4
export REACT_APP_DRT_ARBSEPOLIA_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-drt-arbisep-devnet/version/latest
5
5
export REACT_APP_STATUS_URL=https://kleros-v2-devnet.betteruptime.com/badge
6
- export REACT_APP_GENESIS_BLOCK_ARBSEPOLIA=3084598
7
6
export REACT_APP_ARBITRATOR_TYPE=university
8
7
export REACT_APP_ATLAS_URI=http://localhost:3000
9
8
export WALLETCONNECT_PROJECT_ID=
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ export REACT_APP_DEPLOYMENT=devnet
3
3
export REACT_APP_CORE_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-core-devnet/version/latest
4
4
export REACT_APP_DRT_ARBSEPOLIA_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-drt-arbisep-devnet/version/latest
5
5
export REACT_APP_STATUS_URL=https://kleros-v2-devnet.betteruptime.com/badge
6
- export REACT_APP_GENESIS_BLOCK_ARBSEPOLIA=3084598
7
6
export REACT_APP_ATLAS_URI=http://localhost:3000
8
7
export REACT_APP_DEVTOOLS_URL=https://dev--kleros-v2-testnet-devtools.netlify.app
9
8
export NODE_OPTIONS='--max-old-space-size=7680'
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ export REACT_APP_DEPLOYMENT=mainnet
3
3
export REACT_APP_CORE_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-coreneo/version/latest
4
4
export REACT_APP_DRT_ARBMAINNET_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-drt/version/latest
5
5
export REACT_APP_STATUS_URL=https://kleros-v2-devnet.betteruptime.com/badge
6
- export REACT_APP_GENESIS_BLOCK_ARBMAINNET=190274403
7
6
export REACT_APP_DEVTOOLS_URL=https://devtools.v2.kleros.builders
8
7
export REACT_APP_ARBITRATOR_TYPE=neo
9
8
export REACT_APP_ATLAS_URI=http://localhost:3000
Original file line number Diff line number Diff line change @@ -4,7 +4,6 @@ export REACT_APP_CORE_SUBGRAPH=https://api.studio.thegraph.com/query/61738/klero
4
4
export REACT_APP_DRT_ARBSEPOLIA_SUBGRAPH=https://api.studio.thegraph.com/query/61738/kleros-v2-drt-arbisep-devnet/version/latest
5
5
export REACT_APP_STATUS_URL=https://kleros-v2.betteruptime.com/badge
6
6
export REACT_APP_ATLAS_URI=http://localhost:3000
7
- export REACT_APP_GENESIS_BLOCK_ARBSEPOLIA=3842783
8
7
export REACT_APP_DEVTOOLS_URL=https://devtools.v2-testnet.kleros.builders
9
8
export WALLETCONNECT_PROJECT_ID=
10
9
export ALCHEMY_API_KEY=
Original file line number Diff line number Diff line change 75
75
"dependencies" : {
76
76
"@cyntler/react-doc-viewer" : " ^1.16.3" ,
77
77
"@kleros/kleros-sdk" : " workspace:^" ,
78
+ "@kleros/kleros-v2-contracts" : " workspace:^" ,
78
79
"@kleros/ui-components-library" : " ^2.15.0" ,
79
80
"@lifi/wallet-management" : " ^3.0.3" ,
80
81
"@lifi/widget" : " ^3.2.0" ,
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export const ETH_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
28
28
export const ETH_SIGNATURE_REGEX = / ^ 0 x [ a - f A - F 0 - 9 ] { 130 } $ / ;
29
29
30
30
export const isProductionDeployment = ( ) => import . meta. env . REACT_APP_DEPLOYMENT === "mainnet" ;
31
+ export const isTestnetDeployment = ( ) => import . meta. env . REACT_APP_DEPLOYMENT === "testnet" ;
31
32
32
33
export const isKlerosUniversity = ( ) => getArbitratorType ( ) === ArbitratorTypes . university ;
33
34
export const isKlerosNeo = ( ) => getArbitratorType ( ) === ArbitratorTypes . neo ;
@@ -36,10 +37,6 @@ export const getArbitratorType = (): ArbitratorTypes =>
36
37
37
38
export const getDevToolsUrl = ( ) => import . meta. env . REACT_APP_DEVTOOLS_URL || "https://devtools.v2.kleros.builders" ;
38
39
39
- export const GENESIS_BLOCK_ARBSEPOLIA = BigInt ( import . meta. env . REACT_APP_GENESIS_BLOCK_ARBSEPOLIA ?? 0 ) ;
40
- export const GENESIS_BLOCK_ARBMAINNET = BigInt ( import . meta. env . REACT_APP_GENESIS_BLOCK_ARBMAINNET ?? 0 ) ;
41
- export const genesisBlock = ( ) => ( isProductionDeployment ( ) ? GENESIS_BLOCK_ARBMAINNET : GENESIS_BLOCK_ARBSEPOLIA ) ;
42
-
43
40
export const INVALID_DISPUTE_DATA_ERROR = `The dispute data is not valid, please vote "Refuse to arbitrate"` ;
44
41
export const RPC_ERROR = `RPC Error: Unable to fetch dispute data. Please avoid voting.` ;
45
42
Original file line number Diff line number Diff line change @@ -26,10 +26,6 @@ export const isKlerosNeo = () => getArbitratorType() === ArbitratorTypes.neo;
26
26
export const getArbitratorType = ( ) : ArbitratorTypes =>
27
27
_getArbitratorType ( process . env . REACT_APP_ARBITRATOR_TYPE ?. toLowerCase ( ) ) ;
28
28
29
- export const GENESIS_BLOCK_ARBSEPOLIA = BigInt ( process . env . REACT_APP_GENESIS_BLOCK_ARBSEPOLIA ?? 0 ) ;
30
- export const GENESIS_BLOCK_ARBMAINNET = BigInt ( process . env . REACT_APP_GENESIS_BLOCK_ARBMAINNET ?? 0 ) ;
31
- export const genesisBlock = ( ) => ( isProductionDeployment ( ) ? GENESIS_BLOCK_ARBMAINNET : GENESIS_BLOCK_ARBSEPOLIA ) ;
32
-
33
29
export const INVALID_DISPUTE_DATA_ERROR = `The dispute data is not valid, please vote "Refuse to arbitrate"` ;
34
30
export const RPC_ERROR = `RPC Error: Unable to fetch dispute data. Please avoid voting.` ;
35
31
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { isUndefined } from "utils/index";
5
5
6
6
import { graphql } from "src/graphql" ;
7
7
import { HomePageBlockQuery } from "src/graphql/graphql" ;
8
+ import useGenesisBlock from "../useGenesisBlock" ;
8
9
export type { HomePageBlockQuery } ;
9
10
10
11
const homePageBlockQuery = graphql ( `
@@ -58,18 +59,20 @@ export type HomePageBlockStats = {
58
59
} ;
59
60
60
61
export const useHomePageBlockQuery = ( blockNumber : number | undefined , allTime : boolean ) => {
61
- const isEnabled = ! isUndefined ( blockNumber ) || allTime ;
62
+ const genesisBlock = useGenesisBlock ( ) ;
63
+ const isEnabled = ! isUndefined ( blockNumber ) || allTime || ! isUndefined ( genesisBlock ) ;
62
64
const { graphqlBatcher } = useGraphqlBatcher ( ) ;
63
65
64
66
return useQuery < HomePageBlockStats > ( {
65
67
queryKey : [ `homePageBlockQuery${ blockNumber } -${ allTime } ` ] ,
66
68
enabled : isEnabled ,
67
69
staleTime : Infinity ,
68
70
queryFn : async ( ) => {
71
+ const targetBlock = Math . max ( blockNumber ! , genesisBlock ! ) ;
69
72
const data = await graphqlBatcher . fetch ( {
70
73
id : crypto . randomUUID ( ) ,
71
74
document : homePageBlockQuery ,
72
- variables : { blockNumber } ,
75
+ variables : { blockNumber : targetBlock } ,
73
76
} ) ;
74
77
75
78
return processData ( data , allTime ) ;
Original file line number Diff line number Diff line change
1
+ import { useEffect , useState } from "react" ;
2
+ import { isKlerosNeo , isKlerosUniversity , isTestnetDeployment } from "~src/consts" ;
3
+
4
+ /**
5
+ * @returns genesis block for kleros core contract
6
+ */
7
+ const useGenesisBlock = ( ) => {
8
+ const [ genesisBlock , setGenesisBlock ] = useState < number > ( ) ;
9
+ useEffect ( ( ) => {
10
+ if ( isKlerosUniversity ( ) ) {
11
+ import ( "@kleros/kleros-v2-contracts/deployments/arbitrumSepoliaDevnet/KlerosCoreUniversity.json" ) . then ( ( json ) =>
12
+ setGenesisBlock ( json . receipt . blockNumber )
13
+ ) ;
14
+ } else if ( isKlerosNeo ( ) ) {
15
+ import ( "@kleros/kleros-v2-contracts/deployments/arbitrum/KlerosCoreNeo.json" ) . then ( ( json ) =>
16
+ setGenesisBlock ( json . receipt . blockNumber )
17
+ ) ;
18
+ } else if ( isTestnetDeployment ( ) ) {
19
+ import ( "@kleros/kleros-v2-contracts/deployments/arbitrumSepolia/KlerosCore.json" ) . then ( ( json ) =>
20
+ setGenesisBlock ( json . receipt . blockNumber )
21
+ ) ;
22
+ } else {
23
+ import ( "@kleros/kleros-v2-contracts/deployments/arbitrumSepoliaDevnet/KlerosCore.json" ) . then ( ( json ) =>
24
+ setGenesisBlock ( json . receipt . blockNumber )
25
+ ) ;
26
+ }
27
+ } , [ ] ) ;
28
+
29
+ return genesisBlock ;
30
+ } ;
31
+
32
+ export default useGenesisBlock ;
Original file line number Diff line number Diff line change @@ -6553,7 +6553,7 @@ __metadata:
6553
6553
languageName: unknown
6554
6554
linkType: soft
6555
6555
6556
- "@kleros/kleros-v2-contracts@workspace:contracts":
6556
+ "@kleros/kleros-v2-contracts@workspace:^, @kleros/kleros-v2-contracts@workspace: contracts":
6557
6557
version: 0.0.0-use.local
6558
6558
resolution: "@kleros/kleros-v2-contracts@workspace:contracts"
6559
6559
dependencies:
@@ -6707,6 +6707,7 @@ __metadata:
6707
6707
"@graphql-codegen/cli": "npm:^4.0.1"
6708
6708
"@graphql-codegen/client-preset": "npm:^4.2.0"
6709
6709
"@kleros/kleros-sdk": "workspace:^"
6710
+ "@kleros/kleros-v2-contracts": "workspace:^"
6710
6711
"@kleros/kleros-v2-eslint-config": "workspace:^"
6711
6712
"@kleros/kleros-v2-prettier-config": "workspace:^"
6712
6713
"@kleros/kleros-v2-tsconfig": "workspace:^"
You can’t perform that action at this time.
0 commit comments