Skip to content

Commit

Permalink
updated BaseErrorsEnum
Browse files Browse the repository at this point in the history
  • Loading branch information
bee344 committed Feb 6, 2024
1 parent fa24962 commit ede9bf9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/errors/BaseError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/registry/parseRegistry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ describe('parseRegistry', () => {
};
const err = () => parseRegistry(reg as ChainInfoRegistry<ChainInfoKeys>, 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';
Expand Down
5 changes: 3 additions & 2 deletions src/registry/parseRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -55,7 +56,7 @@ const propertyIterator = (input: object, chain: ChainInfo<ChainInfoKeys>, 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
Expand All @@ -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);
Expand Down

0 comments on commit ede9bf9

Please sign in to comment.