diff --git a/CHANGELOG.md b/CHANGELOG.md index 80951fbd9a..d00d3c21aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,13 @@ +# 1.4.0-beta.x + +- Add `.toHuman` on SubmittableResult, aligning with Codec + # 1.3.1 Feb 18, 2020 - Add `@types/bn.js` as a normal dependency, exposed in `*.d.ts` ((Thanks to https://github.com/monitz87) - Type generation scripts (including `polkadot-types-from-{chain,defs}`) has been moved to the `@polkadot/typegen` package - The `@polkadot/types/codec/create` has been moved to `@polkadot/types/create`, imports from `@polkadot/types` are unaffected -- Expose chain properies on registry (and use for API type formatting) +- Expose chain properties on registry (and use for API type formatting) - Add `toHuman(isExtended?: boolean)` to all codec types, formatting into a human-readable structure # 1.2.1 Feb 16, 2020 diff --git a/packages/api/src/submittable/Result.ts b/packages/api/src/submittable/Result.ts index a042a322d0..596ef34a2e 100644 --- a/packages/api/src/submittable/Result.ts +++ b/packages/api/src/submittable/Result.ts @@ -3,7 +3,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { ExtrinsicStatus, EventRecord } from '@polkadot/types/interfaces'; -import { ISubmittableResult } from '@polkadot/types/types'; +import { AnyJson, ISubmittableResult } from '@polkadot/types/types'; import { SubmittableResultValue } from './types'; export default class SubmittableResult implements ISubmittableResult { @@ -49,4 +49,14 @@ export default class SubmittableResult implements ISubmittableResult { event.section === section && event.method === method ); } + + /** + * @description Creates a human representation of the output + */ + public toHuman (isExtended?: boolean): AnyJson { + return { + events: this.events.map((event) => event.toHuman(isExtended)), + status: this.status.toHuman(isExtended) + }; + } } diff --git a/packages/types/src/types/extrinsic.ts b/packages/types/src/types/extrinsic.ts index 88abf21082..d71feee947 100644 --- a/packages/types/src/types/extrinsic.ts +++ b/packages/types/src/types/extrinsic.ts @@ -6,7 +6,7 @@ import { ExtrinsicStatus } from '../interfaces/rpc'; import { Address, Balance, Call, EcdsaSignature, Ed25519Signature, Index, Sr25519Signature } from '../interfaces/runtime'; import { EventRecord } from '../interfaces/system'; import { Codec } from './codec'; -import { AnyNumber, AnyU8a } from './helpers'; +import { AnyJson, AnyNumber, AnyU8a } from './helpers'; import { ICompact, IHash, IKeyringPair, IMethod, IRuntimeVersion } from './interfaces'; // eslint-disable-next-line @typescript-eslint/interface-name-prefix @@ -20,6 +20,7 @@ export interface ISubmittableResult { filterRecords (section: string, method: string): EventRecord[]; findRecord (section: string, method: string): EventRecord | undefined; + toHuman (isExtended?: boolean): AnyJson; } export interface SignerResult {