Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Change ./neardev references everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrichina committed May 13, 2020
1 parent d426201 commit f79beaa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 6 additions & 4 deletions commands/dev-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const connect = require('../utils/connect');
const { readFile, writeFile, mkdir } = require('fs').promises;
const { existsSync } = require('fs');
const eventtracking = require('../utils/eventtracking');
const { PROJECT_KEY_DIR } = require('../middleware/key-store');

module.exports = {
command: 'dev-deploy [wasmFile]',
Expand Down Expand Up @@ -52,9 +53,8 @@ async function devDeploy(options) {
async function createDevAccountIfNeeded({ near, keyStore, networkId, init }) {
// TODO: once examples and create-near-app use the dev-account.env file, we can remove the creation of dev-account
// https://github.com/nearprotocol/near-shell/issues/287
const accountFilePath = 'neardev/dev-account';
const accountFilePathEnv = 'neardev/dev-account.env';
const projectCredentialsPath = './neardev';
const accountFilePath = `${PROJECT_KEY_DIR}/dev-account`;
const accountFilePathEnv = `${PROJECT_KEY_DIR}/dev-account.env`;
if (!init) {
try {
// throws if either file is missing
Expand All @@ -66,7 +66,9 @@ async function createDevAccountIfNeeded({ near, keyStore, networkId, init }) {
} catch (e) {
if (e.code === 'ENOENT') {
// Create neardev directory, new account will be created below
if (!existsSync(projectCredentialsPath)) await mkdir(projectCredentialsPath);
if (!existsSync(PROJECT_KEY_DIR)) {
await mkdir(PROJECT_KEY_DIR);
}
} else {
throw e;
}
Expand Down
5 changes: 4 additions & 1 deletion middleware/key-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const MergeKeyStore = nearlib.keyStores.MergeKeyStore;
const UnencryptedFileSystemKeyStore = nearlib.keyStores.UnencryptedFileSystemKeyStore;

const CREDENTIALS_DIR = '.near-credentials';
const PROJECT_KEY_DIR = './neardev';

module.exports = async function createKeyStore() {
// ./neardev is an old way of storing keys under project folder. We want to fallback there for backwards compatibility
Expand All @@ -13,7 +14,9 @@ module.exports = async function createKeyStore() {
const credentialsPath = path.join(homedir, CREDENTIALS_DIR);
const keyStores = [
new UnencryptedFileSystemKeyStore(credentialsPath),
new UnencryptedFileSystemKeyStore('./neardev')
new UnencryptedFileSystemKeyStore(PROJECT_KEY_DIR)
];
return { keyStore: new MergeKeyStore(keyStores) };
};

module.exports.PROJECT_KEY_DIR = PROJECT_KEY_DIR;
4 changes: 3 additions & 1 deletion test_environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const NodeEnvironment = require('jest-environment-node');
const nearlib = require('near-api-js');
const fs = require('fs');

const { PROJECT_KEY_DIR } = require('./middleware/key-store');

const INITIAL_BALANCE = '500000000000000000000000000';
const testAccountName = 'test.near';

Expand All @@ -19,7 +21,7 @@ class LocalTestEnvironment extends NodeEnvironment {
contractName: 'test' + Date.now(),
accountId: 'test' + Date.now()
});
const keyStore = new nearlib.keyStores.UnencryptedFileSystemKeyStore('./neardev');
const keyStore = new nearlib.keyStores.UnencryptedFileSystemKeyStore(PROJECT_KEY_DIR);
config.deps = Object.assign(config.deps || {}, {
storage: this.createFakeStorage(),
keyStore,
Expand Down

0 comments on commit f79beaa

Please sign in to comment.