@everyprotocol/every-cli 0.1.2 → 0.1.3
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/.every.toml +8 -10
- package/abis/ElementRegistry.json +1 -1
- package/abis/IObjectMinter.json +1 -1
- package/abis/IObjectMinterAdmin.json +1 -1
- package/abis/IOmniRegistry.json +1 -1
- package/abis/ISet.json +1 -1
- package/abis/ISetRegistry.json +1 -1
- package/abis/ISetRegistryAdmin.json +1 -1
- package/abis/KindRegistry.json +1 -1
- package/abis/ObjectMinter.json +1 -1
- package/abis/OmniRegistry.json +1 -1
- package/abis/SetRegistry.json +1 -1
- package/dist/abi.js +5 -0
- package/dist/config.js +86 -0
- package/dist/keystore.js +120 -0
- package/dist/matter.js +25 -81
- package/dist/mint.js +37 -23
- package/dist/options.js +26 -0
- package/dist/program.js +6 -6
- package/dist/substrate.js +57 -0
- package/dist/utils.js +41 -0
- package/dist/wallet.js +85 -103
- package/package.json +1 -1
package/dist/wallet.js
CHANGED
|
@@ -3,106 +3,88 @@ import { Keyring } from "@polkadot/keyring";
|
|
|
3
3
|
import { mnemonicGenerate, cryptoWaitReady } from "@polkadot/util-crypto";
|
|
4
4
|
import { bytesToHex } from "viem";
|
|
5
5
|
import * as fs from "fs";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
console.log(` Keystore: ${keystoreDisplay}`);
|
|
93
|
-
console.log(` Wallet: ${name}`);
|
|
94
|
-
console.log(` Type: ${account.type}`);
|
|
95
|
-
console.log(` Meta: ${JSON.stringify(account.meta)}`);
|
|
96
|
-
console.log(` Address: ${account.address}`);
|
|
97
|
-
console.log(`AddressRaw: ${bytesToHex(account.addressRaw)}`);
|
|
98
|
-
console.log(` PublicKey: ${bytesToHex(account.publicKey)}`);
|
|
99
|
-
if (decoded) {
|
|
100
|
-
console.log(`SecretKey: ${bytesToHex(decoded.secretKey)}`);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
walletCmd.addCommand(listCmd);
|
|
104
|
-
walletCmd.addCommand(generateCmd);
|
|
105
|
-
walletCmd.addCommand(importCmd);
|
|
106
|
-
walletCmd.addCommand(inspectCmd);
|
|
107
|
-
return walletCmd;
|
|
108
|
-
}
|
|
6
|
+
import { getPasswordConfirm, keystoreFromAccount, resolveKeystoreDir, saveKeystore } from "./utils.js";
|
|
7
|
+
const listCmd = new Command()
|
|
8
|
+
.name("list")
|
|
9
|
+
.description("List all wallets")
|
|
10
|
+
.option("-f, --foundry", "use foundry keystore directory (~/.foundry/keystores)")
|
|
11
|
+
.option("--dir <dir>", "specify a custom keystore directory")
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const dir = resolveKeystoreDir(options);
|
|
14
|
+
const files = fs.readdirSync(dir);
|
|
15
|
+
files.forEach((file) => console.log(file));
|
|
16
|
+
});
|
|
17
|
+
const generateCmd = new Command()
|
|
18
|
+
.name("new")
|
|
19
|
+
.description("Generate a new wallet")
|
|
20
|
+
.option("-t, --type <type>", "key type (sr25519, ed25519, ethereum)", "sr25519")
|
|
21
|
+
.option("-p, --password <password>", "password to encrypt the keystore")
|
|
22
|
+
.option("-P, --password-file <file>", "password file")
|
|
23
|
+
.option("--dir <dir>", "specify keystore directory")
|
|
24
|
+
.argument("<name>", "name of the wallet")
|
|
25
|
+
.action(async (name, options) => {
|
|
26
|
+
const password = getPasswordConfirm(options);
|
|
27
|
+
await cryptoWaitReady();
|
|
28
|
+
const keyring = new Keyring();
|
|
29
|
+
const mnemonic = mnemonicGenerate();
|
|
30
|
+
const pair = keyring.addFromUri(mnemonic, { name }, options.type);
|
|
31
|
+
const json = pair.toJson(password);
|
|
32
|
+
saveKeystore(json, name, options);
|
|
33
|
+
});
|
|
34
|
+
const importCmd = new Command()
|
|
35
|
+
.name("import")
|
|
36
|
+
.description("Import a wallet from a secrete URI")
|
|
37
|
+
.option("-t, --type <type>", "key type (sr25519, ed25519, ethereum)", "sr25519")
|
|
38
|
+
.option("-p, --password <password>", "password to encrypt the keystore")
|
|
39
|
+
.option("-P, --password-file <file>", "password file")
|
|
40
|
+
.option("--dir <dir>", "specify a custom keystore directory")
|
|
41
|
+
.option("-f, --foundry", "use foundry keystore directory (~/.foundry/keystores)")
|
|
42
|
+
.argument("<name>", "name of the wallet")
|
|
43
|
+
.argument("<suri>", "secret URI")
|
|
44
|
+
.action(async (name, suri, options) => {
|
|
45
|
+
const password = getPasswordConfirm(options);
|
|
46
|
+
await cryptoWaitReady();
|
|
47
|
+
const keyring = new Keyring({ type: options.type });
|
|
48
|
+
const pair = keyring.addFromUri(suri);
|
|
49
|
+
const json = pair.toJson(password);
|
|
50
|
+
saveKeystore(json, name, options);
|
|
51
|
+
});
|
|
52
|
+
const inspectCmd = new Command()
|
|
53
|
+
.name("inspect")
|
|
54
|
+
.description("Inspect a wallet")
|
|
55
|
+
.option("-t, --type <type>", "key type (sr25519, ed25519, ethereum)", "sr25519")
|
|
56
|
+
.option("-p, --password <password>", "password to decrypt the keystore")
|
|
57
|
+
.option("-P, --password-file <file>", "file containing the password")
|
|
58
|
+
.option("-x, --decrypt", "also decrypt the private key", false)
|
|
59
|
+
.option("--dir <dir>", "specify a custom keystore directory")
|
|
60
|
+
.option("-f, --foundry", "use foundry keystore directory (~/.foundry/keystores)")
|
|
61
|
+
.argument("<name>", "name of the wallet")
|
|
62
|
+
.action(async (name, options) => {
|
|
63
|
+
const keystore = await keystoreFromAccount(name, options);
|
|
64
|
+
let decoded;
|
|
65
|
+
if (options.decrypt) {
|
|
66
|
+
decoded = await keystore.privateKey();
|
|
67
|
+
}
|
|
68
|
+
let dir = "~/.every/keystores";
|
|
69
|
+
if (options.foundry) {
|
|
70
|
+
dir = "~/.foundry/keystores";
|
|
71
|
+
}
|
|
72
|
+
else if (options.dir) {
|
|
73
|
+
dir = options.dir;
|
|
74
|
+
}
|
|
75
|
+
console.log(` Keystore: ${dir}/${name}`);
|
|
76
|
+
console.log(` Store Type: ${keystore.type()}`);
|
|
77
|
+
console.log(` Key Type: ${keystore.keyType()}`);
|
|
78
|
+
console.log(` Address: ${await keystore.address()}`);
|
|
79
|
+
console.log(` Public Key: ${bytesToHex(await keystore.publicKey())}`);
|
|
80
|
+
if (decoded) {
|
|
81
|
+
console.log(`Private Key: ${bytesToHex(decoded)}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
export const walletCmd = new Command()
|
|
85
|
+
.name("wallet")
|
|
86
|
+
.description("manage wallets")
|
|
87
|
+
.addCommand(listCmd)
|
|
88
|
+
.addCommand(generateCmd)
|
|
89
|
+
.addCommand(importCmd)
|
|
90
|
+
.addCommand(inspectCmd);
|