How to use the @ledgerhq/hw-transport.TransportStatusError function in @ledgerhq/hw-transport

To help you get started, we’ve selected a few @ledgerhq/hw-transport 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 / ledgerjs / packages / hw-app-ada / src / Ada.js View on Github external
async signTransactionWithIndexes(
    indexes: Array
  ): Promise> {
    let response = [];

    for (let i = 0; i < indexes.length; i++) {
      if (isNaN(indexes[i])) {
        throw new TransportStatusError(INDEX_NAN);
      }

      if (indexes[i] > INDEX_MAX) {
        throw new TransportStatusError(INDEX_MAX_EXCEEDED);
      }

      const data = Buffer.alloc(4);
      data.writeUInt32BE(indexes[i], 0);

      const res = await this.transport.send(CLA, INS_SIGN_TX, 0x00, 0x00, data);
      const digest = res.slice(0, res.length - 2).toString("hex");

      response.push({ digest });
    }

    return response;
  }
}
github LedgerHQ / ledgerjs / packages / hw-app-ada / src / Ada.js View on Github external
async signTransactionWithIndexes(
    indexes: Array
  ): Promise> {
    let response = [];

    for (let i = 0; i < indexes.length; i++) {
      if (isNaN(indexes[i])) {
        throw new TransportStatusError(INDEX_NAN);
      }

      if (indexes[i] > INDEX_MAX) {
        throw new TransportStatusError(INDEX_MAX_EXCEEDED);
      }

      const data = Buffer.alloc(4);
      data.writeUInt32BE(indexes[i], 0);

      const res = await this.transport.send(CLA, INS_SIGN_TX, 0x00, 0x00, data);
      const digest = res.slice(0, res.length - 2).toString("hex");

      response.push({ digest });
    }

    return response;
github LedgerHQ / ledgerjs / packages / hw-app-ada / src / Ada.js View on Github external
async getWalletPublicKeyWithIndex(
    index: number
  ): Promise<{ publicKey: string }> {
    if (isNaN(index)) {
      throw new TransportStatusError(INDEX_NAN);
    }

    const data = Buffer.alloc(4);
    data.writeUInt32BE(index, 0);

    const response = await this.transport.send(
      CLA,
      INS_GET_PUBLIC_KEY,
      0x02,
      0x00,
      data
    );

    const [publicKeyLength] = response;
    const publicKey = response.slice(1, 1 + publicKeyLength).toString("hex");