@t2000/cli 0.12.3 → 0.13.0
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
CHANGED
|
@@ -202,7 +202,8 @@ function registerSend(program2) {
|
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
204
|
printBlank();
|
|
205
|
-
|
|
205
|
+
const displayTo = result.contactName ? `${result.contactName} (${truncateAddress(result.to)})` : truncateAddress(result.to);
|
|
206
|
+
printSuccess(`Sent ${formatUsd(result.amount)} ${asset.toUpperCase()} \u2192 ${displayTo}`);
|
|
206
207
|
printKeyValue("Gas", `${result.gasCost.toFixed(4)} ${result.gasCostUnit} (${result.gasMethod})`);
|
|
207
208
|
printKeyValue("Balance", formatUsd(result.balance.available) + " USDC");
|
|
208
209
|
printKeyValue("Tx", explorerUrl(result.tx));
|
|
@@ -1759,7 +1760,7 @@ function registerMcp(program2) {
|
|
|
1759
1760
|
mcp.command("start", { isDefault: true }).description("Start MCP server (stdio transport)").option("--key <path>", "Key file path").action(async (opts) => {
|
|
1760
1761
|
let mod;
|
|
1761
1762
|
try {
|
|
1762
|
-
mod = await import("./dist-
|
|
1763
|
+
mod = await import("./dist-QGTOSQO3.js");
|
|
1763
1764
|
} catch {
|
|
1764
1765
|
console.error(
|
|
1765
1766
|
"MCP server not installed. Run:\n npm install -g @t2000/mcp"
|
|
@@ -1842,6 +1843,74 @@ function registerMcp(program2) {
|
|
|
1842
1843
|
});
|
|
1843
1844
|
}
|
|
1844
1845
|
|
|
1846
|
+
// src/commands/contacts.ts
|
|
1847
|
+
import { ContactManager, truncateAddress as truncateAddress3 } from "@t2000/sdk";
|
|
1848
|
+
function registerContacts(program2) {
|
|
1849
|
+
const contacts = program2.command("contacts").description("Manage contacts (send by name instead of address)");
|
|
1850
|
+
contacts.command("add <name> <address>").description("Add or update a contact").action((name, address) => {
|
|
1851
|
+
try {
|
|
1852
|
+
const manager = new ContactManager();
|
|
1853
|
+
const result = manager.add(name, address);
|
|
1854
|
+
if (isJsonMode()) {
|
|
1855
|
+
const contact2 = manager.get(name);
|
|
1856
|
+
printJson({ action: result.action, name: contact2.name, address: contact2.address });
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const contact = manager.get(name);
|
|
1860
|
+
printBlank();
|
|
1861
|
+
printSuccess(`${result.action === "added" ? "Added" : "Updated"} ${contact.name} (${truncateAddress3(contact.address)})`);
|
|
1862
|
+
printBlank();
|
|
1863
|
+
} catch (error) {
|
|
1864
|
+
handleError(error);
|
|
1865
|
+
}
|
|
1866
|
+
});
|
|
1867
|
+
contacts.command("remove <name>").description("Remove a contact").action((name) => {
|
|
1868
|
+
try {
|
|
1869
|
+
const manager = new ContactManager();
|
|
1870
|
+
const removed = manager.remove(name);
|
|
1871
|
+
if (isJsonMode()) {
|
|
1872
|
+
printJson({ removed, name });
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
printBlank();
|
|
1876
|
+
if (removed) {
|
|
1877
|
+
printSuccess(`Removed ${name}`);
|
|
1878
|
+
} else {
|
|
1879
|
+
printError(`Contact "${name}" not found`);
|
|
1880
|
+
}
|
|
1881
|
+
printBlank();
|
|
1882
|
+
} catch (error) {
|
|
1883
|
+
handleError(error);
|
|
1884
|
+
}
|
|
1885
|
+
});
|
|
1886
|
+
contacts.command("list", { isDefault: true }).description("List all contacts").action(() => {
|
|
1887
|
+
try {
|
|
1888
|
+
const manager = new ContactManager();
|
|
1889
|
+
const list = manager.list();
|
|
1890
|
+
if (isJsonMode()) {
|
|
1891
|
+
printJson(list);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
if (list.length === 0) {
|
|
1895
|
+
printBlank();
|
|
1896
|
+
printLine("No contacts yet.");
|
|
1897
|
+
printLine("Add one: t2000 contacts add Tom 0x...");
|
|
1898
|
+
printBlank();
|
|
1899
|
+
return;
|
|
1900
|
+
}
|
|
1901
|
+
printHeader("Contacts");
|
|
1902
|
+
const maxNameLen = Math.max(...list.map((c) => c.name.length));
|
|
1903
|
+
for (const contact of list) {
|
|
1904
|
+
const padded = contact.name.padEnd(maxNameLen + 4);
|
|
1905
|
+
printLine(`${padded}${truncateAddress3(contact.address)}`);
|
|
1906
|
+
}
|
|
1907
|
+
printBlank();
|
|
1908
|
+
} catch (error) {
|
|
1909
|
+
handleError(error);
|
|
1910
|
+
}
|
|
1911
|
+
});
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1845
1914
|
// src/program.ts
|
|
1846
1915
|
var require2 = createRequire(import.meta.url);
|
|
1847
1916
|
var { version: CLI_VERSION } = require2("../package.json");
|
|
@@ -1877,6 +1946,7 @@ function createProgram() {
|
|
|
1877
1946
|
registerRebalance(program2);
|
|
1878
1947
|
registerExchange(program2);
|
|
1879
1948
|
registerMcp(program2);
|
|
1949
|
+
registerContacts(program2);
|
|
1880
1950
|
return program2;
|
|
1881
1951
|
}
|
|
1882
1952
|
|