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

Commit

Permalink
Merge branch 'master' into hotfix/307-subdomains
Browse files Browse the repository at this point in the history
# Conflicts:
#	commands/create-account.js
  • Loading branch information
mikedotexe committed Apr 23, 2020
2 parents 95a4fea + 82ac910 commit 92cc593
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,6 +1,6 @@
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');
const NEAR_ENV_SUFFIXES = [
'near',
'test',
Expand Down Expand Up @@ -38,6 +38,7 @@ module.exports = {
};

async function createAccount(options) {
// NOTE: initialBalance is passed as part of config here, parsed in middleware/initial-balance
// periods are disallowed in top-level accounts and can only be used for subdomains
const splitAccount = options.accountId.split('.');
if (splitAccount.length === 2) {
Expand All @@ -58,8 +59,6 @@ async function createAccount(options) {
`2. A subdomain account name ending with .${NEAR_ENV_SUFFIXES.join(', .')}. (Example: counter.alice.test)`);
throw(ERROR_INVALID_FORMAT);
}
options.initialBalance = utils.format.parseNearAmount(options.initialBalance);
// NOTE: initialBalance is passed as part of config here
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 92cc593

Please sign in to comment.