fix(@embark/deployment): don't break when using abiDefinitions

In https://github.com/embark-framework/embark/pull/1119 we've introduced a feature where
users can provide an already compiled ABI for Smart Contracts so they can be used
without the need to compiling them again.

This also means that, internally, those Smart Contract object won't have any
bytecode attached to it.

Later on, in 387d33a076,  we've introduced a warning
which is rendered when a Smart Contract's bytecode is too large. The check expects
a Smart Contract object to have bytecode associated to it, which will break the code
in cases where a Smart Contract has already an ABI and therefore didn't need compilation.

This commit ensures we only check a Smart Contract's bytecode when bytecode exists for
the Smart Contract in question.
This commit is contained in:
Pascal Precht 2019-06-12 11:14:05 +02:00 committed by Pascal Precht
parent e288483661
commit 9e5c9c7f17
1 changed files with 4 additions and 0 deletions

View File

@ -96,6 +96,10 @@ class ContractDeployer {
async.waterfall([
function checkContractBytesize(next) {
if (!contract.code) {
return next();
}
const code = (contract.code.indexOf('0x') === 0) ? contract.code.substr(2) : contract.code;
const contractCodeLength = Buffer.from(code, 'hex').toString().length;
if(contractCodeLength > MAX_CONTRACT_BYTECODE_LENGTH) {