@zoralabs/cli 1.4.1 → 1.4.2
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 +137 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -173,6 +173,63 @@ function extractErrorMessage(error) {
|
|
|
173
173
|
}
|
|
174
174
|
return JSON.stringify(error);
|
|
175
175
|
}
|
|
176
|
+
var MAX_SERIALIZE_DEPTH = 6;
|
|
177
|
+
function toSerializable(value, seen, depth) {
|
|
178
|
+
if (value === null) return null;
|
|
179
|
+
const type = typeof value;
|
|
180
|
+
if (type === "string" || type === "boolean") {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
if (type === "number") {
|
|
184
|
+
return Number.isFinite(value) ? value : null;
|
|
185
|
+
}
|
|
186
|
+
if (type === "bigint") return value.toString();
|
|
187
|
+
if (type === "undefined" || type === "function" || type === "symbol") {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const obj = value;
|
|
191
|
+
if (seen.has(obj)) return "[Circular]";
|
|
192
|
+
if (depth >= MAX_SERIALIZE_DEPTH) return "[MaxDepth]";
|
|
193
|
+
if (value instanceof Date) {
|
|
194
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
195
|
+
}
|
|
196
|
+
seen.add(obj);
|
|
197
|
+
try {
|
|
198
|
+
if (Array.isArray(value)) {
|
|
199
|
+
return value.map((item) => toSerializable(item, seen, depth + 1));
|
|
200
|
+
}
|
|
201
|
+
const result = {};
|
|
202
|
+
if (value instanceof Error) {
|
|
203
|
+
result.name = value.name;
|
|
204
|
+
result.message = value.message;
|
|
205
|
+
if (value.stack) result.stack = value.stack;
|
|
206
|
+
}
|
|
207
|
+
for (const key of Object.keys(value)) {
|
|
208
|
+
if (key in result) continue;
|
|
209
|
+
let raw;
|
|
210
|
+
try {
|
|
211
|
+
raw = value[key];
|
|
212
|
+
} catch (getterError) {
|
|
213
|
+
result[key] = `[Unserializable: ${getterError instanceof Error ? getterError.message : String(getterError)}]`;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const t = typeof raw;
|
|
217
|
+
if (t === "undefined" || t === "function" || t === "symbol") continue;
|
|
218
|
+
result[key] = toSerializable(raw, seen, depth + 1);
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
} finally {
|
|
222
|
+
seen.delete(obj);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function serializeError(err) {
|
|
226
|
+
const serialized = toSerializable(err, /* @__PURE__ */ new WeakSet(), 0);
|
|
227
|
+
if (serialized !== null && typeof serialized === "object") {
|
|
228
|
+
if (Array.isArray(serialized)) return { value: serialized };
|
|
229
|
+
return serialized;
|
|
230
|
+
}
|
|
231
|
+
return { message: serialized === null ? String(err) : serialized };
|
|
232
|
+
}
|
|
176
233
|
function bannedCoinMessage(address) {
|
|
177
234
|
return `The coin at ${address} is unavailable because it violates the Zora terms of service.`;
|
|
178
235
|
}
|
|
@@ -1070,8 +1127,8 @@ async function confirmAgentAction(opts) {
|
|
|
1070
1127
|
}
|
|
1071
1128
|
|
|
1072
1129
|
// src/lib/analytics.ts
|
|
1073
|
-
import { PostHog } from "posthog-node";
|
|
1074
1130
|
import { createHash, randomUUID } from "crypto";
|
|
1131
|
+
import { PostHog } from "posthog-node";
|
|
1075
1132
|
import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
|
|
1076
1133
|
|
|
1077
1134
|
// src/lib/account/index.ts
|
|
@@ -1472,22 +1529,37 @@ var getClient = () => {
|
|
|
1472
1529
|
}
|
|
1473
1530
|
return client;
|
|
1474
1531
|
};
|
|
1475
|
-
var
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
});
|
|
1481
|
-
var hashApiKey = (key) => createHash("sha256").update(key).digest("hex").slice(0, 16);
|
|
1482
|
-
var getWalletAddress = () => {
|
|
1532
|
+
var getWalletAddresses = () => {
|
|
1533
|
+
const addresses = {
|
|
1534
|
+
wallet: void 0,
|
|
1535
|
+
smartWallet: void 0
|
|
1536
|
+
};
|
|
1483
1537
|
try {
|
|
1484
|
-
const
|
|
1485
|
-
|
|
1486
|
-
return privateKeyToAccount2(normalizeKey(key)).address;
|
|
1538
|
+
const privateKey = resolvePrivateKey();
|
|
1539
|
+
addresses.wallet = privateKeyToAccount2(normalizeKey(privateKey)).address;
|
|
1487
1540
|
} catch {
|
|
1488
|
-
|
|
1541
|
+
addresses.wallet = void 0;
|
|
1489
1542
|
}
|
|
1543
|
+
try {
|
|
1544
|
+
const smartWalletAddress = resolveSmartWalletAddress();
|
|
1545
|
+
addresses.smartWallet = smartWalletAddress;
|
|
1546
|
+
} catch {
|
|
1547
|
+
addresses.smartWallet = void 0;
|
|
1548
|
+
}
|
|
1549
|
+
return addresses;
|
|
1490
1550
|
};
|
|
1551
|
+
var commonProperties = () => {
|
|
1552
|
+
const addresses = getWalletAddresses();
|
|
1553
|
+
return {
|
|
1554
|
+
cli_version: true ? "1.4.2" : "development",
|
|
1555
|
+
os: process.platform,
|
|
1556
|
+
arch: process.arch,
|
|
1557
|
+
node_version: process.version,
|
|
1558
|
+
wallet_address: addresses.wallet,
|
|
1559
|
+
smart_wallet_address: addresses.smartWallet
|
|
1560
|
+
};
|
|
1561
|
+
};
|
|
1562
|
+
var hashApiKey = (key) => createHash("sha256").update(key).digest("hex").slice(0, 16);
|
|
1491
1563
|
var identified = false;
|
|
1492
1564
|
var identify = () => {
|
|
1493
1565
|
try {
|
|
@@ -1495,20 +1567,37 @@ var identify = () => {
|
|
|
1495
1567
|
identified = true;
|
|
1496
1568
|
const id = getOrCreateDistinctId();
|
|
1497
1569
|
const apiKey = getApiKey();
|
|
1498
|
-
const walletAddress =
|
|
1499
|
-
if (!apiKey && !walletAddress) {
|
|
1570
|
+
const { wallet: walletAddress, smartWallet: smartWalletAddress } = getWalletAddresses();
|
|
1571
|
+
if (!apiKey && !walletAddress && !smartWalletAddress) {
|
|
1500
1572
|
return;
|
|
1501
1573
|
}
|
|
1502
1574
|
getClient().identify({
|
|
1503
1575
|
distinctId: id,
|
|
1504
1576
|
properties: {
|
|
1505
1577
|
api_key_hash: apiKey ? hashApiKey(apiKey) : void 0,
|
|
1506
|
-
wallet_address: walletAddress ?? void 0
|
|
1578
|
+
wallet_address: walletAddress ?? void 0,
|
|
1579
|
+
smart_wallet_address: smartWalletAddress ?? void 0
|
|
1507
1580
|
}
|
|
1508
1581
|
});
|
|
1509
1582
|
} catch {
|
|
1510
1583
|
}
|
|
1511
1584
|
};
|
|
1585
|
+
var setPersonProperties = (properties) => {
|
|
1586
|
+
try {
|
|
1587
|
+
if (isDisabled()) return;
|
|
1588
|
+
const cleaned = Object.fromEntries(
|
|
1589
|
+
Object.entries(properties).filter(
|
|
1590
|
+
([, value]) => value !== void 0 && value !== null && value !== ""
|
|
1591
|
+
)
|
|
1592
|
+
);
|
|
1593
|
+
if (Object.keys(cleaned).length === 0) return;
|
|
1594
|
+
getClient().identify({
|
|
1595
|
+
distinctId: getOrCreateDistinctId(),
|
|
1596
|
+
properties: cleaned
|
|
1597
|
+
});
|
|
1598
|
+
} catch {
|
|
1599
|
+
}
|
|
1600
|
+
};
|
|
1512
1601
|
var track = (event, properties) => {
|
|
1513
1602
|
try {
|
|
1514
1603
|
if (isDisabled()) return;
|
|
@@ -3283,6 +3372,7 @@ Re-running 'agent create' will mint another ${what} for it.`;
|
|
|
3283
3372
|
set_ticker: options.ticker !== void 0,
|
|
3284
3373
|
output_format: json ? "json" : "text"
|
|
3285
3374
|
});
|
|
3375
|
+
setPersonProperties({ name: result.username });
|
|
3286
3376
|
outputData(json, {
|
|
3287
3377
|
json: {
|
|
3288
3378
|
...result,
|
|
@@ -3505,6 +3595,7 @@ agentCommand.command("connect-email").description(
|
|
|
3505
3595
|
generated_wallet: resolved.generated,
|
|
3506
3596
|
output_format: json ? "json" : "text"
|
|
3507
3597
|
});
|
|
3598
|
+
setPersonProperties({ email });
|
|
3508
3599
|
return outputData(json, {
|
|
3509
3600
|
json: {
|
|
3510
3601
|
email,
|
|
@@ -3600,6 +3691,7 @@ agentCommand.command("connect-email").description(
|
|
|
3600
3691
|
generated_wallet: resolved.generated,
|
|
3601
3692
|
output_format: json ? "json" : "text"
|
|
3602
3693
|
});
|
|
3694
|
+
setPersonProperties({ email: result.email });
|
|
3603
3695
|
outputData(json, {
|
|
3604
3696
|
json: {
|
|
3605
3697
|
email: result.email,
|
|
@@ -3711,6 +3803,9 @@ The old handle may be claimed by someone else, and links to it can break.`,
|
|
|
3711
3803
|
updated_avatar: options.avatar !== void 0,
|
|
3712
3804
|
output_format: json ? "json" : "text"
|
|
3713
3805
|
});
|
|
3806
|
+
if (options.username !== void 0) {
|
|
3807
|
+
setPersonProperties({ name: profile.username });
|
|
3808
|
+
}
|
|
3714
3809
|
const profileUrl = `https://zora.co/@${profile.username}`;
|
|
3715
3810
|
outputData(json, {
|
|
3716
3811
|
json: {
|
|
@@ -5947,7 +6042,8 @@ ${err instanceof Error ? err.stack || err.message : String(err)}
|
|
|
5947
6042
|
slippage: slippagePct,
|
|
5948
6043
|
output_format: json ? "json" : "static",
|
|
5949
6044
|
success: false,
|
|
5950
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
6045
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
6046
|
+
error: serializeError(err)
|
|
5951
6047
|
});
|
|
5952
6048
|
await shutdownAnalytics();
|
|
5953
6049
|
return outputErrorAndExit(
|
|
@@ -5975,7 +6071,11 @@ ${err instanceof Error ? err.stack || err.message : String(err)}
|
|
|
5975
6071
|
const now = /* @__PURE__ */ new Date();
|
|
5976
6072
|
const updated = appendSpend(
|
|
5977
6073
|
budget,
|
|
5978
|
-
{
|
|
6074
|
+
{
|
|
6075
|
+
at: now.toISOString(),
|
|
6076
|
+
usd: swapAmountUsd,
|
|
6077
|
+
skill: `buy ${coinSymbol}`
|
|
6078
|
+
},
|
|
5979
6079
|
now
|
|
5980
6080
|
);
|
|
5981
6081
|
saveBudget(updated);
|
|
@@ -6311,7 +6411,8 @@ var commentCommand = new Command5("comment").description("Comment on a coin you
|
|
|
6311
6411
|
coin_address: coin.address,
|
|
6312
6412
|
output_format: json ? "json" : "static",
|
|
6313
6413
|
success: false,
|
|
6314
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
6414
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
6415
|
+
error: serializeError(err)
|
|
6315
6416
|
});
|
|
6316
6417
|
await shutdownAnalytics();
|
|
6317
6418
|
const rawMessage = err instanceof Error ? err.message : String(err);
|
|
@@ -6636,7 +6737,9 @@ var createCommand = new Command6("create").description("Create a coin (post)").o
|
|
|
6636
6737
|
output_format: json ? "json" : "static",
|
|
6637
6738
|
success: false,
|
|
6638
6739
|
stage: "upload",
|
|
6639
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
6740
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
6741
|
+
error_message: err instanceof Error ? err.message : String(err),
|
|
6742
|
+
error: serializeError(err)
|
|
6640
6743
|
});
|
|
6641
6744
|
await shutdownAnalytics();
|
|
6642
6745
|
return outputErrorAndExit(
|
|
@@ -6671,7 +6774,9 @@ var createCommand = new Command6("create").description("Create a coin (post)").o
|
|
|
6671
6774
|
output_format: json ? "json" : "static",
|
|
6672
6775
|
success: false,
|
|
6673
6776
|
stage: "deploy",
|
|
6674
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
6777
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
6778
|
+
error_message: err instanceof Error ? err.message : String(err),
|
|
6779
|
+
error: serializeError(err)
|
|
6675
6780
|
});
|
|
6676
6781
|
await shutdownAnalytics();
|
|
6677
6782
|
return outputErrorAndExit(
|
|
@@ -7400,7 +7505,8 @@ dmCommand.command("send").description(
|
|
|
7400
7505
|
track("cli_dm_send", {
|
|
7401
7506
|
output_format: json ? "json" : "text",
|
|
7402
7507
|
success: false,
|
|
7403
|
-
denied: true
|
|
7508
|
+
denied: true,
|
|
7509
|
+
error: serializeError(err)
|
|
7404
7510
|
});
|
|
7405
7511
|
return outputErrorAndExit(
|
|
7406
7512
|
json,
|
|
@@ -7978,7 +8084,8 @@ async function runFollow(command, action, identifierArg) {
|
|
|
7978
8084
|
action,
|
|
7979
8085
|
output_format: json ? "json" : "static",
|
|
7980
8086
|
success: false,
|
|
7981
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
8087
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
8088
|
+
error: serializeError(err)
|
|
7982
8089
|
});
|
|
7983
8090
|
await shutdownAnalytics();
|
|
7984
8091
|
const message = formatError(err);
|
|
@@ -9655,7 +9762,8 @@ ${err instanceof Error ? err.stack || err.message : String(err)}
|
|
|
9655
9762
|
slippage: slippagePct,
|
|
9656
9763
|
output_format: output,
|
|
9657
9764
|
success: false,
|
|
9658
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
9765
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
9766
|
+
error: serializeError(err)
|
|
9659
9767
|
});
|
|
9660
9768
|
await shutdownAnalytics();
|
|
9661
9769
|
return outputErrorAndExit(
|
|
@@ -11070,7 +11178,8 @@ var sendCommand = new Command13("send").description("Send coins or ETH to an add
|
|
|
11070
11178
|
asset: "eth",
|
|
11071
11179
|
output_format: json ? "json" : "static",
|
|
11072
11180
|
success: false,
|
|
11073
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
11181
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
11182
|
+
error: serializeError(err)
|
|
11074
11183
|
});
|
|
11075
11184
|
await shutdownAnalytics();
|
|
11076
11185
|
return outputErrorAndExit(
|
|
@@ -11338,7 +11447,8 @@ var sendCommand = new Command13("send").description("Send coins or ETH to an add
|
|
|
11338
11447
|
coin_symbol: symbol,
|
|
11339
11448
|
output_format: json ? "json" : "static",
|
|
11340
11449
|
success: false,
|
|
11341
|
-
error_type: err instanceof Error ? err.constructor.name : "unknown"
|
|
11450
|
+
error_type: err instanceof Error ? err.constructor.name : "unknown",
|
|
11451
|
+
error: serializeError(err)
|
|
11342
11452
|
});
|
|
11343
11453
|
await shutdownAnalytics();
|
|
11344
11454
|
return outputErrorAndExit(
|
|
@@ -12557,7 +12667,7 @@ import { jsx as jsx24 } from "react/jsx-runtime";
|
|
|
12557
12667
|
if (process.env.ZORA_API_TARGET) {
|
|
12558
12668
|
setApiBaseUrl(process.env.ZORA_API_TARGET);
|
|
12559
12669
|
}
|
|
12560
|
-
var version = true ? "1.4.
|
|
12670
|
+
var version = true ? "1.4.2" : JSON.parse(
|
|
12561
12671
|
readFileSync5(new URL("../package.json", import.meta.url), "utf-8")
|
|
12562
12672
|
).version;
|
|
12563
12673
|
function styledHelpWriteOut(showHeader) {
|