Bump common (#1879)
* Bump common * Add documentation to extended call * TODO for toHuman event * CHANGELOG
This commit is contained in:
@@ -50,7 +50,7 @@ export default class UInt extends AbstractInt {
|
||||
public toHuman (isExpanded?: boolean): any {
|
||||
// FIXME we need proper expansion here
|
||||
return this instanceof ClassOf(this.registry, 'Balance')
|
||||
? formatBalance(this, { withSi: true, withUnit: true })
|
||||
? formatBalance(this, { withSi: true, withUnit: this.registry.chainToken }, this.registry.chainDecimals)
|
||||
: super.toHuman(isExpanded);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ChainProperties, DispatchErrorModule } from '../interfaces/types';
|
||||
import { CallFunction, Codec, Constructor, InterfaceTypes, RegistryError, RegistryTypes, Registry, RegistryMetadata, TypeDef } from '../types';
|
||||
|
||||
import extrinsicsFromMeta from '@polkadot/metadata/Decorated/extrinsics/fromMetadata';
|
||||
import { assert, isFunction, isString, isU8a, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
import { assert, formatBalance, isFunction, isString, isU8a, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Raw from '../codec/Raw';
|
||||
import { EventData } from '../primitive/Generic/Event';
|
||||
@@ -121,7 +121,7 @@ export class TypeRegistry implements Registry {
|
||||
public get chainToken (): string {
|
||||
return this._chainProperties?.tokenSymbol.isSome
|
||||
? this._chainProperties.tokenSymbol.unwrap().toString()
|
||||
: 'DEV';
|
||||
: formatBalance.getDefaults().unit;
|
||||
}
|
||||
|
||||
// find a specific call
|
||||
|
||||
@@ -215,7 +215,11 @@ export default class Call extends Struct implements IMethod {
|
||||
callIndex: u8aToHex(this.callIndex),
|
||||
section: call?.section,
|
||||
method: call?.method,
|
||||
args: this.args.map((arg) => arg.toHuman(isExpanded))
|
||||
args: this.args.map((arg) => arg.toHuman(isExpanded)),
|
||||
...(isExpanded && call
|
||||
? { documentation: call.meta.documentation.map((d) => d.toString()) }
|
||||
: {}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { TypeDef } from '../../create/types';
|
||||
import { EventMetadataLatest } from '../../interfaces/metadata';
|
||||
import { EventId } from '../../interfaces/system';
|
||||
import { Constructor, Registry, RegistryMetadataEvent } from '../../types';
|
||||
import { AnyJsonObject, Constructor, Registry, RegistryMetadataEvent } from '../../types';
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
import Tuple from '../../codec/Tuple';
|
||||
@@ -141,4 +141,13 @@ export default class Event extends Struct {
|
||||
public get typeDef (): TypeDef[] {
|
||||
return this.data.typeDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public toHuman (isExpanded?: boolean): AnyJsonObject {
|
||||
// FIXME May this human-friendly
|
||||
return this.toJSON();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user