From 6900f8fe03f7fc394eb5b1f4e968cdeb5d06396a Mon Sep 17 00:00:00 2001 From: brusher_ru Date: Mon, 16 Sep 2024 13:18:27 -0300 Subject: [PATCH] feat: check account balances before publishing tx --- src/api/schemas/strNumber.ts | 2 +- src/components/sendTx/ConfirmationModal.tsx | 20 +++++++-- src/components/sendTx/SendTxModal.tsx | 45 +++++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/api/schemas/strNumber.ts b/src/api/schemas/strNumber.ts index 2626b67..759a0a0 100644 --- a/src/api/schemas/strNumber.ts +++ b/src/api/schemas/strNumber.ts @@ -10,6 +10,6 @@ export const BigIntStringSchema = z.custom((a) => { }); export const BigIntMin = (min: bigint) => - z.custom((a) => BigInt(a) >= min, { + z.custom((a) => a && BigInt(a) >= min, { message: `Should be greater than or equal to ${String(min)}`, }); diff --git a/src/components/sendTx/ConfirmationModal.tsx b/src/components/sendTx/ConfirmationModal.tsx index b9dc7c9..e129cbd 100644 --- a/src/components/sendTx/ConfirmationModal.tsx +++ b/src/components/sendTx/ConfirmationModal.tsx @@ -77,6 +77,7 @@ type ConfirmationModalProps = ConfirmationData & { isOpen: boolean; estimatedGas: bigint | null; isLedgerRejected?: boolean; + insufficientFunds: string; }; const renderTemplateSpecificFields = (form: FormValues) => { @@ -222,6 +223,7 @@ function ConfirmationModal({ signatures = undefined, required = 1, isMultiSig = false, + insufficientFunds, isOpen, onClose, onSubmit, @@ -320,7 +322,13 @@ function ConfirmationModal({ if (!isMultiSig) { return ( - @@ -349,10 +357,11 @@ function ConfirmationModal({ return (