From a9d6cf2bba64ef5e8d6971ad268b52683440bfbe Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 13 Jan 2022 12:06:22 -0800 Subject: [PATCH 1/2] fix: https://github.com/near/near-cli/issues/786 --- commands/generate-key.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/generate-key.js b/commands/generate-key.js index 2bae5499..b2df50a3 100644 --- a/commands/generate-key.js +++ b/commands/generate-key.js @@ -9,6 +9,10 @@ module.exports = { .option('yolo', { description: 'Do not ask for extra confirmation when using Ledger', type: 'boolean', + }) + .option('seedPhrase', { + description: 'Seed phrase mnemonic', + type: 'string', }), handler: exitOnError(async (argv) => { let near = await require('../utils/connect')(argv); @@ -36,13 +40,14 @@ module.exports = { const { deps: { keyStore } } = near.config; const existingKey = await keyStore.getKey(argv.networkId, argv.accountId); - if (existingKey) { + if (existingKey && !argv.seedPhrase) { console.log(`Account has existing key pair with ${existingKey.publicKey} public key`); return; } // If key doesn't exist, create one and store in the keyStore. // Otherwise, it's expected that both key and accountId are already provided in arguments. + if (!argv.publicKey) { const keyPair = KeyPair.fromRandom('ed25519'); argv.publicKey = keyPair.publicKey.toString(); From cadd4632b191786c5730f8945bb8c7e9dc93d57a Mon Sep 17 00:00:00 2001 From: Will Date: Thu, 13 Jan 2022 12:09:06 -0800 Subject: [PATCH 2/2] update: remove line return --- commands/generate-key.js | 1 - 1 file changed, 1 deletion(-) diff --git a/commands/generate-key.js b/commands/generate-key.js index b2df50a3..37f8ba81 100644 --- a/commands/generate-key.js +++ b/commands/generate-key.js @@ -47,7 +47,6 @@ module.exports = { // If key doesn't exist, create one and store in the keyStore. // Otherwise, it's expected that both key and accountId are already provided in arguments. - if (!argv.publicKey) { const keyPair = KeyPair.fromRandom('ed25519'); argv.publicKey = keyPair.publicKey.toString();