diff --git a/CHANGELOG.md b/CHANGELOG.md index ad77696d50..b56d508463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,9 @@ ## 1.20.0-beta.x +- **Important** RPC for `account_nextIndex` has been moved to `system_accountNextIndex` (Aligning with Substrate as a primary alias) - Cleanup map entries support with only Substrate 2.0-era RPCs (when introduced) +- Add `system_dryRun` RPC ## 1.19.1 Jun 16, 2020 diff --git a/packages/api/src/augment/rpc.ts b/packages/api/src/augment/rpc.ts index e40af20670..81ebec13cb 100644 --- a/packages/api/src/augment/rpc.ts +++ b/packages/api/src/augment/rpc.ts @@ -19,16 +19,10 @@ import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; import { RpcMethods } from '@polkadot/types/interfaces/rpc'; import { AccountId, BlockNumber, H256, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime'; import { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state'; -import { ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo } from '@polkadot/types/interfaces/system'; +import { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo } from '@polkadot/types/interfaces/system'; declare module '@polkadot/rpc-core/types.jsonrpc' { export interface RpcInterface { - account: { - /** - * Retrieves the next accountIndex as available on the node - **/ - nextIndex: AugmentedRpc<(accountId: AccountId | string | Uint8Array) => Observable>; - }; author: { /** * Returns true if the keystore has private keys for the given public key and key type. @@ -244,6 +238,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' { subscribeStorage: AugmentedRpc<(keys?: Vec | (StorageKey | string | Uint8Array | any)[]) => Observable>; }; system: { + /** + * Retrieves the next accountIndex as available on the node + **/ + accountNextIndex: AugmentedRpc<(accountId: AccountId | string | Uint8Array) => Observable>; /** * Adds a reserved peer **/ @@ -256,6 +254,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' { * Retrieves the chain type **/ chainType: AugmentedRpc<() => Observable>; + /** + * Dry run an extrinsic at a given block + **/ + dryRun: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable>; /** * Return health status of the node **/ diff --git a/packages/rpc-core/src/index.ts b/packages/rpc-core/src/index.ts index ceb3c7a075..92d0274e11 100644 --- a/packages/rpc-core/src/index.ts +++ b/packages/rpc-core/src/index.ts @@ -80,8 +80,6 @@ export default class Rpc implements RpcInterface { // these via the createInterfaces inside the constructor. However... this is not quite visible. The reason // why we don't do for individual assignments is to allow user-defined RPCs to also be defined - public readonly account!: RpcInterface['account']; - public readonly author!: RpcInterface['author']; public readonly babe!: RpcInterface['babe']; diff --git a/packages/types/src/augment/registry.ts b/packages/types/src/augment/registry.ts index b816cf724c..6da9e76c88 100644 --- a/packages/types/src/augment/registry.ts +++ b/packages/types/src/augment/registry.ts @@ -31,14 +31,14 @@ import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, Cand import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment'; 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, DispatchClass, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime'; +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, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, 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'; import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, ReleasesStaking, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking'; import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state'; import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support'; -import { AccountInfo, ChainProperties, ChainType, DigestOf, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount } from '@polkadot/types/interfaces/system'; +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, OpenTipFinder, OpenTipTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury'; import { Multiplier } from '@polkadot/types/interfaces/txpayment'; import { CallHash, Multisig, Timepoint } from '@polkadot/types/interfaces/utility'; @@ -171,18 +171,6 @@ declare module '@polkadot/types/types/registry' { DigestItem: DigestItem; 'Option': Option; 'Vec': Vec; - DispatchClass: DispatchClass; - 'Option': Option; - 'Vec': Vec; - DispatchInfo: DispatchInfo; - 'Option': Option; - 'Vec': Vec; - DispatchInfoTo190: DispatchInfoTo190; - 'Option': Option; - 'Vec': Vec; - DispatchInfoTo244: DispatchInfoTo244; - 'Option': Option; - 'Vec': Vec; ExtrinsicsWeight: ExtrinsicsWeight; 'Option': Option; 'Vec': Vec; @@ -1008,6 +996,9 @@ declare module '@polkadot/types/types/registry' { AccountInfo: AccountInfo; 'Option': Option; 'Vec': Vec; + ApplyExtrinsicResult: ApplyExtrinsicResult; + 'Option': Option; + 'Vec': Vec; ChainProperties: ChainProperties; 'Option': Option; 'Vec': Vec; @@ -1017,6 +1008,9 @@ declare module '@polkadot/types/types/registry' { DigestOf: DigestOf; 'Option': Option; 'Vec': Vec; + DispatchClass: DispatchClass; + 'Option': Option; + 'Vec': Vec; DispatchError: DispatchError; 'Option': Option; 'Vec': Vec; @@ -1026,6 +1020,18 @@ declare module '@polkadot/types/types/registry' { DispatchErrorTo198: DispatchErrorTo198; 'Option': Option; 'Vec': Vec; + DispatchInfo: DispatchInfo; + 'Option': Option; + 'Vec': Vec; + DispatchInfoTo190: DispatchInfoTo190; + 'Option': Option; + 'Vec': Vec; + DispatchInfoTo244: DispatchInfoTo244; + 'Option': Option; + 'Vec': Vec; + DispatchOutcome: DispatchOutcome; + 'Option': Option; + 'Vec': Vec; DispatchResult: DispatchResult; 'Option': Option; 'Vec': Vec; @@ -1054,6 +1060,9 @@ declare module '@polkadot/types/types/registry' { Health: Health; 'Option': Option; 'Vec': Vec; + InvalidTransaction: InvalidTransaction; + 'Option': Option; + 'Vec': Vec; Key: Key; 'Option': Option; 'Vec': Vec; @@ -1097,6 +1106,12 @@ declare module '@polkadot/types/types/registry' { 'Compact': Compact; 'Option': Option; 'Vec': Vec; + TransactionValidityError: TransactionValidityError; + 'Option': Option; + 'Vec': Vec; + UnknownTransaction: UnknownTransaction; + 'Option': Option; + 'Vec': Vec; OpenTip: OpenTip; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/account/definitions.ts b/packages/types/src/interfaces/account/definitions.ts deleted file mode 100644 index 37a032b30a..0000000000 --- a/packages/types/src/interfaces/account/definitions.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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: { - nextIndex: { - alias: ['system_accountNextIndex'], - description: 'Retrieves the next accountIndex as available on the node', - params: [ - { - name: 'accountId', - type: 'AccountId' - } - ], - type: 'Index' - } - }, - types: {} -} as Definitions; diff --git a/packages/types/src/interfaces/account/index.ts b/packages/types/src/interfaces/account/index.ts deleted file mode 100644 index 2d307291c3..0000000000 --- a/packages/types/src/interfaces/account/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Auto-generated via `yarn polkadot-types-from-defs`, do not edit -/* eslint-disable */ - -export * from './types'; diff --git a/packages/types/src/interfaces/account/types.ts b/packages/types/src/interfaces/account/types.ts deleted file mode 100644 index d4469e0ce5..0000000000 --- a/packages/types/src/interfaces/account/types.ts +++ /dev/null @@ -1,4 +0,0 @@ -// Auto-generated via `yarn polkadot-types-from-defs`, do not edit -/* eslint-disable */ - -export type PHANTOM_ACCOUNT = 'account'; diff --git a/packages/types/src/interfaces/definitions.ts b/packages/types/src/interfaces/definitions.ts index 4e56717eae..211268ef50 100644 --- a/packages/types/src/interfaces/definitions.ts +++ b/packages/types/src/interfaces/definitions.ts @@ -45,7 +45,6 @@ export { default as metadata } from './metadata/definitions'; export { default as rpc } from './rpc/definitions'; // rpc-only definitions -export { default as account } from './account/definitions'; export { default as author } from './author/definitions'; export { default as chain } from './chain/definitions'; export { default as childstate } from './childstate/definitions'; diff --git a/packages/types/src/interfaces/payment/types.ts b/packages/types/src/interfaces/payment/types.ts index e6aefe4af3..2144b08062 100644 --- a/packages/types/src/interfaces/payment/types.ts +++ b/packages/types/src/interfaces/payment/types.ts @@ -2,7 +2,8 @@ /* eslint-disable */ import { Struct } from '@polkadot/types/codec'; -import { Balance, DispatchClass, Weight } from '@polkadot/types/interfaces/runtime'; +import { Balance, Weight } from '@polkadot/types/interfaces/runtime'; +import { DispatchClass } from '@polkadot/types/interfaces/system'; /** @name RuntimeDispatchInfo */ export interface RuntimeDispatchInfo extends Struct { diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index efd052fcf0..2363c8c735 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -39,23 +39,6 @@ export default { PreRuntime: 'PreRuntime' // 6 } }, - DispatchClass: { - _enum: ['Normal', 'Operational', 'Mandatory'] - }, - DispatchInfo: { - weight: 'Weight', - class: 'DispatchClass', - paysFee: 'Pays' - }, - DispatchInfoTo190: { - weight: 'Weight', - class: 'DispatchClass' - }, - DispatchInfoTo244: { - weight: 'Weight', - class: 'DispatchClass', - paysFee: 'bool' - }, ExtrinsicsWeight: { normal: 'Weight', operational: 'Weight' diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index 1c84c89a4a..44fefa0f4b 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -4,7 +4,7 @@ import { ITuple } from '@polkadot/types/types'; import { Compact, Enum, Int, Struct, U8aFixed, Vec } from '@polkadot/types/codec'; import { GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId } from '@polkadot/types/generic'; -import { Bytes, DoNotConstruct, Null, StorageKey, bool, u128, u32, u64, u8 } from '@polkadot/types/primitive'; +import { Bytes, DoNotConstruct, Null, StorageKey, u128, u32, u64, u8 } from '@polkadot/types/primitive'; import { AuthorityId } from '@polkadot/types/interfaces/consensus'; import { Signature } from '@polkadot/types/interfaces/extrinsics'; @@ -73,33 +73,6 @@ export interface DigestItem extends Enum { readonly asPreRuntime: PreRuntime; } -/** @name DispatchClass */ -export interface DispatchClass extends Enum { - readonly isNormal: boolean; - readonly isOperational: boolean; - readonly isMandatory: boolean; -} - -/** @name DispatchInfo */ -export interface DispatchInfo extends Struct { - readonly weight: Weight; - readonly class: DispatchClass; - readonly paysFee: Pays; -} - -/** @name DispatchInfoTo190 */ -export interface DispatchInfoTo190 extends Struct { - readonly weight: Weight; - readonly class: DispatchClass; -} - -/** @name DispatchInfoTo244 */ -export interface DispatchInfoTo244 extends Struct { - readonly weight: Weight; - readonly class: DispatchClass; - readonly paysFee: bool; -} - /** @name ExtrinsicsWeight */ export interface ExtrinsicsWeight extends Struct { readonly normal: Weight; diff --git a/packages/types/src/interfaces/system/definitions.ts b/packages/types/src/interfaces/system/definitions.ts index 892ac81d93..97c882575c 100644 --- a/packages/types/src/interfaces/system/definitions.ts +++ b/packages/types/src/interfaces/system/definitions.ts @@ -9,6 +9,33 @@ import { Definitions } from '../../types'; export default { rpc: { + accountNextIndex: { + alias: ['account_nextIndex'], + description: 'Retrieves the next accountIndex as available on the node', + params: [ + { + name: 'accountId', + type: 'AccountId' + } + ], + type: 'Index' + }, + dryRun: { + alias: ['system_dryRunAt'], + description: 'Dry run an extrinsic at a given block', + params: [ + { + name: 'extrinsic', + type: 'Bytes' + }, + { + name: 'at', + type: 'BlockHash', + isOptional: true + } + ], + type: 'ApplyExtrinsicResult' + }, name: { description: 'Retrieves the node name', params: [], @@ -91,6 +118,7 @@ export default { refcount: 'RefCount', data: 'AccountData' }, + ApplyExtrinsicResult: 'Result', ChainProperties: { ss58Format: 'Option', tokenDecimals: 'Option', @@ -105,6 +133,9 @@ export default { } }, DigestOf: 'Digest', + DispatchClass: { + _enum: ['Normal', 'Operational', 'Mandatory'] + }, DispatchError: { _enum: { Other: 'Null', @@ -121,6 +152,21 @@ export default { module: 'Option', error: 'u8' }, + DispatchInfo: { + weight: 'Weight', + class: 'DispatchClass', + paysFee: 'Pays' + }, + DispatchInfoTo190: { + weight: 'Weight', + class: 'DispatchClass' + }, + DispatchInfoTo244: { + weight: 'Weight', + class: 'DispatchClass', + paysFee: 'bool' + }, + DispatchOutcome: 'Result<(), DispatchError>', DispatchResult: 'Result<(), DispatchError>', DispatchResultOf: 'DispatchResult', DispatchResultTo198: 'Result<(), Text>', @@ -141,6 +187,20 @@ export default { isSyncing: 'bool', shouldHavePeers: 'bool' }, + InvalidTransaction: { + _enum: { + Call: 'Null', + Payment: 'Null', + Future: 'Null', + Stale: 'Null', + BadProof: 'Null', + AncientBirthBlock: 'Null', + ExhaustsResources: 'Null', + Custom: 'u8', + BadMandatory: 'Null', + MandatoryDispatch: 'Null' + } + }, Key: 'Bytes', LastRuntimeUpgradeInfo: { specVersion: 'Compact', @@ -214,6 +274,19 @@ export default { Initialization: 'Null' } }, - RefCount: 'u8' + RefCount: 'u8', + TransactionValidityError: { + _enum: { + Invalid: 'InvalidTransaction', + Unknown: 'UnknownTransaction' + } + }, + UnknownTransaction: { + _enum: { + CannotLookup: 'Null', + NoUnsignedValidator: 'Null', + Custom: 'u8' + } + } } } as Definitions; diff --git a/packages/types/src/interfaces/system/types.ts b/packages/types/src/interfaces/system/types.ts index a7dc62a655..65233f5f63 100644 --- a/packages/types/src/interfaces/system/types.ts +++ b/packages/types/src/interfaces/system/types.ts @@ -6,7 +6,7 @@ import { Compact, Enum, HashMap, Option, Result, Struct, U8aFixed, Vec } from '@ import { GenericEvent } from '@polkadot/types/generic'; import { Bytes, Text, bool, u32, u64, u8 } from '@polkadot/types/primitive'; import { AccountData } from '@polkadot/types/interfaces/balances'; -import { BlockNumber, Digest, Hash, Index } from '@polkadot/types/interfaces/runtime'; +import { BlockNumber, Digest, Hash, Index, Pays, Weight } from '@polkadot/types/interfaces/runtime'; /** @name AccountInfo */ export interface AccountInfo extends Struct { @@ -15,6 +15,14 @@ export interface AccountInfo extends Struct { readonly data: AccountData; } +/** @name ApplyExtrinsicResult */ +export interface ApplyExtrinsicResult extends Result { + readonly isError: boolean; + readonly asError: TransactionValidityError; + readonly isOk: boolean; + readonly asOk: DispatchOutcome; +} + /** @name ChainProperties */ export interface ChainProperties extends Struct { readonly ss58Format: Option; @@ -34,6 +42,13 @@ export interface ChainType extends Enum { /** @name DigestOf */ export interface DigestOf extends Digest {} +/** @name DispatchClass */ +export interface DispatchClass extends Enum { + readonly isNormal: boolean; + readonly isOperational: boolean; + readonly isMandatory: boolean; +} + /** @name DispatchError */ export interface DispatchError extends Enum { readonly isOther: boolean; @@ -55,6 +70,34 @@ export interface DispatchErrorTo198 extends Struct { readonly error: u8; } +/** @name DispatchInfo */ +export interface DispatchInfo extends Struct { + readonly weight: Weight; + readonly class: DispatchClass; + readonly paysFee: Pays; +} + +/** @name DispatchInfoTo190 */ +export interface DispatchInfoTo190 extends Struct { + readonly weight: Weight; + readonly class: DispatchClass; +} + +/** @name DispatchInfoTo244 */ +export interface DispatchInfoTo244 extends Struct { + readonly weight: Weight; + readonly class: DispatchClass; + readonly paysFee: bool; +} + +/** @name DispatchOutcome */ +export interface DispatchOutcome extends Result, DispatchError> { + readonly isError: boolean; + readonly asError: DispatchError; + readonly isOk: boolean; + readonly asOk: ITuple<[]>; +} + /** @name DispatchResult */ export interface DispatchResult extends Result, DispatchError> { readonly isError: boolean; @@ -103,6 +146,21 @@ export interface Health extends Struct { readonly shouldHavePeers: bool; } +/** @name InvalidTransaction */ +export interface InvalidTransaction extends Enum { + readonly isCall: boolean; + readonly isPayment: boolean; + readonly isFuture: boolean; + readonly isStale: boolean; + readonly isBadProof: boolean; + readonly isAncientBirthBlock: boolean; + readonly isExhaustsResources: boolean; + readonly isCustom: boolean; + readonly asCustom: u8; + readonly isBadMandatory: boolean; + readonly isMandatoryDispatch: boolean; +} + /** @name Key */ export interface Key extends Bytes {} @@ -199,4 +257,20 @@ export interface Phase extends Enum { /** @name RefCount */ export interface RefCount extends u8 {} +/** @name TransactionValidityError */ +export interface TransactionValidityError extends Enum { + readonly isInvalid: boolean; + readonly asInvalid: InvalidTransaction; + readonly isUnknown: boolean; + readonly asUnknown: UnknownTransaction; +} + +/** @name UnknownTransaction */ +export interface UnknownTransaction extends Enum { + readonly isCannotLookup: boolean; + readonly isNoUnsignedValidator: boolean; + readonly isCustom: boolean; + readonly asCustom: u8; +} + export type PHANTOM_SYSTEM = 'system'; diff --git a/packages/types/src/interfaces/types.ts b/packages/types/src/interfaces/types.ts index d3a6b722b0..82a464fc1f 100644 --- a/packages/types/src/interfaces/types.ts +++ b/packages/types/src/interfaces/types.ts @@ -35,7 +35,6 @@ export * from './claims/types'; export * from './parachains/types'; export * from './metadata/types'; export * from './rpc/types'; -export * from './account/types'; export * from './author/types'; export * from './chain/types'; export * from './childstate/types';