Add types for Polkadot claims module (#1277)

* Add types for Polkadot claims module

* ' instead of `

* Adjust types, `[u8; x]` workarounds

* One less import

* Map [u8; x] -> Uint8Array

* Fix Codec imports
This commit is contained in:
Jaco Greeff
2019-08-07 18:08:38 +02:00
committed by GitHub
parent c7584a083d
commit 438c02def5
11 changed files with 119 additions and 75 deletions
+64 -57
View File
@@ -16,10 +16,11 @@ import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from
import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from './interfaces/deprecated';
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from './interfaces/genericAsset';
import { Heartbeat, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from './interfaces/imOnline';
import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParachainDispatchOrigin, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from './interfaces/parachains';
import { EraIndex, EraRewards, Exposure, IndividualExposure, MomentOf, RewardDestination, StakingLedger, UnlockChunk, ValidatorPrefs } from './interfaces/staking';
import { DigestOf, Event, EventId, EventIndex, EventRecord, EventRecord0to76, Key, Phase } from './interfaces/system';
import { TreasuryProposal } from './interfaces/treasury';
import { EcdsaSignature, EthereumAddress } from './interfaces/claims';
import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParachainDispatchOrigin, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from './interfaces/parachains';
import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc';
export interface InterfaceRegistry {
@@ -435,6 +436,68 @@ export interface InterfaceRegistry {
Heartbeat: Heartbeat;
'Option<Heartbeat>': Option<Heartbeat>;
'Vec<Heartbeat>': Vec<Heartbeat>;
EraIndex: EraIndex;
'Compact<EraIndex>': Compact<EraIndex>;
'Option<EraIndex>': Option<EraIndex>;
'Vec<EraIndex>': Vec<EraIndex>;
EraRewards: EraRewards;
'Option<EraRewards>': Option<EraRewards>;
'Vec<EraRewards>': Vec<EraRewards>;
IndividualExposure: IndividualExposure;
'Option<IndividualExposure>': Option<IndividualExposure>;
'Vec<IndividualExposure>': Vec<IndividualExposure>;
Exposure: Exposure;
'Option<Exposure>': Option<Exposure>;
'Vec<Exposure>': Vec<Exposure>;
MomentOf: MomentOf;
'Option<MomentOf>': Option<MomentOf>;
'Vec<MomentOf>': Vec<MomentOf>;
RewardDestination: RewardDestination;
'Option<RewardDestination>': Option<RewardDestination>;
'Vec<RewardDestination>': Vec<RewardDestination>;
UnlockChunk: UnlockChunk;
'Option<UnlockChunk>': Option<UnlockChunk>;
'Vec<UnlockChunk>': Vec<UnlockChunk>;
StakingLedger: StakingLedger;
'Option<StakingLedger>': Option<StakingLedger>;
'Vec<StakingLedger>': Vec<StakingLedger>;
ValidatorPrefs: ValidatorPrefs;
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
DigestOf: DigestOf;
'Option<DigestOf>': Option<DigestOf>;
'Vec<DigestOf>': Vec<DigestOf>;
EventId: EventId;
'Option<EventId>': Option<EventId>;
'Vec<EventId>': Vec<EventId>;
EventIndex: EventIndex;
'Compact<EventIndex>': Compact<EventIndex>;
'Option<EventIndex>': Option<EventIndex>;
'Vec<EventIndex>': Vec<EventIndex>;
Key: Key;
'Option<Key>': Option<Key>;
'Vec<Key>': Vec<Key>;
Phase: Phase;
'Option<Phase>': Option<Phase>;
'Vec<Phase>': Vec<Phase>;
Event: Event;
'Option<Event>': Option<Event>;
'Vec<Event>': Vec<Event>;
EventRecord0to76: EventRecord0to76;
'Option<EventRecord0to76>': Option<EventRecord0to76>;
'Vec<EventRecord0to76>': Vec<EventRecord0to76>;
EventRecord: EventRecord;
'Option<EventRecord>': Option<EventRecord>;
'Vec<EventRecord>': Vec<EventRecord>;
TreasuryProposal: TreasuryProposal;
'Option<TreasuryProposal>': Option<TreasuryProposal>;
'Vec<TreasuryProposal>': Vec<TreasuryProposal>;
EcdsaSignature: EcdsaSignature;
'Option<EcdsaSignature>': Option<EcdsaSignature>;
'Vec<EcdsaSignature>': Vec<EcdsaSignature>;
EthereumAddress: EthereumAddress;
'Option<EthereumAddress>': Option<EthereumAddress>;
'Vec<EthereumAddress>': Vec<EthereumAddress>;
AuctionIndex: AuctionIndex;
'Compact<AuctionIndex>': Compact<AuctionIndex>;
'Option<AuctionIndex>': Option<AuctionIndex>;
@@ -514,62 +577,6 @@ export interface InterfaceRegistry {
WinningData: WinningData;
'Option<WinningData>': Option<WinningData>;
'Vec<WinningData>': Vec<WinningData>;
EraIndex: EraIndex;
'Compact<EraIndex>': Compact<EraIndex>;
'Option<EraIndex>': Option<EraIndex>;
'Vec<EraIndex>': Vec<EraIndex>;
EraRewards: EraRewards;
'Option<EraRewards>': Option<EraRewards>;
'Vec<EraRewards>': Vec<EraRewards>;
IndividualExposure: IndividualExposure;
'Option<IndividualExposure>': Option<IndividualExposure>;
'Vec<IndividualExposure>': Vec<IndividualExposure>;
Exposure: Exposure;
'Option<Exposure>': Option<Exposure>;
'Vec<Exposure>': Vec<Exposure>;
MomentOf: MomentOf;
'Option<MomentOf>': Option<MomentOf>;
'Vec<MomentOf>': Vec<MomentOf>;
RewardDestination: RewardDestination;
'Option<RewardDestination>': Option<RewardDestination>;
'Vec<RewardDestination>': Vec<RewardDestination>;
UnlockChunk: UnlockChunk;
'Option<UnlockChunk>': Option<UnlockChunk>;
'Vec<UnlockChunk>': Vec<UnlockChunk>;
StakingLedger: StakingLedger;
'Option<StakingLedger>': Option<StakingLedger>;
'Vec<StakingLedger>': Vec<StakingLedger>;
ValidatorPrefs: ValidatorPrefs;
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
DigestOf: DigestOf;
'Option<DigestOf>': Option<DigestOf>;
'Vec<DigestOf>': Vec<DigestOf>;
EventId: EventId;
'Option<EventId>': Option<EventId>;
'Vec<EventId>': Vec<EventId>;
EventIndex: EventIndex;
'Compact<EventIndex>': Compact<EventIndex>;
'Option<EventIndex>': Option<EventIndex>;
'Vec<EventIndex>': Vec<EventIndex>;
Key: Key;
'Option<Key>': Option<Key>;
'Vec<Key>': Vec<Key>;
Phase: Phase;
'Option<Phase>': Option<Phase>;
'Vec<Phase>': Vec<Phase>;
Event: Event;
'Option<Event>': Option<Event>;
'Vec<Event>': Vec<Event>;
EventRecord0to76: EventRecord0to76;
'Option<EventRecord0to76>': Option<EventRecord0to76>;
'Vec<EventRecord0to76>': Vec<EventRecord0to76>;
EventRecord: EventRecord;
'Option<EventRecord>': Option<EventRecord>;
'Vec<EventRecord>': Vec<EventRecord>;
TreasuryProposal: TreasuryProposal;
'Option<TreasuryProposal>': Option<TreasuryProposal>;
'Vec<TreasuryProposal>': Vec<TreasuryProposal>;
ApiId: ApiId;
'Option<ApiId>': Option<ApiId>;
'Vec<ApiId>': Vec<ApiId>;
@@ -0,0 +1,10 @@
// Copyright 2017-2019 @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.
export default {
types: {
EcdsaSignature: '[u8; 65]',
EthereumAddress: 'H160'
}
};
@@ -0,0 +1,3 @@
// Auto-generated via `yarn build:interfaces`, do not edit
export * from './types';
@@ -0,0 +1,10 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Codec } from '../../types';
import { H160 } from '../../primitive';
/** Uint8Array & Codec */
export type EcdsaSignature = Uint8Array & Codec;
/** H160 */
export type EthereumAddress = H160;
@@ -1,7 +1,8 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Compact, Enum, Option, Struct, Vec } from '../../codec';
import { Bytes, Null, bool, u32, u64, u8 } from '../../primitive';
import { Codec } from '../../types';
import { Compact, Enum, Option, Struct } from '../../codec';
import { Bytes, Null, bool, u32, u64 } from '../../primitive';
import { Balance, BlockNumber, Hash } from '../runtime';
/** Struct */
@@ -35,8 +36,8 @@ export interface ContractInfo extends Enum {
readonly asTombstone: TombstoneContractInfo;
}
/** Vec<u8> */
export type ContractStorageKey = Vec<u8>;
/** Uint8Array & Codec */
export type ContractStorageKey = Uint8Array & Codec;
/** u64 */
export type Gas = u64;
+4 -1
View File
@@ -31,10 +31,13 @@ export { default as democracy } from './democracy/definitions';
export { default as deprecated } from './deprecated/definitions';
export { default as genericAsset } from './genericAsset/definitions';
export { default as imOnline } from './imOnline/definitions';
export { default as parachains } from './parachains/definitions';
export { default as staking } from './staking/definitions';
export { default as system } from './system/definitions';
export { default as treasury } from './treasury/definitions';
// polkadot-specific types
export { default as claims } from './claims/definitions';
export { default as parachains } from './parachains/definitions';
// pull in rpc last, assuming that is uses info from above
export { default as rpc } from './rpc/definitions';
+3 -3
View File
@@ -2,11 +2,11 @@
import { Codec } from '../../types';
import { Enum, Option, Struct, Vec } from '../../codec';
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive';
import { Bytes, StorageData, StorageKey, Text, bool, u32, u64 } from '../../primitive';
import { BlockNumber, Hash } from '../runtime';
/** Vec<u8> */
export type ApiId = Vec<u8>;
/** Uint8Array & Codec */
export type ApiId = Uint8Array & Codec;
/** Struct */
export interface ChainProperties extends Struct {
@@ -1,8 +1,8 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Codec } from '../../types';
import { Compact, Struct, Vec } from '../../codec';
import { Bytes, Fixed64, GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId, GenericDigest, GenericDigestItem, GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericImmortalEra, GenericMortalEra, GenericOrigin, H256, H512, Null, StorageData, StorageKey, u128, u32, u64, u8 } from '../../primitive';
import { Compact, Struct } from '../../codec';
import { Bytes, Fixed64, GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId, GenericDigest, GenericDigestItem, GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericImmortalEra, GenericMortalEra, GenericOrigin, H256, H512, Null, StorageData, StorageKey, u128, u32, u64 } from '../../primitive';
/** GenericAccountId */
export type AccountId = GenericAccountId;
@@ -90,8 +90,8 @@ export type KeyTypeId = u32;
/** [StorageKey, StorageData] & Codec */
export type KeyValue = [StorageKey, StorageData] & Codec;
/** Vec<u8> */
export type LockIdentifier = Vec<u8>;
/** Uint8Array & Codec */
export type LockIdentifier = Uint8Array & Codec;
/** u64 */
export type Moment = u64;
@@ -1,7 +1,8 @@
// Auto-generated via `yarn build:interfaces`, do not edit
import { Codec } from '../../types';
import { Enum, Struct, Vec } from '../../codec';
import { Bytes, GenericEvent, u32, u8 } from '../../primitive';
import { Bytes, GenericEvent, u32 } from '../../primitive';
import { Digest, Hash } from '../runtime';
/** Digest */
@@ -10,8 +11,8 @@ export type DigestOf = Digest;
/** GenericEvent */
export type Event = GenericEvent;
/** Vec<u8> */
export type EventId = Vec<u8>;
/** Uint8Array & Codec */
export type EventId = Uint8Array & Codec;
/** u32 */
export type EventIndex = u32;
+2 -1
View File
@@ -14,8 +14,9 @@ export * from './democracy/types';
export * from './deprecated/types';
export * from './genericAsset/types';
export * from './imOnline/types';
export * from './parachains/types';
export * from './staking/types';
export * from './system/types';
export * from './treasury/types';
export * from './claims/types';
export * from './parachains/types';
export * from './rpc/types';
+10 -2
View File
@@ -229,7 +229,7 @@ function _tsTupleGetterType (tupleName: string | undefined, { info, sub, type }:
}
function tsTuple ({ name: tupleName, sub }: TypeDef, imports: TypeImports): string {
setImports(imports, ['Tuple']);
setImports(imports, ['Codec', 'Tuple']);
const types = (sub as TypeDef[]).map((typedef): string =>
_tsTupleGetterType(tupleName, typedef, imports)
@@ -243,6 +243,14 @@ function tsVec ({ ext, info, name: vectorName, sub }: TypeDef, imports: TypeImpo
? (ext as TypeDefExtVecFixed).type
: (sub as TypeDef).type;
// FIXME This should be a VecFixed
// FIXME Technically Vec has length prefix, so for others this is not 100%
if (info === TypeDefInfo.VecFixed && type === 'u8') {
setImports(imports, ['Codec']);
return exportType(vectorName, 'Uint8Array & Codec');
}
setImports(imports, ['Vec', type]);
return exportType(vectorName, `Vec<${type}>`);
@@ -331,7 +339,7 @@ function generateTsDef (defName: string, { types }: { types: Record<string, any>
const header = createImportCode(HEADER, [
{
file: '../../types',
types: imports.codecTypes['Tuple'] ? ['Codec'] : []
types: Object.keys(imports.typesTypes)
},
{
file: '../../codec',