@needmoretruth/nmts-cli 0.50.0 → 0.52.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.ko.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/api.js +3 -0
  5. package/dist/artifact-about.d.ts +1 -1
  6. package/dist/client-id.d.ts +11 -0
  7. package/dist/client-id.js +30 -0
  8. package/dist/commands/mcp.js +3 -0
  9. package/dist/commands/wallet-activity.d.ts +10 -6
  10. package/dist/commands/wallet-activity.js +17 -6
  11. package/dist/env-vars.d.ts +1 -1
  12. package/dist/env-vars.js +1 -1
  13. package/dist/extend-chain.d.ts +4 -6
  14. package/dist/extend-chain.js +30 -28
  15. package/dist/net-retry.js +14 -0
  16. package/dist/portable.d.ts +2 -0
  17. package/dist/portable.js +2 -0
  18. package/dist/product.d.ts +1 -1
  19. package/dist/product.js +1 -1
  20. package/dist/reach.d.ts +1 -1
  21. package/dist/shared/lib/storage-control/chain.d.ts +30 -29
  22. package/dist/shared/lib/storage-control/chain.js +14 -20
  23. package/dist/shared/lib/wallet/activity.d.ts +42 -48
  24. package/dist/shared/lib/wallet/activity.js +51 -30
  25. package/dist/shared/lib/wallet/address-history.d.ts +42 -0
  26. package/dist/shared/lib/wallet/address-history.js +247 -0
  27. package/dist/shared/lib/wallet/chain-calls.d.ts +44 -0
  28. package/dist/shared/lib/wallet/chain-calls.js +59 -0
  29. package/dist/storage-control-chain.js +5 -4
  30. package/dist/sui-execute.d.ts +54 -0
  31. package/dist/sui-execute.js +43 -0
  32. package/dist/sui-rpc.d.ts +16 -9
  33. package/dist/sui-rpc.js +53 -19
  34. package/dist/upload-wallet-chain.d.ts +8 -3
  35. package/dist/upload-wallet-chain.js +33 -29
  36. package/dist/upload-wallet-plan.d.ts +1 -1
  37. package/dist/upload-wallet-put.js +1 -1
  38. package/dist/wallet-activity-chain.d.ts +2 -2
  39. package/dist/wallet-activity-chain.js +12 -27
  40. package/dist/wallet-chain.js +19 -13
  41. package/dist/wallet-list-chain.d.ts +1 -1
  42. package/dist/wallet-list-chain.js +13 -14
  43. package/dist/wallet-send-chain.js +4 -3
  44. package/dist/wallet-sign-external.d.ts +18 -25
  45. package/dist/wallet-sign-external.js +16 -19
  46. package/dist/wallet-sign.js +22 -70
  47. package/dist/wallet-storage-chain.js +2 -3
  48. package/dist/wallet-swap-chain.d.ts +3 -6
  49. package/dist/wallet-swap-chain.js +16 -16
  50. package/dist/wallet-swap-quote.js +16 -17
  51. package/dist/walrus-fresh.d.ts +8 -0
  52. package/dist/walrus-fresh.js +15 -0
  53. package/dist/walrus-write.js +6 -16
  54. package/dist/walrus.d.ts +13 -13
  55. package/dist/walrus.js +15 -15
  56. package/package.json +7 -4
  57. package/server.json +2 -2
  58. package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +11 -11
  59. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
  60. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +11 -11
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
3
3
  Each version's entry is what changed for the person or the program using `nmts`. The product's own
4
4
  update history, which covers the site and the server too, is at https://nmts.me/updates.
5
5
 
6
+ ## 0.52.0 — 2026-10-24
7
+
8
+ - `nmts` talks to Sui over gRPC-web instead of JSON-RPC, which Sui retired in October 2026. The
9
+ JSON-RPC nodes were gone on testnet by 21 October and on mainnet by 24 October, so every command
10
+ that reads or writes the chain had stopped working. Each
11
+ network now has two nodes, Suiscan and Mysten Labs, and the second is asked when the first does
12
+ not answer. A node you name in `NMTS_SUI_RPC` (or the SDK's `suiRpc`) must answer gRPC-web.
13
+ - `nmts wallet list` and `nmts wallet activity` ask one question per wallet where they asked two
14
+ (sent and received). A gRPC node keeps only the last few weeks of transactions, so history older
15
+ than that is read from Sui's GraphQL service. Before this, a wallet funded months ago and idle
16
+ since would have been listed as never used. If you named your own node, the GraphQL service is
17
+ not asked: `wallet list` then stops at a wallet it could not finish reading instead of calling it
18
+ unused, and `wallet activity` shows only what that node keeps.
19
+ - `nmts wallet activity` says when it could not read the older history, instead of printing "lists
20
+ no transaction" for a wallet that was only quiet lately. `--json` carries `complete: false` then.
21
+
22
+ ## 0.51.0 — 2026-10-21
23
+
24
+ - Every request now tells the NMTS server whether it came from the CLI or its MCP server, so the
25
+ public stats page can count use by client. The server keeps the count and nothing else.
26
+
27
+ ## 0.50.1 — 2026-10-20
28
+
29
+ - `nmts put` paying from your wallet into a storage resource the wallet already holds carried the
30
+ write price it read when the upload was reviewed, and paid exactly that at signing. If Walrus
31
+ storage nodes changed the price in between, the chain refused the registration before anything was
32
+ charged. The price is now read when the transaction is signed.
33
+
6
34
  ## 0.50.0 — 2026-10-01
7
35
 
8
36
  - `nmts create` can spend a one-time pass taken from the environment variable `NMTS_AGENT_PASS`. It
package/README.ko.md CHANGED
@@ -50,7 +50,7 @@ nmts --help
50
50
 
51
51
  ```sh
52
52
  npm install -g github:needmoretruth/nmts-cli # 기본 브랜치
53
- npm install -g github:needmoretruth/nmts-cli#v0.50.0 # 버전을 고정할 때
53
+ npm install -g github:needmoretruth/nmts-cli#v0.52.0 # 버전을 고정할 때
54
54
  npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
55
55
  ```
56
56
 
package/README.md CHANGED
@@ -51,7 +51,7 @@ default branch, from a pinned version, or from the tarball attached to the
51
51
 
52
52
  ```sh
53
53
  npm install -g github:needmoretruth/nmts-cli # the default branch
54
- npm install -g github:needmoretruth/nmts-cli#v0.50.0 # a pinned version
54
+ npm install -g github:needmoretruth/nmts-cli#v0.52.0 # a pinned version
55
55
  npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
56
56
  ```
57
57
 
package/dist/api.js CHANGED
@@ -11,6 +11,7 @@
11
11
  //
12
12
  // ⛔ THE TOKEN IS NEVER IN A MESSAGE, A URL OR A LOG. It goes in one header and nowhere else.
13
13
  import { adviseFor } from "./api-advice.js";
14
+ import { CLIENT_HEADER, clientHeaderValue } from "./client-id.js";
14
15
  import { NmtsError } from "./errors.js";
15
16
  import { isTransient, keepTrying } from "./net-retry.js";
16
17
  import { reachFetch } from "./reach.js";
@@ -150,6 +151,8 @@ async function once(base, path, options) {
150
151
  // which sees headers and never a body — which is why the proof is a header and not a field.
151
152
  if (options.accountProof !== undefined)
152
153
  headers["x-nmts-account-proof"] = options.accountProof;
154
+ // Which program this is, for the public use-by-client counts (`client-id.ts`). Not a credential.
155
+ headers[CLIENT_HEADER] = clientHeaderValue();
153
156
  let response;
154
157
  try {
155
158
  // ⛔ Built conditionally rather than passing `body: undefined`: with exactOptionalPropertyTypes
@@ -11,7 +11,7 @@ export declare const CRYPTO_SPEC_URL = "https://github.com/needmoretruth/nmts-re
11
11
  * is the field's own contract — what the writer says about itself — and a person holding two
12
12
  * copies of one account's artefacts can then tell which program made each.
13
13
  */
14
- export declare const WRITTEN_BY = "nmts-cli 0.50.0";
14
+ export declare const WRITTEN_BY = "nmts-cli 0.52.0";
15
15
  /** Which of the three artefacts a wrapper is. A reader holding several can sort them. */
16
16
  export type ArtifactKind = "recovery-list" | "file-list" | "recovery-kit";
17
17
  /**
@@ -0,0 +1,11 @@
1
+ /** The header's name, spelled once. The server's spelling is `api/src/usage/client.rs`. */
2
+ export declare const CLIENT_HEADER = "x-nmts-client";
3
+ /** The three programs that send it. Anything else the server counts as "other". */
4
+ export type ClientKind = "cli" | "mcp" | "sdk";
5
+ /**
6
+ * Say which program this process is. The MCP server calls it with `"mcp"`, and the SDK's entry
7
+ * points with `"sdk"` and the SDK's own version.
8
+ */
9
+ export declare function identifyClient(next: ClientKind, nextVersion?: string): void;
10
+ /** `cli/0.52.0`, `mcp/0.52.0`, `sdk/0.17.0`. */
11
+ export declare function clientHeaderValue(): string;
@@ -0,0 +1,30 @@
1
+ // Which program is talking to the NMTS server — the value of `x-nmts-client` on every request.
2
+ //
3
+ // ⛔ WHAT THE SERVER DOES WITH IT, AND NOTHING MORE. It counts, per UTC day, how many accounts used
4
+ // NMTS through the command line, its MCP server and the SDK, and publishes those counts on the
5
+ // public stats page. It keeps the counts and nothing else: no record of which account sent
6
+ // which value. It is not authentication and grants nothing — a request with a different value,
7
+ // or none, is served exactly the same.
8
+ //
9
+ // ⛔ ONLY ON REQUESTS TO THE NMTS SERVER. `api.ts` builds those and is the one place this is read;
10
+ // a storage network, an RPC node or a release page never sees it.
11
+ //
12
+ // ⚠ ONE VALUE PER PROCESS. A program that loads this package through the SDK is the SDK, and the
13
+ // command-line tool running as an MCP server is the MCP server, for every request either makes.
14
+ import { VERSION } from "./product.js";
15
+ /** The header's name, spelled once. The server's spelling is `api/src/usage/client.rs`. */
16
+ export const CLIENT_HEADER = "x-nmts-client";
17
+ let kind = "cli";
18
+ let version = VERSION;
19
+ /**
20
+ * Say which program this process is. The MCP server calls it with `"mcp"`, and the SDK's entry
21
+ * points with `"sdk"` and the SDK's own version.
22
+ */
23
+ export function identifyClient(next, nextVersion = VERSION) {
24
+ kind = next;
25
+ version = nextVersion;
26
+ }
27
+ /** `cli/0.52.0`, `mcp/0.52.0`, `sdk/0.17.0`. */
28
+ export function clientHeaderValue() {
29
+ return `${kind}/${version}`;
30
+ }
@@ -31,6 +31,7 @@
31
31
  import { existsSync, mkdirSync, statSync } from "node:fs";
32
32
  import { resolve } from "node:path";
33
33
  import { identityOf } from "../account.js";
34
+ import { identifyClient } from "../client-id.js";
34
35
  import { requireAccountCode } from "../code-access.js";
35
36
  import { API_KEY_ENV_VAR, CODE_ENV_VAR, readCredentialsFile, resolveApiKey } from "../credentials.js";
36
37
  import { NmtsError } from "../errors.js";
@@ -101,6 +102,8 @@ export function mcpToolSchemas() {
101
102
  return all.map((t) => ({ name: t.name, inputSchema: t.inputSchema }));
102
103
  }
103
104
  export async function mcp(options = {}) {
105
+ // Every request from here on is the MCP server's, before the first one leaves (`client-id.ts`).
106
+ identifyClient("mcp");
104
107
  const note = options.note ?? ((line) => process.stderr.write(`${line}\n`));
105
108
  // ⛔ NO PROMPT FROM HERE. stdin is the protocol; see `OpenOptions.allowPrompt`.
106
109
  //
@@ -1,12 +1,16 @@
1
1
  import { type Network } from "../network.ts";
2
- import { type ActivityContext, type RpcTransaction } from "../shared/lib/wallet/activity.ts";
3
- /** How many to ask for in each direction, and how many to print after the merge. */
4
- export declare const FETCH_PER_DIRECTION = 25;
2
+ import { type ActivityContext, type ChainTransaction } from "../shared/lib/wallet/activity.ts";
3
+ /** How many to ask for, and how many to print after the merge. */
4
+ export declare const FETCH = 25;
5
5
  export declare const SHOW = 20;
6
- /** The two lists the chain answers with. */
6
+ /** The list the chain answers with, newest first. */
7
7
  export interface ActivityFetch {
8
- sent: readonly RpcTransaction[];
9
- received: readonly RpcTransaction[];
8
+ transactions: readonly ChainTransaction[];
9
+ /**
10
+ * False when the history could not be read to the end — the node keeps a few weeks and the older
11
+ * part comes from Sui's GraphQL service, which may not answer. Absent counts as true.
12
+ */
13
+ complete?: boolean;
10
14
  }
11
15
  export interface WalletActivityOptions {
12
16
  server?: string | undefined;
@@ -1,6 +1,7 @@
1
1
  // `nmts wallet activity` — the recent transactions of the wallet this NMTS key derives.
2
2
  //
3
- // ⛔ IT READS. The chain is asked twice (sent, received — the RPC filter has no OR), the rows are
3
+ // ⛔ IT READS. The chain is asked once (every transaction that moved this address — the gRPC index's
4
+ // `affectedAddress`, since the JSON-RPC that needed two questions was retired), the rows are
4
5
  // named by the SAME judgement the browser uses (`shared/lib/wallet/activity.ts`, copied
5
6
  // byte-for-byte), and nothing here signs or spends.
6
7
  //
@@ -22,8 +23,8 @@ import { resolveServer } from "../server.js";
22
23
  import { mergeActivity, toActivityRow, } from "../shared/lib/wallet/activity.js";
23
24
  import { BLUEFIN_PACKAGE_IDS, DEEPBOOK_PACKAGE_IDS } from "../shared/lib/wallet/venue-ids.js";
24
25
  import { coinAmount, walCoinType, walletAddress } from "../wallet.js";
25
- /** How many to ask for in each direction, and how many to print after the merge. */
26
- export const FETCH_PER_DIRECTION = 25;
26
+ /** How many to ask for, and how many to print after the merge. */
27
+ export const FETCH = 25;
27
28
  export const SHOW = 20;
28
29
  /** What the judgement compares against on this network. Donation and pool addresses: unknown here. */
29
30
  export function activityContext(network, address) {
@@ -61,21 +62,31 @@ export async function walletActivity(options = {}) {
61
62
  });
62
63
  }
63
64
  const ctx = activityContext(network, address);
64
- const rows = mergeActivity([fetched.sent.map((tx) => toActivityRow(tx, ctx)), fetched.received.map((tx) => toActivityRow(tx, ctx))], SHOW);
65
+ const rows = mergeActivity([fetched.transactions.map((tx) => toActivityRow(tx, ctx))], SHOW);
66
+ const complete = fetched.complete !== false;
65
67
  if (options.json) {
66
- say(JSON.stringify({ address, network, shown: rows.length, rows: rows.map(asJson) }));
68
+ say(JSON.stringify({ address, network, shown: rows.length, complete, rows: rows.map(asJson) }));
67
69
  return 0;
68
70
  }
69
71
  say(`Address ${address}`);
70
72
  say(`Network ${network}`);
71
73
  say(``);
72
- if (rows.length === 0) {
74
+ // ⛔ "No transaction" is said only of a history read to the end; a short read says it is short.
75
+ if (rows.length === 0 && complete) {
73
76
  say(` The chain answered and lists no transaction for this wallet.`);
74
77
  }
78
+ else if (rows.length === 0) {
79
+ say(` No transaction in the last few weeks, and the older history could not be read just now.`);
80
+ }
75
81
  else {
76
82
  for (const row of rows)
77
83
  say(` ${inWords(row)}`);
78
84
  }
85
+ if (rows.length > 0 && !complete) {
86
+ say(``);
87
+ say(` The older history could not be read just now: transactions from more than a few weeks`);
88
+ say(` ago may be missing. Run this again to retry.`);
89
+ }
79
90
  say(``);
80
91
  say(` The newest ${SHOW} at most; the chain link on each line shows the rest. A name is put only`);
81
92
  say(` where the transaction proves it — the storage network's own calls, the two exchanges, a`);
@@ -16,7 +16,7 @@ export declare const AGGREGATOR_ENV_VAR = "NMTS_AGGREGATOR";
16
16
  * ⚠ ONE host, not a list. Unlike reads there is nothing to fail over to — see `RELAY_HOSTS`.
17
17
  */
18
18
  export declare const RELAY_ENV_VAR = "NMTS_RELAY";
19
- /** Ask a different Sui JSON-RPC node the shard-count question. */
19
+ /** Ask a different Sui node (one that answers gRPC-web) the chain questions. */
20
20
  export declare const SUI_RPC_ENV_VAR = "NMTS_SUI_RPC";
21
21
  /**
22
22
  * The one-time pass a person took on nmts.me/ai for their agent (D19g ⑥). `nmts create` spends it.
package/dist/env-vars.js CHANGED
@@ -23,7 +23,7 @@ export const AGGREGATOR_ENV_VAR = "NMTS_AGGREGATOR";
23
23
  * ⚠ ONE host, not a list. Unlike reads there is nothing to fail over to — see `RELAY_HOSTS`.
24
24
  */
25
25
  export const RELAY_ENV_VAR = "NMTS_RELAY";
26
- /** Ask a different Sui JSON-RPC node the shard-count question. */
26
+ /** Ask a different Sui node (one that answers gRPC-web) the chain questions. */
27
27
  export const SUI_RPC_ENV_VAR = "NMTS_SUI_RPC";
28
28
  /**
29
29
  * The one-time pass a person took on nmts.me/ai for their agent (D19g ⑥). `nmts create` spends it.
@@ -1,4 +1,3 @@
1
- import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
2
1
  import type { BlobLease, ExtendReads } from "./extend-plan.ts";
3
2
  /** How long one chain question gets. A read that stalls is a read that failed. */
4
3
  export declare const EXTEND_READ_TIMEOUT_MS = 20000;
@@ -12,14 +11,13 @@ export declare const EXTEND_READ_TIMEOUT_MS = 20000;
12
11
  export declare function walrusClient(network: string): ReturnType<typeof build>;
13
12
  declare function build(network: string): import("@mysten/sui/client").ClientWithExtensions<{
14
13
  walrus: import("@mysten/walrus").WalrusClient;
15
- }, SuiJsonRpcClient>;
14
+ }, import("@mysten/sui/grpc").SuiGrpcClient>;
16
15
  /**
17
16
  * One blob's lease, read from the Blob object itself.
18
17
  *
19
- * ⛔ NARROWED FROM `unknown`, NOT FROM THE SDK'S TYPE. `MoveStruct` is a three-way union whose
20
- * members do not all carry an index signature, so reading a field off it means asserting — and
21
- * an assertion compiles whether or not the check above it is right. What matters is the shape
22
- * on the wire, and the predicate in `guards.ts` is what carries that narrowing.
18
+ * ⛔ NARROWED FROM `unknown`. The node renders the Move struct as JSON (gRPC and GraphQL alike —
19
+ * measured on mainnet 2026-10-21: `size` a string, `storage.end_epoch` a number), and nothing about
20
+ * that rendering is promised by a type the compiler could check, so every field is read with a test.
23
21
  */
24
22
  export declare function readBlobLease(client: ReturnType<typeof build>, objectId: string): Promise<BlobLease>;
25
23
  /**
@@ -15,14 +15,15 @@
15
15
  // ⛔ AND NOTHING IS DEFAULTED TO ZERO. A lease that cannot be read, a shape the Move struct does
16
16
  // not have, a price the system object will not give — each throws with its reason. A cost of
17
17
  // zero on a screen that asks for money is the one wrong answer nobody would question.
18
- import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
18
+ import { ObjectError } from "@mysten/sui/client";
19
19
  import { walrus } from "@mysten/walrus";
20
20
  import { NmtsError } from "./errors.js";
21
21
  import { epochClock } from "./expiry.js";
22
- import { isRecord } from "./guards.js";
22
+ import { dryRun, objectFields } from "./shared/lib/wallet/chain-calls.js";
23
23
  import { epochStartedMs } from "./walrus-write.js";
24
24
  import { storageNodesThrough } from "./walrus.js";
25
- import { suiRpcTransport } from "./sui-rpc.js";
25
+ import { freshWalrus } from "./walrus-fresh.js";
26
+ import { suiClient } from "./sui-rpc.js";
26
27
  import { readBalances, walCoinType } from "./wallet.js";
27
28
  import { chainReader } from "./wallet-chain.js";
28
29
  import { Transaction } from "@mysten/sui/transactions";
@@ -39,10 +40,7 @@ export function walrusClient(network) {
39
40
  return build(network);
40
41
  }
41
42
  function build(network) {
42
- return new SuiJsonRpcClient({
43
- network: network === "mainnet" ? "mainnet" : "testnet",
44
- transport: suiRpcTransport(network),
45
- }).$extend(walrus(storageNodesThrough()));
43
+ return suiClient(network === "mainnet" ? "mainnet" : "testnet").$extend(walrus(storageNodesThrough()));
46
44
  }
47
45
  /** A number off the wire, whether it arrived as a number or as one of Sui's 64-bit strings. */
48
46
  function numberOf(value) {
@@ -56,30 +54,32 @@ function numberOf(value) {
56
54
  /**
57
55
  * One blob's lease, read from the Blob object itself.
58
56
  *
59
- * ⛔ NARROWED FROM `unknown`, NOT FROM THE SDK'S TYPE. `MoveStruct` is a three-way union whose
60
- * members do not all carry an index signature, so reading a field off it means asserting — and
61
- * an assertion compiles whether or not the check above it is right. What matters is the shape
62
- * on the wire, and the predicate in `guards.ts` is what carries that narrowing.
57
+ * ⛔ NARROWED FROM `unknown`. The node renders the Move struct as JSON (gRPC and GraphQL alike —
58
+ * measured on mainnet 2026-10-21: `size` a string, `storage.end_epoch` a number), and nothing about
59
+ * that rendering is promised by a type the compiler could check, so every field is read with a test.
63
60
  */
64
61
  export async function readBlobLease(client, objectId) {
65
- const response = await client.getObject({
66
- id: objectId,
67
- options: { showContent: true },
68
- });
69
- const data = isRecord(response) ? response["data"] : undefined;
70
- const content = isRecord(data) ? data["content"] : undefined;
71
- if (!isRecord(content) || content["dataType"] !== "moveObject") {
62
+ let fields;
63
+ try {
64
+ fields = await objectFields(client, objectId);
65
+ }
66
+ catch (error) {
67
+ // Only the node's own "no such object" is said as one; a node that did not answer is thrown
68
+ // as itself, because "deleted" and "unreachable" ask the person to do different things.
69
+ if (!(error instanceof ObjectError))
70
+ throw error;
71
+ fields = null;
72
+ }
73
+ if (fields === null) {
72
74
  throw new NmtsError(`The storage object ${objectId} could not be read from the chain.`, {
73
75
  exitCode: 1,
74
76
  nextStep: "Nothing was signed and nothing was charged. The blob may already have been deleted, or " +
75
77
  "this tool may be pointed at the wrong network — `nmts env` says which one it is using.",
76
78
  });
77
79
  }
78
- const fields = content["fields"];
79
- const storage = isRecord(fields) ? fields["storage"] : undefined;
80
- const storageFields = isRecord(storage) ? storage["fields"] : undefined;
81
- const size = numberOf(isRecord(fields) ? fields["size"] : undefined);
82
- const endEpoch = numberOf(isRecord(storageFields) ? storageFields["end_epoch"] : undefined);
80
+ const storage = fields["storage"];
81
+ const size = numberOf(fields["size"]);
82
+ const endEpoch = numberOf(typeof storage === "object" && storage !== null && "end_epoch" in storage ? storage.end_epoch : undefined);
83
83
  if (size === null || endEpoch === null) {
84
84
  // ⛔ A shape change in the Move struct surfaces HERE, not as a wrong price downstream.
85
85
  throw new NmtsError(`The storage object ${objectId} is not shaped the way this version reads.`, {
@@ -134,7 +134,8 @@ export function extendReads(network) {
134
134
  async quote(leases, epochs) {
135
135
  if (epochs <= 0 || leases.length === 0)
136
136
  return 0n;
137
- const costs = await Promise.all(leases.map((lease) => client.walrus.storageCost(lease.size, epochs)));
137
+ const fresh = freshWalrus(client);
138
+ const costs = await Promise.all(leases.map((lease) => fresh.storageCost(lease.size, epochs)));
138
139
  return costs.reduce((sum, cost) => sum + BigInt(cost.storageCost), 0n);
139
140
  },
140
141
  async readWallet(address) {
@@ -148,14 +149,15 @@ export function extendReads(network) {
148
149
  try {
149
150
  const tx = new Transaction();
150
151
  tx.setSender(sender);
152
+ const fresh = freshWalrus(client);
151
153
  for (const blobObjectId of [...new Set(objectIds)]) {
152
- tx.add(client.walrus.extendBlob({ blobObjectId, epochs }));
154
+ tx.add(fresh.extendBlob({ blobObjectId, epochs }));
153
155
  }
154
156
  const bytes = await tx.build({ client });
155
- const { effects } = await client.dryRunTransactionBlock({ transactionBlock: bytes });
156
- if (effects.status.status !== "success")
157
+ const { status, gasUsed } = await dryRun(client, bytes);
158
+ if (!status.success)
157
159
  return null;
158
- return netGasFee(effects.gasUsed);
160
+ return netGasFee(gasUsed);
159
161
  }
160
162
  catch {
161
163
  // Not a number, and not zero: "could not measure" is a different fact from "free".
package/dist/net-retry.js CHANGED
@@ -76,6 +76,20 @@ export function isTransient(error, status) {
76
76
  return status === 408 || status === 429 || status >= 500;
77
77
  if (!(error instanceof Error))
78
78
  return false;
79
+ // ⭐ 2026-10-21 — THE CHAIN IS gRPC NOW, and a gRPC error names what happened as a status word
80
+ // (`RpcError.code`). Only two of them mean "nobody answered": UNAVAILABLE and RESOURCE_EXHAUSTED
81
+ // (what a 503 and a 429 become). Every other status — NOT_FOUND, INVALID_ARGUMENT, a refused
82
+ // transaction — is the node ANSWERING. The failover `fetch` throws a last host's 5xx as
83
+ // "<host> → HTTP <n>", and the transport keeps that sentence as the message, so the number is
84
+ // read back out of it.
85
+ if (error.name === "RpcError") {
86
+ const code = Reflect.get(error, "code");
87
+ if (code === "UNAVAILABLE" || code === "RESOURCE_EXHAUSTED")
88
+ return true;
89
+ }
90
+ const http = /→ HTTP (\d{3})\b/.exec(error.message);
91
+ if (http?.[1] !== undefined)
92
+ return isTransient(null, Number(http[1]));
79
93
  // ⛔ A DEADLINE THAT FIRED IS NOT A BLIP. The request already had its thirty seconds; asking
80
94
  // again usually spends thirty more and ends the same way, and the deadline exists precisely so
81
95
  // that an agent loop is not left waiting. What comes back here as true is a connection that
@@ -9,6 +9,8 @@ export type { ZstdCodec } from "./shared/lib/drive/zstd.ts";
9
9
  export { NmtsError, NotLoggedInError, renderError } from "./errors.ts";
10
10
  export { request, ServerError, DEFAULT_TIMEOUT_MS } from "./api.ts";
11
11
  export type { RequestOptions, ServerRefusal } from "./api.ts";
12
+ export { CLIENT_HEADER, clientHeaderValue, identifyClient } from "./client-id.ts";
13
+ export type { ClientKind } from "./client-id.ts";
12
14
  export { DEFAULT_SERVER, SERVER_ENV_VAR, resolveServer } from "./server.ts";
13
15
  export { NETWORKS, NETWORK_ENV_VAR, resolveNetwork } from "./network.ts";
14
16
  export type { Network } from "./network.ts";
package/dist/portable.js CHANGED
@@ -32,6 +32,8 @@ export { setZstdCodec, zstdCodec, zstdContentSize } from "./shared/lib/drive/zst
32
32
  export { NmtsError, NotLoggedInError, renderError } from "./errors.js";
33
33
  // The server: one request function, and what a refusal looks like.
34
34
  export { request, ServerError, DEFAULT_TIMEOUT_MS } from "./api.js";
35
+ // Which program sends those requests (`x-nmts-client`) — the SDK says so on the way in.
36
+ export { CLIENT_HEADER, clientHeaderValue, identifyClient } from "./client-id.js";
35
37
  export { DEFAULT_SERVER, SERVER_ENV_VAR, resolveServer } from "./server.js";
36
38
  export { NETWORKS, NETWORK_ENV_VAR, resolveNetwork } from "./network.js";
37
39
  // The account: what a code derives, and the engine that derives it.
package/dist/product.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare const BINARY_NAME = "nmts";
9
9
  * beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
10
10
  * command importing the entry point is a cycle waiting to bite.
11
11
  */
12
- export declare const VERSION = "0.50.0";
12
+ export declare const VERSION = "0.52.0";
13
13
  /** Where the product lives, for messages that need to send somebody somewhere real. */
14
14
  export declare const HOME_URL = "https://nmts.me";
15
15
  /** The source, so a person holding only the built program can find what it was built from. */
package/dist/product.js CHANGED
@@ -18,7 +18,7 @@ export const BINARY_NAME = "nmts";
18
18
  * beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
19
19
  * command importing the entry point is a cycle waiting to bite.
20
20
  */
21
- export const VERSION = "0.50.0";
21
+ export const VERSION = "0.52.0";
22
22
  /** Where the product lives, for messages that need to send somebody somewhere real. */
23
23
  export const HOME_URL = "https://nmts.me";
24
24
  /** The source, so a person holding only the built program can find what it was built from. */
package/dist/reach.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface Reach {
8
8
  */
9
9
  relay?: string | undefined;
10
10
  /**
11
- * The Sui JSON-RPC endpoints to ask, in order, instead of the network's own.
11
+ * The Sui nodes to ask (over gRPC-web), in order, instead of the network's own.
12
12
  *
13
13
  * ⛔ IT REPLACES THE LIST rather than adding to it — somebody who names a node is saying *those*,
14
14
  * and quietly reaching a public mirror as well would send their traffic somewhere they did
@@ -1,33 +1,34 @@
1
1
  /**
2
- * The slice of a Sui RPC client this file uses. Structural on purpose: the browser hands in its
3
- * Walrus-extended client and the command-line tool its plain JSON-RPC client, and neither has to
4
- * be named here.
2
+ * The slice of a Sui client this file uses — its core API (`client.core`), which the gRPC and GraphQL
3
+ * clients both carry. Structural on purpose: the browser hands in its Walrus-extended client and the
4
+ * command-line tool its plain one, and neither has to be named here.
5
+ *
6
+ * ⛔ 2026-10-21 — this used to be JSON-RPC's `getObject` / `getOwnedObjects`, which Sui retired. The
7
+ * core API answers the same two questions; the object's fields now come as the node's JSON
8
+ * rendering of the struct (`json`), with no `content.fields` wrapper.
5
9
  */
6
10
  export interface StorageChainReader {
7
- getObject(input: {
8
- id: string;
9
- options: {
10
- showType: true;
11
- };
12
- }): Promise<{
13
- data?: {
14
- type?: string | null;
15
- } | null;
16
- }>;
17
- getOwnedObjects(input: {
18
- owner: string;
19
- filter: {
20
- StructType: string;
21
- };
22
- options: {
23
- showContent: true;
24
- };
25
- cursor?: string;
26
- }): Promise<{
27
- data?: readonly unknown[] | null;
28
- hasNextPage?: boolean;
29
- nextCursor?: string | null;
30
- }>;
11
+ core: {
12
+ getObject(input: {
13
+ objectId: string;
14
+ }): Promise<{
15
+ object: {
16
+ type: string;
17
+ };
18
+ }>;
19
+ listOwnedObjects(input: {
20
+ owner: string;
21
+ type: string;
22
+ include: {
23
+ json: true;
24
+ };
25
+ cursor?: string | null;
26
+ }): Promise<{
27
+ objects: readonly unknown[];
28
+ hasNextPage: boolean;
29
+ cursor: string | null;
30
+ }>;
31
+ };
31
32
  }
32
33
  /** One storage resource — the chain's `Storage { id, start_epoch, end_epoch, storage_size }` as is. */
33
34
  export interface StorageResource {
@@ -43,10 +44,10 @@ export interface StorageResource {
43
44
  /**
44
45
  * This network's storage-resource type name, derived from the system object.
45
46
  *
46
- * ⛔ `showType` only — the content is not needed, and asking for it returns a large answer.
47
+ * ⛔ The type only — the content is not needed, and asking for it returns a large answer.
47
48
  */
48
49
  export declare function readStorageType(client: StorageChainReader, systemObjectId: string): Promise<string>;
49
- /** One object response as a storage resource. A different shape gives null — it quietly leaves the list. */
50
+ /** One listed object as a storage resource. A different shape gives null — it quietly leaves the list. */
50
51
  export declare function toStorageResource(node: unknown): StorageResource | null;
51
52
  /**
52
53
  * Every storage resource this address holds.
@@ -21,29 +21,23 @@
21
21
  /**
22
22
  * This network's storage-resource type name, derived from the system object.
23
23
  *
24
- * ⛔ `showType` only — the content is not needed, and asking for it returns a large answer.
24
+ * ⛔ The type only — the content is not needed, and asking for it returns a large answer.
25
25
  */
26
26
  export async function readStorageType(client, systemObjectId) {
27
- const res = await client.getObject({ id: systemObjectId, options: { showType: true } });
28
- const type = res.data?.type;
27
+ const { object } = await client.core.getObject({ objectId: systemObjectId });
28
+ const type = object.type;
29
29
  if (typeof type !== "string" || !type.includes("::")) {
30
30
  throw new Error("The storage network's system object did not say its type.");
31
31
  }
32
32
  return `${type.split("::")[0]}::storage_resource::Storage`;
33
33
  }
34
- /** One object response as a storage resource. A different shape gives null — it quietly leaves the list. */
34
+ /** One listed object as a storage resource. A different shape gives null — it quietly leaves the list. */
35
35
  export function toStorageResource(node) {
36
36
  if (typeof node !== "object" || node === null)
37
37
  return null;
38
- const data = Reflect.get(node, "data");
39
- if (typeof data !== "object" || data === null)
40
- return null;
41
- const objectId = Reflect.get(data, "objectId");
42
- const content = Reflect.get(data, "content");
43
- if (typeof objectId !== "string" || typeof content !== "object" || content === null)
44
- return null;
45
- const fields = Reflect.get(content, "fields");
46
- if (typeof fields !== "object" || fields === null)
38
+ const objectId = Reflect.get(node, "objectId");
39
+ const fields = Reflect.get(node, "json");
40
+ if (typeof objectId !== "string" || typeof fields !== "object" || fields === null)
47
41
  return null;
48
42
  const start = Number(Reflect.get(fields, "start_epoch"));
49
43
  const end = Number(Reflect.get(fields, "end_epoch"));
@@ -62,20 +56,20 @@ export async function readOwnedStorage(client, owner, storageType, maxPages = 20
62
56
  const out = [];
63
57
  let cursor = null;
64
58
  for (let page = 0; page < maxPages; page += 1) {
65
- const res = await client.getOwnedObjects({
59
+ const res = await client.core.listOwnedObjects({
66
60
  owner,
67
- filter: { StructType: storageType },
68
- options: { showContent: true },
69
- ...(cursor === null ? {} : { cursor }),
61
+ type: storageType,
62
+ include: { json: true },
63
+ cursor,
70
64
  });
71
- for (const node of res.data ?? []) {
65
+ for (const node of res.objects) {
72
66
  const one = toStorageResource(node);
73
67
  if (one !== null)
74
68
  out.push(one);
75
69
  }
76
- if (res.hasNextPage !== true || typeof res.nextCursor !== "string")
70
+ if (!res.hasNextPage || res.cursor === null)
77
71
  return out;
78
- cursor = res.nextCursor;
72
+ cursor = res.cursor;
79
73
  }
80
74
  // ⛔ Hitting the page ceiling is SAID. Cutting quietly would make the screen claim "this is all".
81
75
  throw new Error("Too many storage resources to read in one go.");