From 6e4761b29211418401813f1af477e4c392e543bd Mon Sep 17 00:00:00 2001 From: tarikgul Date: Tue, 26 Sep 2023 10:35:47 -0400 Subject: [PATCH] add overwrite for specName --- src/consts.ts | 5 ++--- src/registry/parseRegistry.spec.ts | 5 ++++- src/registry/parseRegistry.ts | 7 +++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/consts.ts b/src/consts.ts index e9ef924c..9b55014e 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -24,6 +24,7 @@ export const SYSTEM_PARACHAINS_NAMES = [ 'asset-hub-kusama', 'asset-hub-polkadot', 'asset-hub-westend', + 'asset-hub-rococo', 'bridge-hub-kusama', 'bridge-hub-polkadot', 'encointer-parachain', @@ -32,9 +33,7 @@ export const SYSTEM_PARACHAINS_NAMES = [ export const POLKADOT_ASSET_HUB_SPEC_NAMES = ['statemint', 'asset-hub-polkadot']; export const KUSAMA_ASSET_HUB_SPEC_NAMES = ['statemine', 'asset-hub-kusama']; export const WESTEND_ASSET_HUB_SPEC_NAMES = ['westmint', 'asset-hub-westend']; -// Rococo's asset hub is currently labeled as `statemine` within our registry. -// There I put both names a recognizable just in case it changes in polkadot-js. -export const ROCOCO_ASSET_HUB_SPEC_NAME = ['rococo', 'statemine', 'asset-hub-rococo']; +export const ROCOCO_ASSET_HUB_SPEC_NAME = ['asset-hub-rococo']; /** * The default xcm version to construct a xcm message. diff --git a/src/registry/parseRegistry.spec.ts b/src/registry/parseRegistry.spec.ts index 5ca9cccc..56d84572 100644 --- a/src/registry/parseRegistry.spec.ts +++ b/src/registry/parseRegistry.spec.ts @@ -11,7 +11,10 @@ describe('parseRegistry', () => { expect(registry.westend['0'].tokens).toStrictEqual(['WND']); expect(registry.rococo['0'].tokens).toStrictEqual(['ROC']); }); - + it('Should correctly overwrite rococos asset-hub specName', () => { + const registry = parseRegistry({}); + expect((registry.rococo['1000'].specName = 'asset-hub-rococo')); + }); it('Should correctly inject an injectedRegsitry', () => { const assetsInfo = {}; const foreignAssetsInfo = {}; diff --git a/src/registry/parseRegistry.ts b/src/registry/parseRegistry.ts index dbe4c174..9cce8714 100644 --- a/src/registry/parseRegistry.ts +++ b/src/registry/parseRegistry.ts @@ -2,6 +2,7 @@ import registry from '@substrate/asset-transfer-api-registry'; +import { ASSET_HUB_CHAIN_ID } from '../consts'; import type { AssetTransferApiOpts } from '../types'; import type { ChainInfoRegistry } from './types'; @@ -19,5 +20,11 @@ export const parseRegistry = (assetsOpts: AssetTransferApiOpts): ChainInfoRegist if (rococo) Object.assign(registry.rococo, rococo); } + /** + * This is a temporary overwrite to ensure the statemine specName is not shared between + * kusama and rococo for their asset-hub chains. + */ + registry.rococo[ASSET_HUB_CHAIN_ID].specName = 'asset-hub-rococo'; + return registry as ChainInfoRegistry; };