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
Add interactive near repl
with auto-injected nearlib
, near
and account
#128
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8dfaae8
Add interactive `near repl` with auto-injected `nearlib`, `near` and …
vgrichina 098a262
Display default config similar to regular config
vgrichina 4b07cb4
Merge remote-tracking branch 'origin/master' into repl
vgrichina 1995e36
yarn fix
vgrichina 570f32f
Add Travis CI config
vgrichina 84c1268
Add shell trampoline for near-shell CLI with repl await
vgrichina 7012e9e
Try parallelizing build script
vgrichina 9aacc2f
yarn fix
vgrichina 10fb08e
Remaining lint fix
vgrichina bd70009
Set NODE_ENV for Travis
vgrichina 4d6134c
Use yarn cache
vgrichina c003d51
Add back yarn.lock (for Travis)
vgrichina 3f08a1b
Disable GitLab CI
vgrichina 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
command: 'repl', | ||
desc: 'launch interactive Node.js shell with NEAR connection available to use', | ||
builder: (yargs) => yargs, | ||
handler: async (argv) => { | ||
const repl = require('repl'); | ||
const context = repl.start('> ').context; | ||
context.nearlib = require('nearlib'); | ||
context.near = await require('../utils/connect')(argv); | ||
if (argv.accountId) { | ||
context.account = await context.near.account(argv.accountId); | ||
} | ||
} | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const nearlib = require('nearlib'); | ||
const UnencryptedFileSystemKeyStore = nearlib.keyStores.UnencryptedFileSystemKeyStore; | ||
|
||
module.exports = async function connect(options) { | ||
if (options.keyPath === undefined && options.helperUrl === undefined) { | ||
const homeDir = options.homeDir || `${process.env.HOME}/.near`; | ||
options.keyPath = `${homeDir}/validator_key.json`; | ||
} | ||
// TODO: search for key store. | ||
const keyStore = new UnencryptedFileSystemKeyStore('./neardev'); | ||
options.deps = { | ||
keyStore, | ||
}; | ||
return await nearlib.connect(options); | ||
} |
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.
what's --experimental-repl-await?
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.
(would be helpful to leave a comment)
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.
seems to be very googlable, so probably not worth it:
https://www.google.com/search?client=safari&rls=en&q=--experimental-repl-await&ie=UTF-8&oe=UTF-8