diff --git a/ui/components/vault/VaultCard.tsx b/ui/components/vault/VaultCard.tsx index 7be2475..a3adbe4 100644 --- a/ui/components/vault/VaultCard.tsx +++ b/ui/components/vault/VaultCard.tsx @@ -13,7 +13,6 @@ import { getForrmattedFullDate, isValidAddress } from '@/utils/tools'; import { ClaimType } from '@/utils/vaults/claim'; import { RuleOperators, getShortOperator } from '@/utils/vaults/operators'; import { splitValidationSchema } from '@/utils/vaults/schema'; -import { isNumericType } from '@/utils/vaults/types'; import { wagmiConfig } from '@/utils/wagmi'; import { ArrowRightIcon } from 'lucide-react'; import Link from 'next/link'; @@ -104,9 +103,7 @@ export const VaultCard: IComponent = ({ const value = decodeAbiParameters(abi, thresholds[index])[0] as string; thresholdValue = isValidAddress(value) ? value.slice(0, 4) + '...' + value.slice(-4) - : isNumericType(type as TRuleType) - ? Number(value).toLocaleString() - : value; + : value; } return ( { // eslint-disable-next-line @typescript-eslint/no-explicit-any const value = (values as any)[ruleName]; - const [valid, parsedValue, msg] = validateField(rule.type, value); - if (!valid || !parsedValue) { + const [valid, msg] = validateField(rule.type, value); + if (!valid) { form.setError(ruleName, { message: msg }); isError = true; return; } - ops.push(op); - if (rule.type === 'bool') { - const boolValue = value === 'true'; - thresholds.push(encodeAbiParameters([{ type: 'bool', value: boolValue }], [boolValue])); - return; - } else { - const encodedValue = encodeAbiParameters([{ type: rule.type, value: value }], [value]); - thresholds.push(encodedValue); - } + const encodedValue = encodeAbiParameters([{ type: rule.type, value }], [value]); + thresholds.push(encodedValue); }); if (isError) { diff --git a/ui/utils/vaults/schema.ts b/ui/utils/vaults/schema.ts index 7204b4e..928a712 100644 --- a/ui/utils/vaults/schema.ts +++ b/ui/utils/vaults/schema.ts @@ -114,29 +114,26 @@ export const RuleSchema: Record = { .optional(), } as const; -export const validateField = ( - type: TRuleType, - value: string -): [boolean, number | string | boolean | bigint | undefined, string] => { +export const validateField = (type: TRuleType, value: string): [boolean, string] => { if (isNumericType(type)) { const num = parseInt(value, 10); if (isNaN(num)) { - return [false, undefined, 'Must be a valid number']; + return [false, 'Must be a valid number']; } const min = getMinValue(type); const max = getMaxValue(type); const result = num >= min && num <= max; - return [result, num, result ? '' : `Must be a number between ${min} and ${max}`]; + return [result, result ? '' : `Must be a number between ${min} and ${max}`]; } else if (isBytesType(type)) { - return [isNBytesValue(type, value), value, 'Must be a valid bytes string']; + return [isNBytesValue(type, value), 'Must be a valid bytes string']; } else if (type === 'address') { - return [isValidAddress(value), value, 'Must be a valid address']; + return [isValidAddress(value), 'Must be a valid address']; } else if (type === 'bool') { - return [value === 'true' || value === 'false', value === 'true', 'Must be a valid boolean']; + return [value === 'true' || value === 'false', 'Must be a valid boolean']; } else { // string is always valid } - return [true, undefined, '']; + return [true, '']; }; export const splitValidationSchema = (schema: string): [string, string][] => {