diff --git a/packages/react-params/src/Param/Amount.tsx b/packages/react-params/src/Param/Amount.tsx index 6aff81c461..68fad98c47 100644 --- a/packages/react-params/src/Param/Amount.tsx +++ b/packages/react-params/src/Param/Amount.tsx @@ -12,7 +12,7 @@ import { bnToBn, formatNumber, isUndefined } from '@polkadot/util'; import Bare from './Bare'; -function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, withLabel }: Props): React.ReactElement { +function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, type, withLabel }: Props): React.ReactElement { const defaultValue = useMemo( () => isDisabled ? value instanceof ClassOf(registry, 'AccountIndex') @@ -22,6 +22,17 @@ function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, [isDisabled, value] ); + const bitLength = useMemo( + (): number => { + try { + return registry.createType(type.type as 'u32').bitLength(); + } catch (error) { + return 32; + } + }, + [type] + ); + const _onChange = useCallback( (value?: BN) => onChange && onChange({ isValid: !isUndefined(value), @@ -45,6 +56,7 @@ function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, ) : (