Merge branch 'refactor_5_0_0' of github.com:embark-framework/embark into refactor_5_0_0

This commit is contained in:
Iuri Matias 2019-08-19 17:35:18 -04:00
commit cfb010c8b2
3 changed files with 19 additions and 2 deletions

View File

@ -22,8 +22,8 @@ class ContractDeployer {
async.waterfall([
(next) => {
this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (_params) => {
next();
this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (err, _params) => {
next(err);
});
},
(next) => {

View File

@ -0,0 +1,15 @@
// Check out definition 97 of the yellow paper: https://ethereum.github.io/yellowpaper/paper.pdf
const MAX_CONTRACT_BYTECODE_LENGTH = 24576;
export default function checkContractSize({contract}, callback) {
if (!contract.code) {
return callback();
}
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) {
return callback(new Error(`Bytecode for ${contract.className} contract is too large. Not deploying.`));
}
callback();
}

View File

@ -3,6 +3,7 @@ import {__} from 'embark-i18n';
const async = require('async');
const Web3 = require('web3');
const embarkJsUtils = require('embarkjs').Utils;
import checkContractSize from "./checkContractSize";
class EthereumBlockchainClient {
@ -14,6 +15,7 @@ class EthereumBlockchainClient {
this.embark.registerActionForEvent("deployment:contract:deployed", this.addContractJSONToPipeline.bind(this));
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', this.determineArguments.bind(this));
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', this.doLinking.bind(this));
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', checkContractSize.bind(this));
this.events.request("blockchain:client:register", "ethereum", this.getClient.bind(this));
this.events.request("deployment:deployer:register", "ethereum", this.deployer.bind(this));
}