Skip to content

Commit e5a3df7

Browse files
committed
Address review comments
1 parent 3a75a7f commit e5a3df7

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/cli/src/commands/init.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,17 @@ async function processInitForm(
594594
message: `IPFS node to use for fetching subgraph manifest`,
595595
initial: ipfsUrl,
596596
skip: () => !isComposedSubgraph,
597+
validate: value => {
598+
if (!value) {
599+
return 'IPFS node URL cannot be empty';
600+
}
601+
try {
602+
new URL(value);
603+
return true;
604+
} catch {
605+
return 'Please enter a valid URL';
606+
}
607+
},
597608
result: value => {
598609
ipfsNode = value;
599610
initDebugger.extend('processInitForm')('ipfs: %O', value);
@@ -615,9 +626,6 @@ async function processInitForm(
615626
initial: initContract,
616627
validate: async (value: string): Promise<string | boolean> => {
617628
if (isComposedSubgraph) {
618-
if (!ipfsNode) {
619-
return true;
620-
}
621629
const ipfs = createIpfsClient(ipfsNode);
622630
const { valid, error } = await validateSubgraphNetworkMatch(ipfs, value, network.id);
623631
if (!valid) {
@@ -835,7 +843,7 @@ async function processInitForm(
835843
await promptManager.executeInteractive();
836844

837845
// Validate network matches if loading from IPFS
838-
if (ipfsNode && source?.startsWith('Qm')) {
846+
if (isComposedSubgraph) {
839847
const ipfs = createIpfsClient(ipfsNode);
840848
try {
841849
const { valid, error } = await validateSubgraphNetworkMatch(ipfs, source!, network.id);

packages/cli/src/utils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,8 @@ export async function validateSubgraphNetworkMatch(
7575

7676
// Get network from first data source
7777
const sourceNetwork = allSources[0].network;
78-
if (!sourceNetwork) {
79-
return { valid: true }; // Network not specified in source, skip validation
80-
}
81-
82-
const normalizedSourceNetwork = sourceNetwork.toLowerCase();
83-
const normalizedTargetNetwork = targetNetwork.toLowerCase();
8478

85-
if (normalizedSourceNetwork !== normalizedTargetNetwork) {
79+
if (sourceNetwork !== targetNetwork) {
8680
return {
8781
valid: false,
8882
error: `Network mismatch: The source subgraph is indexing the '${sourceNetwork}' network, but you're creating a subgraph for '${targetNetwork}' network. When composing subgraphs, they must index the same network.`,

0 commit comments

Comments
 (0)