mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-04-23 04:47:57 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
// Copyright 2017-2025 @pezkuwi/react-params authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Props as BaseProps } from '../types.js';
|
||||
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { InputAddressSimple } from '@pezkuwi/react-components';
|
||||
import { isEthereumAddress, validateAddress } from '@pezkuwi/util-crypto';
|
||||
|
||||
import Bare from './Bare.js';
|
||||
|
||||
interface Props extends BaseProps {
|
||||
bytesLength: 20 | 32;
|
||||
}
|
||||
|
||||
function isValidAddress (value: string | null | undefined, isEthereum: boolean): boolean {
|
||||
if (value) {
|
||||
try {
|
||||
return isEthereum
|
||||
? isEthereumAddress(value)
|
||||
: validateAddress(value);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function BasicAccountIdBase (props: Props): React.ReactElement<Props> {
|
||||
const { bytesLength, className = '', defaultValue: { value }, isDisabled, isError, label, onChange } = props;
|
||||
const [defaultValue] = useState(() => (value as string)?.toString());
|
||||
|
||||
const _onChange = useCallback(
|
||||
(value?: string | null) =>
|
||||
onChange && onChange({
|
||||
isValid: isValidAddress(value, bytesLength === 20),
|
||||
value
|
||||
}),
|
||||
[bytesLength, onChange]
|
||||
);
|
||||
|
||||
return (
|
||||
<Bare className={className}>
|
||||
<InputAddressSimple
|
||||
bytesLength={bytesLength}
|
||||
className='full'
|
||||
defaultValue={defaultValue}
|
||||
forceIconType={bytesLength === 20 ? 'ethereum' : 'bizinikiwi'}
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
label={label}
|
||||
noConvert
|
||||
onChange={_onChange}
|
||||
placeholder={bytesLength === 20 ? '0x1...' : '5...'}
|
||||
/>
|
||||
</Bare>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(BasicAccountIdBase);
|
||||
Reference in New Issue
Block a user