ExtrinsicEra & Vote toHuman (#1893)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { AnyU8a, IU8a, Registry } from '../types';
|
||||
import { AnyJson, AnyU8a, IU8a, Registry } from '../types';
|
||||
|
||||
import { isU8a, isUndefined, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
@@ -102,7 +102,7 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): string {
|
||||
public toHuman (): AnyJson {
|
||||
return this.toJSON();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { AnyU8a, IExtrinsicEra, Registry } from '../../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { assert, bnToBn, hexToU8a, isHex, isU8a, isObject, u8aToBn } from '@polkadot/util';
|
||||
import { assert, bnToBn, formatNumber, hexToU8a, isHex, isU8a, isObject, u8aToBn } from '@polkadot/util';
|
||||
|
||||
import Enum from '../../codec/Enum';
|
||||
import Tuple from '../../codec/Tuple';
|
||||
@@ -127,8 +127,10 @@ export class MortalEra extends Tuple {
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): any {
|
||||
// FIXME we need proper expansion here
|
||||
return this.toJSON();
|
||||
return {
|
||||
period: formatNumber(this.period),
|
||||
phase: formatNumber(this.phase)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { ArrayElementType, Registry } from '../../types';
|
||||
import { AnyJsonObject, ArrayElementType, Registry } from '../../types';
|
||||
import democracyDef from '../../interfaces/democracy/definitions';
|
||||
import { Conviction } from '../../interfaces/democracy';
|
||||
|
||||
@@ -101,6 +101,16 @@ export default class Vote extends U8aFixed {
|
||||
return !this.isAye;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (isExpanded?: boolean): AnyJsonObject {
|
||||
return {
|
||||
vote: this.isAye ? 'Aye' : 'Nay',
|
||||
conviction: this.conviction.toHuman(isExpanded)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user