|
@@ -1,5 +1,7 @@
|
|
|
import StateAwareCommandBase from '../../base/StateAwareCommandBase';
|
|
|
import chalk from 'chalk';
|
|
|
+import { WsProvider } from '@polkadot/api';
|
|
|
+import ExitCodes from '../../ExitCodes';
|
|
|
|
|
|
type ApiSetUriArgs = { uri: string };
|
|
|
|
|
@@ -15,6 +17,11 @@ export default class ApiSetUri extends StateAwareCommandBase {
|
|
|
|
|
|
async run() {
|
|
|
const args: ApiSetUriArgs = <ApiSetUriArgs> this.parse(ApiSetUri).args;
|
|
|
+ try {
|
|
|
+ new WsProvider(args.uri);
|
|
|
+ } catch(e) {
|
|
|
+ this.error('The WS provider uri seems to be incorrect', { exit: ExitCodes.InvalidInput });
|
|
|
+ }
|
|
|
await this.setPreservedState({ apiUri: args.uri });
|
|
|
this.log(chalk.greenBright('Api uri successfuly changed! New uri: ') + chalk.white(args.uri))
|
|
|
}
|