@zeroxyz/cli 0.0.19 → 0.0.20
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/index.js +36 -23
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command as Command9 } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@zeroxyz/cli",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.20",
|
|
10
10
|
type: "module",
|
|
11
11
|
bin: {
|
|
12
12
|
zero: "dist/index.js",
|
|
@@ -480,32 +480,41 @@ var initCommand = (appContext) => new Command4("init").description("Initialize Z
|
|
|
480
480
|
const home = homedir2();
|
|
481
481
|
const zeroDir = join2(home, ".zero");
|
|
482
482
|
const configPath = join2(zeroDir, "config.json");
|
|
483
|
-
|
|
483
|
+
let walletCreated = false;
|
|
484
|
+
let walletAddress = null;
|
|
485
|
+
const walletExists = (() => {
|
|
486
|
+
if (!existsSync2(configPath)) return false;
|
|
484
487
|
try {
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
const existing = JSON.parse(readFileSync2(configPath, "utf8"));
|
|
489
|
+
return !!existing.privateKey;
|
|
490
|
+
} catch {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
})();
|
|
494
|
+
if (!walletExists || options.force) {
|
|
495
|
+
const privateKey = generatePrivateKey();
|
|
496
|
+
const account = privateKeyToAccount(privateKey);
|
|
497
|
+
mkdirSync2(zeroDir, { recursive: true });
|
|
498
|
+
const existing = existsSync2(configPath) ? JSON.parse(readFileSync2(configPath, "utf8")) : {};
|
|
499
|
+
writeFileSync2(
|
|
500
|
+
configPath,
|
|
501
|
+
JSON.stringify(
|
|
502
|
+
{ ...existing, privateKey, lowBalanceWarning: 1 },
|
|
503
|
+
null,
|
|
504
|
+
2
|
|
505
|
+
)
|
|
506
|
+
);
|
|
507
|
+
walletCreated = true;
|
|
508
|
+
walletAddress = account.address;
|
|
509
|
+
console.log(`Wallet address: ${account.address}`);
|
|
510
|
+
} else {
|
|
511
|
+
try {
|
|
512
|
+
const existing = JSON.parse(readFileSync2(configPath, "utf8"));
|
|
513
|
+
const account = privateKeyToAccount(existing.privateKey);
|
|
514
|
+
walletAddress = account.address;
|
|
493
515
|
} catch {
|
|
494
516
|
}
|
|
495
517
|
}
|
|
496
|
-
const privateKey = generatePrivateKey();
|
|
497
|
-
const account = privateKeyToAccount(privateKey);
|
|
498
|
-
mkdirSync2(zeroDir, { recursive: true });
|
|
499
|
-
const existing = existsSync2(configPath) ? JSON.parse(readFileSync2(configPath, "utf8")) : {};
|
|
500
|
-
writeFileSync2(
|
|
501
|
-
configPath,
|
|
502
|
-
JSON.stringify(
|
|
503
|
-
{ ...existing, privateKey, lowBalanceWarning: 1 },
|
|
504
|
-
null,
|
|
505
|
-
2
|
|
506
|
-
)
|
|
507
|
-
);
|
|
508
|
-
console.log(`Wallet address: ${account.address}`);
|
|
509
518
|
const agentsDetected = [];
|
|
510
519
|
const agentsWithSkills = [];
|
|
511
520
|
let skillsError = null;
|
|
@@ -536,6 +545,10 @@ var initCommand = (appContext) => new Command4("init").description("Initialize Z
|
|
|
536
545
|
'Zero is ready! Run `zero search` to find capabilities.\n\nTry:\n zero search "translate text to Spanish"\n zero search "generate an image"\n zero search "weather forecast"'
|
|
537
546
|
);
|
|
538
547
|
appContext.services.analyticsService.capture("wallet_initialized", {
|
|
548
|
+
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|
|
549
|
+
wallet_created: walletCreated,
|
|
550
|
+
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|
|
551
|
+
wallet_address: walletAddress,
|
|
539
552
|
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|
|
540
553
|
agents_detected: agentsDetected,
|
|
541
554
|
// biome-ignore lint/style/useNamingConvention: snake_case for analytics
|