How to use trezor-link - 1 common examples

To help you get started, we’ve selected a few trezor-link 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 decred / decrediton / app / actions / TrezorActions.js View on Github external
return new Promise((resolve, reject) => {
    const { trezor: { getDeviceListAttempt } } = getState();
    if (getDeviceListAttempt) return;

    wallet.allowExternalRequest(EXTERNALREQUEST_TREZOR_BRIDGE);

    dispatch({ type: TRZ_LOADDEVICELIST_ATTEMPT });
    const debug = getState().trezor.debug;

    // Convert the protocol buffers definition (i.e. the messages of the comm
    // protocol to the bridge/device) to a string so that the transport can be
    // configured with it.
    const config = JSON.stringify(messages);

    trezorTransports.BridgeV2.setFetch(fetch, true);
    const transport = new trezorTransports.BridgeV2(null, null, null);
    const opts = { debug, debugInfo: debug, config, transport };
    const devList = new trezorjs.DeviceList(opts);
    let resolvedTransport = false;

    devList.on("transport", t => {
      debug && console.log("transport", t);
      if (resolvedTransport) return;
      resolvedTransport = true; // resolved with success
      dispatch({ deviceList: devList, type: TRZ_LOADDEVICELIST_SUCCESS });
      resolve(t);
    });

    devList.on("error", err => {
      debug && console.log("error", err);
      if (!resolvedTransport && err.message.includes("ECONNREFUSED")) {
        resolvedTransport = true; // resolved with failure

trezor-link

Trezor Link for browser

LGPL-3.0+
Latest version published 4 years ago

Package Health Score

42 / 100
Full package analysis

Popular trezor-link functions

Similar packages