function processTxn(tx, meta, is_historic)
  {
    var processedTxn = rewriter.processTxn(tx, meta, account);

    if (processedTxn) {
      var transaction = processedTxn.transaction;

      // Update account
      if (processedTxn.accountRoot) {
        handleAccountEntry(processedTxn.accountRoot);
      }

      // Show status notification
      if (processedTxn.tx_result === "tesSUCCESS" &&
          transaction &&
          !is_historic) {

        $scope.$broadcast('$appTxNotification', {
          hash:tx.hash,
          tx: transaction
        });
      }

      // Add to recent notifications
      if (processedTxn.tx_result === "tesSUCCESS" &&
          transaction) {

        var effects = [];
        // Only show specific transactions
        switch (transaction.type) {
          case 'offernew':
          case 'exchange':
            var funded = false;
            processedTxn.effects.some(function(effect) {
              if (_.contains(['offer_bought','offer_funded','offer_partially_funded'], effect.type)) {
                funded = true;
                effects.push(effect);
                return true;
              }
            });

            // Only show trades/exchanges which are at least partially funded
            if (!funded) {
              break;            
            }
            /* falls through */
          case 'received':

            // Is it unseen?
            if (processedTxn.date > ($scope.userBlob.data.lastSeenTxDate || 0)) {
              processedTxn.unseen = true;
              $scope.unseenNotifications.count++;
            }

            processedTxn.showEffects = effects;
            $scope.events.unshift(processedTxn);
        }
      }

      // TODO Switch to txmemo field
      appManager.getAllApps(function(apps){
        _.each(apps, function(app){
          var historyProfile;
          if (historyProfile = app.findProfile('history')) {
            historyProfile.getTransactions($scope.address, function(err, history){
              history.forEach(function(tx){
                tx.app = app;
                if (processedTxn.hash === tx.hash) {
                  processedTxn.details = tx;
                }
              });
            });
          }
        });
      });

      // Add to history
      $scope.history.unshift(processedTxn);

      // Update Ripple lines
      if (processedTxn.effects && !is_historic) {
        updateLines(processedTxn.effects);
      }

      // Update my offers
      if (processedTxn.effects && !is_historic) {
        // Iterate on each effect to find offers
        processedTxn.effects.forEach(function (effect) {
          // Only these types are offers
          if (_.contains([
            'offer_created',
            'offer_funded',
            'offer_partially_funded',
            'offer_cancelled'], effect.type))
          {
            var offer = {
              seq: +effect.seq,
              gets: effect.gets,
              pays: effect.pays,
              deleted: effect.deleted,
              flags: effect.flags
            };

            updateOffer(offer);
          }
        });

        $scope.$broadcast('$offersUpdate');
      }
    }
  }
/**
   * Process a transaction and add it to the history table.
   */
Process a transaction and add it to the history table.
Process a transaction and add it to the history table .
function processTxn(tx, meta, is_historic)
  {
    var processedTxn = rewriter.processTxn(tx, meta, account);
    if (processedTxn) {
      var transaction = processedTxn.transaction;
      if (processedTxn.accountRoot) {
        handleAccountEntry(processedTxn.accountRoot);
      }
      if (processedTxn.tx_result === "tesSUCCESS" &&
          transaction &&
          !is_historic) {
        $scope.$broadcast('$appTxNotification', {
          hash:tx.hash,
          tx: transaction
        });
      }
      if (processedTxn.tx_result === "tesSUCCESS" &&
          transaction) {
        var effects = [];
        switch (transaction.type) {
          case 'offernew':
          case 'exchange':
            var funded = false;
            processedTxn.effects.some(function(effect) {
              if (_.contains(['offer_bought','offer_funded','offer_partially_funded'], effect.type)) {
                funded = true;
                effects.push(effect);
                return true;
              }
            });
            if (!funded) {
              break;            
            }
          case 'received':
            if (processedTxn.date > ($scope.userBlob.data.lastSeenTxDate || 0)) {
              processedTxn.unseen = true;
              $scope.unseenNotifications.count++;
            }
            processedTxn.showEffects = effects;
            $scope.events.unshift(processedTxn);
        }
      }
      appManager.getAllApps(function(apps){
        _.each(apps, function(app){
          var historyProfile;
          if (historyProfile = app.findProfile('history')) {
            historyProfile.getTransactions($scope.address, function(err, history){
              history.forEach(function(tx){
                tx.app = app;
                if (processedTxn.hash === tx.hash) {
                  processedTxn.details = tx;
                }
              });
            });
          }
        });
      });
      $scope.history.unshift(processedTxn);
      if (processedTxn.effects && !is_historic) {
        updateLines(processedTxn.effects);
      }
      if (processedTxn.effects && !is_historic) {
        processedTxn.effects.forEach(function (effect) {
          if (_.contains([
            'offer_created',
            'offer_funded',
            'offer_partially_funded',
            'offer_cancelled'], effect.type))
          {
            var offer = {
              seq: +effect.seq,
              gets: effect.gets,
              pays: effect.pays,
              deleted: effect.deleted,
              flags: effect.flags
            };
            updateOffer(offer);
          }
        });
        $scope.$broadcast('$offersUpdate');
      }
    }
  }
function processTxn ( tx , meta , is_historic ) { var processedTxn = rewriter . processTxn ( tx , meta , account ) ; if ( processedTxn ) { var transaction = processedTxn . transaction ; if ( processedTxn . accountRoot ) { handleAccountEntry ( processedTxn . accountRoot ) ; } if ( processedTxn . tx_result === "tesSUCCESS" && transaction && ! is_historic ) { $scope . $broadcast ( '$appTxNotification' , { hash : tx . hash , tx : transaction } ) ; } if ( processedTxn . tx_result === "tesSUCCESS" && transaction ) { var effects = [ ] ; switch ( transaction . type ) { case 'offernew' : case 'exchange' : var funded = false ; processedTxn . effects . some ( function ( effect ) { if ( _ . contains ( [ 'offer_bought' , 'offer_funded' , 'offer_partially_funded' ] , effect . type ) ) { funded = true ; effects . push ( effect ) ; return true ; } } ) ; if ( ! funded ) { break ; } case 'received' : if ( processedTxn . date > ( $scope . userBlob . data . lastSeenTxDate || 0 ) ) { processedTxn . unseen = true ; $scope . unseenNotifications . count ++ ; } processedTxn . showEffects = effects ; $scope . events . unshift ( processedTxn ) ; } } appManager . getAllApps ( function ( apps ) { _ . each ( apps , function ( app ) { var historyProfile ; if ( historyProfile = app . findProfile ( 'history' ) ) { historyProfile . getTransactions ( $scope . address , function ( err , history ) { history . forEach ( function ( tx ) { tx . app = app ; if ( processedTxn . hash === tx . hash ) { processedTxn . details = tx ; } } ) ; } ) ; } } ) ; } ) ; $scope . history . unshift ( processedTxn ) ; if ( processedTxn . effects && ! is_historic ) { updateLines ( processedTxn . effects ) ; } if ( processedTxn . effects && ! is_historic ) { processedTxn . effects . forEach ( function ( effect ) { if ( _ . contains ( [ 'offer_created' , 'offer_funded' , 'offer_partially_funded' , 'offer_cancelled' ] , effect . type ) ) { var offer = { seq : + effect . seq , gets : effect . gets , pays : effect . pays , deleted : effect . deleted , flags : effect . flags } ; updateOffer ( offer ) ; } } ) ; $scope . $broadcast ( '$offersUpdate' ) ; } } }
Process a transaction and add it to the history table.
Process a transaction and add it to the history table .
// Update account // Show status notification // Add to recent notifications // Only show specific transactions // Only show trades/exchanges which are at least partially funded /* falls through */ // Is it unseen? // TODO Switch to txmemo field // Add to history // Update Ripple lines // Update my offers // Iterate on each effect to find offers // Only these types are offers