1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const crypto_1 = require("@arkecosystem/crypto");
|
4 | const command_1 = require("@oclif/command");
|
5 | const utils_1 = require("../utils");
|
6 | const command_2 = require("./command");
|
7 | class IdentityCommand extends command_2.BaseCommand {
|
8 | async run() {
|
9 |
|
10 | const { flags } = this.parse(IdentityCommand);
|
11 | let output;
|
12 | if (flags.type === "passphrase") {
|
13 | const keys = crypto_1.crypto.getKeys(flags.data);
|
14 | output = {
|
15 | passphrase: flags.data,
|
16 | publicKey: keys.publicKey,
|
17 | privateKey: keys.privateKey,
|
18 | address: crypto_1.crypto.getAddress(keys.publicKey, flags.network),
|
19 | };
|
20 | }
|
21 | else if (flags.type === "privateKey") {
|
22 | const keys = crypto_1.crypto.getKeysByPrivateKey(flags.data);
|
23 | output = {
|
24 | publicKey: keys.publicKey,
|
25 | privateKey: keys.privateKey,
|
26 | address: crypto_1.crypto.getAddress(keys.publicKey, flags.network),
|
27 | };
|
28 | }
|
29 | else if (flags.type === "publicKey") {
|
30 | output = {
|
31 | publicKey: flags.data,
|
32 | address: crypto_1.crypto.getAddress(flags.data, flags.network),
|
33 | };
|
34 | }
|
35 | return utils_1.handleOutput(flags, output);
|
36 | }
|
37 | }
|
38 | IdentityCommand.description = "Get identities from the given input";
|
39 | IdentityCommand.flags = Object.assign({}, command_2.BaseCommand.flags, { data: command_1.flags.string({
|
40 | description: "the data to get the identities from",
|
41 | required: true,
|
42 | }), network: command_1.flags.integer({
|
43 | description: "the network version used for calculating the address.",
|
44 | required: true,
|
45 | default: 30,
|
46 | }), type: command_1.flags.string({
|
47 | description: "the input type is either of passphrase, privateKey or publicKey",
|
48 | required: true,
|
49 | }) });
|
50 | exports.IdentityCommand = IdentityCommand;
|
51 |
|
\ | No newline at end of file |