From 96b4da6734e46c01ef4fbd76dffecafc9931de81 Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 17 Aug 2023 14:04:49 +0400 Subject: [PATCH 1/3] Add Type Bundle for Cere Mainnet --- CHANGELOG.md | 2 +- packages/apps-config/src/api/typesBundle.ts | 77 +++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e556a4538be..a6b563da7c5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # CHANGELOG ## vNext -... +- Added Type Bundle for Cere Mainnet to be able to see all historical blocks ## 0.23.0 - Reverted to commit `f778359c` (between tags `v0.121.1` and `v0.122.1` of Polkadot-JS Apps) to align with our node version and fix the Smart Contract Page diff --git a/packages/apps-config/src/api/typesBundle.ts b/packages/apps-config/src/api/typesBundle.ts index 95795bb27df3..b257252a91f8 100644 --- a/packages/apps-config/src/api/typesBundle.ts +++ b/packages/apps-config/src/api/typesBundle.ts @@ -10,6 +10,83 @@ import type { OverrideBundleType } from '@polkadot/types/types'; /* eslint-disable sort-keys */ export const typesBundle = { + "chain": { + "Cere Mainnet Beta": { + "types": [ + { + "minmax": [ + 266, + 281 + ], + "types": { + "ChainId": "u8", + "DepositNonce": "u64", + "ResourceId": "[u8; 32]", + "ProposalStatus": { + "_enum": [ + "Initiated", + "Approved", + "Rejected" + ] + }, + "ProposalVotes": { + "votes_for": "Vec", + "votes_against": "Vec", + "status": "ProposalStatus", + "expiry": "BlockNumber" + }, + "TokenId": "u256", + "Erc721Token": { + "id": "TokenId", + "metadata": "Vec" + }, + "Address": "IndicesLookupSource", + "LookupSource": "IndicesLookupSource", + "AccountInfo": "AccountInfoWithDualRefCount", + "ValidatorPrefs": { + "commission": "Compact" + } + } + }, + { + "minmax": [ + 282, + 294 + ], + "types": { + "ChainId": "u8", + "DepositNonce": "u64", + "ResourceId": "[u8; 32]", + "ProposalStatus": { + "_enum": [ + "Initiated", + "Approved", + "Rejected" + ] + }, + "ProposalVotes": { + "votes_for": "Vec", + "votes_against": "Vec", + "status": "ProposalStatus", + "expiry": "BlockNumber" + }, + "TokenId": "u256", + "Erc721Token": { + "id": "TokenId", + "metadata": "Vec" + }, + "Address": "MultiAddress", + "LookupSource": "MultiAddress", + "AccountInfo": "AccountInfoWithDualRefCount" + } + }, + { + "minmax": [295, null], + "types": {} + } + ] + }, + }, "spec": { "Crab": { "alias": {}, From 53b2ab8055817ea17930fa1f57e12cf4fcd73a3b Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 17 Aug 2023 16:02:31 +0400 Subject: [PATCH 2/3] Release 0.24.0 --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6b563da7c5d..a77dacae2036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # CHANGELOG ## vNext +... + +## 0.24.0 - Added Type Bundle for Cere Mainnet to be able to see all historical blocks ## 0.23.0 diff --git a/package.json b/package.json index 72e7898248ff..54e216e50502 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "url": "https://github.com/polkadot-js/apps.git" }, "sideEffects": false, - "version": "0.23.0", + "version": "0.24.0", "workspaces": [ "packages/*" ], From 46cbb8c51be4f374828676502e93c13dd18f09e9 Mon Sep 17 00:00:00 2001 From: shamilkhan Date: Thu, 17 Aug 2023 17:08:06 +0400 Subject: [PATCH 3/3] Add auto generation of Cere Network type bundle. --- packages/apps-config/src/api/chain/cere.ts | 102 +++++++++++++----- packages/apps-config/src/api/chain/index.ts | 13 +++ .../apps-config/src/api/typesBundle.spec.ts | 15 ++- packages/apps-config/src/api/typesBundle.ts | 7 +- 4 files changed, 110 insertions(+), 27 deletions(-) create mode 100644 packages/apps-config/src/api/chain/index.ts diff --git a/packages/apps-config/src/api/chain/cere.ts b/packages/apps-config/src/api/chain/cere.ts index 9b23ffe3ecdb..a62f1996d2d3 100644 --- a/packages/apps-config/src/api/chain/cere.ts +++ b/packages/apps-config/src/api/chain/cere.ts @@ -1,28 +1,82 @@ -// Copyright 2017-2021 @polkadot/apps-config authors & contributors +// Copyright 2017-2023 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -// structs need to be in order -/* eslint-disable sort-keys */ +import type { OverrideBundleDefinition } from '@polkadot/types/types'; -export default { - ChainId: 'u8', - DepositNonce: 'u64', - ResourceId: '[u8; 32]', - ProposalStatus: { - _enum: ['Initiated', 'Approved', 'Rejected'] - }, - ProposalVotes: { - votes_for: 'Vec', - votes_against: 'Vec', - status: 'ProposalStatus', - expiry: 'BlockNumber' - }, - TokenId: 'u256', - Erc721Token: { - id: 'TokenId', - metadata: 'Vec' - }, - Address: 'MultiAddress', - LookupSource: 'MultiAddress', - AccountInfo: 'AccountInfoWithDualRefCount' +const definitions: OverrideBundleDefinition = { + types: [ + { + minmax: [ + 266, + 281 + ], + types: { + ChainId: 'u8', + DepositNonce: 'u64', + ResourceId: '[u8; 32]', + ProposalStatus: { + _enum: [ + 'Initiated', + 'Approved', + 'Rejected' + ] + }, + ProposalVotes: { + votes_for: 'Vec', + votes_against: 'Vec', + status: 'ProposalStatus', + expiry: 'BlockNumber' + }, + TokenId: 'u256', + Erc721Token: { + id: 'TokenId', + metadata: 'Vec' + }, + Address: 'IndicesLookupSource', + LookupSource: 'IndicesLookupSource', + AccountInfo: 'AccountInfoWithDualRefCount', + ValidatorPrefs: { + commission: 'Compact' + } + } + }, + { + minmax: [ + 282, + 294 + ], + types: { + ChainId: 'u8', + DepositNonce: 'u64', + ResourceId: '[u8; 32]', + ProposalStatus: { + _enum: [ + 'Initiated', + 'Approved', + 'Rejected' + ] + }, + ProposalVotes: { + votes_for: 'Vec', + votes_against: 'Vec', + status: 'ProposalStatus', + expiry: 'BlockNumber' + }, + TokenId: 'u256', + Erc721Token: { + id: 'TokenId', + metadata: 'Vec' + }, + Address: 'MultiAddress', + LookupSource: 'MultiAddress', + AccountInfo: 'AccountInfoWithDualRefCount' + } + }, + { + minmax: [295, null], + types: {} + } + ] }; + +export default definitions; diff --git a/packages/apps-config/src/api/chain/index.ts b/packages/apps-config/src/api/chain/index.ts new file mode 100644 index 000000000000..3db012621cc3 --- /dev/null +++ b/packages/apps-config/src/api/chain/index.ts @@ -0,0 +1,13 @@ +// Copyright 2017-2023 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { OverrideBundleDefinition } from '@polkadot/types/types'; + +import cere from './cere.js'; + +// NOTE: The mapping is done from chain name in system.chain +const chain: Record = { + 'Cere Mainnet Beta': cere +}; + +export default chain; diff --git a/packages/apps-config/src/api/typesBundle.spec.ts b/packages/apps-config/src/api/typesBundle.spec.ts index 846629fa7990..139c0372218b 100644 --- a/packages/apps-config/src/api/typesBundle.spec.ts +++ b/packages/apps-config/src/api/typesBundle.spec.ts @@ -5,11 +5,16 @@ import fs from 'fs'; import { objectSpread } from '@polkadot/util'; +import chain from './chain/index.js'; import spec from './spec'; it('generates the typesBundle', (): void => { const specEntries = Object.entries(spec); - const typesBundle: { spec: Record } = { spec: {} }; + const chainEntries = Object.entries(chain); + const typesBundle: { + chain: Record + spec: Record + } = { chain: {}, spec: {} }; specEntries.forEach(([k, v]): void => { const value = objectSpread<{ derives: unknown }>({}, v); @@ -19,6 +24,14 @@ it('generates the typesBundle', (): void => { typesBundle.spec[k] = value; }); + 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-2022 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 diff --git a/packages/apps-config/src/api/typesBundle.ts b/packages/apps-config/src/api/typesBundle.ts index b257252a91f8..73b50b4597b3 100644 --- a/packages/apps-config/src/api/typesBundle.ts +++ b/packages/apps-config/src/api/typesBundle.ts @@ -81,11 +81,14 @@ export const typesBundle = { } }, { - "minmax": [295, null], + "minmax": [ + 295, + null + ], "types": {} } ] - }, + } }, "spec": { "Crab": {