From 10a639a011de8d1e9f5d95094aff6cc62edb4cc6 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 21 May 2019 00:59:59 -0700 Subject: [PATCH 1/2] Disable .strict() to allow extra properties in config --- bin/near | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/near b/bin/near index a6ed452c..c7bbcd8c 100755 --- a/bin/near +++ b/bin/near @@ -131,6 +131,5 @@ yargs // eslint-disable-line }) .showHelpOnFail(true) .demandCommand(1, 'Please enter a command') - .strict() .argv; From bc0a3863338fbd2c77c644abd570e8bf66586a81 Mon Sep 17 00:00:00 2001 From: Vladimir Grichina Date: Tue, 21 May 2019 01:04:05 -0700 Subject: [PATCH 2/2] Take networkId parameter --- bin/near | 6 ++++++ index.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/near b/bin/near index c7bbcd8c..1f966eab 100755 --- a/bin/near +++ b/bin/near @@ -102,6 +102,11 @@ yargs // eslint-disable-line type: 'string', default: 'http://localhost:3030' }) + .option('networkId', { + desc: 'NEAR network ID, allows using different keys based on network', + type: 'string', + default: 'default' + }) .option('helperUrl', { desc: 'NEAR contract helper URL', type: 'string', @@ -125,6 +130,7 @@ yargs // eslint-disable-line .alias({ 'accountId': ['account_id'], 'nodeUrl': 'node_url', + 'networkId': ['network_id'], 'wasmFile': 'wasm_file', 'projectDir': 'project_dir', 'outDir': 'out_dir' diff --git a/index.js b/index.js index 0bad3be5..1f8e6465 100755 --- a/index.js +++ b/index.js @@ -44,13 +44,13 @@ exports.createDevAccount = async function(options) { await neardev.connect(options); await options.deps.createAccount(options.accountId, keyPair.getPublicKey()); - const keyStore = new UnencryptedFileSystemKeyStore(); + const keyStore = new UnencryptedFileSystemKeyStore('./', options.networkId); keyStore.setKey(options.accountId, keyPair); console.log("Create account complete."); }; async function connect(options) { - const keyStore = new UnencryptedFileSystemKeyStore(); + const keyStore = new UnencryptedFileSystemKeyStore('./', options.networkId); if (!options.accountId) { // see if we only have one account in keystore and just use that. const accountIds = await keyStore.getAccountIds();