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
+2 -2
View File
@@ -32,8 +32,8 @@
"@babel/core": "^7.5.5",
"@babel/register": "^7.5.5",
"@babel/runtime": "^7.5.5",
"@polkadot/dev": "^0.31.0-beta.2",
"@polkadot/dev": "^0.31.0-beta.3",
"@polkadot/ts": "^0.1.64",
"gh-pages": "2.0.1"
"gh-pages": "^2.1.1"
}
}
@@ -8,7 +8,7 @@ import { AnyJsonObject, Constructor } from '@polkadot/types/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
import { Struct } from '@polkadot/types';
// @ts-ignore
// @ts-ignore We can ignore the properties, added via Struct.with
const _Header: Constructor<Header> = Struct.with(runtimeTypes.types.Header);
/**
@@ -9,7 +9,7 @@ import BN from 'bn.js';
import democracyTypes from '@polkadot/types/interfaces/democracy/definitions';
import { Struct, createType } from '@polkadot/types';
// @ts-ignore
// @ts-ignore We can ignore the properties, added via Struct.with
const _ReferendumInfo: Constructor<ReferendumInfo> = Struct.with(democracyTypes.types.ReferendumInfo);
/**
+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)
*/
+8 -8
View File
@@ -1795,10 +1795,10 @@
universal-user-agent "^3.0.0"
url-template "^2.0.8"
"@polkadot/dev@^0.31.0-beta.2":
version "0.31.0-beta.2"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.31.0-beta.2.tgz#28d1e10cc40267db2dc7854916feeb0613c22609"
integrity sha512-jtexumNVyfcbIPCbuwYF77DE54it/CeKdg9HClyjig3Iw26Np0uHIrfDCxmINLwrckkuvka66hs64sj7u3QqXw==
"@polkadot/dev@^0.31.0-beta.3":
version "0.31.0-beta.3"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.31.0-beta.3.tgz#f9880e7c430e6a4df423211244a1dddb509c3eca"
integrity sha512-6VTgIR4EBvowVmaJorDmHbCctlUa+gTTL5etlU+T+yaVEA1vAS3gaSwlhgQY1baEjc9PNKHkfHun6MO/gqq+RA==
dependencies:
"@babel/cli" "^7.5.5"
"@babel/core" "^7.5.5"
@@ -6123,10 +6123,10 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"
gh-pages@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-2.0.1.tgz#aefe47a43b8d9d2aa3130576b33fe95641e29a2f"
integrity sha512-uFlk3bukljeiWKQ2XvPfjcSi/ou7IfoDf2p+Fj672saLAr8bnOdFVqI/JSgrSgInKpCg5BksxEwGUl++dbg8Dg==
gh-pages@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/gh-pages/-/gh-pages-2.1.1.tgz#5be70a92f9cb70404bafabd8bb149c0e9a8c264b"
integrity sha512-yNW2SFp9xGRP/8Sk2WXuLI/Gn92oOL4HBgudn6PsqAnuWT90Y1tozJoTfX1WdrDSW5Rb90kLVOf5mm9KJ/2fDw==
dependencies:
async "^2.6.1"
commander "^2.18.0"