@twin.org/crypto-cli 0.0.1-next.20 → 0.0.1-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +16 -8
- package/dist/esm/index.mjs +16 -8
- package/dist/locales/en.json +5 -5
- package/dist/types/commands/address.d.ts +2 -2
- package/docs/changelog.md +1 -1
- package/docs/examples.md +2 -2
- package/locales/en.json +5 -5
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ function buildCommandAddress() {
|
|
|
24
24
|
.option(core.I18n.formatMessage("commands.address.options.start.param"), core.I18n.formatMessage("commands.address.options.start.description"), "0")
|
|
25
25
|
.option(core.I18n.formatMessage("commands.address.options.count.param"), core.I18n.formatMessage("commands.address.options.count.description"), "10")
|
|
26
26
|
.option(core.I18n.formatMessage("commands.address.options.account.param"), core.I18n.formatMessage("commands.address.options.account.description"), "0")
|
|
27
|
-
.option(core.I18n.formatMessage("commands.address.options.hrp.param"), core.I18n.formatMessage("commands.address.options.hrp.description")
|
|
27
|
+
.option(core.I18n.formatMessage("commands.address.options.hrp.param"), core.I18n.formatMessage("commands.address.options.hrp.description"))
|
|
28
28
|
.option(core.I18n.formatMessage("commands.address.options.coin.param"), core.I18n.formatMessage("commands.address.options.coin.description"), "4218")
|
|
29
29
|
.addOption(new commander.Option(core.I18n.formatMessage("commands.address.options.key-type.param"), core.I18n.formatMessage("commands.address.options.key-type.description"))
|
|
30
30
|
.choices(["Ed25519", "Secp256k1"])
|
|
@@ -49,7 +49,7 @@ function buildCommandAddress() {
|
|
|
49
49
|
* @param opts.start The start index for the address generation.
|
|
50
50
|
* @param opts.count The number of addresses to generate.
|
|
51
51
|
* @param opts.account The account index for the address generation.
|
|
52
|
-
* @param opts.hrp The human readable part for the
|
|
52
|
+
* @param opts.hrp The human readable part for the addresses if generating bech32 format.
|
|
53
53
|
* @param opts.coin The coin type for the address.
|
|
54
54
|
* @param opts.keyType The key type for the address.
|
|
55
55
|
* @param opts.keyFormat The output format of the key.
|
|
@@ -67,7 +67,9 @@ async function actionCommandAddress(opts) {
|
|
|
67
67
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.start"), start);
|
|
68
68
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.count"), count);
|
|
69
69
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.account"), account);
|
|
70
|
-
|
|
70
|
+
if (core.Is.stringValue(hrp)) {
|
|
71
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.hrp"), hrp);
|
|
72
|
+
}
|
|
71
73
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.coin"), coin);
|
|
72
74
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.key-type"), keyType);
|
|
73
75
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.key-format"), keyFormat);
|
|
@@ -76,9 +78,15 @@ async function actionCommandAddress(opts) {
|
|
|
76
78
|
cliCore.CLIDisplay.break();
|
|
77
79
|
const addressDictionary = {};
|
|
78
80
|
for (let i = start; i < start + count; i++) {
|
|
79
|
-
|
|
81
|
+
let addressKeyPair;
|
|
82
|
+
if (core.Is.stringValue(hrp)) {
|
|
83
|
+
addressKeyPair = crypto.Bip44.addressBech32(seed, keyType === "Ed25519" ? crypto.KeyType.Ed25519 : crypto.KeyType.Secp256k1, hrp, coin, account, false, i);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
addressKeyPair = crypto.Bip44.address(seed, keyType === "Ed25519" ? crypto.KeyType.Ed25519 : crypto.KeyType.Secp256k1, coin, account, false, i);
|
|
87
|
+
}
|
|
80
88
|
addressDictionary[i] = {
|
|
81
|
-
|
|
89
|
+
address: addressKeyPair.address,
|
|
82
90
|
privateKey: keyFormat === "hex"
|
|
83
91
|
? core.Converter.bytesToHex(addressKeyPair.privateKey, true)
|
|
84
92
|
: core.Converter.bytesToBase64(addressKeyPair.privateKey),
|
|
@@ -88,7 +96,7 @@ async function actionCommandAddress(opts) {
|
|
|
88
96
|
};
|
|
89
97
|
if (opts.console) {
|
|
90
98
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.index"), i);
|
|
91
|
-
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.address"), addressDictionary[i].
|
|
99
|
+
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.address"), addressDictionary[i].address);
|
|
92
100
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.private-key"), addressDictionary[i].privateKey);
|
|
93
101
|
cliCore.CLIDisplay.value(core.I18n.formatMessage("commands.address.labels.public-key"), addressDictionary[i].publicKey);
|
|
94
102
|
cliCore.CLIDisplay.break();
|
|
@@ -100,7 +108,7 @@ async function actionCommandAddress(opts) {
|
|
|
100
108
|
if (core.Is.stringValue(opts?.env)) {
|
|
101
109
|
const output = [];
|
|
102
110
|
for (const addressIndex in addressDictionary) {
|
|
103
|
-
output.push(`ADDRESS_${addressIndex}
|
|
111
|
+
output.push(`ADDRESS_${addressIndex}="${addressDictionary[addressIndex].address}"`);
|
|
104
112
|
output.push(`ADDRESS_${addressIndex}_PRIVATE_KEY="${addressDictionary[addressIndex].privateKey}"`);
|
|
105
113
|
output.push(`ADDRESS_${addressIndex}_PUBLIC_KEY="${addressDictionary[addressIndex].publicKey}"`);
|
|
106
114
|
}
|
|
@@ -185,7 +193,7 @@ class CLI extends cliCore.CLIBase {
|
|
|
185
193
|
return this.execute({
|
|
186
194
|
title: "TWIN Crypto",
|
|
187
195
|
appName: "twin-crypto",
|
|
188
|
-
version: "0.0.1-next.
|
|
196
|
+
version: "0.0.1-next.22",
|
|
189
197
|
icon: "🌍",
|
|
190
198
|
supportsEnvFiles: true,
|
|
191
199
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/esm/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ function buildCommandAddress() {
|
|
|
21
21
|
.option(I18n.formatMessage("commands.address.options.start.param"), I18n.formatMessage("commands.address.options.start.description"), "0")
|
|
22
22
|
.option(I18n.formatMessage("commands.address.options.count.param"), I18n.formatMessage("commands.address.options.count.description"), "10")
|
|
23
23
|
.option(I18n.formatMessage("commands.address.options.account.param"), I18n.formatMessage("commands.address.options.account.description"), "0")
|
|
24
|
-
.option(I18n.formatMessage("commands.address.options.hrp.param"), I18n.formatMessage("commands.address.options.hrp.description")
|
|
24
|
+
.option(I18n.formatMessage("commands.address.options.hrp.param"), I18n.formatMessage("commands.address.options.hrp.description"))
|
|
25
25
|
.option(I18n.formatMessage("commands.address.options.coin.param"), I18n.formatMessage("commands.address.options.coin.description"), "4218")
|
|
26
26
|
.addOption(new Option(I18n.formatMessage("commands.address.options.key-type.param"), I18n.formatMessage("commands.address.options.key-type.description"))
|
|
27
27
|
.choices(["Ed25519", "Secp256k1"])
|
|
@@ -46,7 +46,7 @@ function buildCommandAddress() {
|
|
|
46
46
|
* @param opts.start The start index for the address generation.
|
|
47
47
|
* @param opts.count The number of addresses to generate.
|
|
48
48
|
* @param opts.account The account index for the address generation.
|
|
49
|
-
* @param opts.hrp The human readable part for the
|
|
49
|
+
* @param opts.hrp The human readable part for the addresses if generating bech32 format.
|
|
50
50
|
* @param opts.coin The coin type for the address.
|
|
51
51
|
* @param opts.keyType The key type for the address.
|
|
52
52
|
* @param opts.keyFormat The output format of the key.
|
|
@@ -64,7 +64,9 @@ async function actionCommandAddress(opts) {
|
|
|
64
64
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.start"), start);
|
|
65
65
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.count"), count);
|
|
66
66
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.account"), account);
|
|
67
|
-
|
|
67
|
+
if (Is.stringValue(hrp)) {
|
|
68
|
+
CLIDisplay.value(I18n.formatMessage("commands.address.labels.hrp"), hrp);
|
|
69
|
+
}
|
|
68
70
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.coin"), coin);
|
|
69
71
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.key-type"), keyType);
|
|
70
72
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.key-format"), keyFormat);
|
|
@@ -73,9 +75,15 @@ async function actionCommandAddress(opts) {
|
|
|
73
75
|
CLIDisplay.break();
|
|
74
76
|
const addressDictionary = {};
|
|
75
77
|
for (let i = start; i < start + count; i++) {
|
|
76
|
-
|
|
78
|
+
let addressKeyPair;
|
|
79
|
+
if (Is.stringValue(hrp)) {
|
|
80
|
+
addressKeyPair = Bip44.addressBech32(seed, keyType === "Ed25519" ? KeyType.Ed25519 : KeyType.Secp256k1, hrp, coin, account, false, i);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
addressKeyPair = Bip44.address(seed, keyType === "Ed25519" ? KeyType.Ed25519 : KeyType.Secp256k1, coin, account, false, i);
|
|
84
|
+
}
|
|
77
85
|
addressDictionary[i] = {
|
|
78
|
-
|
|
86
|
+
address: addressKeyPair.address,
|
|
79
87
|
privateKey: keyFormat === "hex"
|
|
80
88
|
? Converter.bytesToHex(addressKeyPair.privateKey, true)
|
|
81
89
|
: Converter.bytesToBase64(addressKeyPair.privateKey),
|
|
@@ -85,7 +93,7 @@ async function actionCommandAddress(opts) {
|
|
|
85
93
|
};
|
|
86
94
|
if (opts.console) {
|
|
87
95
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.index"), i);
|
|
88
|
-
CLIDisplay.value(I18n.formatMessage("commands.address.labels.address"), addressDictionary[i].
|
|
96
|
+
CLIDisplay.value(I18n.formatMessage("commands.address.labels.address"), addressDictionary[i].address);
|
|
89
97
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.private-key"), addressDictionary[i].privateKey);
|
|
90
98
|
CLIDisplay.value(I18n.formatMessage("commands.address.labels.public-key"), addressDictionary[i].publicKey);
|
|
91
99
|
CLIDisplay.break();
|
|
@@ -97,7 +105,7 @@ async function actionCommandAddress(opts) {
|
|
|
97
105
|
if (Is.stringValue(opts?.env)) {
|
|
98
106
|
const output = [];
|
|
99
107
|
for (const addressIndex in addressDictionary) {
|
|
100
|
-
output.push(`ADDRESS_${addressIndex}
|
|
108
|
+
output.push(`ADDRESS_${addressIndex}="${addressDictionary[addressIndex].address}"`);
|
|
101
109
|
output.push(`ADDRESS_${addressIndex}_PRIVATE_KEY="${addressDictionary[addressIndex].privateKey}"`);
|
|
102
110
|
output.push(`ADDRESS_${addressIndex}_PUBLIC_KEY="${addressDictionary[addressIndex].publicKey}"`);
|
|
103
111
|
}
|
|
@@ -182,7 +190,7 @@ class CLI extends CLIBase {
|
|
|
182
190
|
return this.execute({
|
|
183
191
|
title: "TWIN Crypto",
|
|
184
192
|
appName: "twin-crypto",
|
|
185
|
-
version: "0.0.1-next.
|
|
193
|
+
version: "0.0.1-next.22",
|
|
186
194
|
icon: "🌍",
|
|
187
195
|
supportsEnvFiles: true,
|
|
188
196
|
overrideOutputWidth: options?.overrideOutputWidth
|
package/dist/locales/en.json
CHANGED
|
@@ -270,8 +270,8 @@
|
|
|
270
270
|
}
|
|
271
271
|
},
|
|
272
272
|
"address": {
|
|
273
|
-
"summary": "Create
|
|
274
|
-
"description": "Create a number of
|
|
273
|
+
"summary": "Create addresses and keys from the seed.",
|
|
274
|
+
"description": "Create a number of addresses and their associated key pairs from the seed.",
|
|
275
275
|
"options": {
|
|
276
276
|
"seed": {
|
|
277
277
|
"param": "--seed '<'seed'>'",
|
|
@@ -287,15 +287,15 @@
|
|
|
287
287
|
},
|
|
288
288
|
"account": {
|
|
289
289
|
"param": "--account '<'number'>'",
|
|
290
|
-
"description": "The account used to generate the
|
|
290
|
+
"description": "The account used to generate the addresses."
|
|
291
291
|
},
|
|
292
292
|
"hrp": {
|
|
293
293
|
"param": "--hrp '<'hrp'>'",
|
|
294
|
-
"description": "The human readable part
|
|
294
|
+
"description": "The human readable part for the addresses if generating bech32 format."
|
|
295
295
|
},
|
|
296
296
|
"coin": {
|
|
297
297
|
"param": "--coin '<'coin'>'",
|
|
298
|
-
"description": "The coin type used to generate the
|
|
298
|
+
"description": "The coin type used to generate the addresses."
|
|
299
299
|
},
|
|
300
300
|
"key-type": {
|
|
301
301
|
"param": "--key-type '<'type'>'",
|
|
@@ -12,7 +12,7 @@ export declare function buildCommandAddress(): Command;
|
|
|
12
12
|
* @param opts.start The start index for the address generation.
|
|
13
13
|
* @param opts.count The number of addresses to generate.
|
|
14
14
|
* @param opts.account The account index for the address generation.
|
|
15
|
-
* @param opts.hrp The human readable part for the
|
|
15
|
+
* @param opts.hrp The human readable part for the addresses if generating bech32 format.
|
|
16
16
|
* @param opts.coin The coin type for the address.
|
|
17
17
|
* @param opts.keyType The key type for the address.
|
|
18
18
|
* @param opts.keyFormat The output format of the key.
|
|
@@ -22,7 +22,7 @@ export declare function actionCommandAddress(opts: {
|
|
|
22
22
|
start: string;
|
|
23
23
|
count: string;
|
|
24
24
|
account: string;
|
|
25
|
-
hrp
|
|
25
|
+
hrp?: string;
|
|
26
26
|
coin: string;
|
|
27
27
|
keyType: "Ed25519" | "Secp256k1";
|
|
28
28
|
keyFormat: "hex" | "base64";
|
package/docs/changelog.md
CHANGED
package/docs/examples.md
CHANGED
|
@@ -229,10 +229,10 @@ twin-crypto address --load-env my.env --seed !SEED --env address.env --merge-env
|
|
|
229
229
|
The output of this command would produce address.env
|
|
230
230
|
|
|
231
231
|
```shell
|
|
232
|
-
|
|
232
|
+
ADDRESS_0="iota1qqcpqyrnqtzteu7k26dgjvjp3x76tts526prtwrjq99v50pyv6l9xysdcg8"
|
|
233
233
|
ADDRESS_0_PRIVATE_KEY="0x3b2863db878ce156a46d2142c72baa7807a40a990684604ff86456821228d978"
|
|
234
234
|
ADDRESS_0_PUBLIC_KEY="0x6b6eb9e54b44bfbc65c4a02c6489609fbc9588e640ca44bfdfdb1af4e5874905"
|
|
235
|
-
|
|
235
|
+
ADDRESS_1="iota1qrqyyyuhfzgrp7ducjapg8pta3w877nu0u5jpe50cxx39qjs08kczw7uj4v"
|
|
236
236
|
ADDRESS_1_PRIVATE_KEY="0xc5038b4c0b1dc46769687e77555a7be176e22de4262cf5aabf11290ab7c8d856"
|
|
237
237
|
ADDRESS_1_PUBLIC_KEY="0x603d9b2d25341d142524867536e3ee94d3e02a45fe498ec4c3473b0449446d77"
|
|
238
238
|
....
|
package/locales/en.json
CHANGED
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"address": {
|
|
52
|
-
"summary": "Create
|
|
53
|
-
"description": "Create a number of
|
|
52
|
+
"summary": "Create addresses and keys from the seed.",
|
|
53
|
+
"description": "Create a number of addresses and their associated key pairs from the seed.",
|
|
54
54
|
"options": {
|
|
55
55
|
"seed": {
|
|
56
56
|
"param": "--seed '<'seed'>'",
|
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
},
|
|
67
67
|
"account": {
|
|
68
68
|
"param": "--account '<'number'>'",
|
|
69
|
-
"description": "The account used to generate the
|
|
69
|
+
"description": "The account used to generate the addresses."
|
|
70
70
|
},
|
|
71
71
|
"hrp": {
|
|
72
72
|
"param": "--hrp '<'hrp'>'",
|
|
73
|
-
"description": "The human readable part
|
|
73
|
+
"description": "The human readable part for the addresses if generating bech32 format."
|
|
74
74
|
},
|
|
75
75
|
"coin": {
|
|
76
76
|
"param": "--coin '<'coin'>'",
|
|
77
|
-
"description": "The coin type used to generate the
|
|
77
|
+
"description": "The coin type used to generate the addresses."
|
|
78
78
|
},
|
|
79
79
|
"key-type": {
|
|
80
80
|
"param": "--key-type '<'type'>'",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/crypto-cli",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.22",
|
|
4
4
|
"description": "A command line interface for interacting with the crypto tools",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/cli-core": "0.0.1-next.
|
|
18
|
-
"@twin.org/core": "0.0.1-next.
|
|
19
|
-
"@twin.org/crypto": "0.0.1-next.
|
|
17
|
+
"@twin.org/cli-core": "0.0.1-next.22",
|
|
18
|
+
"@twin.org/core": "0.0.1-next.22",
|
|
19
|
+
"@twin.org/crypto": "0.0.1-next.22",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"commander": "13.0.0"
|
|
22
22
|
},
|