@trustwallet/cli 0.6.2 → 0.6.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmC1D"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2D1D"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2D1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsb3D"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/commands/query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgd3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/commands/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAspB5D"}
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/commands/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0pB5D"}
package/dist/index.js CHANGED
@@ -49,6 +49,13 @@
49
49
  head: { appendChild: function(){} }
50
50
  };
51
51
  }
52
+ // --- Suppress Node.js --localstorage-file warning from Trust SDK WASM ---
53
+ var _origEmit = process.emitWarning;
54
+ process.emitWarning = function(warning) {
55
+ if (typeof warning === 'string' && warning.indexOf('--localstorage-file') !== -1) return;
56
+ return _origEmit.apply(process, arguments);
57
+ };
58
+
52
59
  if (typeof globalThis.window === 'undefined') globalThis.window = globalThis;
53
60
  if (typeof globalThis.self === 'undefined') globalThis.self = globalThis;
54
61
  if (typeof globalThis.navigator === 'undefined') globalThis.navigator = { onLine: true, userAgent: 'Mozilla/5.0 (twak)' };
@@ -124,7 +131,13 @@ function loadKeytar() {
124
131
  return null;
125
132
  }
126
133
  }
127
- var fs, path, os, crypto, crypto2, __require, FileStore, ALGORITHM, KEY_LENGTH, IV_LENGTH, SALT_LENGTH, ITERATIONS, SERVICE, WALLET_ACCOUNT, API_SECRET_ACCOUNT, KeychainManager, CREDENTIALS_FILE, CredentialManager, WALLET_FILE, WalletConfigStore, ALERTS_FILE, AlertStore, SEEN_HASHES_FILE, SeenHashStore;
134
+ function getBackend() {
135
+ const keytar = loadKeytar();
136
+ if (keytar) return keytar;
137
+ if (macSecurity.isAvailable()) return macSecurity;
138
+ return null;
139
+ }
140
+ var fs, path, os, crypto, import_child_process, import_os, crypto2, __require, FileStore, ALGORITHM, KEY_LENGTH, IV_LENGTH, SALT_LENGTH, ITERATIONS, SERVICE, WALLET_ACCOUNT, API_SECRET_ACCOUNT, macSecurity, KeychainManager, CREDENTIALS_FILE, CredentialManager, WALLET_FILE, WalletConfigStore, ALERTS_FILE, AlertStore, SEEN_HASHES_FILE, SeenHashStore;
128
141
  var init_dist = __esm({
129
142
  "../storage/dist/index.mjs"() {
130
143
  "use strict";
@@ -132,6 +145,8 @@ var init_dist = __esm({
132
145
  path = __toESM(require("path"), 1);
133
146
  os = __toESM(require("os"), 1);
134
147
  crypto = __toESM(require("crypto"), 1);
148
+ import_child_process = require("child_process");
149
+ import_os = require("os");
135
150
  crypto2 = __toESM(require("crypto"), 1);
136
151
  __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
137
152
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -189,50 +204,84 @@ var init_dist = __esm({
189
204
  SERVICE = "twak";
190
205
  WALLET_ACCOUNT = "wallet";
191
206
  API_SECRET_ACCOUNT = "api-secret";
207
+ macSecurity = {
208
+ isAvailable() {
209
+ return (0, import_os.platform)() === "darwin";
210
+ },
211
+ getPassword(service, account) {
212
+ try {
213
+ const output2 = (0, import_child_process.execFileSync)(
214
+ "security",
215
+ ["find-generic-password", "-s", service, "-a", account, "-w"],
216
+ { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
217
+ );
218
+ return output2.replace(/\r?\n$/, "");
219
+ } catch {
220
+ return null;
221
+ }
222
+ },
223
+ setPassword(service, account, password) {
224
+ (0, import_child_process.execFileSync)(
225
+ "security",
226
+ ["add-generic-password", "-U", "-s", service, "-a", account, "-w"],
227
+ { input: password + "\n", stdio: ["pipe", "pipe", "pipe"] }
228
+ );
229
+ },
230
+ deletePassword(service, account) {
231
+ try {
232
+ (0, import_child_process.execFileSync)(
233
+ "security",
234
+ ["delete-generic-password", "-s", service, "-a", account],
235
+ { stdio: ["pipe", "pipe", "pipe"] }
236
+ );
237
+ } catch {
238
+ }
239
+ }
240
+ };
192
241
  KeychainManager = class {
193
242
  async getWalletPassword() {
194
- const keytar = loadKeytar();
195
- if (!keytar) return null;
243
+ const backend = getBackend();
244
+ if (!backend) return null;
196
245
  try {
197
- return await keytar.getPassword(SERVICE, WALLET_ACCOUNT);
246
+ return await backend.getPassword(SERVICE, WALLET_ACCOUNT);
198
247
  } catch {
199
248
  return null;
200
249
  }
201
250
  }
202
251
  async saveWalletPassword(password) {
203
- const keytar = loadKeytar();
204
- if (!keytar) throw new Error("keytar native module not available on this system");
205
- await keytar.setPassword(SERVICE, WALLET_ACCOUNT, password);
252
+ const backend = getBackend();
253
+ if (!backend) throw new Error("No keychain backend available (keytar not installed and not on macOS)");
254
+ await backend.setPassword(SERVICE, WALLET_ACCOUNT, password);
206
255
  }
207
256
  async deleteWalletPassword() {
208
- const keytar = loadKeytar();
209
- if (!keytar) throw new Error("keytar native module not available on this system");
210
- await keytar.deletePassword(SERVICE, WALLET_ACCOUNT);
257
+ const backend = getBackend();
258
+ if (!backend) throw new Error("No keychain backend available (keytar not installed and not on macOS)");
259
+ await backend.deletePassword(SERVICE, WALLET_ACCOUNT);
211
260
  }
212
261
  async getApiSecret() {
213
- const keytar = loadKeytar();
214
- if (!keytar) return null;
262
+ const backend = getBackend();
263
+ if (!backend) return null;
215
264
  try {
216
- return await keytar.getPassword(SERVICE, API_SECRET_ACCOUNT);
265
+ return await backend.getPassword(SERVICE, API_SECRET_ACCOUNT);
217
266
  } catch {
218
267
  return null;
219
268
  }
220
269
  }
221
270
  async saveApiSecret(secret) {
222
- const keytar = loadKeytar();
223
- if (!keytar) throw new Error("keytar native module not available on this system");
224
- await keytar.setPassword(SERVICE, API_SECRET_ACCOUNT, secret);
271
+ const backend = getBackend();
272
+ if (!backend) throw new Error("No keychain backend available (keytar not installed and not on macOS)");
273
+ await backend.setPassword(SERVICE, API_SECRET_ACCOUNT, secret);
225
274
  }
226
275
  async deleteApiSecret() {
227
- const keytar = loadKeytar();
228
- if (!keytar) return;
276
+ const backend = getBackend();
277
+ if (!backend) return;
229
278
  try {
230
- await keytar.deletePassword(SERVICE, API_SECRET_ACCOUNT);
279
+ await backend.deletePassword(SERVICE, API_SECRET_ACCOUNT);
231
280
  } catch {
232
281
  }
233
282
  }
234
283
  isAvailable() {
235
- return loadKeytar() !== null;
284
+ return getBackend() !== null;
236
285
  }
237
286
  };
238
287
  CREDENTIALS_FILE = "credentials.json";
@@ -12128,59 +12177,9 @@ function info(message) {
12128
12177
  console.log(import_chalk.default.cyan(message));
12129
12178
  }
12130
12179
 
12131
- // src/branding.ts
12132
- var import_chalk2 = __toESM(require("chalk"));
12133
- var boxen = require("boxen");
12134
- var SHIELD = [
12135
- " @@=+ ",
12136
- " @@@@@@@======= ",
12137
- " @@@@@@@@@@@@@============+ ",
12138
- " @@@@@@@@@@@@@@@@================ ",
12139
- " @@@@@@@@@@@@@@@@+=============== ",
12140
- " @@@@@@@@@@@@@@@@++++============ ",
12141
- " @@@@@@@@@@@@@@@@++++++++++=====+ ",
12142
- " @@@@@@@@@@@@@@@@**++++++++++++++ ",
12143
- " @@@@@@@@@@@@@@@@********++++++++ ",
12144
- " @@@@@@@@@@@@@@@@**************++ ",
12145
- " @@@@@@@@@@@@@@@@#####*********** ",
12146
- " @@@@@@@@@@@@@@@###########**** ",
12147
- " @@@@@@@@@@@@@@%############## ",
12148
- " @@@@@@@@@@@@@@%%%%%%%####### ",
12149
- " @@@@@@@@@@@@@%%%%%%%%%%%%% ",
12150
- " @@@@@@@@@@@%%%%%%%%%%% ",
12151
- " @@@@@@@@@@@@@%%%%% ",
12152
- " @@@@@@@@@@@@@@ ",
12153
- " @@@@@@@@@@ ",
12154
- " @@ "
12155
- ];
12156
- function printBanner(version2) {
12157
- const logo = SHIELD.map((l) => import_chalk2.default.green(l)).join("\n");
12158
- const title = import_chalk2.default.green.bold(" Trust Wallet Agent Kit");
12159
- const ver = import_chalk2.default.dim(` v${version2}`);
12160
- console.log(
12161
- boxen(`${logo}
12162
-
12163
- ${title}
12164
- ${ver}`, {
12165
- borderColor: "green",
12166
- borderStyle: "round",
12167
- padding: { top: 1, bottom: 1, left: 2, right: 2 }
12168
- })
12169
- );
12170
- }
12171
- function box(content) {
12172
- return boxen(content, {
12173
- borderColor: "green",
12174
- borderStyle: "round",
12175
- padding: { top: 0, bottom: 0, left: 1, right: 1 }
12176
- });
12177
- }
12178
-
12179
12180
  // src/commands/init.ts
12180
12181
  function registerInitCommand(program2) {
12181
12182
  program2.command("init").description("Initialize twak configuration").option("--api-key <key>", "TWAK API access ID (prefer TWAK_ACCESS_ID env var)").option("--api-secret <secret>", "TWAK HMAC secret (prefer TWAK_HMAC_SECRET env var)").option("--wc-project-id <id>", "WalletConnect project ID").action(async (opts) => {
12182
- printBanner(program2.version() ?? "0.2.0");
12183
- console.log("");
12184
12183
  const credManager = new CredentialManager();
12185
12184
  if (opts.apiKey && opts.apiSecret) {
12186
12185
  warn("Secrets passed as CLI arguments are visible in shell history.");
@@ -12192,6 +12191,7 @@ function registerInitCommand(program2) {
12192
12191
  walletConnectProjectId: opts.wcProjectId
12193
12192
  });
12194
12193
  success("Credentials saved to ~/.twak/credentials.json");
12194
+ info("\nNext step: create a wallet with `twak wallet create --password <pw>`");
12195
12195
  return;
12196
12196
  }
12197
12197
  const envAccessId = process.env.TWAK_ACCESS_ID;
@@ -12204,6 +12204,7 @@ function registerInitCommand(program2) {
12204
12204
  walletConnectProjectId: envWcId
12205
12205
  });
12206
12206
  success("Credentials saved from environment variables to ~/.twak/credentials.json");
12207
+ info("\nNext step: create a wallet with `twak wallet create --password <pw>`");
12207
12208
  return;
12208
12209
  }
12209
12210
  const existing = await credManager.load();
@@ -12225,6 +12226,7 @@ function registerInitCommand(program2) {
12225
12226
  }
12226
12227
 
12227
12228
  // src/commands/auth.ts
12229
+ var import_chalk2 = __toESM(require("chalk"));
12228
12230
  init_dist();
12229
12231
  function registerAuthCommand(program2) {
12230
12232
  const auth = program2.command("auth").description("Manage authentication");
@@ -12241,12 +12243,17 @@ function registerAuthCommand(program2) {
12241
12243
  const credManager = new CredentialManager();
12242
12244
  const creds = await credManager.load();
12243
12245
  const envConfigured = !!(process.env.TWAK_ACCESS_ID && process.env.TWAK_HMAC_SECRET);
12244
- const result = {
12245
- configured: !!creds || envConfigured,
12246
- source: creds ? "file" : envConfigured ? "environment" : "none",
12247
- accessId: creds?.accessId?.slice(0, 8) || process.env.TWAK_ACCESS_ID?.slice(0, 8) || null
12248
- };
12249
- output(result, opts.json);
12246
+ const configured = !!creds || envConfigured;
12247
+ const source = creds ? "file" : envConfigured ? "environment" : "none";
12248
+ const accessId = creds?.accessId?.slice(0, 8) || process.env.TWAK_ACCESS_ID?.slice(0, 8) || null;
12249
+ if (opts.json) {
12250
+ output({ configured, source, accessId }, true);
12251
+ } else {
12252
+ console.log(` ${import_chalk2.default.dim("Status")} ${configured ? import_chalk2.default.green("configured") : import_chalk2.default.yellow("not configured")}`);
12253
+ console.log(` ${import_chalk2.default.dim("Source")} ${source}`);
12254
+ if (accessId) console.log(` ${import_chalk2.default.dim("Access ID")} ${accessId}...`);
12255
+ if (!configured) info("\nRun `twak init` to set up credentials.");
12256
+ }
12250
12257
  });
12251
12258
  }
12252
12259
 
@@ -12258,7 +12265,7 @@ init_dist3();
12258
12265
 
12259
12266
  // src/commands/wallet.ts
12260
12267
  init_dist();
12261
- var import_chalk4 = __toESM(require("chalk"));
12268
+ var import_chalk5 = __toESM(require("chalk"));
12262
12269
 
12263
12270
  // src/config-loader.ts
12264
12271
  var import_chalk3 = __toESM(require("chalk"));
@@ -12326,6 +12333,56 @@ async function resolvePassword(opts) {
12326
12333
 
12327
12334
  // src/commands/wallet.ts
12328
12335
  init_dist2();
12336
+
12337
+ // src/branding.ts
12338
+ var import_chalk4 = __toESM(require("chalk"));
12339
+ var boxen = require("boxen");
12340
+ var SHIELD = [
12341
+ " @@=+ ",
12342
+ " @@@@@@@======= ",
12343
+ " @@@@@@@@@@@@@============+ ",
12344
+ " @@@@@@@@@@@@@@@@================ ",
12345
+ " @@@@@@@@@@@@@@@@+=============== ",
12346
+ " @@@@@@@@@@@@@@@@++++============ ",
12347
+ " @@@@@@@@@@@@@@@@++++++++++=====+ ",
12348
+ " @@@@@@@@@@@@@@@@**++++++++++++++ ",
12349
+ " @@@@@@@@@@@@@@@@********++++++++ ",
12350
+ " @@@@@@@@@@@@@@@@**************++ ",
12351
+ " @@@@@@@@@@@@@@@@#####*********** ",
12352
+ " @@@@@@@@@@@@@@@###########**** ",
12353
+ " @@@@@@@@@@@@@@%############## ",
12354
+ " @@@@@@@@@@@@@@%%%%%%%####### ",
12355
+ " @@@@@@@@@@@@@%%%%%%%%%%%%% ",
12356
+ " @@@@@@@@@@@%%%%%%%%%%% ",
12357
+ " @@@@@@@@@@@@@%%%%% ",
12358
+ " @@@@@@@@@@@@@@ ",
12359
+ " @@@@@@@@@@ ",
12360
+ " @@ "
12361
+ ];
12362
+ function printBanner(version2) {
12363
+ const logo = SHIELD.map((l) => import_chalk4.default.green(l)).join("\n");
12364
+ const title = import_chalk4.default.green.bold(" Trust Wallet Agent Kit");
12365
+ const ver = import_chalk4.default.dim(` v${version2}`);
12366
+ console.log(
12367
+ boxen(`${logo}
12368
+
12369
+ ${title}
12370
+ ${ver}`, {
12371
+ borderColor: "green",
12372
+ borderStyle: "round",
12373
+ padding: { top: 1, bottom: 1, left: 2, right: 2 }
12374
+ })
12375
+ );
12376
+ }
12377
+ function box(content) {
12378
+ return boxen(content, {
12379
+ borderColor: "green",
12380
+ borderStyle: "round",
12381
+ padding: { top: 0, bottom: 0, left: 1, right: 1 }
12382
+ });
12383
+ }
12384
+
12385
+ // src/commands/wallet.ts
12329
12386
  var qrcode = require("qrcode-terminal");
12330
12387
  function getQRString(address) {
12331
12388
  let result = "";
@@ -12341,7 +12398,7 @@ function registerWalletCommand(program2) {
12341
12398
  await ensureTrustSDK();
12342
12399
  const store = new WalletConfigStore();
12343
12400
  if (await store.exists()) {
12344
- const msg = "Wallet already exists. Use `twak wallet export` to back up, then delete ~/.twak/wallet.json to create a new one.";
12401
+ const msg = "Wallet already exists. Back up ~/.twak/wallet.json, then delete it to create a new one.";
12345
12402
  error(msg);
12346
12403
  if (opts.json) output({ error: msg }, true);
12347
12404
  process.exitCode = 1;
@@ -12350,7 +12407,6 @@ function registerWalletCommand(program2) {
12350
12407
  }
12351
12408
  const provider = await AgentWalletProvider.create(opts.password);
12352
12409
  const addresses = await provider.getAddresses();
12353
- if (!opts.json) success("Agent wallet created successfully");
12354
12410
  if (opts.keychain !== false) {
12355
12411
  const kc = new KeychainManager();
12356
12412
  if (kc.isAvailable()) {
@@ -12358,6 +12414,7 @@ function registerWalletCommand(program2) {
12358
12414
  if (!opts.json) info("Password saved to OS keychain (use --no-keychain to skip)");
12359
12415
  }
12360
12416
  }
12417
+ if (!opts.json) success("Agent wallet created successfully");
12361
12418
  try {
12362
12419
  const creds = await getCredentials();
12363
12420
  await registerWalletWithBackend(creds, provider);
@@ -12388,8 +12445,8 @@ function registerWalletCommand(program2) {
12388
12445
  output({ chain: opts.chain, address }, true);
12389
12446
  } else {
12390
12447
  const qr = getQRString(address);
12391
- const content = `${import_chalk4.default.dim("Chain")} ${import_chalk4.default.bold(opts.chain)}
12392
- ${import_chalk4.default.dim("Address")} ${import_chalk4.default.green(address)}
12448
+ const content = `${import_chalk5.default.dim("Chain")} ${import_chalk5.default.bold(opts.chain)}
12449
+ ${import_chalk5.default.dim("Address")} ${import_chalk5.default.green(address)}
12393
12450
 
12394
12451
  ${qr}`;
12395
12452
  console.log(box(content));
@@ -12420,7 +12477,7 @@ ${qr}`;
12420
12477
  for (const [address, chains] of grouped) {
12421
12478
  const qr = getQRString(address);
12422
12479
  const maxWidth = Math.max(address.length + 9, 50);
12423
- const chainLabel = `${import_chalk4.default.dim("Chains")} `;
12480
+ const chainLabel = `${import_chalk5.default.dim("Chains")} `;
12424
12481
  const chainLabelLen = 9;
12425
12482
  const chainLines = [];
12426
12483
  let line = "";
@@ -12434,9 +12491,9 @@ ${qr}`;
12434
12491
  }
12435
12492
  }
12436
12493
  if (line) chainLines.push(line);
12437
- const chainsStr = chainLines.map((l, i) => (i === 0 ? chainLabel : " ".repeat(chainLabelLen)) + import_chalk4.default.bold(l)).join("\n");
12494
+ const chainsStr = chainLines.map((l, i) => (i === 0 ? chainLabel : " ".repeat(chainLabelLen)) + import_chalk5.default.bold(l)).join("\n");
12438
12495
  const content = `${chainsStr}
12439
- ${import_chalk4.default.dim("Address")} ${import_chalk4.default.green(address)}
12496
+ ${import_chalk5.default.dim("Address")} ${import_chalk5.default.green(address)}
12440
12497
 
12441
12498
  ${qr}`;
12442
12499
  console.log(box(content));
@@ -12610,17 +12667,17 @@ ${qr}`;
12610
12667
  for (let i = 0; i < results.length; i++) {
12611
12668
  const r = results[i];
12612
12669
  if (i > 0) console.log("");
12613
- console.log(import_chalk4.default.bold.underline(`${String(r.chain)} (${String(r.symbol)})`));
12614
- console.log(` ${import_chalk4.default.dim("Address")} ${r.address}`);
12615
- console.log(` ${import_chalk4.default.dim("Available")} ${r.available}`);
12616
- if (r.staked) console.log(` ${import_chalk4.default.dim("Staked")} ${r.staked}`);
12617
- if (r.pending) console.log(` ${import_chalk4.default.dim("Pending")} ${r.pending}`);
12618
- console.log(` ${import_chalk4.default.dim("Total")} ${r.total}`);
12670
+ console.log(import_chalk5.default.bold.underline(`${String(r.chain)} (${String(r.symbol)})`));
12671
+ console.log(` ${import_chalk5.default.dim("Address")} ${r.address}`);
12672
+ console.log(` ${import_chalk5.default.dim("Available")} ${r.available}`);
12673
+ if (r.staked) console.log(` ${import_chalk5.default.dim("Staked")} ${r.staked}`);
12674
+ if (r.pending) console.log(` ${import_chalk5.default.dim("Pending")} ${r.pending}`);
12675
+ console.log(` ${import_chalk5.default.dim("Total")} ${r.total}`);
12619
12676
  const tokens = r.tokens;
12620
12677
  if (tokens.length > 0) {
12621
- console.log(` ${import_chalk4.default.dim("Tokens:")}`);
12678
+ console.log(` ${import_chalk5.default.dim("Tokens:")}`);
12622
12679
  for (const t of tokens) {
12623
- console.log(` ${import_chalk4.default.bold(t.symbol.padEnd(10))} ${t.balance}`);
12680
+ console.log(` ${import_chalk5.default.bold(t.symbol.padEnd(10))} ${t.balance}`);
12624
12681
  }
12625
12682
  }
12626
12683
  }
@@ -12646,20 +12703,16 @@ ${qr}`;
12646
12703
  if (opts.json) {
12647
12704
  output(result, true);
12648
12705
  } else {
12649
- output({
12650
- chain: result.chain,
12651
- address: result.address,
12652
- symbol: result.symbol,
12653
- available: result.available,
12654
- ...result.staked ? { staked: result.staked } : {},
12655
- ...result.pending ? { pending: result.pending } : {},
12656
- total: result.total
12657
- }, false);
12706
+ console.log(import_chalk5.default.bold.underline(`${result.chain} (${result.symbol})`));
12707
+ console.log(` ${import_chalk5.default.dim("Address")} ${result.address}`);
12708
+ console.log(` ${import_chalk5.default.dim("Available")} ${result.available}`);
12709
+ if (result.staked) console.log(` ${import_chalk5.default.dim("Staked")} ${result.staked}`);
12710
+ if (result.pending) console.log(` ${import_chalk5.default.dim("Pending")} ${result.pending}`);
12711
+ console.log(` ${import_chalk5.default.dim("Total")} ${result.total}`);
12658
12712
  if (result.tokens.length > 0) {
12659
- console.log("");
12660
- info("Token balances:");
12713
+ console.log(` ${import_chalk5.default.dim("Tokens:")}`);
12661
12714
  for (const t of result.tokens) {
12662
- console.log(` ${import_chalk4.default.bold(t.symbol.padEnd(10))} ${t.balance}`);
12715
+ console.log(` ${import_chalk5.default.bold(t.symbol.padEnd(10))} ${t.balance}`);
12663
12716
  }
12664
12717
  }
12665
12718
  }
@@ -12714,10 +12767,17 @@ ${qr}`;
12714
12767
  const exists = await store.exists();
12715
12768
  const kc = new KeychainManager();
12716
12769
  const keychainHasPassword = kc.isAvailable() ? !!await kc.getWalletPassword() : false;
12717
- output({
12770
+ const result = {
12718
12771
  agentWallet: exists ? "configured" : "not configured",
12719
12772
  keychainPassword: keychainHasPassword ? "stored" : "not stored"
12720
- }, opts.json);
12773
+ };
12774
+ if (opts.json) {
12775
+ output(result, true);
12776
+ } else {
12777
+ console.log(` ${import_chalk5.default.dim("Wallet")} ${exists ? import_chalk5.default.green("configured") : import_chalk5.default.yellow("not configured")}`);
12778
+ console.log(` ${import_chalk5.default.dim("Keychain")} ${keychainHasPassword ? import_chalk5.default.green("password stored") : import_chalk5.default.yellow("no password")}`);
12779
+ if (!exists) info("\nRun `twak wallet create --password <pw>` to create a wallet.");
12780
+ }
12721
12781
  });
12722
12782
  wallet.command("portfolio").description("Show portfolio balances and USD values across chains, including token holdings").option("--chains <list>", "Comma-separated chain keys (default: all EVM + major L1s)", "ethereum,base,bsc,polygon,arbitrum,optimism,avalanche,fantom,linea,scroll,zksync,blast,sonic,celo,aurora,solana,tron").option("--password <password>", "Wallet password (falls back to keychain / TWAK_WALLET_PASSWORD)").option("--json", "JSON output").action(async (opts) => {
12723
12783
  try {
@@ -13706,9 +13766,11 @@ var TransactionService = class {
13706
13766
  // src/commands/query.ts
13707
13767
  init_dist5();
13708
13768
  init_dist4();
13769
+ var import_chalk6 = __toESM(require("chalk"));
13709
13770
  function handleError(err, json) {
13710
13771
  const msg = err instanceof Error ? err.message : String(err);
13711
- error(msg);
13772
+ const hint = msg.includes("403 Forbidden") ? " \u2014 check your API key at https://portal.trustwallet.com" : "";
13773
+ error(`${msg}${hint}`);
13712
13774
  if (json) output({ error: msg }, true);
13713
13775
  process.exitCode = 1;
13714
13776
  }
@@ -13745,7 +13807,14 @@ function registerQueryCommand(program2) {
13745
13807
  chain: m.chain,
13746
13808
  priceUsd: priceMap.get(assetIds[i]) ?? null
13747
13809
  }));
13748
- output(results, opts.json);
13810
+ if (opts.json) {
13811
+ output(results, true);
13812
+ } else {
13813
+ for (const r of results) {
13814
+ const priceStr = r.priceUsd !== null ? `$${r.priceUsd.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}` : "N/A";
13815
+ console.log(`${import_chalk6.default.bold(r.token.padEnd(10))} ${priceStr.padStart(14)} ${import_chalk6.default.dim(r.chain)}`);
13816
+ }
13817
+ }
13749
13818
  return;
13750
13819
  }
13751
13820
  const chain = resolveChain(token);
@@ -13770,7 +13839,12 @@ function registerQueryCommand(program2) {
13770
13839
  output({ token: token.toUpperCase(), chain, priceUsd: price, history: chartData.prices }, opts.json);
13771
13840
  return;
13772
13841
  }
13773
- output({ token: token.toUpperCase(), chain, priceUsd: price }, opts.json);
13842
+ if (opts.json) {
13843
+ output({ token: token.toUpperCase(), chain, priceUsd: price }, true);
13844
+ } else {
13845
+ const priceStr = price !== null ? `$${price.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}` : "N/A";
13846
+ console.log(`${import_chalk6.default.bold(token.toUpperCase())} ${priceStr} ${import_chalk6.default.dim(chain)}`);
13847
+ }
13774
13848
  } catch (err) {
13775
13849
  handleError(err, opts.json);
13776
13850
  }
@@ -13779,7 +13853,7 @@ function registerQueryCommand(program2) {
13779
13853
  try {
13780
13854
  const client = await getClient();
13781
13855
  const swapClient = new SwapClient(client);
13782
- const result = await swapClient.searchTokens({ query, limit: parseInt(opts.limit) });
13856
+ const result = await swapClient.searchTokens({ query, limit: parseInt(opts.limit, 10) });
13783
13857
  output(result, opts.json);
13784
13858
  } catch (err) {
13785
13859
  handleError(err, opts.json);
@@ -13803,7 +13877,14 @@ function registerQueryCommand(program2) {
13803
13877
  from: opts.from,
13804
13878
  to: opts.to
13805
13879
  });
13806
- output(result2.slice(0, parseInt(opts.limit)), opts.json);
13880
+ const sliced = result2.slice(0, parseInt(opts.limit, 10));
13881
+ if (opts.json) {
13882
+ output(sliced, true);
13883
+ } else if (sliced.length === 0) {
13884
+ info("No transactions found.");
13885
+ } else {
13886
+ output(sliced, false);
13887
+ }
13807
13888
  return;
13808
13889
  }
13809
13890
  let address = opts.address;
@@ -13818,7 +13899,7 @@ function registerQueryCommand(program2) {
13818
13899
  chain: opts.chain,
13819
13900
  from: opts.from,
13820
13901
  to: opts.to,
13821
- limit: parseInt(opts.limit)
13902
+ limit: parseInt(opts.limit, 10)
13822
13903
  });
13823
13904
  if (result.length > 0) {
13824
13905
  const chain = getChainById(opts.chain);
@@ -13843,7 +13924,13 @@ function registerQueryCommand(program2) {
13843
13924
  return;
13844
13925
  }
13845
13926
  }
13846
- output(result, opts.json);
13927
+ if (opts.json) {
13928
+ output(result, true);
13929
+ } else if (result.length === 0) {
13930
+ info("No transactions found.");
13931
+ } else {
13932
+ output(result, false);
13933
+ }
13847
13934
  } catch (err) {
13848
13935
  handleError(err, opts.json);
13849
13936
  }
@@ -13859,12 +13946,13 @@ function registerQueryCommand(program2) {
13859
13946
  }
13860
13947
  });
13861
13948
  program2.command("chains").description("List supported chains").option("--json", "JSON output").action(async (opts) => {
13862
- const chains = getSupportedChains();
13949
+ const chainEntries = Object.entries(CHAINS);
13863
13950
  if (opts.json) {
13864
- output(chains, true);
13951
+ output(chainEntries.map(([key, chain]) => ({ key, ...chain })), true);
13865
13952
  } else {
13866
- for (const chain of chains) {
13867
- console.log(`${chain.id.padEnd(15)} ${chain.name.padEnd(25)} coinId:${chain.coinId}`);
13953
+ for (const [key, chain] of chainEntries) {
13954
+ const idHint = key !== chain.id ? import_chalk6.default.dim(` (${chain.id})`) : "";
13955
+ console.log(`${key.padEnd(15)} ${chain.name.padEnd(25)} coinId:${chain.coinId}${idHint}`);
13868
13956
  }
13869
13957
  }
13870
13958
  });
@@ -13974,9 +14062,9 @@ function registerQueryCommand(program2) {
13974
14062
  if (opts.category) {
13975
14063
  const categoryId = categoryMap[opts.category] ?? opts.category;
13976
14064
  const sort = opts.sort ? sortMap[opts.sort] ?? opts.sort : "percent_change_24h";
13977
- tokens = await service.getAssetListings({ categoryId, sort, limit: parseInt(opts.limit) });
14065
+ tokens = await service.getAssetListings({ categoryId, sort, limit: parseInt(opts.limit, 10) });
13978
14066
  } else {
13979
- tokens = await service.getTrendingTokens(parseInt(opts.limit));
14067
+ tokens = await service.getTrendingTokens(parseInt(opts.limit, 10));
13980
14068
  }
13981
14069
  const seen = /* @__PURE__ */ new Map();
13982
14070
  for (const t of tokens) {
@@ -14013,7 +14101,7 @@ function registerQueryCommand(program2) {
14013
14101
  }
14014
14102
  return;
14015
14103
  }
14016
- const dapps = opts.search ? await service.search(opts.search, parseInt(opts.limit)) : await service.getTop(parseInt(opts.limit), opts.category);
14104
+ const dapps = opts.search ? await service.search(opts.search, parseInt(opts.limit, 10)) : await service.getTop(parseInt(opts.limit, 10), opts.category);
14017
14105
  if (opts.json) {
14018
14106
  output(dapps, true);
14019
14107
  } else {
@@ -27838,7 +27926,7 @@ function registerServeCommand(program2) {
27838
27926
  // src/commands/skill.ts
27839
27927
  var import_fs = require("fs");
27840
27928
  var import_path = require("path");
27841
- var import_os = require("os");
27929
+ var import_os2 = require("os");
27842
27930
  var SKILL_ID = "twak";
27843
27931
  var SKILL_NAME = "TWAK \u2014 Trust Wallet Agent Kit";
27844
27932
  function findSkillMd() {
@@ -27862,10 +27950,10 @@ function registerSkillCommand(program2) {
27862
27950
  process.exitCode = 1;
27863
27951
  return;
27864
27952
  }
27865
- const skillsDir = opts.dir ? (0, import_path.resolve)(opts.dir) : (0, import_path.join)((0, import_os.homedir)(), ".claude", "skills");
27953
+ const skillsDir = opts.dir ? (0, import_path.resolve)(opts.dir) : (0, import_path.join)((0, import_os2.homedir)(), ".claude", "skills");
27866
27954
  if (opts.dir) {
27867
27955
  const { relative, sep: sep2 } = await import("path");
27868
- const safeBase = (0, import_path.join)((0, import_os.homedir)(), ".claude");
27956
+ const safeBase = (0, import_path.join)((0, import_os2.homedir)(), ".claude");
27869
27957
  const rel = relative(safeBase, skillsDir);
27870
27958
  const isOutside = rel.startsWith("..") || rel.startsWith(sep2) || (0, import_path.resolve)(opts.dir) === (0, import_path.resolve)("/");
27871
27959
  if (isOutside) {
@@ -28057,7 +28145,7 @@ var crypto3 = __toESM(require("crypto"));
28057
28145
  // package.json
28058
28146
  var package_default = {
28059
28147
  name: "@trustwallet/cli",
28060
- version: "0.6.2",
28148
+ version: "0.6.4",
28061
28149
  description: "TWAK CLI \u2014 command-line interface for Trust Wallet Agent Kit",
28062
28150
  main: "dist/index.js",
28063
28151
  types: "dist/index.d.ts",
@@ -28217,7 +28305,7 @@ function registerTelemetryCommand(program2) {
28217
28305
  // src/index.ts
28218
28306
  var VERSION2 = package_default.version;
28219
28307
  var program = new import_commander.Command();
28220
- program.name("twak").description("Trust Wallet Agent \u2014 AI-powered multichain wallet SDK").version(VERSION2).option("--no-analytics", "Disable telemetry for this invocation").addHelpText("beforeAll", () => {
28308
+ program.name("twak").description("Trust Wallet Agent \u2014 AI-powered multichain wallet SDK").version(VERSION2).option("--no-analytics", "Disable telemetry for this invocation").addHelpText("before", () => {
28221
28309
  printBanner(VERSION2);
28222
28310
  return "";
28223
28311
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustwallet/cli",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "TWAK CLI — command-line interface for Trust Wallet Agent Kit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,17 +27,17 @@
27
27
  "devDependencies": {
28
28
  "tsup": "8.5.1",
29
29
  "typescript": "5.7.3",
30
- "@twak/actions": "0.6.2",
31
- "@twak/blockchain": "0.6.2",
32
- "@twak/core": "0.6.2",
33
- "@twak/mcp": "0.6.2",
34
- "@twak/storage": "0.6.2",
35
- "@twak/swap": "0.6.2",
36
- "@twak/wallet": "0.6.2",
37
- "@twak/wallet-core": "0.6.2",
38
- "@twak/walletconnect": "0.6.2",
39
- "@twak/transactions": "0.6.2",
40
- "@twak/security": "0.6.2"
30
+ "@twak/core": "0.6.4",
31
+ "@twak/mcp": "0.6.4",
32
+ "@twak/security": "0.6.4",
33
+ "@twak/blockchain": "0.6.4",
34
+ "@twak/storage": "0.6.4",
35
+ "@twak/actions": "0.6.4",
36
+ "@twak/swap": "0.6.4",
37
+ "@twak/transactions": "0.6.4",
38
+ "@twak/wallet": "0.6.4",
39
+ "@twak/wallet-core": "0.6.4",
40
+ "@twak/walletconnect": "0.6.4"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -48,6 +48,13 @@
48
48
  head: { appendChild: function(){} }
49
49
  };
50
50
  }
51
+ // --- Suppress Node.js --localstorage-file warning from Trust SDK WASM ---
52
+ var _origEmit = process.emitWarning;
53
+ process.emitWarning = function(warning) {
54
+ if (typeof warning === 'string' && warning.indexOf('--localstorage-file') !== -1) return;
55
+ return _origEmit.apply(process, arguments);
56
+ };
57
+
51
58
  if (typeof globalThis.window === 'undefined') globalThis.window = globalThis;
52
59
  if (typeof globalThis.self === 'undefined') globalThis.self = globalThis;
53
60
  if (typeof globalThis.navigator === 'undefined') globalThis.navigator = { onLine: true, userAgent: 'Mozilla/5.0 (twak)' };