@otonix/cli 2.1.7 → 2.1.8
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/commands/agent.js +32 -19
- package/package.json +1 -1
package/dist/commands/agent.js
CHANGED
|
@@ -97,13 +97,15 @@ export function agentCommand(program) {
|
|
|
97
97
|
failure("No creator wallet found. Run: otonix wallet generate");
|
|
98
98
|
process.exit(1);
|
|
99
99
|
}
|
|
100
|
-
const balSpinner = ora("Checking
|
|
101
|
-
let
|
|
102
|
-
let
|
|
100
|
+
const balSpinner = ora("Checking balances...").start();
|
|
101
|
+
let creatorOtx, creatorEth;
|
|
102
|
+
let agentOtx, agentEth;
|
|
103
103
|
try {
|
|
104
|
-
[
|
|
104
|
+
[creatorOtx, creatorEth, agentOtx, agentEth] = await Promise.all([
|
|
105
105
|
getOtxBalance(cfg.wallet.address),
|
|
106
106
|
getEthBalance(cfg.wallet.address),
|
|
107
|
+
getOtxBalance(agent.address),
|
|
108
|
+
getEthBalance(agent.address),
|
|
107
109
|
]);
|
|
108
110
|
}
|
|
109
111
|
catch {
|
|
@@ -112,35 +114,46 @@ export function agentCommand(program) {
|
|
|
112
114
|
process.exit(1);
|
|
113
115
|
}
|
|
114
116
|
balSpinner.stop();
|
|
117
|
+
const creatorOk = creatorOtx >= OTX_REQUIRED && parseFloat(creatorEth) >= 0.0001;
|
|
118
|
+
const agentOk = agentOtx >= OTX_REQUIRED && parseFloat(agentEth) >= 0.0001;
|
|
119
|
+
const payerKey = creatorOk ? cfg.wallet.privateKey : agent.privateKey;
|
|
120
|
+
const payerAddress = creatorOk ? cfg.wallet.address : agent.address;
|
|
121
|
+
const payerLabel = creatorOk ? "creator wallet" : "agent wallet";
|
|
115
122
|
br();
|
|
116
|
-
|
|
117
|
-
row("$OTX
|
|
118
|
-
row("ETH
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
console.log(chalk.dim(" Creator wallet ") + chalk.white(cfg.wallet.address));
|
|
124
|
+
row(" $OTX", formatOtx(creatorOtx) + " OTX" + (creatorOtx >= OTX_REQUIRED ? chalk.green(" ✓") : chalk.yellow(" ✗")));
|
|
125
|
+
row(" ETH", parseFloat(creatorEth).toFixed(6) + " ETH" + (parseFloat(creatorEth) >= 0.0001 ? chalk.green(" ✓") : chalk.yellow(" ✗")));
|
|
126
|
+
br();
|
|
127
|
+
console.log(chalk.dim(" Agent wallet ") + chalk.white(agent.address));
|
|
128
|
+
row(" $OTX", formatOtx(agentOtx) + " OTX" + (agentOtx >= OTX_REQUIRED ? chalk.green(" ✓") : chalk.yellow(" ✗")));
|
|
129
|
+
row(" ETH", parseFloat(agentEth).toFixed(6) + " ETH" + (parseFloat(agentEth) >= 0.0001 ? chalk.green(" ✓") : chalk.yellow(" ✗")));
|
|
121
130
|
br();
|
|
122
|
-
if (
|
|
123
|
-
failure(
|
|
124
|
-
info("
|
|
131
|
+
if (!creatorOk && !agentOk) {
|
|
132
|
+
failure("Neither creator nor agent wallet has enough $OTX + ETH.");
|
|
133
|
+
info("Need ≥ 200 $OTX + ≥ 0.0001 ETH in either wallet.");
|
|
134
|
+
info("Buy $OTX: https://dexscreener.com/base/0xF7E2a6226Ffe0693DD85406AC3A8917cbea5DC40");
|
|
125
135
|
process.exit(1);
|
|
126
136
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
process.exit(1);
|
|
137
|
+
if (!creatorOk && agentOk) {
|
|
138
|
+
console.log(chalk.yellow("⚠ ") + chalk.dim("Creator wallet insufficient — using agent wallet instead."));
|
|
139
|
+
br();
|
|
131
140
|
}
|
|
141
|
+
row("Paying from", payerLabel + " (" + payerAddress.slice(0, 10) + "...)");
|
|
142
|
+
row("Registration fee", "200 $OTX → Otonix treasury");
|
|
143
|
+
row("Treasury", OTONIX_TREASURY);
|
|
144
|
+
br();
|
|
132
145
|
const confirmed = await confirm({
|
|
133
|
-
message: `Send 200 $OTX from
|
|
146
|
+
message: `Send 200 $OTX from ${payerLabel} to Otonix treasury to activate "${opts.name}"?`,
|
|
134
147
|
default: true,
|
|
135
148
|
});
|
|
136
149
|
if (!confirmed) {
|
|
137
150
|
info("Cancelled.");
|
|
138
151
|
return;
|
|
139
152
|
}
|
|
140
|
-
const sendSpinner = ora(
|
|
153
|
+
const sendSpinner = ora(`Sending 200 $OTX from ${payerLabel}...`).start();
|
|
141
154
|
let txHash;
|
|
142
155
|
try {
|
|
143
|
-
txHash = await sendOtx(
|
|
156
|
+
txHash = await sendOtx(payerKey, OTONIX_TREASURY, OTX_REQUIRED);
|
|
144
157
|
}
|
|
145
158
|
catch (err) {
|
|
146
159
|
sendSpinner.stop();
|