Skip to content

Commit 40688d1

Browse files
committed
fix: doing all verifications for deposit and withdraws transfers
1 parent 9e4dfc3 commit 40688d1

File tree

1 file changed

+29
-16
lines changed
  • wallet/src/components/BridgeComponent

1 file changed

+29
-16
lines changed

‎wallet/src/components/BridgeComponent/index.jsx

+29-16
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,33 @@ const BridgeComponent = () => {
316316
}
317317

318318
const handleShow = () => {
319+
console.log('Transfer value: ',transferValue);
319320
if (
320321
(txType === 'deposit' &&
321322
new BigFloat(transferValue, token.decimals).toBigInt() > l1Balance) ||
322323
(txType === 'withdraw' && new BigFloat(transferValue, token.decimals).toBigInt() > l2Balance)
323-
)
324+
) {
324325
toast.error("Input value can't be greater than balance!");
325-
else if (!transferValue) toast.warn('Input a value for transfer, please.');
326-
else if (transferValue === 0) toast.warn("Input a value can't be zero.");
326+
return;
327+
}
328+
329+
if (txType === 'deposit' &&
330+
new BigFloat(transferValue, token.decimals).toBigInt() > new BigFloat('0.25 ', token.decimals).toBigInt()
331+
) {
332+
toast.error("Input value can't be greater than 0.25");
333+
return;
334+
}
335+
336+
if (!transferValue) {
337+
toast.warn('Input a value for transfer, please.');
338+
return;
339+
}
340+
341+
if (transferValue === '0') {
342+
toast.warn("Input a value can't be zero.");
343+
return;
344+
}
345+
327346
setShow(true);
328347
};
329348

@@ -358,11 +377,11 @@ const BridgeComponent = () => {
358377
.shadowRoot.getElementById('inputValue');
359378
if (txType === 'deposit') {
360379
inputElement.value = new BigFloat(l1Balance, token.decimals).toFixed(4);
361-
setTransferValue(l1Balance);
380+
setTransferValue((new BigFloat(l1Balance, token.decimals).toFixed(4)).toString());
362381
return;
363382
}
364-
inputElement.value = new BigFloat(l2Balance, token.decimals).toFixed(4);
365-
setTransferValue(l2Balance);
383+
inputElement.value = new BigFloat(l2Balance, token.decimals).toFixed(4);
384+
setTransferValue((new BigFloat(l2Balance, token.decimals).toFixed(4)).toString());
366385
};
367386

368387
return (
@@ -538,16 +557,10 @@ const BridgeComponent = () => {
538557
</div>
539558

540559
{/* TRANSFER BUTTON */}
541-
<div>
542-
{Number(transferValue) > 0 ? (
543-
<button type="button" className="transfer_button" onClick={handleShow}>
544-
<p>Transfer</p>
545-
</button>
546-
) : (
547-
<button type="button" className="transfer_button">
548-
<p>Transfer</p>
549-
</button>
550-
)}
560+
<div>
561+
<button type="button" className="transfer_button" onClick={handleShow}>
562+
<p>Transfer</p>
563+
</button>
551564
</div>
552565
</div>
553566
{show && (

0 commit comments

Comments
 (0)