Fix KeyValue[] input (eg. system.setStorage) (#1546)

This commit is contained in:
Jaco Greeff 2019-08-28 08:30:40 +02:00 committed by GitHub
parent 90e431b594
commit e90614e76e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,10 +24,7 @@ interface State {
interface Parsed {
isValid: boolean;
value: {
key: Uint8Array;
value: Uint8Array;
}[];
value: [Uint8Array, Uint8Array][];
}
const BYTES_TYPE = {
@ -133,7 +130,7 @@ class KeyValueArray extends React.PureComponent<Props, State> {
const json = JSON.parse(u8aToString(raw));
const keys = Object.keys(json);
let isValid = keys.length !== 0;
const value = keys.map((key): { key: Uint8Array; value: Uint8Array } => {
const value = keys.map((key): [Uint8Array, Uint8Array] => {
const value = json[key];
assert(isHex(key) && isHex(value), `Non-hex key/value pair found in ${key.toString()} => ${value.toString()}`);
@ -143,10 +140,7 @@ class KeyValueArray extends React.PureComponent<Props, State> {
isValid = isValid && encKey.isValid && encValue.isValid;
return {
key: encKey.u8a,
value: encValue.u8a
};
return [encKey.u8a, encValue.u8a];
});
return {