* Fake Origin for compatibility * Add Gas * Add Moment * Cleanups * NewAccountOutcome * Permill & Perbill * PrendingExtrinsics -> PendingExtrinsics * Extrinsics & PendingExtrinsics * Alias String -> Text (as found in jsonrpc, expose it) * MetaDate -> Metadata (compat) * Add StorageData, StorageKey & ChangeSet * Cleanup comments * Comment update * Comment typo * Add ParachainId * Add Tuple type * Tuple tests * Clenaup Tuple generics * Expand comment * Expose keys/values on struct * Array-like at -> get * Cleanup & simplify EnumType * Use setValue internally to fromU8a * Add RuntimeVersion * Expose RuntimeVersion
92 lines
2.2 KiB
TypeScript
92 lines
2.2 KiB
TypeScript
// Copyright 2017-2018 @polkadot/api-codec authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the ISC license. See the LICENSE file for details.
|
|
|
|
import { AnyNumber, AnyU8a } from './types';
|
|
|
|
import Struct from './codec/Struct';
|
|
import Tuple from './codec/Tuple';
|
|
import Vector from './codec/Vector';
|
|
import AuthorityId from './AuthorityId';
|
|
import Hash from './Hash';
|
|
import Signature from './Signature';
|
|
import U32 from './U32';
|
|
|
|
export type BftAuthoritySignatureValue = {
|
|
authorityId?: AnyU8a,
|
|
signature?: AnyU8a
|
|
};
|
|
|
|
// Represents a Bft Hash and Signature pairing, typically used in reporting
|
|
// network behaviour.
|
|
export class BftAuthoritySignature extends Tuple {
|
|
constructor (value?: BftAuthoritySignatureValue) {
|
|
super({
|
|
authorityId: AuthorityId,
|
|
signature: Signature
|
|
}, value);
|
|
}
|
|
|
|
get authorityId (): AuthorityId {
|
|
return this.raw.authorityId as AuthorityId;
|
|
}
|
|
|
|
get signature (): Signature {
|
|
return this.raw.signature as Signature;
|
|
}
|
|
}
|
|
|
|
export type BftHashSignatureValue = {
|
|
hash?: AnyU8a,
|
|
signature?: AnyU8a
|
|
};
|
|
|
|
// Represents a Bft Hash and Signature pairing, typically used in reporting
|
|
// network behaviour.
|
|
export class BftHashSignature extends Tuple {
|
|
constructor (value?: BftHashSignatureValue) {
|
|
super({
|
|
hash: Hash,
|
|
signature: Signature
|
|
}, value);
|
|
}
|
|
|
|
get hash (): Hash {
|
|
return this.raw.hash as Hash;
|
|
}
|
|
|
|
get signature (): Signature {
|
|
return this.raw.signature as Signature;
|
|
}
|
|
}
|
|
|
|
export type JustificationValue = {
|
|
round?: AnyNumber,
|
|
hash?: AnyU8a,
|
|
signatures?: Array<BftAuthoritySignatureValue>
|
|
};
|
|
|
|
export class Justification extends Struct {
|
|
constructor (value?: JustificationValue) {
|
|
super({
|
|
// FIXME Rust returns this as "round_number", we actually want a JSON alias
|
|
// in the structure to take care of these renames...
|
|
round: U32,
|
|
hash: Hash,
|
|
signatures: Vector.with(BftAuthoritySignature)
|
|
}, value, new Map([['round', 'round_number']]));
|
|
}
|
|
|
|
get hash (): Hash {
|
|
return this.raw.hash as Hash;
|
|
}
|
|
|
|
get round (): U32 {
|
|
return this.raw.round as U32;
|
|
}
|
|
|
|
get signatures (): Vector<BftAuthoritySignature> {
|
|
return this.raw.signatures as Vector<BftAuthoritySignature>;
|
|
}
|
|
}
|