Skip to content

Commit

Permalink
fix: add error message for chains that dont support parachains (#642)
Browse files Browse the repository at this point in the history
* fix: add error message for chains that dont support parachains
  • Loading branch information
TarikGul committed Aug 19, 2021
1 parent 3d377fa commit 1f5f6b7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/controllers/paras/ParasController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export default class ParasController extends AbstractController<ParasService> {
{ query: { at } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);

ParasController.sanitizedSend(res, await this.service.paras(hash));
Expand All @@ -35,6 +37,8 @@ export default class ParasController extends AbstractController<ParasService> {
{ params: { paraId }, query: { at } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);
const paraIdArg = this.parseNumberOrThrow(
paraId,
Expand All @@ -51,6 +55,8 @@ export default class ParasController extends AbstractController<ParasService> {
{ query: { at } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);

ParasController.sanitizedSend(res, await this.service.crowdloans(hash));
Expand All @@ -60,6 +66,8 @@ export default class ParasController extends AbstractController<ParasService> {
{ params: { paraId }, query: { at } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);
const paraIdArg = this.parseNumberOrThrow(
paraId,
Expand All @@ -76,6 +84,8 @@ export default class ParasController extends AbstractController<ParasService> {
{ query: { at, currentLeaseHolders } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);
const includeCurrentLeaseHolders = currentLeaseHolders !== 'false';

Expand All @@ -89,11 +99,19 @@ export default class ParasController extends AbstractController<ParasService> {
{ query: { at } },
res
): Promise<void> => {
this.checkParasModule();

const hash = await this.getHashFromAt(at);

ParasController.sanitizedSend(
res,
await this.service.auctionsCurrent(hash)
);
};

private checkParasModule = (): void => {
if (!this.api.query.paras) {
throw new Error('Parachains are not yet supported on this network.');
}
};
}

0 comments on commit 1f5f6b7

Please sign in to comment.