@t2000/cli 2.18.1 → 2.19.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/{chunk-ZNZ4MOY2.js → chunk-2TOYZOH3.js} +192 -3
- package/dist/chunk-2TOYZOH3.js.map +1 -0
- package/dist/{dist-APKOY2VV.js → dist-EJKUXGU5.js} +129 -4
- package/dist/{dist-APKOY2VV.js.map → dist-EJKUXGU5.js.map} +1 -1
- package/dist/{dist-EFTMN6BY.js → dist-LIH33AY2.js} +22 -2
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-ZNZ4MOY2.js.map +0 -1
- /package/dist/{dist-EFTMN6BY.js.map → dist-LIH33AY2.js.map} +0 -0
|
@@ -134943,6 +134943,76 @@ function extractCommands(txBlock) {
|
|
|
134943
134943
|
return result;
|
|
134944
134944
|
}
|
|
134945
134945
|
init_token_registry();
|
|
134946
|
+
var SUI_MAINNET_URL = "https://fullnode.mainnet.sui.io:443";
|
|
134947
|
+
var SUI_ADDRESS_REGEX = /^0x[a-fA-F0-9]{1,64}$/i;
|
|
134948
|
+
var SUINS_NAME_REGEX = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.sui$/;
|
|
134949
|
+
var InvalidAddressError4 = class extends Error {
|
|
134950
|
+
constructor(raw) {
|
|
134951
|
+
super(
|
|
134952
|
+
`"${raw}" isn't a valid Sui address or SuiNS name. Pass a 0x-prefixed hex address (e.g. 0x40cd\u20263e62) or a SuiNS name ending in .sui (e.g. alex.sui).`
|
|
134953
|
+
);
|
|
134954
|
+
this.raw = raw;
|
|
134955
|
+
this.name = "InvalidAddressError";
|
|
134956
|
+
}
|
|
134957
|
+
};
|
|
134958
|
+
var SuinsNotRegisteredError = class extends Error {
|
|
134959
|
+
constructor(name_) {
|
|
134960
|
+
super(
|
|
134961
|
+
`"${name_}" isn't a registered SuiNS name. Double-check the spelling, or paste the full Sui address (0x\u2026 64 hex characters).`
|
|
134962
|
+
);
|
|
134963
|
+
this.name_ = name_;
|
|
134964
|
+
this.name = "SuinsNotRegisteredError";
|
|
134965
|
+
}
|
|
134966
|
+
};
|
|
134967
|
+
var SuinsRpcError = class extends Error {
|
|
134968
|
+
constructor(name_, detail) {
|
|
134969
|
+
super(`SuiNS lookup failed for "${name_}" (${detail}). Try again, or paste the full Sui address.`);
|
|
134970
|
+
this.name_ = name_;
|
|
134971
|
+
this.name = "SuinsRpcError";
|
|
134972
|
+
}
|
|
134973
|
+
};
|
|
134974
|
+
function looksLikeSuiNs(value) {
|
|
134975
|
+
if (!value) return false;
|
|
134976
|
+
return SUINS_NAME_REGEX.test(value.trim().toLowerCase());
|
|
134977
|
+
}
|
|
134978
|
+
async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
134979
|
+
const name = rawName.trim().toLowerCase();
|
|
134980
|
+
if (!SUINS_NAME_REGEX.test(name)) {
|
|
134981
|
+
throw new InvalidAddressError4(rawName);
|
|
134982
|
+
}
|
|
134983
|
+
const url3 = ctx.suiRpcUrl || SUI_MAINNET_URL;
|
|
134984
|
+
let res;
|
|
134985
|
+
try {
|
|
134986
|
+
res = await fetch(url3, {
|
|
134987
|
+
method: "POST",
|
|
134988
|
+
headers: { "Content-Type": "application/json" },
|
|
134989
|
+
body: JSON.stringify({
|
|
134990
|
+
jsonrpc: "2.0",
|
|
134991
|
+
id: 1,
|
|
134992
|
+
method: "suix_resolveNameServiceAddress",
|
|
134993
|
+
params: [name]
|
|
134994
|
+
}),
|
|
134995
|
+
signal: ctx.signal ?? AbortSignal.timeout(8e3)
|
|
134996
|
+
});
|
|
134997
|
+
} catch (err) {
|
|
134998
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
134999
|
+
throw new SuinsRpcError(name, msg);
|
|
135000
|
+
}
|
|
135001
|
+
if (!res.ok) {
|
|
135002
|
+
throw new SuinsRpcError(name, `HTTP ${res.status}`);
|
|
135003
|
+
}
|
|
135004
|
+
let body;
|
|
135005
|
+
try {
|
|
135006
|
+
body = await res.json();
|
|
135007
|
+
} catch (err) {
|
|
135008
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
135009
|
+
throw new SuinsRpcError(name, `JSON parse failed: ${msg}`);
|
|
135010
|
+
}
|
|
135011
|
+
if (body.error) {
|
|
135012
|
+
throw new SuinsRpcError(name, body.error.message);
|
|
135013
|
+
}
|
|
135014
|
+
return body.result ?? null;
|
|
135015
|
+
}
|
|
134946
135016
|
function ulebEncode2(num2) {
|
|
134947
135017
|
let bigNum = BigInt(num2);
|
|
134948
135018
|
const arr = [];
|
|
@@ -139313,6 +139383,14 @@ var SafeguardEnforcer = class {
|
|
|
139313
139383
|
};
|
|
139314
139384
|
init_errors9();
|
|
139315
139385
|
var RESERVED_NAMES = /* @__PURE__ */ new Set(["to", "all", "address"]);
|
|
139386
|
+
var deprecationWarned = false;
|
|
139387
|
+
function warnContactsDeprecation() {
|
|
139388
|
+
if (deprecationWarned) return;
|
|
139389
|
+
deprecationWarned = true;
|
|
139390
|
+
console.warn(
|
|
139391
|
+
"[t2000] DEPRECATION: ~/.t2000/contacts.json alias resolution is deprecated and will be removed in the next major release. Use SuiNS names instead (e.g. `t2000 send alex.sui 10 USDC`). Register a SuiNS name at https://suins.io if you need a memorable handle."
|
|
139392
|
+
);
|
|
139393
|
+
}
|
|
139316
139394
|
var ContactManager = class {
|
|
139317
139395
|
contacts = {};
|
|
139318
139396
|
filePath;
|
|
@@ -139366,12 +139444,15 @@ var ContactManager = class {
|
|
|
139366
139444
|
}
|
|
139367
139445
|
const contact = this.contacts[nameOrAddress.toLowerCase()];
|
|
139368
139446
|
if (contact) {
|
|
139447
|
+
warnContactsDeprecation();
|
|
139369
139448
|
return { address: contact.address, contactName: contact.name };
|
|
139370
139449
|
}
|
|
139371
139450
|
throw new T2000Error(
|
|
139372
139451
|
"CONTACT_NOT_FOUND",
|
|
139373
139452
|
`"${nameOrAddress}" is not a valid Sui address or saved contact.
|
|
139374
|
-
|
|
139453
|
+
Use a SuiNS name (e.g. alex.sui \u2014 register at https://suins.io)
|
|
139454
|
+
or paste the full Sui address (0x... 64 hex characters).
|
|
139455
|
+
Legacy contact aliases: \`t2000 contacts add ${nameOrAddress} 0x...\` (deprecated).`
|
|
139375
139456
|
);
|
|
139376
139457
|
}
|
|
139377
139458
|
validateName(name) {
|
|
@@ -139741,7 +139822,7 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
139741
139822
|
if (!(asset in SUPPORTED_ASSETS)) {
|
|
139742
139823
|
throw new T2000Error("ASSET_NOT_SUPPORTED", `Asset ${asset} is not supported`);
|
|
139743
139824
|
}
|
|
139744
|
-
const resolved = this.
|
|
139825
|
+
const resolved = await this.resolveRecipient(params.to);
|
|
139745
139826
|
const sendAmount = params.amount;
|
|
139746
139827
|
const sendTo = resolved.address;
|
|
139747
139828
|
const gasResult = await executeTx(
|
|
@@ -139758,11 +139839,55 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
139758
139839
|
amount: sendAmount,
|
|
139759
139840
|
to: resolved.address,
|
|
139760
139841
|
contactName: resolved.contactName,
|
|
139842
|
+
suinsName: resolved.suinsName,
|
|
139761
139843
|
gasCost: gasResult.gasCostSui,
|
|
139762
139844
|
gasCostUnit: "SUI",
|
|
139763
139845
|
balance
|
|
139764
139846
|
};
|
|
139765
139847
|
}
|
|
139848
|
+
/**
|
|
139849
|
+
* [S.279 / CLI-CONTACTS-CLEANUP — 2026-05-23] Resolve a recipient
|
|
139850
|
+
* string into a canonical 0x address, trying each shape in priority
|
|
139851
|
+
* order:
|
|
139852
|
+
* 1. **hex** — `0x…` is used directly (no RPC round-trip).
|
|
139853
|
+
* 2. **SuiNS** — `alex.sui` resolves via `suix_resolveNameServiceAddress`.
|
|
139854
|
+
* 3. **saved contact** — `ContactManager.resolve()` falls back to the
|
|
139855
|
+
* legacy `~/.t2000/contacts.json` alias map. Deprecated; the
|
|
139856
|
+
* manager surfaces a one-time `console.warn` when this path fires.
|
|
139857
|
+
*
|
|
139858
|
+
* Returns `{ address, suinsName?, contactName? }` so `send()` can stamp
|
|
139859
|
+
* the name source on the receipt without re-resolving.
|
|
139860
|
+
*
|
|
139861
|
+
* Throws `T2000Error('SUINS_NOT_REGISTERED', …)` for well-formed but
|
|
139862
|
+
* unregistered SuiNS names (vs. propagating the engine-style
|
|
139863
|
+
* `SuinsNotRegisteredError` — keeps the SDK's error surface
|
|
139864
|
+
* `T2000Error`-only, consistent with every other write helper).
|
|
139865
|
+
*/
|
|
139866
|
+
async resolveRecipient(input) {
|
|
139867
|
+
const trimmed = input.trim();
|
|
139868
|
+
if (SUI_ADDRESS_REGEX.test(trimmed)) {
|
|
139869
|
+
return { address: trimmed.toLowerCase() };
|
|
139870
|
+
}
|
|
139871
|
+
if (looksLikeSuiNs(trimmed)) {
|
|
139872
|
+
try {
|
|
139873
|
+
const name = trimmed.toLowerCase();
|
|
139874
|
+
const address2 = await resolveSuinsViaRpc(name);
|
|
139875
|
+
if (!address2) {
|
|
139876
|
+
throw new SuinsNotRegisteredError(name);
|
|
139877
|
+
}
|
|
139878
|
+
return { address: address2.toLowerCase(), suinsName: name };
|
|
139879
|
+
} catch (err) {
|
|
139880
|
+
if (err instanceof SuinsNotRegisteredError) {
|
|
139881
|
+
throw new T2000Error(
|
|
139882
|
+
"SUINS_NOT_REGISTERED",
|
|
139883
|
+
err.message
|
|
139884
|
+
);
|
|
139885
|
+
}
|
|
139886
|
+
throw err;
|
|
139887
|
+
}
|
|
139888
|
+
}
|
|
139889
|
+
return this.contacts.resolve(input);
|
|
139890
|
+
}
|
|
139766
139891
|
async balance() {
|
|
139767
139892
|
const bal = await queryBalance(this.client, this._address);
|
|
139768
139893
|
let chainTotal = bal.available + bal.gasReserve.usdEquiv;
|
|
@@ -142008,7 +142133,7 @@ ${context}
|
|
|
142008
142133
|
})
|
|
142009
142134
|
);
|
|
142010
142135
|
}
|
|
142011
|
-
var PKG_VERSION = "2.
|
|
142136
|
+
var PKG_VERSION = "2.19.0";
|
|
142012
142137
|
console.log = (...args) => console.error("[log]", ...args);
|
|
142013
142138
|
console.warn = (...args) => console.error("[warn]", ...args);
|
|
142014
142139
|
async function startMcpServer(opts) {
|
|
@@ -142099,4 +142224,4 @@ axios/dist/node/axios.cjs:
|
|
|
142099
142224
|
@scure/bip39/index.js:
|
|
142100
142225
|
(*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
|
|
142101
142226
|
*/
|
|
142102
|
-
//# sourceMappingURL=dist-
|
|
142227
|
+
//# sourceMappingURL=dist-EJKUXGU5.js.map
|