@t2000/sdk 5.5.0 → 5.5.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/dist/browser.cjs.map +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +24 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -18
- package/dist/index.d.ts +22 -18
- package/dist/index.js +24 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -303,31 +303,35 @@ declare class SuinsRpcError extends Error {
|
|
|
303
303
|
*/
|
|
304
304
|
declare function looksLikeSuiNs(value: string): boolean;
|
|
305
305
|
/**
|
|
306
|
-
* Resolve a SuiNS name to its on-chain Sui address via the
|
|
307
|
-
* `
|
|
308
|
-
*
|
|
309
|
-
* `SuinsRpcError` on RPC/network failure.
|
|
306
|
+
* Resolve a SuiNS name to its on-chain Sui address via the Sui GraphQL
|
|
307
|
+
* `address(name:)` query. Returns `null` if the name resolves to no address
|
|
308
|
+
* (= not registered or expired). Throws `SuinsRpcError` on transport failure.
|
|
310
309
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
310
|
+
* `ctx.signal` is honored for cancellation. (`ctx.suiRpcUrl` is retained for
|
|
311
|
+
* call-site back-compat but no longer used — resolution runs against the
|
|
312
|
+
* canonical GraphQL endpoint via `getSuiGraphQLClient()`.)
|
|
314
313
|
*/
|
|
315
314
|
declare function resolveSuinsViaRpc(rawName: string, ctx?: {
|
|
316
315
|
suiRpcUrl?: string;
|
|
317
316
|
signal?: AbortSignal;
|
|
318
317
|
}): Promise<string | null>;
|
|
319
318
|
/**
|
|
320
|
-
* Reverse-resolve a 0x address to its
|
|
321
|
-
* `
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
319
|
+
* Reverse-resolve a 0x address to its SuiNS name via the Sui GraphQL
|
|
320
|
+
* `address(address:){ defaultNameRecord { domain } }` query. Returns a
|
|
321
|
+
* single-element array with the address's **default (primary)** name, or
|
|
322
|
+
* `[]` when it has none. Throws `SuinsRpcError` on transport failure.
|
|
323
|
+
*
|
|
324
|
+
* Behavior note: the legacy JSON-RPC path returned *all* names for the
|
|
325
|
+
* address; GraphQL exposes the explicitly-configured default record, which is
|
|
326
|
+
* the one every consumer here actually uses (the LLM `resolve_suins` tool +
|
|
327
|
+
* card titles only ever render the primary). Returning `[primary]` keeps the
|
|
328
|
+
* `string[]` contract intact.
|
|
329
|
+
*
|
|
330
|
+
* Why this is its own helper (not folded into `normalizeAddressInput`): a
|
|
331
|
+
* reverse lookup adds a second round-trip per tool call. We don't want every
|
|
332
|
+
* read tool that takes an `address` to silently double its latency. The lookup
|
|
333
|
+
* primitive is opt-in via the `resolve_suins` tool; normalizers stay
|
|
334
|
+
* forward-only.
|
|
331
335
|
*/
|
|
332
336
|
declare function resolveAddressToSuinsViaRpc(rawAddress: string, ctx?: {
|
|
333
337
|
suiRpcUrl?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -303,31 +303,35 @@ declare class SuinsRpcError extends Error {
|
|
|
303
303
|
*/
|
|
304
304
|
declare function looksLikeSuiNs(value: string): boolean;
|
|
305
305
|
/**
|
|
306
|
-
* Resolve a SuiNS name to its on-chain Sui address via the
|
|
307
|
-
* `
|
|
308
|
-
*
|
|
309
|
-
* `SuinsRpcError` on RPC/network failure.
|
|
306
|
+
* Resolve a SuiNS name to its on-chain Sui address via the Sui GraphQL
|
|
307
|
+
* `address(name:)` query. Returns `null` if the name resolves to no address
|
|
308
|
+
* (= not registered or expired). Throws `SuinsRpcError` on transport failure.
|
|
310
309
|
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
310
|
+
* `ctx.signal` is honored for cancellation. (`ctx.suiRpcUrl` is retained for
|
|
311
|
+
* call-site back-compat but no longer used — resolution runs against the
|
|
312
|
+
* canonical GraphQL endpoint via `getSuiGraphQLClient()`.)
|
|
314
313
|
*/
|
|
315
314
|
declare function resolveSuinsViaRpc(rawName: string, ctx?: {
|
|
316
315
|
suiRpcUrl?: string;
|
|
317
316
|
signal?: AbortSignal;
|
|
318
317
|
}): Promise<string | null>;
|
|
319
318
|
/**
|
|
320
|
-
* Reverse-resolve a 0x address to its
|
|
321
|
-
* `
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
330
|
-
*
|
|
319
|
+
* Reverse-resolve a 0x address to its SuiNS name via the Sui GraphQL
|
|
320
|
+
* `address(address:){ defaultNameRecord { domain } }` query. Returns a
|
|
321
|
+
* single-element array with the address's **default (primary)** name, or
|
|
322
|
+
* `[]` when it has none. Throws `SuinsRpcError` on transport failure.
|
|
323
|
+
*
|
|
324
|
+
* Behavior note: the legacy JSON-RPC path returned *all* names for the
|
|
325
|
+
* address; GraphQL exposes the explicitly-configured default record, which is
|
|
326
|
+
* the one every consumer here actually uses (the LLM `resolve_suins` tool +
|
|
327
|
+
* card titles only ever render the primary). Returning `[primary]` keeps the
|
|
328
|
+
* `string[]` contract intact.
|
|
329
|
+
*
|
|
330
|
+
* Why this is its own helper (not folded into `normalizeAddressInput`): a
|
|
331
|
+
* reverse lookup adds a second round-trip per tool call. We don't want every
|
|
332
|
+
* read tool that takes an `address` to silently double its latency. The lookup
|
|
333
|
+
* primitive is opt-in via the `resolve_suins` tool; normalizers stay
|
|
334
|
+
* forward-only.
|
|
331
335
|
*/
|
|
332
336
|
declare function resolveAddressToSuinsViaRpc(rawAddress: string, ctx?: {
|
|
333
337
|
suiRpcUrl?: string;
|
package/dist/index.js
CHANGED
|
@@ -1552,7 +1552,7 @@ var TX_NODE_FRAGMENT = `
|
|
|
1552
1552
|
}
|
|
1553
1553
|
`;
|
|
1554
1554
|
var HISTORY_QUERY = `query History($address: SuiAddress!, $last: Int!) {
|
|
1555
|
-
transactions(last: $last, filter: {
|
|
1555
|
+
transactions(last: $last, filter: { affectedAddress: $address }) {
|
|
1556
1556
|
nodes {${TX_NODE_FRAGMENT}}
|
|
1557
1557
|
}
|
|
1558
1558
|
}`;
|
|
@@ -1679,7 +1679,12 @@ function extractCommands(txBlock) {
|
|
|
1679
1679
|
init_token_registry();
|
|
1680
1680
|
|
|
1681
1681
|
// src/utils/suins.ts
|
|
1682
|
-
var
|
|
1682
|
+
var RESOLVE_NAME_QUERY = `query ResolveSuins($name: String!) {
|
|
1683
|
+
address(name: $name) { address }
|
|
1684
|
+
}`;
|
|
1685
|
+
var REVERSE_NAME_QUERY = `query ReverseSuins($address: SuiAddress!) {
|
|
1686
|
+
address(address: $address) { defaultNameRecord { domain } }
|
|
1687
|
+
}`;
|
|
1683
1688
|
var SUI_ADDRESS_REGEX = /^0x[a-fA-F0-9]{1,64}$/i;
|
|
1684
1689
|
var SUI_ADDRESS_STRICT_REGEX = /^0x[a-fA-F0-9]{64}$/i;
|
|
1685
1690
|
var SUINS_NAME_REGEX = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.sui$/;
|
|
@@ -1717,76 +1722,45 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
|
|
|
1717
1722
|
if (!SUINS_NAME_REGEX.test(name)) {
|
|
1718
1723
|
throw new InvalidAddressError(rawName);
|
|
1719
1724
|
}
|
|
1720
|
-
const
|
|
1725
|
+
const gql = getSuiGraphQLClient();
|
|
1721
1726
|
let res;
|
|
1722
1727
|
try {
|
|
1723
|
-
res = await
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
jsonrpc: "2.0",
|
|
1728
|
-
id: 1,
|
|
1729
|
-
method: "suix_resolveNameServiceAddress",
|
|
1730
|
-
params: [name]
|
|
1731
|
-
}),
|
|
1732
|
-
signal: ctx.signal ?? AbortSignal.timeout(8e3)
|
|
1728
|
+
res = await gql.query({
|
|
1729
|
+
query: RESOLVE_NAME_QUERY,
|
|
1730
|
+
variables: { name },
|
|
1731
|
+
signal: ctx.signal
|
|
1733
1732
|
});
|
|
1734
1733
|
} catch (err) {
|
|
1735
1734
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1736
1735
|
throw new SuinsRpcError(name, msg);
|
|
1737
1736
|
}
|
|
1738
|
-
if (
|
|
1739
|
-
throw new SuinsRpcError(name,
|
|
1740
|
-
}
|
|
1741
|
-
let body;
|
|
1742
|
-
try {
|
|
1743
|
-
body = await res.json();
|
|
1744
|
-
} catch (err) {
|
|
1745
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1746
|
-
throw new SuinsRpcError(name, `JSON parse failed: ${msg}`);
|
|
1747
|
-
}
|
|
1748
|
-
if (body.error) {
|
|
1749
|
-
throw new SuinsRpcError(name, body.error.message);
|
|
1737
|
+
if (res.errors?.length) {
|
|
1738
|
+
throw new SuinsRpcError(name, res.errors.map((e) => e.message ?? "unknown error").join("; "));
|
|
1750
1739
|
}
|
|
1751
|
-
return
|
|
1740
|
+
return res.data?.address?.address ?? null;
|
|
1752
1741
|
}
|
|
1753
1742
|
async function resolveAddressToSuinsViaRpc(rawAddress, ctx = {}) {
|
|
1754
1743
|
const address = rawAddress.trim().toLowerCase();
|
|
1755
1744
|
if (!SUI_ADDRESS_REGEX.test(address)) {
|
|
1756
1745
|
throw new InvalidAddressError(rawAddress);
|
|
1757
1746
|
}
|
|
1758
|
-
const
|
|
1747
|
+
const gql = getSuiGraphQLClient();
|
|
1759
1748
|
let res;
|
|
1760
1749
|
try {
|
|
1761
|
-
res = await
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
jsonrpc: "2.0",
|
|
1766
|
-
id: 1,
|
|
1767
|
-
method: "suix_resolveNameServiceNames",
|
|
1768
|
-
params: [address]
|
|
1769
|
-
}),
|
|
1770
|
-
signal: ctx.signal ?? AbortSignal.timeout(8e3)
|
|
1750
|
+
res = await gql.query({
|
|
1751
|
+
query: REVERSE_NAME_QUERY,
|
|
1752
|
+
variables: { address },
|
|
1753
|
+
signal: ctx.signal
|
|
1771
1754
|
});
|
|
1772
1755
|
} catch (err) {
|
|
1773
1756
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1774
1757
|
throw new SuinsRpcError(address, msg);
|
|
1775
1758
|
}
|
|
1776
|
-
if (
|
|
1777
|
-
throw new SuinsRpcError(address,
|
|
1778
|
-
}
|
|
1779
|
-
let body;
|
|
1780
|
-
try {
|
|
1781
|
-
body = await res.json();
|
|
1782
|
-
} catch (err) {
|
|
1783
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1784
|
-
throw new SuinsRpcError(address, `JSON parse failed: ${msg}`);
|
|
1785
|
-
}
|
|
1786
|
-
if (body.error) {
|
|
1787
|
-
throw new SuinsRpcError(address, body.error.message);
|
|
1759
|
+
if (res.errors?.length) {
|
|
1760
|
+
throw new SuinsRpcError(address, res.errors.map((e) => e.message ?? "unknown error").join("; "));
|
|
1788
1761
|
}
|
|
1789
|
-
|
|
1762
|
+
const domain = res.data?.address?.defaultNameRecord?.domain;
|
|
1763
|
+
return domain ? [domain] : [];
|
|
1790
1764
|
}
|
|
1791
1765
|
async function normalizeAddressInput(value, ctx = {}) {
|
|
1792
1766
|
const trimmed = value.trim();
|