diff --git a/packages/types-known/src/chain/index.ts b/packages/types-known/src/chain/index.ts index 296b1f043f..0c4ddfc89e 100644 --- a/packages/types-known/src/chain/index.ts +++ b/packages/types-known/src/chain/index.ts @@ -4,6 +4,4 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; // Type overrides based on specific nodes -const typesChain: Record = {}; - -export default typesChain; +export const typesChain: Record = {}; diff --git a/packages/types-known/src/spec/centrifuge-chain.ts b/packages/types-known/src/spec/centrifuge-chain.ts index 6640c286a8..0590d79385 100644 --- a/packages/types-known/src/spec/centrifuge-chain.ts +++ b/packages/types-known/src/spec/centrifuge-chain.ts @@ -5,8 +5,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -import { objectSpread } from '@polkadot/util'; - const sharedTypes = { // Anchor AnchorData: { @@ -82,18 +80,20 @@ const sharedTypes = { } }; -const standaloneTypes = objectSpread({}, sharedTypes, { +const standaloneTypes = { + ...sharedTypes, AccountInfo: 'AccountInfoWithRefCount', Address: 'LookupSource', LookupSource: 'IndicesLookupSource', Multiplier: 'Fixed64', RefCount: 'RefCountTo259' -}); +}; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [240, 243], - types: objectSpread({}, standaloneTypes, { + types: { + ...standaloneTypes, ProxyType: { _enum: [ 'Any', @@ -103,16 +103,14 @@ const versioned: OverrideVersionedType[] = [ 'Vesting' ] } - }) + } }, { minmax: [244, 999], - types: objectSpread({}, standaloneTypes) + types: { ...standaloneTypes } }, { minmax: [1000, undefined], - types: objectSpread({}, sharedTypes) + types: { ...sharedTypes } } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/index.ts b/packages/types-known/src/spec/index.ts index 939143e098..619aa77199 100644 --- a/packages/types-known/src/spec/index.ts +++ b/packages/types-known/src/spec/index.ts @@ -3,18 +3,18 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -import centrifugeChain from './centrifuge-chain.js'; -import kusama from './kusama.js'; -import node from './node.js'; -import nodeTemplate from './node-template.js'; -import polkadot from './polkadot.js'; -import rococo from './rococo.js'; -import shell from './shell.js'; -import statemint from './statemint.js'; -import westend from './westend.js'; +import { versioned as centrifugeChain } from './centrifuge-chain.js'; +import { versioned as kusama } from './kusama.js'; +import { versioned as node } from './node.js'; +import { versioned as nodeTemplate } from './node-template.js'; +import { versioned as polkadot } from './polkadot.js'; +import { versioned as rococo } from './rococo.js'; +import { versioned as shell } from './shell.js'; +import { versioned as statemint } from './statemint.js'; +import { versioned as westend } from './westend.js'; // Type overrides for specific spec types & versions as given in runtimeVersion -const typesSpec: Record = { +export const typesSpec: Record = { 'centrifuge-chain': centrifugeChain, kusama, node, @@ -27,5 +27,3 @@ const typesSpec: Record = { westend, westmint: statemint }; - -export default typesSpec; diff --git a/packages/types-known/src/spec/kusama.ts b/packages/types-known/src/spec/kusama.ts index 4d18998573..dd68da7ec8 100644 --- a/packages/types-known/src/spec/kusama.ts +++ b/packages/types-known/src/spec/kusama.ts @@ -6,7 +6,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; import { mapXcmTypes } from '@polkadot/types-create'; -import { objectSpread } from '@polkadot/util'; const sharedTypes = { CompactAssignments: 'CompactAssignmentsWith24', @@ -41,11 +40,12 @@ const addrAccountIdTypes = { ValidatorPrefs: 'ValidatorPrefsWithCommission' }; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { // 1020 is first CC3 minmax: [1019, 1031], - types: objectSpread({}, addrIndicesTypes, { + types: { + ...addrIndicesTypes, BalanceLock: 'BalanceLockTo212', CompactAssignments: 'CompactAssignmentsTo257', DispatchError: 'DispatchErrorTo198', @@ -61,11 +61,12 @@ const versioned: OverrideVersionedType[] = [ StakingLedger: 'StakingLedgerTo223', Votes: 'VotesTo230', Weight: 'u32' - }) + } }, { minmax: [1032, 1042], - types: objectSpread({}, addrIndicesTypes, { + types: { + ...addrIndicesTypes, BalanceLock: 'BalanceLockTo212', CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', @@ -79,12 +80,13 @@ const versioned: OverrideVersionedType[] = [ StakingLedger: 'StakingLedgerTo223', Votes: 'VotesTo230', Weight: 'u32' - }) + } }, { // actual at 1045 (1043-1044 is dev) minmax: [1043, 1045], - types: objectSpread({}, addrIndicesTypes, { + types: { + ...addrIndicesTypes, BalanceLock: 'BalanceLockTo212', CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', @@ -97,11 +99,13 @@ const versioned: OverrideVersionedType[] = [ StakingLedger: 'StakingLedgerTo223', Votes: 'VotesTo230', Weight: 'u32' - }) + } }, { minmax: [1046, 1049], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', @@ -111,11 +115,13 @@ const versioned: OverrideVersionedType[] = [ ReferendumInfo: 'ReferendumInfoTo239', StakingLedger: 'StakingLedgerTo223', Weight: 'u32' - }) + } }, { minmax: [1050, 1054], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', @@ -125,11 +131,13 @@ const versioned: OverrideVersionedType[] = [ ReferendumInfo: 'ReferendumInfoTo239', StakingLedger: 'StakingLedgerTo240', Weight: 'u32' - }) + } }, { minmax: [1055, 1056], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', @@ -138,66 +146,85 @@ const versioned: OverrideVersionedType[] = [ RefCount: 'RefCountTo259', StakingLedger: 'StakingLedgerTo240', Weight: 'u32' - }) + } }, { minmax: [1057, 1061], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', OpenTip: 'OpenTipTo225', RefCount: 'RefCountTo259' - }) + } }, { minmax: [1062, 2012], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', OpenTip: 'OpenTipTo225', RefCount: 'RefCountTo259' - }) + } }, { minmax: [2013, 2022], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', RefCount: 'RefCountTo259' - }) + } }, { minmax: [2023, 2024], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, RefCount: 'RefCountTo259' - }) + } }, { minmax: [2025, 2027], - types: objectSpread({}, sharedTypes, addrAccountIdTypes) + types: { + ...sharedTypes, + ...addrAccountIdTypes + } }, { minmax: [2028, 2029], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, AccountInfo: 'AccountInfoWithDualRefCount', CompactAssignments: 'CompactAssignmentsWith16', RawSolution: 'RawSolutionWith16' - }) + } }, { minmax: [2030, 9000], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, CompactAssignments: 'CompactAssignmentsWith16', RawSolution: 'RawSolutionWith16' - }) + } }, { minmax: [9010, 9099], - types: objectSpread({}, sharedTypes, mapXcmTypes('V0')) + types: { + ...sharedTypes, + ...mapXcmTypes('V0') + } }, { // jump from 9100 to 9110, however align with Rococo minmax: [9100, 9105], - types: objectSpread({}, sharedTypes, mapXcmTypes('V1')) + types: { + ...sharedTypes, + ...mapXcmTypes('V1') + } }, { // metadata v14 @@ -215,5 +242,3 @@ const versioned: OverrideVersionedType[] = [ // } // } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/node-template.ts b/packages/types-known/src/spec/node-template.ts index ca0e4c9c89..2d08f314f2 100644 --- a/packages/types-known/src/spec/node-template.ts +++ b/packages/types-known/src/spec/node-template.ts @@ -5,7 +5,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, undefined], types: { @@ -15,5 +15,3 @@ const versioned: OverrideVersionedType[] = [ } } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/node.ts b/packages/types-known/src/spec/node.ts index ca0e4c9c89..2d08f314f2 100644 --- a/packages/types-known/src/spec/node.ts +++ b/packages/types-known/src/spec/node.ts @@ -5,7 +5,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, undefined], types: { @@ -15,5 +15,3 @@ const versioned: OverrideVersionedType[] = [ } } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/polkadot.ts b/packages/types-known/src/spec/polkadot.ts index acba77da1d..7eb582ad83 100644 --- a/packages/types-known/src/spec/polkadot.ts +++ b/packages/types-known/src/spec/polkadot.ts @@ -5,8 +5,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -import { objectSpread } from '@polkadot/util'; - const sharedTypes = { CompactAssignments: 'CompactAssignmentsWith16', DispatchErrorModule: 'DispatchErrorModuleU8', @@ -37,41 +35,51 @@ const addrAccountIdTypes = { }; // these are override types for Polkadot -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, 12], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', OpenTip: 'OpenTipTo225', RefCount: 'RefCountTo259' - }) + } }, { minmax: [13, 22], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', RefCount: 'RefCountTo259' - }) + } }, { minmax: [23, 24], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, RefCount: 'RefCountTo259' - }) + } }, { minmax: [25, 27], - types: objectSpread({}, sharedTypes, addrAccountIdTypes) + types: { + ...sharedTypes, + ...addrAccountIdTypes + } }, { minmax: [28, 29], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, AccountInfo: 'AccountInfoWithDualRefCount' - }) + } }, { minmax: [30, 9109], - types: objectSpread({}, sharedTypes) + types: { ...sharedTypes } }, { // metadata v14 @@ -89,5 +97,3 @@ const versioned: OverrideVersionedType[] = [ // } // } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/rococo.ts b/packages/types-known/src/spec/rococo.ts index e620e233d7..d29ff495a6 100644 --- a/packages/types-known/src/spec/rococo.ts +++ b/packages/types-known/src/spec/rococo.ts @@ -6,7 +6,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; import { mapXcmTypes } from '@polkadot/types-create'; -import { objectSpread } from '@polkadot/util'; // structs need to be in order /* eslint-disable sort-keys */ @@ -18,34 +17,43 @@ const sharedTypes = { Weight: 'WeightV1' }; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, 200], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, AccountInfo: 'AccountInfoWithDualRefCount', Address: 'AccountId', LookupSource: 'AccountId' - }) + } }, { minmax: [201, 214], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, AccountInfo: 'AccountInfoWithDualRefCount' - }) + } }, { minmax: [215, 228], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, Keys: 'SessionKeys6' - }) + } }, { minmax: [229, 9099], - types: objectSpread({}, sharedTypes, mapXcmTypes('V0')) + types: { + ...sharedTypes, + ...mapXcmTypes('V0') + } }, { minmax: [9100, 9105], - types: objectSpread({}, sharedTypes, mapXcmTypes('V1')) + types: { + ...sharedTypes, + ...mapXcmTypes('V1') + } }, { // metadata v14 @@ -63,5 +71,3 @@ const versioned: OverrideVersionedType[] = [ // } // } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/shell.ts b/packages/types-known/src/spec/shell.ts index 8e0ab17720..2c41669362 100644 --- a/packages/types-known/src/spec/shell.ts +++ b/packages/types-known/src/spec/shell.ts @@ -5,7 +5,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, undefined], types: { @@ -13,5 +13,3 @@ const versioned: OverrideVersionedType[] = [ } } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/statemint.ts b/packages/types-known/src/spec/statemint.ts index 4554ae77ca..9036c42fd3 100644 --- a/packages/types-known/src/spec/statemint.ts +++ b/packages/types-known/src/spec/statemint.ts @@ -6,7 +6,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; import { mapXcmTypes } from '@polkadot/types-create'; -import { objectSpread } from '@polkadot/util'; const sharedTypes = { DispatchErrorModule: 'DispatchErrorModuleU8', @@ -26,21 +25,25 @@ const sharedTypes = { }; // these are override types for Statemine, Statemint, Westmint -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [0, 3], - types: objectSpread({ + types: { // Enum was modified mid-flight - // https://github.com/paritytech/substrate/pull/10382/files#diff-e4e016b33a82268b6208dc974eea841bad47597865a749fee2f937eb6fdf67b4R498 - DispatchError: 'DispatchErrorPre6First' - }, sharedTypes, mapXcmTypes('V0')) + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V0') + } }, { minmax: [4, 5], - types: objectSpread({ + types: { // As above, see https://github.com/polkadot-js/api/issues/5301 - DispatchError: 'DispatchErrorPre6First' - }, sharedTypes, mapXcmTypes('V1')) + DispatchError: 'DispatchErrorPre6First', + ...sharedTypes, + ...mapXcmTypes('V1') + } }, { // metadata V14 @@ -58,5 +61,3 @@ const versioned: OverrideVersionedType[] = [ // } // } ]; - -export default versioned; diff --git a/packages/types-known/src/spec/westend.ts b/packages/types-known/src/spec/westend.ts index b6b5201d18..a5ed7372ff 100644 --- a/packages/types-known/src/spec/westend.ts +++ b/packages/types-known/src/spec/westend.ts @@ -6,7 +6,6 @@ import type { OverrideVersionedType } from '@polkadot/types/types'; import { mapXcmTypes } from '@polkadot/types-create'; -import { objectSpread } from '@polkadot/util'; const sharedTypes = { // 16 validators @@ -32,10 +31,12 @@ const addrAccountIdTypes = { ValidatorPrefs: 'ValidatorPrefsWithCommission' }; -const versioned: OverrideVersionedType[] = [ +export const versioned: OverrideVersionedType[] = [ { minmax: [1, 2], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', @@ -43,52 +44,68 @@ const versioned: OverrideVersionedType[] = [ OpenTip: 'OpenTipTo225', RefCount: 'RefCountTo259', Weight: 'u32' - }) + } }, { minmax: [3, 22], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', OpenTip: 'OpenTipTo225', RefCount: 'RefCountTo259' - }) + } }, { minmax: [23, 42], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, CompactAssignments: 'CompactAssignmentsTo257', DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', RefCount: 'RefCountTo259' - }) + } }, { minmax: [43, 44], - types: objectSpread({}, sharedTypes, addrAccountIdTypes, { + types: { + ...sharedTypes, + ...addrAccountIdTypes, DispatchInfo: 'DispatchInfoTo244', Heartbeat: 'HeartbeatTo244', RefCount: 'RefCountTo259' - }) + } }, { minmax: [45, 47], - types: objectSpread({}, sharedTypes, addrAccountIdTypes) + types: { + ...sharedTypes, + ...addrAccountIdTypes + } }, { minmax: [48, 49], - types: objectSpread({}, sharedTypes, { + types: { + ...sharedTypes, AccountInfo: 'AccountInfoWithDualRefCount' - }) + } }, { minmax: [50, 9099], - types: objectSpread({}, sharedTypes, mapXcmTypes('V0')) + types: { + ...sharedTypes, + ...mapXcmTypes('V0') + } }, { minmax: [9100, 9105], - types: objectSpread({}, sharedTypes, mapXcmTypes('V1')) + types: { + ...sharedTypes, + ...mapXcmTypes('V1') + } }, { // metadata v14 @@ -106,5 +123,3 @@ const versioned: OverrideVersionedType[] = [ // } // } ]; - -export default versioned; diff --git a/packages/types-known/src/upgrades/e2e/index.spec.ts b/packages/types-known/src/upgrades/e2e/index.spec.ts index 3e45de91cf..b6df3c6727 100644 --- a/packages/types-known/src/upgrades/e2e/index.spec.ts +++ b/packages/types-known/src/upgrades/e2e/index.spec.ts @@ -39,9 +39,7 @@ for (const chain of keys) { import type { ChainUpgradesExpanded } from '../types.js'; - const upgrades: ChainUpgradesExpanded = ${JSON.stringify(final, null, 2)}; - - export default upgrades; + export const upgrades: ChainUpgradesExpanded = ${JSON.stringify(final, null, 2)}; `); await api.disconnect(); }); diff --git a/packages/types-known/src/upgrades/e2e/index.ts b/packages/types-known/src/upgrades/e2e/index.ts index f7682849ed..a18a2f6777 100644 --- a/packages/types-known/src/upgrades/e2e/index.ts +++ b/packages/types-known/src/upgrades/e2e/index.ts @@ -1,6 +1,6 @@ // Copyright 2017-2023 @polkadot/types-known authors & contributors // SPDX-License-Identifier: Apache-2.0 -export { default as kusama } from './kusama.js'; -export { default as polkadot } from './polkadot.js'; -export { default as westend } from './westend.js'; +export { upgrades as kusama } from './kusama.js'; +export { upgrades as polkadot } from './polkadot.js'; +export { upgrades as westend } from './westend.js'; diff --git a/packages/types-known/src/upgrades/e2e/kusama.ts b/packages/types-known/src/upgrades/e2e/kusama.ts index ac66622031..f7b5a5aa5a 100644 --- a/packages/types-known/src/upgrades/e2e/kusama.ts +++ b/packages/types-known/src/upgrades/e2e/kusama.ts @@ -6,7 +6,7 @@ import type { ChainUpgradesExpanded } from '../types.js'; -const upgrades: ChainUpgradesExpanded = [ +export const upgrades: ChainUpgradesExpanded = [ [ 0, 1020, @@ -4180,5 +4180,3 @@ const upgrades: ChainUpgradesExpanded = [ ] ] ]; - -export default upgrades; diff --git a/packages/types-known/src/upgrades/e2e/polkadot.ts b/packages/types-known/src/upgrades/e2e/polkadot.ts index 324a34a06c..7a15bb5d82 100644 --- a/packages/types-known/src/upgrades/e2e/polkadot.ts +++ b/packages/types-known/src/upgrades/e2e/polkadot.ts @@ -6,7 +6,7 @@ import type { ChainUpgradesExpanded } from '../types.js'; -const upgrades: ChainUpgradesExpanded = [ +export const upgrades: ChainUpgradesExpanded = [ [ 0, 0, @@ -2630,5 +2630,3 @@ const upgrades: ChainUpgradesExpanded = [ ] ] ]; - -export default upgrades; diff --git a/packages/types-known/src/upgrades/e2e/westend.ts b/packages/types-known/src/upgrades/e2e/westend.ts index 2d12c18d94..97f4e572a3 100644 --- a/packages/types-known/src/upgrades/e2e/westend.ts +++ b/packages/types-known/src/upgrades/e2e/westend.ts @@ -6,7 +6,7 @@ import type { ChainUpgradesExpanded } from '../types.js'; -const upgrades: ChainUpgradesExpanded = [ +export const upgrades: ChainUpgradesExpanded = [ [ 214356, 4, @@ -4018,5 +4018,3 @@ const upgrades: ChainUpgradesExpanded = [ ] ] ]; - -export default upgrades; diff --git a/packages/types-known/src/upgrades/index.spec.ts b/packages/types-known/src/upgrades/index.spec.ts index 387ffb6877..c74b77b448 100644 --- a/packages/types-known/src/upgrades/index.spec.ts +++ b/packages/types-known/src/upgrades/index.spec.ts @@ -9,7 +9,7 @@ import { stringify, u8aEq } from '@polkadot/util'; import * as allGen from './e2e/index.js'; import * as allMan from './manual/index.js'; -import all from './index.js'; +import { upgrades } from './index.js'; interface TestDef { genesisHash: string; @@ -92,7 +92,7 @@ describe('generated', (): void => { describe('upgrades', (): void => { TESTS.forEach(({ genesisHash, network, versions }): void => { describe(network, (): void => { - const chain = all.find((n) => n.network === network); + const chain = upgrades.find((n) => n.network === network); if (!chain) { throw new Error(`Unable to find the entry for ${network}`); diff --git a/packages/types-known/src/upgrades/index.ts b/packages/types-known/src/upgrades/index.ts index 6bc0a59162..ba500f9542 100644 --- a/packages/types-known/src/upgrades/index.ts +++ b/packages/types-known/src/upgrades/index.ts @@ -37,6 +37,4 @@ function mapRaw ([network, versions]: [string, ChainUpgradesExpanded]): ChainUpg } // Type overrides for specific spec types & versions as given in runtimeVersion -const upgrades = Object.entries(allKnown).map(mapRaw); - -export default upgrades; +export const upgrades = Object.entries(allKnown).map(mapRaw); diff --git a/packages/types-known/src/upgrades/manual/index.ts b/packages/types-known/src/upgrades/manual/index.ts index f7682849ed..a18a2f6777 100644 --- a/packages/types-known/src/upgrades/manual/index.ts +++ b/packages/types-known/src/upgrades/manual/index.ts @@ -1,6 +1,6 @@ // Copyright 2017-2023 @polkadot/types-known authors & contributors // SPDX-License-Identifier: Apache-2.0 -export { default as kusama } from './kusama.js'; -export { default as polkadot } from './polkadot.js'; -export { default as westend } from './westend.js'; +export { upgrades as kusama } from './kusama.js'; +export { upgrades as polkadot } from './polkadot.js'; +export { upgrades as westend } from './westend.js'; diff --git a/packages/types-known/src/upgrades/manual/kusama.ts b/packages/types-known/src/upgrades/manual/kusama.ts index 49898f8fe1..df6ec51d6e 100644 --- a/packages/types-known/src/upgrades/manual/kusama.ts +++ b/packages/types-known/src/upgrades/manual/kusama.ts @@ -3,7 +3,7 @@ import type { ChainUpgradesRaw } from '../types.js'; -const upgrades: ChainUpgradesRaw = [ +export const upgrades: ChainUpgradesRaw = [ [0, 1020], [26669, 1021], [38245, 1022], [54248, 1023], [59659, 1024], [67651, 1025], [82191, 1027], [83238, 1028], [101503, 1029], [203466, 1030], [295787, 1031], [461692, 1032], [504329, 1033], [569327, 1038], [587687, 1039], @@ -21,5 +21,3 @@ const upgrades: ChainUpgradesRaw = [ // we have 9340 via system.setStorage (whitelist.WhitelistedCallDispatched event) [15680713, 9340], [15756296, 9350] ]; - -export default upgrades; diff --git a/packages/types-known/src/upgrades/manual/polkadot.ts b/packages/types-known/src/upgrades/manual/polkadot.ts index 659adaf8e0..d5ccb543d4 100644 --- a/packages/types-known/src/upgrades/manual/polkadot.ts +++ b/packages/types-known/src/upgrades/manual/polkadot.ts @@ -3,7 +3,7 @@ import type { ChainUpgradesRaw } from '../types.js'; -const upgrades: ChainUpgradesRaw = [ +export const upgrades: ChainUpgradesRaw = [ [0, 0], [29231, 1], [188836, 5], [199405, 6], [214264, 7], [244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12], [528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17], @@ -14,5 +14,3 @@ const upgrades: ChainUpgradesRaw = [ [10458576, 9200], [10655116, 9220], [10879371, 9230], [11328884, 9250], [11532856, 9260], [11933818, 9270], [12217535, 9280], [12245277, 9281], [12532644, 9291], [12876189, 9300] ]; - -export default upgrades; diff --git a/packages/types-known/src/upgrades/manual/westend.ts b/packages/types-known/src/upgrades/manual/westend.ts index d9432ca5d0..6e70272dbc 100644 --- a/packages/types-known/src/upgrades/manual/westend.ts +++ b/packages/types-known/src/upgrades/manual/westend.ts @@ -3,7 +3,7 @@ import type { ChainUpgradesRaw } from '../types.js'; -const upgrades: ChainUpgradesRaw = [ +export const upgrades: ChainUpgradesRaw = [ [214356, 4], [392764, 7], [409740, 8], [809976, 20], [877581, 24], [879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29], [1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35], @@ -19,5 +19,3 @@ const upgrades: ChainUpgradesRaw = [ [12604343, 9290], [12841034, 9300], [13128237, 9310], [13272363, 9320], [13483497, 9330], [13649433, 9340], [13761100, 9350] ]; - -export default upgrades; diff --git a/packages/types-known/src/util.ts b/packages/types-known/src/util.ts index 0fd66e5915..b669ec9ffb 100644 --- a/packages/types-known/src/util.ts +++ b/packages/types-known/src/util.ts @@ -7,11 +7,11 @@ import type { ChainUpgradeVersion, CodecHasher, DefinitionRpc, DefinitionRpcSub, import type { Text } from '@polkadot/types-codec'; import type { BN } from '@polkadot/util'; -import { bnToBn, objectSpread } from '@polkadot/util'; +import { bnToBn } from '@polkadot/util'; -import typesChain from './chain/index.js'; -import typesSpec from './spec/index.js'; -import upgrades from './upgrades/index.js'; +import { typesChain } from './chain/index.js'; +import { typesSpec } from './spec/index.js'; +import { upgrades } from './upgrades/index.js'; /** * @description Perform the callback function using the stringified spec/chain @@ -31,21 +31,17 @@ function filterVersions (versions: OverrideVersionedType[] = [], specVersion: nu (min === undefined || min === null || specVersion >= min) && (max === undefined || max === null || specVersion <= max) ) - .reduce((result: RegistryTypes, { types }) => - objectSpread(result, types), {} - ); + .reduce((result: RegistryTypes, { types }) => ({ ...result, ...types }), {}); } /** * @description Based on the chain and runtimeVersion, get the applicable signed extensions (ready for registration) */ export function getSpecExtensions ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): ExtDef { - return withNames(chainName, specName, (c, s) => - objectSpread({}, - knownTypes.typesBundle?.spec?.[s]?.signedExtensions, - knownTypes.typesBundle?.chain?.[c]?.signedExtensions - ) - ); + return withNames(chainName, specName, (c, s) => ({ + ...(knownTypes.typesBundle?.spec?.[s]?.signedExtensions ?? {}), + ...(knownTypes.typesBundle?.chain?.[c]?.signedExtensions ?? {}) + })); } /** @@ -54,21 +50,19 @@ export function getSpecExtensions ({ knownTypes }: Registry, chainName: Text | s export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: bigint | BN | number): RegistryTypes { const _specVersion = bnToBn(specVersion).toNumber(); - return withNames(chainName, specName, (c, s) => + return withNames(chainName, specName, (c, s) => ({ // The order here is always, based on - // - spec then chain // - typesBundle takes higher precedence // - types is the final catch-all override - objectSpread({}, - filterVersions(typesSpec[s], _specVersion), - filterVersions(typesChain[c], _specVersion), - filterVersions(knownTypes.typesBundle?.spec?.[s]?.types, _specVersion), - filterVersions(knownTypes.typesBundle?.chain?.[c]?.types, _specVersion), - knownTypes.typesSpec?.[s], - knownTypes.typesChain?.[c], - knownTypes.types - ) - ); + ...filterVersions(typesSpec[s], _specVersion), + ...filterVersions(typesChain[c], _specVersion), + ...filterVersions(knownTypes.typesBundle?.spec?.[s]?.types, _specVersion), + ...filterVersions(knownTypes.typesBundle?.chain?.[c]?.types, _specVersion), + ...(knownTypes.typesSpec?.[s] ?? {}), + ...(knownTypes.typesChain?.[c] ?? {}), + ...(knownTypes.types ?? {}) + })); } /** @@ -87,38 +81,32 @@ export function getSpecHasher ({ knownTypes }: Registry, chainName: Text | strin * @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration) */ export function getSpecRpc ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record> { - return withNames(chainName, specName, (c, s) => - objectSpread({}, - knownTypes.typesBundle?.spec?.[s]?.rpc, - knownTypes.typesBundle?.chain?.[c]?.rpc - ) - ); + return withNames(chainName, specName, (c, s) => ({ + ...(knownTypes.typesBundle?.spec?.[s]?.rpc ?? {}), + ...(knownTypes.typesBundle?.chain?.[c]?.rpc ?? {}) + })); } /** * @description Based on the chain and runtimeVersion, get the applicable runtime definitions (ready for registration) */ export function getSpecRuntime ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): DefinitionsCall { - return withNames(chainName, specName, (c, s) => - objectSpread({}, - knownTypes.typesBundle?.spec?.[s]?.runtime, - knownTypes.typesBundle?.chain?.[c]?.runtime - ) - ); + return withNames(chainName, specName, (c, s) => ({ + ...(knownTypes.typesBundle?.spec?.[s]?.runtime ?? {}), + ...(knownTypes.typesBundle?.chain?.[c]?.runtime ?? {}) + })); } /** * @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration) */ export function getSpecAlias ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record { - return withNames(chainName, specName, (c, s) => + return withNames(chainName, specName, (c, s) => ({ // as per versions, first spec, then chain then finally non-versioned - objectSpread({}, - knownTypes.typesBundle?.spec?.[s]?.alias, - knownTypes.typesBundle?.chain?.[c]?.alias, - knownTypes.typesAlias - ) - ); + ...(knownTypes.typesBundle?.spec?.[s]?.alias ?? {}), + ...(knownTypes.typesBundle?.chain?.[c]?.alias ?? {}), + ...(knownTypes.typesAlias ?? {}) + })); } /**