diff --git a/CHANGELOG.md b/CHANGELOG.md index cd7f488c1..936df61ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug fixes +- [#1069](https://github.com/alleslabs/celatone-frontend/pull/1069) Fix add custom minitia network manually - [#1065](https://github.com/alleslabs/celatone-frontend/pull/1065) Fix zod url validation to allow only http and https in add custom minitia page - [#1064](https://github.com/alleslabs/celatone-frontend/pull/1064) Fix cancel button in add custom minitia page - [#1068](https://github.com/alleslabs/celatone-frontend/pull/1068) Add fetching bech32 prefix from lcd and disable close success modal on overlay click diff --git a/src/lib/app-provider/env.ts b/src/lib/app-provider/env.ts index 6e8794065..1f9552f62 100644 --- a/src/lib/app-provider/env.ts +++ b/src/lib/app-provider/env.ts @@ -15,7 +15,7 @@ export enum CELATONE_QUERY_KEYS { ACCOUNT_DATA = "CELATONE_QUERY_ACCOUNT_DATA", ACCOUNT_TYPE = "CELATONE_QUERY_ACCOUNT_TYPE", ACCOUNT_TYPE_LCD = "CELATONE_QUERY_ACCOUNT_TYPE_LCD", - ACCOUNT_BECH_32 = "CELATONE_QUERY_ACCOUNT_BECH_32", + ACCOUNT_BECH_32_LCD = "CELATONE_QUERY_ACCOUNT_BECH_32_LCD", // ASSET ASSET_INFOS = "CELATONE_QUERY_ASSET_INFOS", // BLOCK diff --git a/src/lib/app-provider/hooks/useRestrictedInput.ts b/src/lib/app-provider/hooks/useRestrictedInput.ts index 30c826086..182a21936 100644 --- a/src/lib/app-provider/hooks/useRestrictedInput.ts +++ b/src/lib/app-provider/hooks/useRestrictedInput.ts @@ -46,15 +46,15 @@ export function useRestrictedInput( export interface RestrictedNumberInputParams { type?: "decimal" | "integer"; maxDecimalPoints?: number; - maxIntegerPoinsts?: number; + maxIntegerPoints?: number; onChange?: (event: ChangeEvent) => void; } // eslint-disable-next-line sonarjs/cognitive-complexity export function useRestrictedNumberInput({ type = "decimal", - maxDecimalPoints, - maxIntegerPoinsts, + maxDecimalPoints = 6, + maxIntegerPoints = 7, onChange: _onChange, }: RestrictedNumberInputParams): RestrictedInputReturn { const { onKeyPress: restrictCharacters } = useRestrictedInput( @@ -65,14 +65,14 @@ export function useRestrictedNumberInput({ (nextValue: string): boolean => { return ( Number.isNaN(+nextValue) || - (typeof maxIntegerPoinsts === "number" && - new RegExp(`^[0-9]{${maxIntegerPoinsts + 1},}`).test(nextValue)) || + (typeof maxIntegerPoints === "number" && + new RegExp(`^[0-9]{${maxIntegerPoints + 1},}`).test(nextValue)) || (type === "decimal" && typeof maxDecimalPoints === "number" && new RegExp(`\\.[0-9]{${maxDecimalPoints + 1},}$`).test(nextValue)) ); }, - [maxDecimalPoints, maxIntegerPoinsts, type] + [maxDecimalPoints, maxIntegerPoints, type] ); const onKeyPress = useCallback( diff --git a/src/lib/components/forms/ControllerInput.tsx b/src/lib/components/forms/ControllerInput.tsx index 4dbf73e38..7e0bc90f3 100644 --- a/src/lib/components/forms/ControllerInput.tsx +++ b/src/lib/components/forms/ControllerInput.tsx @@ -41,7 +41,7 @@ export interface ControllerInputProps }; restrictedNumberInputParams?: Pick< RestrictedNumberInputParams, - "maxDecimalPoints" | "maxIntegerPoinsts" + "maxDecimalPoints" | "maxIntegerPoints" >; } @@ -63,10 +63,7 @@ export const ControllerInput = ({ helperAction, textAlign = "left", cta, - restrictedNumberInputParams = { - maxIntegerPoinsts: 7, - maxDecimalPoints: 6, - }, + restrictedNumberInputParams, ...componentProps }: ControllerInputProps) => { const watcher = useWatch({ @@ -103,14 +100,13 @@ export const ControllerInput = ({ const decimalHandlers = useRestrictedNumberInput({ type: "decimal", - maxIntegerPoinsts: restrictedNumberInputParams.maxIntegerPoinsts, - maxDecimalPoints: restrictedNumberInputParams.maxDecimalPoints, onChange: field.onChange, + ...restrictedNumberInputParams, }); const numberHandlers = useRestrictedNumberInput({ type: "integer", - maxIntegerPoinsts: 7, + maxIntegerPoints: 7, maxDecimalPoints: 0, onChange: field.onChange, }); diff --git a/src/lib/components/forms/NumberInput.tsx b/src/lib/components/forms/NumberInput.tsx index 67c4a3bab..a78341638 100644 --- a/src/lib/components/forms/NumberInput.tsx +++ b/src/lib/components/forms/NumberInput.tsx @@ -51,7 +51,7 @@ export const NumberInput = ({ const handlers = useRestrictedNumberInput({ type: "integer", - maxIntegerPoinsts: 7, + maxIntegerPoints: 7, maxDecimalPoints: 0, onChange: inputOnChange, }); diff --git a/src/lib/services/account/index.ts b/src/lib/services/account/index.ts index 4ebc1374e..3f6f8c4b4 100644 --- a/src/lib/services/account/index.ts +++ b/src/lib/services/account/index.ts @@ -96,7 +96,7 @@ export const useAccountBech32 = ( endpoint: string ): UseQueryResult => useQuery( - [CELATONE_QUERY_KEYS.ACCOUNT_BECH_32], + [CELATONE_QUERY_KEYS.ACCOUNT_BECH_32_LCD], async () => getAccountBech32Lcd(endpoint), { retry: 1,