<commit_before>angular.module('omniwallet')
  .factory('asset_types_template', function($q, $http) {
    var deferred = $q.defer();

    $http.get('/partials/asset_types.html').then(function(result) {
      deferred.resolve(result.data);
    });

    return deferred.promise;
  })
  .factory('asset_types_data', function($http, $q, $timeout, $injector, Account) {
    var count = 1;
    return {
      "getData": function() {
        //console.log( '*** getData!' );
        var deferred = $q.defer();

        _.defer(function() {
          var wallet = Account.wallet;
          if (wallet && wallet.addresses.length > 0) {
            var requests = [];

            var balances = {};
            var currencyInfo;
            var emptyAddresses = [];

            var appraiser = $injector.get('appraiser');

            wallet.addresses.forEach(function(addr) {
              requests.push($injector.get('balanceService').balance(addr.address).then(function(result) {
                result.data.balance.forEach(function(currencyItem) {
                  if(currencyItem.divisible)
                    var value=new Big(currencyItem.value).times(WHOLE_UNIT).valueOf();
                  if (!balances.hasOwnProperty(currencyItem.symbol)) {
                    balances[currencyItem.symbol] = {
                      "symbol": currencyItem.symbol,
                      "balance": +value || currencyItem.value,
                      "value": appraiser.getValue(currencyItem.value, currencyItem.symbol, currencyItem.divisible),
                    };
                  } else {
                    balances[currencyItem.symbol].balance += +value || currencyItem.value;
                    balances[currencyItem.symbol].value += appraiser.getValue(currencyItem.value, currencyItem.symbol, currencyItem.divisible);
                  }
		  //console.log(balances);
                  if (currencyItem.symbol == 'BTC') {
                    balances[currencyItem.symbol].name = "Bitcoin"
                  }
                });
              }));
            });
            // First, the standard currencies.
            requests.push($http.get('/v1/transaction/values.json').then(function(result) {
              currencyInfo = result.data;
            }
            ));
            $q.all(requests).then(function(responses) {
              if (currencyInfo) {
                currencyInfo.forEach(function(item) {
                  if (balances.hasOwnProperty(item.currency))
                    balances[item.currency].name = item.name;
                });

                // Now, any applicable smart properties.
                var spReqs = [];

                for (var b in balances) {
                  var spMatch = balances[b].symbol.match(/^SP([0-9]+)$/);

                  if (spMatch != null) {
                    var updateFunction = function(result) {
                      if (result.status == 200)
                        this.property_type = result.data[0].formatted_property_type;
                      this.name = result.data[0].propertyName + ' (' + this.symbol.match(/^SP([0-9]+)$/)[1] + ')';
		      this.shortname = result.data[0].propertyName;
                    };
                    spReqs.push($http.get('/v1/property/' + spMatch[1] + '.json').then(updateFunction.bind(balances[b])));
                  }
                }

                if (spReqs.length > 0) {
                  $q.all(spReqs).then(function() {
                    deferred.resolve(
                    {
                      balances: balances,
                      currencies: currencyInfo
                    });
                  });
                } else {
                  deferred.resolve(
                  {
                    balances: balances,
                    currencies: currencyInfo
                  });
                }
              }
            });
          } else {
            $http.get('/v1/transaction/values.json').then(function(currencyInfo) {
              deferred.resolve({
                currencies: currencyInfo
              });
            }
            );
          }
        });

        return deferred.promise;
      }
    };
  })
  .directive('showAssetTypes', function($compile, $injector) {
    return {<commit_msg>Get the balances from the AddressModel<commit_after>angular.module('omniwallet')
  .factory('asset_types_template', function($q, $http) {
    var deferred = $q.defer();

    $http.get('/partials/asset_types.html').then(function(result) {
      deferred.resolve(result.data);
    });

    return deferred.promise;
  })
  .factory('asset_types_data', function($http, $q, $timeout, $injector, Wallet) {
    var count = 1;
    return {
      "getData": function() {
        //console.log( '*** getData!' );
        var deferred = $q.defer();

        _.defer(function() {
          if (Wallet.addresses && Wallet.addresses.length > 0) {
            var requests = [];

            var balances = {};
            var currencyInfo;
            var emptyAddresses = [];

            var appraiser = $injector.get('appraiser');

            Wallet.addresses.forEach(function(addr) {
              addr.balance.forEach(function(currencyItem) {
                  if(currencyItem.divisible)
                    var value=new Big(currencyItem.value).times(WHOLE_UNIT).valueOf();
                  if (!balances.hasOwnProperty(currencyItem.symbol)) {
                    balances[currencyItem.symbol] = {
                      "symbol": currencyItem.symbol,
                      "balance": +value || currencyItem.value,
                      "value": appraiser.getValue(currencyItem.value, currencyItem.symbol, currencyItem.divisible),
                    };
                  } else {
                    balances[currencyItem.symbol].balance += +value || currencyItem.value;
                    balances[currencyItem.symbol].value += appraiser.getValue(currencyItem.value, currencyItem.symbol, currencyItem.divisible);
                  }
		  //console.log(balances);
                  if (currencyItem.symbol == 'BTC') {
                    balances[currencyItem.symbol].name = "Bitcoin"
                  }
                });
              }));
            });
            // First, the standard currencies.
            $http.get('/v1/transaction/values.json').then(function(result) {
              currencyInfo = result.data;
              currencyInfo.forEach(function(item) {
                if (balances.hasOwnProperty(item.currency))
                  balances[item.currency].name = item.name;
              });

              // Now, any applicable smart properties.
              var spReqs = [];

              for (var b in balances) {
                var spMatch = balances[b].symbol.match(/^SP([0-9]+)$/);

                if (spMatch != null) {
                  var updateFunction = function(result) {
                    if (result.status == 200)
                      this.property_type = result.data[0].formatted_property_type;
                    this.name = result.data[0].propertyName + ' (' + this.symbol.match(/^SP([0-9]+)$/)[1] + ')';
                    this.shortname = result.data[0].propertyName;
                  };
                  spReqs.push($http.get('/v1/property/' + spMatch[1] + '.json').then(updateFunction.bind(balances[b])));
                }
              }

              if (spReqs.length > 0) {
                $q.all(spReqs).then(function() {
                  deferred.resolve(
                  {
                    balances: balances,
                    currencies: currencyInfo
                  });
                });
              } else {
                deferred.resolve(
                {
                  balances: balances,
                  currencies: currencyInfo
                });
              }
            }
            );
            $q.all(requests).then(function(responses) {
              if (currencyInfo) {
                
              }
            });
          } else {
            $http.get('/v1/transaction/values.json').then(function(currencyInfo) {
              deferred.resolve({
                currencies: currencyInfo
              });
            }
            );
          }
        });

        return deferred.promise;
      }
    };
  })
  .directive('showAssetTypes', function($compile, $injector) {
    return {
{'fraction_non_alphanumeric': 0.12867383512544803, 'fraction_numerical': 0.004301075268817204, 'mean_word_length': 1.4040781160252729, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493474', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2075, 'n_words': 311}