BigInt support (& some TS typing cleanups) (#1919)

* Some TS typing cleanups

* docs building again

* yarn.lock rewrite

* tweaks

* BigInt support

* Checktypes with BigInt

* AccountIndex support for BigInt

* Fix ApiPromise signAsync
This commit is contained in:
Jaco Greeff
2020-02-21 17:26:05 +01:00
committed by GitHub
parent 429b797b23
commit 4540495a44
34 changed files with 401 additions and 434 deletions
+15 -3
View File
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { AccountId, Header } from '@polkadot/types/interfaces';
import { AnyJsonObject, Constructor, Registry } from '@polkadot/types/types';
import { AnyJson, Constructor, Registry } from '@polkadot/types/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
import { Struct } from '@polkadot/types';
@@ -54,12 +54,24 @@ export default class HeaderExtended extends _Header {
return this._author;
}
/**
* @description Creates a human-friendly JSON representation
*/
public toHuman (isExtended?: boolean): AnyJson {
return {
...super.toHuman(isExtended) as { [index: string]: AnyJson },
author: this.author
? this.author.toHuman()
: undefined
};
}
/**
* @description Creates the JSON representation
*/
public toJSON (): AnyJsonObject {
public toJSON (): AnyJson {
return {
...super.toJSON() as AnyJsonObject,
...super.toJSON() as { [index: string]: AnyJson },
author: this.author
? this.author.toJSON()
: undefined
@@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { AnyJsonObject, Constructor, Registry } from '@polkadot/types/types';
import { AnyJson, Constructor, Registry } from '@polkadot/types/types';
import BN from 'bn.js';
import democracyTypes from '@polkadot/types/interfaces/democracy/definitions';
@@ -35,12 +35,22 @@ export default class ReferendumInfoExtended extends _ReferendumInfo {
return this._index;
}
/**
* @description Creates a human-friendly JSON representation
*/
public toHuman (isExtended?: boolean): AnyJson {
return {
...super.toHuman(isExtended) as { [index: string]: AnyJson },
index: this.index.toHuman(isExtended)
};
}
/**
* @description Creates the JSON representation
*/
public toJSON (): AnyJsonObject {
public toJSON (): AnyJson {
return {
...super.toJSON() as AnyJsonObject,
...super.toJSON() as { [index: string]: AnyJson },
index: this.index.toJSON()
};
}