Skip to content

Commit

Permalink
Merge pull request #322 from nearprotocol/mainnet-config
Browse files Browse the repository at this point in the history
feat: add mainnet config
  • Loading branch information
vgrichina committed Apr 23, 2020
2 parents 59f662b + 33d6e0d commit 82ac910
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions bin/near-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ yargs // eslint-disable-line
type: 'string',
hidden: true
})
.middleware(require('../middleware/initial-balance'))
.middleware(require('../middleware/print-options'))
.middleware(require('../middleware/key-store'))
.command(require('../commands/create-account'))
Expand Down
5 changes: 2 additions & 3 deletions commands/create-account.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

const exitOnError = require('../utils/exit-on-error');
const connect = require('../utils/connect');
const { KeyPair, utils } = require('near-api-js');
const { KeyPair } = require('near-api-js');

module.exports = {
command: 'create_account <accountId>',
Expand Down Expand Up @@ -31,8 +31,7 @@ module.exports = {
};

async function createAccount(options) {
options.initialBalance = utils.format.parseNearAmount(options.initialBalance);
// NOTE: initialBalance is passed as part of config here
// NOTE: initialBalance is passed as part of config here, parsed in middleware/initial-balance
let near = await connect(options);
let keyPair;
let publicKey;
Expand Down
5 changes: 5 additions & 0 deletions commands/dev-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module.exports = {
type: 'boolean',
default: false
})
.option('initialBalance', {
desc: 'Number of tokens to transfer to newly created account',
type: 'string',
default: '100'
})
.alias({
'init': ['force', 'f'],
}),
Expand Down
13 changes: 10 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ function getConfig(env) {
switch (env) {

case 'production':
return {
networkId: 'mainnet',
nodeUrl: 'https://rpc.mainnet.nearprotocol.com',
contractName: CONTRACT_NAME,
walletUrl: 'https://wallet.mainnet.nearprotocol.com',
helperUrl: 'https://helper.mainnet.nearprotocol.com',
};
case 'development':
return {
networkId: 'default',
nodeUrl: 'https://rpc.nearprotocol.com',
nodeUrl: 'https://rpc.testnet.nearprotocol.com',
contractName: CONTRACT_NAME,
walletUrl: 'https://wallet.nearprotocol.com',
helperUrl: 'https://helper.nearprotocol.com',
walletUrl: 'https://wallet.testnet.nearprotocol.com',
helperUrl: 'https://helper.testnet.nearprotocol.com',
};
case 'devnet':
return {
Expand Down
6 changes: 6 additions & 0 deletions middleware/initial-balance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const { utils } = require('near-api-js');

module.exports = async function parseInitialBalance(options) {
options.initialBalance = utils.format.parseNearAmount(options.initialBalance);
};

0 comments on commit 82ac910

Please sign in to comment.