-
Notifications
You must be signed in to change notification settings - Fork 94
Create seed phrase option on add-key #997
base: master
Are you sure you want to change the base?
Conversation
You can already add a seed phrase key via the CLI, but in 2 commands: # First generate the key
near generate-key --seedPhrase 'your seed phrase ... 12 words' key.example
# Get the generated public key
pub_key=$(jq -r .public_key < ~/.near-credentials/testnet/key.example.json)
# Add the key to your current account
near add-key your_account.testnet "$pub_key" The |
It doesn't override the current account. It uses the current (already logged in) account to add the key generated by the mnemonic. As to your example, yes, you can do that. But the discoverability or generating a key to an account which is then not used is quite poor, compared to just adding a new key using the seed phrase to the account directly. |
yes my bad, I confused add-key & generate-key when talking about "overwrites". A few things about your code:
Otherwise yes I think this improve ux. We could even have an option to auto generate the seed phrase. |
|
@@ -5,13 +5,13 @@ const { utils } = require('near-api-js'); | |||
const checkCredentials = require('../utils/check-credentials'); | |||
|
|||
module.exports = { | |||
command: 'add-key <account-id> <access-key>', | |||
command: 'add-key <account-id>', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed there is another syntax to possibly use the existing arg as an optional parameter
command: 'add-key <account-id>', | |
command: 'add-key <account-id> [access-key]', |
example in the generate-key command
This would allow to not break the current input of the command (and thus the existing docs). But I let maintainers decide for the best solution :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a pretty good idea. Other thoughts?
The problem:
There is currently no way in the CLI to add a seed phrase to an already existing account. As a result, if an account was generated on the CLI, it is not easy to also add it on the web wallet.
The solution:
If
add-key
is called not with a public key, but with the--seedPhrase
option, the key generated by that seed phrase is added to the account