@t2000/sdk 2.19.0 → 2.19.1
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/README.md +9 -4
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,8 +36,11 @@ const agent = await T2000.create({ pin: 'my-secret' });
|
|
|
36
36
|
const balance = await agent.balance();
|
|
37
37
|
console.log(`$${balance.available} USDC available`);
|
|
38
38
|
|
|
39
|
-
// Send USDC
|
|
39
|
+
// Send USDC — recipient can be a 0x address, a SuiNS name, or a saved contact alias
|
|
40
40
|
await agent.send({ to: '0x...', amount: 10 });
|
|
41
|
+
await agent.send({ to: 'alex.sui', amount: 10 }); // SuiNS — resolved on-chain
|
|
42
|
+
// Legacy contact aliases (~/.t2000/contacts.json) still work but emit a deprecation
|
|
43
|
+
// warning on first use per process. Sunset target: next major SDK release.
|
|
41
44
|
|
|
42
45
|
// Save (earn yield — auto-selects best rate via NAVI)
|
|
43
46
|
await agent.save({ amount: 50 });
|
|
@@ -88,7 +91,8 @@ const agent = T2000.fromPrivateKey('suiprivkey1q...');
|
|
|
88
91
|
|--------|-------------|---------|
|
|
89
92
|
| `agent.address()` | Wallet Sui address | `string` |
|
|
90
93
|
| `agent.balance()` | Available USDC + savings + gas reserve | `BalanceResponse` |
|
|
91
|
-
| `agent.send({ to, amount, asset? })` | Transfer USDC to
|
|
94
|
+
| `agent.send({ to, amount, asset? })` | Transfer USDC (or other supported asset) to a 0x address, SuiNS name (`alex.sui`), or saved contact alias. Priority: hex > SuiNS > contact. `SendResult.suinsName` / `.contactName` flag which path resolved. | `SendResult` |
|
|
95
|
+
| `agent.resolveRecipient(input)` | Public resolver — same hex / SuiNS / contact priority used by `send()`. Useful for dryRun previews where you need the resolved address before committing. | `{ address, suinsName?, contactName? }` |
|
|
92
96
|
| `agent.receive({ amount?, currency?, memo?, label? })` | Generate payment request with Payment Kit URI (`sui:pay?...`), nonce for duplicate prevention | `PaymentRequest` |
|
|
93
97
|
| `agent.save({ amount, asset?, protocol? })` | Deposit **USDC or USDsui** to NAVI savings (v0.51.0+). `asset` defaults to `'USDC'`. Auto-selects best rate or specify `protocol`. `amount` can be `'all'`. | `SaveResult` |
|
|
94
98
|
| `agent.withdraw({ amount, asset? })` | Withdraw from savings. `amount` can be `'all'`. Optional `asset` (default: USDC; also supports USDsui plus legacy USDe / SUI). | `WithdrawResult` |
|
|
@@ -285,10 +289,11 @@ Swap uses Cetus Aggregator V3. Per-call `overlayFee` is opt-in — the SDK and C
|
|
|
285
289
|
import { T2000Error } from '@t2000/sdk';
|
|
286
290
|
|
|
287
291
|
try {
|
|
288
|
-
await agent.send({ to: '
|
|
292
|
+
await agent.send({ to: 'alex.sui', amount: 1000 });
|
|
289
293
|
} catch (e) {
|
|
290
294
|
if (e instanceof T2000Error) {
|
|
291
|
-
console.log(e.code);
|
|
295
|
+
console.log(e.code);
|
|
296
|
+
// 'INSUFFICIENT_BALANCE' | 'SUINS_NOT_REGISTERED' | 'CONTACT_NOT_FOUND' | …
|
|
292
297
|
console.log(e.message); // Human-readable message
|
|
293
298
|
}
|
|
294
299
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -6435,6 +6435,7 @@ var ContactManager = class {
|
|
|
6435
6435
|
const existed = key in this.contacts;
|
|
6436
6436
|
this.contacts[key] = { name, address: normalized };
|
|
6437
6437
|
this.save();
|
|
6438
|
+
warnContactsDeprecation();
|
|
6438
6439
|
return { action: existed ? "updated" : "added" };
|
|
6439
6440
|
}
|
|
6440
6441
|
remove(name) {
|
|
@@ -6877,6 +6878,14 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
6877
6878
|
* unregistered SuiNS names (vs. propagating the engine-style
|
|
6878
6879
|
* `SuinsNotRegisteredError` — keeps the SDK's error surface
|
|
6879
6880
|
* `T2000Error`-only, consistent with every other write helper).
|
|
6881
|
+
*
|
|
6882
|
+
* [S.279.1 / 2026-05-23 — patch v2.19.1] Promoted from `private` to
|
|
6883
|
+
* `public` so MCP's `t2000_send` dryRun preview path can share the
|
|
6884
|
+
* same resolution logic as the live execute path. Pre-2.19.1 the
|
|
6885
|
+
* MCP dryRun called `agent.contacts.resolve(to)` directly, which
|
|
6886
|
+
* rejected SuiNS names — preview-then-execute flows broke for
|
|
6887
|
+
* `alex.sui`-style recipients. SSOT: never let preview and execute
|
|
6888
|
+
* resolve the same input differently.
|
|
6880
6889
|
*/
|
|
6881
6890
|
async resolveRecipient(input) {
|
|
6882
6891
|
const trimmed = input.trim();
|