create.ts 754 B

123456789101112131415161718192021222324
  1. import AccountsCommandBase, { DEFAULT_ACCOUNT_TYPE } from '../../base/AccountsCommandBase'
  2. import { KeypairType } from '@polkadot/util-crypto/types'
  3. import { flags } from '@oclif/command'
  4. export default class AccountCreate extends AccountsCommandBase {
  5. static description = 'Create a new account'
  6. static flags = {
  7. name: flags.string({
  8. required: false,
  9. description: 'Account name',
  10. }),
  11. type: flags.enum<KeypairType>({
  12. required: false,
  13. description: `Account type (defaults to ${DEFAULT_ACCOUNT_TYPE})`,
  14. options: ['sr25519', 'ed25519'],
  15. }),
  16. }
  17. async run(): Promise<void> {
  18. const { name, type } = this.parse(AccountCreate).flags
  19. await this.createAccount(name, undefined, undefined, type)
  20. }
  21. }