<commit_before>var util = require('util'),
    Tab = require('../client/tab').Tab;

var UsdTab = function ()
{
  Tab.call(this);
};

util.inherits(UsdTab, Tab);

UsdTab.prototype.tabName = 'usd';
UsdTab.prototype.mainMenu = 'fund';

UsdTab.prototype.angularDeps = Tab.prototype.angularDeps.concat(['qr']);

UsdTab.prototype.generateHtml = function ()
{
  return require('../../jade/tabs/usd.jade')();
};

UsdTab.prototype.extraRoutes = [
  { name: '/usd/:result' }
];

UsdTab.prototype.angular = function (module)
{
  module.controller('UsdCtrl', ['$scope', 'rpId', '$routeParams', '$http', 'rpAuthFlow', 'rpNetwork', 'rpTxQueue', '$location',
    function ($scope, $id, $routeParams, $http, authflow, network, txQueue, $location)
    {
      if (!$id.loginStatus) return $id.goId();

      var issuer = Options.b2rAddress;
      var currency = 'USD';
      var trustAmount = '100000000000';

      /**
       * Decide whether we want to show the form
       * (Only show if the user has been KYCd)
       */
      var checkAttestation = function(){
        $scope.options = {
          url         : $scope.userBlob.url,
          auth_secret : $scope.userBlob.data.auth_secret,
          blob_id     : $scope.userBlob.id,
          type        : 'profile',
          full        : true
        };

        authflow.getAttestationSummary($scope.options, function(err, resp) {
          if (err) {
            console.log('Error while getting attestation', err);
            $scope.error = 'We are unable to proceed with instant deposit. Please contact <EMAIL>.';
            return;
          }

          if (resp && resp.decoded && resp.decoded.payload && !resp.decoded.payload.profile_verified) {
            $scope.mode = 'noKyc';
            return;
          }

          $scope.attestation = resp.attestation;
          $scope.mode = 'step1';
        });
      };

      // If blob is already loaded
      if ($scope.userBlob.id) {
        checkAttestation();
      }

      // If not, then wait until it's there
      $scope.$on('$blobUpdate', checkAttestation);

      //$scope.mode = 'step1';
      $scope.step1 = function() {
        $scope.mode = 'step1';
        $location.path('/usd');
      };

      /**
       * Create the Snapswap profile and get the quote
       */

      // Create a SnapSwap account
      $scope.createAccount = function(callback) {
        $http({
          method: 'POST',
          data: {
            domain: 'snapswap.us',
            email: $scope.userBlob.data.email,
            rippleAddress: $id.account,
            trustTxBlob: 'anystring',
            usernameProposal: $id.account, // TODO use ripple name when applicable
            data: {
              source: 'https://id.ripple.com',
              jwt: $scope.attestation
            }<commit_msg>[TASK] USD Fund: usernameProposal should be the username<commit_after>var util = require('util'),
    Tab = require('../client/tab').Tab;

var UsdTab = function ()
{
  Tab.call(this);
};

util.inherits(UsdTab, Tab);

UsdTab.prototype.tabName = 'usd';
UsdTab.prototype.mainMenu = 'fund';

UsdTab.prototype.angularDeps = Tab.prototype.angularDeps.concat(['qr']);

UsdTab.prototype.generateHtml = function ()
{
  return require('../../jade/tabs/usd.jade')();
};

UsdTab.prototype.extraRoutes = [
  { name: '/usd/:result' }
];

UsdTab.prototype.angular = function (module)
{
  module.controller('UsdCtrl', ['$scope', 'rpId', '$routeParams', '$http', 'rpAuthFlow', 'rpNetwork', 'rpTxQueue', '$location',
    function ($scope, $id, $routeParams, $http, authflow, network, txQueue, $location)
    {
      if (!$id.loginStatus) return $id.goId();

      var issuer = Options.b2rAddress;
      var currency = 'USD';
      var trustAmount = '100000000000';

      /**
       * Decide whether we want to show the form
       * (Only show if the user has been KYCd)
       */
      var checkAttestation = function(){
        $scope.options = {
          url         : $scope.userBlob.url,
          auth_secret : $scope.userBlob.data.auth_secret,
          blob_id     : $scope.userBlob.id,
          type        : 'profile',
          full        : true
        };

        authflow.getAttestationSummary($scope.options, function(err, resp) {
          if (err) {
            console.log('Error while getting attestation', err);
            $scope.error = 'We are unable to proceed with instant deposit. Please contact <EMAIL>.';
            return;
          }

          if (resp && resp.decoded && resp.decoded.payload && !resp.decoded.payload.profile_verified) {
            $scope.mode = 'noKyc';
            return;
          }

          $scope.attestation = resp.attestation;
          $scope.mode = 'step1';
        });
      };

      // If blob is already loaded
      if ($scope.userBlob.id) {
        checkAttestation();
      }

      // If not, then wait until it's there
      $scope.$on('$blobUpdate', checkAttestation);

      //$scope.mode = 'step1';
      $scope.step1 = function() {
        $scope.mode = 'step1';
        $location.path('/usd');
      };

      /**
       * Create the Snapswap profile and get the quote
       */

      // Create a SnapSwap account
      $scope.createAccount = function(callback) {
        $http({
          method: 'POST',
          data: {
            domain: 'snapswap.us',
            email: $scope.userBlob.data.email,
            rippleAddress: $id.account,
            trustTxBlob: 'anystring',
            usernameProposal: $scope.userCredentials.username,
            data: {
              source: 'https://id.ripple.com',
              jwt: $scope.attestation
            }
{'fraction_non_alphanumeric': 0.1437954908574472, 'fraction_numerical': 0.0060358601100656845, 'mean_word_length': 2.0553145336225596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '306924', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1689, 'n_words': 373}