Skip to content

Commit

Permalink
Align RPCs with Substrate master (polkadot-js#3493)
Browse files Browse the repository at this point in the history
* Align RPCs with Substrate master

* Build interfaces, apply fixes

* Metadata v13 changes
  • Loading branch information
jacogr authored May 5, 2021
1 parent 7365056 commit 1c00cb4
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 7 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

Upgrade priority: Medium. Required for the next v0.9.0 Polkadot/Kusama chains

- **Breaking change** The previously deprecated contracts interfaces (marked as deprecated, should have been dropped with the 4.0 release), has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces.
- **Breaking change** The previously deprecated contracts interfaces, has been removed. Update to `<myContract>.query.*`, `<myContract>.tx.*` and `<myCode>.tx.*` interfaces as per the previous code usage hints.
- **Important** By default the `isPedantic` mode is now switched on for storage queries. This means that the API will fail on any types where the input/output decoding doesn't match 100%

Changes:

Expand All @@ -16,9 +17,12 @@ Changes:
- Adjust `ContractInfo` type as per latest Substrate
- Adjust `DigestItem` type as per latest Substrate
- Adjust re-encoding of `BitVec` based on decoded length
- Added `contracts_instantiate`, `state_traceBlock` & `system_reservedPeers` RPCs
- Prepare for auto-capability detection with historic `.at` queries
- Add known upgrade block for Westend 900
- Add known upgrade block for Westend 900 & 9000
- Remove all deprecated interfaces inside `@polkadot/api-contracts`
- Initial support for NMap storage keys
- Support metadata v13 from Substrate (upcoming upgrade)


## 4.8.1 May 2, 2021
Expand Down
16 changes: 14 additions & 2 deletions packages/api/src/augment/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
import type { BlockHash } from '@polkadot/types/interfaces/chain';
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
import type { ContractCallRequest, ContractExecResult, ContractInstantiateResult, InstantiateRequest } from '@polkadot/types/interfaces/contracts';
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
import type { EthAccount, EthCallRequest, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
Expand All @@ -20,7 +20,7 @@ import type { StorageKind } from '@polkadot/types/interfaces/offchain';
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import type { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';

declare module '@polkadot/rpc-core/types.jsonrpc' {
Expand Down Expand Up @@ -128,6 +128,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the value under a specified storage key in a contract
**/
getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* Instantiate a new contract
**/
instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; endowment?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
/**
* Returns the projected time a given contract will be able to sustain paying its rent
**/
Expand Down Expand Up @@ -442,6 +446,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Subscribes to storage changes for the provided keys
**/
subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
/**
* Provides a way to trace the re-execution of a single block
**/
traceBlock: AugmentedRpc<(block: Hash | string | Uint8Array, targets: Option<Text> | null | object | string | Uint8Array, storageKeys: Option<Text> | null | object | string | Uint8Array) => Observable<TraceBlockResponse>>;
};
syncstate: {
/**
Expand Down Expand Up @@ -510,6 +518,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Remove a reserved peer
**/
removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
/**
* Returns the list of reserved peers
**/
reservedPeers: AugmentedRpc<() => Observable<Vec<Text>>>;
/**
* Resets the log filter to Substrate defaults
**/
Expand Down
37 changes: 35 additions & 2 deletions packages/types/src/augment/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import type { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractStorageKey, DeletedContract, Gas, HostFnWeights, HostFnWeightsTo264, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractInfo, ContractInstantiateResult, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpec, ContractEventSpec, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpec, ContractMessageSpec, ContractProject, ContractProjectContract, ContractProjectSource, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
Expand Down Expand Up @@ -47,7 +47,7 @@ import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, Sch
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TokenError, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
Expand Down Expand Up @@ -225,6 +225,10 @@ declare module '@polkadot/types/types/registry' {
'Option<BlockHash>': Option<BlockHash>;
'Option<BlockLength>': Option<BlockLength>;
'Option<BlockNumber>': Option<BlockNumber>;
'Option<BlockTrace>': Option<BlockTrace>;
'Option<BlockTraceEvent>': Option<BlockTraceEvent>;
'Option<BlockTraceEventData>': Option<BlockTraceEventData>;
'Option<BlockTraceSpan>': Option<BlockTraceSpan>;
'Option<BlockWeights>': Option<BlockWeights>;
'Option<BodyId>': Option<BodyId>;
'Option<BodyPart>': Option<BodyPart>;
Expand Down Expand Up @@ -285,6 +289,7 @@ declare module '@polkadot/types/types/registry' {
'Option<ContractExecResultTo255>': Option<ContractExecResultTo255>;
'Option<ContractExecResultTo260>': Option<ContractExecResultTo260>;
'Option<ContractInfo>': Option<ContractInfo>;
'Option<ContractInstantiateResult>': Option<ContractInstantiateResult>;
'Option<ContractLayoutArray>': Option<ContractLayoutArray>;
'Option<ContractLayoutCell>': Option<ContractLayoutCell>;
'Option<ContractLayoutEnum>': Option<ContractLayoutEnum>;
Expand Down Expand Up @@ -404,6 +409,7 @@ declare module '@polkadot/types/types/registry' {
'Option<EvmAccount>': Option<EvmAccount>;
'Option<EvmLog>': Option<EvmLog>;
'Option<EvmVicinity>': Option<EvmVicinity>;
'Option<ExecReturnValue>': Option<ExecReturnValue>;
'Option<ExitError>': Option<ExitError>;
'Option<ExitFatal>': Option<ExitFatal>;
'Option<ExitReason>': Option<ExitReason>;
Expand Down Expand Up @@ -512,6 +518,8 @@ declare module '@polkadot/types/types/registry' {
'Option<Index>': Option<Index>;
'Option<IndicesLookupSource>': Option<IndicesLookupSource>;
'Option<IndividualExposure>': Option<IndividualExposure>;
'Option<InstantiateRequest>': Option<InstantiateRequest>;
'Option<InstantiateReturnValue>': Option<InstantiateReturnValue>;
'Option<InstructionWeights>': Option<InstructionWeights>;
'Option<InvalidDisputeStatementKind>': Option<InvalidDisputeStatementKind>;
'Option<InvalidTransaction>': Option<InvalidTransaction>;
Expand Down Expand Up @@ -725,6 +733,7 @@ declare module '@polkadot/types/types/registry' {
'Option<Releases>': Option<Releases>;
'Option<Remark>': Option<Remark>;
'Option<Renouncing>': Option<Renouncing>;
'Option<RentProjection>': Option<RentProjection>;
'Option<ReportedRoundStates>': Option<ReportedRoundStates>;
'Option<Reporter>': Option<Reporter>;
'Option<ReportIdOf>': Option<ReportIdOf>;
Expand Down Expand Up @@ -861,6 +870,8 @@ declare module '@polkadot/types/types/registry' {
'Option<Timepoint>': Option<Timepoint>;
'Option<TokenError>': Option<TokenError>;
'Option<TombstoneContractInfo>': Option<TombstoneContractInfo>;
'Option<TraceBlockResponse>': Option<TraceBlockResponse>;
'Option<TraceError>': Option<TraceError>;
'Option<TransactionPriority>': Option<TransactionPriority>;
'Option<TransactionValidityError>': Option<TransactionValidityError>;
'Option<TransientValidationData>': Option<TransientValidationData>;
Expand Down Expand Up @@ -1043,6 +1054,10 @@ declare module '@polkadot/types/types/registry' {
'Vec<BlockHash>': Vec<BlockHash>;
'Vec<BlockLength>': Vec<BlockLength>;
'Vec<BlockNumber>': Vec<BlockNumber>;
'Vec<BlockTrace>': Vec<BlockTrace>;
'Vec<BlockTraceEvent>': Vec<BlockTraceEvent>;
'Vec<BlockTraceEventData>': Vec<BlockTraceEventData>;
'Vec<BlockTraceSpan>': Vec<BlockTraceSpan>;
'Vec<BlockWeights>': Vec<BlockWeights>;
'Vec<BodyId>': Vec<BodyId>;
'Vec<BodyPart>': Vec<BodyPart>;
Expand Down Expand Up @@ -1103,6 +1118,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<ContractExecResultTo255>': Vec<ContractExecResultTo255>;
'Vec<ContractExecResultTo260>': Vec<ContractExecResultTo260>;
'Vec<ContractInfo>': Vec<ContractInfo>;
'Vec<ContractInstantiateResult>': Vec<ContractInstantiateResult>;
'Vec<ContractLayoutArray>': Vec<ContractLayoutArray>;
'Vec<ContractLayoutCell>': Vec<ContractLayoutCell>;
'Vec<ContractLayoutEnum>': Vec<ContractLayoutEnum>;
Expand Down Expand Up @@ -1222,6 +1238,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<EvmAccount>': Vec<EvmAccount>;
'Vec<EvmLog>': Vec<EvmLog>;
'Vec<EvmVicinity>': Vec<EvmVicinity>;
'Vec<ExecReturnValue>': Vec<ExecReturnValue>;
'Vec<ExitError>': Vec<ExitError>;
'Vec<ExitFatal>': Vec<ExitFatal>;
'Vec<ExitReason>': Vec<ExitReason>;
Expand Down Expand Up @@ -1330,6 +1347,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<Index>': Vec<Index>;
'Vec<IndicesLookupSource>': Vec<IndicesLookupSource>;
'Vec<IndividualExposure>': Vec<IndividualExposure>;
'Vec<InstantiateRequest>': Vec<InstantiateRequest>;
'Vec<InstantiateReturnValue>': Vec<InstantiateReturnValue>;
'Vec<InstructionWeights>': Vec<InstructionWeights>;
'Vec<InvalidDisputeStatementKind>': Vec<InvalidDisputeStatementKind>;
'Vec<InvalidTransaction>': Vec<InvalidTransaction>;
Expand Down Expand Up @@ -1543,6 +1562,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<Releases>': Vec<Releases>;
'Vec<Remark>': Vec<Remark>;
'Vec<Renouncing>': Vec<Renouncing>;
'Vec<RentProjection>': Vec<RentProjection>;
'Vec<ReportedRoundStates>': Vec<ReportedRoundStates>;
'Vec<Reporter>': Vec<Reporter>;
'Vec<ReportIdOf>': Vec<ReportIdOf>;
Expand Down Expand Up @@ -1679,6 +1699,8 @@ declare module '@polkadot/types/types/registry' {
'Vec<Timepoint>': Vec<Timepoint>;
'Vec<TokenError>': Vec<TokenError>;
'Vec<TombstoneContractInfo>': Vec<TombstoneContractInfo>;
'Vec<TraceBlockResponse>': Vec<TraceBlockResponse>;
'Vec<TraceError>': Vec<TraceError>;
'Vec<TransactionPriority>': Vec<TransactionPriority>;
'Vec<TransactionValidityError>': Vec<TransactionValidityError>;
'Vec<TransientValidationData>': Vec<TransientValidationData>;
Expand Down Expand Up @@ -1861,6 +1883,10 @@ declare module '@polkadot/types/types/registry' {
BlockHash: BlockHash;
BlockLength: BlockLength;
BlockNumber: BlockNumber;
BlockTrace: BlockTrace;
BlockTraceEvent: BlockTraceEvent;
BlockTraceEventData: BlockTraceEventData;
BlockTraceSpan: BlockTraceSpan;
BlockWeights: BlockWeights;
BodyId: BodyId;
BodyPart: BodyPart;
Expand Down Expand Up @@ -1921,6 +1947,7 @@ declare module '@polkadot/types/types/registry' {
ContractExecResultTo255: ContractExecResultTo255;
ContractExecResultTo260: ContractExecResultTo260;
ContractInfo: ContractInfo;
ContractInstantiateResult: ContractInstantiateResult;
ContractLayoutArray: ContractLayoutArray;
ContractLayoutCell: ContractLayoutCell;
ContractLayoutEnum: ContractLayoutEnum;
Expand Down Expand Up @@ -2040,6 +2067,7 @@ declare module '@polkadot/types/types/registry' {
EvmAccount: EvmAccount;
EvmLog: EvmLog;
EvmVicinity: EvmVicinity;
ExecReturnValue: ExecReturnValue;
ExitError: ExitError;
ExitFatal: ExitFatal;
ExitReason: ExitReason;
Expand Down Expand Up @@ -2148,6 +2176,8 @@ declare module '@polkadot/types/types/registry' {
Index: Index;
IndicesLookupSource: IndicesLookupSource;
IndividualExposure: IndividualExposure;
InstantiateRequest: InstantiateRequest;
InstantiateReturnValue: InstantiateReturnValue;
InstructionWeights: InstructionWeights;
InvalidDisputeStatementKind: InvalidDisputeStatementKind;
InvalidTransaction: InvalidTransaction;
Expand Down Expand Up @@ -2361,6 +2391,7 @@ declare module '@polkadot/types/types/registry' {
Releases: Releases;
Remark: Remark;
Renouncing: Renouncing;
RentProjection: RentProjection;
ReportedRoundStates: ReportedRoundStates;
Reporter: Reporter;
ReportIdOf: ReportIdOf;
Expand Down Expand Up @@ -2497,6 +2528,8 @@ declare module '@polkadot/types/types/registry' {
Timepoint: Timepoint;
TokenError: TokenError;
TombstoneContractInfo: TombstoneContractInfo;
TraceBlockResponse: TraceBlockResponse;
TraceError: TraceError;
TransactionPriority: TransactionPriority;
TransactionValidityError: TransactionValidityError;
TransientValidationData: TransientValidationData;
Expand Down
Loading

0 comments on commit 1c00cb4

Please sign in to comment.