UNPKG

544 BJavaScriptView Raw
1import { u8aEq } from '@polkadot/util';
2import { decodeAddress } from './decode.js';
3/**
4 * @name addressEq
5 * @summary Compares two addresses, either in ss58, Uint8Array or hex format.
6 * @description
7 * For the input values, return true is the underlying public keys do match.
8 * @example
9 * <BR>
10 *
11 * ```javascript
12 * import { u8aEq } from '@polkadot/util';
13 *
14 * u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
15 * ```
16 */
17export function addressEq(a, b) {
18 return u8aEq(decodeAddress(a), decodeAddress(b));
19}