From b5c81bd41a76e871a128a3ab61fb32f539121c70 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Tue, 23 Jul 2019 11:28:33 -0400 Subject: [PATCH] feat(@embark/pipeline): enable choosing which fields to filter out --- dapps/templates/boilerplate/config/contracts.js | 2 ++ dapps/templates/demo/config/contracts.js | 2 ++ dapps/templates/simple/contracts.js | 2 ++ packages/embark-pipeline/src/index.js | 16 +++++++++++----- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dapps/templates/boilerplate/config/contracts.js b/dapps/templates/boilerplate/config/contracts.js index dfc93212a..774f89719 100644 --- a/dapps/templates/boilerplate/config/contracts.js +++ b/dapps/templates/boilerplate/config/contracts.js @@ -52,7 +52,9 @@ module.exports = { //strategy: 'implicit', // 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, + // filteredFields: [], contracts: { // example: diff --git a/dapps/templates/demo/config/contracts.js b/dapps/templates/demo/config/contracts.js index 3d9228380..c39129762 100644 --- a/dapps/templates/demo/config/contracts.js +++ b/dapps/templates/demo/config/contracts.js @@ -52,7 +52,9 @@ module.exports = { //strategy: 'implicit', // 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, + // filteredFields: [], contracts: { SimpleStorage: { diff --git a/dapps/templates/simple/contracts.js b/dapps/templates/simple/contracts.js index 78e7be48c..64b501b89 100644 --- a/dapps/templates/simple/contracts.js +++ b/dapps/templates/simple/contracts.js @@ -52,7 +52,9 @@ module.exports = { //strategy: 'implicit', // 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, + // filteredFields: [], contracts: { // example: diff --git a/packages/embark-pipeline/src/index.js b/packages/embark-pipeline/src/index.js index 670d596f8..6c0da6aed 100644 --- a/packages/embark-pipeline/src/index.js +++ b/packages/embark-pipeline/src/index.js @@ -343,11 +343,17 @@ class Pipeline { async.each(contracts, (contract, eachCb) => { if (self.embark.config.contractsConfig.minimalContractSize) { contract = Object.assign({}, contract); - delete contract.code; - delete contract.runtimeBytecode; - delete contract.realRuntimeBytecode; - delete contract.gasEstimates; - delete contract.swarmHash; + + const filteredFields = self.embark.config.contractsConfig.filteredFields || [ + 'code', + 'runtimeBytecode', + 'realRuntimeBytecode', + 'gasEstimates', + 'swarmHash' + ]; + filteredFields.forEach(filteredField => { + delete contract[filteredField]; + }); } self.fs.writeJson(dappPath( self.buildDir,