Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add error message for chains that dont support parachains #642

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.');
}
};
}