src/blockchain/lib/topicsFromArtifacts.js
/**
 * Generate a list of topics, for any event in the artifacts.
 *
 * @param {array} artifacts array of solcpiler|embark generated artifact for a solidity contract
 * @param {array} names list of events names to generate topics for
 * @returns {array} array of topics used to subscribe to the events for the contract
 */
Generate a list of topics, for any event in the artifacts.
@param {array} artifacts array of solcpiler|embark generated artifact for a solidity contract
@param {array} names list of events names to generate topics for
@returns {array} array of topics used to subscribe to the events for the contract
Generate a list of topics for any event in the artifacts . @param { array } artifacts array of solcpiler|embark generated artifact for a solidity contract @param { array } names list of events names to generate topics for @returns { array } array of topics used to subscribe to the events for the contract
function topicsFromArtifacts(artifacts, names) {
  return artifacts
    .reduce((accumulator, { abiDefinition, compilerOutput }) => {
      const abi = compilerOutput ? compilerOutput.abi : abiDefinition;
      if (!abi) return accumulator;
      return accumulator.concat(
        abi.filter(method => method.type === 'event' && names.includes(method.name)),
      );
    }, [])
    .reduce(
      (accumulator, event) =>
        accumulator.concat({
          name: event.name,
          hash: keccak256(`${event.name}(${event.inputs.map(i => i.type).join(',')})`),
        }),
      [],
    );
}
function topicsFromArtifacts ( artifacts , names ) { return artifacts . reduce ( ( accumulator , { abiDefinition , compilerOutput } ) => { const abi = compilerOutput ? compilerOutput . abi : abiDefinition ; if ( ! abi ) return accumulator ; return accumulator . concat ( abi . filter ( method => method . type === 'event' && names . includes ( method . name ) ) , ) ; } , [ ] ) . reduce ( ( accumulator , event ) => accumulator . concat ( { name : event . name , hash : keccak256 ( ` ${ event . name } ${ event . inputs . map ( i => i . type ) . join ( ',' ) } ` ) , } ) , [ ] , ) ; }
Generate a list of topics, for any event in the artifacts.
Generate a list of topics for any event in the artifacts .