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

feat: add mainnet config #322

Merged
merged 5 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
};