Skip to content

Commit

Permalink
create-account: console log the key file location
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedotexe authored and Mike Purvis committed Aug 13, 2020
1 parent fabfde4 commit b3ed443
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions commands/create-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,21 @@ async function createAccount(options) {
let near = await connect(options);
let keyPair;
let publicKey;
let keyRootPath;
let keyFilePath;
if (options.publicKey) {
publicKey = options.publicKey;
} else {
keyPair = await KeyPair.fromRandom('ed25519');
publicKey = keyPair.getPublicKey();
}
if (keyPair) {
// keyFilePath = near.connection.signer.keyStore.getKeyFilePath(options.networkId, options.accountId);

if (near.connection.signer.keyStore.keyStores.length) {
keyRootPath = near.connection.signer.keyStore.keyStores[0].keyDir;
}
keyFilePath = `${keyRootPath}/${options.networkId}/${options.accountId}.json`;
await near.connection.signer.keyStore.setKey(options.networkId, options.accountId, keyPair);
await eventtracking.track(eventtracking.EVENT_ID_CREATE_ACCOUNT_END, { success: true, new_keypair: true }, options);
} else {
Expand All @@ -127,6 +135,7 @@ async function createAccount(options) {
}
}
// Create account
console.log(`Saving key to '${keyFilePath}'`);
try {
const response = await near.createAccount(options.accountId, publicKey);
inspectResponse.prettyPrintResponse(response, options);
Expand Down

0 comments on commit b3ed443

Please sign in to comment.