@trustwallet/cli 0.6.9 → 0.6.10
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/query.d.ts.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/index.js +63 -13
- package/package.json +12 -12
|
@@ -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;AAmBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
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,CAskB3D"}
|
|
@@ -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;AA4BpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/commands/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4BpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgtB5D"}
|
package/dist/index.js
CHANGED
|
@@ -12616,7 +12616,17 @@ var init_dist5 = __esm({
|
|
|
12616
12616
|
} catch (err) {
|
|
12617
12617
|
const msg = err instanceof Error ? err.message : String(err);
|
|
12618
12618
|
const details = err?.details;
|
|
12619
|
-
|
|
12619
|
+
let detailsStr = "";
|
|
12620
|
+
if (details != null) {
|
|
12621
|
+
try {
|
|
12622
|
+
detailsStr = JSON.stringify(details);
|
|
12623
|
+
} catch {
|
|
12624
|
+
try {
|
|
12625
|
+
detailsStr = String(details);
|
|
12626
|
+
} catch {
|
|
12627
|
+
}
|
|
12628
|
+
}
|
|
12629
|
+
}
|
|
12620
12630
|
if (msg.includes("GraphQL") || msg.includes("Failed to decode") || detailsStr.includes("GraphQL") || detailsStr.includes("Failed to decode")) {
|
|
12621
12631
|
return { valid: false, message: "Invalid address format" };
|
|
12622
12632
|
}
|
|
@@ -38907,6 +38917,7 @@ ${qr3}`;
|
|
|
38907
38917
|
const result = {
|
|
38908
38918
|
agentWallet: exists ? "configured" : "not configured",
|
|
38909
38919
|
keychainPassword: keychainHasPassword ? "stored" : "not stored",
|
|
38920
|
+
chains: totalChains,
|
|
38910
38921
|
supportedChains: totalChains,
|
|
38911
38922
|
...createdAt ? { createdAt } : {},
|
|
38912
38923
|
...addressCount !== void 0 ? { addressCount } : {}
|
|
@@ -39902,7 +39913,7 @@ function handleError(err, json) {
|
|
|
39902
39913
|
process.exitCode = 1;
|
|
39903
39914
|
}
|
|
39904
39915
|
function registerQueryCommand(program3) {
|
|
39905
|
-
program3.command("price <token>").description("Get token price").option("--chain <id>", "Chain").option("--history
|
|
39916
|
+
program3.command("price <token>").description("Get token price").option("--chain <id>", "Chain").option("--history [period]", "Price history period: hour, day, week, month, year, all (default: week)").option("--json", "JSON output").action(async (token, opts) => {
|
|
39906
39917
|
try {
|
|
39907
39918
|
const client = await getClient();
|
|
39908
39919
|
const swapClient = new SwapClient(client);
|
|
@@ -39968,7 +39979,8 @@ function registerQueryCommand(program3) {
|
|
|
39968
39979
|
process.exitCode = 1;
|
|
39969
39980
|
return;
|
|
39970
39981
|
}
|
|
39971
|
-
if (opts.history) {
|
|
39982
|
+
if (opts.history !== void 0) {
|
|
39983
|
+
const period = typeof opts.history === "string" ? opts.history : "week";
|
|
39972
39984
|
const chainInfo = getChainById(chain2);
|
|
39973
39985
|
if (!chainInfo) throw new Error(`Unknown chain: ${chain2}`);
|
|
39974
39986
|
const isNative = !tokenInfo.address || tokenInfo.address === NATIVE_TOKEN_ADDRESS || tokenInfo.address === SOLANA_NATIVE_ADDRESS;
|
|
@@ -39977,7 +39989,7 @@ function registerQueryCommand(program3) {
|
|
|
39977
39989
|
"GET",
|
|
39978
39990
|
`/v1/market/charts/${assetId}`,
|
|
39979
39991
|
void 0,
|
|
39980
|
-
`currency=USD&period=${
|
|
39992
|
+
`currency=USD&period=${period}`
|
|
39981
39993
|
);
|
|
39982
39994
|
output({ token: token.toUpperCase(), chain: chain2, priceUsd: price, history: chartData.prices }, opts.json);
|
|
39983
39995
|
return;
|
|
@@ -39992,14 +40004,24 @@ function registerQueryCommand(program3) {
|
|
|
39992
40004
|
handleError(err, opts.json);
|
|
39993
40005
|
}
|
|
39994
40006
|
});
|
|
39995
|
-
program3.command("search <query>").description("Search for tokens").option("--networks <
|
|
40007
|
+
program3.command("search <query>").description("Search for tokens").option("--networks <names>", "Comma-separated chain names or coin IDs (e.g., ethereum,bsc)").option("--limit <n>", "Max results", "10").option("--json", "JSON output").action(async (query, opts) => {
|
|
39996
40008
|
try {
|
|
39997
40009
|
const client = await getClient();
|
|
39998
40010
|
const swapClient = new SwapClient(client);
|
|
40011
|
+
let networks;
|
|
40012
|
+
if (opts.networks) {
|
|
40013
|
+
networks = opts.networks.split(",").map((n4) => {
|
|
40014
|
+
const trimmed = n4.trim();
|
|
40015
|
+
if (/^\d+$/.test(trimmed)) return trimmed;
|
|
40016
|
+
const chain2 = getChainById(trimmed);
|
|
40017
|
+
if (chain2) return String(chain2.coinId);
|
|
40018
|
+
throw new Error(`Unknown network "${trimmed}". Use a supported chain name or numeric coin ID.`);
|
|
40019
|
+
}).join(",");
|
|
40020
|
+
}
|
|
39999
40021
|
const result = await swapClient.searchTokens({
|
|
40000
40022
|
query,
|
|
40001
40023
|
limit: parseInt(opts.limit, 10),
|
|
40002
|
-
...
|
|
40024
|
+
...networks ? { networks } : {}
|
|
40003
40025
|
});
|
|
40004
40026
|
output(result, opts.json);
|
|
40005
40027
|
} catch (err) {
|
|
@@ -40126,9 +40148,19 @@ function registerQueryCommand(program3) {
|
|
|
40126
40148
|
}
|
|
40127
40149
|
}
|
|
40128
40150
|
});
|
|
40129
|
-
program3.command("balance").description("Get
|
|
40151
|
+
program3.command("balance").description("Get token balance for an address (native or ERC-20)").requiredOption("--address <address>", "Wallet address").option("--coin <coinId>", "SLIP44 coin ID (for native token)").option("--chain <key>", "Chain key (e.g., ethereum, bsc)").option("--token <address>", "Token contract address (for ERC-20)").option("--json", "JSON output").action(async (opts) => {
|
|
40130
40152
|
try {
|
|
40131
|
-
|
|
40153
|
+
let coinId;
|
|
40154
|
+
if (opts.coin) {
|
|
40155
|
+
coinId = Number(opts.coin);
|
|
40156
|
+
if (!Number.isInteger(coinId)) throw new Error(`Invalid coin ID: ${opts.coin}`);
|
|
40157
|
+
} else if (opts.chain) {
|
|
40158
|
+
const chainInfo = getChainById(opts.chain);
|
|
40159
|
+
if (!chainInfo) throw new Error(`Unknown chain: ${opts.chain}`);
|
|
40160
|
+
coinId = chainInfo.coinId;
|
|
40161
|
+
} else {
|
|
40162
|
+
throw new Error("Provide --coin or --chain");
|
|
40163
|
+
}
|
|
40132
40164
|
const chain2 = getChainByCoinId(coinId);
|
|
40133
40165
|
if (!chain2) throw new Error(`Unknown coin ID: ${coinId}`);
|
|
40134
40166
|
try {
|
|
@@ -40142,17 +40174,35 @@ function registerQueryCommand(program3) {
|
|
|
40142
40174
|
} catch (err) {
|
|
40143
40175
|
if (err instanceof Error && err.message.startsWith("Invalid address")) throw err;
|
|
40144
40176
|
}
|
|
40177
|
+
const assetId = opts.token ? `c${coinId}_t${opts.token}` : `c${coinId}`;
|
|
40145
40178
|
const client = new BlockchainClient();
|
|
40146
|
-
const balance = await client.getBalance(
|
|
40179
|
+
const balance = await client.getBalance(assetId, opts.address);
|
|
40180
|
+
let decimals = chain2.decimals;
|
|
40181
|
+
let symbol = chain2.symbol;
|
|
40182
|
+
if (opts.token) {
|
|
40183
|
+
const apiClient = await getClient();
|
|
40184
|
+
const swapClient = new SwapClient(apiClient);
|
|
40185
|
+
const chainKey = opts.chain || Object.entries(CHAINS).find(([, c3]) => c3.coinId === coinId)?.[0] || "";
|
|
40186
|
+
const tokens = await swapClient.searchTokens({ query: opts.token, chains: [chainKey], limit: 1 });
|
|
40187
|
+
if (tokens.length > 0) {
|
|
40188
|
+
decimals = tokens[0].decimals ?? 18;
|
|
40189
|
+
symbol = tokens[0].symbol ?? opts.token;
|
|
40190
|
+
} else {
|
|
40191
|
+
decimals = 18;
|
|
40192
|
+
symbol = opts.token;
|
|
40193
|
+
}
|
|
40194
|
+
}
|
|
40147
40195
|
const fmt = (raw) => {
|
|
40148
40196
|
const big = BigInt(raw);
|
|
40149
|
-
|
|
40150
|
-
|
|
40197
|
+
if (decimals === 0) return big.toString();
|
|
40198
|
+
const div = 10n ** BigInt(decimals);
|
|
40199
|
+
return `${big / div}.${(big % div).toString().padStart(decimals, "0").slice(0, 6)}`;
|
|
40151
40200
|
};
|
|
40152
40201
|
output({
|
|
40153
40202
|
address: opts.address,
|
|
40154
40203
|
chain: chain2.id,
|
|
40155
|
-
symbol
|
|
40204
|
+
symbol,
|
|
40205
|
+
...opts.token ? { token: opts.token } : {},
|
|
40156
40206
|
available: fmt(balance.available),
|
|
40157
40207
|
...balance.staked ? { staked: fmt(balance.staked) } : {},
|
|
40158
40208
|
...balance.pending ? { pending: fmt(balance.pending) } : {},
|
|
@@ -54352,7 +54402,7 @@ var crypto5 = __toESM(require("crypto"));
|
|
|
54352
54402
|
// package.json
|
|
54353
54403
|
var package_default = {
|
|
54354
54404
|
name: "@trustwallet/cli",
|
|
54355
|
-
version: "0.6.
|
|
54405
|
+
version: "0.6.10",
|
|
54356
54406
|
description: "TWAK CLI \u2014 command-line interface for Trust Wallet Agent Kit",
|
|
54357
54407
|
main: "dist/index.js",
|
|
54358
54408
|
types: "dist/index.d.ts",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trustwallet/cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
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
|
"ora": "5.4.1",
|
|
28
28
|
"tsup": "8.5.1",
|
|
29
29
|
"typescript": "5.7.3",
|
|
30
|
-
"@twak/actions": "0.6.
|
|
31
|
-
"@twak/blockchain": "0.6.
|
|
32
|
-
"@twak/core": "0.6.
|
|
33
|
-
"@twak/mcp": "0.6.
|
|
34
|
-
"@twak/
|
|
35
|
-
"@twak/
|
|
36
|
-
"@twak/
|
|
37
|
-
"@twak/wallet": "0.6.
|
|
38
|
-
"@twak/walletconnect": "0.6.
|
|
39
|
-
"@twak/
|
|
40
|
-
"@twak/
|
|
30
|
+
"@twak/actions": "0.6.10",
|
|
31
|
+
"@twak/blockchain": "0.6.10",
|
|
32
|
+
"@twak/core": "0.6.10",
|
|
33
|
+
"@twak/mcp": "0.6.10",
|
|
34
|
+
"@twak/swap": "0.6.10",
|
|
35
|
+
"@twak/transactions": "0.6.10",
|
|
36
|
+
"@twak/wallet": "0.6.10",
|
|
37
|
+
"@twak/wallet-core": "0.6.10",
|
|
38
|
+
"@twak/walletconnect": "0.6.10",
|
|
39
|
+
"@twak/security": "0.6.10",
|
|
40
|
+
"@twak/storage": "0.6.10"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|