How to use the trezor-connect.ethereumGetAddress function in trezor-connect

To help you get started, we’ve selected a few trezor-connect 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 AugurProject / augur / packages / augur-ui / src / modules / auth / components / trezor-connect / trezor-connect.tsx View on Github external
indexes.forEach((index: number) => {
        const derivationPath = DerivationPath.buildString(
          DerivationPath.increment(components, index)
        );
        paths.push(derivationPath);
      });
    });

    const addresses: Array = [];

    const bundle = paths.map((path: string) => ({
      path,
      showOnTrezor: false,
    }));

    const response = await TrezorConnect.ethereumGetAddress({
      bundle,
    }).catch((err: any) => {
      console.log("Error:", err);
      return { success: false };
    });

    if (response.success) {
      // parse up the bundle results
      response.payload.every((item: { address: string, path: Array, serializedPath: string }) => {
        return addresses.push({
          address: item.address,
          derivationPath: item.path,
          serializedPath: item.serializedPath,
        });
      });
github AugurProject / augur-ui / src / modules / auth / components / trezor-connect / trezor-connect.jsx View on Github external
indexes.forEach(index => {
        const derivationPath = DerivationPath.buildString(
          DerivationPath.increment(components, index)
        );
        paths.push(derivationPath);
      });
    });

    const addresses = [];

    const bundle = paths.map(path => ({
      path,
      showOnTrezor: false
    }));

    const response = await TrezorConnect.ethereumGetAddress({
      bundle
    }).catch(err => {
      console.log("Error:", err);
      return { success: false };
    });

    if (response.success) {
      // parse up the bundle results
      response.payload.every(item =>
        addresses.push({
          address: item.address,
          derivationPath: item.path,
          serializedPath: item.serializedPath
        })
      );
      if (addresses && addresses.length > 0) {
github Synthetixio / synthetix-js / lib / signers / trezorSigner.js View on Github external
pageSize = pageSize || 5;
      const toAddressIndex = fromAddressIndex + pageSize;
      if (this.addressLoaderBusy)
        return this.cachedAddresses.slice(fromAddressIndex, toAddressIndex);
      this.addressLoaderBusy = true;
      if (this.cachedAddresses.length >= toAddressIndex) {
        return this.cachedAddresses.slice(fromAddressIndex, toAddressIndex);
      }
      const bundle = [];
      for (let i = 0; i < pageSize; i++) {
        bundle.push({
          path: this.derivationPath + (fromAddressIndex + i),
          showOnTrezor: false,
        });
      }
      const result = await TrezorConnect.ethereumGetAddress({
        bundle,
      });
      this.cachedAddresses.push(...result.payload.map(item => item.address));
      return this.cachedAddresses.slice(fromAddressIndex, toAddressIndex);
    } catch (e) {
      console.log(e);
    } finally {
      this.addressLoaderBusy = false;
    }
  }
github AugurProject / augur-ui / src / modules / auth / components / trezor-connect / trezor-connect.jsx View on Github external
async connectWallet(derivationPath) {
    const { loginWithTrezor, logout } = this.props;
    const result = await TrezorConnect.ethereumGetAddress({
      path: derivationPath
    });

    TrezorConnect.on(DEVICE_EVENT, event => {
      switch (event.type) {
        case DEVICE.DISCONNECT: {
          logout();
          break;
        }
        default:
          break;
      }
    });

    if (result.success) {
      const { address } = result.payload;
github MyEtherWallet / MyEtherWallet / src / wallets / hardware / trezor / index.js View on Github external
const displayAddress = async () => {
      await Trezor.ethereumGetAddress({
        path: this.basePath + '/' + idx,
        showOnTrezor: true
      });
    };
    return new HDWalletInterface(
github Synthetixio / synthetix-js / lib / signers / trezorSigner.js View on Github external
async getAddress() {
    if (this.cachedAddresses && this.addressIndex <= this.cachedAddresses.length) {
      return this.cachedAddresses[this.addressIndex];
    }
    this.cachedAddresses[this.addressIndex] = (await TrezorConnect.ethereumGetAddress({
      path: this.derivationPath + this.addressIndex,
      showOnTrezor: false,
    })).payload.address;
    return this.cachedAddresses[this.addressIndex];
  }
github joincivil / Civil / packages / utils / src / web3 / trezor.ts View on Github external
getAccounts(cb: (err: any, res?: any) => any): void {
      TrezorConnect.ethereumGetAddress(path, (response: any) => {
        if (response.success) {
          cb(null, ["0x" + response.address]);
        } else {
          cb(response.error);
        }
      });
    },
    approveTransaction(_: any, cb: (err: any, res?: any) => any): void {
github MyEtherWallet / MyEtherWallet / src / wallets / hardware / trezor / index.js View on Github external
const displayAddress = async () => {
      await Trezor.ethereumGetAddress({
        path: this.basePath + '/' + idx,
        showOnTrezor: true
      });
    };
    return new HDWalletInterface(
github AdExNetwork / adex-platform / src / services / smart-contracts / signers / trezor.js View on Github external
getAddresses = async ({ from = 0, to = 9 } = {}) => {
		const { success, payload } = await TrezorConnect.ethereumGetAddress(
			this.getAddsParams({ from, to })
		)

		return { success, payload }
	}
github AugurProject / augur / packages / augur-ui / src / modules / auth / components / trezor-connect / trezor-connect.tsx View on Github external
async connectWallet(derivationPath: string) {
    const { loginWithTrezor, logout } = this.props;
    const result = await TrezorConnect.ethereumGetAddress({
      path: derivationPath,
    });

    TrezorConnect.on(DEVICE_EVENT, (event: any) => {
      switch (event.type) {
        case DEVICE.DISCONNECT: {
          logout();
          break;
        }
        default:
          break;
      }
    });

    if (result.success) {
      const { address } = result.payload;