function ledsOff () {
  if (_.isNil(currentScheme)) {
    console.log('Attempted to turn off LEDs that were already off.')
    return
  }

  if (_.isNil(lp)) {
    console.log('Attempted to turn off LEDs that were already off [no pointer]')
    return
  }

  console.log('DEBUG600: %j', currentScheme)

  const promise = currentScheme.type === 'solid'
  ? fadeOut(PULSE_FADE_MS).then(() => light(tc(COLORS.off)))
  : Promise.resolve(light(tc(COLORS.off)))

  return promise
  .then(() => {
    lp = null
    console.log('DEBUG800')
    currentScheme = null
    ledSm.dispatch('LEDS_COMPLETED')
  })
}
Exemple #2
0
function massage (tx) {
  if (!tx) return

  const massagedFields = {
    fiat: _.isNil(tx.fiat) ? undefined : BN(tx.fiat),
    cryptoAtoms: _.isNil(tx.cryptoAtoms) ? undefined : BN(tx.cryptoAtoms)
  }

  return _.assign(tx, massagedFields)
}
  UPDATEABLE_FIELDS.forEach(fieldKey => {
    if (oldTx && _.isEqualWith(nilEqual, oldTx[fieldKey], newTx[fieldKey])) return

    // We never null out an existing field
    if (oldTx && _.isNil(newTx[fieldKey])) return

    updatedTx[fieldKey] = newTx[fieldKey]
  })
Exemple #4
0
  render() {
    const {
      className,
      disabled,
      label,
      name,
      radio,
      readOnly,
      slider,
      tabIndex,
      toggle,
      type,
      value,
    } = this.props
    const { checked, indeterminate } = this.state

    const classes = cx(
      'ui',
      useKeyOnly(checked, 'checked'),
      useKeyOnly(disabled, 'disabled'),
      useKeyOnly(indeterminate, 'indeterminate'),
      // auto apply fitted class to compact white space when there is no label
      // http://semantic-ui.com/modules/checkbox.html#fitted
      useKeyOnly(!label, 'fitted'),
      useKeyOnly(radio, 'radio'),
      useKeyOnly(readOnly, 'read-only'),
      useKeyOnly(slider, 'slider'),
      useKeyOnly(toggle, 'toggle'),
      'checkbox',
      className
    )
    const rest = getUnhandledProps(Checkbox, this.props)
    const ElementType = getElementType(Checkbox, this.props)

    let computedTabIndex
    if (!_.isNil(tabIndex)) computedTabIndex = tabIndex
    else computedTabIndex = disabled ? -1 : 0

    return (
      <ElementType {...rest} className={classes} onClick={this.handleClick} onChange={this.handleClick}>
        <input
          checked={checked}
          className='hidden'
          name={name}
          readOnly
          ref={this.handleRef}
          tabIndex={computedTabIndex}
          type={type}
          value={value}
        />
        {/*
         Heads Up!
         Do not remove empty labels, they are required by SUI CSS
         */}
        {createHTMLLabel(label) || <label />}
      </ElementType>
    )
  }
function lightUp (scheme) {
  if (_.isNil(currentScheme)) {
    console.log('DEBUG801')
    currentScheme = scheme
  } else {
    pendingScheme = scheme
  }

  triggerScheme()
}
Exemple #6
0
function MessageList(props) {
  const { children, className, items } = props
  const classes = cx('list', className)
  const rest = getUnhandledProps(MessageList, props)
  const ElementType = getElementType(MessageList, props)

  return (
    <ElementType {...rest} className={classes}>
      {_.isNil(children) ? _.map(MessageItem.create, items) : children}
    </ElementType>
  )
}
async function hashPassword(value: ?string | ?number): Promise<Either> {
  const stringValue: string = String(value);
  const error: HTTPError = new errors.Unauthorized(authMessages.invalid);

  if (!isNil(value)) {
    return Either
      .Right(encrypt.hash(stringValue));
  }

  return Either
    .Left(error);
}
function triggerScheme () {
  if (_.isNil(currentScheme)) return
  if (ledSm.state() !== 'off') return

  const schemeType = currentScheme.type
  switch (schemeType) {
    case 'solid':
      return ledSm.dispatch('LIGHT_SOLID')
    case 'pulse':
      return ledSm.dispatch('LIGHT_PULSE')
    default:
      console.log(`Unsupported LED scheme: ${schemeType}`)
  }
}
Exemple #9
0
    .then(() => {
      const data = {
        method,
        params,
        id: uuid.v4()
      }

      if (_.isNil(account.port)) throw new Error('port attribute required for jsonRpc')

      const url = _.defaultTo(`http://localhost:${account.port}`, account.url)

      return axios({
        method: 'post',
        auth: {username: account.username, password: account.password},
        url,
        data
      })
    })
Exemple #10
0
      _reader.on('status', function (status) {
        const state = _.isNil(this.state) ? 0x00 : this.state
        const changes = state ^ status.state

        if (changes) {
          if ((changes & _reader.SCARD_STATE_EMPTY) && (status.state & _reader.SCARD_STATE_EMPTY)) {
            _reader.disconnect(_reader.SCARD_LEAVE_CARD, function (err) {
              protocol = null
              if (err) return console.log(`[leave] ${err}`)
              actionEmitter.emit('nfc', {action: 'cardRemoved'})
            })
          } else if ((changes & _reader.SCARD_STATE_PRESENT) && (status.state & _reader.SCARD_STATE_PRESENT)) {
            _reader.connect({share_mode: _reader.SCARD_SHARE_EXCLUSIVE}, function (err, _protocol) {
              if (err) console.log(`[present] ${err}`)
              protocol = _protocol
              const atr = status.atr
              actionEmitter.emit('nfc', {action: 'cardPresent', atr})
            })
          }
        }
      })
 .then(log => (!_.isNil(log) && !_.isEmpty(log)) ? log : supportLogs.batch().then(_.first))
function nilEqual (a, b) {
  if (_.isNil(a) && _.isNil(b)) return true

  return undefined
}