mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-18 08:36:51 +00:00
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([
|
async.waterfall([
|
||||||
(next) => {
|
(next) => {
|
||||||
this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (_params) => {
|
this.plugins.emitAndRunActionsForEvent('deployment:contract:beforeDeploy', {contract: contract}, (err, _params) => {
|
||||||
next();
|
next(err);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(next) => {
|
(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 async = require('async');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const embarkJsUtils = require('embarkjs').Utils;
|
const embarkJsUtils = require('embarkjs').Utils;
|
||||||
|
import checkContractSize from "./checkContractSize";
|
||||||
|
|
||||||
class EthereumBlockchainClient {
|
class EthereumBlockchainClient {
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ class EthereumBlockchainClient {
|
|||||||
this.embark.registerActionForEvent("deployment:contract:deployed", this.addContractJSONToPipeline.bind(this));
|
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.determineArguments.bind(this));
|
||||||
this.embark.registerActionForEvent('deployment:contract:beforeDeploy', this.doLinking.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("blockchain:client:register", "ethereum", this.getClient.bind(this));
|
||||||
this.events.request("deployment:deployer:register", "ethereum", this.deployer.bind(this));
|
this.events.request("deployment:deployer:register", "ethereum", this.deployer.bind(this));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user