1 | // Copyright 2017-2022 @polkadot/util-crypto authors & contributors
|
2 | // SPDX-License-Identifier: Apache-2.0
|
3 | import { isHex } from '@polkadot/util';
|
4 | import { isEthereumChecksum } from "./isChecksum.js";
|
5 | export function isEthereumAddress(address) {
|
6 | if (!address || address.length !== 42 || !isHex(address)) {
|
7 | return false;
|
8 | } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
|
9 | return true;
|
10 | }
|
11 |
|
12 | return isEthereumChecksum(address);
|
13 | } |
\ | No newline at end of file |