Skip to content

Commit

Permalink
chore: bridge validation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ap211unitech committed Jun 21, 2024
1 parent adb9e30 commit 3408e88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/hestia/src/components/thea/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export const Form = () => {
} = useFormik({
initialValues,
validationSchema: bridgeValidations(
!!sourceAccount,
!!destinationAccount,
minAmount,
max?.amount,
destinationPDEXBalance,
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/validations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from "@orderbook/core/constants";

export const bridgeValidations = (
sourceWalletPresent: boolean,
destinationWalletPresent: boolean,
minAmount = 0,
maxAmount = 0,
destinationPDEXBalance = 0,
Expand All @@ -24,6 +26,16 @@ export const bridgeValidations = (
return Yup.object().shape({
amount: Yup.string()
.required("Required")
.test(
CrossChainError.SOURCE_WALLET,
CrossChainError.SOURCE_WALLET,
() => sourceWalletPresent
)
.test(
CrossChainError.DESTINATION_WALLET,
CrossChainError.DESTINATION_WALLET,
() => destinationWalletPresent
)
.test(
ErrorMessages().WHITESPACE_NOT_ALLOWED,
ErrorMessages().WHITESPACE_NOT_ALLOWED,
Expand Down

0 comments on commit 3408e88

Please sign in to comment.