Skip to content

Commit 7e95705

Browse files
committed
fix protocol flag validation
1 parent 4edbedc commit 7e95705

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/cli/src/commands/init.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,20 +234,19 @@ export default class InitCommand extends Command {
234234

235235
const protocolInstance = new Protocol(protocol as ProtocolName);
236236

237-
if (fromSubgraph && protocolInstance.isComposedSubgraph()) {
238-
this.error('--protocol must be subgraph when using --from-subgraph');
239-
}
240-
241-
if (!fromSubgraph && protocolInstance.isComposedSubgraph()) {
237+
if (fromSubgraph && !protocolInstance.isComposedSubgraph()) {
242238
this.error('--protocol can only be subgraph when using --from-subgraph');
243239
}
244240

245-
if (fromSubgraph && !protocolInstance.isComposedSubgraph()) {
246-
this.error('--protocol can only be subgraph when using --from-subgraph');
241+
if (
242+
fromContract &&
243+
(protocolInstance.isComposedSubgraph() || protocolInstance.isSubstreams())
244+
) {
245+
this.error('--protocol cannot be subgraph or substreams when using --from-contract');
247246
}
248247

249-
if (fromContract && protocolInstance.isComposedSubgraph()) {
250-
this.error('--protocol can only be subgraph when using --from-subgraph');
248+
if (spkgPath && !protocolInstance.isSubstreams()) {
249+
this.error('--protocol can only be substreams when using --spkg');
251250
}
252251

253252
// Only fetch contract info and ABI for non-source-subgraph cases

0 commit comments

Comments
 (0)