From 8fd705d2afe6ddcb53a16973256a0674e180be67 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 15 Mar 2018 16:30:18 +0100 Subject: Throw an error if contract file doesn't contain the contract with the same name --- packages/deployer/src/compiler.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/deployer/src/compiler.ts') diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 83977709b..206f333f6 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -228,6 +228,11 @@ export class Compiler { } const contractName = path.basename(fileName, constants.SOLIDITY_FILE_EXTENSION); const contractIdentifier = `${fileName}:${contractName}`; + if (_.isUndefined(compiled.contracts[contractIdentifier])) { + throw new Error( + `Contract ${contractName} not found in ${fileName}. Please make sure your contract has the same name as a file`, + ); + } const abi: Web3.ContractAbi = JSON.parse(compiled.contracts[contractIdentifier].interface); const bytecode = `0x${compiled.contracts[contractIdentifier].bytecode}`; const runtimeBytecode = `0x${compiled.contracts[contractIdentifier].runtimeBytecode}`; -- cgit v1.2.3