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',
// 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:

View File

@ -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: {

View File

@ -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:

View File

@ -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,