From 7c8ec1f7f55d3c36f1c62ab8d382c0fedf25af7c Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 16 May 2019 11:11:32 +0200 Subject: [PATCH] Move additional types to primitive & rpc (#916) --- packages/api-derive/src/accounts/indexToId.ts | 2 +- packages/api-derive/src/accounts/indexes.ts | 2 +- packages/types/README.md | 32 +++++++++---------- packages/types/src/codec/Vector.spec.ts | 5 +-- .../src/{type => primitive}/AccountId.spec.ts | 2 +- .../src/{type => primitive}/AccountId.ts | 0 .../{type => primitive}/AccountIndex.spec.ts | 0 .../src/{type => primitive}/AccountIndex.ts | 5 +-- .../src/{type => primitive}/AccountInfo.ts | 4 +-- .../src/{type => primitive}/Address.spec.ts | 0 .../types/src/{type => primitive}/Address.ts | 0 .../types/src/{type => primitive}/Event.ts | 4 +-- .../{type => primitive}/EventRecord.spec.ts | 6 ++-- .../src/{type => primitive}/EventRecord.ts | 4 +-- .../types/src/{type => primitive}/Hash.ts | 3 +- .../src/{type => primitive}/Origin.spec.ts | 0 .../types/src/{type => primitive}/Origin.ts | 2 +- packages/types/src/primitive/index.ts | 8 +++++ packages/types/src/{type => rpc}/Block.ts | 4 +-- .../types/src/{type => rpc}/Digest.spec.ts | 0 packages/types/src/{type => rpc}/Digest.ts | 6 ++-- packages/types/src/rpc/ExtrinsicStatus.ts | 2 +- .../types/src/{type => rpc}/Header.spec.ts | 0 packages/types/src/{type => rpc}/Header.ts | 7 ++-- packages/types/src/rpc/PeerInfo.ts | 2 +- packages/types/src/rpc/SignedBlock.ts | 4 +-- packages/types/src/rpc/StorageChangeSet.ts | 2 +- packages/types/src/rpc/index.ts | 3 ++ packages/types/src/type/AttestedCandidate.ts | 4 +-- packages/types/src/type/AuthorityId.ts | 2 +- packages/types/src/type/Bft.ts | 2 +- packages/types/src/type/CodeHash.ts | 2 +- packages/types/src/type/ContractInfo.ts | 2 +- packages/types/src/type/EventIndex.ts | 13 -------- packages/types/src/type/Extrinsic.ts | 4 +-- packages/types/src/type/ExtrinsicSignature.ts | 4 +-- packages/types/src/type/IndividualExposure.ts | 2 +- packages/types/src/type/Justification.ts | 2 +- packages/types/src/type/MisbehaviorReport.ts | 2 +- packages/types/src/type/SeedOf.ts | 2 +- packages/types/src/type/SignaturePayload.ts | 6 ++-- packages/types/src/type/StakingLedger.ts | 2 +- packages/types/src/type/TreasuryProposal.ts | 2 +- packages/types/src/type/index.ts | 11 ------- packages/types/src/types.ts | 4 ++- 45 files changed, 83 insertions(+), 92 deletions(-) rename packages/types/src/{type => primitive}/AccountId.spec.ts (98%) rename packages/types/src/{type => primitive}/AccountId.ts (100%) rename packages/types/src/{type => primitive}/AccountIndex.spec.ts (100%) rename packages/types/src/{type => primitive}/AccountIndex.ts (98%) rename packages/types/src/{type => primitive}/AccountInfo.ts (91%) rename packages/types/src/{type => primitive}/Address.spec.ts (100%) rename packages/types/src/{type => primitive}/Address.ts (100%) rename packages/types/src/{type => primitive}/Event.ts (98%) rename packages/types/src/{type => primitive}/EventRecord.spec.ts (100%) rename packages/types/src/{type => primitive}/EventRecord.ts (97%) rename packages/types/src/{type => primitive}/Hash.ts (92%) rename packages/types/src/{type => primitive}/Origin.spec.ts (100%) rename packages/types/src/{type => primitive}/Origin.ts (93%) rename packages/types/src/{type => rpc}/Block.ts (93%) rename packages/types/src/{type => rpc}/Digest.spec.ts (100%) rename packages/types/src/{type => rpc}/Digest.ts (97%) rename packages/types/src/{type => rpc}/Header.spec.ts (100%) rename packages/types/src/{type => rpc}/Header.ts (96%) delete mode 100644 packages/types/src/type/EventIndex.ts diff --git a/packages/api-derive/src/accounts/indexToId.ts b/packages/api-derive/src/accounts/indexToId.ts index e2c3976ced..900fccf1aa 100644 --- a/packages/api-derive/src/accounts/indexToId.ts +++ b/packages/api-derive/src/accounts/indexToId.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; import { ApiInterface$Rx } from '@plugnet/api/types'; -import { ENUMSET_SIZE } from '@plugnet/types/type/AccountIndex'; +import { ENUMSET_SIZE } from '@plugnet/types/primitive/AccountIndex'; import { AccountId, AccountIndex, Vector } from '@plugnet/types'; import { drr } from '../util/drr'; diff --git a/packages/api-derive/src/accounts/indexes.ts b/packages/api-derive/src/accounts/indexes.ts index b9ee785710..796d28c7bf 100644 --- a/packages/api-derive/src/accounts/indexes.ts +++ b/packages/api-derive/src/accounts/indexes.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { map, switchMap } from 'rxjs/operators'; import { ApiInterface$Rx } from '@plugnet/api/types'; -import { ENUMSET_SIZE } from '@plugnet/types/type/AccountIndex'; +import { ENUMSET_SIZE } from '@plugnet/types/primitive/AccountIndex'; import { AccountId, AccountIndex } from '@plugnet/types'; import { drr } from '../util/drr'; diff --git a/packages/types/README.md b/packages/types/README.md index 74ebb2aad2..58212bf7af 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -6,7 +6,7 @@ On the Rust side, the codec types and primitive types are implemented via the [p ## Codec types -These are the base types of the codec. They are typically not used directly, but rather inherited from to create specific types. They are the building blocks for declaring custom types: +These are the base types of the codec. They are typically not used directly, but rather inherited from to create specific types. They are the building blocks for declaring custom types: | **Types** | | | --- | --- | @@ -33,12 +33,19 @@ These primitive types are available: | **Types** | | | --- | --- | +| [[AccountId]] | A wrapper around an AccountId/PublicKey representation | +| [[AccountIndex]] | A wrapper around an AccountIndex, which is a shortened, variable-length encoding for an Account | +| [[AccountInfo]] | An Account information structure for contracts | +| [[Address]] | A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix | | [[Bool]] | Representation for a boolean value in the system | | [[Bytes]] | A Bytes wrapper for `Vec` | | [[Data]] | A raw data structure. It is an encoding of a U8a without any length encoding | +| [[Event]] | Wrapper for the actual data that forms part of an [[Event]] | +| [[EventRecord]] | A record for an [[Event]] (as specified by [[Metadata]]) with the specific [[Phase]] of application | | [[H160]] | Hash containing 160 bits (20 bytes), typically used in blocks, extrinsics and as a sane default | | [[H256]] | Hash containing 256 bits (32 bytes), typically used in blocks, extrinsics and as a sane default | | [[H512]] | Hash containing 512 bits (64 bytes), typically used for signatures | +| [[Hash]] | The default hash that is used accross the system. It is just a thin wrapper around [[H256]] | [[I8]] | An 8-bit signed integer | | [[I16]] | A 16-bit signed integer | | [[I32]] | A 32-bit signed integer | @@ -48,6 +55,7 @@ These primitive types are available: | [[Method]] | Extrinsic function descriptor, as defined in [the extrinsic format for a node](https://github.com/paritytech/wiki/blob/master/Extrinsic.md#the-extrinsic-format-for-node) | | [[Moment]] | A wrapper around seconds/timestamps. Internally the representation only has second precicion (aligning with Rust) | | [[Null]] | Implements a type that does not contain anything (apart from `null`) | +| [[Origin]] | Where Origin occurs, it should be ignored as an internal-only value | | [[StorageData]] | Data retrieved via Storage queries and data for key-value pairs | | [[StorageKey]] | A representation of a storage key (typically hashed) in the system | | [[Text]] | This is a string wrapper, along with the length. | @@ -63,14 +71,10 @@ These primitive types are available: ## Substrate types -These custom types implement specific types that are found as part of the Substrate core. They're all extensions of one of the codec types: +These custom types implement specific types that are found as part of the Substrate core. They're all extensions of one of the codec types: | **Types** | | | --- | --- | -| [[AccountId]] | A wrapper around an AccountId/PublicKey representation | -| [[AccountIndex]] | A wrapper around an AccountIndex, which is a shortened, variable-length encoding for an Account | -| [[AccountInfo]] | An Account information structure for contracts | -| [[Address]] | A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix | | [[Amount]] | The Substrate Amount representation as a [[Balance]] | | [[AssetOf]] | The Substrate AssetOf representation as a [[Balance]] | | [[AttestedCandidate]] | An attested candidate | @@ -83,23 +87,15 @@ These custom types implement specific types that are found as part of the Substr | [[BftAuthoritySignature]] | Represents a Bft Hash and Signature pairing, typically used in reporting network behaviour | | [[BftHashSignature]] | Represents a Bft Hash and Signature pairing, typically used in reporting network behaviour | | [[BftProposeOutOfTurn]] | A report for out-of-turn proposals | -| [[Block]] | A block encoded with header and extrinsics | | [[BlockNumber]] | A representation of a Substrate BlockNumber, implemented as a [[U64]] | | [[CodeHash]] | The default contract code hash that is used accross the system | | [[Consensus]] | Log item indicating consensus | -| [[Digest]] | A [[Header]] Digest | -| [[DigestItem]] | A [[EnumType]] the specifies the specific item in the logs of a [[Digest]] | -| [[Event]] | Wrapper for the actual data that forms part of an [[Event]] | -| [[EventRecord]] | A record for an [[Event]] (as specified by [[Metadata]]) with the specific [[Phase]] of application | | [[Exposure]] | A snapshot of the stake backing a single validator in the system | | [[Extrinsic]] | Representation of an Extrinsic in the system | | [[ExtrinsicEra]] | The era for an extrinsic, indicating either a mortal or immortal extrinsic | | [[Extrinsics]] | A [[Vector]] of [[Extrinsic]] | | [[ExtrinsicSignature]] | A container for the [[Signature]] associated with a specific [[Extrinsic]] | | [[Gas]] | A gas number type for Substrate, extending [[U64]] | -| [[Hash]] | The default hash that is used accross the system. It is just a thin wrapper around [[H256]] | -| [[Header]] | A [[Block]] header | -| [[HeaderExtended]] | A [[Block]] header with an additional `author` field that indicates the block author] | | [[IndividualExposure]] | The Substrate IndividualExposure for staking | | [[InherentOfflineReport]] | Describes the offline-reporting extrinsic | | [[Justification]] | A generic justification as a stream of [[Bytes]], this is specific per consensus implementation | @@ -114,7 +110,6 @@ These custom types implement specific types that are found as part of the Substr | [[NextAuthority]] | The next authority available as [[SessionKey]] | | [[Nonce]] | The Nonce or number of transactions sent by a specific account | | [[NonceCompact]] | The Compact or number of transactions sent by a specific account | -| [[Origin]] | Where Origin occurs, it should be ignored as an internal-only value | | [[ParaId]] | Identifier for a deployed parachain implemented as a [[U32]] | | [[Perbill]] | Parts per billion (see also [[Permill]]) | | [[Permill]] | Parts per million (See also [[Perbill]]) | @@ -145,12 +140,17 @@ These custom types implement specific types that are found as part of the Substr ## RPC types -These types are not used in the runtime, but are rather used in RPC results: +These types are not used in the runtime, but are rather used in RPC results: | **Types** | | | --- | --- | +| [[Block]] | A block encoded with header and extrinsics | | [[ChainProperties]] | Wraps the properties retrieved from the chain via the `system.properties` RPC call | +| [[Digest]] | A [[Header]] Digest | +| [[DigestItem]] | A [[EnumType]] the specifies the specific item in the logs of a [[Digest]] | | [[ExtrinsicStatus]] | An EnumType that indicates the status of the Extrinsic as been submitted | +| [[Header]] | A [[Block]] header | +| [[HeaderExtended]] | A [[Block]] header with an additional `author` field that indicates the block author] | | [[Health]] | A system health indicator, reported back over RPC | | [[Json]] | Wraps the a JSON structure retrieve via RPC. It extends the standard JS Map | | [[NetworkState]] | Wraps the properties retrieved from the chain via the `system.network_state` RPC call | diff --git a/packages/types/src/codec/Vector.spec.ts b/packages/types/src/codec/Vector.spec.ts index d8e3f6688a..58101b33c0 100644 --- a/packages/types/src/codec/Vector.spec.ts +++ b/packages/types/src/codec/Vector.spec.ts @@ -2,14 +2,15 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { Codec, CodecTo } from '../types'; + import extrinsics from '@plugnet/extrinsics/static'; +import AccountId from '../primitive/AccountId'; import Method from '../primitive/Method'; import Text from '../primitive/Text'; import PropIndex from '../type/PropIndex'; import Proposal from '../type/Proposal'; -import AccountId from '../type/AccountId'; -import { Codec, CodecTo } from '../types'; import createType from './createType'; import Vector from './Vector'; import Tuple from './Tuple'; diff --git a/packages/types/src/type/AccountId.spec.ts b/packages/types/src/primitive/AccountId.spec.ts similarity index 98% rename from packages/types/src/type/AccountId.spec.ts rename to packages/types/src/primitive/AccountId.spec.ts index 799783b1fa..b9fa81a97c 100644 --- a/packages/types/src/type/AccountId.spec.ts +++ b/packages/types/src/primitive/AccountId.spec.ts @@ -7,7 +7,7 @@ import U8a from '../codec/U8a'; import Vector from '../codec/Vector'; import jsonVec from '../json/AccountIdVec.001.json'; import AccountId from './AccountId'; -import StorageData from '../primitive/StorageData'; +import StorageData from './StorageData'; describe('AccountId', () => { describe('defaults', () => { diff --git a/packages/types/src/type/AccountId.ts b/packages/types/src/primitive/AccountId.ts similarity index 100% rename from packages/types/src/type/AccountId.ts rename to packages/types/src/primitive/AccountId.ts diff --git a/packages/types/src/type/AccountIndex.spec.ts b/packages/types/src/primitive/AccountIndex.spec.ts similarity index 100% rename from packages/types/src/type/AccountIndex.spec.ts rename to packages/types/src/primitive/AccountIndex.spec.ts diff --git a/packages/types/src/type/AccountIndex.ts b/packages/types/src/primitive/AccountIndex.ts similarity index 98% rename from packages/types/src/type/AccountIndex.ts rename to packages/types/src/primitive/AccountIndex.ts index 9e1007af62..355c3f650e 100644 --- a/packages/types/src/type/AccountIndex.ts +++ b/packages/types/src/primitive/AccountIndex.ts @@ -2,12 +2,13 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { AnyNumber } from '../types'; + import BN from 'bn.js'; import { decodeAddress, encodeAddress } from '@plugnet/keyring'; import { bnToBn, isBn, isNumber, isU8a, isHex } from '@plugnet/util'; -import U32 from '../primitive/U32'; -import { AnyNumber } from '../types'; +import U32 from './U32'; export const ENUMSET_SIZE = new BN(64); diff --git a/packages/types/src/type/AccountInfo.ts b/packages/types/src/primitive/AccountInfo.ts similarity index 91% rename from packages/types/src/type/AccountInfo.ts rename to packages/types/src/primitive/AccountInfo.ts index 78ccb36370..5aa2ca29bc 100644 --- a/packages/types/src/type/AccountInfo.ts +++ b/packages/types/src/primitive/AccountInfo.ts @@ -3,8 +3,8 @@ // of the Apache-2.0 license. See the LICENSE file for details. import Struct from '../codec/Struct'; -import Bytes from '../primitive/Bytes'; -import U64 from '../primitive/U64'; +import Bytes from './Bytes'; +import U64 from './U64'; /** * @name AccountInfo diff --git a/packages/types/src/type/Address.spec.ts b/packages/types/src/primitive/Address.spec.ts similarity index 100% rename from packages/types/src/type/Address.spec.ts rename to packages/types/src/primitive/Address.spec.ts diff --git a/packages/types/src/type/Address.ts b/packages/types/src/primitive/Address.ts similarity index 100% rename from packages/types/src/type/Address.ts rename to packages/types/src/primitive/Address.ts diff --git a/packages/types/src/type/Event.ts b/packages/types/src/primitive/Event.ts similarity index 98% rename from packages/types/src/type/Event.ts rename to packages/types/src/primitive/Event.ts index 95ced0765a..f7c1f552b8 100644 --- a/packages/types/src/type/Event.ts +++ b/packages/types/src/primitive/Event.ts @@ -10,11 +10,11 @@ import Struct from '../codec/Struct'; import Tuple from '../codec/Tuple'; import U8aFixed from '../codec/U8aFixed'; import { TypeDef, getTypeClass, getTypeDef } from '../codec/createType'; -import Null from '../primitive/Null'; -import U32 from '../primitive/U32'; import Metadata from '../Metadata'; import { EventMetadata as EventMetadataV0 } from '../Metadata/v0/Events'; import { MetadataEvent as EventMetadataV4 } from '../Metadata/v1/Events'; +import Null from './Null'; +import U32 from './U32'; const EventTypes: { [index: string]: Constructor } = {}; diff --git a/packages/types/src/type/EventRecord.spec.ts b/packages/types/src/primitive/EventRecord.spec.ts similarity index 100% rename from packages/types/src/type/EventRecord.spec.ts rename to packages/types/src/primitive/EventRecord.spec.ts index e61e669346..3c05ddc6a5 100644 --- a/packages/types/src/type/EventRecord.spec.ts +++ b/packages/types/src/primitive/EventRecord.spec.ts @@ -7,12 +7,12 @@ import Vector from '../codec/Vector'; import json1 from '../json/EventRecord.001.json'; import json2 from '../json/EventRecord.002.json'; import json3 from '../json/EventRecord.003.json'; -import AccountId from './AccountId'; -import Event from './Event'; -import EventRecord from './EventRecord'; import Metadata from '../Metadata'; import metadataV0 from '../Metadata/v0/static'; import metadataV1 from '../Metadata/static'; +import AccountId from './AccountId'; +import Event from './Event'; +import EventRecord from './EventRecord'; describe('EventRecord', () => { describe('v0', () => { diff --git a/packages/types/src/type/EventRecord.ts b/packages/types/src/primitive/EventRecord.ts similarity index 97% rename from packages/types/src/type/EventRecord.ts rename to packages/types/src/primitive/EventRecord.ts index 6d7c6c3f1d..8fab5ffeb3 100644 --- a/packages/types/src/type/EventRecord.ts +++ b/packages/types/src/primitive/EventRecord.ts @@ -7,10 +7,10 @@ import { assert } from '@plugnet/util'; import EnumType from '../codec/EnumType'; import Struct from '../codec/Struct'; import Vector from '../codec/Vector'; -import Null from '../primitive/Null'; -import U32 from '../primitive/U32'; import Hash from './Hash'; import Event from './Event'; +import Null from './Null'; +import U32 from './U32'; /** * @name ApplyExtrinsic diff --git a/packages/types/src/type/Hash.ts b/packages/types/src/primitive/Hash.ts similarity index 92% rename from packages/types/src/type/Hash.ts rename to packages/types/src/primitive/Hash.ts index a4d98a3921..f7f6b6d51b 100644 --- a/packages/types/src/type/Hash.ts +++ b/packages/types/src/primitive/Hash.ts @@ -3,7 +3,8 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { IHash } from '../types'; -import H256 from '../primitive/H256'; + +import H256 from './H256'; /** * @name Hash diff --git a/packages/types/src/type/Origin.spec.ts b/packages/types/src/primitive/Origin.spec.ts similarity index 100% rename from packages/types/src/type/Origin.spec.ts rename to packages/types/src/primitive/Origin.spec.ts diff --git a/packages/types/src/type/Origin.ts b/packages/types/src/primitive/Origin.ts similarity index 93% rename from packages/types/src/type/Origin.ts rename to packages/types/src/primitive/Origin.ts index 7246b6d6f1..12e0ba4839 100644 --- a/packages/types/src/type/Origin.ts +++ b/packages/types/src/primitive/Origin.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 Null from '../primitive/Null'; +import Null from './Null'; /** * @name Origin diff --git a/packages/types/src/primitive/index.ts b/packages/types/src/primitive/index.ts index 8c902dabf2..8c18a7172c 100644 --- a/packages/types/src/primitive/index.ts +++ b/packages/types/src/primitive/index.ts @@ -10,12 +10,19 @@ */ // NOTE We are exporting Bool as bool to match with Rust (however also using Bool internally), // so with the renamed versions, epose both cases, allowing createType to work +export { default as AccountId, AccountIdOf } from './AccountId'; +export { default as AccountIndex } from './AccountIndex'; +export { default as AccountInfo } from './AccountInfo'; +export { default as Address } from './Address'; +export { default as Event, EventIndex } from './Event'; +export { default as EventRecord, EventRecord77 } from './EventRecord'; export { default as Bool, default as bool } from './Bool'; export { default as Bytes } from './Bytes'; export { default as Data } from './Data'; export { default as H160 } from './H160'; export { default as H256 } from './H256'; export { default as H512 } from './H512'; +export { default as Hash } from './Hash'; export { default as I8, default as i8 } from './I8'; export { default as I16, default as i16 } from './I16'; export { default as I32, default as i32 } from './I32'; @@ -25,6 +32,7 @@ export { default as I256, default as i256 } from './I256'; export { default as Method } from './Method'; export { default as Moment, MomentOf } from './Moment'; export { default as Null } from './Null'; +export { default as Origin } from './Origin'; export { default as StorageData } from './StorageData'; export { default as StorageHasher } from './StorageHasher'; export { default as StorageKey } from './StorageKey'; diff --git a/packages/types/src/type/Block.ts b/packages/types/src/rpc/Block.ts similarity index 93% rename from packages/types/src/type/Block.ts rename to packages/types/src/rpc/Block.ts index 505ed1a30f..25ea2565b4 100644 --- a/packages/types/src/type/Block.ts +++ b/packages/types/src/rpc/Block.ts @@ -7,8 +7,8 @@ import { AnyU8a } from '../types'; import { blake2AsU8a } from '@plugnet/util-crypto'; import Struct from '../codec/Struct'; -import Extrinsics from './Extrinsics'; -import Hash from './Hash'; +import Hash from '../primitive/Hash'; +import Extrinsics from '../type/Extrinsics'; import Header, { HeaderValue } from './Header'; export type BlockValue = { diff --git a/packages/types/src/type/Digest.spec.ts b/packages/types/src/rpc/Digest.spec.ts similarity index 100% rename from packages/types/src/type/Digest.spec.ts rename to packages/types/src/rpc/Digest.spec.ts diff --git a/packages/types/src/type/Digest.ts b/packages/types/src/rpc/Digest.ts similarity index 97% rename from packages/types/src/type/Digest.ts rename to packages/types/src/rpc/Digest.ts index 764af2db23..7303612e44 100644 --- a/packages/types/src/type/Digest.ts +++ b/packages/types/src/rpc/Digest.ts @@ -9,11 +9,11 @@ import Struct from '../codec/Struct'; import Tuple from '../codec/Tuple'; import Vector from '../codec/Vector'; import Bytes from '../primitive/Bytes'; +import Hash from '../primitive/Hash'; import U32 from '../primitive/U32'; import U64 from '../primitive/U64'; -import AuthorityId from './AuthorityId'; -import Hash from './Hash'; -import Signature from './Signature'; +import AuthorityId from '../type/AuthorityId'; +import Signature from '../type/Signature'; /** * @name AuthoritiesChange diff --git a/packages/types/src/rpc/ExtrinsicStatus.ts b/packages/types/src/rpc/ExtrinsicStatus.ts index a3560abdf3..b8f72565b8 100644 --- a/packages/types/src/rpc/ExtrinsicStatus.ts +++ b/packages/types/src/rpc/ExtrinsicStatus.ts @@ -6,9 +6,9 @@ import { assert } from '@plugnet/util'; import EnumType from '../codec/EnumType'; import Vector from '../codec/Vector'; +import Hash from '../primitive/Hash'; import Null from '../primitive/Null'; import Text from '../primitive/Text'; -import Hash from '../type/Hash'; /** * @name Broadcast diff --git a/packages/types/src/type/Header.spec.ts b/packages/types/src/rpc/Header.spec.ts similarity index 100% rename from packages/types/src/type/Header.spec.ts rename to packages/types/src/rpc/Header.spec.ts diff --git a/packages/types/src/type/Header.ts b/packages/types/src/rpc/Header.ts similarity index 96% rename from packages/types/src/type/Header.ts rename to packages/types/src/rpc/Header.ts index 55cdc01752..c46fcd816a 100644 --- a/packages/types/src/type/Header.ts +++ b/packages/types/src/rpc/Header.ts @@ -9,11 +9,10 @@ import { blake2AsU8a } from '@plugnet/util-crypto'; import Compact from '../codec/Compact'; import Struct from '../codec/Struct'; import U64 from '../primitive/U64'; - -import AccountId from './AccountId'; -import BlockNumber from './BlockNumber'; +import AccountId from '../primitive/AccountId'; +import Hash from '../primitive/Hash'; +import BlockNumber from '../type/BlockNumber'; import Digest, { DigestItem } from './Digest'; -import Hash from './Hash'; export type HeaderValue = { digest?: Digest | { logs: DigestItem[] }, diff --git a/packages/types/src/rpc/PeerInfo.ts b/packages/types/src/rpc/PeerInfo.ts index 3d86d0a9e4..2d6c446be0 100644 --- a/packages/types/src/rpc/PeerInfo.ts +++ b/packages/types/src/rpc/PeerInfo.ts @@ -5,8 +5,8 @@ import Struct from '../codec/Struct'; import Text from '../primitive/Text'; import U32 from '../primitive/U32'; +import Hash from '../primitive/Hash'; import BlockNumber from '../type/BlockNumber'; -import Hash from '../type/Hash'; const JSON_MAP = new Map([ ['bestHash', 'best_hash'], diff --git a/packages/types/src/rpc/SignedBlock.ts b/packages/types/src/rpc/SignedBlock.ts index 1182966ec3..7c7ba495e5 100644 --- a/packages/types/src/rpc/SignedBlock.ts +++ b/packages/types/src/rpc/SignedBlock.ts @@ -5,9 +5,9 @@ import { AnyU8a } from '../types'; import Struct from '../codec/Struct'; -import Block, { BlockValue } from '../type/Block'; -import Hash from '../type/Hash'; +import Hash from '../primitive/Hash'; import Justification from '../type/Justification'; +import Block, { BlockValue } from './Block'; type SignedBlockValue = { block?: BlockValue, diff --git a/packages/types/src/rpc/StorageChangeSet.ts b/packages/types/src/rpc/StorageChangeSet.ts index 15758066b2..61015f2d33 100644 --- a/packages/types/src/rpc/StorageChangeSet.ts +++ b/packages/types/src/rpc/StorageChangeSet.ts @@ -6,7 +6,7 @@ import { AnyU8a } from '../types'; import Struct from '../codec/Struct'; import Vector from '../codec/Vector'; -import Hash from '../type/Hash'; +import Hash from '../primitive/Hash'; import { KeyValueOption, KeyValueOptionValue } from '../type/KeyValue'; type StorageChangeSetValue = { diff --git a/packages/types/src/rpc/index.ts b/packages/types/src/rpc/index.ts index c791d1e880..ecb66ef92a 100644 --- a/packages/types/src/rpc/index.ts +++ b/packages/types/src/rpc/index.ts @@ -8,8 +8,11 @@ /** * @summary Type definitions that are used in the rpc */ +export { default as Block } from './Block'; export { default as ChainProperties } from './ChainProperties'; +export { default as Digest, DigestItem } from './Digest'; export { default as ExtrinsicStatus } from './ExtrinsicStatus'; +export { default as Header, HeaderExtended } from './Header'; export { default as Health } from './Health'; export { default as Json } from './Json'; export { default as NetworkState } from './NetworkState'; diff --git a/packages/types/src/type/AttestedCandidate.ts b/packages/types/src/type/AttestedCandidate.ts index 9f2b8cd4e8..416113b895 100644 --- a/packages/types/src/type/AttestedCandidate.ts +++ b/packages/types/src/type/AttestedCandidate.ts @@ -8,11 +8,11 @@ import EnumType from '../codec/EnumType'; import Struct from '../codec/Struct'; import Tuple from '../codec/Tuple'; import Vector from '../codec/Vector'; +import AccountId from '../primitive/AccountId'; import Bytes from '../primitive/Bytes'; +import Hash from '../primitive/Hash'; import Null from '../primitive/Null'; import U64 from '../primitive/U64'; -import AccountId from './AccountId'; -import Hash from './Hash'; import ParaId from './ParaId'; import Signature from './Signature'; import SessionKey from './SessionKey'; diff --git a/packages/types/src/type/AuthorityId.ts b/packages/types/src/type/AuthorityId.ts index f8bf6dd3ef..bdbbeb5fbe 100644 --- a/packages/types/src/type/AuthorityId.ts +++ b/packages/types/src/type/AuthorityId.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 AccountId from './AccountId'; +import AccountId from '../primitive/AccountId'; // Wrapper for a AuthorityId. Same as an normal AccountId, i.e. a wrapper // around publicKey, however specialized since it specifically points to diff --git a/packages/types/src/type/Bft.ts b/packages/types/src/type/Bft.ts index 09f73bb1ba..3f9364e1a2 100644 --- a/packages/types/src/type/Bft.ts +++ b/packages/types/src/type/Bft.ts @@ -5,8 +5,8 @@ import { AnyU8a } from '../types'; import Tuple from '../codec/Tuple'; +import Hash from '../primitive/Hash'; import AuthorityId from './AuthorityId'; -import Hash from './Hash'; import Signature from './Signature'; export type BftAuthoritySignatureValue = [AnyU8a, AnyU8a]; diff --git a/packages/types/src/type/CodeHash.ts b/packages/types/src/type/CodeHash.ts index 27b1fc8f74..e46837033e 100644 --- a/packages/types/src/type/CodeHash.ts +++ b/packages/types/src/type/CodeHash.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 Hash from './Hash'; +import Hash from '../primitive/Hash'; /** * @name CodeHash diff --git a/packages/types/src/type/ContractInfo.ts b/packages/types/src/type/ContractInfo.ts index e8d3eded16..e32c8d1bc6 100644 --- a/packages/types/src/type/ContractInfo.ts +++ b/packages/types/src/type/ContractInfo.ts @@ -7,11 +7,11 @@ import { assert } from '@plugnet/util'; import Bytes from '../primitive/Bytes'; import EnumType from '../codec/EnumType'; import Struct from '../codec/Struct'; +import Hash from '../primitive/Hash'; import U64 from '../primitive/U64'; import Balance from './Balance'; import BlockNumber from './BlockNumber'; import CodeHash from './CodeHash'; -import Hash from './Hash'; export class TrieId extends Bytes { } diff --git a/packages/types/src/type/EventIndex.ts b/packages/types/src/type/EventIndex.ts deleted file mode 100644 index 547b189b86..0000000000 --- a/packages/types/src/type/EventIndex.ts +++ /dev/null @@ -1,13 +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. - -import U32 from '../primitive/U32'; - -/** - * @name EventIndex - * @description - * The Substrate EventIndex representation as a [[U32]]. - */ -export default class EventIndex extends U32 { -} diff --git a/packages/types/src/type/Extrinsic.ts b/packages/types/src/type/Extrinsic.ts index cb042db97d..6abac30df7 100644 --- a/packages/types/src/type/Extrinsic.ts +++ b/packages/types/src/type/Extrinsic.ts @@ -12,9 +12,9 @@ import Compact from '../codec/Compact'; import Struct from '../codec/Struct'; import { FunctionMetadata } from '../Metadata/v0/Modules'; import Method from '../primitive/Method'; -import Address from './Address'; +import Address from '../primitive/Address'; +import Hash from '../primitive/Hash'; import ExtrinsicSignature from './ExtrinsicSignature'; -import Hash from './Hash'; type ExtrinsicValue = { method?: Method diff --git a/packages/types/src/type/ExtrinsicSignature.ts b/packages/types/src/type/ExtrinsicSignature.ts index 3b203d055d..3b30353bec 100644 --- a/packages/types/src/type/ExtrinsicSignature.ts +++ b/packages/types/src/type/ExtrinsicSignature.ts @@ -6,12 +6,12 @@ import { KeyringPair } from '@plugnet/keyring/types'; import { AnyNumber, IExtrinsicSignature, SignatureOptions } from '../types'; import Struct from '../codec/Struct'; -import Address from './Address'; +import Address from '../primitive/Address'; import Method from '../primitive/Method'; import U8 from '../primitive/U8'; +import RuntimeVersion from '../rpc/RuntimeVersion'; import ExtrinsicEra from './ExtrinsicEra'; import Nonce from './NonceCompact'; -import RuntimeVersion from '../rpc/RuntimeVersion'; import Signature from './Signature'; import SignaturePayload from './SignaturePayload'; diff --git a/packages/types/src/type/IndividualExposure.ts b/packages/types/src/type/IndividualExposure.ts index d19993ce47..ba040b4f49 100644 --- a/packages/types/src/type/IndividualExposure.ts +++ b/packages/types/src/type/IndividualExposure.ts @@ -4,7 +4,7 @@ import Compact from '../codec/Compact'; import Struct from '../codec/Struct'; -import AccountId from './AccountId'; +import AccountId from '../primitive/AccountId'; import Balance from './Balance'; /** diff --git a/packages/types/src/type/Justification.ts b/packages/types/src/type/Justification.ts index 88400b4557..c2022304a8 100644 --- a/packages/types/src/type/Justification.ts +++ b/packages/types/src/type/Justification.ts @@ -7,8 +7,8 @@ import { AnyNumber, AnyU8a } from '../types'; import Struct from '../codec/Struct'; import Vector from '../codec/Vector'; import Bytes from '../primitive/Bytes'; +import Hash from '../primitive/Hash'; import U32 from '../primitive/U32'; -import Hash from './Hash'; import { BftAuthoritySignature, BftAuthoritySignatureValue } from './Bft'; export type RhdJustificationValue = { diff --git a/packages/types/src/type/MisbehaviorReport.ts b/packages/types/src/type/MisbehaviorReport.ts index dc1c03c11b..25b4d14225 100644 --- a/packages/types/src/type/MisbehaviorReport.ts +++ b/packages/types/src/type/MisbehaviorReport.ts @@ -8,11 +8,11 @@ import { assert } from '@plugnet/util'; import EnumType from '../codec/EnumType'; import Struct from '../codec/Struct'; +import Hash from '../primitive/Hash'; import U32 from '../primitive/U32'; import AuthorityId from './AuthorityId'; import { BftHashSignature, BftHashSignatureValue } from './Bft'; import BlockNumber from './BlockNumber'; -import Hash from './Hash'; type BftAtReportValueSingle = { round?: AnyNumber, diff --git a/packages/types/src/type/SeedOf.ts b/packages/types/src/type/SeedOf.ts index 2661acf12c..c724fbc7f4 100644 --- a/packages/types/src/type/SeedOf.ts +++ b/packages/types/src/type/SeedOf.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 Hash from './Hash'; +import Hash from '../primitive/Hash'; /** * @name SeedOf diff --git a/packages/types/src/type/SignaturePayload.ts b/packages/types/src/type/SignaturePayload.ts index e928dcddac..4a19c0bc34 100644 --- a/packages/types/src/type/SignaturePayload.ts +++ b/packages/types/src/type/SignaturePayload.ts @@ -8,11 +8,11 @@ import { AnyNumber, AnyU8a } from '../types'; import { blake2AsU8a } from '@plugnet/util-crypto'; import Struct from '../codec/Struct'; -import ExtrinsicEra from './ExtrinsicEra'; -import Hash from './Hash'; +import Hash from '../primitive/Hash'; import Method from '../primitive/Method'; -import Nonce from './NonceCompact'; import RuntimeVersion from '../rpc/RuntimeVersion'; +import ExtrinsicEra from './ExtrinsicEra'; +import Nonce from './NonceCompact'; type SignaturePayloadValue = { nonce?: AnyNumber, diff --git a/packages/types/src/type/StakingLedger.ts b/packages/types/src/type/StakingLedger.ts index d946821738..ee07505580 100644 --- a/packages/types/src/type/StakingLedger.ts +++ b/packages/types/src/type/StakingLedger.ts @@ -5,7 +5,7 @@ import Compact from '../codec/Compact'; import Struct from '../codec/Struct'; import Vector from '../codec/Vector'; -import AccountId from './AccountId'; +import AccountId from '../primitive/AccountId'; import Balance from './Balance'; import BlockNumber from './BlockNumber'; import UnlockChunk from './UnlockChunk'; diff --git a/packages/types/src/type/TreasuryProposal.ts b/packages/types/src/type/TreasuryProposal.ts index 682bf27238..0f33e0011c 100644 --- a/packages/types/src/type/TreasuryProposal.ts +++ b/packages/types/src/type/TreasuryProposal.ts @@ -3,7 +3,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import Struct from '../codec/Struct'; -import AccountId from './AccountId'; +import AccountId from '../primitive/AccountId'; import Balance from './Balance'; /** diff --git a/packages/types/src/type/index.ts b/packages/types/src/type/index.ts index 6d301f7a42..18f45221bb 100644 --- a/packages/types/src/type/index.ts +++ b/packages/types/src/type/index.ts @@ -8,10 +8,6 @@ /** * @summary Type definitions that are used in the system */ -export { default as AccountId, AccountIdOf } from './AccountId'; -export { default as AccountIndex } from './AccountIndex'; -export { default as AccountInfo } from './AccountInfo'; -export { default as Address } from './Address'; export { default as Amount } from './Amount'; export { default as AssetOf } from './AssetOf'; export { default as AttestedCandidate } from './AttestedCandidate'; @@ -20,13 +16,9 @@ export { default as Balance, BalanceOf } from './Balance'; export { default as BalanceLock } from './BalanceLock'; // NOTE Bft items are only used in internal structures // export * from './Bft; -export { default as Block } from './Block'; export { default as BlockNumber } from './BlockNumber'; export { default as CodeHash } from './CodeHash'; export { default as ContractInfo } from './ContractInfo'; -export { default as Digest, DigestItem } from './Digest'; -export { default as Event, EventIndex } from './Event'; -export { default as EventRecord, EventRecord77 } from './EventRecord'; export { default as Exposure } from './Exposure'; export { default as Extrinsic } from './Extrinsic'; export { default as ExtrinsicEra } from './ExtrinsicEra'; @@ -34,8 +26,6 @@ export { default as ExtrinsicSignature } from './ExtrinsicSignature'; // NOTE Only used internally, exported as PendingExtrinsics // export { default as Extrinsics } from './Extrinsics'; export { default as Gas } from './Gas'; -export { default as Hash } from './Hash'; -export { default as Header, HeaderExtended } from './Header'; export { default as IndividualExposure } from './IndividualExposure'; export { default as InherentOfflineReport } from './InherentOfflineReport'; export { default as Key } from './Key'; @@ -48,7 +38,6 @@ export { default as NewAccountOutcome } from './NewAccountOutcome'; export { default as Index } from './Nonce'; export { default as IndexCompact } from './NonceCompact'; export { default as Justification } from './Justification'; -export { default as Origin } from './Origin'; export { default as ParaId } from './ParaId'; export { default as Permill } from './Permill'; export { default as Perbill } from './Perbill'; diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index f6b143f063..7c8b3686b6 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -3,10 +3,12 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { KeyringPair } from '@plugnet/keyring/types'; + import BN from 'bn.js'; + import U8a from './codec/U8a'; import Method from './primitive/Method'; -import Address from './type/Address'; +import Address from './primitive/Address'; import { FunctionMetadata } from './Metadata/v0/Modules'; export type CodecArg = Codec | BN | Boolean | String | Uint8Array | boolean | number | string | undefined | CodecArgArray | CodecArgObject;