mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 09:08:03 +00:00
12 lines
390 B
JavaScript
12 lines
390 B
JavaScript
import { isHex } from '@pezkuwi/util';
|
|
import { isEthereumChecksum } from './isChecksum.js';
|
|
export function isEthereumAddress(address) {
|
|
if (!address || address.length !== 42 || !isHex(address)) {
|
|
return false;
|
|
}
|
|
else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
|
|
return true;
|
|
}
|
|
return isEthereumChecksum(address);
|
|
}
|