From ede9bf95ce5334cc8b750958ced17312c4019a97 Mon Sep 17 00:00:00 2001 From: bee344 Date: Tue, 6 Feb 2024 11:49:10 -0300 Subject: [PATCH] updated BaseErrorsEnum --- src/errors/BaseError.ts | 4 ++++ src/registry/parseRegistry.spec.ts | 2 +- src/registry/parseRegistry.ts | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/errors/BaseError.ts b/src/errors/BaseError.ts index f34cf03a..dbddc045 100644 --- a/src/errors/BaseError.ts +++ b/src/errors/BaseError.ts @@ -28,6 +28,10 @@ export enum BaseErrorsEnum { * The following pallet is not found. */ PalletNotFound = 'PalletNotFound', + /** + * The specName was not provided when injecting a new chain in the registry. + */ + SpecNameNotProvided = 'SpecNameNotProvided', /** * The direction in which these assets are going to be sent is incorrect. */ diff --git a/src/registry/parseRegistry.spec.ts b/src/registry/parseRegistry.spec.ts index 10f8bb34..bb903169 100644 --- a/src/registry/parseRegistry.spec.ts +++ b/src/registry/parseRegistry.spec.ts @@ -360,7 +360,7 @@ describe('parseRegistry', () => { }; const err = () => parseRegistry(reg as ChainInfoRegistry, opts); - expect(err).toThrow('Must include specName when adding new chain to the registry'); + expect(err).toThrow('SpecNameNotProvided'); }); it('Should correctly add a new foreignAsset ignoring the specName', () => { const specName = 'prorrata'; diff --git a/src/registry/parseRegistry.ts b/src/registry/parseRegistry.ts index 219783c8..f6131714 100644 --- a/src/registry/parseRegistry.ts +++ b/src/registry/parseRegistry.ts @@ -2,6 +2,7 @@ import { AnyJson } from '@polkadot/types/types'; import { ASSET_HUB_CHAIN_ID } from '../consts'; +import { BaseErrorsEnum } from '../errors'; import type { AssetTransferApiOpts } from '../types'; import { deepEqual } from '../util/deepEqual'; import type { @@ -55,7 +56,7 @@ const propertyIterator = (input: object, chain: ChainInfo, id: st }; /** - * Function to update the current chain registry with injected information. It + * Function to update the current chain registry with injected information. It * errors out when adding a new chain without defining a specName * * @param injectedChain chain information to add to the registry @@ -77,7 +78,7 @@ const updateRegistry = ( }; for (const id of Object.keys(injectedChain)) { if (!chain[id] && !injectedChain[id].specName) { - throw Error('Must include specName when adding new chain to the registry'); + throw Error(BaseErrorsEnum.SpecNameNotProvided); } else if (!chain[id]) { Object.assign(buffer, injectedChain[id]); Object.assign(injectedChain[id], buffer);