Additional export cleanups (root & types) (#694)
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { KeyringPair } from '@polkadot/keyring/types';
|
||||
import { AnyNumber, AnyU8a, Codec } from './types';
|
||||
import { AnyNumber, AnyU8a, Codec, SignatureOptions } from './types';
|
||||
|
||||
import { isHex, isU8a, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
@@ -11,7 +11,7 @@ import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import Compact from './codec/Compact';
|
||||
import Struct from './codec/Struct';
|
||||
import Address from './Address';
|
||||
import ExtrinsicSignature, { SignatureOptions } from './ExtrinsicSignature';
|
||||
import ExtrinsicSignature from './ExtrinsicSignature';
|
||||
import Hash from './Hash';
|
||||
import { FunctionMetadata } from './Metadata/v0/Modules';
|
||||
import Method from './Method';
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { KeyringPair } from '@polkadot/keyring/types';
|
||||
import { AnyNumber, AnyU8a } from './types';
|
||||
import { AnyNumber, SignatureOptions } from './types';
|
||||
|
||||
import Struct from './codec/Struct';
|
||||
import Address from './Address';
|
||||
@@ -15,13 +15,6 @@ import Signature from './Signature';
|
||||
import SignaturePayload from './SignaturePayload';
|
||||
import U8 from './U8';
|
||||
|
||||
export type SignatureOptions = {
|
||||
blockHash: AnyU8a,
|
||||
era?: Uint8Array,
|
||||
nonce: AnyNumber,
|
||||
version?: RuntimeVersion
|
||||
};
|
||||
|
||||
export const IMMORTAL_ERA = new Uint8Array([0]);
|
||||
|
||||
const BIT_SIGNED = 0b10000000;
|
||||
@@ -155,7 +148,7 @@ export default class ExtrinsicSignature extends Struct {
|
||||
era: era || IMMORTAL_ERA,
|
||||
blockHash
|
||||
});
|
||||
const signature = new Signature(signingPayload.sign(account, version));
|
||||
const signature = new Signature(signingPayload.sign(account, version as RuntimeVersion));
|
||||
|
||||
return this.injectSignature(signature, signer, signingPayload.nonce, signingPayload.era);
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ export type HeaderValue = {
|
||||
* A [[Block]] header
|
||||
*/
|
||||
export default class Header extends Struct {
|
||||
constructor (value?: HeaderValue | Uint8Array) {
|
||||
constructor (value?: HeaderValue | Uint8Array | null) {
|
||||
super({
|
||||
parentHash: Hash,
|
||||
number: Compact.with(BlockNumber),
|
||||
stateRoot: Hash,
|
||||
extrinsicsRoot: Hash,
|
||||
digest: Digest
|
||||
}, value);
|
||||
}, value || {});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,11 +91,10 @@ export default class Header extends Struct {
|
||||
export class HeaderExtended extends Header {
|
||||
private _author?: AccountId;
|
||||
|
||||
constructor (header: Header, sessionValidators: Array<AccountId> = []) {
|
||||
constructor (header: Header | null = null, sessionValidators: Array<AccountId> = []) {
|
||||
super(header);
|
||||
|
||||
const { digest: { logs } } = header;
|
||||
const digestItem = logs.find(({ type }) => type === 'Seal');
|
||||
const digestItem = header && header.digest && header.digest.logs.find(({ type }) => type === 'Seal');
|
||||
|
||||
this._author = digestItem && sessionValidators.length
|
||||
? sessionValidators[digestItem.asSeal.slot.toNumber() % sessionValidators.length]
|
||||
|
||||
@@ -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 { AnyNumber, AnyU8a } from './types';
|
||||
import { AnyNumber, AnyU8a, RuntimeVersionInterface } from './types';
|
||||
|
||||
import Struct from './codec/Struct';
|
||||
import Tuple from './codec/Tuple';
|
||||
@@ -69,7 +69,7 @@ type RuntimeVersionValue = {
|
||||
* @description
|
||||
* A defintion of the runtime and the associated versions thereof
|
||||
*/
|
||||
export default class RuntimeVersion extends Struct {
|
||||
export default class RuntimeVersion extends Struct implements RuntimeVersionInterface {
|
||||
constructor (value?: RuntimeVersionValue | Uint8Array) {
|
||||
super({
|
||||
specName: Text,
|
||||
|
||||
@@ -24,7 +24,7 @@ export { default as Bytes } from './Bytes';
|
||||
export { default as ChainProperties } from './ChainProperties';
|
||||
export { default as CodeHash } from './CodeHash';
|
||||
export { default as Data } from './Data';
|
||||
export { default as Digest } from './Digest';
|
||||
export { default as Digest, DigestItem } from './Digest';
|
||||
export { default as Event } from './Event';
|
||||
export { default as EventRecord } from './EventRecord';
|
||||
export { default as Extrinsic } from './Extrinsic';
|
||||
@@ -37,7 +37,7 @@ export { default as Gas } from './Gas';
|
||||
export { default as H256 } from './H256';
|
||||
export { default as H512 } from './H512';
|
||||
export { default as Hash } from './Hash';
|
||||
export { default as Header } from './Header';
|
||||
export { default as Header, HeaderExtended } from './Header';
|
||||
export { default as Health } from './Health';
|
||||
export { default as i8 } from './I8';
|
||||
export { default as i16 } from './I16';
|
||||
|
||||
@@ -71,3 +71,19 @@ export type TypeDef = { [index: string]: Codec };
|
||||
export type RegistryTypes = {
|
||||
[name: string]: Constructor | string | { [name: string]: string }
|
||||
};
|
||||
|
||||
export interface RuntimeVersionInterface {
|
||||
readonly apis: Array<any>;
|
||||
readonly authoringVersion: BN;
|
||||
readonly implName: String;
|
||||
readonly implVersion: BN;
|
||||
readonly specName: String;
|
||||
readonly specVersion: BN;
|
||||
}
|
||||
|
||||
export type SignatureOptions = {
|
||||
blockHash: AnyU8a,
|
||||
era?: Uint8Array,
|
||||
nonce: AnyNumber,
|
||||
version?: RuntimeVersionInterface
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user