StorageKey toHuman returns decoded key (#2183)
This commit is contained in:
@@ -240,9 +240,7 @@ describe('StorageKey', (): void => {
|
||||
|
||||
key.setMeta(metadata.query.staking.erasStakers.meta);
|
||||
|
||||
expect(
|
||||
key.args.map((arg) => arg.toHuman())
|
||||
).toEqual([
|
||||
expect(key.toHuman()).toEqual([
|
||||
'16',
|
||||
'5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY'
|
||||
]);
|
||||
@@ -253,9 +251,7 @@ describe('StorageKey', (): void => {
|
||||
|
||||
key.setMeta(metadata.query.society.defenderVotes.meta);
|
||||
|
||||
expect(
|
||||
key.args.map((arg) => arg.toHuman())
|
||||
).toEqual([
|
||||
expect(key.toHuman()).toEqual([
|
||||
'5D4yQHKfqCQYThhHmTfN1JEDi47uyDJc1xg9eZfAG1R7FC7J'
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { StorageEntryMetadataLatest, StorageEntryTypeLatest, StorageHasher } from '../interfaces/metadata';
|
||||
import { AnyU8a, Codec, InterfaceTypes, Registry } from '../types';
|
||||
import { AnyJson, AnyU8a, Codec, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { assert, isFunction, isString, isU8a } from '@polkadot/util';
|
||||
|
||||
@@ -261,4 +261,20 @@ export default class StorageKey extends Bytes {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the Human representation for this type
|
||||
*/
|
||||
public toHuman (): AnyJson {
|
||||
return this._args.length
|
||||
? this._args.map((arg) => arg.toHuman())
|
||||
: super.toHuman();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the raw type for this
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'StorageKey';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user