src/blockchain/watcher.js
/**
   * Fetch all events between now and the latest block
   *
   * @param  {Number} [fromBlockNum=lastForeignBlock] The block from which onwards should the events be checked
   * @param  {Number} [toBlockNum=lastForeignBlock+1] No events after this block should be returned
   *
   * @return {Promise} Resolves to an array of events between speciefied block and latest known block.
   */
Fetch all events between now and the latest block
@param  {Number} [fromBlockNum=lastForeignBlock] The block from which onwards should the events be checked
@param  {Number} [toBlockNum=lastForeignBlock+1] No events after this block should be returned

@return {Promise} Resolves to an array of events between speciefied block and latest known block.
Fetch all events between now and the latest block @param { Number } [ fromBlockNum = lastForeignBlock ] The block from which onwards should the events be checked @param { Number } [ toBlockNum = lastForeignBlock + 1 ] No events after this block should be returned @return { Promise } Resolves to an array of events between speciefied block and latest known block .
async function fetchPastHomeEvents(fromBlockNum = lastHomeBlock, toBlockNum = lastHomeBlock + 1) {
    const fromBlock = fromBlockNum || 1; 
    const toBlock = toBlockNum || 1; 
    const events = [].concat(
      await givethBridge.$contract.getPastEvents('PaymentAuthorized', {
        fromBlock,
        toBlock,
      }),
      await givethBridge.$contract.getPastEvents('PaymentExecuted', {
        fromBlock,
        toBlock,
      }),
    );
    return events.map(e => {
      return { ...e, isHomeEvent: true };
    });
  }
async function fetchPastHomeEvents ( fromBlockNum = lastHomeBlock , toBlockNum = lastHomeBlock + 1 ) { const fromBlock = fromBlockNum || 1 ; const toBlock = toBlockNum || 1 ; const events = [ ] . concat ( await givethBridge . $contract . getPastEvents ( 'PaymentAuthorized' , { fromBlock , toBlock , } ) , await givethBridge . $contract . getPastEvents ( 'PaymentExecuted' , { fromBlock , toBlock , } ) , ) ; return events . map ( e => { return { ... e , isHomeEvent : true } ; } ) ; }
Fetch all events between now and the latest block
 @param  {Number} [fromBlockNum=lastForeignBlock] The block from which onwards should the events be checked
 @param  {Number} [toBlockNum=lastForeignBlock+1] No events after this block should be returned
Fetch all events between now and the latest block @param { Number } [ fromBlockNum = lastForeignBlock ] The block from which onwards should the events be checked @param { Number } [ toBlockNum = lastForeignBlock + 1 ] No events after this block should be returned
// convert to hex due to web3 bug https://github.com/ethereum/web3.js/issues/1097 // convert to hex due to web3 bug https://github.com/ethereum/web3.js/issues/1097 // Get the events from contracts