Skip to content

Commit

Permalink
add overwrite for specName
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Sep 26, 2023
1 parent c002bbe commit 6e4761b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion src/registry/parseRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down
7 changes: 7 additions & 0 deletions src/registry/parseRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
};

0 comments on commit 6e4761b

Please sign in to comment.