Skip to content

Commit

Permalink
feat: [AHM] - Add AH Next Westend chain (#1586)
Browse files Browse the repository at this point in the history
- Sort alphabetically available controllers in other chain-config to check more easily
- Small correction in guide
  • Loading branch information
Imod7 authored Feb 25, 2025
1 parent f0e84a2 commit 7217e6e
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 14 deletions.
2 changes: 1 addition & 1 deletion guides/CHAIN_INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A chain builder can follow the steps below and submit a chain's controller confi

Create a controller config for your chain. The shape of the controller config is specified [here](/src/types/chains-config/ControllerConfig.ts). The `controllers` property has keys from the [controller export](/src/controllers/index.ts), which is an exhaustive collection of the available controller classes. In order to see the path(s) associated with a controller one must look in the controller source code.

The easiest way to start creating a controller config would be to copy [defaultControllers.ts](/src/chains-config/ControllerConfig.ts) and name the file and export `{specName}Controllers`. Then remove or add any of the controllers you want inside of the `controllers` array. Ensure to export the controller config from `chains-config` by adding `export * from './{specName}Controllers.ts'` in [/src/chains-config/index.ts](/src/chains-config/index.ts).
The easiest way to start creating a controller config would be to copy [defaultControllers.ts](/src/chains-config/defaultControllers.ts) and name the file and export `{specName}Controllers`. Then remove or add any of the controllers you want inside of the `controllers` array. Ensure to export the controller config from `chains-config` by adding `export * from './{specName}Controllers.ts'` in [/src/chains-config/index.ts](/src/chains-config/index.ts).

To determine what controllers to include, one must consider the runtime logic, specifically what pallets the chain uses. It is important to keep in mind the assumptions the service's logic makes and what exact pallets the service queries.

Expand Down
65 changes: 65 additions & 0 deletions src/chains-config/assetHubNextWestendControllers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright 2017-2025 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { ControllerConfig } from '../types/chains-config';
import { initLRUCache, QueryFeeDetailsCache } from './cache';

/**
* Asset Hub Next Westend configuration for Sidecar.
*/
export const assetHubNextWestendControllers: ControllerConfig = {
controllers: [
'AccountsAssets',
'AccountsBalanceInfo',
'AccountsPoolAssets',
'AccountsProxyInfo',
'AccountsStakingInfo',
'AccountsStakingPayouts',
'AccountsValidate',
'AccountsVestingInfo',
'Blocks',
'BlocksExtrinsics',
'BlocksRawExtrinsics',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsAssetConversion',
'PalletsConsts',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsNominationPools',
'PalletsOnGoingReferenda',
'PalletsStakingProgress',
'PalletsStakingValidators',
'PalletsStorage',
'PalletsPoolAssets',
'RuntimeCode',
'RuntimeMetadata',
'RuntimeSpec',
'TransactionDryRun',
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
],
options: {
finalizes: true,
minCalcFeeRuntime: 601,
blockStore: initLRUCache(),
hasQueryFeeApi: new QueryFeeDetailsCache(null, null),
},
};
6 changes: 3 additions & 3 deletions src/chains-config/assetHubWestendControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const assetHubWestendControllers: ControllerConfig = {
'AccountsAssets',
'AccountsBalanceInfo',
'AccountsCompare',
'AccountsProxyInfo',
'AccountsPoolAssets',
'AccountsProxyInfo',
'AccountsValidate',
'Blocks',
'BlocksExtrinsics',
Expand All @@ -36,10 +36,10 @@ export const assetHubWestendControllers: ControllerConfig = {
'NodeVersion',
'PalletsAssets',
'PalletsAssetConversion',
'PalletsDispatchables',
'PalletsConsts',
'PalletsEvents',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsPoolAssets',
'RuntimeCode',
'RuntimeMetadata',
Expand Down
2 changes: 1 addition & 1 deletion src/chains-config/defaultControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const defaultControllers: ControllerConfig = {
'NodeTransactionPool',
'NodeVersion',
'PalletsAssets',
'PalletsDispatchables',
'PalletsConsts',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsForeignAssets',
Expand Down
2 changes: 2 additions & 0 deletions src/chains-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { AbstractService } from '../services/AbstractService';
import { ControllerConfig } from '../types/chains-config';
import { acalaControllers } from './acalaControllers';
import { assetHubKusamaControllers } from './assetHubKusamaControllers';
import { assetHubNextWestendControllers } from './assetHubNextWestendControllers';
import { assetHubPolkadotControllers } from './assetHubPolkadotControllers';
import { assetHubWestendControllers } from './assetHubWestendControllers';
import { astarControllers } from './astarControllers';
Expand Down Expand Up @@ -65,6 +66,7 @@ const specToControllerMap: { [x: string]: ControllerConfig } = {
statemint: assetHubPolkadotControllers,
westmine: assetHubKusamaControllers,
'asset-hub-westend': assetHubWestendControllers,
'asset-hub-next-westend': assetHubNextWestendControllers,
westmint: assetHubWestendControllers,
shiden: shidenControllers,
astar: astarControllers,
Expand Down
6 changes: 3 additions & 3 deletions src/chains-config/kusamaControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ export const kusamaControllers: ControllerConfig = {
'AccountsVestingInfo',
'Blocks',
'BlocksExtrinsics',
'BlocksTrace',
'BlocksRawExtrinsics',
'BlocksTrace',
'CoretimeGeneric',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsDispatchables',
'PalletsConsts',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsNominationPools',
Expand All @@ -54,7 +55,6 @@ export const kusamaControllers: ControllerConfig = {
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
'CoretimeGeneric',
],
options: {
finalizes: true,
Expand Down
4 changes: 2 additions & 2 deletions src/chains-config/polkadotControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export const polkadotControllers: ControllerConfig = {
'AccountsVestingInfo',
'Blocks',
'BlocksExtrinsics',
'BlocksTrace',
'BlocksRawExtrinsics',
'BlocksTrace',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsDispatchables',
'PalletsConsts',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsNominationPools',
Expand Down
6 changes: 3 additions & 3 deletions src/chains-config/westendControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ export const westendControllers: ControllerConfig = {
'AccountsVestingInfo',
'Blocks',
'BlocksExtrinsics',
'BlocksTrace',
'BlocksRawExtrinsics',
'BlocksTrace',
'CoretimeGeneric',
'NodeNetwork',
'NodeTransactionPool',
'NodeVersion',
'PalletsDispatchables',
'PalletsConsts',
'PalletsDispatchables',
'PalletsErrors',
'PalletsEvents',
'PalletsNominationPools',
Expand All @@ -53,7 +54,6 @@ export const westendControllers: ControllerConfig = {
'TransactionFeeEstimate',
'TransactionMaterial',
'TransactionSubmit',
'CoretimeGeneric',
],
options: {
finalizes: true,
Expand Down
2 changes: 1 addition & 1 deletion src/types/chains-config/ControllerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IOption } from '../util';
* controller class names and the values are booleans indicating whether or not
* to include the controller.
*
* There is an additional `finalizes` field that is used to indicate wether or
* There is an additional `finalizes` field that is used to indicate whether or
* not a chain has finalized blocks. Practically, this only affects if
* `BlocksController` defaults to getFinalizedHead (in the case it finalizes) or
* getHeader (in the case it does not finalize)
Expand Down

0 comments on commit 7217e6e

Please sign in to comment.