Skip to content

Commit

Permalink
fix: near#786
Browse files Browse the repository at this point in the history
  • Loading branch information
june07 committed Jan 13, 2022
1 parent 63cd30c commit a9d6cf2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion commands/generate-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

1 comment on commit a9d6cf2

@june07
Copy link
Owner Author

@june07 june07 commented on a9d6cf2 Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add that this is only a partial fix as other issues were discussed in near#786

Please sign in to comment.