Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Add option to create multiple accounts #423

Closed
willclarktech opened this issue Jan 30, 2018 · 3 comments
Closed

Add option to create multiple accounts #423

willclarktech opened this issue Jan 30, 2018 · 3 comments

Comments

@willclarktech
Copy link
Contributor

Description

Sometimes it would be helpful to create multiple accounts in one go. E.g. if setting up a third-party application which needs to distinguish between payments from different sources.

Expected behavior: create account -n 50 would create 50 accounts and return them in an array

Actual behavior: Only one account can be created at a time

@mauliksoneji
Copy link

@willclarktech I am able to add the option to create multiple accounts, but I am not able to get how it these many accounts will be visible to the user.

Currently, I am able to parse the value provided by the user, I want to use this value to create these many accounts and display these accounts to the user.
screen shot 2018-05-02 at 10 41 19 pm

Also, I see that in the code, we use tablify.js to print the table to the user, so here as we will have multiple responses, do we need to display multiple tables to the user?

@willclarktech
Copy link
Contributor Author

@Mastermaulik For table output they should be separate rows in the same table.

@mauliksoneji
Copy link

@willclarktech , I was able to create n number of accounts through code.

Here is what updated code looks like:

export const actionCreator = () => async ({ options }) => {
	const {
		number = 1,
	} = options;

	const accountsArray = [];

	for (let i = 0; i < number; i += 1) {
		const passphrase = createMnemonicPassphrase();
		const { privateKey, publicKey } = cryptography.getKeys(passphrase);
		const { address } = cryptography.getAddressFromPublicKey(publicKey);
		accountsArray.push({
			passphrase,
			privateKey,
			publicKey,
			address,
		});
	}

	return accountsArray;
};

The output of the commands looks like:

screen shot 2018-05-03 at 2 10 38 pm

If this looks ok, I can send a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants