Add missing Polkadot (parachains module) types (#491)
* Add ParaId (u32, originally ParachainId) * Add AttestedCandidate (setHeads) * Bump dependencies * Cater for latest.substrate.json rename * Update version deps
This commit is contained in:
@@ -33,6 +33,6 @@
|
||||
"@polkadot/jsonrpc": "^0.34.2",
|
||||
"@polkadot/rpc-provider": "^0.34.2",
|
||||
"@polkadot/types": "^0.34.2",
|
||||
"@polkadot/util": "^0.33.18"
|
||||
"@polkadot/util": "^0.33.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/keyring": "^0.33.18",
|
||||
"@polkadot/keyring": "^0.33.19",
|
||||
"@polkadot/storage": "^0.34.2",
|
||||
"@polkadot/util": "^0.33.18",
|
||||
"@polkadot/util-crypto": "^0.33.18",
|
||||
"@polkadot/util": "^0.33.19",
|
||||
"@polkadot/util-crypto": "^0.33.19",
|
||||
"@types/nock": "^9.3.0",
|
||||
"eventemitter3": "^3.1.0",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
|
||||
@@ -12,6 +12,6 @@
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/types": "^0.34.2",
|
||||
"@polkadot/util": "^0.33.18"
|
||||
"@polkadot/util": "^0.33.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/keyring": "^0.33.18",
|
||||
"@polkadot/keyring": "^0.33.19",
|
||||
"@polkadot/types": "^0.34.2",
|
||||
"@polkadot/util": "^0.33.18",
|
||||
"@polkadot/util-crypto": "^0.33.18"
|
||||
"@polkadot/util": "^0.33.19",
|
||||
"@polkadot/util-crypto": "^0.33.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.2.0",
|
||||
"@polkadot/keyring": "^0.33.18",
|
||||
"@polkadot/util": "^0.33.18"
|
||||
"@polkadot/keyring": "^0.33.19",
|
||||
"@polkadot/util": "^0.33.19"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright 2017-2018 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import EnumType from './codec/EnumType';
|
||||
import Struct from './codec/Struct';
|
||||
import Tuple from './codec/Tuple';
|
||||
import Vector from './codec/Vector';
|
||||
import AccountId from './AccountId';
|
||||
import Bytes from './Bytes';
|
||||
import Hash from './Hash';
|
||||
import Null from './Null';
|
||||
import ParaId from './ParaId';
|
||||
import Signature from './Signature';
|
||||
import SessionKey from './SessionKey';
|
||||
import U64 from './U64';
|
||||
|
||||
export class CandidateSignature extends Signature {
|
||||
}
|
||||
|
||||
export class BalanceUpload extends Tuple.with([AccountId, U64]) {
|
||||
}
|
||||
|
||||
export class EgressQueueRoot extends Tuple.with([ParaId, Hash]) {
|
||||
}
|
||||
|
||||
export class HeadData extends Bytes {
|
||||
}
|
||||
|
||||
export class CandidateReceipt extends Struct {
|
||||
constructor (value?: any) {
|
||||
super({
|
||||
parachainIndex: ParaId,
|
||||
collator: AccountId,
|
||||
signature: CandidateSignature,
|
||||
headData: HeadData,
|
||||
balanceUploads: Vector.with(BalanceUpload),
|
||||
egressQueueRoots: Vector.with(EgressQueueRoot),
|
||||
fees: U64,
|
||||
blockDataHash: Hash
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
|
||||
export class AvailabilityVote extends Tuple.with([SessionKey, CandidateSignature]) {
|
||||
}
|
||||
|
||||
export class ExplicitCandidateSignature extends CandidateSignature {
|
||||
}
|
||||
|
||||
export class ImplicitCandidateSignature extends CandidateSignature {
|
||||
}
|
||||
|
||||
export class ValidityAttestation extends EnumType<Null | ImplicitCandidateSignature | ExplicitCandidateSignature> {
|
||||
constructor (value?: any) {
|
||||
super({
|
||||
// This Null is not in the original, however indexes start at 1, so add a
|
||||
// placeholder in the first position (which is basically non-valid)
|
||||
Null,
|
||||
ImplicitCandidateSignature, // 1
|
||||
ExplicitCandidateSignature // 2
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
|
||||
export class ValidityVote extends Tuple.with([SessionKey, ValidityAttestation]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @name AttestedCandidate
|
||||
* @description
|
||||
* An attested candidate
|
||||
*/
|
||||
export default class AttestedCandidate extends Struct {
|
||||
constructor (value?: any) {
|
||||
super({
|
||||
candidate: CandidateReceipt,
|
||||
validityVotes: Vector.with(ValidityVote),
|
||||
availabilityVotes: Vector.with(AvailabilityVote)
|
||||
}, value);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import bbqBirch from '../json/Metadata.bbq.json';
|
||||
import compacted from '../json/Metadata.latest.json';
|
||||
import Metadata from './index';
|
||||
import rpcdata from './static';
|
||||
import latestParsed from './latest.json';
|
||||
import latestParsed from './latest.substrate.json';
|
||||
|
||||
describe('Metadata', () => {
|
||||
it('decodes properly', () => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import U64 from './U64';
|
||||
import U32 from './U32';
|
||||
|
||||
/**
|
||||
* @name ParachainId
|
||||
* @name ParaId
|
||||
* @description
|
||||
* Identifier for a deployed parachain implemented as a [[U64]]
|
||||
* Identifier for a deployed parachain implemented as a [[U32]]
|
||||
*/
|
||||
export default class ParachainId extends U64 {
|
||||
export default class ParaId extends U32 {
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
export { default as AccountId } from './AccountId';
|
||||
export { default as AccountIndex } from './AccountIndex';
|
||||
export { default as Address } from './Address';
|
||||
export { default as AttestedCandidate } from './AttestedCandidate';
|
||||
export { default as AuthorityId } from './AuthorityId';
|
||||
export { default as Balance } from './Balance';
|
||||
// NOTE Bft items are only used in internal structures
|
||||
@@ -54,7 +55,7 @@ export { default as Null } from './Null';
|
||||
export { default as Index } from './Nonce';
|
||||
export { default as Justification } from './Justification';
|
||||
export { default as Origin } from './Origin';
|
||||
export { default as ParachainId } from './ParachainId';
|
||||
export { default as ParaId } from './ParaId';
|
||||
export { default as PendingExtrinsics } from './PendingExtrinsics';
|
||||
export { default as Permill } from './Permill';
|
||||
export { default as Perbill } from './Perbill';
|
||||
|
||||
@@ -1369,14 +1369,14 @@
|
||||
typedoc-plugin-no-inherit "^1.0.2"
|
||||
typescript "^3.2.2"
|
||||
|
||||
"@polkadot/keyring@^0.33.18":
|
||||
version "0.33.18"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.18.tgz#8fd0a4b6fc23d568ec5799ab333993aa4acf38ce"
|
||||
integrity sha512-p4LtenOPSH3CuwgKuu6pql4b+WiRSDXaYg0Y9+PznQtAlRwGFqGm7KSyVs0ak7EBNBq6DvRLp3E1AEcDpc3dWg==
|
||||
"@polkadot/keyring@^0.33.19":
|
||||
version "0.33.19"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.33.19.tgz#4e69ec8516c47a4bde44fa5d33c13bbfe1e13764"
|
||||
integrity sha512-r3ESIlvPMthQSq4BdWltNND921fBB47CfypE2ZEJRTIo8F2quXX/Rl2hxk32eEpJsE08f17UDAH/8X0sKtxJYQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.2.0"
|
||||
"@polkadot/util" "^0.33.18"
|
||||
"@polkadot/util-crypto" "^0.33.18"
|
||||
"@polkadot/util" "^0.33.19"
|
||||
"@polkadot/util-crypto" "^0.33.19"
|
||||
"@types/bs58" "^3.0.30"
|
||||
bs58 "^4.0.1"
|
||||
|
||||
@@ -1385,13 +1385,13 @@
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.43.tgz#e59d86cf6bed833010315c5b301bfea6c05fd4a8"
|
||||
integrity sha512-B7mSH+yrc7PBHMWUfpTFAK0OLgOesWlzkhse0/O8Itu2Rf6YrixEnhUYKEDp7mDO3h2SlBwn6BfVkvY4qvtwgg==
|
||||
|
||||
"@polkadot/util-crypto@^0.33.18":
|
||||
version "0.33.18"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.18.tgz#7fb937794c4130b67a847784578a5def1fce61c2"
|
||||
integrity sha512-gr/xi3Jl3rX0CXyzfFCIJ02r+s+tKxrP/CiZ80boHeSEvSH9LoFvkrVaHjBaejD3ouAVXLbr2uFq9SdLACY0gg==
|
||||
"@polkadot/util-crypto@^0.33.19":
|
||||
version "0.33.19"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.33.19.tgz#555e55f89fefd1c8cdd7ac4499cf6482b814170f"
|
||||
integrity sha512-uiplby89WoiLmPTyOF4z0AoF2nHvv1149PMx6NhjIY4cuZmZufjNLIpRvB+lOr6xOGPgjnpbZ09o+kg08ds2sA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.2.0"
|
||||
"@polkadot/util" "^0.33.18"
|
||||
"@polkadot/util" "^0.33.19"
|
||||
"@types/bip39" "^2.4.1"
|
||||
bip39 "^2.5.0"
|
||||
blakejs "^1.1.0"
|
||||
@@ -1399,10 +1399,10 @@
|
||||
tweetnacl "^1.0.0"
|
||||
xxhashjs "^0.2.2"
|
||||
|
||||
"@polkadot/util@^0.33.18":
|
||||
version "0.33.18"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.18.tgz#2d0fa95d72de462f389516b5b0c61824099bbff7"
|
||||
integrity sha512-bvC7/ucrY8Ws2ckRhU0cvI0TNylmcFEEaw97p96w/sHQcMuQH+yBu1VLyUnxIvyV1nX0lrmSqR+s4a9I6R1mMA==
|
||||
"@polkadot/util@^0.33.19":
|
||||
version "0.33.19"
|
||||
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.33.19.tgz#bdabc77b15252657751d78c970e850364d12fc2a"
|
||||
integrity sha512-FdkHpaul9jIOG7revj49wQuptaPtRFviRZ9KTR/MeldDJW/zcLaau9Qr/0Pz2cprGLg0fMJvsP02TaFxaxarnQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.2.0"
|
||||
"@types/bn.js" "^4.11.3"
|
||||
|
||||
Reference in New Issue
Block a user