From ec0b9a84a37fa89a4547a8f8ea12f308194988c4 Mon Sep 17 00:00:00 2001 From: Amaury Martiny Date: Fri, 26 Jul 2019 13:53:12 +0200 Subject: [PATCH] Put all mapping of InterfaceRegistry in one file (#1200) * Remove module augmentation * Put all definitions in one file * Add back compacts --- packages/types/src/interfaceRegistry.ts | 433 ++++++++++++++++++ .../types/src/interfaces/authorship/types.ts | 16 +- packages/types/src/interfaces/babe/types.ts | 10 - .../types/src/interfaces/balances/types.ts | 16 +- .../types/src/interfaces/collective/types.ts | 18 +- .../types/src/interfaces/consensus/types.ts | 9 - .../types/src/interfaces/contracts/types.ts | 39 -- .../types/src/interfaces/democracy/types.ts | 24 +- .../types/src/interfaces/deprecated/types.ts | 32 +- .../types/src/interfaces/elections/types.ts | 25 +- .../types/src/interfaces/grandpa/types.ts | 26 +- .../types/src/interfaces/imOnline/types.ts | 19 +- .../types/src/interfaces/parachains/types.ts | 86 +--- packages/types/src/interfaces/rpc/types.ts | 50 -- .../types/src/interfaces/runtime/types.ts | 77 +--- .../types/src/interfaces/session/types.ts | 13 - .../types/src/interfaces/staking/types.ts | 35 +- packages/types/src/interfaces/system/types.ts | 29 +- .../types/src/interfaces/treasury/types.ts | 10 +- packages/types/src/scripts/interfacesTs.ts | 40 +- 20 files changed, 469 insertions(+), 538 deletions(-) diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index 9d5239b78a..96a76d7009 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -2,6 +2,24 @@ import { Compact, Option, Vec } from './codec'; import { AccountId, AccountIndex, Address, Block, Bool, Bytes, ConsensusEngineId, Data, Digest, DigestItem, Event, Extrinsic, ExtrinsicEra, Fixed64, H160, H256, H512, Header, I128, I16, I256, I32, I64, I8, ImmortalEra, Method, Moment, MortalEra, Null, Origin, SignaturePayload, StorageHasher, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, Vote, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive'; +import { AccountIdOf, Balance, BalanceOf, BlockNumber, Ed25519Signature, Hash, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Perbill, Permill, Phantom, SessionKeys, Signature, Sr25519Signature, StorageData, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime'; +import { AuthorityId } from './interfaces/consensus'; +import { Keys, SessionIndex } from './interfaces/session'; +import { AuthorityWeight, NextAuthority, PendingPause, PendingResume, StoredPendingChange, StoredState } from './interfaces/grandpa'; +import { ApprovalFlag, SetIndex, VoteIndex, VoteThreshold, VoterInfo } from './interfaces/elections'; +import { InclusionHeight, Uncle, UncleEntryItem } from './interfaces/authorship'; +import { BabeWeight } from './interfaces/babe'; +import { BalanceLock, VestingSchedule, WithdrawReasons } from './interfaces/balances'; +import { MemberCount, ProposalIndex, Votes } from './interfaces/collective'; +import { AliveContractInfo, CodeHash, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, SeedOf, TombstoneContractInfo, TrieId } from './interfaces/contracts'; +import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from './interfaces/democracy'; +import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from './interfaces/deprecated'; +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, EventId, EventIndex, EventRecord, EventRecord0to76, Key, Phase } from './interfaces/system'; +import { TreasuryProposal } from './interfaces/treasury'; +import { ApiId, ChainProperties, Consensus, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, PreRuntime, RuntimeVersion, RuntimeVersionApi, Seal, SealV0, SignedBlock, StorageChangeSet } from './interfaces/rpc'; export interface InterfaceRegistry { AccountId: AccountId; @@ -187,4 +205,419 @@ export interface InterfaceRegistry { SignaturePayload: SignaturePayload; 'Option': Option; 'Vec': Vec; + AccountIdOf: AccountIdOf; + 'Option': Option; + 'Vec': Vec; + Balance: Balance; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + BalanceOf: BalanceOf; + 'Option': Option; + 'Vec': Vec; + BlockNumber: BlockNumber; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Hash: Hash; + 'Option': Option; + 'Vec': Vec; + Justification: Justification; + 'Option': Option; + 'Vec': Vec; + KeyTypeId: KeyTypeId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + LockIdentifier: LockIdentifier; + 'Option': Option; + 'Vec': Vec; + Index: Index; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Perbill: Perbill; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Permill: Permill; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Phantom: Phantom; + 'Option': Option; + 'Vec': Vec; + SessionKeys: SessionKeys; + 'Option': Option; + 'Vec': Vec; + Signature: Signature; + 'Option': Option; + 'Vec': Vec; + Ed25519Signature: Ed25519Signature; + 'Option': Option; + 'Vec': Vec; + Sr25519Signature: Sr25519Signature; + 'Option': Option; + 'Vec': Vec; + StorageData: StorageData; + 'Option': Option; + 'Vec': Vec; + KeyValue: KeyValue; + 'Option': Option; + 'Vec': Vec; + ValidatorId: ValidatorId; + 'Option': Option; + 'Vec': Vec; + Weight: Weight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + WeightMultiplier: WeightMultiplier; + 'Option': Option; + 'Vec': Vec; + AuthorityId: AuthorityId; + 'Option': Option; + 'Vec': Vec; + SessionIndex: SessionIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Keys: Keys; + 'Option': Option; + 'Vec': Vec; + AuthorityWeight: AuthorityWeight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + NextAuthority: NextAuthority; + 'Option': Option; + 'Vec': Vec; + PendingPause: PendingPause; + 'Option': Option; + 'Vec': Vec; + PendingResume: PendingResume; + 'Option': Option; + 'Vec': Vec; + StoredPendingChange: StoredPendingChange; + 'Option': Option; + 'Vec': Vec; + StoredState: StoredState; + 'Option': Option; + 'Vec': Vec; + ApprovalFlag: ApprovalFlag; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + SetIndex: SetIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + VoteIndex: VoteIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + VoterInfo: VoterInfo; + 'Option': Option; + 'Vec': Vec; + VoteThreshold: VoteThreshold; + 'Option': Option; + 'Vec': Vec; + InclusionHeight: InclusionHeight; + 'Option': Option; + 'Vec': Vec; + Uncle: Uncle; + 'Option': Option; + 'Vec': Vec; + UncleEntryItem: UncleEntryItem; + 'Option': Option; + 'Vec': Vec; + BabeWeight: BabeWeight; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + VestingSchedule: VestingSchedule; + 'Option': Option; + 'Vec': Vec; + WithdrawReasons: WithdrawReasons; + 'Option': Option; + 'Vec': Vec; + BalanceLock: BalanceLock; + 'Option': Option; + 'Vec': Vec; + MemberCount: MemberCount; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + ProposalIndex: ProposalIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Votes: Votes; + 'Option': Option; + 'Vec': Vec; + CodeHash: CodeHash; + 'Option': Option; + 'Vec': Vec; + TrieId: TrieId; + 'Option': Option; + 'Vec': Vec; + AliveContractInfo: AliveContractInfo; + 'Option': Option; + 'Vec': Vec; + TombstoneContractInfo: TombstoneContractInfo; + 'Option': Option; + 'Vec': Vec; + ContractInfo: ContractInfo; + 'Option': Option; + 'Vec': Vec; + ContractStorageKey: ContractStorageKey; + 'Option': Option; + 'Vec': Vec; + Gas: Gas; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + PrefabWasmModuleReserved: PrefabWasmModuleReserved; + 'Option': Option; + 'Vec': Vec; + PrefabWasmModule: PrefabWasmModule; + 'Option': Option; + 'Vec': Vec; + Schedule: Schedule; + 'Option': Option; + 'Vec': Vec; + SeedOf: SeedOf; + 'Option': Option; + 'Vec': Vec; + Conviction: Conviction; + 'Option': Option; + 'Vec': Vec; + PropIndex: PropIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Proposal: Proposal; + 'Option': Option; + 'Vec': Vec; + ReferendumIndex: ReferendumIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + ReferendumInfo: ReferendumInfo; + 'Option': Option; + 'Vec': Vec; + NewAccountOutcome: NewAccountOutcome; + 'Option': Option; + 'Vec': Vec; + Amount: Amount; + 'Option': Option; + 'Vec': Vec; + AssetOf: AssetOf; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + AccountInfo: AccountInfo; + 'Option': Option; + 'Vec': Vec; + LockPeriods: LockPeriods; + 'Option': Option; + 'Vec': Vec; + InherentOfflineReport: InherentOfflineReport; + 'Option': Option; + 'Vec': Vec; + SessionKey: SessionKey; + 'Option': Option; + 'Vec': Vec; + OpaqueKey: OpaqueKey; + 'Option': Option; + 'Vec': Vec; + OpaqueMultiaddr: OpaqueMultiaddr; + 'Option': Option; + 'Vec': Vec; + OpaquePeerId: OpaquePeerId; + 'Option': Option; + 'Vec': Vec; + OpaqueNetworkState: OpaqueNetworkState; + 'Option': Option; + 'Vec': Vec; + Heartbeat: Heartbeat; + 'Option': Option; + 'Vec': Vec; + AuctionIndex: AuctionIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + CollatorSignature: CollatorSignature; + 'Option': Option; + 'Vec': Vec; + ValidityAttestation: ValidityAttestation; + 'Option': Option; + 'Vec': Vec; + ParaId: ParaId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + ParaIdOf: ParaIdOf; + 'Option': Option; + 'Vec': Vec; + ValidatorIndex: ValidatorIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + ValidityVote: ValidityVote; + 'Option': Option; + 'Vec': Vec; + BalanceUpload: BalanceUpload; + 'Option': Option; + 'Vec': Vec; + EgressQueueRoot: EgressQueueRoot; + 'Option': Option; + 'Vec': Vec; + HeadData: HeadData; + 'Option': Option; + 'Vec': Vec; + CandidateReceipt: CandidateReceipt; + 'Option': Option; + 'Vec': Vec; + AttestedCandidate: AttestedCandidate; + 'Option': Option; + 'Vec': Vec; + SubId: SubId; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + NewBidder: NewBidder; + 'Option': Option; + 'Vec': Vec; + Bidder: Bidder; + 'Option': Option; + 'Vec': Vec; + IncomingParachainDeploy: IncomingParachainDeploy; + 'Option': Option; + 'Vec': Vec; + IncomingParachainFixed: IncomingParachainFixed; + 'Option': Option; + 'Vec': Vec; + IncomingParachain: IncomingParachain; + 'Option': Option; + 'Vec': Vec; + LeasePeriod: LeasePeriod; + 'Option': Option; + 'Vec': Vec; + LeasePeriodOf: LeasePeriodOf; + 'Option': Option; + 'Vec': Vec; + ParachainDispatchOrigin: ParachainDispatchOrigin; + 'Option': Option; + 'Vec': Vec; + SlotRange: SlotRange; + 'Option': Option; + 'Vec': Vec; + UpwardMessage: UpwardMessage; + 'Option': Option; + 'Vec': Vec; + WinningDataEntry: WinningDataEntry; + 'Option': Option; + 'Vec': Vec; + WinningData: WinningData; + 'Option': Option; + 'Vec': Vec; + EraIndex: EraIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + EraRewards: EraRewards; + 'Option': Option; + 'Vec': Vec; + IndividualExposure: IndividualExposure; + 'Option': Option; + 'Vec': Vec; + Exposure: Exposure; + 'Option': Option; + 'Vec': Vec; + MomentOf: MomentOf; + 'Option': Option; + 'Vec': Vec; + RewardDestination: RewardDestination; + 'Option': Option; + 'Vec': Vec; + UnlockChunk: UnlockChunk; + 'Option': Option; + 'Vec': Vec; + StakingLedger: StakingLedger; + 'Option': Option; + 'Vec': Vec; + ValidatorPrefs: ValidatorPrefs; + 'Option': Option; + 'Vec': Vec; + DigestOf: DigestOf; + 'Option': Option; + 'Vec': Vec; + EventId: EventId; + 'Option': Option; + 'Vec': Vec; + EventIndex: EventIndex; + 'Compact': Compact; + 'Option': Option; + 'Vec': Vec; + Key: Key; + 'Option': Option; + 'Vec': Vec; + Phase: Phase; + 'Option': Option; + 'Vec': Vec; + EventRecord0to76: EventRecord0to76; + 'Option': Option; + 'Vec': Vec; + EventRecord: EventRecord; + 'Option': Option; + 'Vec': Vec; + TreasuryProposal: TreasuryProposal; + 'Option': Option; + 'Vec': Vec; + ApiId: ApiId; + 'Option': Option; + 'Vec': Vec; + ChainProperties: ChainProperties; + 'Option': Option; + 'Vec': Vec; + Consensus: Consensus; + 'Option': Option; + 'Vec': Vec; + ExtrinsicStatus: ExtrinsicStatus; + 'Option': Option; + 'Vec': Vec; + Health: Health; + 'Option': Option; + 'Vec': Vec; + KeyValueOption: KeyValueOption; + 'Option': Option; + 'Vec': Vec; + NetworkState: NetworkState; + 'Option': Option; + 'Vec': Vec; + PeerInfo: PeerInfo; + 'Option': Option; + 'Vec': Vec; + PreRuntime: PreRuntime; + 'Option': Option; + 'Vec': Vec; + RuntimeVersionApi: RuntimeVersionApi; + 'Option': Option; + 'Vec': Vec; + RuntimeVersion: RuntimeVersion; + 'Option': Option; + 'Vec': Vec; + SealV0: SealV0; + 'Option': Option; + 'Vec': Vec; + Seal: Seal; + 'Option': Option; + 'Vec': Vec; + SignedBlock: SignedBlock; + 'Option': Option; + 'Vec': Vec; + StorageChangeSet: StorageChangeSet; + 'Option': Option; + 'Vec': Vec; } diff --git a/packages/types/src/interfaces/authorship/types.ts b/packages/types/src/interfaces/authorship/types.ts index 2d6d6cf6f8..24ec601f08 100644 --- a/packages/types/src/interfaces/authorship/types.ts +++ b/packages/types/src/interfaces/authorship/types.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn build:interfaces`, do not edit import { Codec } from '../../types'; -import { Enum, Option, Vec } from '../../codec'; +import { Enum, Option } from '../../codec'; import { AccountId } from '../../primitive'; import { BlockNumber, Hash } from '../runtime'; @@ -22,17 +22,3 @@ export interface UncleEntryItem extends Enum { /** Uncle */ readonly asUncle: Uncle; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - InclusionHeight: InclusionHeight; - 'Option': Option; - 'Vec': Vec; - Uncle: Uncle; - 'Option': Option; - 'Vec': Vec; - UncleEntryItem: UncleEntryItem; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/babe/types.ts b/packages/types/src/interfaces/babe/types.ts index 898b96dc3b..5b3dba2995 100644 --- a/packages/types/src/interfaces/babe/types.ts +++ b/packages/types/src/interfaces/babe/types.ts @@ -1,16 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Option, Vec } from '../../codec'; import { u64 } from '../../primitive'; /** u64 */ export type BabeWeight = u64; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - BabeWeight: BabeWeight; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/balances/types.ts b/packages/types/src/interfaces/balances/types.ts index 6c55bac00d..12fe4d00b7 100644 --- a/packages/types/src/interfaces/balances/types.ts +++ b/packages/types/src/interfaces/balances/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Option, Set, Struct, Vec } from '../../codec'; +import { Set, Struct } from '../../codec'; import { Balance, BlockNumber, LockIdentifier } from '../runtime'; /** Struct */ @@ -34,17 +34,3 @@ export interface WithdrawReasons extends Set { /** boolean */ readonly isFee: boolean; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - VestingSchedule: VestingSchedule; - 'Option': Option; - 'Vec': Vec; - WithdrawReasons: WithdrawReasons; - 'Option': Option; - 'Vec': Vec; - BalanceLock: BalanceLock; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/collective/types.ts b/packages/types/src/interfaces/collective/types.ts index 11b2e8e107..7d439fa10b 100644 --- a/packages/types/src/interfaces/collective/types.ts +++ b/packages/types/src/interfaces/collective/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Option, Struct, Vec } from '../../codec'; +import { Struct, Vec } from '../../codec'; import { AccountId, u32, u64 } from '../../primitive'; /** u64 */ @@ -20,19 +20,3 @@ export interface Votes extends Struct { /** Vec */ readonly nays: Vec; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - MemberCount: MemberCount; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - ProposalIndex: ProposalIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Votes: Votes; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/consensus/types.ts b/packages/types/src/interfaces/consensus/types.ts index a25832bf63..89fc9d01cb 100644 --- a/packages/types/src/interfaces/consensus/types.ts +++ b/packages/types/src/interfaces/consensus/types.ts @@ -1,15 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Option, Vec } from '../../codec'; import { AccountId } from '../../primitive'; /** AccountId */ export type AuthorityId = AccountId; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - AuthorityId: AuthorityId; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/contracts/types.ts b/packages/types/src/interfaces/contracts/types.ts index d2d4dc11b5..7e212cbc76 100644 --- a/packages/types/src/interfaces/contracts/types.ts +++ b/packages/types/src/interfaces/contracts/types.ts @@ -100,42 +100,3 @@ export type TombstoneContractInfo = Hash; /** Bytes */ export type TrieId = Bytes; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - CodeHash: CodeHash; - 'Option': Option; - 'Vec': Vec; - TrieId: TrieId; - 'Option': Option; - 'Vec': Vec; - AliveContractInfo: AliveContractInfo; - 'Option': Option; - 'Vec': Vec; - TombstoneContractInfo: TombstoneContractInfo; - 'Option': Option; - 'Vec': Vec; - ContractInfo: ContractInfo; - 'Option': Option; - 'Vec': Vec; - ContractStorageKey: ContractStorageKey; - 'Option': Option; - 'Vec': Vec; - Gas: Gas; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - PrefabWasmModuleReserved: PrefabWasmModuleReserved; - 'Option': Option; - 'Vec': Vec; - PrefabWasmModule: PrefabWasmModule; - 'Option': Option; - 'Vec': Vec; - Schedule: Schedule; - 'Option': Option; - 'Vec': Vec; - SeedOf: SeedOf; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/democracy/types.ts b/packages/types/src/interfaces/democracy/types.ts index 51b4409580..00b6633569 100644 --- a/packages/types/src/interfaces/democracy/types.ts +++ b/packages/types/src/interfaces/democracy/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct } from '../../codec'; import { Method, u32 } from '../../primitive'; import { BlockNumber } from '../runtime'; import { VoteThreshold } from '../elections'; @@ -41,25 +41,3 @@ export interface ReferendumInfo extends Struct { /** BlockNumber */ readonly delay: BlockNumber; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - Conviction: Conviction; - 'Option': Option; - 'Vec': Vec; - PropIndex: PropIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Proposal: Proposal; - 'Option': Option; - 'Vec': Vec; - ReferendumIndex: ReferendumIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - ReferendumInfo: ReferendumInfo; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/deprecated/types.ts b/packages/types/src/interfaces/deprecated/types.ts index 33309504e9..9c263c0b94 100644 --- a/packages/types/src/interfaces/deprecated/types.ts +++ b/packages/types/src/interfaces/deprecated/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct } from '../../codec'; import { AccountId, Bytes, Null, i8, u32, u64 } from '../../primitive'; import { Balance } from '../runtime'; @@ -39,33 +39,3 @@ export type OpaqueKey = Bytes; /** AccountId */ export type SessionKey = AccountId; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - NewAccountOutcome: NewAccountOutcome; - 'Option': Option; - 'Vec': Vec; - Amount: Amount; - 'Option': Option; - 'Vec': Vec; - AssetOf: AssetOf; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - AccountInfo: AccountInfo; - 'Option': Option; - 'Vec': Vec; - LockPeriods: LockPeriods; - 'Option': Option; - 'Vec': Vec; - InherentOfflineReport: InherentOfflineReport; - 'Option': Option; - 'Vec': Vec; - SessionKey: SessionKey; - 'Option': Option; - 'Vec': Vec; - OpaqueKey: OpaqueKey; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/elections/types.ts b/packages/types/src/interfaces/elections/types.ts index 4839bf12d4..d69c6dd6f2 100644 --- a/packages/types/src/interfaces/elections/types.ts +++ b/packages/types/src/interfaces/elections/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct } from '../../codec'; import { u32 } from '../../primitive'; import { Balance } from '../runtime'; @@ -34,26 +34,3 @@ export interface VoteThreshold extends Enum { /** 2:: Simple majority */ readonly isSimpleMajority: boolean; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - ApprovalFlag: ApprovalFlag; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - SetIndex: SetIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - VoteIndex: VoteIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - VoterInfo: VoterInfo; - 'Option': Option; - 'Vec': Vec; - VoteThreshold: VoteThreshold; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/grandpa/types.ts b/packages/types/src/interfaces/grandpa/types.ts index 356a50626c..9f09fa9876 100644 --- a/packages/types/src/interfaces/grandpa/types.ts +++ b/packages/types/src/interfaces/grandpa/types.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn build:interfaces`, do not edit import { Codec } from '../../types'; -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct, Vec } from '../../codec'; import { u64 } from '../../primitive'; import { BlockNumber } from '../runtime'; import { AuthorityId } from '../consensus'; @@ -53,27 +53,3 @@ export interface StoredState extends Enum { /** PendingResume */ readonly asPendingResume: PendingResume; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - AuthorityWeight: AuthorityWeight; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - NextAuthority: NextAuthority; - 'Option': Option; - 'Vec': Vec; - PendingPause: PendingPause; - 'Option': Option; - 'Vec': Vec; - PendingResume: PendingResume; - 'Option': Option; - 'Vec': Vec; - StoredPendingChange: StoredPendingChange; - 'Option': Option; - 'Vec': Vec; - StoredState: StoredState; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/imOnline/types.ts b/packages/types/src/interfaces/imOnline/types.ts index b529fc4f32..7af86cd297 100644 --- a/packages/types/src/interfaces/imOnline/types.ts +++ b/packages/types/src/interfaces/imOnline/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Option, Struct, Vec } from '../../codec'; +import { Struct, Vec } from '../../codec'; import { Bytes } from '../../primitive'; import { BlockNumber } from '../runtime'; import { AuthorityId } from '../consensus'; @@ -31,20 +31,3 @@ export interface OpaqueNetworkState extends Struct { /** Bytes */ export type OpaquePeerId = Bytes; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - OpaqueMultiaddr: OpaqueMultiaddr; - 'Option': Option; - 'Vec': Vec; - OpaquePeerId: OpaquePeerId; - 'Option': Option; - 'Vec': Vec; - OpaqueNetworkState: OpaqueNetworkState; - 'Option': Option; - 'Vec': Vec; - Heartbeat: Heartbeat; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/parachains/types.ts b/packages/types/src/interfaces/parachains/types.ts index e7b31aaec0..f6030cf5bf 100644 --- a/packages/types/src/interfaces/parachains/types.ts +++ b/packages/types/src/interfaces/parachains/types.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn build:interfaces`, do not edit import { Codec } from '../../types'; -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct, Vec } from '../../codec'; import { AccountId, Bytes, u32, u64 } from '../../primitive'; import { BalanceOf, BlockNumber, Hash, Signature } from '../runtime'; @@ -180,87 +180,3 @@ export type WinningData = Vec; /** [AccountId, ParaIdOf, BalanceOf] & Codec */ export type WinningDataEntry = [AccountId, ParaIdOf, BalanceOf] & Codec; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - AuctionIndex: AuctionIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - CollatorSignature: CollatorSignature; - 'Option': Option; - 'Vec': Vec; - ValidityAttestation: ValidityAttestation; - 'Option': Option; - 'Vec': Vec; - ParaId: ParaId; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - ParaIdOf: ParaIdOf; - 'Option': Option; - 'Vec': Vec; - ValidatorIndex: ValidatorIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - ValidityVote: ValidityVote; - 'Option': Option; - 'Vec': Vec; - BalanceUpload: BalanceUpload; - 'Option': Option; - 'Vec': Vec; - EgressQueueRoot: EgressQueueRoot; - 'Option': Option; - 'Vec': Vec; - HeadData: HeadData; - 'Option': Option; - 'Vec': Vec; - CandidateReceipt: CandidateReceipt; - 'Option': Option; - 'Vec': Vec; - AttestedCandidate: AttestedCandidate; - 'Option': Option; - 'Vec': Vec; - SubId: SubId; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - NewBidder: NewBidder; - 'Option': Option; - 'Vec': Vec; - Bidder: Bidder; - 'Option': Option; - 'Vec': Vec; - IncomingParachainDeploy: IncomingParachainDeploy; - 'Option': Option; - 'Vec': Vec; - IncomingParachainFixed: IncomingParachainFixed; - 'Option': Option; - 'Vec': Vec; - IncomingParachain: IncomingParachain; - 'Option': Option; - 'Vec': Vec; - LeasePeriod: LeasePeriod; - 'Option': Option; - 'Vec': Vec; - LeasePeriodOf: LeasePeriodOf; - 'Option': Option; - 'Vec': Vec; - ParachainDispatchOrigin: ParachainDispatchOrigin; - 'Option': Option; - 'Vec': Vec; - SlotRange: SlotRange; - 'Option': Option; - 'Vec': Vec; - UpwardMessage: UpwardMessage; - 'Option': Option; - 'Vec': Vec; - WinningDataEntry: WinningDataEntry; - 'Option': Option; - 'Vec': Vec; - WinningData: WinningData; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/rpc/types.ts b/packages/types/src/interfaces/rpc/types.ts index 4fb739b3fa..189318dc5f 100644 --- a/packages/types/src/interfaces/rpc/types.ts +++ b/packages/types/src/interfaces/rpc/types.ts @@ -119,53 +119,3 @@ export interface StorageChangeSet extends Struct { /** Vec */ readonly changes: Vec; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - ApiId: ApiId; - 'Option': Option; - 'Vec': Vec; - ChainProperties: ChainProperties; - 'Option': Option; - 'Vec': Vec; - Consensus: Consensus; - 'Option': Option; - 'Vec': Vec; - ExtrinsicStatus: ExtrinsicStatus; - 'Option': Option; - 'Vec': Vec; - Health: Health; - 'Option': Option; - 'Vec': Vec; - KeyValueOption: KeyValueOption; - 'Option': Option; - 'Vec': Vec; - NetworkState: NetworkState; - 'Option': Option; - 'Vec': Vec; - PeerInfo: PeerInfo; - 'Option': Option; - 'Vec': Vec; - PreRuntime: PreRuntime; - 'Option': Option; - 'Vec': Vec; - RuntimeVersionApi: RuntimeVersionApi; - 'Option': Option; - 'Vec': Vec; - RuntimeVersion: RuntimeVersion; - 'Option': Option; - 'Vec': Vec; - SealV0: SealV0; - 'Option': Option; - 'Vec': Vec; - Seal: Seal; - 'Option': Option; - 'Vec': Vec; - SignedBlock: SignedBlock; - 'Option': Option; - 'Vec': Vec; - StorageChangeSet: StorageChangeSet; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index 29f74912ee..30a2e0cfb0 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -1,7 +1,7 @@ // Auto-generated via `yarn build:interfaces`, do not edit import { Codec } from '../../types'; -import { Compact, Option, Struct, Vec } from '../../codec'; +import { Struct, Vec } from '../../codec'; import { AccountId, Bytes, Fixed64, H256, H512, Null, StorageKey, u128, u32, u64, u8 } from '../../primitive'; /** AccountId */ @@ -69,78 +69,3 @@ export type Weight = u32; /** Fixed64 */ export type WeightMultiplier = Fixed64; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - AccountIdOf: AccountIdOf; - 'Option': Option; - 'Vec': Vec; - Balance: Balance; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - BalanceOf: BalanceOf; - 'Option': Option; - 'Vec': Vec; - BlockNumber: BlockNumber; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Hash: Hash; - 'Option': Option; - 'Vec': Vec; - Justification: Justification; - 'Option': Option; - 'Vec': Vec; - KeyTypeId: KeyTypeId; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - LockIdentifier: LockIdentifier; - 'Option': Option; - 'Vec': Vec; - Index: Index; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Perbill: Perbill; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Permill: Permill; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Phantom: Phantom; - 'Option': Option; - 'Vec': Vec; - SessionKeys: SessionKeys; - 'Option': Option; - 'Vec': Vec; - Signature: Signature; - 'Option': Option; - 'Vec': Vec; - Ed25519Signature: Ed25519Signature; - 'Option': Option; - 'Vec': Vec; - Sr25519Signature: Sr25519Signature; - 'Option': Option; - 'Vec': Vec; - StorageData: StorageData; - 'Option': Option; - 'Vec': Vec; - KeyValue: KeyValue; - 'Option': Option; - 'Vec': Vec; - ValidatorId: ValidatorId; - 'Option': Option; - 'Vec': Vec; - Weight: Weight; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - WeightMultiplier: WeightMultiplier; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/session/types.ts b/packages/types/src/interfaces/session/types.ts index 8b65ab42e7..bf3a17a031 100644 --- a/packages/types/src/interfaces/session/types.ts +++ b/packages/types/src/interfaces/session/types.ts @@ -1,6 +1,5 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Option, Vec } from '../../codec'; import { u32 } from '../../primitive'; import { SessionKeys } from '../runtime'; @@ -9,15 +8,3 @@ export type Keys = SessionKeys; /** u32 */ export type SessionIndex = u32; - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - SessionIndex: SessionIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Keys: Keys; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/staking/types.ts b/packages/types/src/interfaces/staking/types.ts index 6b73ecd7df..2e057eda72 100644 --- a/packages/types/src/interfaces/staking/types.ts +++ b/packages/types/src/interfaces/staking/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Compact, Enum, Struct, Vec } from '../../codec'; import { AccountId, Moment, u32 } from '../../primitive'; import { Balance, BlockNumber } from '../runtime'; @@ -73,36 +73,3 @@ export interface ValidatorPrefs extends Struct { /** Compact */ readonly validatorPayment: Compact; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - EraIndex: EraIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - EraRewards: EraRewards; - 'Option': Option; - 'Vec': Vec; - IndividualExposure: IndividualExposure; - 'Option': Option; - 'Vec': Vec; - Exposure: Exposure; - 'Option': Option; - 'Vec': Vec; - MomentOf: MomentOf; - 'Option': Option; - 'Vec': Vec; - RewardDestination: RewardDestination; - 'Option': Option; - 'Vec': Vec; - UnlockChunk: UnlockChunk; - 'Option': Option; - 'Vec': Vec; - StakingLedger: StakingLedger; - 'Option': Option; - 'Vec': Vec; - ValidatorPrefs: ValidatorPrefs; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/system/types.ts b/packages/types/src/interfaces/system/types.ts index e03817b8c4..7a4a59f58c 100644 --- a/packages/types/src/interfaces/system/types.ts +++ b/packages/types/src/interfaces/system/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Compact, Enum, Option, Struct, Vec } from '../../codec'; +import { Enum, Struct, Vec } from '../../codec'; import { Bytes, Digest, Event, u32, u8 } from '../../primitive'; import { Hash } from '../runtime'; @@ -43,30 +43,3 @@ export interface Phase extends Enum { /** 1:: Finalization */ readonly isFinalization: boolean; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - DigestOf: DigestOf; - 'Option': Option; - 'Vec': Vec; - EventId: EventId; - 'Option': Option; - 'Vec': Vec; - EventIndex: EventIndex; - 'Compact': Compact; - 'Option': Option; - 'Vec': Vec; - Key: Key; - 'Option': Option; - 'Vec': Vec; - Phase: Phase; - 'Option': Option; - 'Vec': Vec; - EventRecord0to76: EventRecord0to76; - 'Option': Option; - 'Vec': Vec; - EventRecord: EventRecord; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/interfaces/treasury/types.ts b/packages/types/src/interfaces/treasury/types.ts index 27f1f823b8..d75a3c10bf 100644 --- a/packages/types/src/interfaces/treasury/types.ts +++ b/packages/types/src/interfaces/treasury/types.ts @@ -1,6 +1,6 @@ // Auto-generated via `yarn build:interfaces`, do not edit -import { Option, Struct, Vec } from '../../codec'; +import { Struct } from '../../codec'; import { AccountId } from '../../primitive'; import { Balance } from '../runtime'; @@ -15,11 +15,3 @@ export interface TreasuryProposal extends Struct { /** Balance */ readonly bond: Balance; } - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { - TreasuryProposal: TreasuryProposal; - 'Option': Option; - 'Vec': Vec; - } -} diff --git a/packages/types/src/scripts/interfacesTs.ts b/packages/types/src/scripts/interfacesTs.ts index 4fc22ec4b6..2338140d39 100644 --- a/packages/types/src/scripts/interfacesTs.ts +++ b/packages/types/src/scripts/interfacesTs.ts @@ -267,17 +267,6 @@ function getDerivedTypes (type: string, primitiveName: string, imports: TypeImpo .join('\n'); } -// Do module augmentation on srml types to populate InterfaceRegistry -function interfaceRegistry (types: Record, imports: TypeImports): string { - return ` - -declare module '@polkadot/types/interfaceRegistry' { - export interface InterfaceRegistry { -${Object.keys(types).map((type): string => getDerivedTypes(type, types[type], imports, 4)).join('\n')} - } -}`; -} - function generateTsDef (defName: string, { types }: { types: Record }): void { // handlers are defined externally to use - this means that when we do a // `generators[typedef.info](...)` TS will show any unhandled types. Rather @@ -312,7 +301,6 @@ function generateTsDef (defName: string, { types }: { types: Record }); const sortedDefs = interfaces.sort((a, b): number => a[0].localeCompare(b[0])).map(([, definition]): string => definition).join('\n\n'); - const interfaceReg = interfaceRegistry(types, { codecTypes, localTypes, ownTypes, primitiveTypes }); const header = createImportCode(HEADER, [ { file: '../../types', @@ -332,7 +320,7 @@ function generateTsDef (defName: string, { types }: { types: Record })) ]); - fs.writeFileSync(`packages/types/src/interfaces/${defName}/types.ts`, header.concat(sortedDefs).concat(interfaceReg).concat(FOOTER), { flag: 'w' }); + fs.writeFileSync(`packages/types/src/interfaces/${defName}/types.ts`, header.concat(sortedDefs).concat(FOOTER), { flag: 'w' }); fs.writeFileSync(`packages/types/src/interfaces/${defName}/index.ts`, HEADER.concat(`export * from './types';`).concat(FOOTER), { flag: 'w' }); } @@ -349,14 +337,18 @@ fs.writeFileSync(`packages/types/src/interfaces/index.ts`, HEADER.concat(`export function generateInterfaceRegistry (): void { const codecTypes: TypeExist = {}; - const localTypes: LocalExist = {}; + const localTypes: LocalExist = Object.keys(definitions).reduce((localTypes: Record, moduleName): Record => { + localTypes[moduleName] = {}; + + return localTypes; + }, {}); const ownTypes: string[] = []; const primitiveTypes: TypeExist = {}; const substrateTypes: TypeExist = {}; const imports = { codecTypes, localTypes, ownTypes, primitiveTypes, substrateTypes }; - const body = Object.keys(primitiveClasses).reduce((accumulator, primitiveName): string => { + const primitives = Object.keys(primitiveClasses).reduce((accumulator, primitiveName): string => { setImports(imports, [primitiveName]); return [ @@ -365,6 +357,16 @@ function generateInterfaceRegistry (): void { ].join('\n'); }, ''); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const srml = Object.entries(definitions).reduce((accumulator, [_defName, { types }]): string => { + setImports(imports, Object.keys(types)); + + return [ + accumulator, + ...Object.keys(types).map((type): string => getDerivedTypes(type, (types as any)[type], imports, 2)) + ].join('\n'); + }, ''); + const header = createImportCode(HEADER, [ { file: './codec', @@ -373,7 +375,11 @@ function generateInterfaceRegistry (): void { { file: './primitive', types: Object.keys(primitiveTypes) - } + }, + ...Object.keys(localTypes).map((moduleName): { file: string; types: string[] } => ({ + file: `./interfaces/${moduleName}`, + types: Object.keys(localTypes[moduleName]) + })) ]); const interfaceStart = 'export interface InterfaceRegistry {'; @@ -381,7 +387,7 @@ function generateInterfaceRegistry (): void { fs.writeFileSync( `packages/types/src/interfaceRegistry.ts`, - header.concat(interfaceStart).concat(body).concat(interfaceEnd).concat(FOOTER) + header.concat(interfaceStart).concat(primitives).concat(srml).concat(interfaceEnd).concat(FOOTER) , { flag: 'w' } ); }