diff --git a/.changeset/three-fans-attend.md b/.changeset/three-fans-attend.md new file mode 100644 index 000000000..48e2f23ae --- /dev/null +++ b/.changeset/three-fans-attend.md @@ -0,0 +1,5 @@ +--- +'@graphprotocol/graph-cli': patch +--- + +remove studio network validation checks diff --git a/packages/cli/src/command-helpers/studio.test.ts b/packages/cli/src/command-helpers/studio.test.ts deleted file mode 100644 index e73d4634f..000000000 --- a/packages/cli/src/command-helpers/studio.test.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { allowedStudioNetworks, validateStudioNetwork } from './studio'; - -describe('Version Command Helpers', () => { - describe('validateStudioNetwork', () => { - describe("When it's studio", () => { - test("And it's Ethereum mainnet", () => { - expect(() => - validateStudioNetwork({ - studio: true, - network: 'mainnet', - }), - ).not.toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - - test("And it's Gnosis chain", () => { - expect(() => - validateStudioNetwork({ - studio: true, - network: 'gnosis', - }), - ).not.toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - - test('And no network is passed', () => { - expect(() => - validateStudioNetwork({ - studio: true, - network: undefined, - }), - ).not.toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - - test("And it's NOT an allowed network", () => { - expect(() => - validateStudioNetwork({ - product: 'subgraph-studio', - network: 'moonriver', - }), - ).toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - }); - - describe("When it's NOT studio", () => { - test("And it's Rinkeby", () => { - expect(() => - validateStudioNetwork({ - studio: false, - network: 'rinkeby', - }), - ).not.toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - - test("And it's NOT an allowed network", () => { - expect(() => - validateStudioNetwork({ - product: 'hosted-service', - network: 'celo', - }), - ).not.toThrow( - new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ), - ); - }); - }); - }); -}); diff --git a/packages/cli/src/command-helpers/studio.ts b/packages/cli/src/command-helpers/studio.ts deleted file mode 100644 index a86e31096..000000000 --- a/packages/cli/src/command-helpers/studio.ts +++ /dev/null @@ -1,61 +0,0 @@ -export const allowedStudioNetworks = [ - 'mainnet', - 'rinkeby', - 'goerli', - 'gnosis', - 'chapel', - 'optimism-goerli', - 'clover', - 'fantom', - 'matic', - 'fantom-testnet', - 'arbitrum-goerli', - 'fuji', - 'celo-alfajores', - 'mumbai', - 'aurora-testnet', - 'near-testnet', - 'optimism', - 'optimism-goerli', - 'theta-testnet-001', - 'osmo-test-4', - 'base-testnet', - 'base', - 'celo', - 'arbitrum-one', - 'arbitrum-sepolia', - 'avalanche', - 'zksync-era', - 'zksync-era-testnet', - 'sepolia', - 'polygon-zkevm-testnet', - 'polygon-zkevm', - 'scroll-sepolia', - 'scroll', -] as const; - -export const validateStudioNetwork = ({ - studio, - product, - network, -}: { - studio?: string | boolean; - product?: string; - network?: string; -}) => { - const isStudio = studio || product === 'subgraph-studio'; - const isAllowedNetwork = - !network || - allowedStudioNetworks.includes( - // @ts-expect-error we're checking if the network is allowed - network, - ); - - if (isStudio && !isAllowedNetwork) { - throw new Error( - `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join( - ', ', - )}`, - ); - } -}; diff --git a/packages/cli/src/commands/deploy.ts b/packages/cli/src/commands/deploy.ts index eaa4ac3a8..819b758ff 100644 --- a/packages/cli/src/commands/deploy.ts +++ b/packages/cli/src/commands/deploy.ts @@ -10,7 +10,6 @@ import { DEFAULT_IPFS_URL } from '../command-helpers/ipfs'; import { createJsonRpcClient } from '../command-helpers/jsonrpc'; import { updateSubgraphNetwork } from '../command-helpers/network'; import { chooseNodeUrl, getHostedServiceSubgraphId } from '../command-helpers/node'; -import { validateStudioNetwork } from '../command-helpers/studio'; import { assertGraphTsVersion, assertManifestApiVersion } from '../command-helpers/version'; import { GRAPH_CLI_SHARED_HEADERS } from '../constants'; import Protocol from '../protocols'; @@ -410,30 +409,10 @@ export default class DeployCommand extends Command { await ipfsClient.pin.add(ipfsHash); - try { - const dataSourcesAndTemplates = DataSourcesExtractor.fromManifestString(manifestFile); - - for (const { network } of dataSourcesAndTemplates) { - validateStudioNetwork({ studio, product, network }); - } - } catch (e) { - this.error(e, { exit: 1 }); - } - await deploySubgraph(ipfsHash); return; } - try { - const dataSourcesAndTemplates = await DataSourcesExtractor.fromFilePath(manifest); - - for (const { network } of dataSourcesAndTemplates) { - validateStudioNetwork({ studio, product, network }); - } - } catch (e) { - this.error(e, { exit: 1 }); - } - let protocol; try { // Checks to make sure deploy doesn't run against diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 516da493b..1c0f2752d 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -13,7 +13,6 @@ import { initNetworksConfig } from '../command-helpers/network'; import { chooseNodeUrl } from '../command-helpers/node'; import { generateScaffold, writeScaffold } from '../command-helpers/scaffold'; import { withSpinner } from '../command-helpers/spinner'; -import { validateStudioNetwork } from '../command-helpers/studio'; import { getSubgraphBasename, validateSubgraphName } from '../command-helpers/subgraph'; import debugFactory from '../debug'; import Protocol, { ProtocolName } from '../protocols'; @@ -245,8 +244,6 @@ export default class InitCommand extends Command { subgraphName, contractName, node, - studio, - product, startBlock, spkgPath, skipInstall, @@ -322,8 +319,6 @@ export default class InitCommand extends Command { indexEvents: answers.indexEvents, contractName: answers.contractName, node, - studio: answers.studio, - product: answers.product, startBlock: answers.startBlock, spkgPath: answers.spkgPath, skipInstall, @@ -1074,8 +1069,6 @@ async function initSubgraphFromContract( indexEvents, contractName, node, - studio, - product, startBlock, spkgPath, skipInstall, @@ -1090,8 +1083,6 @@ async function initSubgraphFromContract( indexEvents: boolean; contractName?: string; node?: string; - studio: boolean; - product?: string; startBlock?: string; spkgPath?: string; skipInstall: boolean; @@ -1132,15 +1123,6 @@ async function initSubgraphFromContract( this.error(`ABI does not contain any events`, { exit: 1 }); } - // We can validate this before the scaffold because we receive - // the network from the form or via command line argument. - // We don't need to read the manifest in this case. - try { - validateStudioNetwork({ studio, product, network }); - } catch (e) { - this.error(e, { exit: 1 }); - } - // Scaffold subgraph const scaffold = await withSpinner( `Create subgraph scaffold`,