How to use the @ledgerhq/live-common/lib/env.getEnv function in @ledgerhq/live-common

To help you get started, we’ve selected a few @ledgerhq/live-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-desktop / src / helpers / live-common-setup-internal-hw.js View on Github external
implementCountervalues({
  storeSelector: state => state.countervalues,
  pairsSelector: () => [],
  setExchangePairsAction: () => {},
})

setErrorRemapping(e => {
  // NB ideally we should solve it in ledgerjs
  if (e && e.message && e.message.indexOf('HID') >= 0) {
    return throwError(new DisconnectedDevice(e.message))
  }
  return throwError(e)
})

if (getEnv('DEVICE_PROXY_URL')) {
  const Tr = TransportHttp(getEnv('DEVICE_PROXY_URL').split('|'))

  registerTransportModule({
    id: 'proxy',
    open: () => retry(() => Tr.create(3000, 5000)),
    disconnect: () => Promise.resolve(),
  })
} else {
  registerTransportModule({
    id: 'hid',
    open: devicePath =>
      retry(
        () =>
          getEnv('EXPERIMENTAL_USB')
            ? TransportNodeHidSingleton.open()
            : TransportNodeHid.open(devicePath),
        { maxRetry: 4 },
github LedgerHQ / ledger-live-desktop / src / helpers / live-common-setup-internal-hw.js View on Github external
implementCountervalues({
  storeSelector: state => state.countervalues,
  pairsSelector: () => [],
  setExchangePairsAction: () => {},
})

setErrorRemapping(e => {
  // NB ideally we should solve it in ledgerjs
  if (e && e.message && e.message.indexOf('HID') >= 0) {
    return throwError(new DisconnectedDevice(e.message))
  }
  return throwError(e)
})

if (getEnv('DEVICE_PROXY_URL')) {
  const Tr = TransportHttp(getEnv('DEVICE_PROXY_URL').split('|'))

  registerTransportModule({
    id: 'proxy',
    open: () => retry(() => Tr.create(3000, 5000)),
    disconnect: () => Promise.resolve(),
  })
} else {
  registerTransportModule({
    id: 'hid',
    open: devicePath =>
      retry(
        () =>
          getEnv('EXPERIMENTAL_USB')
            ? TransportNodeHidSingleton.open()
            : TransportNodeHid.open(devicePath),
github LedgerHQ / ledger-live-desktop / src / bridge / index.js View on Github external
export const getCurrencyBridge = (currency: CryptoCurrency): CurrencyBridge => {
  if (getEnv('MOCK')) return mockCurrencyBridge
  switch (currency.family) {
    case 'ripple':
      return RippleJSBridge.currencyBridge
    case 'ethereum':
      if (libcoreNoGo.includes(currency.id)) {
        return EthereumJSBridge.currencyBridge
      }
      return LibcoreBridge.currencyBridge
    case 'bitcoin':
      return LibcoreBridge.currencyBridge
    default:
      return mockCurrencyBridge // fallback mock until we implement it all!
  }
}
github LedgerHQ / ledger-live-desktop / src / reducers / accounts.js View on Github external
  () => getEnv('HIDE_EMPTY_TOKEN_ACCOUNTS'), // The result of this func is not used but it allows the input params to be different so that reselect recompute the output
  (accounts, ids) => flattenFilterAndSort(accounts, ids, { enforceHideEmptySubAccounts: true }),
github LedgerHQ / ledger-live-desktop / src / helpers / countervalues.js View on Github external
  getAPIBaseURL: () => getEnv('LEDGER_COUNTERVALUES_API'),
  storeSelector: state => state.countervalues,
github LedgerHQ / ledger-live-desktop / src / config / languages.js View on Github external
export const getLanguages = () =>
  getEnv('EXPERIMENTAL_LANGUAGES') ? allLanguages : prodStableLanguages
github LedgerHQ / ledger-live-desktop / src / reducers / settings.js View on Github external
countervalueFirst: false,
  hasPassword: false,
  autoLockTimeout: 10,
  selectedTimeRange: 'month',
  marketIndicator: 'western',
  currenciesSettings: {},
  pairExchanges: {},
  developerMode: !!process.env.__DEV__,
  loaded: false,
  shareAnalytics: true,
  sentryLogs: true,
  lastUsedVersion: __APP_VERSION__,
  dismissedBanners: [],
  accountsViewMode: 'list',
  showAccountsHelperBanner: true,
  hideEmptyTokenAccounts: getEnv('HIDE_EMPTY_TOKEN_ACCOUNTS'),
  sidebarCollapsed: false,
}

const pairHash = (from, to) => `${from.ticker}_${to.ticker}`

const handlers: Object = {
  SETTINGS_SET_PAIRS: (
    state: SettingsState,
    {
      pairs,
    }: {
      pairs: Array<{
        from: Currency,
        to: Currency,
        exchange: string,
      }>,
github LedgerHQ / ledger-live-desktop / src / components / ManagerPage / AppsList.js View on Github external
async fetchAppList() {
    const { deviceInfo } = this.props

    try {
      const filteredAppVersionsList = await manager.getAppsList(
        deviceInfo,
        getEnv('MANAGER_DEV_MODE'),
        () => currenciesByMarketcap(listCryptoCurrencies()),
      )

      const eth = filteredAppVersionsList.find(c => c.name === 'Ethereum')

      if (!this._unmounted) {
        this.setState({
          status: 'idle',
          filteredAppVersionsList,
          appsLoaded: true,
          eth,
        })
      }
    } catch (err) {
      this.setState({ status: 'error', error: err })
    }
github LedgerHQ / ledger-live-desktop / src / components / ManagerV2Page / index.js View on Github external
export const getManagerPageRoute = () =>
  getEnv('EXPERIMENTAL_MANAGER') ? '/managerv2' : '/manager'