diff --git a/packages/api/src/base/typeInjector.ts b/packages/api/src/base/typeInjector.ts index 0701b5a61f..e6078a2ca7 100644 --- a/packages/api/src/base/typeInjector.ts +++ b/packages/api/src/base/typeInjector.ts @@ -18,16 +18,10 @@ interface VersionedType { // implementation) are different. Detect Polkadot and inject the `Keys` // definition as applicable. (4 keys in substrate vs 5 in Polkadot/CC3). const TYPES_POLKADOT_VERSIONED: VersionedType[] = [ - { - minmax: [0, 1018], // CC2 - types: { - Keys: 'SessionKeys4', - ValidatorPrefs: 'ValidatorPrefsTo196' - } - }, { minmax: [1019, undefined], // CC3 types: { + DispatchError: 'DispatchErrorTo198', Keys: 'SessionKeys5' } } diff --git a/packages/types/src/codec/Result.spec.ts b/packages/types/src/codec/Result.spec.ts index dc2331bc9f..758bbbae2a 100644 --- a/packages/types/src/codec/Result.spec.ts +++ b/packages/types/src/codec/Result.spec.ts @@ -45,6 +45,6 @@ describe('Result', (): void => { }); it('returns a proper raw typedef rom a built-in', (): void => { - expect(createType(registry, 'DispatchResult').toRawType()).toEqual('Result'); + expect(createType(registry, 'DispatchResult').toRawType()).toEqual('Result'); }); }); diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index 9fa771fb24..bf87adfd93 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -21,10 +21,9 @@ import { AuthIndex, AuthoritySignature, Heartbeat, OpaqueMultiaddr, OpaqueNetwor import { Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences'; import { FullIdentification, IdentificationTuple, Keys, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6 } from '@polkadot/types/interfaces/session'; import { EraIndex, EraPoints, EraRewards, Exposure, Forcing, IndividualExposure, MomentOf, Nominations, Points, RewardDestination, SlashJournalEntry, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; -import { DigestOf, DispatchError, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, Phase } from '@polkadot/types/interfaces/system'; +import { DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Key, Phase } from '@polkadot/types/interfaces/system'; import { TreasuryProposal } from '@polkadot/types/interfaces/treasury'; import { Multiplier } from '@polkadot/types/interfaces/txpayment'; -import { DispatchResult, DispatchResultOf } from '@polkadot/types/interfaces/utility'; import { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations'; import { EthereumAddress } from '@polkadot/types/interfaces/claims'; import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorId, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParaInfo, ParaScheduling, ParachainDispatchOrigin, Retriable, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains'; @@ -703,6 +702,21 @@ export interface InterfaceRegistry { DispatchError: DispatchError; 'Option': Option; 'Vec': Vec; + DispatchErrorModule: DispatchErrorModule; + 'Option': Option; + 'Vec': Vec; + DispatchErrorTo198: DispatchErrorTo198; + 'Option': Option; + 'Vec': Vec; + DispatchResult: DispatchResult; + 'Option': Option; + 'Vec': Vec; + DispatchResultOf: DispatchResultOf; + 'Option': Option; + 'Vec': Vec; + DispatchResultTo198: DispatchResultTo198; + 'Option': Option; + 'Vec': Vec; Event: Event; 'Option': Option; 'Vec': Vec; @@ -731,12 +745,6 @@ export interface InterfaceRegistry { Multiplier: Multiplier; 'Option': Option; 'Vec': Vec; - DispatchResult: DispatchResult; - 'Option': Option; - 'Vec': Vec; - DispatchResultOf: DispatchResultOf; - 'Option': Option; - 'Vec': Vec; BlockAttestations: BlockAttestations; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index 5fc40ab200..cc6502cf0c 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -26,7 +26,6 @@ export { default as staking } from './staking/definitions'; export { default as system } from './system/definitions'; export { default as treasury } from './treasury/definitions'; export { default as txpayment } from './txpayment/definitions'; -export { default as utility } from './utility/definitions'; // polkadot-specific types export { default as attestations } from './attestations/definitions'; diff --git a/packages/types/src/interfaces/system/definitions.ts b/packages/types/src/interfaces/system/definitions.ts index b7bf881d15..9bb093660d 100644 --- a/packages/types/src/interfaces/system/definitions.ts +++ b/packages/types/src/interfaces/system/definitions.ts @@ -6,9 +6,24 @@ export default { types: { DigestOf: 'Digest', DispatchError: { + _enum: { + Other: 'Null', + CannotLookup: 'Null', + BadOrigin: 'Null', + Module: 'DispatchErrorModule' + } + }, + DispatchErrorModule: { + index: 'u8', + error: 'u8' + }, + DispatchErrorTo198: { module: 'Option', error: 'u8' }, + DispatchResult: 'Result<(), DispatchError>', + DispatchResultOf: 'DispatchResult', + DispatchResultTo198: 'Result<(), Text>', Event: 'GenericEvent', EventId: '[u8; 2]', EventIndex: 'u32', diff --git a/packages/types/src/interfaces/system/types.ts b/packages/types/src/interfaces/system/types.ts index 81d7e826de..914591986c 100644 --- a/packages/types/src/interfaces/system/types.ts +++ b/packages/types/src/interfaces/system/types.ts @@ -2,21 +2,66 @@ /* eslint-disable @typescript-eslint/no-empty-interface */ import { Codec } from '@polkadot/types/types'; -import { Enum, Option, Struct, Vec } from '@polkadot/types/codec'; -import { Bytes, GenericEvent, u32, u8 } from '@polkadot/types/primitive'; +import { Enum, Option, Result, Struct, Vec } from '@polkadot/types/codec'; +import { Bytes, GenericEvent, Null, Text, u32, u8 } from '@polkadot/types/primitive'; import { Digest, Hash } from '@polkadot/types/interfaces/runtime'; /** Digest */ export interface DigestOf extends Digest {} +/** Enum */ +export interface DispatchError extends Enum { + /** 0:: Other */ + readonly isOther: boolean; + /** 1:: CannotLookup */ + readonly isCannotLookup: boolean; + /** 2:: BadOrigin */ + readonly isBadOrigin: boolean; + /** 3:: Module(DispatchErrorModule) */ + readonly isModule: boolean; + /** DispatchErrorModule */ + readonly asModule: DispatchErrorModule; +} + /** Struct */ -export interface DispatchError extends Struct { +export interface DispatchErrorModule extends Struct { + /** u8 */ + readonly index: u8; + /** u8 */ + readonly error: u8; +} + +/** Struct */ +export interface DispatchErrorTo198 extends Struct { /** Option */ readonly module: Option; /** u8 */ readonly error: u8; } +/** Result */ +export interface DispatchResult extends Result { + /** Error:: (DispatchError) */ + readonly isError: boolean; + /** DispatchError */ + readonly asError: DispatchError; + /** Ok:: */ + readonly isOk: boolean; +} + +/** DispatchResult */ +export interface DispatchResultOf extends DispatchResult {} + +/** Result */ +export interface DispatchResultTo198 extends Result { + /** Error:: (Text) */ + readonly isError: boolean; + /** Text */ + readonly asError: Text; + /** Ok:: */ + readonly isOk: boolean; +} + /** GenericEvent */ export interface Event extends GenericEvent {} diff --git a/packages/types/src/interfaces/types.ts b/packages/types/src/interfaces/types.ts index a5cc77ff77..233ffc772b 100644 --- a/packages/types/src/interfaces/types.ts +++ b/packages/types/src/interfaces/types.ts @@ -22,7 +22,6 @@ export * from './staking/types'; export * from './system/types'; export * from './treasury/types'; export * from './txpayment/types'; -export * from './utility/types'; export * from './attestations/types'; export * from './claims/types'; export * from './parachains/types'; diff --git a/packages/types/src/interfaces/utility/definitions.ts b/packages/types/src/interfaces/utility/definitions.ts deleted file mode 100644 index 7e5a89cc83..0000000000 --- a/packages/types/src/interfaces/utility/definitions.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 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: { - // This is not deprecated, only there for a short while, replaced by Result<(), DispatchError> - DispatchResult: 'Result<(), Text>', - DispatchResultOf: 'DispatchResult' - } -}; diff --git a/packages/types/src/interfaces/utility/index.ts b/packages/types/src/interfaces/utility/index.ts deleted file mode 100644 index 05fdc138ff..0000000000 --- a/packages/types/src/interfaces/utility/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Auto-generated via `yarn build:interfaces`, do not edit -/* eslint-disable @typescript-eslint/no-empty-interface */ - -export * from './types'; diff --git a/packages/types/src/interfaces/utility/types.ts b/packages/types/src/interfaces/utility/types.ts deleted file mode 100644 index 7e54bc69cb..0000000000 --- a/packages/types/src/interfaces/utility/types.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Auto-generated via `yarn build:interfaces`, do not edit -/* eslint-disable @typescript-eslint/no-empty-interface */ - -import { Result } from '@polkadot/types/codec'; -import { Null, Text } from '@polkadot/types/primitive'; - -/** Result */ -export interface DispatchResult extends Result { - /** Error:: (Text) */ - readonly isError: boolean; - /** Text */ - readonly asError: Text; - /** Ok:: */ - readonly isOk: boolean; -} - -/** DispatchResult */ -export interface DispatchResultOf extends DispatchResult {}