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:
Antonio 2023-01-05 12:12:26 +01:00 committed by GitHub
parent 5e0f61c3db
commit aeacede967
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View 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;

View File

@ -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