From ad59abfc37526a09e7ebd9631c8420596433b897 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 28 Apr 2023 10:23:04 +0300 Subject: [PATCH] Adjust spread usage in types/interfaces (#5610) --- packages/types/src/interfaces/alias.ts | 10 +-- packages/types/src/interfaces/babe/runtime.ts | 16 ++-- .../src/interfaces/blockbuilder/runtime.ts | 40 ++++++---- .../types/src/interfaces/contracts/runtime.ts | 16 ++-- .../interfaces/contractsAbi/definitions.ts | 73 +++++++++---------- .../src/interfaces/contractsAbi/types.ts | 5 +- .../types/src/interfaces/eth/definitions.ts | 9 ++- packages/types/src/interfaces/eth/rpc.ts | 8 +- .../types/src/interfaces/grandpa/runtime.ts | 9 +-- .../src/interfaces/metadata/definitions.ts | 12 ++- .../types/src/interfaces/metadata/runtime.ts | 13 ++-- packages/types/src/interfaces/metadata/v14.ts | 19 +++-- .../src/interfaces/parachains/definitions.ts | 11 ++- .../src/interfaces/parachains/runtime.ts | 27 +++++-- .../types/src/interfaces/parachains/slots.ts | 7 +- .../types/src/interfaces/payment/runtime.ts | 67 ++++++++--------- .../src/interfaces/runtime/definitions.ts | 7 +- .../types/src/interfaces/runtime/runtime.ts | 32 +++++--- .../src/interfaces/scaleInfo/definitions.ts | 8 +- .../src/interfaces/session/definitions.ts | 7 +- .../src/interfaces/staking/definitions.ts | 8 +- .../types/src/interfaces/xcm/definitions.ts | 11 ++- 22 files changed, 224 insertions(+), 191 deletions(-) diff --git a/packages/types/src/interfaces/alias.ts b/packages/types/src/interfaces/alias.ts index ddb3f1cd58..2d12e62293 100644 --- a/packages/types/src/interfaces/alias.ts +++ b/packages/types/src/interfaces/alias.ts @@ -3,8 +3,6 @@ import type { OverrideModuleType, Registry } from '../types/index.js'; -import { objectSpread } from '@polkadot/util'; - // type overrides for modules (where duplication between modules exist) const typesAlias: Record = { assets: { @@ -111,8 +109,8 @@ const typesAlias: Record = { * @description Get types for specific modules (metadata override) */ export function getAliasTypes ({ knownTypes }: Registry, section: string): OverrideModuleType { - return objectSpread({}, - typesAlias[section], - knownTypes.typesAlias?.[section] - ); + return { + ...(typesAlias[section] ?? {}), + ...(knownTypes.typesAlias?.[section] ?? {}) + }; } diff --git a/packages/types/src/interfaces/babe/runtime.ts b/packages/types/src/interfaces/babe/runtime.ts index 79990a357b..a379971717 100644 --- a/packages/types/src/interfaces/babe/runtime.ts +++ b/packages/types/src/interfaces/babe/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionCall, DefinitionsCall } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const V1_V2_SHARED: Record = { current_epoch: { description: 'Returns information regarding the current epoch.', @@ -54,23 +52,25 @@ const V1_V2_SHARED: Record = { export const runtime: DefinitionsCall = { BabeApi: [ { - methods: objectSpread({ + methods: { configuration: { description: 'Return the genesis configuration for BABE. The configuration is only read on genesis.', params: [], type: 'BabeGenesisConfiguration' - } - }, V1_V2_SHARED), + }, + ...V1_V2_SHARED + }, version: 2 }, { - methods: objectSpread({ + methods: { configuration: { description: 'Return the configuration for BABE. Version 1.', params: [], type: 'BabeGenesisConfigurationV1' - } - }, V1_V2_SHARED), + }, + ...V1_V2_SHARED + }, version: 1 } ] diff --git a/packages/types/src/interfaces/blockbuilder/runtime.ts b/packages/types/src/interfaces/blockbuilder/runtime.ts index 9fb33a52b4..3cac9d7d62 100644 --- a/packages/types/src/interfaces/blockbuilder/runtime.ts +++ b/packages/types/src/interfaces/blockbuilder/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const BB_V2_TO_V4: DefinitionsCallEntry['methods'] = { // this was removed after V4 random_seed: { @@ -66,7 +64,7 @@ const BB_V3_TO_V6: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { BlockBuilder: [ { - methods: objectSpread({ + methods: { apply_extrinsic: { description: 'Apply the given extrinsic.', params: [ @@ -76,36 +74,50 @@ export const runtime: DefinitionsCall = { } ], type: 'ApplyExtrinsicResult' - } - }, BB_V2_TO_V6, BB_V3_TO_V6), + }, + ...BB_V2_TO_V6, + ...BB_V3_TO_V6 + }, version: 6 }, { - methods: objectSpread({ + methods: { // apply_extrinsic result changed in 6 - }, BB_V2_TO_V5, BB_V2_TO_V6, BB_V3_TO_V6), + ...BB_V2_TO_V5, + ...BB_V2_TO_V6, + ...BB_V3_TO_V6 + }, version: 5 }, { - methods: objectSpread({ + methods: { // random_seed removed - }, BB_V2_TO_V4, BB_V2_TO_V5, BB_V2_TO_V6, BB_V3_TO_V6), + ...BB_V2_TO_V4, + ...BB_V2_TO_V5, + ...BB_V2_TO_V6, + ...BB_V3_TO_V6 + }, version: 4 }, { - methods: objectSpread({ + methods: { // finalize_block renamed - }, BB_V2_TO_V4, BB_V2_TO_V6, BB_V3_TO_V6), + ...BB_V2_TO_V4, + ...BB_V2_TO_V6, + ...BB_V3_TO_V6 + }, version: 3 }, { - methods: objectSpread({ + methods: { finalise_block: { description: 'Finish the current block.', params: [], type: 'Header' - } - }, BB_V2_TO_V4, BB_V2_TO_V6), + }, + ...BB_V2_TO_V4, + ...BB_V2_TO_V6 + }, version: 2 } ] diff --git a/packages/types/src/interfaces/contracts/runtime.ts b/packages/types/src/interfaces/contracts/runtime.ts index e99cee7663..6b075e3d78 100644 --- a/packages/types/src/interfaces/contracts/runtime.ts +++ b/packages/types/src/interfaces/contracts/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionCall, DefinitionsCall } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const SHARED_V1_V2: Record = { get_storage: { description: 'Query a given storage key in a given contract.', @@ -43,7 +41,7 @@ const SHARED_V1_V2: Record = { export const runtime: DefinitionsCall = { ContractsApi: [ { - methods: objectSpread({ + methods: { call: { description: 'Perform a call from a specified account to a given contract.', params: [ @@ -107,12 +105,13 @@ export const runtime: DefinitionsCall = { } ], type: 'ContractInstantiateResult' - } - }, SHARED_V1_V2), + }, + ...SHARED_V1_V2 + }, version: 2 }, { - methods: objectSpread({ + methods: { call: { description: 'Perform a call from a specified account to a given contract.', params: [ @@ -176,8 +175,9 @@ export const runtime: DefinitionsCall = { } ], type: 'ContractInstantiateResultU64' - } - }, SHARED_V1_V2), + }, + ...SHARED_V1_V2 + }, version: 1 } ] diff --git a/packages/types/src/interfaces/contractsAbi/definitions.ts b/packages/types/src/interfaces/contractsAbi/definitions.ts index 0670cf66b7..db62ccdbbf 100644 --- a/packages/types/src/interfaces/contractsAbi/definitions.ts +++ b/packages/types/src/interfaces/contractsAbi/definitions.ts @@ -3,8 +3,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - // order important in structs... :) /* eslint-disable sort-keys */ @@ -177,34 +175,6 @@ const spec = { } }; -const ContractMetadataV0 = { - metadataVersion: 'Text', - types: 'Vec', - spec: 'ContractContractSpecV0' -}; - -const ContractMetadataV1 = { - types: 'Vec', - spec: 'ContractContractSpecV1' -}; - -const ContractMetadataV2 = { - types: 'Vec', - spec: 'ContractContractSpecV2' -}; - -const ContractMetadataV3 = { - types: 'Vec', - spec: 'ContractContractSpecV3' -}; - -const ContractMetadataV4 = ContractMetadataV3; - -const ContractProjectInfo = { - source: 'ContractProjectSource', - contract: 'ContractProjectContract' -}; - const latest = { ContractConstructorSpecLatest: 'ContractConstructorSpecV3', ContractEventSpecLatest: 'ContractEventSpecV2', @@ -216,13 +186,32 @@ const latest = { export default { rpc: {}, - types: objectSpread({}, layout, spec, latest, { - ContractProjectInfo, - ContractMetadataV0, - ContractMetadataV1, - ContractMetadataV2, - ContractMetadataV3, - ContractMetadataV4, + types: { + ...layout, + ...spec, + ...latest, + ContractProjectInfo: { + source: 'ContractProjectSource', + contract: 'ContractProjectContract' + }, + ContractMetadataV0: { + metadataVersion: 'Text', + types: 'Vec', + spec: 'ContractContractSpecV0' + }, + ContractMetadataV1: { + types: 'Vec', + spec: 'ContractContractSpecV1' + }, + ContractMetadataV2: { + types: 'Vec', + spec: 'ContractContractSpecV2' + }, + ContractMetadataV3: { + types: 'Vec', + spec: 'ContractContractSpecV3' + }, + ContractMetadataV4: 'ContractMetadataV3', ContractMetadata: { _enum: { V0: 'ContractMetadataV0', @@ -232,7 +221,13 @@ export default { V4: 'ContractMetadataV4' } }, - ContractProjectV0: objectSpread({ metadataVersion: 'Text' }, ContractProjectInfo, ContractMetadataV0), + ContractProjectV0: { + metadataVersion: 'Text', + source: 'ContractProjectSource', + contract: 'ContractProjectContract', + types: 'Vec', + spec: 'ContractContractSpecV0' + }, ContractProject: '(ContractProjectInfo, ContractMetadata)', ContractProjectContract: { _alias: { @@ -256,5 +251,5 @@ export default { compiler: 'Text', wasm: 'Raw' } - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/contractsAbi/types.ts b/packages/types/src/interfaces/contractsAbi/types.ts index f58598897b..f12a2f0c82 100644 --- a/packages/types/src/interfaces/contractsAbi/types.ts +++ b/packages/types/src/interfaces/contractsAbi/types.ts @@ -277,10 +277,7 @@ export interface ContractMetadataV3 extends Struct { } /** @name ContractMetadataV4 */ -export interface ContractMetadataV4 extends Struct { - readonly types: Vec; - readonly spec: ContractContractSpecV3; -} +export interface ContractMetadataV4 extends ContractMetadataV3 {} /** @name ContractProject */ export interface ContractProject extends ITuple<[ContractProjectInfo, ContractMetadata]> {} diff --git a/packages/types/src/interfaces/eth/definitions.ts b/packages/types/src/interfaces/eth/definitions.ts index 515f9c213b..fd5f0f33f1 100644 --- a/packages/types/src/interfaces/eth/definitions.ts +++ b/packages/types/src/interfaces/eth/definitions.ts @@ -8,8 +8,6 @@ import type { DefinitionsTypes } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { rpc } from './rpc.js'; import { runtime } from './runtime.js'; @@ -87,7 +85,10 @@ const V2: DefinitionsTypes = { } }; -const types: DefinitionsTypes = objectSpread({}, V0, V1, V2, { +const types: DefinitionsTypes = { + ...V0, + ...V1, + ...V2, EthereumAccountId: 'GenericEthereumAccountId', EthereumAddress: 'GenericEthereumAccountId', EthereumLookupSource: 'GenericEthereumLookupSource', @@ -361,6 +362,6 @@ const types: DefinitionsTypes = objectSpread({}, V0, V1, V2, { target: 'H256', number: 'Option' } -}); +}; export default { rpc, runtime, types }; diff --git a/packages/types/src/interfaces/eth/rpc.ts b/packages/types/src/interfaces/eth/rpc.ts index 38813305b5..02e1b27c13 100644 --- a/packages/types/src/interfaces/eth/rpc.ts +++ b/packages/types/src/interfaces/eth/rpc.ts @@ -5,8 +5,6 @@ import type { DefinitionsRpc } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - // We use aliasSection here to override since these are in another namespace const netRpc: DefinitionsRpc = { listening: { @@ -43,7 +41,9 @@ const web3Rpc: DefinitionsRpc = { } }; -export const rpc: DefinitionsRpc = objectSpread({}, netRpc, web3Rpc, { +export const rpc: DefinitionsRpc = { + ...netRpc, + ...web3Rpc, accounts: { description: 'Returns accounts list.', params: [], @@ -505,4 +505,4 @@ export const rpc: DefinitionsRpc = objectSpread({}, netRpc, web3Rpc, { ], type: 'bool' } -}); +}; diff --git a/packages/types/src/interfaces/grandpa/runtime.ts b/packages/types/src/interfaces/grandpa/runtime.ts index 27d4edb2bc..5c72903a42 100644 --- a/packages/types/src/interfaces/grandpa/runtime.ts +++ b/packages/types/src/interfaces/grandpa/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const GRANDPA_V2_V3: DefinitionsCallEntry['methods'] = { generate_key_ownership_proof: { description: 'Generates a proof of key ownership for the given authority in the given set.', @@ -44,13 +42,14 @@ const GRANDPA_V2_V3: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { GrandpaApi: [ { - methods: objectSpread({ + methods: { current_set_id: { description: 'Get current GRANDPA authority set id.', params: [], type: 'SetId' - } - }, GRANDPA_V2_V3), + }, + ...GRANDPA_V2_V3 + }, version: 3 }, { diff --git a/packages/types/src/interfaces/metadata/definitions.ts b/packages/types/src/interfaces/metadata/definitions.ts index a08dca0b45..f00c5614ad 100644 --- a/packages/types/src/interfaces/metadata/definitions.ts +++ b/packages/types/src/interfaces/metadata/definitions.ts @@ -6,8 +6,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { AllHashers } from './hashers.js'; import { runtime } from './runtime.js'; import { v9 } from './v9.js'; @@ -22,7 +20,13 @@ export { AllHashers }; export default { rpc: {}, runtime, - types: objectSpread({}, v9, v10, v11, v12, v13, v14, { + types: { + ...v9, + ...v10, + ...v11, + ...v12, + ...v13, + ...v14, // latest mappings ErrorMetadataLatest: 'ErrorMetadataV14', EventMetadataLatest: 'EventMetadataV14', @@ -67,5 +71,5 @@ export default { V14: 'MetadataV14' } } - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/metadata/runtime.ts b/packages/types/src/interfaces/metadata/runtime.ts index f2608d162f..604b0ea6c1 100644 --- a/packages/types/src/interfaces/metadata/runtime.ts +++ b/packages/types/src/interfaces/metadata/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const META_V1_TO_V2: DefinitionsCallEntry['methods'] = { metadata: { description: 'Returns the metadata of a runtime', @@ -16,7 +14,7 @@ const META_V1_TO_V2: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { Metadata: [ { - methods: objectSpread({ + methods: { metadata_at_version: { description: 'Returns the metadata at a given version.', params: [ @@ -31,12 +29,15 @@ export const runtime: DefinitionsCall = { description: 'Returns the supported metadata versions.', params: [], type: 'Vec' - } - }, META_V1_TO_V2), + }, + ...META_V1_TO_V2 + }, version: 2 }, { - methods: objectSpread({}, META_V1_TO_V2), + methods: { + ...META_V1_TO_V2 + }, version: 1 } ] diff --git a/packages/types/src/interfaces/metadata/v14.ts b/packages/types/src/interfaces/metadata/v14.ts index 817977a090..6c50f09299 100644 --- a/packages/types/src/interfaces/metadata/v14.ts +++ b/packages/types/src/interfaces/metadata/v14.ts @@ -4,9 +4,7 @@ // order important in structs... :) /* eslint-disable sort-keys */ -import type { DefinitionsTypes, DefinitionTypeStruct } from '../../types/index.js'; - -import { objectSpread } from '@polkadot/util'; +import type { DefinitionsTypes } from '../../types/index.js'; import { Si1Variant } from '../scaleInfo/v1.js'; @@ -18,14 +16,23 @@ export const v14: DefinitionsTypes = { }, // compatibility with earlier layouts, i.e. don't break previous users - ErrorMetadataV14: objectSpread({}, Si1Variant, { args: 'Vec' }), - EventMetadataV14: objectSpread({}, Si1Variant, { args: 'Vec' }), + ErrorMetadataV14: { + ...Si1Variant, + args: 'Vec' + }, + EventMetadataV14: { + ...Si1Variant, + args: 'Vec' + }, FunctionArgumentMetadataV14: { name: 'Text', type: 'Type', typeName: 'Option' }, - FunctionMetadataV14: objectSpread({}, Si1Variant, { args: 'Vec' }), + FunctionMetadataV14: { + ...Si1Variant, + args: 'Vec' + }, // V14 ExtrinsicMetadataV14: { diff --git a/packages/types/src/interfaces/parachains/definitions.ts b/packages/types/src/interfaces/parachains/definitions.ts index 738acf0bf0..bffcabe225 100644 --- a/packages/types/src/interfaces/parachains/definitions.ts +++ b/packages/types/src/interfaces/parachains/definitions.ts @@ -6,8 +6,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import hrmpTypes from './hrmp.js'; import { runtime } from './runtime.js'; import slotTypes from './slots.js'; @@ -98,7 +96,12 @@ const disputeTypes = { export default { rpc: {}, runtime, - types: objectSpread({}, cumulusTypes, disputeTypes, hrmpTypes, proposeTypes, slotTypes, { + types: { + ...cumulusTypes, + ...disputeTypes, + ...hrmpTypes, + ...proposeTypes, + ...slotTypes, AbridgedCandidateReceipt: { parachainIndex: 'ParaId', relayParent: 'Hash', @@ -509,5 +512,5 @@ export default { MessagingStateSnapshotEgressEntry: '(ParaId, AbridgedHrmpChannel)', SystemInherentData: 'ParachainInherentData', VecInboundHrmpMessage: 'Vec' - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/parachains/runtime.ts b/packages/types/src/interfaces/parachains/runtime.ts index 7f02e4ac9f..a1e0b1d270 100644 --- a/packages/types/src/interfaces/parachains/runtime.ts +++ b/packages/types/src/interfaces/parachains/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const PH_V1_TO_V2: DefinitionsCallEntry['methods'] = { assumed_validation_data: { description: 'Returns the persisted validation data for the given `ParaId` along with the corresponding validation code hash.', @@ -204,19 +202,31 @@ const PH_V4: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { ParachainHost: [ { - methods: objectSpread({}, PH_V1_TO_V2, PH_V2_TO_V3, PH_V3, PH_V4), + methods: { + ...PH_V1_TO_V2, + ...PH_V2_TO_V3, + ...PH_V3, + ...PH_V4 + }, version: 4 }, { - methods: objectSpread({}, PH_V1_TO_V2, PH_V2_TO_V3, PH_V3), + methods: { + ...PH_V1_TO_V2, + ...PH_V2_TO_V3, + ...PH_V3 + }, version: 3 }, { - methods: objectSpread({}, PH_V1_TO_V2, PH_V2_TO_V3), + methods: { + ...PH_V1_TO_V2, + ...PH_V2_TO_V3 + }, version: 2 }, { - methods: objectSpread({ + methods: { session_info: { description: 'Get the session info for the given session, if stored.', params: [ @@ -226,8 +236,9 @@ export const runtime: DefinitionsCall = { } ], type: 'Option' - } - }, PH_V1_TO_V2), + }, + ...PH_V1_TO_V2 + }, version: 1 } ] diff --git a/packages/types/src/interfaces/parachains/slots.ts b/packages/types/src/interfaces/parachains/slots.ts index 232cad9dec..56d56a26d4 100644 --- a/packages/types/src/interfaces/parachains/slots.ts +++ b/packages/types/src/interfaces/parachains/slots.ts @@ -1,8 +1,6 @@ // Copyright 2017-2023 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { objectSpread } from '@polkadot/util'; - // order important in structs... :) /* eslint-disable sort-keys */ @@ -44,7 +42,8 @@ const oldTypes = { SubId: 'u32' }; -export default objectSpread({}, oldTypes, { +export default { + ...oldTypes, AuctionIndex: 'u32', LeasePeriod: 'BlockNumber', LeasePeriodOf: 'BlockNumber', @@ -57,4 +56,4 @@ export default objectSpread({}, oldTypes, { WinnersData: 'Vec', WinnersDataTuple10: '(AccountId, ParaId, BalanceOf, SlotRange10)', WinnersDataTuple: '(AccountId, ParaId, BalanceOf, SlotRange)' -}); +}; diff --git a/packages/types/src/interfaces/payment/runtime.ts b/packages/types/src/interfaces/payment/runtime.ts index fa093e5125..edf6c0ec75 100644 --- a/packages/types/src/interfaces/payment/runtime.ts +++ b/packages/types/src/interfaces/payment/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionCall, DefinitionsCall } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const V1_TO_V4_SHARED_PAY: Record = { query_fee_details: { description: 'The transaction fee details', @@ -100,33 +98,30 @@ export const runtime: DefinitionsCall = { TransactionPaymentApi: [ { // V4 is equivalent to V3 (V4 just dropped all V1 references) - methods: objectSpread( - {}, - V3_SHARED_PAY_CALL, - V2_TO_V4_SHARED_PAY, - V1_TO_V4_SHARED_PAY - ), + methods: { + ...V3_SHARED_PAY_CALL, + ...V2_TO_V4_SHARED_PAY, + ...V1_TO_V4_SHARED_PAY + }, version: 4 }, { - methods: objectSpread( - {}, - V3_SHARED_PAY_CALL, - V2_TO_V4_SHARED_PAY, - V1_TO_V4_SHARED_PAY - ), + methods: { + ...V3_SHARED_PAY_CALL, + ...V2_TO_V4_SHARED_PAY, + ...V1_TO_V4_SHARED_PAY + }, version: 3 }, { - methods: objectSpread( - {}, - V2_TO_V4_SHARED_PAY, - V1_TO_V4_SHARED_PAY - ), + methods: { + ...V2_TO_V4_SHARED_PAY, + ...V1_TO_V4_SHARED_PAY + }, version: 2 }, { - methods: objectSpread({ + methods: { query_info: { description: 'The transaction info', params: [ @@ -143,31 +138,30 @@ export const runtime: DefinitionsCall = { // changed mid-flight between versions. So we have some of each depending on // runtime. (We do detect the weight type, so correct) type: 'RuntimeDispatchInfo' - } - }, V1_TO_V4_SHARED_PAY), + }, + ...V1_TO_V4_SHARED_PAY + }, version: 1 } ], TransactionPaymentCallApi: [ { - methods: objectSpread( - {}, - V3_SHARED_PAY_CALL, - V2_V3_SHARED_CALL, - V1_TO_V3_SHARED_CALL - ), + methods: { + ...V3_SHARED_PAY_CALL, + ...V2_V3_SHARED_CALL, + ...V1_TO_V3_SHARED_CALL + }, version: 3 }, { - methods: objectSpread( - {}, - V2_V3_SHARED_CALL, - V1_TO_V3_SHARED_CALL - ), + methods: { + ...V2_V3_SHARED_CALL, + ...V1_TO_V3_SHARED_CALL + }, version: 2 }, { - methods: objectSpread({ + methods: { CALL: { description: 'The call info', params: [ @@ -183,8 +177,9 @@ export const runtime: DefinitionsCall = { // NOTE: As per the above comment, the below is correct according to Substrate, but // _may_ yield fallback decoding on some versions of the runtime type: 'RuntimeDispatchInfo' - } - }, V1_TO_V3_SHARED_CALL), + }, + ...V1_TO_V3_SHARED_CALL + }, version: 1 } ] diff --git a/packages/types/src/interfaces/runtime/definitions.ts b/packages/types/src/interfaces/runtime/definitions.ts index b9e7b682ab..a557623662 100644 --- a/packages/types/src/interfaces/runtime/definitions.ts +++ b/packages/types/src/interfaces/runtime/definitions.ts @@ -6,8 +6,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { runtime } from './runtime.js'; const numberTypes = { @@ -50,7 +48,8 @@ export const knownOrigins: Record = { export default { rpc: {}, runtime, - types: objectSpread({}, numberTypes, { + types: { + ...numberTypes, AccountId: 'AccountId32', AccountId20: 'GenericEthereumAccountId', AccountId32: 'GenericAccountId32', @@ -228,5 +227,5 @@ export default { SealV0: '(u64, Signature)', Seal: '(ConsensusEngineId, Bytes)', Consensus: '(ConsensusEngineId, Bytes)' - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/runtime/runtime.ts b/packages/types/src/interfaces/runtime/runtime.ts index bac7f4c919..ab15b990f3 100644 --- a/packages/types/src/interfaces/runtime/runtime.ts +++ b/packages/types/src/interfaces/runtime/runtime.ts @@ -3,8 +3,6 @@ import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - const CORE_V1_TO_V4: DefinitionsCallEntry['methods'] = { execute_block: { description: 'Execute the given block.', @@ -42,31 +40,39 @@ const CORE_V2_TO_V4: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { Core: [ { - methods: objectSpread({ + methods: { version: { description: 'Returns the version of the runtime.', params: [], type: 'RuntimeVersion' - } - }, CORE_V1_TO_V4, CORE_V2_TO_V4), + }, + ...CORE_V1_TO_V4, + ...CORE_V2_TO_V4 + }, version: 4 }, { - methods: objectSpread({ + methods: { version: { description: 'Returns the version of the runtime.', params: [], type: 'RuntimeVersionPre4' - } - }, CORE_V1_TO_V4, CORE_V2_TO_V4), + }, + ...CORE_V1_TO_V4, + ...CORE_V2_TO_V4 + }, version: 3 }, { - methods: objectSpread({}, CORE_V1_TO_V2, CORE_V1_TO_V4, CORE_V2_TO_V4), + methods: { + ...CORE_V1_TO_V2, + ...CORE_V1_TO_V4, + ...CORE_V2_TO_V4 + }, version: 2 }, { - methods: objectSpread({ + methods: { initialise_block: { description: 'Initialize a block with the given header.', params: [ @@ -76,8 +82,10 @@ export const runtime: DefinitionsCall = { } ], type: 'Null' - } - }, CORE_V1_TO_V2, CORE_V1_TO_V4), + }, + ...CORE_V1_TO_V2, + ...CORE_V1_TO_V4 + }, version: 1 } ] diff --git a/packages/types/src/interfaces/scaleInfo/definitions.ts b/packages/types/src/interfaces/scaleInfo/definitions.ts index cf13719d72..3efe1cf369 100644 --- a/packages/types/src/interfaces/scaleInfo/definitions.ts +++ b/packages/types/src/interfaces/scaleInfo/definitions.ts @@ -3,8 +3,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { v0 } from './v0.js'; import { v1 } from './v1.js'; @@ -13,7 +11,9 @@ import { v1 } from './v1.js'; export default { rpc: {}, - types: objectSpread({}, v0, v1, { + types: { + ...v0, + ...v1, // latest mappings SiField: 'Si1Field', SiLookupTypeId: 'Si1LookupTypeId', @@ -30,5 +30,5 @@ export default { SiTypeParameter: 'Si1TypeParameter', SiTypeDefVariant: 'Si1TypeDefVariant', SiVariant: 'Si1Variant' - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/session/definitions.ts b/packages/types/src/interfaces/session/definitions.ts index 9c9b218c90..f40e365a51 100644 --- a/packages/types/src/interfaces/session/definitions.ts +++ b/packages/types/src/interfaces/session/definitions.ts @@ -6,8 +6,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { runtime } from './runtime.js'; // The runtime definition of SessionKeys are passed as a Trait to session @@ -42,7 +40,8 @@ const keyTypes = { export default { rpc: {}, runtime, - types: objectSpread({}, keyTypes, { + types: { + ...keyTypes, FullIdentification: 'Exposure', IdentificationTuple: '(ValidatorId, FullIdentification)', MembershipProof: { @@ -52,5 +51,5 @@ export default { }, SessionIndex: 'u32', ValidatorCount: 'u32' - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/staking/definitions.ts b/packages/types/src/interfaces/staking/definitions.ts index 4fc1ba7347..57bfd3f673 100644 --- a/packages/types/src/interfaces/staking/definitions.ts +++ b/packages/types/src/interfaces/staking/definitions.ts @@ -6,8 +6,6 @@ import type { Definitions } from '../../types/index.js'; -import { objectSpread } from '@polkadot/util'; - import { runtime } from './runtime.js'; const deprecated = { @@ -177,7 +175,9 @@ const phragmen = { export default { rpc: {}, runtime, - types: objectSpread({}, deprecated, phragmen, { + types: { + ...deprecated, + ...phragmen, ActiveEraInfo: { index: 'EraIndex', start: 'Option' @@ -302,5 +302,5 @@ export default { unstakeThreshold: 'Compact', validatorPayment: 'Compact' } - }) + } } as Definitions; diff --git a/packages/types/src/interfaces/xcm/definitions.ts b/packages/types/src/interfaces/xcm/definitions.ts index f24f2cd967..eea0c86957 100644 --- a/packages/types/src/interfaces/xcm/definitions.ts +++ b/packages/types/src/interfaces/xcm/definitions.ts @@ -7,7 +7,6 @@ import type { Definitions } from '../../types/index.js'; import { mapXcmTypes } from '@polkadot/types-create'; -import { objectSpread } from '@polkadot/util'; import { v0 } from './v0.js'; import { v1 } from './v1.js'; @@ -82,7 +81,13 @@ const location = { export default { rpc: {}, - types: objectSpread({}, location, xcm, v0, v1, v2, mapXcmTypes(XCM_LATEST), { + types: { + ...location, + ...xcm, + ...v0, + ...v1, + ...v2, + ...mapXcmTypes(XCM_LATEST), DoubleEncodedCall: { encoded: 'Vec' }, @@ -159,5 +164,5 @@ export default { } }, XcmVersion: 'u32' - }) + } } as Definitions;