How to use @ledgerhq/hw-app-str - 6 common examples

To help you get started, weā€™ve selected a few @ledgerhq/hw-app-str 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 stellarchat / desktop-client / src / main / hardwareWalletLedger.js View on Github external
async _watchdogCallback() {
      console.log(`Hardwallet<${this.uid}> Watchdog: state='${this.state}' busy='${this.busy}'`)
      if(!this.transport) {
        try {
          const transport = await Transport.open(this.descriptor);
          const str = new Str(transport);
          this.transport = transport;
          this.str = str;
          console.info(`Hardwallet<${this.uid}>: Transport open.`)
        } catch(e) {
          console.warn(`Hardwallet<${this.uid}> Watchdog: recovering from error... (${e.message})`)
          return;  // Skip the rest try again later.
        }
      }

      let newState;
      try {

        if(this.subaccount) {
          if(!this.publicKey && !this.busy) await this.selectSubaccount(this.subaccount)
          if(!this.busy) await this.ping();
          newState = HWW_STATE.READY;
github stellar / js-stellar-wallets / src / keyTypeHandlers / ledger.ts View on Github external
throw new Error(
        `Non-ledger key sent to ledger handler: ${JSON.stringify(
          key.publicKey,
        )}`,
      );
    }

    /* 
      There's a naive way to do this (to keep all functions stateless and 
      make the connection anew each time), and there's some way of weaving state
      into this.

      Gonna do the naive thing first and then figure out how to do this right.
    */
    const transport = await LedgerTransport.create(60 * 1000);
    const ledgerApi = new LedgerStr(transport);
    const result = await ledgerApi.signTransaction(
      key.path,
      transaction.signatureBase(),
    );

    const keyPair = StellarSdk.Keypair.fromPublicKey(key.publicKey);
    const decoratedSignature = new StellarSdk.xdr.DecoratedSignature({
      hint: keyPair.signatureHint(),
      signature: result.signature,
    });
    transaction.signatures.push(decoratedSignature);

    return Promise.resolve(transaction);
  },
};
github stellarterm / stellarterm / src / lib / MagicSpoon.js View on Github external
                .then(transport => new AppStellar(transport))
                .then(app => app.signTransaction(this.bip32Path, transaction.signatureBase()))
github stellarterm / stellarterm / src / lib / driver / Session.js View on Github external
logInWithLedger: async (bip32Path) => {
            try {
                const transport = await Transport.create();
                const ledgerApp = new AppStellar(transport);
                const connectionResult = await ledgerApp.getPublicKey(bip32Path);
                this.setupLedgerError = null;
                const keypair = StellarSdk.Keypair.fromPublicKey(connectionResult.publicKey);
                return this.handlers.logIn(keypair, {
                    authType: 'ledger',
                    bip32Path,
                });
            } catch (error) {
                this.setupLedgerError = error.message;
                if (error && error.errorCode) {
                    const u2fErrorCodes = {
                        0: 'OK',
                        1: 'OTHER_ERROR',
                        2: 'BAD_REQUEST',
                        3: 'CONFIGURATION_UNSUPPORTED',
                        4: 'DEVICE_INELIGIBLE',
github stellarterm / stellarterm / src / lib / driver / Session.js View on Github external
            .then(transport => new AppStellar(transport))
            .then(app => app.getAppConfiguration())

@ledgerhq/hw-app-str

Ledger Hardware Wallet Stellar Application API

MIT
Latest version published 18 days ago

Package Health Score

87 / 100
Full package analysis

Popular @ledgerhq/hw-app-str functions