{"size": 870, "ext": "js", "max_stars_repo_path": "src/utils/Wallet.js", "max_stars_repo_name": "moaazsidat/depay-widgets", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/utils/Wallet.js", "max_issues_repo_name": "moaazsidat/depay-widgets", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/utils/Wallet.js", "max_forks_repo_name": "moaazsidat/depay-widgets", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 16.4150943396, "max_line_length": 64, "alphanum_fraction": 0.6471264368}
import _ from 'lodash';
import MetaMaskConnector from '../connectors/MetaMaskConnector';

class Wallet {
  static connectors = [
    MetaMaskConnector
  ]

  static connector() {
    return _.find(Wallet.connectors, function(connector){
      return connector.isAvailable()
    });
  }

  static isAvailable() {
    return Boolean(Wallet.connector() !== undefined)
  }

  constructor() {
    this.connector = Wallet.connector();
  }

  isConnected() {
    return this.connector.isConnected()
  }

  connect() {
    return this.connector.connect();
  }

  onAddressChange() {
    return this.connector.onAddressChange();
  }

  address() {
    return this.connector.address();
  }

  balance() {
    return this.connector.balance();
  }

  name() {
    return this.connector.name();
  }

  provider() {
    return this.connector.provider();
  }
}

export default Wallet;
