mirror of https://github.com/embarklabs/embark.git
Merge branch 'refactor_5_0_0' of github.com:embark-framework/embark into refactor_5_0_0
This commit is contained in:
commit
cfb010c8b2
|
@ -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) => {
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue