@trustwallet/cli 0.6.8 → 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/alert.d.ts.map +1 -1
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/wallet.d.ts.map +1 -1
- package/dist/index.js +192 -47
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../src/commands/alert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../src/commands/alert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAuI3D"}
|
|
@@ -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
|
@@ -12606,15 +12606,51 @@ var init_dist5 = __esm({
|
|
|
12606
12606
|
query.set("address", params.address);
|
|
12607
12607
|
if (params.type) query.set("type", params.type);
|
|
12608
12608
|
if (params.version) query.set("version", params.version.toString());
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12609
|
+
try {
|
|
12610
|
+
return await this.client.gateway(
|
|
12611
|
+
"GET",
|
|
12612
|
+
"/v1/validate",
|
|
12613
|
+
void 0,
|
|
12614
|
+
query.toString()
|
|
12615
|
+
);
|
|
12616
|
+
} catch (err) {
|
|
12617
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
12618
|
+
const details = err?.details;
|
|
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
|
+
}
|
|
12630
|
+
if (msg.includes("GraphQL") || msg.includes("Failed to decode") || detailsStr.includes("GraphQL") || detailsStr.includes("Failed to decode")) {
|
|
12631
|
+
return { valid: false, message: "Invalid address format" };
|
|
12632
|
+
}
|
|
12633
|
+
throw err;
|
|
12634
|
+
}
|
|
12615
12635
|
}
|
|
12616
12636
|
async getAssetInfo(assetId) {
|
|
12617
|
-
|
|
12637
|
+
const info2 = await this.client.gateway("GET", `/v1/assets/${assetId}`);
|
|
12638
|
+
try {
|
|
12639
|
+
const priceResp = await this.client.market(
|
|
12640
|
+
"POST",
|
|
12641
|
+
"/v2/market/tickers",
|
|
12642
|
+
{ currency: "USD", assets: [assetId] }
|
|
12643
|
+
);
|
|
12644
|
+
const ticker = priceResp.tickers?.[0];
|
|
12645
|
+
if (ticker) {
|
|
12646
|
+
if (ticker.price != null) info2.priceUsd = ticker.price;
|
|
12647
|
+
if (ticker.change_24h != null) info2.priceChange24h = ticker.change_24h;
|
|
12648
|
+
if (ticker.market_cap != null) info2.marketCapUsd = ticker.market_cap;
|
|
12649
|
+
if (ticker.volume_24h != null) info2.volume24hUsd = ticker.volume_24h;
|
|
12650
|
+
}
|
|
12651
|
+
} catch {
|
|
12652
|
+
}
|
|
12653
|
+
return info2;
|
|
12618
12654
|
}
|
|
12619
12655
|
async getTokenHoldings(assets, fromTime = 0) {
|
|
12620
12656
|
const response = await this.client.gateway("POST", "/v1/assets", {
|
|
@@ -12737,7 +12773,15 @@ var init_dist5 = __esm({
|
|
|
12737
12773
|
}
|
|
12738
12774
|
const totalRisks = (security?.contract_security?.num_risks ?? 0) + (security?.honeypot_risk?.num_risks ?? 0);
|
|
12739
12775
|
const totalWarnings = (security?.contract_security?.num_warnings ?? 0) + (security?.honeypot_risk?.num_warnings ?? 0);
|
|
12740
|
-
const
|
|
12776
|
+
const computedRiskLevel = totalRisks > 0 ? "high" : totalWarnings > 0 ? "medium" : security ? "low" : void 0;
|
|
12777
|
+
let finalRiskLevel = security?.risk_level ?? security?.riskLevel ?? computedRiskLevel;
|
|
12778
|
+
const knownStablecoins = ["USDC", "USDT", "DAI", "BUSD", "TUSD", "USDP", "FRAX", "PYUSD"];
|
|
12779
|
+
const symbol = (asset.symbol ?? raw.symbol ?? "").toUpperCase();
|
|
12780
|
+
let riskContext;
|
|
12781
|
+
if (finalRiskLevel === "medium" && knownStablecoins.includes(symbol) && totalRisks === 0) {
|
|
12782
|
+
riskContext = "Warnings are due to proxy contract pattern, common in audited stablecoins";
|
|
12783
|
+
finalRiskLevel = "low";
|
|
12784
|
+
}
|
|
12741
12785
|
return {
|
|
12742
12786
|
assetId,
|
|
12743
12787
|
name: asset.name ?? raw.name,
|
|
@@ -12749,7 +12793,8 @@ var init_dist5 = __esm({
|
|
|
12749
12793
|
isHoneypot: isHoneypot ?? security.is_honeypot ?? security.isHoneypot,
|
|
12750
12794
|
hasAudit: security.has_audit ?? security.hasAudit ?? security.is_scanned,
|
|
12751
12795
|
auditProvider: security.audit_provider ?? security.auditProvider ?? security.provider,
|
|
12752
|
-
riskLevel:
|
|
12796
|
+
riskLevel: finalRiskLevel,
|
|
12797
|
+
...riskContext ? { riskContext } : {},
|
|
12753
12798
|
warnings: warnings.length > 0 ? warnings : security.warnings
|
|
12754
12799
|
} : void 0,
|
|
12755
12800
|
solanaSecurityInfo: solanaSecurity ? {
|
|
@@ -38862,17 +38907,29 @@ ${qr3}`;
|
|
|
38862
38907
|
const kc2 = new KeychainManager();
|
|
38863
38908
|
const keychainHasPassword = kc2.isAvailable() ? !!await kc2.getWalletPassword() : false;
|
|
38864
38909
|
const totalChains = Object.keys(CHAINS).length;
|
|
38910
|
+
let createdAt;
|
|
38911
|
+
let addressCount;
|
|
38912
|
+
if (exists) {
|
|
38913
|
+
const config2 = await store.getConfig();
|
|
38914
|
+
createdAt = config2?.createdAt;
|
|
38915
|
+
addressCount = config2?.chains?.length ?? totalChains;
|
|
38916
|
+
}
|
|
38865
38917
|
const result = {
|
|
38866
38918
|
agentWallet: exists ? "configured" : "not configured",
|
|
38867
38919
|
keychainPassword: keychainHasPassword ? "stored" : "not stored",
|
|
38868
|
-
chains: totalChains
|
|
38920
|
+
chains: totalChains,
|
|
38921
|
+
supportedChains: totalChains,
|
|
38922
|
+
...createdAt ? { createdAt } : {},
|
|
38923
|
+
...addressCount !== void 0 ? { addressCount } : {}
|
|
38869
38924
|
};
|
|
38870
38925
|
if (opts.json) {
|
|
38871
38926
|
output(result, true);
|
|
38872
38927
|
} else {
|
|
38873
38928
|
console.log(` ${import_chalk5.default.dim("Wallet")} ${exists ? import_chalk5.default.green("configured") : import_chalk5.default.yellow("not configured")}`);
|
|
38929
|
+
if (createdAt) console.log(` ${import_chalk5.default.dim("Created")} ${createdAt}`);
|
|
38874
38930
|
console.log(` ${import_chalk5.default.dim("Keychain")} ${keychainHasPassword ? import_chalk5.default.green("password stored") : import_chalk5.default.yellow("no password")}`);
|
|
38875
38931
|
console.log(` ${import_chalk5.default.dim("Chains")} ${totalChains} supported`);
|
|
38932
|
+
if (addressCount !== void 0) console.log(` ${import_chalk5.default.dim("Addresses")} ${addressCount}`);
|
|
38876
38933
|
if (!exists) info("\nRun `twak wallet create --password <pw>` to create a wallet.");
|
|
38877
38934
|
}
|
|
38878
38935
|
});
|
|
@@ -39102,8 +39159,7 @@ var SwapClient = class {
|
|
|
39102
39159
|
return transactions;
|
|
39103
39160
|
}
|
|
39104
39161
|
async searchTokens(params) {
|
|
39105
|
-
const
|
|
39106
|
-
const coinIds = chains.map((c3) => getChainById(c3)?.coinId).filter(Boolean).join(",");
|
|
39162
|
+
const coinIds = params.networks ? params.networks : (params.chains || Object.keys(CHAINS)).map((c3) => getChainById(c3)?.coinId).filter((id) => id != null).join(",");
|
|
39107
39163
|
const queryParams = new URLSearchParams({
|
|
39108
39164
|
networks: coinIds,
|
|
39109
39165
|
exactQuery: params.query,
|
|
@@ -39726,7 +39782,15 @@ function registerAlertCommand(program3) {
|
|
|
39726
39782
|
alert.command("list").description("List all alerts").option("--active", "Show only active alerts").option("--json", "JSON output").action(async (opts) => {
|
|
39727
39783
|
const alerts = opts.active ? await alertStore.getActive() : await alertStore.list();
|
|
39728
39784
|
if (opts.json) {
|
|
39729
|
-
|
|
39785
|
+
const enriched = alerts.map((a3) => {
|
|
39786
|
+
let chainLabel = a3.chainKey;
|
|
39787
|
+
try {
|
|
39788
|
+
chainLabel = tokenIdToChain(a3.tokenId) ?? a3.chainKey;
|
|
39789
|
+
} catch {
|
|
39790
|
+
}
|
|
39791
|
+
return { ...a3, tokenLabel: resolveTokenLabel(a3.tokenId), chainLabel };
|
|
39792
|
+
});
|
|
39793
|
+
output(enriched, true);
|
|
39730
39794
|
} else {
|
|
39731
39795
|
if (alerts.length === 0) {
|
|
39732
39796
|
info("No alerts found");
|
|
@@ -39734,8 +39798,13 @@ function registerAlertCommand(program3) {
|
|
|
39734
39798
|
}
|
|
39735
39799
|
for (const a3 of alerts) {
|
|
39736
39800
|
const label = resolveTokenLabel(a3.tokenId);
|
|
39737
|
-
|
|
39738
|
-
|
|
39801
|
+
let chainHint = "";
|
|
39802
|
+
try {
|
|
39803
|
+
const chain2 = tokenIdToChain(a3.tokenId);
|
|
39804
|
+
chainHint = chain2 ? ` (${chain2})` : "";
|
|
39805
|
+
} catch {
|
|
39806
|
+
chainHint = "";
|
|
39807
|
+
}
|
|
39739
39808
|
info(`${a3.id} | ${label}${chainHint} | ${a3.condition} $${a3.targetPrice} | ${a3.active ? "active" : "triggered"}`);
|
|
39740
39809
|
}
|
|
39741
39810
|
}
|
|
@@ -39844,7 +39913,7 @@ function handleError(err, json) {
|
|
|
39844
39913
|
process.exitCode = 1;
|
|
39845
39914
|
}
|
|
39846
39915
|
function registerQueryCommand(program3) {
|
|
39847
|
-
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) => {
|
|
39848
39917
|
try {
|
|
39849
39918
|
const client = await getClient();
|
|
39850
39919
|
const swapClient = new SwapClient(client);
|
|
@@ -39904,24 +39973,27 @@ function registerQueryCommand(program3) {
|
|
|
39904
39973
|
price = results[0].priceUsd;
|
|
39905
39974
|
}
|
|
39906
39975
|
}
|
|
39907
|
-
if (
|
|
39976
|
+
if (price === null) {
|
|
39977
|
+
error(`Token not found: ${token}`);
|
|
39978
|
+
if (opts.json) output({ token: token.toUpperCase(), chain: chain2, priceUsd: null, error: "Token not found" }, true);
|
|
39979
|
+
process.exitCode = 1;
|
|
39980
|
+
return;
|
|
39981
|
+
}
|
|
39982
|
+
if (opts.history !== void 0) {
|
|
39983
|
+
const period = typeof opts.history === "string" ? opts.history : "week";
|
|
39908
39984
|
const chainInfo = getChainById(chain2);
|
|
39909
39985
|
if (!chainInfo) throw new Error(`Unknown chain: ${chain2}`);
|
|
39910
39986
|
const isNative = !tokenInfo.address || tokenInfo.address === NATIVE_TOKEN_ADDRESS || tokenInfo.address === SOLANA_NATIVE_ADDRESS;
|
|
39911
39987
|
const assetId = isNative ? `c${chainInfo.coinId}` : `c${chainInfo.coinId}_t${tokenInfo.address}`;
|
|
39912
|
-
const chartData = await client.
|
|
39988
|
+
const chartData = await client.gateway(
|
|
39913
39989
|
"GET",
|
|
39914
|
-
`/
|
|
39990
|
+
`/v1/market/charts/${assetId}`,
|
|
39991
|
+
void 0,
|
|
39992
|
+
`currency=USD&period=${period}`
|
|
39915
39993
|
);
|
|
39916
39994
|
output({ token: token.toUpperCase(), chain: chain2, priceUsd: price, history: chartData.prices }, opts.json);
|
|
39917
39995
|
return;
|
|
39918
39996
|
}
|
|
39919
|
-
if (price === null) {
|
|
39920
|
-
error(`Token not found: ${token}`);
|
|
39921
|
-
if (opts.json) output({ token: token.toUpperCase(), chain: chain2, priceUsd: null, error: "Token not found" }, true);
|
|
39922
|
-
process.exitCode = 1;
|
|
39923
|
-
return;
|
|
39924
|
-
}
|
|
39925
39997
|
if (opts.json) {
|
|
39926
39998
|
output({ token: token.toUpperCase(), chain: chain2, priceUsd: price }, true);
|
|
39927
39999
|
} else {
|
|
@@ -39932,11 +40004,25 @@ function registerQueryCommand(program3) {
|
|
|
39932
40004
|
handleError(err, opts.json);
|
|
39933
40005
|
}
|
|
39934
40006
|
});
|
|
39935
|
-
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) => {
|
|
39936
40008
|
try {
|
|
39937
40009
|
const client = await getClient();
|
|
39938
40010
|
const swapClient = new SwapClient(client);
|
|
39939
|
-
|
|
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
|
+
}
|
|
40021
|
+
const result = await swapClient.searchTokens({
|
|
40022
|
+
query,
|
|
40023
|
+
limit: parseInt(opts.limit, 10),
|
|
40024
|
+
...networks ? { networks } : {}
|
|
40025
|
+
});
|
|
39940
40026
|
output(result, opts.json);
|
|
39941
40027
|
} catch (err) {
|
|
39942
40028
|
handleError(err, opts.json);
|
|
@@ -40010,7 +40096,9 @@ function registerQueryCommand(program3) {
|
|
|
40010
40096
|
if (opts.json) {
|
|
40011
40097
|
output(result, true);
|
|
40012
40098
|
} else if (result.length === 0) {
|
|
40013
|
-
|
|
40099
|
+
const explorer = opts.chain === "ethereum" ? "etherscan.io" : opts.chain === "bsc" ? "bscscan.com" : void 0;
|
|
40100
|
+
const hint = explorer ? ` Check ${explorer} for full history.` : "";
|
|
40101
|
+
info(`No transactions found via API.${hint}`);
|
|
40014
40102
|
} else {
|
|
40015
40103
|
output(result, false);
|
|
40016
40104
|
}
|
|
@@ -40060,23 +40148,61 @@ function registerQueryCommand(program3) {
|
|
|
40060
40148
|
}
|
|
40061
40149
|
}
|
|
40062
40150
|
});
|
|
40063
|
-
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) => {
|
|
40064
40152
|
try {
|
|
40065
|
-
|
|
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
|
+
}
|
|
40066
40164
|
const chain2 = getChainByCoinId(coinId);
|
|
40067
40165
|
if (!chain2) throw new Error(`Unknown coin ID: ${coinId}`);
|
|
40068
|
-
|
|
40166
|
+
try {
|
|
40167
|
+
await ensureTrustSDK();
|
|
40168
|
+
const { getWalletCore: getWalletCore2, getCoinType: getCoinType2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports2));
|
|
40169
|
+
const wc2 = getWalletCore2();
|
|
40170
|
+
const ct5 = getCoinType2(coinId);
|
|
40171
|
+
if (ct5 && !wc2.CoinTypeExt.validate(ct5, opts.address)) {
|
|
40172
|
+
throw new Error(`Invalid address format for ${chain2.name}`);
|
|
40173
|
+
}
|
|
40174
|
+
} catch (err) {
|
|
40175
|
+
if (err instanceof Error && err.message.startsWith("Invalid address")) throw err;
|
|
40176
|
+
}
|
|
40177
|
+
const assetId = opts.token ? `c${coinId}_t${opts.token}` : `c${coinId}`;
|
|
40069
40178
|
const client = new BlockchainClient();
|
|
40070
|
-
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
|
+
}
|
|
40071
40195
|
const fmt = (raw) => {
|
|
40072
40196
|
const big = BigInt(raw);
|
|
40073
|
-
|
|
40074
|
-
|
|
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)}`;
|
|
40075
40200
|
};
|
|
40076
40201
|
output({
|
|
40077
40202
|
address: opts.address,
|
|
40078
40203
|
chain: chain2.id,
|
|
40079
|
-
symbol
|
|
40204
|
+
symbol,
|
|
40205
|
+
...opts.token ? { token: opts.token } : {},
|
|
40080
40206
|
available: fmt(balance.available),
|
|
40081
40207
|
...balance.staked ? { staked: fmt(balance.staked) } : {},
|
|
40082
40208
|
...balance.pending ? { pending: fmt(balance.pending) } : {},
|
|
@@ -40114,26 +40240,28 @@ function registerQueryCommand(program3) {
|
|
|
40114
40240
|
const wc2 = getWalletCore2();
|
|
40115
40241
|
const ct5 = getCoinType2(coinId);
|
|
40116
40242
|
if (ct5) {
|
|
40117
|
-
const isValid2 = wc2.
|
|
40243
|
+
const isValid2 = wc2.CoinTypeExt.validate(ct5, opts.address);
|
|
40118
40244
|
if (!isValid2) {
|
|
40119
|
-
const
|
|
40245
|
+
const chainInfo = getChainByCoinId(coinId);
|
|
40246
|
+
const label = chainInfo?.name ?? `coin ${coinId}`;
|
|
40247
|
+
const result = { status: "error", valid: false, chain: chainInfo?.id, message: `Invalid address format for ${label}` };
|
|
40120
40248
|
output(result, opts.json);
|
|
40121
40249
|
return;
|
|
40122
40250
|
}
|
|
40123
40251
|
}
|
|
40124
40252
|
} catch {
|
|
40125
|
-
const isHex = /^0x[0-9a-fA-F]{40}$/.test(opts.address);
|
|
40126
|
-
const isEvmCoin = [60, 20000714, 10009e3, 966, 10042221, 10000070, 8453, 137, 250, 10000250, 10000324, 81457, 2e3, 61].includes(coinId);
|
|
40127
|
-
if (isEvmCoin && !isHex) {
|
|
40128
|
-
output({ status: "error", valid: false, message: `Invalid EVM address format` }, opts.json);
|
|
40129
|
-
return;
|
|
40130
|
-
}
|
|
40131
40253
|
}
|
|
40132
40254
|
}
|
|
40133
40255
|
const client = await getClient();
|
|
40134
40256
|
const service = new SecurityService(client);
|
|
40135
40257
|
const backendResult = await service.validate({ address: opts.address, assetId });
|
|
40136
|
-
|
|
40258
|
+
const chainKey = opts.chain || (assetId ? (() => {
|
|
40259
|
+
const coinIdStr = assetId.replace(/^c/, "").split("_")[0];
|
|
40260
|
+
const coinId = parseInt(coinIdStr, 10);
|
|
40261
|
+
return getChainByCoinId(coinId)?.id;
|
|
40262
|
+
})() : void 0);
|
|
40263
|
+
const enriched = { ...backendResult, ...chainKey ? { chain: chainKey } : {} };
|
|
40264
|
+
output(enriched, opts.json);
|
|
40137
40265
|
} catch (err) {
|
|
40138
40266
|
handleError(err, opts.json);
|
|
40139
40267
|
}
|
|
@@ -44345,17 +44473,34 @@ var BalanceActionProvider = class extends ActionProvider {
|
|
|
44345
44473
|
getTokenHoldings() {
|
|
44346
44474
|
return {
|
|
44347
44475
|
name: "get_token_holdings",
|
|
44348
|
-
description: "Get
|
|
44476
|
+
description: "Get ERC-20 token holdings for an address",
|
|
44349
44477
|
schema: external_exports.object({
|
|
44350
44478
|
address: external_exports.string().describe("Wallet address"),
|
|
44351
44479
|
coin: external_exports.coerce.number().describe("SLIP44 coin ID")
|
|
44352
44480
|
}),
|
|
44353
44481
|
invoke: async (ctx, input) => {
|
|
44354
|
-
|
|
44482
|
+
const response = await ctx.httpClient.gateway("POST", "/v1/assets", {
|
|
44355
44483
|
version: 2,
|
|
44356
44484
|
includeDisabledAssets: false,
|
|
44357
44485
|
assets: [{ address: input.address, coin: input.coin }]
|
|
44358
44486
|
});
|
|
44487
|
+
const holdings = Array.isArray(response) ? response : response.docs ?? response.data ?? [];
|
|
44488
|
+
const tokens = [];
|
|
44489
|
+
for (const h4 of holdings) {
|
|
44490
|
+
if (Array.isArray(h4.tokens)) {
|
|
44491
|
+
for (const t of h4.tokens) {
|
|
44492
|
+
tokens.push({
|
|
44493
|
+
symbol: t.symbol ?? t.contract,
|
|
44494
|
+
contract: t.contract,
|
|
44495
|
+
decimals: t.decimals ?? 18,
|
|
44496
|
+
balance: t.balance ?? "0",
|
|
44497
|
+
name: t.name,
|
|
44498
|
+
type: t.type
|
|
44499
|
+
});
|
|
44500
|
+
}
|
|
44501
|
+
}
|
|
44502
|
+
}
|
|
44503
|
+
return { address: input.address, coin: input.coin, tokens };
|
|
44359
44504
|
}
|
|
44360
44505
|
};
|
|
44361
44506
|
}
|
|
@@ -54257,7 +54402,7 @@ var crypto5 = __toESM(require("crypto"));
|
|
|
54257
54402
|
// package.json
|
|
54258
54403
|
var package_default = {
|
|
54259
54404
|
name: "@trustwallet/cli",
|
|
54260
|
-
version: "0.6.
|
|
54405
|
+
version: "0.6.10",
|
|
54261
54406
|
description: "TWAK CLI \u2014 command-line interface for Trust Wallet Agent Kit",
|
|
54262
54407
|
main: "dist/index.js",
|
|
54263
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/
|
|
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"
|