From 54b4c2620ac22064cc4408cc923c87471bfdc9eb Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 4 Aug 2020 22:38:56 +0200 Subject: [PATCH] Types for time-delay proxies (#2468) * Types for time-delay proxies * Remove duplicated CallHash (& generate output) --- packages/api/src/augment/query.ts | 3 +- packages/api/src/augment/tx.ts | 3 +- packages/types-known/src/modules.ts | 3 ++ packages/types/src/augment/registry.ts | 26 ++++++++++++----- packages/types/src/interfaces/definitions.ts | 1 + .../types/src/interfaces/proxy/definitions.ts | 27 +++++++++++++++++ packages/types/src/interfaces/proxy/index.ts | 4 +++ packages/types/src/interfaces/proxy/types.ts | 29 +++++++++++++++++++ .../src/interfaces/runtime/definitions.ts | 5 ++-- .../types/src/interfaces/runtime/types.ts | 14 ++++----- packages/types/src/interfaces/types.ts | 1 + .../src/interfaces/utility/definitions.ts | 1 - .../types/src/interfaces/utility/types.ts | 5 +--- 13 files changed, 96 insertions(+), 26 deletions(-) create mode 100644 packages/types/src/interfaces/proxy/definitions.ts create mode 100644 packages/types/src/interfaces/proxy/index.ts create mode 100644 packages/types/src/interfaces/proxy/types.ts diff --git a/packages/api/src/augment/query.ts b/packages/api/src/augment/query.ts index 56f70a576f..d6872d9d31 100644 --- a/packages/api/src/augment/query.ts +++ b/packages/api/src/augment/query.ts @@ -16,8 +16,9 @@ import { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfa import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity'; import { AuthIndex } from '@polkadot/types/interfaces/imOnline'; import { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences'; +import { ProxyType } from '@polkadot/types/interfaces/proxy'; import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; -import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, ProxyType, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime'; +import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime'; import { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import { Keys, SessionIndex } from '@polkadot/types/interfaces/session'; import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; diff --git a/packages/api/src/augment/tx.ts b/packages/api/src/augment/tx.ts index 9bba1bb393..0487458648 100644 --- a/packages/api/src/augment/tx.ts +++ b/packages/api/src/augment/tx.ts @@ -13,7 +13,8 @@ import { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics'; import { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa'; import { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity'; import { Heartbeat } from '@polkadot/types/interfaces/imOnline'; -import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, ProxyType, Weight } from '@polkadot/types/interfaces/runtime'; +import { ProxyType } from '@polkadot/types/interfaces/proxy'; +import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime'; import { Period, Priority } from '@polkadot/types/interfaces/scheduler'; import { Keys } from '@polkadot/types/interfaces/session'; import { SocietyJudgement } from '@polkadot/types/interfaces/society'; diff --git a/packages/types-known/src/modules.ts b/packages/types-known/src/modules.ts index d4c2310af9..1475932b74 100644 --- a/packages/types-known/src/modules.ts +++ b/packages/types-known/src/modules.ts @@ -29,6 +29,9 @@ const typesModules: Record = { parachains: { Id: 'ParaId' }, + proxy: { + Announcement: 'ProxyAnnouncement' + }, society: { Judgement: 'SocietyJudgement', Vote: 'SocietyVote' diff --git a/packages/types/src/augment/registry.ts b/packages/types/src/augment/registry.ts index eafadcb883..f8bc4a4fe6 100644 --- a/packages/types/src/augment/registry.ts +++ b/packages/types/src/augment/registry.ts @@ -30,10 +30,11 @@ import { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, Repo import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, RelayChainBlockNumber, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains'; import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; import { Approvals } from '@polkadot/types/interfaces/poll'; +import { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy'; import { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase'; import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery'; import { RpcMethods } from '@polkadot/types/interfaces/rpc'; -import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; +import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler'; import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session'; import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society'; @@ -43,7 +44,7 @@ import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support'; import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system'; import { OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury'; import { Multiplier } from '@polkadot/types/interfaces/txpayment'; -import { CallHash, Multisig, Timepoint } from '@polkadot/types/interfaces/utility'; +import { Multisig, Timepoint } from '@polkadot/types/interfaces/utility'; import { VestingInfo } from '@polkadot/types/interfaces/vesting'; declare module '@polkadot/types/types/registry' { @@ -161,6 +162,12 @@ declare module '@polkadot/types/types/registry' { Call: Call; 'Option': Option; 'Vec': Vec; + CallHash: CallHash; + 'Option': Option; + 'Vec': Vec; + CallHashOf: CallHashOf; + 'Option': Option; + 'Vec': Vec; ChangesTrieConfiguration: ChangesTrieConfiguration; 'Option': Option; 'Vec': Vec; @@ -258,9 +265,6 @@ declare module '@polkadot/types/types/registry' { PhantomData: PhantomData; 'Option': Option; 'Vec': Vec; - ProxyType: ProxyType; - 'Option': Option; - 'Vec': Vec; Releases: Releases; 'Option': Option; 'Vec': Vec; @@ -789,6 +793,15 @@ declare module '@polkadot/types/types/registry' { Reporter: Reporter; 'Option': Option; 'Vec': Vec; + ProxyDefinition: ProxyDefinition; + 'Option': Option; + 'Vec': Vec; + ProxyType: ProxyType; + 'Option': Option; + 'Vec': Vec; + ProxyAnnouncement: ProxyAnnouncement; + 'Option': Option; + 'Vec': Vec; ActiveRecovery: ActiveRecovery; 'Option': Option; 'Vec': Vec; @@ -1138,9 +1151,6 @@ declare module '@polkadot/types/types/registry' { Multiplier: Multiplier; 'Option': Option; 'Vec': Vec; - CallHash: CallHash; - 'Option': Option; - 'Vec': Vec; Multisig: Multisig; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index adba5e8f77..fa99c352a7 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -23,6 +23,7 @@ export { default as grandpa } from './grandpa/definitions'; export { default as identity } from './identity/definitions'; export { default as imOnline } from './imOnline/definitions'; export { default as offences } from './offences/definitions'; +export { default as proxy } from './proxy/definitions'; export { default as recovery } from './recovery/definitions'; export { default as scheduler } from './scheduler/definitions'; export { default as session } from './session/definitions'; diff --git a/packages/types/src/interfaces/proxy/definitions.ts b/packages/types/src/interfaces/proxy/definitions.ts new file mode 100644 index 0000000000..25b6036f57 --- /dev/null +++ b/packages/types/src/interfaces/proxy/definitions.ts @@ -0,0 +1,27 @@ +// Copyright 2017-2020 @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. + +// order important in structs... :) +/* eslint-disable sort-keys */ + +import { Definitions } from '../../types'; + +export default { + rpc: {}, + types: { + ProxyDefinition: { + delegate: 'AccountId', + proxyType: 'ProxyType', + delay: 'BlockNumber' + }, + ProxyType: { + _enum: ['Any', 'NonTransfer', 'Governance', 'Staking'] + }, + ProxyAnnouncement: { + real: 'AccountId', + callHash: 'Hash', + height: 'BlockNumber' + } + } +} as Definitions; diff --git a/packages/types/src/interfaces/proxy/index.ts b/packages/types/src/interfaces/proxy/index.ts new file mode 100644 index 0000000000..2d307291c3 --- /dev/null +++ b/packages/types/src/interfaces/proxy/index.ts @@ -0,0 +1,4 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +export * from './types'; diff --git a/packages/types/src/interfaces/proxy/types.ts b/packages/types/src/interfaces/proxy/types.ts new file mode 100644 index 0000000000..5137d2b18e --- /dev/null +++ b/packages/types/src/interfaces/proxy/types.ts @@ -0,0 +1,29 @@ +// Auto-generated via `yarn polkadot-types-from-defs`, do not edit +/* eslint-disable */ + +import { Enum, Struct } from '@polkadot/types/codec'; +import { AccountId, BlockNumber, Hash } from '@polkadot/types/interfaces/runtime'; + +/** @name ProxyAnnouncement */ +export interface ProxyAnnouncement extends Struct { + readonly real: AccountId; + readonly callHash: Hash; + readonly height: BlockNumber; +} + +/** @name ProxyDefinition */ +export interface ProxyDefinition extends Struct { + readonly delegate: AccountId; + readonly proxyType: ProxyType; + readonly delay: BlockNumber; +} + +/** @name ProxyType */ +export interface ProxyType extends Enum { + readonly isAny: boolean; + readonly isNonTransfer: boolean; + readonly isGovernance: boolean; + readonly isStaking: boolean; +} + +export type PHANTOM_PROXY = 'proxy'; diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index c3c41f8144..3a2d6bca4c 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -20,6 +20,8 @@ export default { Block: 'GenericBlock', BlockNumber: 'u32', Call: 'GenericCall', + CallHash: 'Hash', + CallHashOf: 'CallHash', ChangesTrieConfiguration: { digestInterval: 'u32', digestLevels: 'u32' @@ -76,9 +78,6 @@ export default { Perquintill: 'u64', Phantom: 'Null', PhantomData: 'Null', - ProxyType: { - _enum: ['Any', 'NonTransfer', 'Governance', 'Staking'] - }, Releases: { _enum: ['V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10'] }, diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index 1c0157af22..9d82145113 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -38,6 +38,12 @@ export interface BlockNumber extends u32 {} /** @name Call */ export interface Call extends GenericCall {} +/** @name CallHash */ +export interface CallHash extends Hash {} + +/** @name CallHashOf */ +export interface CallHashOf extends CallHash {} + /** @name ChangesTrieConfiguration */ export interface ChangesTrieConfiguration extends Struct { readonly digestInterval: u32; @@ -166,14 +172,6 @@ export interface PhantomData extends Null {} /** @name PreRuntime */ export interface PreRuntime extends ITuple<[ConsensusEngineId, Bytes]> {} -/** @name ProxyType */ -export interface ProxyType extends Enum { - readonly isAny: boolean; - readonly isNonTransfer: boolean; - readonly isGovernance: boolean; - readonly isStaking: boolean; -} - /** @name Releases */ export interface Releases extends Enum { readonly isV1: boolean; diff --git a/packages/types/src/interfaces/types.ts b/packages/types/src/interfaces/types.ts index fc4d79a888..c3d5ee2bf8 100644 --- a/packages/types/src/interfaces/types.ts +++ b/packages/types/src/interfaces/types.ts @@ -19,6 +19,7 @@ export * from './grandpa/types'; export * from './identity/types'; export * from './imOnline/types'; export * from './offences/types'; +export * from './proxy/types'; export * from './recovery/types'; export * from './scheduler/types'; export * from './session/types'; diff --git a/packages/types/src/interfaces/utility/definitions.ts b/packages/types/src/interfaces/utility/definitions.ts index 18c17daf2d..1efd2c2bde 100644 --- a/packages/types/src/interfaces/utility/definitions.ts +++ b/packages/types/src/interfaces/utility/definitions.ts @@ -10,7 +10,6 @@ import { Definitions } from '../../types'; export default { rpc: {}, types: { - CallHash: 'H256', Multisig: { when: 'Timepoint', deposit: 'Balance', diff --git a/packages/types/src/interfaces/utility/types.ts b/packages/types/src/interfaces/utility/types.ts index a565ae3931..f46ed57306 100644 --- a/packages/types/src/interfaces/utility/types.ts +++ b/packages/types/src/interfaces/utility/types.ts @@ -3,10 +3,7 @@ import { Struct, Vec } from '@polkadot/types/codec'; import { u32 } from '@polkadot/types/primitive'; -import { AccountId, Balance, BlockNumber, H256 } from '@polkadot/types/interfaces/runtime'; - -/** @name CallHash */ -export interface CallHash extends H256 {} +import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces/runtime'; /** @name Multisig */ export interface Multisig extends Struct {