Add .toHuman on SubmittableResult (#1885)

This commit is contained in:
Jaco Greeff
2020-02-18 10:05:48 +01:00
committed by GitHub
parent 64f0d7b2a6
commit b46093e5d3
3 changed files with 18 additions and 3 deletions
+5 -1
View File
@@ -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
+11 -1
View File
@@ -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)
};
}
}
+2 -1
View File
@@ -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 {