Skip to content

Commit 05135c1

Browse files
Improve call-to-action message for non-existing chain (#1842)
* improve call-to-action message for non-existing chain * lint
1 parent 63e2656 commit 05135c1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/cli/src/commands/init.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ async function processInitForm(
432432
if (remaining == 0) return shown;
433433
if (shown.length === choices.length) {
434434
shown.push({
435-
name: '--other--',
435+
name: 'N/A',
436436
value: '',
437437
hint: '· other network not on the list',
438438
message: `Other`,
@@ -485,15 +485,21 @@ async function processInitForm(
485485
.map(networkToChoice)
486486
.filter(({ value }) => (value ?? '').includes(input.toLowerCase())),
487487
),
488-
validate: value => {
489-
if (value === '--other--') {
490-
return 'To add a network refer to https://github.com/graphprotocol/networks-registry';
491-
}
492-
return networks.find(n => n.id === value) ? true : 'Pick a network';
493-
},
488+
validate: value =>
489+
value === 'N/A' || networks.find(n => n.id === value) ? true : 'Pick a network',
494490
result: value => {
495491
initDebugger.extend('processInitForm')('networkId: %O', value);
496-
network = networks.find(n => n.id === value)!;
492+
const foundNetwork = networks.find(n => n.id === value);
493+
if (!foundNetwork) {
494+
this.log(`
495+
The chain list is populated from the Networks Registry:
496+
497+
https://github.com/graphprotocol/networks-registry
498+
499+
To add a chain to the registry you can create an issue or submit a PR`);
500+
process.exit(0);
501+
}
502+
network = foundNetwork;
497503
promptManager.setOptions('protocol', {
498504
choices: [
499505
{

0 commit comments

Comments
 (0)