1+ import Card from '@/components/card/card' ;
12import Container from '@/components/container/container' ;
23import EscrowTokenPanel from '@/components/escrow/escrow-token-panel' ;
4+ import LegacyEscrowBanner from '@/components/homepage/legacy-escrow-banner' ;
5+ import Select from '@/components/input/select' ;
36import SectionTitle from '@/components/section-title/section-title' ;
7+ import { EscrowContractVersion , LEGACY_ESCROW_ADDRESS } from '@/constants/escrow' ;
48import { useEscrowData } from '@/lib/use-escrow-data' ;
9+ import { formatWalletAddress } from '@/utils/formatters' ;
510import { CircularProgress } from '@mui/material' ;
611import classNames from 'classnames' ;
12+ import { useState } from 'react' ;
713import styles from './escrow-page.module.css' ;
814
915const EscrowPage = ( ) => {
10- const { tokens, spenders, loading, reload } = useEscrowData ( ) ;
16+ const [ contractVersion , setContractVersion ] = useState < EscrowContractVersion > ( 'current' ) ;
17+ const isLegacy = contractVersion === 'legacy' ;
18+ const escrowAddress = isLegacy ? LEGACY_ESCROW_ADDRESS : undefined ;
19+ const { tokens, spenders, loading, reload } = useEscrowData ( escrowAddress ) ;
1120
1221 return (
1322 < Container className = "pageRoot" >
@@ -17,6 +26,31 @@ const EscrowPage = () => {
1726 subTitle = "Deposit and withdraw escrow funds, and manage the spending authorizations used to pay for compute jobs."
1827 />
1928 < div className = { classNames ( 'pageContentWrapper' , styles . content ) } >
29+ < LegacyEscrowBanner />
30+ { LEGACY_ESCROW_ADDRESS && (
31+ < Card direction = "column" padding = "sm" radius = "lg" shadow = "black" variant = "glass-shaded" >
32+ < div className = { styles . contractSelector } >
33+ < Select < EscrowContractVersion >
34+ className = { styles . contractSelect }
35+ label = "Escrow contract"
36+ onChange = { ( e ) => setContractVersion ( e . target . value as EscrowContractVersion ) }
37+ options = { [
38+ { label : 'Current contract' , value : 'current' } ,
39+ { label : `Legacy contract (${ formatWalletAddress ( LEGACY_ESCROW_ADDRESS ) } )` , value : 'legacy' } ,
40+ ] }
41+ value = { contractVersion }
42+ />
43+ { isLegacy && < span className = { classNames ( 'chip chipGlass' , styles . legacyChip ) } > Withdraw only</ span > }
44+ </ div >
45+ { isLegacy ? (
46+ < div className = { styles . hint } >
47+ < strong > Viewing the previous escrow deployment.</ strong >
48+ < br />
49+ You can withdraw your funds; deposits and authorization changes are disabled.
50+ </ div >
51+ ) : undefined }
52+ </ Card >
53+ ) }
2054 { loading && tokens . length === 0 ? (
2155 < CircularProgress className = "alignSelfCenter" />
2256 ) : (
@@ -27,6 +61,7 @@ const EscrowPage = () => {
2761 ) ;
2862 return (
2963 < EscrowTokenPanel
64+ escrowAddress = { escrowAddress }
3065 key = { token . address }
3166 loadingSpenders = { loading }
3267 onChange = { reload }
0 commit comments