Minor readability improvements (#952)
* Minor readability improvements * trigger * Additional * Additional
This commit is contained in:
@@ -22,9 +22,5 @@ export function hexAddPrefix (value?: string | null): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
const prefix = value && value.length % 2 === 1
|
||||
? '0'
|
||||
: '';
|
||||
|
||||
return `0x${prefix}${value || ''}`;
|
||||
return `0x${value && value.length % 2 === 1 ? '0' : ''}${value || ''}`;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,9 @@ const UNPREFIX_HEX_REGEX = /^[a-fA-F0-9]+$/;
|
||||
export function hexStripPrefix (value?: string | null): string {
|
||||
if (!value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (hexHasPrefix(value)) {
|
||||
} else if (hexHasPrefix(value)) {
|
||||
return value.substr(2);
|
||||
}
|
||||
|
||||
if (UNPREFIX_HEX_REGEX.test(value)) {
|
||||
} else if (UNPREFIX_HEX_REGEX.test(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ function reverse (value: string): string {
|
||||
|
||||
/**
|
||||
* @name hexToBn
|
||||
* @summary Creates a BN.js bignumber object from a hex string.
|
||||
* @summary Creates a BN.js object from a hex string.
|
||||
* @description
|
||||
* `null` inputs returns a `BN(0)` result. Hex input values return the actual value converted to a BN. Anything that is not a hex string (including the `0x` prefix) throws an error.
|
||||
* @param _value The value to convert
|
||||
@@ -43,7 +43,6 @@ export function hexToBn (value?: string | number | null, options: ToBnOptions |
|
||||
// Backwards-compatibility
|
||||
...(isBoolean(options) ? { isLe: options } : options)
|
||||
};
|
||||
|
||||
const _value = hexStripPrefix(value as string);
|
||||
|
||||
// FIXME: Use BN's 3rd argument `isLe` once this issue is fixed
|
||||
|
||||
Reference in New Issue
Block a user