<commit_before>import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';

import { AppProvider } from '../../../providers/app/app';
import * as _ from 'lodash';

@Component({
  selector: 'page-join-wallet',
  templateUrl: 'join-wallet.html'
})
export class JoinWalletPage implements OnInit{
  public formData: any;
  public showAdvOpts: boolean;
  public seedOptions: any;

  private appName: string;
  private derivationPathByDefault: string;
  private derivationPathForTestnet: string;
  private joinForm: FormGroup;

  constructor(
    public navCtrl: NavController,
    private app: AppProvider,
    private fb: FormBuilder
  ) {
    this.derivationPathByDefault = "m/44'/0'/0'";
    this.derivationPathForTestnet = "m/44'/1'/0'";
    this.showAdvOpts = false;
    this.formData = {
      copayerName: null,
      invitationCode: null,
      bwsURL: 'https://bws.bitpay.com/bws/api',
      recoveryPhrase: null,
      addPassword: false,
      password: <PASSWORD>,
      confirmPassword: <PASSWORD>,
      passwordSaved: null,
      derivationPath: this.derivationPathByDefault,
    };
    this.seedOptions = [{
      id: 'new',
      label: 'Random',
      supportsTestnet: true
    }, {
      id: 'set',
      label: 'Specify Recovery Phrase',
      supportsTestnet: false
    }];
    this.formData.selectedSeed = {
      id: this.seedOptions[0].id
    };
  }

  ngOnInit() {
    this.joinForm = this.fb.group({
      copayerName: ['', Validators.required],
      invitationCode: ['', Validators.required],
      bwsURL: [''],
      selectedSeed: [''],
      recoveryPhrase: [''],
      addPassword: [''],
      password: [''],
      confirmPassword: [''],
      passwordSaved: [''],
      derivationPath: [''],
    });

    this.joinForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => {
      if (addPassword) {
        this.joinForm.get('password').setValidators([Validators.required]);
        this.joinForm.get('confirmPassword').setValidators([Validators.required]);
      }else {
        this.joinForm.get('password').clearValidators();
        this.joinForm.get('confirmPassword').clearValidators();
      }
      this.joinForm.get('password').updateValueAndValidity();
      this.joinForm.get('confirmPassword').updateValueAndValidity();
    })
  }

  validatePasswords() {
    if (this.formData.addPassword) {
      if (this.formData.password == this.formData.confirmPassword) {
        if (this.formData.passwordSaved) return false;
      }
      return true;
    }
    return false;
  }

  seedOptionsChange(seed: any) {
    this.formData.selectedSeed.id = seed;
    this.formData.testnet = false;
    this.formData.derivationPath = this.derivationPathByDefault;
    this.resetFormFields();
  }

  resetFormFields() {
    this.formData.password = <PASSWORD>;
    this.formData.confirmPassword = <PASSWORD>;
    this.formData.passwordSaved = <PASSWORD>;
    this.formData.recoveryPhrase = null;
  }

  setDerivationPath() {
    this.formData.derivationPath = this.formData.testnet ? this.derivationPathForTestnet : this.derivationPathByDefault;
  }

  join() {
    console.log(this.formData);
  }
}
<commit_msg>rename providers - use default values<commit_after>import { Component, OnInit } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from '@angular/forms';

import { DerivationPathHelperProvider } from '../../../providers/derivationPathHelper/derivationPathHelper';
import { ConfigProvider } from '../../../providers/config/config';

@Component({
  selector: 'page-join-wallet',
  templateUrl: 'join-wallet.html'
})
export class JoinWalletPage implements OnInit{
  public formData: any;
  public showAdvOpts: boolean;
  public seedOptions: any;

  private derivationPathByDefault: string;
  private derivationPathForTestnet: string;
  private joinForm: FormGroup;

  constructor(
    public navCtrl: NavController,
    private form: FormBuilder, 
    private pathHelper: DerivationPathHelperProvider,
    private configProvider: ConfigProvider,
  ) {
    this.derivationPathByDefault = this.pathHelper.default;
    this.derivationPathForTestnet = this.pathHelper.defaultTestnet;
    this.showAdvOpts = false;
    this.formData = {
      copayerName: null,
      invitationCode: null,
      bwsURL: this.configProvider.get()['bws']['url'],
      recoveryPhrase: null,
      addPassword: false,
      password: null,
      confirmPassword: null,
      passwordSaved: null,
      derivationPath: this.derivationPathByDefault,
    };
    this.seedOptions = [{
      id: 'new',
      label: 'Random',
      supportsTestnet: true
    }, {
      id: 'set',
      label: 'Specify Recovery Phrase',
      supportsTestnet: false
    }];
    this.formData.selectedSeed = {
      id: this.seedOptions[0].id
    };
  }

  ngOnInit() {
    this.joinForm = this.form.group({
      copayerName: ['', Validators.required],
      invitationCode: ['', Validators.required],
      bwsURL: [''],
      selectedSeed: [''],
      recoveryPhrase: [''],
      addPassword: [''],
      password: [''],
      confirmPassword: [''],
      passwordSaved: [''],
      derivationPath: [''],
    });

    this.joinForm.get('addPassword').valueChanges.subscribe((addPassword: boolean) => {
      if (addPassword) {
        this.joinForm.get('password').setValidators([Validators.required]);
        this.joinForm.get('confirmPassword').setValidators([Validators.required]);
      }else {
        this.joinForm.get('password').clearValidators();
        this.joinForm.get('confirmPassword').clearValidators();
      }
      this.joinForm.get('password').updateValueAndValidity();
      this.joinForm.get('confirmPassword').updateValueAndValidity();
    })
  }

  validatePasswords() {
    if (this.formData.addPassword) {
      if (this.formData.password == this.formData.confirmPassword) {
        if (this.formData.passwordSaved) return false;
      }
      return true;
    }
    return false;
  }

  seedOptionsChange(seed: any) {
    this.formData.selectedSeed.id = seed;
    this.formData.testnet = false;
    this.formData.derivationPath = this.derivationPathByDefault;
    this.resetFormFields();
  }

  resetFormFields() {
    this.formData.password = <PASSWORD>;
    this.formData.confirmPassword = <PASSWORD>;
    this.formData.passwordSaved = <PASSWORD>;
    this.formData.recoveryPhrase = null;
  }

  setDerivationPath() {
    this.formData.derivationPath = this.formData.testnet ? this.derivationPathForTestnet : this.derivationPathByDefault;
  }

  join() {
    console.log(this.formData);
  }
}

{'fraction_non_alphanumeric': 0.13541355628545834, 'fraction_numerical': 0.001492982979994028, 'mean_word_length': 3.302504816955684, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 1, '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': '3300016', 'n_tokens_mistral': 2089, 'n_tokens_neox': 2051, 'n_words': 348}