Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
fix: added message for Ledger users
Browse files Browse the repository at this point in the history
  • Loading branch information
gagdiez committed Mar 19, 2024
1 parent 8518cec commit 67eb317
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions utils/connect.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { connect: nearConnect } = require('near-api-js');
const { getConfig } = require('../config');
const { getPublicKeyForPath, signForPath } = require('./ledger');
const chalk = require('chalk');

module.exports = async function connect({ keyStore, ...options }) {
// If using Ledger, override the signer so that it uses the Ledger device
if (options.signWithLedger) {
console.log(chalk`\nUsing Ledger with path {blue ${options.ledgerPath}}, change path with {blue --ledgerPath}\n`);
options.signer = {
getPublicKey: () => getPublicKeyForPath(options.ledgerPath),
signMessage: (m) => signForPath(m, options.ledgerPath)
Expand Down
4 changes: 3 additions & 1 deletion utils/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ async function getPublicKeyForPath(hdKeyPath) {
// cache keys to avoid confirming on Ledger multiple times
if (cachedPublicKeys[hdKeyPath]) return cachedPublicKeys[hdKeyPath];

console.log('Trying to connect with Ledger...');

transport = await TransportNodeHid.create();
client = await createClient(transport);

console.log('Getting Public Key from Ledger...');
console.log('Getting public key from Ledger...');

try {
const rawPublicKey = await client.getPublicKey(hdKeyPath);
Expand Down

0 comments on commit 67eb317

Please sign in to comment.