diff --git a/.changeset/fluffy-geckos-allow.md b/.changeset/fluffy-geckos-allow.md new file mode 100644 index 000000000..f97cd7985 --- /dev/null +++ b/.changeset/fluffy-geckos-allow.md @@ -0,0 +1,6 @@ +--- +'@sphinx-labs/plugins': patch +'@sphinx-labs/core': patch +--- + +Detect invalid network names for overrides diff --git a/packages/core/src/config/parse.ts b/packages/core/src/config/parse.ts index bb736d591..0289987f0 100644 --- a/packages/core/src/config/parse.ts +++ b/packages/core/src/config/parse.ts @@ -99,6 +99,7 @@ import { } from '../addresses' import { getTargetAddress, getTargetSalt, toContractKindEnum } from './utils' import { + SUPPORTED_LOCAL_NETWOKRS, SUPPORTED_MAINNETS, SUPPORTED_NETWORKS, SUPPORTED_TESTNETS, @@ -1623,7 +1624,14 @@ export const parseContractConstructorArgs = ( ) } - // Todo - check if any of network names listed in overrides are invalid + const invalidOverrideChains = userContractConfig.overrides?.flatMap((el) => + el.chains.filter( + (name) => + !Object.keys(SUPPORTED_MAINNETS).includes(name) && + !Object.keys(SUPPORTED_TESTNETS).includes(name) && + !Object.keys(SUPPORTED_LOCAL_NETWOKRS).includes(name) + ) + ) // Check if there are any variables which have ambiguous overrides (due to fields being listed multiple times for a given network) const ambigiousArgOverrides: { @@ -1782,6 +1790,16 @@ export const parseContractConstructorArgs = ( }) } + if (invalidOverrideChains && invalidOverrideChains.length > 0) { + logValidationError( + 'error', + `Detected invalid override network names for ${referenceName}:`, + invalidOverrideChains, + cre.silent, + cre.stream + ) + } + if (ambiguousArgOutput.length > 0) { logValidationError( 'error', diff --git a/packages/core/src/tasks/index.ts b/packages/core/src/tasks/index.ts index e92d08fe7..a392f3d86 100644 --- a/packages/core/src/tasks/index.ts +++ b/packages/core/src/tasks/index.ts @@ -106,8 +106,12 @@ export const proposeAbstractTask = async ( getProviderForChainId: GetProviderForChainId, spinner: ora.Ora = ora({ isSilent: true }), failureAction: FailureAction = FailureAction.EXIT, - getCanonicalConfig: GetCanonicalConfig = fetchCanonicalConfig -): Promise => { + getCanonicalConfig: GetCanonicalConfig = fetchCanonicalConfig, + signMetaTxn: boolean = true +): Promise<{ + proposalRequest: ProposalRequest | undefined + ipfsData: string[] | undefined +}> => { const apiKey = process.env.SPHINX_API_KEY if (!apiKey) { throw new Error(`Must provide a 'SPHINX_API_KEY' environment variable.`) @@ -233,7 +237,7 @@ export const proposeAbstractTask = async ( spinner.succeed( `Skipping proposal because your Sphinx config file has not changed.` ) - return + return { proposalRequest: undefined, ipfsData: undefined } } if (!cre.confirm && !dryRun) { @@ -263,9 +267,10 @@ export const proposeAbstractTask = async ( // Sign the meta-txn for the auth root, or leave it undefined if we're not relaying the proposal // to the back-end. - const metaTxnSignature = dryRun - ? undefined - : await signAuthRootMetaTxn(wallet, root) + const metaTxnSignature = + !dryRun && !signMetaTxn + ? undefined + : await signAuthRootMetaTxn(wallet, root) const proposalRequestLeafs: Array = [] for (const bundledLeaf of bundledLeafs) { @@ -393,10 +398,10 @@ export const proposeAbstractTask = async ( }, } + const compilerConfigArray = Object.values(compilerConfigs) if (!dryRun) { const websiteLink = blue(hyperlink('website', WEBSITE_URL)) await relayProposal(proposalRequest) - const compilerConfigArray = Object.values(compilerConfigs) await relayIPFSCommit(apiKey, orgId, compilerConfigArray) spinner.succeed( `Proposal succeeded! Go to the ${websiteLink} to approve the deployment.` @@ -405,7 +410,7 @@ export const proposeAbstractTask = async ( spinner.succeed(`Proposal dry run succeeded!`) } - return proposalRequest + return { proposalRequest, ipfsData: compilerConfigArray } } export const sphinxCommitAbstractSubtask = async ( diff --git a/packages/plugins/test/MultiChain.spec.ts b/packages/plugins/test/MultiChain.spec.ts index 217822117..a258cbe11 100644 --- a/packages/plugins/test/MultiChain.spec.ts +++ b/packages/plugins/test/MultiChain.spec.ts @@ -133,7 +133,7 @@ describe('Multi chain projects', () => { }, } - const proposalRequest = await proposeAbstractTask( + const { proposalRequest } = await proposeAbstractTask( newProjectTestInfo.userConfig, true, cre, @@ -145,13 +145,9 @@ describe('Multi chain projects', () => { getCanonicalConfig ) - if (!proposalRequest) { - throw new Error('The proposal is empty. Should never happen.') - } - await proposeThenApproveDeploymentThenExecute( newProjectTestInfo, - proposalRequest, + proposalRequest!, initialTestnets ) }) @@ -192,7 +188,7 @@ describe('Multi chain projects', () => { ) // Deploy the project on the existing chains. - const proposalRequest = await proposeAbstractTask( + const { proposalRequest } = await proposeAbstractTask( newProjectTestInfo.userConfig, true, cre, diff --git a/packages/plugins/test/helpers.ts b/packages/plugins/test/helpers.ts index 77e55a377..1962a2840 100644 --- a/packages/plugins/test/helpers.ts +++ b/packages/plugins/test/helpers.ts @@ -261,7 +261,7 @@ export const setupThenProposeThenApproveDeploymentThenExecute = async ( const { authAddress, userConfig, ownerPrivateKeys, proposerAddresses } = projectTestInfo - const proposalRequest = await proposeAbstractTask( + const { proposalRequest } = await proposeAbstractTask( userConfig, true, // Is testnet cre,