feat: re-introduce support for chain names (#8594)
* Update type-definitions dependency and remove outdated type definitions * Add support for chain names * Change license date to 2023 Co-authored-by: Jaco <jacogr@gmail.com> Co-authored-by: Jaco <jacogr@gmail.com>
This commit is contained in:
parent
5e0f61c3db
commit
aeacede967
9
packages/apps-config/src/api/chain/index.ts
Normal file
9
packages/apps-config/src/api/chain/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright 2017-2023 @polkadot/apps-config authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { OverrideBundleDefinition } from '@polkadot/types/types';
|
||||
|
||||
// NOTE: The mapping is done from chain name in system.chain
|
||||
const chain: Record<string, OverrideBundleDefinition> = {};
|
||||
|
||||
export default chain;
|
||||
@ -5,11 +5,13 @@ import fs from 'fs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import chain from './chain';
|
||||
import spec from './spec';
|
||||
|
||||
it('generates the typesBundle', (): void => {
|
||||
const specEntries = Object.entries(spec);
|
||||
const typesBundle: { spec: Record<string, unknown> } = { spec: {} };
|
||||
const chainEntries = Object.entries(chain);
|
||||
const typesBundle: { chain: Record<string, unknown>, spec: Record<string, unknown> } = { chain: {}, spec: {} };
|
||||
|
||||
specEntries.forEach(([k, v]): void => {
|
||||
const value = objectSpread<{ derives: unknown }>({}, v);
|
||||
@ -18,6 +20,14 @@ it('generates the typesBundle', (): void => {
|
||||
|
||||
typesBundle.spec[k] = value;
|
||||
});
|
||||
// Chain names override anything that spec name might define, if they conflict.
|
||||
chainEntries.forEach(([k, v]): void => {
|
||||
const value = objectSpread<{ derives: unknown }>({}, v);
|
||||
|
||||
delete value.derives;
|
||||
|
||||
typesBundle.chain[k] = value;
|
||||
});
|
||||
|
||||
fs.writeFileSync('packages/apps-config/src/api/typesBundle.ts', `// Copyright 2017-2023 @polkadot/apps-config authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
Loading…
Reference in New Issue
Block a user