@needmoretruth/nmts-cli 0.54.0 → 0.54.2
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/CHANGELOG.md +15 -0
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/client-id.d.ts +1 -1
- package/dist/client-id.js +1 -1
- package/dist/commands/push.js +5 -1
- package/dist/commands/put-wallet.js +5 -1
- package/dist/commands/put.js +5 -1
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/shared/lib/wallet/address-history.d.ts +1 -14
- package/dist/shared/lib/wallet/address-history.js +22 -107
- package/dist/shared/lib/wallet/graphql-history.d.ts +25 -0
- package/dist/shared/lib/wallet/graphql-history.js +136 -0
- package/dist/upload-road.d.ts +33 -0
- package/dist/upload-road.js +93 -0
- package/dist/upload-wallet-chain.js +7 -1
- package/dist/upload-wire.d.ts +2 -1
- package/dist/upload.js +5 -5
- package/dist/walrus-write.js +6 -4
- package/dist/walrus.d.ts +3 -0
- package/dist/walrus.js +3 -0
- package/package.json +1 -1
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
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.54.2 — 2026-11-09
|
|
7
|
+
|
|
8
|
+
- When Mysten Labs' upload relay does not answer, uploads (`put`, `push`) now go through NMTS's own
|
|
9
|
+
relay on the NMTS server instead of failing. On that road a file is sent in parts of at most
|
|
10
|
+
64 MiB, one at a time. Each part carries Walrus's fixed cost per blob, so a large file costs up to
|
|
11
|
+
about 20% more, and the price the review shows already counts those parts. While the relay carries
|
|
12
|
+
another upload, the next one waits and then goes.
|
|
13
|
+
|
|
14
|
+
## 0.54.1 — 2026-11-09
|
|
15
|
+
|
|
16
|
+
- `nmts wallet activity` and `nmts wallet list` no longer stop with an error when a Sui node refuses
|
|
17
|
+
the history read with a message the tool has not seen before: any refusal or failure that leaves
|
|
18
|
+
history unread now moves the read to Sui GraphQL, which has a second operator (01NODE) when Mysten
|
|
19
|
+
Labs does not answer.
|
|
20
|
+
|
|
6
21
|
## 0.54.0 — 2026-11-08
|
|
7
22
|
|
|
8
23
|
- `put --pay wallet --sui-key-file <file>` pays for the upload from another Sui wallet you hold, read
|
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.54.
|
|
53
|
+
npm install -g github:needmoretruth/nmts-cli#v0.54.2 # 버전을 고정할 때
|
|
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.54.
|
|
54
|
+
npm install -g github:needmoretruth/nmts-cli#v0.54.2 # 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/artifact-about.d.ts
CHANGED
|
@@ -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.54.
|
|
14
|
+
export declare const WRITTEN_BY = "nmts-cli 0.54.2";
|
|
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
|
/**
|
package/dist/client-id.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export type ClientKind = "cli" | "mcp" | "sdk";
|
|
|
7
7
|
* points with `"sdk"` and the SDK's own version.
|
|
8
8
|
*/
|
|
9
9
|
export declare function identifyClient(next: ClientKind, nextVersion?: string): void;
|
|
10
|
-
/** `cli/0.54.
|
|
10
|
+
/** `cli/0.54.2`, `mcp/0.54.1`, `sdk/0.17.0`. */
|
|
11
11
|
export declare function clientHeaderValue(): string;
|
package/dist/client-id.js
CHANGED
|
@@ -24,7 +24,7 @@ export function identifyClient(next, nextVersion = VERSION) {
|
|
|
24
24
|
kind = next;
|
|
25
25
|
version = nextVersion;
|
|
26
26
|
}
|
|
27
|
-
/** `cli/0.54.
|
|
27
|
+
/** `cli/0.54.2`, `mcp/0.54.1`, `sdk/0.17.0`. */
|
|
28
28
|
export function clientHeaderValue() {
|
|
29
29
|
return `${kind}/${version}`;
|
|
30
30
|
}
|
package/dist/commands/push.js
CHANGED
|
@@ -32,6 +32,7 @@ import { fileSource } from "../upload-file-node.js";
|
|
|
32
32
|
import { createUploadApi } from "../upload-api.js";
|
|
33
33
|
import { clearItemRecord, clearReservation } from "../upload-store.js";
|
|
34
34
|
import { CREDIT_BYTES, partSizeFor, planAndPrice, UPLOAD_EPOCHS } from "../upload-price.js";
|
|
35
|
+
import { chooseUploadRoad, partSizeForRoad } from "../upload-road.js";
|
|
35
36
|
import { createBlobProtocol, readCurrentEpoch } from "../walrus-write.js";
|
|
36
37
|
import { ensureFolderPath } from "../drive-edit.js";
|
|
37
38
|
import { payerOf, refuseWalletOnlyOptions } from "./put.js";
|
|
@@ -70,7 +71,10 @@ export async function push(target, options = {}) {
|
|
|
70
71
|
return 0;
|
|
71
72
|
}
|
|
72
73
|
const session = await openSession({ server: options.server, network: options.network });
|
|
73
|
-
|
|
74
|
+
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
75
|
+
// quoted below are the credits of those parts.
|
|
76
|
+
await chooseUploadRoad({ network: session.network, server: session.server, apiKey: session.apiKey });
|
|
77
|
+
const partSize = partSizeForRoad(partSizeFor(options.partSize));
|
|
74
78
|
// ⛔ READ BEFORE ANYTHING IS SEALED OR PAID FOR — a typo must not surface after the money.
|
|
75
79
|
const asked = parseAsked(options.onCollision);
|
|
76
80
|
const list = await readFileList(session.server, session.apiKey, session.code, session.accountId);
|
|
@@ -31,6 +31,7 @@ import { stderrSink } from "../progress-node.js";
|
|
|
31
31
|
import { resolveServer } from "../server.js";
|
|
32
32
|
import { fileSource } from "../upload-file-node.js";
|
|
33
33
|
import { partSizeFor } from "../upload-price.js";
|
|
34
|
+
import { chooseUploadRoad, partSizeForRoad } from "../upload-road.js";
|
|
34
35
|
import { measureLocal } from "../upload-price-node.js";
|
|
35
36
|
import { downloadForRefill, findOriginal, settleRefill } from "../refill-source.js";
|
|
36
37
|
import { describeUploadReview } from "../upload-wallet-plan.js";
|
|
@@ -60,6 +61,9 @@ export async function putWithWallet(target, options) {
|
|
|
60
61
|
const stored = readCredentialsFile();
|
|
61
62
|
const server = resolveServer(options.server ?? stored?.server);
|
|
62
63
|
const network = resolveNetwork(server, options.network ?? stored?.network);
|
|
64
|
+
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
65
|
+
// quoted below are the credits of those parts.
|
|
66
|
+
await chooseUploadRoad({ network, server, apiKey: key.key });
|
|
63
67
|
const identity = await identityOf(resolved.code);
|
|
64
68
|
const crypt = await loadCrypto();
|
|
65
69
|
const asked = parseAsked(options.onCollision);
|
|
@@ -84,7 +88,7 @@ export async function putWithWallet(target, options) {
|
|
|
84
88
|
network,
|
|
85
89
|
accountId: identity.accountId,
|
|
86
90
|
crypt,
|
|
87
|
-
partSize: partSizeFor(options.partSize),
|
|
91
|
+
partSize: partSizeForRoad(partSizeFor(options.partSize)),
|
|
88
92
|
rule,
|
|
89
93
|
onCollision: asked,
|
|
90
94
|
settings: list.manifest?.settings,
|
package/dist/commands/put.js
CHANGED
|
@@ -14,6 +14,7 @@ import { basename, resolve } from "node:path";
|
|
|
14
14
|
import { identityOf } from "../account.js";
|
|
15
15
|
import { requireAccountCode } from "../code-access.js";
|
|
16
16
|
import { API_KEY_ENV_VAR, CODE_ENV_VAR, readCredentialsFile, resolveApiKey } from "../credentials.js";
|
|
17
|
+
import { chooseUploadRoad, partSizeForRoad } from "../upload-road.js";
|
|
17
18
|
import { parseAsked } from "../collision.js";
|
|
18
19
|
import { depositDefaultOf, depositLines, parseDeposit, refuseDepositWithWallet } from "../deposit.js";
|
|
19
20
|
import { DERIVED, loadCrypto } from "../crypto.js";
|
|
@@ -103,10 +104,13 @@ export async function put(target, options = {}) {
|
|
|
103
104
|
}
|
|
104
105
|
const localPath = resolve(target);
|
|
105
106
|
const size = measureLocal(localPath);
|
|
106
|
-
const partSize = partSizeFor(options.partSize);
|
|
107
107
|
const stored = readCredentialsFile();
|
|
108
108
|
const server = resolveServer(options.server ?? stored?.server);
|
|
109
109
|
const network = resolveNetwork(server, options.network ?? stored?.network);
|
|
110
|
+
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
111
|
+
// quoted below are the credits of those parts.
|
|
112
|
+
await chooseUploadRoad({ network, server, apiKey: key.key });
|
|
113
|
+
const partSize = partSizeForRoad(partSizeFor(options.partSize));
|
|
110
114
|
const identity = await identityOf(resolved.code);
|
|
111
115
|
const crypt = await loadCrypto();
|
|
112
116
|
const [from, to] = DERIVED.dataKey;
|
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.54.
|
|
12
|
+
export declare const VERSION = "0.54.2";
|
|
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.54.
|
|
21
|
+
export const VERSION = "0.54.2";
|
|
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. */
|
|
@@ -13,13 +13,6 @@ export interface AddressHistory {
|
|
|
13
13
|
}
|
|
14
14
|
/** Where history older than the node's window is read: the newest `limit` rows, newest first. */
|
|
15
15
|
export type DeeperHistory = (address: string, limit: number, signal?: AbortSignal) => Promise<HistoryTransaction[]>;
|
|
16
|
-
/**
|
|
17
|
-
* Sui's public GraphQL service per network (Mysten Labs). Measured 2026-10-21: the `affectedAddress`
|
|
18
|
-
* filter answered back to 2023 on both networks, in 0.2–0.9 s, with `access-control-allow-origin: *`.
|
|
19
|
-
* It is the only public operator of it, so it is the second tier and never the only one: a failure
|
|
20
|
-
* here leaves the answer `complete: false`, never "nothing there".
|
|
21
|
-
*/
|
|
22
|
-
export declare const SUI_GRAPHQL_URLS: Readonly<Record<"mainnet" | "testnet", string>>;
|
|
23
16
|
/**
|
|
24
17
|
* How far above a node's lowest checkpoint a read starts, at most. Mainnet seals about four
|
|
25
18
|
* checkpoints a second, so 20,000 is over an hour of pruning before the start falls out of the window
|
|
@@ -53,10 +46,4 @@ export declare function addressTransactions(client: Pick<SuiGrpcClient, "ledgerS
|
|
|
53
46
|
* tell" and "nothing is there" are opposite facts, and only the second may answer `false`.
|
|
54
47
|
*/
|
|
55
48
|
export declare function hasAddressHistory(client: Pick<SuiGrpcClient, "ledgerService">, address: string, signal?: AbortSignal, deeper?: DeeperHistory | null): Promise<boolean>;
|
|
56
|
-
|
|
57
|
-
* The deeper source over Sui's GraphQL service at `url`.
|
|
58
|
-
*
|
|
59
|
-
* ⛔ Anything but a clean answer throws — an error list, a missing page, a row of the wrong shape.
|
|
60
|
-
* The caller turns that into `complete: false`; it never becomes an empty history.
|
|
61
|
-
*/
|
|
62
|
-
export declare function graphqlHistory(url: string, fetchFn?: (input: string, init: RequestInit) => Promise<Response>): DeeperHistory;
|
|
49
|
+
export { graphqlHistory, SUI_GRAPHQL_URLS } from "./graphql-history.ts";
|
|
@@ -37,16 +37,6 @@
|
|
|
37
37
|
// ⚠ It needs the gRPC client: the filter is a raw ledger-service filter, which the SDK's top-level
|
|
38
38
|
// `listTransactions` does not offer (it filters by sender or function only).
|
|
39
39
|
import { GrpcTypes, parseGrpcTransactionResponse } from "@mysten/sui/grpc";
|
|
40
|
-
/**
|
|
41
|
-
* Sui's public GraphQL service per network (Mysten Labs). Measured 2026-10-21: the `affectedAddress`
|
|
42
|
-
* filter answered back to 2023 on both networks, in 0.2–0.9 s, with `access-control-allow-origin: *`.
|
|
43
|
-
* It is the only public operator of it, so it is the second tier and never the only one: a failure
|
|
44
|
-
* here leaves the answer `complete: false`, never "nothing there".
|
|
45
|
-
*/
|
|
46
|
-
export const SUI_GRAPHQL_URLS = {
|
|
47
|
-
mainnet: "https://graphql.mainnet.sui.io/graphql",
|
|
48
|
-
testnet: "https://graphql.testnet.sui.io/graphql",
|
|
49
|
-
};
|
|
50
40
|
/** How many requests one question may take before it answers with what it has. */
|
|
51
41
|
const MAX_REQUESTS = 8;
|
|
52
42
|
/**
|
|
@@ -186,10 +176,17 @@ async function recentTransactions(client, address, limit, signal) {
|
|
|
186
176
|
break;
|
|
187
177
|
}
|
|
188
178
|
catch (e) {
|
|
189
|
-
|
|
179
|
+
// A read the caller called off is called off; it is not a node failing.
|
|
180
|
+
if (signal?.aborted === true)
|
|
190
181
|
throw e;
|
|
191
|
-
// ⛔
|
|
192
|
-
//
|
|
182
|
+
// ⛔ ANY OTHER REFUSAL LEAVES THE NODE'S PART UNREAD, AND THE DEEPER SOURCE IS ASKED (2026-11-09). This
|
|
183
|
+
// used to throw on a refusal whose wording it did not know, so one changed sentence in a
|
|
184
|
+
// node's reply emptied every wallet's activity again (as on 2026-11-05); a node with no connection
|
|
185
|
+
// did the same. What the node could not give is what GraphQL is for. A window no start can
|
|
186
|
+
// hit (Suiscan's testnet replicas disagreed by more than its 54 checkpoints, 2026-11-07)
|
|
187
|
+
// ends the same way.
|
|
188
|
+
if (!learnWindow(client, e))
|
|
189
|
+
return { transactions, fromGenesis: false, failed: e };
|
|
193
190
|
if (attempt >= MAX_WINDOW_RETRIES)
|
|
194
191
|
return { transactions, fromGenesis: false };
|
|
195
192
|
}
|
|
@@ -229,13 +226,21 @@ export async function addressTransactions(client, address, limit, signal, deeper
|
|
|
229
226
|
const recent = await recentTransactions(client, address, limit, signal);
|
|
230
227
|
if (recent.fromGenesis)
|
|
231
228
|
return { transactions: recent.transactions, complete: true };
|
|
232
|
-
|
|
229
|
+
// ⛔ A node that failed and gave nothing, with nobody else to answer, is "could not read", not a
|
|
230
|
+
// partial list: the screen says it failed rather than "older history is missing" over no rows.
|
|
231
|
+
const unread = recent.failed !== undefined && recent.transactions.length === 0;
|
|
232
|
+
if (deeper === null) {
|
|
233
|
+
if (unread)
|
|
234
|
+
throw recent.failed;
|
|
233
235
|
return { transactions: recent.transactions, complete: false };
|
|
236
|
+
}
|
|
234
237
|
try {
|
|
235
238
|
const older = await deeper(address, limit, signal);
|
|
236
239
|
return { transactions: mergeNewestFirst(recent.transactions, older, limit), complete: true };
|
|
237
240
|
}
|
|
238
|
-
catch {
|
|
241
|
+
catch (e) {
|
|
242
|
+
if (unread)
|
|
243
|
+
throw recent.failed ?? e;
|
|
239
244
|
// The node's rows stand; the answer says plainly that it is not the whole history.
|
|
240
245
|
return { transactions: recent.transactions, complete: false };
|
|
241
246
|
}
|
|
@@ -252,95 +257,5 @@ export async function hasAddressHistory(client, address, signal, deeper = null)
|
|
|
252
257
|
throw new Error(`The chain did not finish looking for transactions of ${address}.`);
|
|
253
258
|
return false;
|
|
254
259
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return value;
|
|
258
|
-
}
|
|
259
|
-
if (Array.isArray(value)) {
|
|
260
|
-
const out = [];
|
|
261
|
-
for (const item of value) {
|
|
262
|
-
const json = asJson(item);
|
|
263
|
-
if (json === undefined)
|
|
264
|
-
return undefined;
|
|
265
|
-
out.push(json);
|
|
266
|
-
}
|
|
267
|
-
return out;
|
|
268
|
-
}
|
|
269
|
-
if (typeof value === "object") {
|
|
270
|
-
const out = {};
|
|
271
|
-
for (const [key, item] of Object.entries(value)) {
|
|
272
|
-
const json = asJson(item);
|
|
273
|
-
if (json === undefined)
|
|
274
|
-
return undefined;
|
|
275
|
-
out[key] = json;
|
|
276
|
-
}
|
|
277
|
-
return out;
|
|
278
|
-
}
|
|
279
|
-
return undefined;
|
|
280
|
-
}
|
|
281
|
-
const objectAt = (json) => json !== null && typeof json === "object" && !Array.isArray(json) ? json : undefined;
|
|
282
|
-
const QUERY = `query ($address: SuiAddress!, $last: Int!) {
|
|
283
|
-
transactions(last: $last, filter: { affectedAddress: $address }) {
|
|
284
|
-
nodes { digest transactionJson effects { status timestamp checkpoint { sequenceNumber } balanceChangesJson } }
|
|
285
|
-
}
|
|
286
|
-
}`;
|
|
287
|
-
/** One GraphQL row as the gRPC message the shared parser reads. `undefined` when its shape is off. */
|
|
288
|
-
function executedFromGraphql(node) {
|
|
289
|
-
const effects = objectAt(node["effects"]);
|
|
290
|
-
const digest = node["digest"];
|
|
291
|
-
const transactionJson = objectAt(node["transactionJson"]);
|
|
292
|
-
const timestamp = effects?.["timestamp"];
|
|
293
|
-
const checkpoint = objectAt(effects?.["checkpoint"])?.["sequenceNumber"];
|
|
294
|
-
const changes = effects?.["balanceChangesJson"];
|
|
295
|
-
if (typeof digest !== "string" || transactionJson === undefined || effects === undefined)
|
|
296
|
-
return undefined;
|
|
297
|
-
const ms = typeof timestamp === "string" ? Date.parse(timestamp) : Number.NaN;
|
|
298
|
-
const options = { ignoreUnknownFields: true };
|
|
299
|
-
return GrpcTypes.ExecutedTransaction.create({
|
|
300
|
-
digest,
|
|
301
|
-
transaction: GrpcTypes.Transaction.fromJson(transactionJson, options),
|
|
302
|
-
effects: GrpcTypes.TransactionEffects.create({ status: { success: effects["status"] === "SUCCESS" } }),
|
|
303
|
-
...(Number.isFinite(ms) ? { timestamp: { seconds: BigInt(Math.floor(ms / 1000)), nanos: (ms % 1000) * 1_000_000 } } : {}),
|
|
304
|
-
...(typeof checkpoint === "number" ? { checkpoint: BigInt(checkpoint) } : {}),
|
|
305
|
-
balanceChanges: Array.isArray(changes) ? changes.map((c) => GrpcTypes.BalanceChange.fromJson(c, options)) : [],
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* The deeper source over Sui's GraphQL service at `url`.
|
|
310
|
-
*
|
|
311
|
-
* ⛔ Anything but a clean answer throws — an error list, a missing page, a row of the wrong shape.
|
|
312
|
-
* The caller turns that into `complete: false`; it never becomes an empty history.
|
|
313
|
-
*/
|
|
314
|
-
export function graphqlHistory(url, fetchFn = (input, init) => fetch(input, init)) {
|
|
315
|
-
return async (address, limit, signal) => {
|
|
316
|
-
const res = await fetchFn(url, {
|
|
317
|
-
method: "POST",
|
|
318
|
-
headers: { "content-type": "application/json" },
|
|
319
|
-
body: JSON.stringify({ query: QUERY, variables: { address, last: limit } }),
|
|
320
|
-
...(signal === undefined ? {} : { signal }),
|
|
321
|
-
});
|
|
322
|
-
if (!res.ok)
|
|
323
|
-
throw new Error(`The history service answered HTTP ${res.status}.`);
|
|
324
|
-
const body = await res.json();
|
|
325
|
-
const top = objectAt(asJson(body));
|
|
326
|
-
if (top === undefined || top["errors"] !== undefined) {
|
|
327
|
-
throw new Error("The history service answered with an error.");
|
|
328
|
-
}
|
|
329
|
-
const nodes = objectAt(objectAt(top["data"])?.["transactions"])?.["nodes"];
|
|
330
|
-
if (!Array.isArray(nodes))
|
|
331
|
-
throw new Error("The history service answered without a list.");
|
|
332
|
-
const rows = [];
|
|
333
|
-
// `last: n` arrives oldest-first; the list here is newest-first.
|
|
334
|
-
for (const node of [...nodes].reverse()) {
|
|
335
|
-
const row = objectAt(node);
|
|
336
|
-
const executed = row === undefined ? undefined : executedFromGraphql(row);
|
|
337
|
-
if (executed === undefined)
|
|
338
|
-
throw new Error("The history service answered a row this build cannot read.");
|
|
339
|
-
const parsed = parseGrpcTransactionResponse(executed, { include: { transaction: true, balanceChanges: true } });
|
|
340
|
-
const tx = parsed.Transaction ?? parsed.FailedTransaction;
|
|
341
|
-
if (tx !== undefined)
|
|
342
|
-
rows.push(tx);
|
|
343
|
-
}
|
|
344
|
-
return rows;
|
|
345
|
-
};
|
|
346
|
-
}
|
|
260
|
+
// The deeper source (Sui's GraphQL services) lives in `graphql-history.ts`; both names stay importable here.
|
|
261
|
+
export { graphqlHistory, SUI_GRAPHQL_URLS } from "./graphql-history.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DeeperHistory } from "./address-history.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Sui's public GraphQL services per network, in the order they are asked. Measured 2026-10-21 for
|
|
4
|
+
* Mysten Labs: the `affectedAddress` filter answered back to 2023 on both networks, in 0.2–0.9 s,
|
|
5
|
+
* with `access-control-allow-origin: *`.
|
|
6
|
+
*
|
|
7
|
+
* ⭐ A SECOND OPERATOR ON MAINNET (2026-11-09). Until then Mysten Labs was the only one and a
|
|
8
|
+
* failure there left every wallet's older history unread. 01NODE Funding SRL (Bucharest, Romania,
|
|
9
|
+
* its own network) runs a public mainnet GraphQL at `sui.01.ro`; measured that day from this machine:
|
|
10
|
+
* the same query and the same rows as Mysten's (the treasury's oldest transaction, 2026-08-02),
|
|
11
|
+
* checkpoints back to 2023, `access-control-allow-origin: *`, 1.3 s. Triton One's `rpcpool` answered
|
|
12
|
+
* too; it is not used because its company is not one the Privacy Policy names. Testnet keeps one
|
|
13
|
+
* operator: development has no second public GraphQL and no one's activity depends on it.
|
|
14
|
+
* Still the second tier and never the only one: when every service fails the answer is
|
|
15
|
+
* `complete: false`, never "nothing there".
|
|
16
|
+
*/
|
|
17
|
+
export declare const SUI_GRAPHQL_URLS: Readonly<Record<"mainnet" | "testnet", readonly string[]>>;
|
|
18
|
+
/**
|
|
19
|
+
* The deeper source over Sui's GraphQL services at `urls`, asked in order until one answers cleanly.
|
|
20
|
+
*
|
|
21
|
+
* ⛔ Anything but a clean answer from a service moves to the next — an error list, a missing page, a
|
|
22
|
+
* row of the wrong shape, no connection; when none answers it throws. The caller turns that into
|
|
23
|
+
* `complete: false`; it never becomes an empty history. A call the caller aborted is not retried.
|
|
24
|
+
*/
|
|
25
|
+
export declare function graphqlHistory(urls: string | readonly string[], fetchFn?: (input: string, init: RequestInit) => Promise<Response>): DeeperHistory;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The deeper source of `address-history.ts`: a wallet's history from Sui's public GraphQL services,
|
|
2
|
+
// for what a gRPC node no longer keeps or could not give. ⚠ PUBLISHED — copied byte-for-byte into
|
|
3
|
+
// the `nmts` command-line package; keep comments self-contained English.
|
|
4
|
+
//
|
|
5
|
+
// ⛔ Its rows are read by the SAME parser as the node's: GraphQL's `transactionJson` and
|
|
6
|
+
// `balanceChangesJson` are the gRPC messages written as JSON, so one row means one thing whichever
|
|
7
|
+
// service gave it.
|
|
8
|
+
import { GrpcTypes, parseGrpcTransactionResponse } from "@mysten/sui/grpc";
|
|
9
|
+
/**
|
|
10
|
+
* Sui's public GraphQL services per network, in the order they are asked. Measured 2026-10-21 for
|
|
11
|
+
* Mysten Labs: the `affectedAddress` filter answered back to 2023 on both networks, in 0.2–0.9 s,
|
|
12
|
+
* with `access-control-allow-origin: *`.
|
|
13
|
+
*
|
|
14
|
+
* ⭐ A SECOND OPERATOR ON MAINNET (2026-11-09). Until then Mysten Labs was the only one and a
|
|
15
|
+
* failure there left every wallet's older history unread. 01NODE Funding SRL (Bucharest, Romania,
|
|
16
|
+
* its own network) runs a public mainnet GraphQL at `sui.01.ro`; measured that day from this machine:
|
|
17
|
+
* the same query and the same rows as Mysten's (the treasury's oldest transaction, 2026-08-02),
|
|
18
|
+
* checkpoints back to 2023, `access-control-allow-origin: *`, 1.3 s. Triton One's `rpcpool` answered
|
|
19
|
+
* too; it is not used because its company is not one the Privacy Policy names. Testnet keeps one
|
|
20
|
+
* operator: development has no second public GraphQL and no one's activity depends on it.
|
|
21
|
+
* Still the second tier and never the only one: when every service fails the answer is
|
|
22
|
+
* `complete: false`, never "nothing there".
|
|
23
|
+
*/
|
|
24
|
+
export const SUI_GRAPHQL_URLS = {
|
|
25
|
+
mainnet: ["https://graphql.mainnet.sui.io/graphql", "https://sui.01.ro/graphql"],
|
|
26
|
+
testnet: ["https://graphql.testnet.sui.io/graphql"],
|
|
27
|
+
};
|
|
28
|
+
function asJson(value) {
|
|
29
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
const out = [];
|
|
34
|
+
for (const item of value) {
|
|
35
|
+
const json = asJson(item);
|
|
36
|
+
if (json === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
out.push(json);
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === "object") {
|
|
43
|
+
const out = {};
|
|
44
|
+
for (const [key, item] of Object.entries(value)) {
|
|
45
|
+
const json = asJson(item);
|
|
46
|
+
if (json === undefined)
|
|
47
|
+
return undefined;
|
|
48
|
+
out[key] = json;
|
|
49
|
+
}
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const objectAt = (json) => json !== null && typeof json === "object" && !Array.isArray(json) ? json : undefined;
|
|
55
|
+
const QUERY = `query ($address: SuiAddress!, $last: Int!) {
|
|
56
|
+
transactions(last: $last, filter: { affectedAddress: $address }) {
|
|
57
|
+
nodes { digest transactionJson effects { status timestamp checkpoint { sequenceNumber } balanceChangesJson } }
|
|
58
|
+
}
|
|
59
|
+
}`;
|
|
60
|
+
/** One GraphQL row as the gRPC message the shared parser reads. `undefined` when its shape is off. */
|
|
61
|
+
function executedFromGraphql(node) {
|
|
62
|
+
const effects = objectAt(node["effects"]);
|
|
63
|
+
const digest = node["digest"];
|
|
64
|
+
const transactionJson = objectAt(node["transactionJson"]);
|
|
65
|
+
const timestamp = effects?.["timestamp"];
|
|
66
|
+
const checkpoint = objectAt(effects?.["checkpoint"])?.["sequenceNumber"];
|
|
67
|
+
const changes = effects?.["balanceChangesJson"];
|
|
68
|
+
if (typeof digest !== "string" || transactionJson === undefined || effects === undefined)
|
|
69
|
+
return undefined;
|
|
70
|
+
const ms = typeof timestamp === "string" ? Date.parse(timestamp) : Number.NaN;
|
|
71
|
+
const options = { ignoreUnknownFields: true };
|
|
72
|
+
return GrpcTypes.ExecutedTransaction.create({
|
|
73
|
+
digest,
|
|
74
|
+
transaction: GrpcTypes.Transaction.fromJson(transactionJson, options),
|
|
75
|
+
effects: GrpcTypes.TransactionEffects.create({ status: { success: effects["status"] === "SUCCESS" } }),
|
|
76
|
+
...(Number.isFinite(ms) ? { timestamp: { seconds: BigInt(Math.floor(ms / 1000)), nanos: (ms % 1000) * 1_000_000 } } : {}),
|
|
77
|
+
...(typeof checkpoint === "number" ? { checkpoint: BigInt(checkpoint) } : {}),
|
|
78
|
+
balanceChanges: Array.isArray(changes) ? changes.map((c) => GrpcTypes.BalanceChange.fromJson(c, options)) : [],
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The deeper source over Sui's GraphQL services at `urls`, asked in order until one answers cleanly.
|
|
83
|
+
*
|
|
84
|
+
* ⛔ Anything but a clean answer from a service moves to the next — an error list, a missing page, a
|
|
85
|
+
* row of the wrong shape, no connection; when none answers it throws. The caller turns that into
|
|
86
|
+
* `complete: false`; it never becomes an empty history. A call the caller aborted is not retried.
|
|
87
|
+
*/
|
|
88
|
+
export function graphqlHistory(urls, fetchFn = (input, init) => fetch(input, init)) {
|
|
89
|
+
const list = typeof urls === "string" ? [urls] : urls;
|
|
90
|
+
return async (address, limit, signal) => {
|
|
91
|
+
let last = new Error("No history service is configured.");
|
|
92
|
+
for (const url of list) {
|
|
93
|
+
try {
|
|
94
|
+
return await graphqlRows(url, fetchFn, address, limit, signal);
|
|
95
|
+
}
|
|
96
|
+
catch (e) {
|
|
97
|
+
if (signal?.aborted === true)
|
|
98
|
+
throw e;
|
|
99
|
+
last = e;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
throw last;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** One GraphQL service's newest `limit` rows for `address`, newest first; throws on anything unclean. */
|
|
106
|
+
async function graphqlRows(url, fetchFn, address, limit, signal) {
|
|
107
|
+
const res = await fetchFn(url, {
|
|
108
|
+
method: "POST",
|
|
109
|
+
headers: { "content-type": "application/json" },
|
|
110
|
+
body: JSON.stringify({ query: QUERY, variables: { address, last: limit } }),
|
|
111
|
+
...(signal === undefined ? {} : { signal }),
|
|
112
|
+
});
|
|
113
|
+
if (!res.ok)
|
|
114
|
+
throw new Error(`The history service answered HTTP ${res.status}.`);
|
|
115
|
+
const body = await res.json();
|
|
116
|
+
const top = objectAt(asJson(body));
|
|
117
|
+
if (top === undefined || top["errors"] !== undefined) {
|
|
118
|
+
throw new Error("The history service answered with an error.");
|
|
119
|
+
}
|
|
120
|
+
const nodes = objectAt(objectAt(top["data"])?.["transactions"])?.["nodes"];
|
|
121
|
+
if (!Array.isArray(nodes))
|
|
122
|
+
throw new Error("The history service answered without a list.");
|
|
123
|
+
const rows = [];
|
|
124
|
+
// `last: n` arrives oldest-first; the list here is newest-first.
|
|
125
|
+
for (const node of [...nodes].reverse()) {
|
|
126
|
+
const row = objectAt(node);
|
|
127
|
+
const executed = row === undefined ? undefined : executedFromGraphql(row);
|
|
128
|
+
if (executed === undefined)
|
|
129
|
+
throw new Error("The history service answered a row this build cannot read.");
|
|
130
|
+
const parsed = parseGrpcTransactionResponse(executed, { include: { transaction: true, balanceChanges: true } });
|
|
131
|
+
const tx = parsed.Transaction ?? parsed.FailedTransaction;
|
|
132
|
+
if (tx !== undefined)
|
|
133
|
+
rows.push(tx);
|
|
134
|
+
}
|
|
135
|
+
return rows;
|
|
136
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Where the own relay answers, after the NMTS server's address. */
|
|
2
|
+
export declare const OWN_RELAY_PATH = "/v1/relay";
|
|
3
|
+
/** The part size on the own road: an existing preset, the size whose relay peak fits the server. */
|
|
4
|
+
export declare const OWN_RELAY_PART_BYTES: number;
|
|
5
|
+
/** How long Mysten's relay gets to answer before this run takes the own road. */
|
|
6
|
+
export declare const ROAD_PROBE_TIMEOUT_MS = 10000;
|
|
7
|
+
/** True for the own relay's address on any NMTS server. */
|
|
8
|
+
export declare function isOwnRelay(relayUrl: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Decide this run's road, once, before anything is priced. True when the own road was taken.
|
|
11
|
+
*
|
|
12
|
+
* `probe` is the request that asks Mysten's relay (tests pass a fake one).
|
|
13
|
+
*/
|
|
14
|
+
export declare function chooseUploadRoad(input: {
|
|
15
|
+
network: string;
|
|
16
|
+
server: string;
|
|
17
|
+
apiKey: string;
|
|
18
|
+
probe?: typeof fetch;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
}): Promise<boolean>;
|
|
21
|
+
/** Forget the choice (tests; a library caller between runs). */
|
|
22
|
+
export declare function resetUploadRoad(): void;
|
|
23
|
+
/** The relay this run writes through: the own one when it was chosen, else the usual one. */
|
|
24
|
+
export declare function uploadRelay(network: string): string;
|
|
25
|
+
/** The part size a fresh upload uses: unchanged on Mysten's road, at most 64 MiB on ours. */
|
|
26
|
+
export declare function partSizeForRoad(partSize: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* The fetch the relay client uses. On the own road it carries this account's key, and while another
|
|
29
|
+
* upload holds the relay (503 with `Retry-After`) it waits and asks again until the SDK's own
|
|
30
|
+
* timeout ends it. On Mysten's road it is `inner` unchanged.
|
|
31
|
+
*/
|
|
32
|
+
export type RelayFetch = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
33
|
+
export declare function relayFetch(relayUrl: string, inner: RelayFetch, sleep?: (ms: number, signal?: AbortSignal | null) => Promise<void>): RelayFetch;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NMTS's own upload relay — the second road for uploads from this tool (D50, 2026-11-09).
|
|
3
|
+
*
|
|
4
|
+
* ⛔ WHY. Every upload reached Walrus through Mysten Labs' relay alone; the day it stops answering,
|
|
5
|
+
* nobody can upload. NMTS runs the same relay software (Mysten's image, no tip) behind its own
|
|
6
|
+
* api at `/v1/relay`. This tool asks Mysten's relay once, before anything is priced, and takes
|
|
7
|
+
* the own road only when that relay refuses or does not answer. A relay the caller or the
|
|
8
|
+
* environment named is never second-guessed.
|
|
9
|
+
*
|
|
10
|
+
* ⛔ CHOSEN BEFORE THE PRICE. The own relay holds about five times a blob in memory (measured
|
|
11
|
+
* 2026-11-09: 64 MiB → 354 MiB peak), so on that road a file is cut into 64 MiB parts, and the
|
|
12
|
+
* credits quoted are the credits of those parts. A road chosen after a quote would charge a number
|
|
13
|
+
* nobody was shown; this module is asked first and the part size follows from its answer.
|
|
14
|
+
*
|
|
15
|
+
* The same path and part size as the browser's (`web/src/lib/walrus/own-relay.ts`); the route
|
|
16
|
+
* table (`deploy/core-routes.json`) names both.
|
|
17
|
+
*/
|
|
18
|
+
import { reachFetch } from "./reach.js";
|
|
19
|
+
import { RELAY_HOSTS, relayHost } from "./walrus.js";
|
|
20
|
+
/** Where the own relay answers, after the NMTS server's address. */
|
|
21
|
+
export const OWN_RELAY_PATH = "/v1/relay";
|
|
22
|
+
/** The part size on the own road: an existing preset, the size whose relay peak fits the server. */
|
|
23
|
+
export const OWN_RELAY_PART_BYTES = 64 * 2 ** 20;
|
|
24
|
+
/** How long Mysten's relay gets to answer before this run takes the own road. */
|
|
25
|
+
export const ROAD_PROBE_TIMEOUT_MS = 10_000;
|
|
26
|
+
let chosen = null;
|
|
27
|
+
/** True for the own relay's address on any NMTS server. */
|
|
28
|
+
export function isOwnRelay(relayUrl) {
|
|
29
|
+
return relayUrl.replace(/\/+$/, "").endsWith(OWN_RELAY_PATH);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Decide this run's road, once, before anything is priced. True when the own road was taken.
|
|
33
|
+
*
|
|
34
|
+
* `probe` is the request that asks Mysten's relay (tests pass a fake one).
|
|
35
|
+
*/
|
|
36
|
+
export async function chooseUploadRoad(input) {
|
|
37
|
+
chosen = null;
|
|
38
|
+
const known = RELAY_HOSTS[input.network]?.[0];
|
|
39
|
+
// A caller or an environment that named a relay chose it; nothing is asked.
|
|
40
|
+
if (known === undefined || relayHost(input.network) !== known)
|
|
41
|
+
return false;
|
|
42
|
+
const probe = input.probe ?? reachFetch;
|
|
43
|
+
try {
|
|
44
|
+
const res = await probe(`${known}/v1/tip-config`, {
|
|
45
|
+
signal: AbortSignal.timeout(input.timeoutMs ?? ROAD_PROBE_TIMEOUT_MS),
|
|
46
|
+
});
|
|
47
|
+
if (res.ok)
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// No answer: the own road below.
|
|
52
|
+
}
|
|
53
|
+
chosen = { relayUrl: `${input.server.replace(/\/+$/, "")}${OWN_RELAY_PATH}`, apiKey: input.apiKey };
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
/** Forget the choice (tests; a library caller between runs). */
|
|
57
|
+
export function resetUploadRoad() {
|
|
58
|
+
chosen = null;
|
|
59
|
+
}
|
|
60
|
+
/** The relay this run writes through: the own one when it was chosen, else the usual one. */
|
|
61
|
+
export function uploadRelay(network) {
|
|
62
|
+
return chosen?.relayUrl ?? relayHost(network);
|
|
63
|
+
}
|
|
64
|
+
/** The part size a fresh upload uses: unchanged on Mysten's road, at most 64 MiB on ours. */
|
|
65
|
+
export function partSizeForRoad(partSize) {
|
|
66
|
+
return chosen === null ? partSize : Math.min(partSize, OWN_RELAY_PART_BYTES);
|
|
67
|
+
}
|
|
68
|
+
const wait = (ms, signal) => new Promise((resolve, reject) => {
|
|
69
|
+
if (signal?.aborted)
|
|
70
|
+
return reject(signal.reason);
|
|
71
|
+
const timer = setTimeout(resolve, ms);
|
|
72
|
+
signal?.addEventListener("abort", () => {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
reject(signal.reason);
|
|
75
|
+
}, { once: true });
|
|
76
|
+
});
|
|
77
|
+
export function relayFetch(relayUrl, inner, sleep = wait) {
|
|
78
|
+
const road = chosen;
|
|
79
|
+
if (road === null || road.relayUrl !== relayUrl)
|
|
80
|
+
return inner;
|
|
81
|
+
return async (input, init) => {
|
|
82
|
+
const headers = new Headers(init?.headers);
|
|
83
|
+
headers.set("authorization", `Bearer ${road.apiKey}`);
|
|
84
|
+
for (;;) {
|
|
85
|
+
const res = await inner(input, { ...init, headers });
|
|
86
|
+
const after = res.headers.get("retry-after");
|
|
87
|
+
if (res.status !== 503 || after === null)
|
|
88
|
+
return res;
|
|
89
|
+
const seconds = Number(after);
|
|
90
|
+
await sleep(Math.max(1, Number.isFinite(seconds) ? seconds : 15) * 1000, init?.signal);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -26,6 +26,7 @@ import { reachFetch } from "./reach.js";
|
|
|
26
26
|
import { readOwnedStorage, readStorageType } from "./shared/lib/storage-control/chain.js";
|
|
27
27
|
import { registerIntoStorage, splitStorageToFit } from "./shared/lib/storage-control/reuse.js";
|
|
28
28
|
import { dryRun, inspect, u64FromLe } from "./shared/lib/wallet/chain-calls.js";
|
|
29
|
+
import { isOwnRelay, relayFetch } from "./upload-road.js";
|
|
29
30
|
import { storageNodesThrough } from "./walrus.js";
|
|
30
31
|
import { freshWalrus } from "./walrus-fresh.js";
|
|
31
32
|
import { suiClient } from "./sui-rpc.js";
|
|
@@ -50,7 +51,12 @@ export function packageConfig(network) {
|
|
|
50
51
|
function build(network, relayUrl) {
|
|
51
52
|
return suiClient(network).$extend(walrus({
|
|
52
53
|
...storageNodesThrough(),
|
|
53
|
-
uploadRelay: {
|
|
54
|
+
uploadRelay: {
|
|
55
|
+
host: relayUrl,
|
|
56
|
+
// The own relay (D50) takes no tip: no tip is paid and none is announced.
|
|
57
|
+
...(isOwnRelay(relayUrl) ? {} : { sendTip: { max: RELAY_TIP_CEILING_MIST[network] } }),
|
|
58
|
+
fetch: relayFetch(relayUrl, reachFetch),
|
|
59
|
+
},
|
|
54
60
|
}));
|
|
55
61
|
}
|
|
56
62
|
/** A Walrus client bound to ONE relay, able to pay that relay's tip. */
|
package/dist/upload-wire.d.ts
CHANGED
|
@@ -62,11 +62,12 @@ export interface UploadApi {
|
|
|
62
62
|
* already been told, which is how a screen and a ledger come to disagree.
|
|
63
63
|
*/
|
|
64
64
|
deposit_credits: number;
|
|
65
|
+
/** Null on NMTS's own relay, which takes no tip (D50). */
|
|
65
66
|
relay: {
|
|
66
67
|
host: string;
|
|
67
68
|
blob_digest_b64: string;
|
|
68
69
|
nonce_b64: string;
|
|
69
|
-
};
|
|
70
|
+
} | null;
|
|
70
71
|
}): Promise<ReserveReply>;
|
|
71
72
|
status(ledgerId: number): Promise<StatusReply>;
|
|
72
73
|
uploaded(ledgerId: number, certificate: Certificate): Promise<unknown>;
|
package/dist/upload.js
CHANGED
|
@@ -32,6 +32,7 @@ import { ServerError } from "./api.js";
|
|
|
32
32
|
import { readReservationBytes, readReservationRecord, writeReservation, } from "./upload-store.js";
|
|
33
33
|
import { refuseOtherSealing, runIdField } from "./upload-run.js";
|
|
34
34
|
import { pushPart } from "./upload-steps.js";
|
|
35
|
+
import { isOwnRelay } from "./upload-road.js";
|
|
35
36
|
import { UploadError, } from "./upload-wire.js";
|
|
36
37
|
export * from "./upload-wire.js";
|
|
37
38
|
/** A reservation state that can still become storage. Anything else is dead. */
|
|
@@ -201,11 +202,10 @@ export async function buyAndPushPart(input) {
|
|
|
201
202
|
size: sealed.length,
|
|
202
203
|
epochs: input.epochs,
|
|
203
204
|
deposit_credits: input.depositCredits,
|
|
204
|
-
relay
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
nonce_b64: nonceB64,
|
|
208
|
-
},
|
|
205
|
+
// The own relay (D50) takes no tip, so the treasury registers without one.
|
|
206
|
+
relay: isOwnRelay(input.relayUrl)
|
|
207
|
+
? null
|
|
208
|
+
: { host: input.relayUrl, blob_digest_b64: toBase64Url(meta.blobDigest), nonce_b64: nonceB64 },
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
catch (error) {
|
package/dist/walrus-write.js
CHANGED
|
@@ -17,7 +17,8 @@ import { epochStartedMs as readEpochStart } from "./shared/lib/extend/epochs.js"
|
|
|
17
17
|
import { NmtsError } from "./errors.js";
|
|
18
18
|
import { countingFetch } from "./progress.js";
|
|
19
19
|
import { reachFetch } from "./reach.js";
|
|
20
|
-
import {
|
|
20
|
+
import { isOwnRelay, relayFetch, uploadRelay } from "./upload-road.js";
|
|
21
|
+
import { storageNodesThrough } from "./walrus.js";
|
|
21
22
|
import { suiClient } from "./sui-rpc.js";
|
|
22
23
|
/**
|
|
23
24
|
* How long the relay gets for one blob PUT, sized to the body.
|
|
@@ -50,7 +51,8 @@ function extend(network, relayUrl, bodyBytes, onSent) {
|
|
|
50
51
|
...storageNodesThrough(),
|
|
51
52
|
uploadRelay: {
|
|
52
53
|
host: relayUrl,
|
|
53
|
-
|
|
54
|
+
// The own relay (D50) takes no tip, so it is not told which transaction paid one.
|
|
55
|
+
...(isOwnRelay(relayUrl) ? {} : { sendTip: { max: TIP_CEILING_UNUSED_MIST } }),
|
|
54
56
|
timeout: relayTimeoutMs(bodyBytes),
|
|
55
57
|
// ⛔ THE ONLY WAY TO SEE AN UPLOAD MOVE. The SDK does not report progress, and the relay
|
|
56
58
|
// PUT is the one step of an upload that takes real time — a person watching a large
|
|
@@ -59,7 +61,7 @@ function extend(network, relayUrl, bodyBytes, onSent) {
|
|
|
59
61
|
//
|
|
60
62
|
// ⛔ AND EITHER WAY IT IS THE CALLER'S `fetch`: the counting wrapper goes through it too,
|
|
61
63
|
// so the request that carries the file cannot be the one that misses a proxy.
|
|
62
|
-
fetch: onSent ? countingFetch(onSent) : reachFetch,
|
|
64
|
+
fetch: relayFetch(relayUrl, onSent ? countingFetch(onSent) : reachFetch),
|
|
63
65
|
},
|
|
64
66
|
}));
|
|
65
67
|
}
|
|
@@ -73,7 +75,7 @@ function fail(what, error) {
|
|
|
73
75
|
* is the only phase of one that anything can report on.
|
|
74
76
|
*/
|
|
75
77
|
export function createBlobProtocol(network, bodyBytes, onSent) {
|
|
76
|
-
const relayUrl =
|
|
78
|
+
const relayUrl = uploadRelay(network);
|
|
77
79
|
const client = extend(network, relayUrl, bodyBytes, onSent);
|
|
78
80
|
return {
|
|
79
81
|
relayUrl,
|
package/dist/walrus.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ export declare const AGGREGATOR_HOSTS: Readonly<Record<string, readonly string[]
|
|
|
15
15
|
* register transaction the server pays a tip in, so the bytes have to go to the SAME host the
|
|
16
16
|
* reservation was made for. That is why a write picks its host BEFORE the storage is bought and
|
|
17
17
|
* then never moves: failing over to a second relay would push bytes nobody paid that relay for.
|
|
18
|
+
*
|
|
19
|
+
* ⭐ THE SECOND ROAD IS NOT A ROW HERE (D50): NMTS's own no-tip relay on the NMTS server, chosen once
|
|
20
|
+
* at the start of a run, before the price, only when this one does not answer (`upload-road.ts`).
|
|
18
21
|
*/
|
|
19
22
|
export declare const RELAY_HOSTS: Readonly<Record<string, readonly string[]>>;
|
|
20
23
|
/**
|
package/dist/walrus.js
CHANGED
|
@@ -40,6 +40,9 @@ export const AGGREGATOR_HOSTS = {
|
|
|
40
40
|
* register transaction the server pays a tip in, so the bytes have to go to the SAME host the
|
|
41
41
|
* reservation was made for. That is why a write picks its host BEFORE the storage is bought and
|
|
42
42
|
* then never moves: failing over to a second relay would push bytes nobody paid that relay for.
|
|
43
|
+
*
|
|
44
|
+
* ⭐ THE SECOND ROAD IS NOT A ROW HERE (D50): NMTS's own no-tip relay on the NMTS server, chosen once
|
|
45
|
+
* at the start of a run, before the price, only when this one does not answer (`upload-road.ts`).
|
|
43
46
|
*/
|
|
44
47
|
export const RELAY_HOSTS = {
|
|
45
48
|
testnet: ["https://upload-relay.testnet.walrus.space"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needmoretruth/nmts-cli",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.2",
|
|
4
4
|
"description": "Command-line and MCP access to NMTS (NeedMoreTruthStorage, https://nmts.me): open-source, end-to-end encrypted storage on the Walrus network. No fee to NMTS; you pay the network from your own wallet. For people and for their agents.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
package/server.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"url": "https://github.com/needmoretruth/nmts-cli",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.54.
|
|
9
|
+
"version": "0.54.2",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
14
14
|
"identifier": "@needmoretruth/nmts-cli",
|
|
15
|
-
"version": "0.54.
|
|
15
|
+
"version": "0.54.2",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|