Skip to content

Commit

Permalink
Merge pull request #124 from nearprotocol/fix-login-key
Browse files Browse the repository at this point in the history
Fix shell login (update code that checks if key got added to use new format
  • Loading branch information
janedegtiareva authored Aug 30, 2019
2 parents 6184a0f + 47a130d commit 27f8d55
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,22 @@ exports.login = async function(options) {
// check that the key got added
const near = await connect(options);
let account = await near.account(accountId);
let state = await account.state();
if (state.public_keys.includes(keyPair.getPublicKey())) {
let keys = await account.getAccessKeys();
let keyFound = false;
for (let i = 0; i < keys.length; i++) {
if (keys[i].public_key == keyPair.getPublicKey()) {
keyFound = true;
}
}
if (keyFound) {
const keyStore = new UnencryptedFileSystemKeyStore('./neardev');
keyStore.setKey(options.networkId, accountId, keyPair);
console.log(`Logged in with ${accountId}`);
} else {
console.log('Log in did not succeed. Please try again.')
}
} catch (_) {
console.log('Log in did not succeed. Please try again.')
} catch (e) {
console.log(e)
}
rl.close();
});
Expand Down

0 comments on commit 27f8d55

Please sign in to comment.