All files / src/chainManagement generateDeploymentDetails.js

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 333x                     3x 2x 2x   3x             2x                 3x  
const log = require('../log')
 
/**
 * Generates deployment details from a map of deployed chains and
 * covenants that mimics the standard Interbit manifest. Used in the
 * start script to create a `setManifest` action.
 * Set for deprecation (#263)
 * @param {Object} chainManifest - The map of chain aliases to chain ids.
 * @param {Object} covenants - The map of covenant aliases to covenant hashes.
 * @returns {Object} - Details of node deployment.
 */
const generateDeploymentDetails = (chainManifest, covenantHashes) => {
  log.info({ chainManifest, covenantHashes })
  return {
    chains: Object.entries(chainManifest).reduce(
      (chains, [alias, chainData]) => ({
        ...chains,
        [alias]: chainData.chainId
      }),
      {}
    ),
    covenants: Object.entries(covenantHashes).reduce(
      (covenants, [alias, hash]) => ({
        ...covenants,
        [alias]: { hash }
      }),
      {}
    )
  }
}
 
module.exports = generateDeploymentDetails