Skip to content

Commit b7dea78

Browse files
authored
Escrow page improvements (#555)
* escrow page improvements * deposit/withdraw funds * single request for fetch nodes by addresses * remove unused class * change endAdornment * fix comment * add terms operator * add amount placeholder * refactor api call
1 parent bb82fb7 commit b7dea78

8 files changed

Lines changed: 246 additions & 142 deletions

src/components/button/copy-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const CopyButton: React.FC<CopyButtonProps> = ({
3232
<Button
3333
className={className}
3434
color={color}
35-
contentBefore={copied ? <CheckIcon /> : <ContentCopyIcon />}
35+
contentBefore={copied ? <CheckIcon fontSize="small" /> : <ContentCopyIcon fontSize="small" />}
3636
onClick={handleClick}
3737
size={size}
3838
variant={variant}

src/components/escrow/authorization-form.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const AuthorizationForm = ({
6060
name="maxLockedAmount"
6161
onBlur={formik.handleBlur}
6262
onChange={formik.handleChange}
63+
size="sm"
6364
step="any"
6465
type="number"
6566
value={formik.values.maxLockedAmount}
@@ -73,16 +74,19 @@ const AuthorizationForm = ({
7374
name="maxLockSeconds"
7475
onBlur={formik.handleBlur}
7576
onChange={formik.handleChange}
77+
size="sm"
7678
type="number"
7779
value={formik.values.maxLockSeconds}
7880
/>
7981
<Input
80-
endAdornment="locks"
82+
endAdornment="jobs"
8183
errorText={formik.touched.maxLockCount && formik.errors.maxLockCount ? formik.errors.maxLockCount : undefined}
82-
label="Max lock count"
84+
hint="Max lock count"
85+
label="Max concurrent jobs"
8386
name="maxLockCount"
8487
onBlur={formik.handleBlur}
8588
onChange={formik.handleChange}
89+
size="sm"
8690
type="number"
8791
value={formik.values.maxLockCount}
8892
/>

src/components/escrow/create-authorization-modal.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ const CreateAuthorizationModal = ({
8989
setFieldError('nodeId', 'Node not found');
9090
return null;
9191
}
92-
const consumer = node.computeEnvironments?.environments?.find((env) => env.consumerAddress)?.consumerAddress;
92+
const consumer =
93+
node.address ?? node.computeEnvironments?.environments?.find((env) => env.consumerAddress)?.consumerAddress;
9394
if (!consumer) {
94-
setFieldError('nodeId', 'Node has no compute environment with a consumer address');
95+
setFieldError('nodeId', 'Could not resolve ETH address for this node');
9596
return null;
9697
}
9798
return consumer;
9899
} catch (error) {
99-
console.error('Error resolving node consumer address: ', error);
100+
console.error('Could not resolve ETH address for this node: ', error);
100101
setFieldError('nodeId', 'Failed to fetch node');
101102
return null;
102103
}
@@ -114,11 +115,12 @@ const CreateAuthorizationModal = ({
114115
<form className={styles.root} onSubmit={formik.handleSubmit}>
115116
<Input
116117
errorText={formik.touched.nodeId && formik.errors.nodeId ? formik.errors.nodeId : undefined}
117-
label="Node ID"
118+
label="Node peer ID"
118119
name="nodeId"
119120
onBlur={formik.handleBlur}
120121
onChange={formik.handleChange}
121122
placeholder="Node peer ID"
123+
size="sm"
122124
type="text"
123125
value={formik.values.nodeId}
124126
/>
@@ -134,6 +136,7 @@ const CreateAuthorizationModal = ({
134136
name="maxLockedAmount"
135137
onBlur={formik.handleBlur}
136138
onChange={formik.handleChange}
139+
size="sm"
137140
step="any"
138141
type="number"
139142
value={formik.values.maxLockedAmount}
@@ -147,18 +150,21 @@ const CreateAuthorizationModal = ({
147150
name="maxLockSeconds"
148151
onBlur={formik.handleBlur}
149152
onChange={formik.handleChange}
153+
size="sm"
150154
type="number"
151155
value={formik.values.maxLockSeconds}
152156
/>
153157
<Input
154-
endAdornment="locks"
158+
endAdornment="jobs"
155159
errorText={
156160
formik.touched.maxLockCount && formik.errors.maxLockCount ? formik.errors.maxLockCount : undefined
157161
}
158-
label="Max lock count"
162+
hint="Max lock count"
163+
label="Max concurrent jobs"
159164
name="maxLockCount"
160165
onBlur={formik.handleBlur}
161166
onChange={formik.handleChange}
167+
size="sm"
162168
type="number"
163169
value={formik.values.maxLockCount}
164170
/>

src/components/escrow/edit-authorization-modal.tsx

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import Button from '@/components/button/button';
2+
import CopyButton from '@/components/button/copy-button';
23
import AuthorizationForm from '@/components/escrow/authorization-form';
4+
import styles from '@/components/escrow/escrow-token-panel.module.css';
35
import Modal from '@/components/modal/modal';
46
import { useAuthorizeTokens } from '@/lib/use-authorize-tokens';
57
import { EscrowSpenderInfo } from '@/lib/use-escrow-data';
8+
import { formatWalletAddress } from '@/utils/formatters';
69

710
type EditAuthorizationModalProps = {
811
isOpen: boolean;
@@ -17,7 +20,36 @@ const EditAuthorizationModal = ({ isOpen, onClose, onSuccess, spender }: EditAut
1720
const { authorizations, tokenAddress, tokenSymbol } = spender;
1821

1922
return (
20-
<Modal isOpen={isOpen} onClose={onClose} title="Edit authorization" width="sm">
23+
<Modal isOpen={isOpen} onClose={onClose} title="Edit authorization per node" width="sm">
24+
<div>
25+
<h4>{spender.nodeFriendlyName ?? (spender.nodeId ? 'Unnamed node' : 'Unknown node')}</h4>
26+
{spender.nodeId && (
27+
<div className={styles.copyRow}>
28+
<strong>Peer ID:</strong>
29+
<span className={styles.hash}>{formatWalletAddress(spender.nodeId)}</span>
30+
<CopyButton
31+
color="accent1"
32+
contentToCopy={spender.nodeId}
33+
label=""
34+
labelCopied=""
35+
size="sm"
36+
variant="transparent"
37+
/>
38+
</div>
39+
)}
40+
<div className={styles.copyRow}>
41+
<strong>ETH Address:</strong>
42+
<span className={styles.hash}>{formatWalletAddress(spender.spender)}</span>
43+
<CopyButton
44+
color="accent1"
45+
contentToCopy={spender.spender}
46+
label=""
47+
labelCopied=""
48+
size="sm"
49+
variant="transparent"
50+
/>
51+
</div>
52+
</div>
2153
<AuthorizationForm
2254
initialValues={{
2355
maxLockedAmount: Number(authorizations.maxLockedAmount),

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

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,6 @@
2222
}
2323
}
2424

25-
.tokenHeader {
26-
display: flex;
27-
align-items: center;
28-
}
29-
30-
.tokenSymbol {
31-
display: block;
32-
font-size: 22px;
33-
font-weight: 700;
34-
line-height: 1.1;
35-
}
36-
3725
.overline {
3826
display: block;
3927
font-size: 12px;
@@ -111,16 +99,23 @@
11199
gap: 10px;
112100
}
113101

114-
.fundRow {
115-
display: flex;
116-
}
117-
118102
.fundInput {
119-
flex: 1;
103+
width: 100%;
120104
min-width: 0;
121105
}
122106

107+
.fundButtons {
108+
display: flex;
109+
flex-direction: column;
110+
gap: 10px;
111+
112+
@media (min-width: 576px) {
113+
flex-direction: row;
114+
}
115+
}
116+
123117
.fundButton {
118+
flex: 1;
124119
white-space: nowrap;
125120
}
126121

@@ -147,31 +142,32 @@
147142
gap: 10px;
148143
}
149144

150-
.authSectionTitle {
151-
font-size: 18px;
152-
font-weight: 700;
153-
line-height: 1.2;
154-
}
155-
156145
.createAuthButton {
157146
margin-left: auto;
158147
}
159148

160149
.authHeader {
161150
display: flex;
162-
align-items: center;
151+
align-items: flex-start;
163152
flex-wrap: wrap;
164153
justify-content: space-between;
165154
gap: 12px;
166155
}
167156

168-
.authSpender {
169-
font-size: 14px;
170-
font-weight: 600;
171-
font-variant-numeric: tabular-nums;
172-
overflow: hidden;
173-
text-overflow: ellipsis;
157+
.copyRow {
158+
display: flex;
159+
align-items: center;
160+
flex-wrap: wrap;
161+
gap: 0px 8px;
174162
white-space: nowrap;
163+
font-size: 13px;
164+
165+
.hash {
166+
color: var(--text-secondary);
167+
font-variant-numeric: tabular-nums;
168+
overflow: hidden;
169+
text-overflow: ellipsis;
170+
}
175171
}
176172

177173
.statsGrid {
@@ -357,10 +353,3 @@
357353
font-size: 17px;
358354
font-weight: 700;
359355
}
360-
361-
.noAuthDesc {
362-
font-size: 14px;
363-
color: var(--text-secondary);
364-
max-width: 400px;
365-
line-height: 1.5;
366-
}

0 commit comments

Comments
 (0)