diff --git a/packages/api/test/e2e/rpc-core/state.spec.ts b/packages/api/test/e2e/rpc-core/state.spec.ts index 9c8c2b57b5..92aacab963 100644 --- a/packages/api/test/e2e/rpc-core/state.spec.ts +++ b/packages/api/test/e2e/rpc-core/state.spec.ts @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { Balance, Hash, Moment, StorageData } from '@polkadot/types/interfaces'; +import { Balance, Hash, Moment } from '@polkadot/types/interfaces'; import fs from 'fs'; import path from 'path'; @@ -15,7 +15,7 @@ import testingPairs from '@polkadot/keyring/testingPairs'; import { KeyringPair } from '@polkadot/keyring/types'; import Rpc from '@polkadot/rpc-core'; import WsProvider from '@polkadot/rpc-provider/ws'; -import { Bytes, Metadata, StorageKey } from '@polkadot/types'; +import { Bytes, Metadata, StorageData, StorageKey } from '@polkadot/types'; import flipperAbi from '../../../../api-contract/test/contracts/flipper.json'; diff --git a/packages/rpc-core/src/index.ts b/packages/rpc-core/src/index.ts index cf487144a4..d72fe1454c 100644 --- a/packages/rpc-core/src/index.ts +++ b/packages/rpc-core/src/index.ts @@ -4,7 +4,7 @@ import { ProviderInterface } from '@polkadot/rpc-provider/types'; import { RpcSection, RpcMethod } from '@polkadot/jsonrpc/types'; -import { StorageChangeSet, StorageData } from '@polkadot/types/interfaces'; +import { StorageChangeSet } from '@polkadot/types/interfaces'; import { AnyJson, Codec } from '@polkadot/types/types'; import { RpcInterface, RpcInterfaceMethod, RpcInterfaceSection } from './types'; @@ -12,7 +12,7 @@ import memoizee from 'memoizee'; import { combineLatest, from, Observable, Observer, of, throwError } from 'rxjs'; import { catchError, map, publishReplay, refCount, switchMap } from 'rxjs/operators'; import interfaces from '@polkadot/jsonrpc'; -import { ClassOf, Option, StorageKey, Vec, createClass } from '@polkadot/types'; +import { ClassOf, Option, StorageData, StorageKey, Vec, createClass } from '@polkadot/types'; import { createTypeUnsafe } from '@polkadot/types/codec/createType'; import { ExtError, assert, isFunction, isNull, isNumber, logger } from '@polkadot/util'; diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index 0e9da65653..f309dbf45d 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -1,8 +1,8 @@ // Auto-generated via `yarn build:interfaces`, do not edit import { Compact, Option, Vec } from './codec'; -import { Bytes, Data, Fixed64, H160, H256, H512, Null, StorageHasher, StorageKey, Text, Type, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive'; -import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, StorageData, ValidatorId, Weight, WeightMultiplier } from './interfaces/runtime'; +import { Bytes, Data, Fixed64, H160, H256, H512, Null, StorageData, StorageHasher, StorageKey, Text, Type, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from './primitive'; +import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, Consensus, ConsensusEngineId, Digest, DigestItem, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, Hash, Header, ImmortalEra, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, Moment, MortalEra, Origin, Perbill, Permill, Phantom, PreRuntime, Seal, SealV0, Signature, SignedBlock, Sr25519Signature, 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'; @@ -65,6 +65,9 @@ export interface InterfaceRegistry { Null: Null; 'Option': Option; 'Vec': Vec; + StorageData: StorageData; + 'Option': Option; + 'Vec': Vec; StorageHasher: StorageHasher; 'Option': Option; 'Vec': Vec; @@ -172,9 +175,6 @@ export interface InterfaceRegistry { WeightMultiplier: WeightMultiplier; 'Option': Option; 'Vec': Vec; - StorageData: StorageData; - 'Option': Option; - 'Vec': Vec; KeyValue: KeyValue; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/rpc/types.ts b/packages/types/src/interfaces/rpc/types.ts index cf2b2ebbf6..898003dfa2 100644 --- a/packages/types/src/interfaces/rpc/types.ts +++ b/packages/types/src/interfaces/rpc/types.ts @@ -2,8 +2,8 @@ import { Codec } from '../../types'; import { Enum, Option, Struct, Vec } from '../../codec'; -import { Bytes, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive'; -import { BlockNumber, Hash, StorageData } from '../runtime'; +import { Bytes, StorageData, StorageKey, Text, bool, u32, u64, u8 } from '../../primitive'; +import { BlockNumber, Hash } from '../runtime'; /** Vec */ export type ApiId = Vec; diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index 9246200d99..2db1d80124 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -25,7 +25,6 @@ export default { WeightMultiplier: 'Fixed64', // storage helpers - StorageData: 'Bytes', KeyValue: '(StorageKey, StorageData)', // signatures (used in block & extrinsics) diff --git a/packages/types/src/interfaces/runtime/types.ts b/packages/types/src/interfaces/runtime/types.ts index ca8b45d5e3..8c0273c527 100644 --- a/packages/types/src/interfaces/runtime/types.ts +++ b/packages/types/src/interfaces/runtime/types.ts @@ -2,7 +2,7 @@ import { Codec } from '../../types'; import { Compact, Struct, Vec } from '../../codec'; -import { Bytes, Fixed64, GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId, GenericDigest, GenericDigestItem, GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericImmortalEra, GenericMortalEra, GenericOrigin, H256, H512, Null, StorageKey, u128, u32, u64, u8 } from '../../primitive'; +import { Bytes, Fixed64, GenericAccountId, GenericAccountIndex, GenericAddress, GenericBlock, GenericCall, GenericConsensusEngineId, GenericDigest, GenericDigestItem, GenericExtrinsic, GenericExtrinsicEra, GenericExtrinsicPayload, GenericImmortalEra, GenericMortalEra, GenericOrigin, H256, H512, Null, StorageData, StorageKey, u128, u32, u64, u8 } from '../../primitive'; /** GenericAccountId */ export type AccountId = GenericAccountId; @@ -134,9 +134,6 @@ export interface SignedBlock extends Struct { /** Signature */ export type Sr25519Signature = Signature; -/** Bytes */ -export type StorageData = Bytes; - /** AccountId */ export type ValidatorId = AccountId; diff --git a/packages/types/src/primitive/StorageData.ts b/packages/types/src/primitive/StorageData.ts new file mode 100644 index 0000000000..abdb934ff1 --- /dev/null +++ b/packages/types/src/primitive/StorageData.ts @@ -0,0 +1,17 @@ +// 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. + +import Bytes from './Bytes'; + +// NOTE Seperate class so StorageData !== Bytes, but rather an extension of it. +// Alternatively the construction check in Bytes will yield false positives for +// eg. StorageKey (which extends Bytes) + +/** + * @name StorageData + * @description + * Data retrieved via Storage queries and data for key-value pairs + */ +export default class StorageData extends Bytes { +} diff --git a/packages/types/src/primitive/index.ts b/packages/types/src/primitive/index.ts index 0fe1265909..705740ce7d 100644 --- a/packages/types/src/primitive/index.ts +++ b/packages/types/src/primitive/index.ts @@ -26,6 +26,7 @@ export { default as Fixed64 } from './I64Fixed'; export { default as i128 } from './I128'; export { default as i256 } from './I256'; export { default as Null } from './Null'; +export { default as StorageData } from './StorageData'; export { default as StorageHasher } from './StorageHasher'; export { default as StorageKey } from './StorageKey'; export { default as Text } from './Text';