Extend SignerPayload with constructor cast (#1302)

This commit is contained in:
Jaco Greeff
2019-08-13 14:10:08 +02:00
committed by GitHub
parent 094141e633
commit 9e61debf45
5 changed files with 19 additions and 14 deletions
+7 -2
View File
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { Address, Balance, BlockNumber, Call, ExtrinsicEra, Hash, Index } from '@polkadot/types/interfaces';
import { Constructor } from '@polkadot/types/types';
import { SignerPayload, SignerPayloadRaw } from './types';
import { createType, Compact, Struct, u8 } from '@polkadot/types';
@@ -19,7 +20,9 @@ export interface SignerPayloadType {
version: u8;
}
export default class Payload extends Struct.with({
// We explicitly cast the type here to get the actual TypeScript exports right
// @ts-ignore We can ignore the properties, added via Struct.with
const _Payload: Constructor<SignerPayloadType> = Struct.with({
address: 'Address',
blockHash: 'Hash',
blockNumber: 'BlockNumber',
@@ -29,7 +32,9 @@ export default class Payload extends Struct.with({
nonce: 'Compact<Index>',
tip: 'Compact<Balance>',
version: u8
}) {
});
export default class Payload extends _Payload {
/**
* @description Returns this as a SignerPayloadType. This works since the Struct.with injects all the getters automatically (just ensure the 2 definitiona are matching)
*/