Skip to content

Commit 2a3fdb2

Browse files
Merge pull request #554 from oceanprotocol/feat/contract-dropdown
Escrow contract switch
2 parents b7dea78 + 9524f71 commit 2a3fdb2

13 files changed

Lines changed: 411 additions & 124 deletions

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ Create a `.env.local` file (or configure your deployment environment) with the f
9898

9999
### App
100100

101-
| Variable | Description |
102-
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
103-
| `NEXT_PUBLIC_APP_ENV` | `"development"` or `"production"`. Controls which backend URLs are used and which chain tokens are on (ETH Sepolia or BASE). |
101+
| Variable | Description |
102+
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103+
| `NEXT_PUBLIC_APP_ENV` | `"development"` or `"production"`. Controls which backend URLs are used and which chain tokens are on (ETH Sepolia or BASE). |
104+
| `NEXT_PUBLIC_LEGACY_ESCROW_ADDRESS` | Optional. Address of the previous Escrow deployment on Base. When set, the escrow page shows a contract selector so users can view and withdraw funds left in it. Ignored on Sepolia. |
104105

105106
### Alchemy
106107

src/components/escrow/escrow-page.module.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
flex-direction: column;
44
}
55

6+
.contractSelector {
7+
display: flex;
8+
align-items: flex-start;
9+
gap: 12px;
10+
margin-bottom: 16px;
11+
}
12+
13+
.contractSelect {
14+
width: 350px;
15+
max-width: 100%;
16+
}
17+
18+
.hint {
19+
color: var(--text-secondary);
20+
padding: 0 16px;
21+
}
22+
23+
/* Line the chip up with the select control, below its label. */
24+
.legacyChip {
25+
margin-top: 38px;
26+
}
27+
628
.panels {
729
display: flex;
830
flex-direction: column;

src/components/escrow/escrow-page.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
import Card from '@/components/card/card';
12
import Container from '@/components/container/container';
23
import EscrowTokenPanel from '@/components/escrow/escrow-token-panel';
4+
import LegacyEscrowBanner from '@/components/homepage/legacy-escrow-banner';
5+
import Select from '@/components/input/select';
36
import SectionTitle from '@/components/section-title/section-title';
7+
import { EscrowContractVersion, LEGACY_ESCROW_ADDRESS } from '@/constants/escrow';
48
import { useEscrowData } from '@/lib/use-escrow-data';
9+
import { formatWalletAddress } from '@/utils/formatters';
510
import { CircularProgress } from '@mui/material';
611
import classNames from 'classnames';
12+
import { useState } from 'react';
713
import styles from './escrow-page.module.css';
814

915
const 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}

src/components/escrow/escrow-token-panel.module.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@
102102
.fundInput {
103103
width: 100%;
104104
min-width: 0;
105+
106+
/* Solid background instead of the translucent glass default, so the field reads as editable
107+
rather than disabled. */
108+
:global(.MuiTextField-root) {
109+
background: var(--background-primary);
110+
}
111+
}
112+
113+
/* Token-symbol prefix, separated from the value area so it doesn't read as a pre-filled value. */
114+
.fundInputSymbol {
115+
align-self: stretch;
116+
display: flex;
117+
align-items: center;
118+
padding-right: 12px;
119+
border-right: 1px solid var(--border);
120+
color: var(--text-secondary);
121+
font-size: 14px;
122+
font-weight: 600;
123+
white-space: nowrap;
105124
}
106125

107126
.fundButtons {
@@ -119,6 +138,12 @@
119138
white-space: nowrap;
120139
}
121140

141+
.legacyHint {
142+
font-size: 14px;
143+
color: var(--text-secondary);
144+
line-height: 1.5;
145+
}
146+
122147
/* ── Right column ── */
123148
.right {
124149
border-left: 1px solid var(--border);

0 commit comments

Comments
 (0)