This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Login with wallet though shell: command format #61
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9f52d71
Login with wallet though shell: command format
janedegtiareva 0126866
basic implementation of login through wallet
janedegtiareva afe0b7d
Use Url to construct wallet url in login
janedegtiareva 261e28d
Add a prompt to enter account id after login
janedegtiareva 2a74b83
Merge branch 'nightshade' into j-walletlogin
janedegtiareva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ const yargs = require('yargs'); | |
const bs58 = require('bs58'); | ||
const ncp = require('ncp').ncp; | ||
const rimraf = require('rimraf'); | ||
const readline = require('readline') | ||
|
||
ncp.limit = 16; | ||
|
||
|
@@ -113,3 +114,27 @@ exports.stake = async function(options) { | |
const result = await account.stake(options.publicKey, BigInt(options.amount)); | ||
console.log('Result: ', JSON.stringify(result)); | ||
} | ||
|
||
exports.login = async function(options) { | ||
if (!options.walletUrl) { | ||
console.log("Log in is not needed on this environment. Please use appropriate master account for shell operations.") | ||
} else { | ||
const newUrl = new URL(options.walletUrl + "/login/"); | ||
const title = 'NEAR Shell'; | ||
newUrl.searchParams.set('title', title); | ||
const keyPair = await KeyPair.fromRandom('ed25519'); | ||
newUrl.searchParams.set('public_key', keyPair.getPublicKey()); | ||
console.log(`Please navigate to this url and follow the insturctions to log in: ${newUrl.toString()}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/insturctions/instructions/ probably good idea to put newline before URL to make it easier to copy if not clickable in given terminal |
||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}); | ||
|
||
rl.question('Please enter the accountId that you logged in with:', (accountId) => { | ||
const keyStore = new UnencryptedFileSystemKeyStore('./neardev'); | ||
keyStore.setKey(options.networkId, accountId, keyPair); | ||
console.log(`Logged in with ${accountId}`); | ||
}); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is hard to understand for outsider. Probably makes sense to link to docs on how to run local setup.