<commit_before>// @flow
import { observable, computed } from 'mobx';
import BigNumber from 'bignumber.js';
import type {
  AssuranceMode,
  AssuranceModeOptionV1,
  AssuranceModeOptionV0
} from '../types/transactionAssuranceTypes';
import { assuranceModeOptionsV1, assuranceModes } from '../types/transactionAssuranceTypes';
import type { AdaV1WalletSyncState, AdaV1WalletSyncStateTag } from '../api/ada/types';

export const syncStateTags: {
  RESTORING: AdaV1WalletSyncStateTag, SYNCED: AdaV1WalletSyncStateTag,
} = {
  RESTORING: 'restoring', SYNCED: 'synced',
};

export default class Wallet {

  id: string = '';
  @observable name: string = '';
  @observable amount: BigNumber;
  @observable assurance: AssuranceModeOptionV1 | AssuranceModeOptionV0;
  @observable hasPassword: boolean;
  @observable passwordUpdateDate: ?Date;
  @observable syncState: ?AdaV1WalletSyncState;

  constructor(data: {
    id: string,
    name: string,
    amount: BigNumber,
    assurance: AssuranceModeOptionV1 | AssuranceModeOptionV0,
    hasPassword: boolean,
    passwordUpdateDate: ?Date,
    syncState?: AdaV1WalletSyncState,
  }) {
    Object.assign(this, data);
  }

  @computed get hasFunds(): boolean {
    return this.amount > 0;
  }

  @computed get assuranceMode(): AssuranceMode {
    switch (this.assurance) {
      case assuranceModeOptionsV1.NORMAL: return assuranceModes.NORMAL;
      case assuranceModeOptionsV1.STRICT: return assuranceModes.STRICT;
      default: return assuranceModes.NORMAL;
    }
  }

}<commit_msg>[DDW-321] Pulls wallet constants containing types into Wallet.js domain<commit_after>// @flow
import { observable, computed } from 'mobx';
import BigNumber from 'bignumber.js';
import type {
  WalletAssuranceLevel,
  WalletAssuranceMode,
  WalletSyncState,
  SyncStateTag
} from '../api/ada/types';

export const WalletAssuranceModeOptions: {
  NORMAL: WalletAssuranceLevel, STRICT: WalletAssuranceLevel,
} = {
  NORMAL: 'normal', STRICT: 'strict',
};

export const WalletSyncStateTags: {
  RESTORING: SyncStateTag, SYNCED: SyncStateTag,
} = {
  RESTORING: 'restoring', SYNCED: 'synced',
};

const WalletAssuranceModes: { NORMAL: WalletAssuranceMode, STRICT: WalletAssuranceMode } = {
  NORMAL: {
    low: 3,
    medium: 9,
  },
  STRICT: {
    low: 5,
    medium: 15,
  }
};

export default class Wallet {

  id: string = '';
  @observable name: string = '';
  @observable amount: BigNumber;
  @observable assurance: WalletAssuranceLevel;
  @observable hasPassword: boolean;
  @observable passwordUpdateDate: ?Date;
  @observable syncState: ?WalletSyncState;

  constructor(data: {
    id: string,
    name: string,
    amount: BigNumber,
    assurance: WalletAssuranceLevel,
    hasPassword: boolean,
    passwordUpdateDate: ?Date,
    syncState?: WalletSyncState,
  }) {
    Object.assign(this, data);
  }

  @computed get hasFunds(): boolean {
    return this.amount > 0;
  }

  @computed get assuranceMode(): WalletAssuranceMode {
    switch (this.assurance) {
      case WalletAssuranceModeOptions.NORMAL: return WalletAssuranceModes.NORMAL;
      case WalletAssuranceModeOptions.STRICT: return WalletAssuranceModes.STRICT;
      default: return WalletAssuranceModes.NORMAL;
    }
  }

}
{'fraction_non_alphanumeric': 0.10662107553621386, 'fraction_numerical': 0.007771215418091389, 'mean_word_length': 4.399328859060403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1771170', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1036, 'n_words': 237}