How to use the @shapeshiftoss/hdwallet-core.Events.DISCONNECT function in @shapeshiftoss/hdwallet-core

To help you get started, we’ve selected a few @shapeshiftoss/hdwallet-core 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 shapeshift / hdwallet / packages / hdwallet-ledger-webusb / src / adapter.ts View on Github external
private async handleDisconnectWebUSBLedger(e: USBConnectionEvent): Promise {
    if (e.device.vendorId !== VENDOR_ID) return

    await timeout(APP_NAVIGATION_DELAY) // timeout gives time to detect if it is an app navigation based disconnec/connect event

    if (this.connectTimestamp !== 0) return

    try {
      await this.keyring.remove(e.device.serialNumber)
    } catch(e) {
      console.error(e)
    } finally {
      this.keyring.emit([e.device.manufacturerName, e.device.productName, Events.DISCONNECT], e.device.serialNumber)
    }
  }
github shapeshift / hdwallet / packages / hdwallet-keepkey-webusb / src / adapter.ts View on Github external
private async handleDisconnectWebUSBKeepKey (e: USBConnectionEvent): Promise {
    try {
      await this.keyring.remove(e.device.serialNumber)
    } catch(e) {
      console.error(e)
    } finally {
      this.keyring.emit([e.device.productName, e.device.serialNumber, Events.DISCONNECT], e.device.serialNumber)
    }
  }
github shapeshift / hdwallet / packages / hdwallet-trezor-connect / src / adapter.ts View on Github external
private async handleDisconnectTrezor (event: any): Promise {
    const { payload: { features: { device_id } } } = event
    try {
      await this.keyring.remove(device_id)
    } catch (e) {
      console.error(e)
    } finally {
      this.keyring.emit(['Trezor', device_id, Events.DISCONNECT], device_id)
    }
  }
github shapeshift / hdwallet / packages / hdwallet-keepkey-chromeusb / src / adapter.ts View on Github external
      .then(() => this.keyring.emit([device.productName, device.serialNumber, Events.DISCONNECT], device.serialNumber))
      .catch(() => this.keyring.emit([device.productName, device.serialNumber, Events.DISCONNECT], device.serialNumber))
github shapeshift / hdwallet / packages / hdwallet-keepkey-nodehid / src / adapter.ts View on Github external
.catch(() =>
        this.keyring.emit(
          [device.product, device.serialNumber, Events.DISCONNECT],
          device.serialNumber
        )
      )
github shapeshift / hdwallet / packages / hdwallet-portis / src / adapter.ts View on Github external
this.portis.onLogout( () => {
        this.keyring.emit(["Portis", this.currentDeviceId, Events.DISCONNECT], this.currentDeviceId)
        this.keyring.remove(this.currentDeviceId)
    })
    return wallet
github shapeshift / hdwallet / examples / sandbox / index.ts View on Github external
await wallet.initialize()
    }
    window['wallet'] = wallet
  })
  wallet = keyring.get()
  window['wallet'] = wallet
  if (wallet) {
    let deviceID = wallet.getDeviceID()
    $keyring.val(deviceID).change()
  }

  keyring.on(['*', '*', Events.CONNECT], async (deviceId) => {
    await deviceConnected(deviceId)
  })

  keyring.on(['*', '*', Events.DISCONNECT], async (deviceId) => {
    $keyring.find(`option[value="${deviceId}"]`).remove()
  })
})()
github shapeshift / hdwallet / packages / hdwallet-react / src / context / HDWalletProvider.tsx View on Github external
componentWillUnmount() {
    this.keyring.off(`*.*.${Events.CONNECT}`, this.handleDeviceConnect);
    this.keyring.off(`*.*.${Events.DISCONNECT}`, this.handleDeviceDisconnect);
  }