feat(@embark/pipeline): enable choosing which fields to filter out

This commit is contained in:
Jonathan Rainville 2019-07-23 11:28:33 -04:00
parent f9fb302740
commit b5c81bd41a
4 changed files with 17 additions and 5 deletions

View File

@ -52,7 +52,9 @@ module.exports = {
//strategy: 'implicit', //strategy: 'implicit',
// minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes // minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes
// Using filteredFields lets you customize which field you want to filter out of the contract file (requires minimalContractSize: true)
// minimalContractSize: false, // minimalContractSize: false,
// filteredFields: [],
contracts: { contracts: {
// example: // example:

View File

@ -52,7 +52,9 @@ module.exports = {
//strategy: 'implicit', //strategy: 'implicit',
// minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes // minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes
// Using filteredFields lets you customize which field you want to filter out of the contract file (requires minimalContractSize: true)
// minimalContractSize: false, // minimalContractSize: false,
// filteredFields: [],
contracts: { contracts: {
SimpleStorage: { SimpleStorage: {

View File

@ -52,7 +52,9 @@ module.exports = {
//strategy: 'implicit', //strategy: 'implicit',
// minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes // minimalContractSize, when set to true, tells Embark to generate contract files without the heavy bytecodes
// Using filteredFields lets you customize which field you want to filter out of the contract file (requires minimalContractSize: true)
// minimalContractSize: false, // minimalContractSize: false,
// filteredFields: [],
contracts: { contracts: {
// example: // example:

View File

@ -343,11 +343,17 @@ class Pipeline {
async.each(contracts, (contract, eachCb) => { async.each(contracts, (contract, eachCb) => {
if (self.embark.config.contractsConfig.minimalContractSize) { if (self.embark.config.contractsConfig.minimalContractSize) {
contract = Object.assign({}, contract); contract = Object.assign({}, contract);
delete contract.code;
delete contract.runtimeBytecode; const filteredFields = self.embark.config.contractsConfig.filteredFields || [
delete contract.realRuntimeBytecode; 'code',
delete contract.gasEstimates; 'runtimeBytecode',
delete contract.swarmHash; 'realRuntimeBytecode',
'gasEstimates',
'swarmHash'
];
filteredFields.forEach(filteredField => {
delete contract[filteredField];
});
} }
self.fs.writeJson(dappPath( self.fs.writeJson(dappPath(
self.buildDir, self.buildDir,