Strip newlines from hex input (#3403)
* Strip newlines from hex input * Update packages/react-components/src/InputFile.tsx
This commit is contained in:
parent
4aecec7628
commit
6cd5e4d847
@ -27,8 +27,7 @@ function Sudo ({ className, isMine, sudoKey }: Props): React.ReactElement<Props>
|
||||
const [weight, setWeight] = useState<BN>(BN_ZERO);
|
||||
|
||||
const _onChangeExtrinsic = useCallback(
|
||||
(method: SubmittableExtrinsic<'promise'> | null = null) =>
|
||||
setMethod(() => method),
|
||||
(method: SubmittableExtrinsic<'promise'> | null = null) => setMethod(() => method),
|
||||
[]
|
||||
);
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ interface FileState {
|
||||
|
||||
const BYTE_STR_0 = '0'.charCodeAt(0);
|
||||
const BYTE_STR_X = 'x'.charCodeAt(0);
|
||||
const STR_NL = '\n';
|
||||
const NOOP = (): void => undefined;
|
||||
|
||||
function convertResult (result: ArrayBuffer): Uint8Array {
|
||||
@ -41,7 +42,11 @@ function convertResult (result: ArrayBuffer): Uint8Array {
|
||||
|
||||
// this converts the input (if detected as hex), via the hex conversion route
|
||||
if (data[0] === BYTE_STR_0 && data[1] === BYTE_STR_X) {
|
||||
const hex = u8aToString(data);
|
||||
let hex = u8aToString(data);
|
||||
|
||||
while (hex[hex.length - 1] === STR_NL) {
|
||||
hex = hex.substr(0, hex.length - 1);
|
||||
}
|
||||
|
||||
if (isHex(hex)) {
|
||||
return hexToU8a(hex);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user