@toon-protocol/rig 2.10.0 → 2.10.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/dist/{chunk-B5ISARMU.js → chunk-35ALWUDJ.js} +10 -2
- package/dist/chunk-35ALWUDJ.js.map +1 -0
- package/dist/{chunk-FQXNLPUR.js → chunk-57UY3OGX.js} +5 -5
- package/dist/{chunk-PG5PUKDR.js → chunk-EEUHZNWS.js} +7 -3
- package/dist/chunk-EEUHZNWS.js.map +1 -0
- package/dist/{chunk-MKCF2OY2.js → chunk-JILCXMID.js} +41 -11
- package/dist/chunk-JILCXMID.js.map +1 -0
- package/dist/{chunk-RALCZLP6.js → chunk-R7G5NYQJ.js} +33 -42
- package/dist/chunk-R7G5NYQJ.js.map +1 -0
- package/dist/cli/rig.js +22 -11
- package/dist/cli/rig.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -2
- package/dist/{network-bootstrap-GRBEPZMI.js → network-bootstrap-KQLKALBI.js} +2 -10
- package/dist/{publisher-BvDfjvHK.d.ts → publisher-ftQeZSib.d.ts} +22 -2
- package/dist/standalone/index.d.ts +35 -4
- package/dist/standalone/index.js +3 -3
- package/dist/{standalone-mode-6KIBWGLP.js → standalone-mode-CTQKDJBL.js} +35 -7
- package/dist/standalone-mode-CTQKDJBL.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-B5ISARMU.js.map +0 -1
- package/dist/chunk-MKCF2OY2.js.map +0 -1
- package/dist/chunk-PG5PUKDR.js.map +0 -1
- package/dist/chunk-RALCZLP6.js.map +0 -1
- package/dist/standalone-mode-6KIBWGLP.js.map +0 -1
- /package/dist/{chunk-FQXNLPUR.js.map → chunk-57UY3OGX.js.map} +0 -0
- /package/dist/{network-bootstrap-GRBEPZMI.js.map → network-bootstrap-KQLKALBI.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as GitObjectType, P as Publisher, F as FeeRates, b as PublishReceipt } from './publisher-
|
|
2
|
-
export { C as COMMENT_KIND, d as GitObject, G as GitObjectUpload, M as MAINTAINERS_TAG, e as MAX_OBJECT_SIZE, R as REPOSITORY_STATE_KIND, S as StatusKind, U as UnsignedEvent, a as UploadReceipt, f as authorizedStatusAuthors, g as buildComment, h as buildIssue, i as buildPatch, j as buildRepoAnnouncement, k as buildRepoRefs, l as buildStatus, m as createGitBlob, n as createGitCommit, o as createGitTag, p as createGitTree, q as
|
|
1
|
+
import { c as GitObjectType, P as Publisher, F as FeeRates, b as PublishReceipt } from './publisher-ftQeZSib.js';
|
|
2
|
+
export { C as COMMENT_KIND, d as GitObject, G as GitObjectUpload, M as MAINTAINERS_TAG, e as MAX_OBJECT_SIZE, R as REPOSITORY_STATE_KIND, S as StatusKind, U as UnsignedEvent, a as UploadReceipt, f as authorizedStatusAuthors, g as buildComment, h as buildIssue, i as buildPatch, j as buildRepoAnnouncement, k as buildRepoRefs, l as buildStatus, m as createGitBlob, n as createGitCommit, o as createGitTag, p as createGitTree, q as flooredUploadFee, r as hashGitObject, s as parseMaintainers } from './publisher-ftQeZSib.js';
|
|
3
3
|
import '@toon-protocol/core/nip34';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -659,7 +659,7 @@ interface PushFeeEstimate {
|
|
|
659
659
|
objectCount: number;
|
|
660
660
|
/** Total bytes across all planned object bodies. */
|
|
661
661
|
totalObjectBytes: number;
|
|
662
|
-
/** Σ size × uploadFeePerByte
|
|
662
|
+
/** Σ max(size × uploadFeePerByte, minUploadFee) — smallest asset unit. */
|
|
663
663
|
uploadFee: bigint;
|
|
664
664
|
/** Number of events to publish (refs event + announcement on first push). */
|
|
665
665
|
eventCount: number;
|
|
@@ -853,7 +853,7 @@ interface GitEstimateRequest {
|
|
|
853
853
|
interface GitFeeEstimate {
|
|
854
854
|
objectCount: number;
|
|
855
855
|
totalObjectBytes: number;
|
|
856
|
-
/** Σ size × uploadFeePerByte. */
|
|
856
|
+
/** Σ max(size × uploadFeePerByte, per-upload route-price floor). */
|
|
857
857
|
uploadFee: string;
|
|
858
858
|
/** Events to publish (refs event + announcement on first push). */
|
|
859
859
|
eventCount: number;
|
package/dist/index.js
CHANGED
|
@@ -27,15 +27,16 @@ import {
|
|
|
27
27
|
walkClosure,
|
|
28
28
|
writeGitObject,
|
|
29
29
|
writeGitObjects
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-EEUHZNWS.js";
|
|
31
31
|
import {
|
|
32
32
|
MAX_OBJECT_SIZE,
|
|
33
33
|
createGitBlob,
|
|
34
34
|
createGitCommit,
|
|
35
35
|
createGitTag,
|
|
36
36
|
createGitTree,
|
|
37
|
+
flooredUploadFee,
|
|
37
38
|
hashGitObject
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-35ALWUDJ.js";
|
|
39
40
|
import {
|
|
40
41
|
COMMENT_KIND,
|
|
41
42
|
MAINTAINERS_TAG,
|
|
@@ -79,6 +80,7 @@ export {
|
|
|
79
80
|
executePush,
|
|
80
81
|
fetchRemoteState,
|
|
81
82
|
fetchTxBytes,
|
|
83
|
+
flooredUploadFee,
|
|
82
84
|
hashGitObject,
|
|
83
85
|
hexToNpub,
|
|
84
86
|
isSafeRefname,
|
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DEVNET_CHAIN_RPC_URLS,
|
|
3
|
-
DEVNET_ZONE,
|
|
4
2
|
DISCOVERY_TIMEOUT_MS,
|
|
5
3
|
ILP_PEER_INFO_KIND,
|
|
6
4
|
SolanaChannelUnderivableError,
|
|
7
5
|
TokenNetworkUnderivableError,
|
|
8
|
-
devnetChainRpcUrl,
|
|
9
6
|
discoverAnnouncedPeers,
|
|
10
7
|
evmChainIdOf,
|
|
11
8
|
evmPresetForChain,
|
|
12
9
|
evmTokenBalance,
|
|
13
10
|
genesisSeedPubkeys,
|
|
14
|
-
isDevnetZonePeer,
|
|
15
11
|
loadGenesisSeed,
|
|
16
12
|
pickPaymentPeer,
|
|
17
13
|
resolveChainSettlement,
|
|
18
14
|
selectSettlementChain,
|
|
19
15
|
solanaPresetForChain,
|
|
20
16
|
solanaTokenBalance
|
|
21
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-R7G5NYQJ.js";
|
|
22
18
|
import "./chunk-3HRFDH7H.js";
|
|
23
19
|
export {
|
|
24
|
-
DEVNET_CHAIN_RPC_URLS,
|
|
25
|
-
DEVNET_ZONE,
|
|
26
20
|
DISCOVERY_TIMEOUT_MS,
|
|
27
21
|
ILP_PEER_INFO_KIND,
|
|
28
22
|
SolanaChannelUnderivableError,
|
|
29
23
|
TokenNetworkUnderivableError,
|
|
30
|
-
devnetChainRpcUrl,
|
|
31
24
|
discoverAnnouncedPeers,
|
|
32
25
|
evmChainIdOf,
|
|
33
26
|
evmPresetForChain,
|
|
34
27
|
evmTokenBalance,
|
|
35
28
|
genesisSeedPubkeys,
|
|
36
|
-
isDevnetZonePeer,
|
|
37
29
|
loadGenesisSeed,
|
|
38
30
|
pickPaymentPeer,
|
|
39
31
|
resolveChainSettlement,
|
|
@@ -41,4 +33,4 @@ export {
|
|
|
41
33
|
solanaPresetForChain,
|
|
42
34
|
solanaTokenBalance
|
|
43
35
|
};
|
|
44
|
-
//# sourceMappingURL=network-bootstrap-
|
|
36
|
+
//# sourceMappingURL=network-bootstrap-KQLKALBI.js.map
|
|
@@ -285,9 +285,29 @@ interface PublishReceipt {
|
|
|
285
285
|
interface FeeRates {
|
|
286
286
|
/** Upload cost per body byte (smallest asset unit). */
|
|
287
287
|
uploadFeePerByte: bigint;
|
|
288
|
-
/**
|
|
288
|
+
/**
|
|
289
|
+
* Flat cost per published event (smallest asset unit). Implementations
|
|
290
|
+
* already fold any per-packet route-price floor into this flat value, so
|
|
291
|
+
* estimates using it match the claims actually signed.
|
|
292
|
+
*/
|
|
289
293
|
eventFee: bigint;
|
|
294
|
+
/**
|
|
295
|
+
* FLAT minimum per upload claim (smallest asset unit): the store
|
|
296
|
+
* destination's announced route price. The connector gates every paid
|
|
297
|
+
* packet at the destination route's price — a balance-proof claim
|
|
298
|
+
* advancing the channel by less is rejected (F06) — so each per-upload fee
|
|
299
|
+
* is `max(bytes × uploadFeePerByte, minUploadFee)`. Absent: no floor
|
|
300
|
+
* (pre-floor behavior, e.g. when the peer announces no capability prices).
|
|
301
|
+
*/
|
|
302
|
+
minUploadFee?: bigint;
|
|
290
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Per-upload fee: `bytes × ratePerByte`, floored at `minFee` (the
|
|
306
|
+
* destination's announced flat route price — see
|
|
307
|
+
* {@link FeeRates.minUploadFee}). The single shared implementation keeps
|
|
308
|
+
* every estimate site equal to what the publisher actually claims.
|
|
309
|
+
*/
|
|
310
|
+
declare function flooredUploadFee(bytes: number, ratePerByte: bigint, minFee?: bigint): bigint;
|
|
291
311
|
/**
|
|
292
312
|
* Paid transport for `executePush` — implemented by the daemon route
|
|
293
313
|
* handlers (#227) and the standalone embedded client (#228).
|
|
@@ -316,4 +336,4 @@ interface Publisher {
|
|
|
316
336
|
publishEvent(event: UnsignedEvent, relayUrls: string[]): Promise<PublishReceipt>;
|
|
317
337
|
}
|
|
318
338
|
|
|
319
|
-
export { type BlobUpload as B, COMMENT_KIND as C, type FeeRates as F, type GitObjectUpload as G, MAINTAINERS_TAG as M, type Publisher as P, REPOSITORY_STATE_KIND as R, type StatusKind as S, type UnsignedEvent as U, type UploadReceipt as a, type PublishReceipt as b, type GitObjectType as c, type GitObject as d, MAX_OBJECT_SIZE as e, authorizedStatusAuthors as f, buildComment as g, buildIssue as h, buildPatch as i, buildRepoAnnouncement as j, buildRepoRefs as k, buildStatus as l, createGitBlob as m, createGitCommit as n, createGitTag as o, createGitTree as p,
|
|
339
|
+
export { type BlobUpload as B, COMMENT_KIND as C, type FeeRates as F, type GitObjectUpload as G, MAINTAINERS_TAG as M, type Publisher as P, REPOSITORY_STATE_KIND as R, type StatusKind as S, type UnsignedEvent as U, type UploadReceipt as a, type PublishReceipt as b, type GitObjectType as c, type GitObject as d, MAX_OBJECT_SIZE as e, authorizedStatusAuthors as f, buildComment as g, buildIssue as h, buildPatch as i, buildRepoAnnouncement as j, buildRepoRefs as k, buildStatus as l, createGitBlob as m, createGitCommit as n, createGitTag as o, createGitTree as p, flooredUploadFee as q, hashGitObject as r, parseMaintainers as s };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToonClientConfig, SignedBalanceProof, PublishEventResult } from '@toon-protocol/client';
|
|
2
|
-
import { U as UnsignedEvent, P as Publisher, F as FeeRates, G as GitObjectUpload, a as UploadReceipt, B as BlobUpload, b as PublishReceipt } from '../publisher-
|
|
2
|
+
import { U as UnsignedEvent, P as Publisher, F as FeeRates, G as GitObjectUpload, a as UploadReceipt, B as BlobUpload, b as PublishReceipt } from '../publisher-ftQeZSib.js';
|
|
3
3
|
import '@toon-protocol/core/nip34';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -401,6 +401,20 @@ interface StandalonePublisherOptions {
|
|
|
401
401
|
eventFee?: bigint;
|
|
402
402
|
/** Upload fee per object body byte (seed pipeline's bid rate). Default 10n. */
|
|
403
403
|
uploadFeePerByte?: bigint;
|
|
404
|
+
/**
|
|
405
|
+
* FLAT per-packet route prices the payment peer announces for the
|
|
406
|
+
* publish/store destinations (kind:10032 `capabilities` — e.g.
|
|
407
|
+
* `{capability:'os.publish', address:'g.proxy.relay', price:'1000'}`).
|
|
408
|
+
* The connector gates every paid packet at the destination route's price:
|
|
409
|
+
* a balance-proof claim advancing the channel by less is rejected (F06).
|
|
410
|
+
* Applied as a FLOOR on the computed per-packet fee — `publish` floors
|
|
411
|
+
* event claims, `store` floors upload claims. A destination without a
|
|
412
|
+
* known price keeps the computed fee unchanged (pre-floor behavior).
|
|
413
|
+
*/
|
|
414
|
+
routePrices?: {
|
|
415
|
+
publish?: bigint;
|
|
416
|
+
store?: bigint;
|
|
417
|
+
};
|
|
404
418
|
/** Daemon control API port probed by the nonce guard. */
|
|
405
419
|
daemonPort?: number;
|
|
406
420
|
/** Directory for the per-identity advisory lockfile. */
|
|
@@ -461,6 +475,7 @@ declare class StandalonePublisher implements Publisher {
|
|
|
461
475
|
private readonly channelDestination;
|
|
462
476
|
private readonly eventFee;
|
|
463
477
|
private readonly uploadFeePerByte;
|
|
478
|
+
private readonly routePrices;
|
|
464
479
|
private readonly daemonPort;
|
|
465
480
|
private readonly lockDir;
|
|
466
481
|
private readonly fetchImpl;
|
|
@@ -568,13 +583,28 @@ declare class StandalonePublisher implements Publisher {
|
|
|
568
583
|
/**
|
|
569
584
|
* Fee rates for `planPush` estimation: the flat per-event fee and the
|
|
570
585
|
* per-byte upload rate this publisher pays (daemon `feePerEvent` and seed
|
|
571
|
-
* bid-rate conventions; override via options)
|
|
586
|
+
* bid-rate conventions; override via options), with the announced route
|
|
587
|
+
* prices folded in so the ESTIMATE always equals the CLAIMS: the flat
|
|
588
|
+
* `eventFee` is returned pre-floored at the publish route price, and the
|
|
589
|
+
* store route price rides as `minUploadFee` (the per-upload floor —
|
|
590
|
+
* per-byte pricing can't fold a flat floor into the rate).
|
|
572
591
|
*/
|
|
573
592
|
getFeeRates(): Promise<FeeRates>;
|
|
593
|
+
/**
|
|
594
|
+
* The flat per-event claim: `eventFee`, floored at the publish route's
|
|
595
|
+
* announced price (the connector rejects a claim below it — F06).
|
|
596
|
+
*/
|
|
597
|
+
private effectiveEventFee;
|
|
598
|
+
/**
|
|
599
|
+
* The per-upload claim: `bytes × uploadFeePerByte`, floored at the store
|
|
600
|
+
* route's announced price (the connector rejects a claim below it — F06).
|
|
601
|
+
*/
|
|
602
|
+
private uploadFee;
|
|
574
603
|
/**
|
|
575
604
|
* Upload one git object as a kind:5094 store write (Git-SHA/Git-Type/Repo
|
|
576
605
|
* tagged — the proven seed-pipeline shape), signing one balance-proof claim
|
|
577
|
-
* for `body.length × uploadFeePerByte
|
|
606
|
+
* for `body.length × uploadFeePerByte`, floored at the store route's
|
|
607
|
+
* announced price ({@link StandalonePublisherOptions.routePrices}).
|
|
578
608
|
*
|
|
579
609
|
* #368: a blob's `Content-Type` is derived from its path extension (else
|
|
580
610
|
* octet-stream) and sent in the `output` tag, which the store forwards onto
|
|
@@ -589,7 +619,8 @@ declare class StandalonePublisher implements Publisher {
|
|
|
589
619
|
* tags (and an optional `Repo` provenance tag), NOT the Git-SHA/Git-Type
|
|
590
620
|
* tags. Without those the store keeps the bytes verbatim instead of
|
|
591
621
|
* re-deriving a git envelope, which is exactly what the ar.io path manifest
|
|
592
|
-
* needs. One balance-proof claim for `body.length × uploadFeePerByte
|
|
622
|
+
* needs. One balance-proof claim for `body.length × uploadFeePerByte`,
|
|
623
|
+
* floored at the store route's announced price.
|
|
593
624
|
*/
|
|
594
625
|
uploadBlob(upload: BlobUpload): Promise<UploadReceipt>;
|
|
595
626
|
/**
|
package/dist/standalone/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
StandalonePublisher,
|
|
4
4
|
deriveRouteDestinations,
|
|
5
5
|
extractArweaveTxId
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-JILCXMID.js";
|
|
7
7
|
import {
|
|
8
8
|
ChannelMapCorruptError,
|
|
9
9
|
ChannelMapStore,
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
defaultLockDir,
|
|
19
19
|
recordKey,
|
|
20
20
|
resolveChannelPaths
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-57UY3OGX.js";
|
|
22
|
+
import "../chunk-35ALWUDJ.js";
|
|
23
23
|
export {
|
|
24
24
|
ChannelMapCorruptError,
|
|
25
25
|
ChannelMapStore,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StandalonePublisher,
|
|
3
|
+
deriveRouteDestinations
|
|
4
|
+
} from "./chunk-JILCXMID.js";
|
|
1
5
|
import {
|
|
2
6
|
resolveIdentity
|
|
3
7
|
} from "./chunk-GZUDRNOK.js";
|
|
4
|
-
import {
|
|
5
|
-
StandalonePublisher
|
|
6
|
-
} from "./chunk-MKCF2OY2.js";
|
|
7
8
|
import {
|
|
8
9
|
ChannelMapStore,
|
|
9
10
|
RIG_CHANNEL_MAP_FILENAME
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-57UY3OGX.js";
|
|
12
|
+
import "./chunk-35ALWUDJ.js";
|
|
12
13
|
import {
|
|
13
14
|
DISCOVERY_TIMEOUT_MS,
|
|
14
15
|
SolanaChannelUnderivableError,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
resolveChainSettlement,
|
|
23
24
|
selectSettlementChain,
|
|
24
25
|
solanaTokenBalance
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-R7G5NYQJ.js";
|
|
26
27
|
import {
|
|
27
28
|
fetchRemoteState
|
|
28
29
|
} from "./chunk-3HRFDH7H.js";
|
|
@@ -268,6 +269,20 @@ async function resolveNetworkTopology(inputs) {
|
|
|
268
269
|
const destination = explicitDestination ?? announce?.info.ilpAddress ?? genesisSeed?.ilpAddress ?? "g.proxy";
|
|
269
270
|
const publishDestination = explicitPublish ?? announce?.routes?.publish;
|
|
270
271
|
const storeDestination = explicitStore ?? announce?.routes?.store;
|
|
272
|
+
let routePrices;
|
|
273
|
+
const capabilities = announce?.capabilities;
|
|
274
|
+
if (capabilities && capabilities.length > 0) {
|
|
275
|
+
const derived = deriveRouteDestinations(destination);
|
|
276
|
+
const priceOf = (address) => capabilities.find((c) => c.address === address)?.price;
|
|
277
|
+
const publishPrice = priceOf(publishDestination ?? derived.publish);
|
|
278
|
+
const storePrice = priceOf(storeDestination ?? derived.store);
|
|
279
|
+
if (publishPrice !== void 0 || storePrice !== void 0) {
|
|
280
|
+
routePrices = {
|
|
281
|
+
...publishPrice !== void 0 ? { publish: publishPrice } : {},
|
|
282
|
+
...storePrice !== void 0 ? { store: storePrice } : {}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
271
286
|
const knownPeers = announce ? [
|
|
272
287
|
{
|
|
273
288
|
pubkey: announce.pubkey,
|
|
@@ -415,6 +430,10 @@ async function resolveNetworkTopology(inputs) {
|
|
|
415
430
|
warn(
|
|
416
431
|
`rig: settlement chain ${selection.chain} selected \u2014 ${selection.detail}; set TOON_CLIENT_CHAIN (or supportedChains in the client config) to override`
|
|
417
432
|
);
|
|
433
|
+
} else if (explicitChain && selection.chain !== explicitChain) {
|
|
434
|
+
warn(
|
|
435
|
+
`rig: aligning configured settlement chain "${explicitChain}" to the announced spelling "${selection.chain}" \u2014 ${selection.detail}`
|
|
436
|
+
);
|
|
418
437
|
}
|
|
419
438
|
} else {
|
|
420
439
|
warn(
|
|
@@ -433,6 +452,7 @@ async function resolveNetworkTopology(inputs) {
|
|
|
433
452
|
destination,
|
|
434
453
|
...publishDestination ? { publishDestination } : {},
|
|
435
454
|
...storeDestination ? { storeDestination } : {},
|
|
455
|
+
...routePrices ? { routePrices } : {},
|
|
436
456
|
knownPeers,
|
|
437
457
|
...selection ? { selection } : {},
|
|
438
458
|
...supportedChains ? { supportedChains } : {},
|
|
@@ -659,6 +679,14 @@ async function createStandaloneContext(options) {
|
|
|
659
679
|
warn,
|
|
660
680
|
...topo.publishDestination ? { publishDestination: topo.publishDestination } : {},
|
|
661
681
|
...topo.storeDestination ? { storeDestination: topo.storeDestination } : {},
|
|
682
|
+
// Route-price floors (F06): every per-packet claim must advance the
|
|
683
|
+
// channel by at least the destination route's announced price.
|
|
684
|
+
...topo.routePrices ? {
|
|
685
|
+
routePrices: {
|
|
686
|
+
...topo.routePrices.publish !== void 0 ? { publish: BigInt(topo.routePrices.publish) } : {},
|
|
687
|
+
...topo.routePrices.store !== void 0 ? { store: BigInt(topo.routePrices.store) } : {}
|
|
688
|
+
}
|
|
689
|
+
} : {},
|
|
662
690
|
// `rig channel open --peer` (#263): anchor the channel (and its map
|
|
663
691
|
// key) to an explicit peer destination instead of the configured
|
|
664
692
|
// default.
|
|
@@ -706,4 +734,4 @@ export {
|
|
|
706
734
|
createStandaloneContext,
|
|
707
735
|
resolveNetworkTopology
|
|
708
736
|
};
|
|
709
|
-
//# sourceMappingURL=standalone-mode-
|
|
737
|
+
//# sourceMappingURL=standalone-mode-CTQKDJBL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/standalone-mode.ts","../src/standalone/topology-cache.ts"],"sourcesContent":["/**\n * The embedded-client (standalone) publisher backing every paid `rig`\n * command: build a nonce-guarded {@link StandalonePublisher} from the\n * caller's own identity and config.\n *\n * Identity comes from the #248 precedence chain (`./identity.ts`:\n * RIG_MNEMONIC env → TOON_CLIENT_MNEMONIC env alias → project `.env` →\n * `~/.toon-client` keystore/config). The remaining config resolution\n * DUPLICATES the toon-clientd conventions\n * (`packages/client-mcp/src/daemon/config.ts`) the same way\n * `../standalone/nonce-guard.ts` does — this package must not import\n * `@toon-protocol/client-mcp` (circular; see that module's doc). Keep in sync:\n *\n * - state dir: `TOON_CLIENT_HOME`, else `~/.toon-client`; config `config.json`\n * - env overrides: `TOON_CLIENT_PROXY_URL`, `TOON_CLIENT_BTP_URL`,\n * `TOON_CLIENT_RELAY_URL`, `TOON_CLIENT_DESTINATION`,\n * `TOON_CLIENT_PUBLISH_DESTINATION`, `TOON_CLIENT_STORE_DESTINATION`,\n * `TOON_CLIENT_CHAIN`\n *\n * NETWORK BOOTSTRAP (#264): what explicit config does not pin is resolved\n * from the network itself — the payment peer's live kind:10032 announce on\n * the relay-origin, falling back to `@toon-protocol/core`'s committed\n * genesis peer seed. Uplink, channel anchor, publish/store routes, the\n * settlement chain and its TokenNetwork/token/RPC parameters all follow the\n * `explicit config > live announce > genesis seed` order documented in\n * `../standalone/network-bootstrap.ts`. The pure resolution lives in\n * {@link resolveNetworkTopology} (unit-testable without any network).\n *\n * TOPOLOGY CACHE (#279): the resolved topology is persisted under\n * `TOON_CLIENT_HOME` (`../standalone/topology-cache.ts`) keyed by\n * relay-origin + identity + an explicit-config fingerprint, with a 15-min\n * TTL (`RIG_TOPOLOGY_TTL_MS` overrides; `0` disables). A cache hit skips\n * announce discovery and the funded-chain probes entirely; a cached\n * topology that then fails to BOOTSTRAP is invalidated and re-resolved\n * live in-process ({@link TopologyRecoveringPublisher}), so staleness costs\n * one failed attempt, never a broken run. Only paid-path resolutions\n * (`requireUplink !== false`) are written — a free-read topology may lack\n * an uplink and must not shadow the paid path's MissingUplinkError.\n *\n * CORE COEXISTENCE NOTE: rig performs discovery with ITS OWN\n * `@toon-protocol/core` (^2.0.x — live genesis seed), while the embedded\n * `@toon-protocol/client` keeps its internal core (^1.6.x) for its own\n * bootstrap/negotiation. The two never exchange class instances — rig feeds\n * the client plain config (`knownPeers`, settlement maps), so the version\n * split is safe by construction.\n *\n * This module statically imports `@toon-protocol/client` (heavy: viem,\n * noble, nostr-tools), so it must only ever be reached through the dynamic\n * import in `push.ts` (see `./standalone-context.ts`).\n */\n\nimport { readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { ToonClientConfig } from '@toon-protocol/client';\nimport {\n EvmSigner,\n deriveFullIdentity,\n deriveNostrKeyFromMnemonic,\n} from '@toon-protocol/client';\nimport {\n decodeEventFromToon,\n encodeEventToToon,\n} from '@toon-protocol/core';\nimport type {\n BlobUpload,\n FeeRates,\n GitObjectUpload,\n Publisher,\n PublishReceipt,\n UploadReceipt,\n} from '../publisher.js';\nimport type { UnsignedEvent } from '../nip34-events.js';\nimport {\n ChannelMapStore,\n RIG_CHANNEL_MAP_FILENAME,\n type ChannelMapRecord,\n} from '../standalone/channel-map.js';\nimport {\n TOPOLOGY_CACHE_FILENAME,\n TOPOLOGY_TTL_ENV,\n TopologyCache,\n explicitConfigFingerprint,\n topologyCacheKey,\n topologyCacheTtlMs,\n} from '../standalone/topology-cache.js';\nimport {\n DISCOVERY_TIMEOUT_MS,\n SolanaChannelUnderivableError,\n TokenNetworkUnderivableError,\n discoverAnnouncedPeers,\n evmChainIdOf,\n evmTokenBalance,\n genesisSeedPubkeys,\n loadGenesisSeed,\n pickPaymentPeer,\n resolveChainSettlement,\n selectSettlementChain,\n solanaTokenBalance,\n type AnnouncedPeer,\n type ChainSelection,\n type ChainSettlement,\n type ChannelRecordLike,\n type EvmBalanceProbe,\n type ExplicitChainConfig,\n type SolanaBalanceProbe,\n} from '../standalone/network-bootstrap.js';\nimport {\n StandalonePublisher,\n deriveRouteDestinations,\n} from '../standalone/standalone-publisher.js';\nimport { fetchRemoteState } from '../remote-state.js';\nimport { resolveIdentity } from './identity.js';\nimport type {\n StandaloneContext,\n StandaloneLoadOptions,\n} from './standalone-context.js';\n\n/** The subset of the shared client config file standalone mode consumes. */\nexport interface ClientConfigFile {\n network?: 'mainnet' | 'testnet' | 'devnet' | 'custom';\n mnemonicAccountIndex?: number;\n btpUrl?: string;\n proxyUrl?: string;\n relayUrl?: string;\n destination?: string;\n publishDestination?: string;\n storeDestination?: string;\n feePerEvent?: string;\n channelStorePath?: string;\n /** Settlement chain: family (`evm`) or full id (`evm:31337`). */\n chain?: string;\n supportedChains?: string[];\n settlementAddresses?: Record<string, string>;\n preferredTokens?: Record<string, string>;\n tokenNetworks?: Record<string, string>;\n chainRpcUrls?: Record<string, string>;\n solanaChannel?: ToonClientConfig['solanaChannel'];\n minaChannel?: ToonClientConfig['minaChannel'];\n}\n\n/** An identity was resolved, but there is no way to send paid writes. */\nexport class MissingUplinkError extends Error {\n constructor(configPath: string, relayUrl: string | undefined) {\n const discovered = relayUrl\n ? `no announce with a btp/http endpoint was found on ${relayUrl} and ` +\n 'the genesis seed has none; '\n : '';\n super(\n `no write uplink configured: ${discovered}set TOON_CLIENT_PROXY_URL ` +\n '(connector payment proxy) or TOON_CLIENT_BTP_URL, or add ' +\n `proxyUrl/btpUrl to ${configPath}`\n );\n this.name = 'MissingUplinkError';\n }\n}\n\nfunction configDir(env: NodeJS.ProcessEnv): string {\n return env['TOON_CLIENT_HOME'] ?? join(homedir(), '.toon-client');\n}\n\nfunction readClientConfig(path: string): ClientConfigFile {\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as ClientConfigFile;\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') return {};\n throw new Error(\n `failed to read client config at ${path}: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n}\n\n/** `https://host/ilp` → `https://host` (the client re-derives `/ilp`). */\nfunction proxyBaseOf(httpEndpoint: string): string {\n return httpEndpoint.replace(/\\/+$/, '').replace(/\\/ilp$/i, '');\n}\n\n// ---------------------------------------------------------------------------\n// Pure topology resolution (#264) — exported for tests\n// ---------------------------------------------------------------------------\n\n/** A genesis-seed peer as this module consumes it (rig's core 2.x shape). */\nexport interface GenesisSeedLike {\n pubkey: string;\n relayUrl: string;\n ilpAddress: string;\n btpEndpoint: string;\n}\n\n/** Inputs to {@link resolveNetworkTopology} (side-effect free). */\nexport interface NetworkTopologyInputs {\n env: NodeJS.ProcessEnv;\n file: ClientConfigFile;\n /** For error messages (\"add X to <configPath>\"). */\n configPath: string;\n /** Resolved relay-origin (already precedence-resolved). */\n relayUrl: string;\n /** The discovered payment-peer announce, if any. */\n announce: AnnouncedPeer | undefined;\n /** The committed genesis seed entry, if any. */\n genesisSeed: GenesisSeedLike | undefined;\n identity: { mnemonic: string; accountIndex: number; pubkey: string };\n /**\n * #262 channel-map records for this identity (chain selection input).\n * A thunk so the (possibly corrupt-throwing) map read only happens when\n * chain selection actually needs it.\n */\n channelRecords: () => ChannelRecordLike[];\n /** EVM balance probe override (tests); default: raw `eth_call`. */\n probeBalance?: EvmBalanceProbe;\n /**\n * Solana balance probe override (tests); default: raw\n * `getTokenAccountsByOwner`.\n */\n probeSolanaBalance?: SolanaBalanceProbe;\n /**\n * When false (#263 free reads, e.g. `rig balance`), a missing uplink is\n * tolerated instead of throwing {@link MissingUplinkError}.\n */\n requireUplink?: boolean;\n warn: (line: string) => void;\n}\n\n/** The resolved payment topology feeding the embedded client config. */\nexport interface NetworkTopology {\n proxyUrl?: string;\n btpUrl?: string;\n /** Channel anchor / default ILP destination. */\n destination: string;\n publishDestination?: string;\n storeDestination?: string;\n /** The peer the embedded client bootstraps + negotiates with. */\n knownPeers: { pubkey: string; relayUrl: string; btpEndpoint: string }[];\n /**\n * FLAT per-packet route prices the peer announces for the effective\n * publish/store destinations (kind:10032 `capabilities`; base-unit integer\n * strings — this document is JSON-cached). The connector rejects any\n * balance-proof claim advancing the channel by less than the destination\n * route's price (F06), so the publisher floors its per-packet fees here.\n */\n routePrices?: { publish?: string; store?: string };\n /** The selected settlement chain + rationale (absent: nothing known). */\n selection?: ChainSelection;\n supportedChains?: string[];\n preferredTokens?: Record<string, string>;\n tokenNetworks?: Record<string, string>;\n chainRpcUrls?: Record<string, string>;\n /**\n * Solana channel parameters derived for the (first) `solana:*` chain in\n * play — the config-ready `ToonClientConfig.solanaChannel` shape. Absent\n * when no Solana chain is supported or an explicit `solanaChannel` config\n * object already covers it (explicit rides through verbatim).\n */\n solanaChannel?: { rpcUrl: string; programId: string; tokenMint?: string };\n}\n\n/**\n * Build the embedded client's `solanaChannel` from one resolved settlement —\n * or throw the actionable {@link SolanaChannelUnderivableError} naming the\n * missing pieces. A Solana chain in play with no way to open its channel must\n * fail HERE, not later as the embedded client's generic \"Solana channel\n * config not provided\".\n */\nfunction deriveSolanaChannel(\n settlement: ChainSettlement,\n announce: AnnouncedPeer | undefined,\n relayUrl: string\n): NonNullable<NetworkTopology['solanaChannel']> {\n const { rpcUrl, programId, tokenAddress } = settlement;\n if (!rpcUrl || !programId || !tokenAddress) {\n const missing = [\n ...(rpcUrl ? [] : ['rpcUrl']),\n ...(programId ? [] : ['programId']),\n ...(tokenAddress ? [] : ['tokenMint']),\n ];\n throw new SolanaChannelUnderivableError(\n settlement.chain,\n missing,\n announce,\n relayUrl\n );\n }\n return { rpcUrl, programId, tokenMint: tokenAddress };\n}\n\n/**\n * Resolve the payment topology per the #264 precedence order —\n * `explicit config > live announce > genesis seed` for every field, plus the\n * documented settlement-chain selection rule (see\n * `../standalone/network-bootstrap.ts`).\n *\n * @throws {MissingUplinkError} when no source yields an uplink.\n * @throws {TokenNetworkUnderivableError} when the selected EVM chain's\n * TokenNetwork cannot be derived from config, announce, or chain preset.\n */\nexport async function resolveNetworkTopology(\n inputs: NetworkTopologyInputs\n): Promise<NetworkTopology> {\n const { env, file, configPath, relayUrl, announce, genesisSeed, warn } =\n inputs;\n\n // ── Explicit config (always wins, per field) ─────────────────────────────\n const explicitProxyUrl = env['TOON_CLIENT_PROXY_URL'] ?? file.proxyUrl;\n const explicitBtpUrl = env['TOON_CLIENT_BTP_URL'] ?? file.btpUrl;\n const explicitDestination =\n env['TOON_CLIENT_DESTINATION'] ?? file.destination;\n const explicitPublish =\n env['TOON_CLIENT_PUBLISH_DESTINATION'] ?? file.publishDestination;\n const explicitStore =\n env['TOON_CLIENT_STORE_DESTINATION'] ?? file.storeDestination;\n const explicitChain = env['TOON_CLIENT_CHAIN'] ?? file.chain;\n const explicitMaps: ExplicitChainConfig = {\n ...(file.chainRpcUrls ? { chainRpcUrls: file.chainRpcUrls } : {}),\n ...(file.preferredTokens ? { preferredTokens: file.preferredTokens } : {}),\n ...(file.tokenNetworks ? { tokenNetworks: file.tokenNetworks } : {}),\n };\n\n // ── Uplink: explicit > announce (http > btp) > genesis seed ──────────────\n let proxyUrl = explicitProxyUrl;\n let btpUrl = explicitBtpUrl;\n if (!proxyUrl && !btpUrl) {\n if (announce?.info.httpEndpoint) {\n proxyUrl = proxyBaseOf(announce.info.httpEndpoint);\n } else if (announce?.info.btpEndpoint) {\n btpUrl = announce.info.btpEndpoint;\n } else if (genesisSeed?.btpEndpoint) {\n btpUrl = genesisSeed.btpEndpoint;\n } else if (inputs.requireUplink !== false) {\n // Free reads (`rig balance`, #263) tolerate a missing uplink; paid\n // commands fail here, after every source has been tried.\n throw new MissingUplinkError(configPath, relayUrl);\n }\n }\n\n // ── Destination anchor + publish/store routes ────────────────────────────\n // The channel anchors at the peer's announced ilpAddress; publish/store\n // routes come from the announce's `routes` map. Explicit values always\n // win; with neither, the publisher's `<base>.relay.store` anchor-derivation\n // convention remains as the last-resort fallback (explicit anchors only).\n const destination =\n explicitDestination ??\n announce?.info.ilpAddress ??\n genesisSeed?.ilpAddress ??\n 'g.proxy';\n const publishDestination = explicitPublish ?? announce?.routes?.publish;\n const storeDestination = explicitStore ?? announce?.routes?.store;\n\n // ── Route-price floors ───────────────────────────────────────────────────\n // The announce's `capabilities` carry a FLAT price per destination route,\n // and the connector gates every paid packet at it (a claim advancing the\n // channel by less is rejected — F06). Match the announced prices against\n // the EFFECTIVE publish/store destinations — including the publisher's\n // `<base>.relay.store` anchor-derivation fallback, so the floor applies\n // exactly when a paid write would actually target the priced route. An\n // unmatched destination gets no floor (behavior unchanged).\n let routePrices: NetworkTopology['routePrices'];\n const capabilities = announce?.capabilities;\n if (capabilities && capabilities.length > 0) {\n const derived = deriveRouteDestinations(destination);\n const priceOf = (address: string): string | undefined =>\n capabilities.find((c) => c.address === address)?.price;\n const publishPrice = priceOf(publishDestination ?? derived.publish);\n const storePrice = priceOf(storeDestination ?? derived.store);\n if (publishPrice !== undefined || storePrice !== undefined) {\n routePrices = {\n ...(publishPrice !== undefined ? { publish: publishPrice } : {}),\n ...(storePrice !== undefined ? { store: storePrice } : {}),\n };\n }\n }\n\n // ── Known peer for the embedded client's own bootstrap ───────────────────\n // The client re-queries the peer's announce itself (its internal core) and\n // negotiates the settlement chain; rig just tells it WHO to bootstrap with.\n const knownPeers = announce\n ? [\n {\n pubkey: announce.pubkey,\n relayUrl,\n btpEndpoint: announce.info.btpEndpoint ?? '',\n },\n ]\n : genesisSeed\n ? [\n {\n pubkey: genesisSeed.pubkey,\n relayUrl: genesisSeed.relayUrl,\n btpEndpoint: genesisSeed.btpEndpoint,\n },\n ]\n : [];\n\n // ── Settlement chain + per-chain parameters ──────────────────────────────\n // NOTE: the `network` preset field is deliberately NOT forwarded to the\n // embedded client. `applyNetworkPresets` puts preset chains FIRST in\n // `supportedChains`, which is what steered devnet negotiation to the\n // unfunded public Solana preset (#260 root cause 4). The announce + the\n // rule below define the chain; presets only serve as per-chain parameter\n // fallbacks inside `resolveChainSettlement`.\n const announcedChains = announce?.info.supportedChains ?? [];\n const resolveSettlement = (chain: string) =>\n resolveChainSettlement(chain, explicitMaps, announce);\n\n let selection: ChainSelection | undefined;\n let supportedChains: string[] | undefined;\n let preferredTokens: Record<string, string> | undefined;\n let tokenNetworks: Record<string, string> | undefined;\n let chainRpcUrls: Record<string, string> | undefined;\n let solanaChannel: NetworkTopology['solanaChannel'];\n\n if (file.supportedChains?.length) {\n // Explicit chain list: pass through in order (its order IS the\n // negotiation preference), filling per-chain parameter gaps from\n // announce/presets.\n const listed = file.supportedChains;\n const kept: string[] = [];\n let firstDropError: unknown;\n preferredTokens = { ...file.preferredTokens };\n tokenNetworks = { ...file.tokenNetworks };\n chainRpcUrls = { ...file.chainRpcUrls };\n for (const chain of listed) {\n const s = resolveSettlement(chain);\n // Chain negotiation is an EXACT string intersection of the two chain\n // lists — a spelling difference for the same chain (config\n // `evm:base:31337` vs announced `evm:31337`) silently strands the\n // chain and negotiation falls through to whatever else matches. When\n // a listed EVM chain names the same numeric chain id as an announced\n // one, advertise the ANNOUNCED spelling (parameters resolved from the\n // configured spelling carry over).\n let key = chain;\n if (s.family === 'evm' && !announcedChains.includes(chain)) {\n const chainId = evmChainIdOf(chain);\n const equivalent =\n chainId !== undefined\n ? announcedChains.find((c) => evmChainIdOf(c) === chainId)\n : undefined;\n if (equivalent) {\n warn(\n `rig: aligning configured settlement chain \"${chain}\" to the ` +\n `announced spelling \"${equivalent}\" (same EVM chain id ` +\n `${chainId}) — chain negotiation matches identifiers exactly`\n );\n key = equivalent;\n }\n }\n if (kept.includes(key)) continue;\n if (s.tokenAddress && !preferredTokens[key]) {\n preferredTokens[key] = s.tokenAddress;\n }\n if (s.tokenNetwork && !tokenNetworks[key]) {\n tokenNetworks[key] = s.tokenNetwork;\n }\n if (s.rpcUrl && !chainRpcUrls[key]) {\n chainRpcUrls[key] = s.rpcUrl;\n }\n // Same fail-fast guarantee as the announce/selection path below: an\n // explicitly configured EVM chain whose TokenNetwork/RPC cannot be\n // derived must fail HERE with an actionable error, not later as the\n // embedded client's generic \"tokenNetwork address is required\".\n if (s.family === 'evm') {\n if (!tokenNetworks[key]) {\n throw new TokenNetworkUnderivableError(chain, announce, relayUrl);\n }\n if (!chainRpcUrls[key]) {\n throw new Error(\n `no RPC URL is derivable for settlement chain \"${chain}\"` +\n ` — add chainRpcUrls[\"${chain}\"] to ${configPath}`\n );\n }\n }\n // A listed Solana chain is advertised to negotiation, which may pick\n // it — so its channel parameters must be derivable NOW. An explicit\n // solanaChannel config object covers it (rides through to the embedded\n // client verbatim); otherwise the first derivable Solana chain\n // provides the channel params, and an UNDERIVABLE one is dropped from\n // the advertised list (warned, with the remedy) instead of leaving a\n // chain in play that the on-chain open is guaranteed to die on.\n if (s.family === 'solana' && !file.solanaChannel) {\n if (solanaChannel) {\n // The embedded client carries ONE solanaChannel — a second Solana\n // chain cannot be honored with distinct params.\n kept.push(key);\n continue;\n }\n try {\n solanaChannel = deriveSolanaChannel(s, announce, relayUrl);\n } catch (err) {\n firstDropError ??= err;\n warn(\n `rig: dropping settlement chain ${chain} from the configured ` +\n `supportedChains — ${err instanceof Error ? err.message : String(err)}`\n );\n continue;\n }\n }\n kept.push(key);\n }\n if (kept.length === 0) {\n // Every listed chain was dropped — surface the first underivable\n // error instead of negotiating with an empty chain list.\n throw firstDropError;\n }\n supportedChains = kept;\n // The embedded client validates chainRpcUrls keys ⊆ supportedChains, so\n // entries for dropped/re-spelled chains must not survive; prune all\n // three chain-keyed maps to the advertised list for coherence.\n const advertised = new Set(kept);\n const prune = (map: Record<string, string>): Record<string, string> =>\n Object.fromEntries(\n Object.entries(map).filter(([chain]) => advertised.has(chain))\n );\n preferredTokens = prune(preferredTokens);\n tokenNetworks = prune(tokenNetworks);\n chainRpcUrls = prune(chainRpcUrls);\n selection = {\n chain: supportedChains[0] as string,\n reason: 'explicit',\n detail: 'supportedChains set by config',\n };\n } else if (explicitChain || announcedChains.length > 0) {\n // Selection rule: explicit > persisted channel > funded > first EVM.\n const { secretKey } = deriveNostrKeyFromMnemonic(\n inputs.identity.mnemonic,\n inputs.identity.accountIndex\n );\n const evmAddress = new EvmSigner(secretKey).address;\n // The Solana funded-chain probe needs the identity's base58 Solana\n // address, derived pre-client-start via the client's own SLIP-0010\n // helper (same paths the embedded client uses, so the probed address IS\n // the one the client will settle with). Only derived when a `solana:*`\n // chain is actually announced and no explicit chain pins selection\n // anyway; `deriveFullIdentity` degrades to an empty publicKey when the\n // Ed25519 deps are unavailable — then Solana chains are not probed.\n let solanaAddress: string | undefined;\n if (!explicitChain && announcedChains.some((c) => c.startsWith('solana:'))) {\n const fullIdentity = await deriveFullIdentity(\n inputs.identity.mnemonic,\n inputs.identity.accountIndex\n );\n solanaAddress = fullIdentity.solana.publicKey || undefined;\n // Only the address is needed here — drop the derived key material.\n fullIdentity.nostr.secretKey.fill(0);\n fullIdentity.evm.privateKey.fill(0);\n fullIdentity.solana.secretKey.fill(0);\n }\n selection = await selectSettlementChain({\n ...(explicitChain ? { explicitChain } : {}),\n announcedChains,\n records: inputs.channelRecords(),\n evmAddress,\n ...(solanaAddress ? { solanaAddress } : {}),\n resolveSettlement,\n probeBalance: inputs.probeBalance ?? evmTokenBalance,\n probeSolanaBalance: inputs.probeSolanaBalance ?? solanaTokenBalance,\n });\n const settlement = resolveSettlement(selection.chain);\n if (settlement.family === 'evm') {\n if (!settlement.tokenNetwork) {\n throw new TokenNetworkUnderivableError(\n selection.chain,\n announce,\n relayUrl\n );\n }\n if (!settlement.rpcUrl) {\n throw new Error(\n `no RPC URL is derivable for settlement chain \"${selection.chain}\"` +\n ` — add chainRpcUrls[\"${selection.chain}\"] to ${configPath}`\n );\n }\n }\n // Same fail-fast for a selected Solana chain: its channel parameters\n // must be derivable now (an explicit solanaChannel config covers it).\n if (settlement.family === 'solana' && !file.solanaChannel) {\n solanaChannel = deriveSolanaChannel(settlement, announce, relayUrl);\n }\n supportedChains = [selection.chain];\n preferredTokens = settlement.tokenAddress\n ? { [selection.chain]: settlement.tokenAddress }\n : undefined;\n tokenNetworks = settlement.tokenNetwork\n ? { [selection.chain]: settlement.tokenNetwork }\n : undefined;\n chainRpcUrls = settlement.rpcUrl\n ? { [selection.chain]: settlement.rpcUrl }\n : undefined;\n if (selection.reason !== 'explicit') {\n warn(\n `rig: settlement chain ${selection.chain} selected — ` +\n `${selection.detail}; set TOON_CLIENT_CHAIN (or supportedChains ` +\n 'in the client config) to override'\n );\n } else if (explicitChain && selection.chain !== explicitChain) {\n // The explicit pin was re-spelled to the announced chain id (chain\n // negotiation matches identifiers exactly) — say so, like the\n // configured-supportedChains path does.\n warn(\n `rig: aligning configured settlement chain \"${explicitChain}\" to ` +\n `the announced spelling \"${selection.chain}\" — ${selection.detail}`\n );\n }\n } else {\n warn(\n 'rig: no settlement chains are configured or announced — paid writes ' +\n 'will fail until a chain is configured (supportedChains) or the ' +\n `payment peer announces its chains on ${relayUrl}`\n );\n }\n\n const network = env['TOON_CLIENT_NETWORK'] ?? file.network;\n if (network && network !== 'custom' && !file.supportedChains?.length) {\n warn(\n `rig: ignoring the \"${network}\" network preset for settlement — the ` +\n \"settlement chain comes from the payment peer's announce and your \" +\n 'config, because preset chains can point at networks your wallet ' +\n 'has no funds on; set supportedChains explicitly to use preset chains'\n );\n }\n\n return {\n ...(proxyUrl ? { proxyUrl } : {}),\n ...(btpUrl ? { btpUrl } : {}),\n destination,\n ...(publishDestination ? { publishDestination } : {}),\n ...(storeDestination ? { storeDestination } : {}),\n ...(routePrices ? { routePrices } : {}),\n knownPeers,\n ...(selection ? { selection } : {}),\n ...(supportedChains ? { supportedChains } : {}),\n ...(preferredTokens && Object.keys(preferredTokens).length > 0\n ? { preferredTokens }\n : {}),\n ...(tokenNetworks && Object.keys(tokenNetworks).length > 0\n ? { tokenNetworks }\n : {}),\n ...(chainRpcUrls && Object.keys(chainRpcUrls).length > 0\n ? { chainRpcUrls }\n : {}),\n ...(solanaChannel ? { solanaChannel } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Cached-topology recovery (#279)\n// ---------------------------------------------------------------------------\n\n/** Structural check for a cached {@link NetworkTopology} document. */\nfunction isNetworkTopology(value: unknown): value is NetworkTopology {\n if (typeof value !== 'object' || value === null) return false;\n const t = value as Record<string, unknown>;\n return typeof t['destination'] === 'string' && Array.isArray(t['knownPeers']);\n}\n\n/**\n * Start failures that must NEVER trigger a cache-invalidation retry: they\n * are concurrency/state guards, not topology staleness — retrying would\n * bypass exactly what they protect.\n */\nconst NON_RECOVERABLE_START_ERRORS: ReadonlySet<string> = new Set([\n 'DaemonIdentityConflictError',\n 'StandaloneLockError',\n 'ChannelMapCorruptError',\n]);\n\n/**\n * Publisher wrapper implementing the #279 cache-invalidation contract: when\n * the inner publisher was built from a CACHED topology and its bootstrap\n * (`start`/`startClientOnly`) fails, the cache entry is invalidated, the\n * topology is re-resolved LIVE, a fresh publisher replaces the inner one,\n * and the operation proceeds — one retry, never more. Bootstrap failures\n * are pre-payment by construction (start() completes before any claim is\n * signed), so the retry can never double-pay. Publishers built from a live\n * resolution get no recovery hook and fail through unchanged.\n */\nclass TopologyRecoveringPublisher implements Publisher {\n private inner: StandalonePublisher;\n private rebuild: (() => Promise<StandalonePublisher>) | undefined;\n private readonly warn: (line: string) => void;\n\n constructor(\n inner: StandalonePublisher,\n rebuild: (() => Promise<StandalonePublisher>) | undefined,\n warn: (line: string) => void\n ) {\n this.inner = inner;\n this.rebuild = rebuild;\n this.warn = warn;\n }\n\n getPublicKey(): string {\n return this.inner.getPublicKey();\n }\n\n getFeeRates(): Promise<FeeRates> {\n return this.inner.getFeeRates();\n }\n\n /**\n * Run the bootstrap step, recovering ONCE from a stale cached topology.\n * A rebuild failure surfaces the LIVE resolution's error — that is the\n * network's real state, strictly more actionable than the cached failure.\n */\n private async ensure(\n start: (p: StandalonePublisher) => Promise<void>\n ): Promise<StandalonePublisher> {\n try {\n await start(this.inner);\n return this.inner;\n } catch (err) {\n const rebuild = this.rebuild;\n this.rebuild = undefined;\n const name = err instanceof Error ? err.name : '';\n if (!rebuild || NON_RECOVERABLE_START_ERRORS.has(name)) throw err;\n this.warn(\n 'rig: bootstrap with the cached network topology failed ' +\n `(${err instanceof Error ? err.message : String(err)}) — ` +\n 'invalidating the cache and re-resolving live'\n );\n const fresh = await rebuild();\n try {\n // Failed starts release their own lock/state; stop() is idempotent.\n await this.inner.stop();\n } catch {\n // best-effort teardown of the abandoned publisher\n }\n this.inner = fresh;\n await start(this.inner);\n return this.inner;\n }\n }\n\n async publishEvent(\n event: UnsignedEvent,\n relayUrls: string[]\n ): Promise<PublishReceipt> {\n const p = await this.ensure((x) => x.start());\n return p.publishEvent(event, relayUrls);\n }\n\n async uploadGitObject(upload: GitObjectUpload): Promise<UploadReceipt> {\n const p = await this.ensure((x) => x.start());\n return p.uploadGitObject(upload);\n }\n\n async uploadBlob(upload: BlobUpload): Promise<UploadReceipt> {\n const p = await this.ensure((x) => x.start());\n return p.uploadBlob(upload);\n }\n\n // ── money lifecycle passthroughs (#263) — same recovery contract ─────────\n\n async openChannelExplicit(\n opts?: Parameters<StandalonePublisher['openChannelExplicit']>[0]\n ): ReturnType<StandalonePublisher['openChannelExplicit']> {\n const p = await this.ensure((x) => x.start());\n return p.openChannelExplicit(opts);\n }\n\n async closeRecordedChannel(\n record: ChannelMapRecord\n ): ReturnType<StandalonePublisher['closeRecordedChannel']> {\n const p = await this.ensure((x) => x.startClientOnly());\n return p.closeRecordedChannel(record);\n }\n\n async settleRecordedChannel(\n record: ChannelMapRecord\n ): ReturnType<StandalonePublisher['settleRecordedChannel']> {\n const p = await this.ensure((x) => x.startClientOnly());\n return p.settleRecordedChannel(record);\n }\n\n /** Free read on the unstarted client — no bootstrap, no recovery needed. */\n readWalletChainBalances(): ReturnType<\n StandalonePublisher['readWalletChainBalances']\n > {\n return this.inner.readWalletChainBalances();\n }\n\n async stop(): Promise<void> {\n await this.inner.stop();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Context factory\n// ---------------------------------------------------------------------------\n\n/**\n * #262 channel-map records for this identity, reduced to the slice chain\n * selection consumes (`closed` folds in the claim-watermark timers).\n */\nfunction chainRecordsFor(\n map: ChannelMapStore,\n identity: string\n): ChannelRecordLike[] {\n return map\n .list()\n .filter((r) => r.identity === identity)\n .map((r) => {\n const watermark = map.readWatermark(r.channelId);\n return {\n chain: r.chain,\n lastUsedAt: r.lastUsedAt,\n closed:\n watermark?.closedAt !== undefined ||\n watermark?.settledAt !== undefined,\n };\n });\n}\n\n/**\n * Assemble an embedded-client standalone context: resolved identity + config\n * → network bootstrap (announce discovery / genesis seed) → ToonClientConfig\n * → nonce-guarded StandalonePublisher (guard + client start + channel open\n * happen lazily on the first paid call, or eagerly via the publisher's own\n * `start`).\n */\nexport async function createStandaloneContext(\n options: StandaloneLoadOptions\n): Promise<StandaloneContext> {\n const { env } = options;\n const warn = (line: string) => options.warn(line);\n const dir = configDir(env);\n const configPath = join(dir, 'config.json');\n const file = readClientConfig(configPath);\n const identity = await resolveIdentity(options);\n\n const genesisSeed = loadGenesisSeed();\n\n // ── Relay-origin ──────────────────────────────────────────────────────────\n // The relay the paid command resolved via `rig remote` (passed by the\n // command) is the user's clearest network statement; env/file follow, and\n // the genesis seed's relay is the out-of-the-box fallback.\n const relayUrl =\n options.relayUrl ??\n env['TOON_CLIENT_RELAY_URL'] ??\n file.relayUrl ??\n genesisSeed?.relayUrl ??\n 'ws://localhost:7100';\n\n // ── Peer→channel persistence (#262) ──────────────────────────────────────\n const channelStorePath = file.channelStorePath ?? join(dir, 'channels.json');\n const channelMap = new ChannelMapStore({\n mapPath: join(dir, RIG_CHANNEL_MAP_FILENAME),\n watermarkPath: channelStorePath,\n });\n\n // ── Topology cache (#279): keyed by relay-origin + identity + explicit\n // config; a hit skips discovery AND the pure-but-probing resolution below.\n const cache = new TopologyCache<NetworkTopology>({\n path: join(dir, TOPOLOGY_CACHE_FILENAME),\n ttlMs: topologyCacheTtlMs(env),\n validate: isNetworkTopology,\n });\n const cacheKey = topologyCacheKey({\n relayUrl,\n identity: identity.pubkey,\n fingerprint: explicitConfigFingerprint(\n env,\n file as Record<string, unknown>\n ),\n });\n\n const resolveLiveTopology = async (): Promise<NetworkTopology> => {\n // ── Live announce discovery ────────────────────────────────────────────\n // Skipped when explicit config already pins the whole payment topology\n // (fully-configured setups keep their zero-roundtrip start and their\n // exact pre-#264 behavior). A listed `solana:*` chain WITHOUT explicit\n // channel parameters is not fully pinned: the announce is a needed\n // parameter source (program id / mint), and skipping discovery would\n // also skip the announced-spelling alignment that keeps the chain list\n // negotiable. Discovery failure is non-fatal: warn + genesis seed.\n const solanaExplicitlyComplete = (file.supportedChains ?? []).every(\n (chain) =>\n !chain.startsWith('solana:') ||\n Boolean(file.solanaChannel) ||\n Boolean(\n file.tokenNetworks?.[chain] &&\n file.preferredTokens?.[chain] &&\n file.chainRpcUrls?.[chain]\n )\n );\n const fullyExplicit =\n Boolean(\n (env['TOON_CLIENT_PROXY_URL'] ?? file.proxyUrl) ||\n (env['TOON_CLIENT_BTP_URL'] ?? file.btpUrl)\n ) &&\n Boolean(env['TOON_CLIENT_DESTINATION'] ?? file.destination) &&\n Boolean(file.supportedChains?.length) &&\n solanaExplicitlyComplete;\n let announce: AnnouncedPeer | undefined;\n if (!fullyExplicit) {\n try {\n const peers = await discoverAnnouncedPeers(relayUrl, {\n timeoutMs: DISCOVERY_TIMEOUT_MS,\n });\n announce = pickPaymentPeer(peers, genesisSeedPubkeys());\n if (!announce) {\n warn(\n `rig: no payment-peer announce (kind:10032) found on ${relayUrl} — ` +\n 'falling back to the genesis peer seed'\n );\n }\n } catch (err) {\n warn(\n `rig: announce discovery on ${relayUrl} failed ` +\n `(${err instanceof Error ? err.message : String(err)}) — falling ` +\n 'back to the genesis peer seed'\n );\n }\n }\n\n // ── Topology resolution (pure; explicit > announce > genesis) ──────────\n const resolved = await resolveNetworkTopology({\n env,\n file,\n configPath,\n relayUrl,\n announce,\n genesisSeed,\n identity: {\n mnemonic: identity.mnemonic,\n accountIndex: identity.accountIndex,\n pubkey: identity.pubkey,\n },\n channelRecords: () => chainRecordsFor(channelMap, identity.pubkey),\n ...(options.requireUplink !== undefined\n ? { requireUplink: options.requireUplink }\n : {}),\n warn,\n });\n // Cache only paid-path resolutions: a `requireUplink: false` free read\n // may resolve WITHOUT an uplink, and caching that would let a later paid\n // command skip past MissingUplinkError with a broken topology.\n if (options.requireUplink !== false) cache.write(cacheKey, resolved);\n return resolved;\n };\n\n const cached = cache.read(cacheKey);\n if (cached) {\n warn(\n `rig: network topology from cache (${Math.round(cached.ageMs / 1000)}s ` +\n `old; ${TOPOLOGY_TTL_ENV}=0 disables) — skipping announce discovery`\n );\n }\n const topology = cached?.topology ?? (await resolveLiveTopology());\n\n const eventFee = BigInt(file.feePerEvent ?? '1');\n\n const buildPublisher = (topo: NetworkTopology): StandalonePublisher => {\n const clientConfig: ToonClientConfig = {\n // validateConfig requires connectorUrl OR proxyUrl; with BTP-only\n // config a dummy connectorUrl satisfies it (unused at runtime — same\n // convention as the daemon).\n ...(topo.proxyUrl\n ? { proxyUrl: topo.proxyUrl }\n : { connectorUrl: 'http://127.0.0.1:1' }),\n mnemonic: identity.mnemonic,\n mnemonicAccountIndex: identity.accountIndex,\n ilpInfo: {\n pubkey: '00'.repeat(32),\n ilpAddress: 'g.toon.client',\n btpEndpoint: topo.btpUrl ?? '',\n assetCode: 'USD',\n assetScale: 6,\n },\n toonEncoder: encodeEventToToon,\n toonDecoder: decodeEventFromToon,\n ...(topo.btpUrl ? { btpUrl: topo.btpUrl, btpAuthToken: '' } : {}),\n destinationAddress: topo.destination,\n // The embedded client bootstraps against the known peer above; its\n // `relayUrl` config only seeds ArDrive-merged peers, so it stays unset.\n relayUrl: '',\n knownPeers: topo.knownPeers,\n channelStorePath,\n ...(topo.supportedChains\n ? { supportedChains: topo.supportedChains }\n : {}),\n ...(file.settlementAddresses\n ? { settlementAddresses: file.settlementAddresses }\n : {}),\n ...(topo.preferredTokens ? { preferredTokens: topo.preferredTokens } : {}),\n ...(topo.tokenNetworks ? { tokenNetworks: topo.tokenNetworks } : {}),\n ...(topo.chainRpcUrls ? { chainRpcUrls: topo.chainRpcUrls } : {}),\n // Solana channel params: an explicit config object wins verbatim; else\n // the topology's derivation (announce/presets — see resolveNetworkTopology).\n ...(file.solanaChannel\n ? { solanaChannel: file.solanaChannel }\n : topo.solanaChannel\n ? { solanaChannel: topo.solanaChannel }\n : {}),\n ...(file.minaChannel ? { minaChannel: file.minaChannel } : {}),\n };\n\n return new StandalonePublisher({\n clientConfig,\n eventFee,\n channelMap,\n warn,\n ...(topo.publishDestination\n ? { publishDestination: topo.publishDestination }\n : {}),\n ...(topo.storeDestination\n ? { storeDestination: topo.storeDestination }\n : {}),\n // Route-price floors (F06): every per-packet claim must advance the\n // channel by at least the destination route's announced price.\n ...(topo.routePrices\n ? {\n routePrices: {\n ...(topo.routePrices.publish !== undefined\n ? { publish: BigInt(topo.routePrices.publish) }\n : {}),\n ...(topo.routePrices.store !== undefined\n ? { store: BigInt(topo.routePrices.store) }\n : {}),\n },\n }\n : {}),\n // `rig channel open --peer` (#263): anchor the channel (and its map\n // key) to an explicit peer destination instead of the configured\n // default.\n ...(options.channelDestination\n ? { channelDestination: options.channelDestination }\n : {}),\n // The peer's announce does not carry TokenNetwork/token parameters, so\n // the client's negotiation leaves them empty (#260 root cause 3) — the\n // publisher back-fills them from the derived per-chain maps before the\n // channel opens.\n ...(topo.tokenNetworks || topo.preferredTokens\n ? {\n negotiationFallbacks: {\n ...(topo.tokenNetworks\n ? { tokenNetworks: topo.tokenNetworks }\n : {}),\n ...(topo.preferredTokens\n ? { preferredTokens: topo.preferredTokens }\n : {}),\n },\n }\n : {}),\n });\n };\n\n // Cache-sourced publishers get the #279 recovery hook: a failed bootstrap\n // invalidates the entry, re-resolves live (which re-writes the cache), and\n // retries once. Live-resolved publishers fail through unchanged.\n const publisher = new TopologyRecoveringPublisher(\n buildPublisher(topology),\n cached\n ? async () => {\n cache.invalidate(cacheKey);\n return buildPublisher(await resolveLiveTopology());\n }\n : undefined,\n warn\n );\n\n return {\n ownerPubkey: publisher.getPublicKey(),\n identitySource: identity.source,\n identitySourceLabel: identity.sourceLabel,\n publisher,\n defaultRelayUrls: [relayUrl],\n fetchRemote: (args) => fetchRemoteState(args),\n // Money lifecycle (#263): same guard/start/channel-map machinery as the\n // paid-write path, surfaced for fund/balance/channel open|close|settle.\n money: {\n openChannel: (opts) => publisher.openChannelExplicit(opts),\n closeChannel: (record) => publisher.closeRecordedChannel(record),\n settleChannel: (record) => publisher.settleRecordedChannel(record),\n walletChainBalances: () => publisher.readWalletChainBalances(),\n },\n stop: () => publisher.stop(),\n };\n}\n","/**\n * Standalone network-topology cache (#279): persist the #264 bootstrap\n * result — the announce-derived uplink, ILP routes, settlement chain and its\n * TokenNetwork/token/RPC parameters (or the genesis-seed fallback) — so\n * back-to-back CLI invocations skip the kind:10032 relay query, the\n * payment-peer pick, and the funded-chain `eth_call` probes.\n *\n * SAFETY MODEL — the cache holds only DISCOVERY results, never money state:\n *\n * - The claim watermark (nonce/cumulative) lives in the client's\n * `channels.json` and the #262 channel map, untouched by this cache;\n * every paid write still resumes from the persisted cumulative.\n * - Entries are keyed by relay-origin + identity pubkey + a fingerprint of\n * every explicit env/config field that feeds topology resolution, so a\n * changed relay, identity, or override can never hit a stale entry.\n * - Entries expire after a TTL (default 15 min;\n * `RIG_TOPOLOGY_TTL_MS` overrides, `0` disables the cache entirely).\n * - A cached topology that fails to bootstrap is EXPLICITLY invalidated\n * and re-resolved live (see `cli/standalone-mode.ts`), so a rotated peer\n * endpoint costs one failed attempt, not a broken 15 minutes.\n * - A corrupt/unreadable cache file is a MISS (discovery re-runs), never\n * an error: unlike the #262 channel map, nothing here guards money.\n *\n * Dependency-light on purpose (node:crypto + node:fs): the cached value is a\n * generic JSON document; `cli/standalone-mode.ts` instantiates the class\n * with its `NetworkTopology` shape and a structural validator.\n */\n\nimport { createHash } from 'node:crypto';\nimport { mkdirSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';\nimport { dirname } from 'node:path';\n\n/** Cache filename under the shared client state dir (`TOON_CLIENT_HOME`). */\nexport const TOPOLOGY_CACHE_FILENAME = 'rig-topology-cache.json';\n\n/** Default entry TTL: 15 minutes. */\nexport const DEFAULT_TOPOLOGY_TTL_MS = 15 * 60 * 1000;\n\n/** TTL env override (milliseconds; `0` disables caching entirely). */\nexport const TOPOLOGY_TTL_ENV = 'RIG_TOPOLOGY_TTL_MS';\n\n/** Resolve the entry TTL: `RIG_TOPOLOGY_TTL_MS` env (>= 0), else 15 min. */\nexport function topologyCacheTtlMs(env: NodeJS.ProcessEnv): number {\n const raw = env[TOPOLOGY_TTL_ENV];\n if (raw === undefined || raw === '') return DEFAULT_TOPOLOGY_TTL_MS;\n const parsed = Number(raw);\n return Number.isFinite(parsed) && parsed >= 0\n ? parsed\n : DEFAULT_TOPOLOGY_TTL_MS;\n}\n\n/**\n * Stable cache key: relay-origin + identity pubkey + the explicit-config\n * fingerprint. Hashed so the key is filename/JSON-safe and the mnemonic-side\n * inputs never appear in the cache file verbatim.\n */\nexport function topologyCacheKey(args: {\n relayUrl: string;\n identity: string;\n fingerprint: string;\n}): string {\n return createHash('sha256')\n .update(`${args.relayUrl}\\n${args.identity}\\n${args.fingerprint}`)\n .digest('hex');\n}\n\n/**\n * Canonical fingerprint of the explicit inputs that steer topology\n * resolution (see `resolveNetworkTopology`'s precedence order): the\n * TOON_CLIENT_* env overrides plus the shared-config fields. Any change\n * produces a different cache key — explicit config can never be shadowed by\n * a cached resolution made under different settings.\n */\nexport function explicitConfigFingerprint(\n env: NodeJS.ProcessEnv,\n file: Record<string, unknown>\n): string {\n const envKeys = [\n 'TOON_CLIENT_PROXY_URL',\n 'TOON_CLIENT_BTP_URL',\n 'TOON_CLIENT_DESTINATION',\n 'TOON_CLIENT_PUBLISH_DESTINATION',\n 'TOON_CLIENT_STORE_DESTINATION',\n 'TOON_CLIENT_CHAIN',\n 'TOON_CLIENT_NETWORK',\n ] as const;\n const fileKeys = [\n 'network',\n 'btpUrl',\n 'proxyUrl',\n 'destination',\n 'publishDestination',\n 'storeDestination',\n 'chain',\n 'supportedChains',\n 'settlementAddresses',\n 'preferredTokens',\n 'tokenNetworks',\n 'chainRpcUrls',\n ] as const;\n const picked: Record<string, unknown> = {};\n for (const key of envKeys) {\n if (env[key] !== undefined) picked[`env:${key}`] = env[key];\n }\n for (const key of fileKeys) {\n if (file[key] !== undefined) picked[`file:${key}`] = file[key];\n }\n // Keys are inserted in fixed order above → deterministic serialization.\n return JSON.stringify(picked);\n}\n\ninterface CacheEntry {\n /** ISO timestamp the entry was written. */\n cachedAt: string;\n /** The cached (JSON-safe) topology document. */\n topology: unknown;\n}\n\ninterface CacheFile {\n version: 1;\n entries: Record<string, CacheEntry>;\n}\n\nexport interface TopologyCacheOptions<T> {\n /** Cache file path (under `TOON_CLIENT_HOME`). */\n path: string;\n /** Entry TTL in ms; `0` (or negative) disables reads AND writes. */\n ttlMs: number;\n /** Structural validator for cached values (a failed check is a miss). */\n validate: (value: unknown) => value is T;\n /** Clock override (tests). */\n now?: () => number;\n}\n\n/**\n * File-backed, TTL'd topology cache. All operations are best-effort and\n * synchronous; failures degrade to cache misses / no-ops (discovery is the\n * always-correct fallback).\n */\nexport class TopologyCache<T> {\n readonly path: string;\n readonly ttlMs: number;\n private readonly validate: (value: unknown) => value is T;\n private readonly now: () => number;\n\n constructor(options: TopologyCacheOptions<T>) {\n this.path = options.path;\n this.ttlMs = options.ttlMs;\n this.validate = options.validate;\n this.now = options.now ?? Date.now;\n }\n\n /** True when the cache is disabled (`RIG_TOPOLOGY_TTL_MS=0`). */\n get disabled(): boolean {\n return this.ttlMs <= 0;\n }\n\n /**\n * A fresh, structurally-valid entry for `key` — or undefined (expired,\n * missing, invalid, corrupt file, or disabled). Also reports the entry age\n * for the \"topology from cache\" stderr line.\n */\n read(key: string): { topology: T; ageMs: number } | undefined {\n if (this.disabled) return undefined;\n const entry = this.readFile().entries[key];\n if (!entry) return undefined;\n const cachedAt = Date.parse(entry.cachedAt);\n if (!Number.isFinite(cachedAt)) return undefined;\n const ageMs = this.now() - cachedAt;\n if (ageMs < 0 || ageMs > this.ttlMs) return undefined;\n if (!this.validate(entry.topology)) return undefined;\n return { topology: entry.topology, ageMs };\n }\n\n /** Persist `topology` under `key` (prunes expired entries; best-effort). */\n write(key: string, topology: T): void {\n if (this.disabled) return;\n try {\n const file = this.readFile();\n const nowMs = this.now();\n const fresh = Object.fromEntries(\n Object.entries(file.entries).filter(([, entry]) => {\n const at = Date.parse(entry.cachedAt);\n return Number.isFinite(at) && nowMs - at <= this.ttlMs;\n })\n );\n fresh[key] = {\n cachedAt: new Date(nowMs).toISOString(),\n topology,\n };\n mkdirSync(dirname(this.path), { recursive: true });\n writeFileSync(\n this.path,\n JSON.stringify(\n { version: 1, entries: fresh } satisfies CacheFile,\n null,\n 2\n ),\n { mode: 0o600 }\n );\n } catch {\n // Best-effort — a failed write just means the next run discovers live.\n }\n }\n\n /** Drop `key` (a cached topology failed to bootstrap). Best-effort. */\n invalidate(key: string): void {\n try {\n const file = this.readFile();\n if (!(key in file.entries)) return;\n const remaining = Object.fromEntries(\n Object.entries(file.entries).filter(([k]) => k !== key)\n );\n if (Object.keys(remaining).length === 0) {\n unlinkSync(this.path);\n return;\n }\n writeFileSync(\n this.path,\n JSON.stringify(\n { version: 1, entries: remaining } satisfies CacheFile,\n null,\n 2\n ),\n { mode: 0o600 }\n );\n } catch {\n // Best-effort — worst case the entry expires by TTL.\n }\n }\n\n private readFile(): CacheFile {\n const empty: CacheFile = { version: 1, entries: {} };\n let raw: string;\n try {\n raw = readFileSync(this.path, 'utf8');\n } catch {\n return empty;\n }\n try {\n const parsed = JSON.parse(raw) as CacheFile;\n if (\n typeof parsed !== 'object' ||\n parsed === null ||\n parsed.version !== 1 ||\n typeof parsed.entries !== 'object' ||\n parsed.entries === null\n ) {\n return empty;\n }\n return parsed;\n } catch {\n return empty; // corrupt cache = miss, never an error (see module doc)\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAS,gBAAAA,qBAAoB;AAC7B,SAAS,eAAe;AACxB,SAAS,YAAY;AAErB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;;;ACnCP,SAAS,kBAAkB;AAC3B,SAAS,WAAW,cAAc,eAAe,kBAAkB;AACnE,SAAS,eAAe;AAGjB,IAAM,0BAA0B;AAGhC,IAAM,0BAA0B,KAAK,KAAK;AAG1C,IAAM,mBAAmB;AAGzB,SAAS,mBAAmB,KAAgC;AACjE,QAAM,MAAM,IAAI,gBAAgB;AAChC,MAAI,QAAQ,UAAa,QAAQ,GAAI,QAAO;AAC5C,QAAM,SAAS,OAAO,GAAG;AACzB,SAAO,OAAO,SAAS,MAAM,KAAK,UAAU,IACxC,SACA;AACN;AAOO,SAAS,iBAAiB,MAItB;AACT,SAAO,WAAW,QAAQ,EACvB,OAAO,GAAG,KAAK,QAAQ;AAAA,EAAK,KAAK,QAAQ;AAAA,EAAK,KAAK,WAAW,EAAE,EAChE,OAAO,KAAK;AACjB;AASO,SAAS,0BACd,KACA,MACQ;AACR,QAAM,UAAU;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,SAAS;AACzB,QAAI,IAAI,GAAG,MAAM,OAAW,QA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L,aAAa,UAAU,aAAa;AAAA,IACpC,gBAAgB,SAAS;AAAA,IACzB,qBAAqB,SAAS;AAAA,IAC9B;AAAA,IACA,kBAAkB,CAAC,QAAQ;AAAA,IAC3B,aAAa,CAAC,SAAS,iBAAiB,IAAI;AAAA;AAAA;AAAA,IAG5C,OAAO;AAAA,MACL,aAAa,CAAC,SAAS,UAAU,oBAAoB,IAAI;AAAA,MACzD,cAAc,CAAC,WAAW,UAAU,qBAAqB,MAAM;AAAA,MAC/D,eAAe,CAAC,WAAW,UAAU,sBAAsB,MAAM;AAAA,MACjE,qBAAqB,MAAM,UAAU,wBAAwB;AAAA,IAC/D;AAAA,IACA,MAAM,MAAM,UAAU,KAAK;AAAA,EAC7B;AACF;","names":["readFileSync","readFileSync"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/objects.ts"],"sourcesContent":["/**\n * Pure git object construction and SHA-1 envelope hashing.\n *\n * Promoted from `packages/rig-web/tests/e2e/seed/lib/git-builder.ts` (#223) —\n * the proven seed pipeline builders, now the core of the Git-to-TOON write\n * path. Everything here is pure: no network, no signing, no payments.\n * Upload/publish lives with the Publisher (#226).\n *\n * Git object format: `<type> <size>\\0<content>`. The SHA-1 is computed over\n * the full envelope (header + NUL + content); the `body` (content only) is\n * what gets uploaded to Arweave.\n */\n\nimport { createHash } from 'node:crypto';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** All git object types TOON can carry. */\nexport type GitObjectType = 'blob' | 'tree' | 'commit' | 'tag';\n\nexport interface GitObject {\n /** SHA-1 hex digest computed over full git envelope */\n sha: string;\n /** Full git object (header + null + content) */\n buffer: Buffer;\n /** Body only (content after the null byte) — this is what gets uploaded */\n body: Buffer;\n}\n\n/**\n * Maximum uploadable git object body size: 95KB safety margin under the\n * 100KB free tier (R10-005). Larger objects are a hard error in v1.\n */\nexport const MAX_OBJECT_SIZE = 95 * 1024;\n\n/**\n * Git's universal empty-blob SHA-1: the object for a zero-byte file.\n *\n * It is the ONLY zero-byte object git can produce (trees, commits, and tags\n * are never empty) and it always has this exact constant value. The store\n * rejects a zero-byte kind:5094 blob upload as malformed (F00), so `rig` never\n * uploads this object — it is skipped on push and synthesized locally on\n * clone/fetch (both keyed off an ACTUAL zero-length body, never a heuristic).\n */\nexport const EMPTY_BLOB_SHA = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391';\n\n// ---------------------------------------------------------------------------\n// Envelope hashing\n// ---------------------------------------------------------------------------\n\n/**\n * Wrap a raw object body in the git envelope (`<type> <size>\\0`) and compute\n * its SHA-1. This is exactly what `git hash-object -t <type>` does.\n */\nexport function hashGitObject(type: GitObjectType, body: Buffer): GitObject {\n const header = Buffer.from(`${type} ${body.length}\\0`);\n const fullObject = Buffer.concat([header, body]);\n const sha = createHash('sha1').update(fullObject).digest('hex');\n return { sha, buffer: fullObject, body };\n}\n\n// ---------------------------------------------------------------------------\n// Git object construction\n// ---------------------------------------------------------------------------\n\n/**\n * Construct a git blob object and compute its SHA-1.\n *\n * Format: blob <size>\\0<content>\n * SHA is over the full envelope; body is content only (for upload).\n */\nexport function createGitBlob(content: string): GitObject {\n return hashGitObject('blob', Buffer.from(content, 'utf-8'));\n}\n\n/**\n * Construct a git tree object from sorted entries.\n *\n * Format: tree <size>\\0<entries>\n * Each entry: <mode> <name>\\0<20-byte-raw-sha1>\n * Entries MUST be sorted by name (byte-wise).\n */\nexport function createGitTree(\n entries: { mode: string; name: string; sha: string }[]\n): GitObject {\n // Git sorts tree entries by raw byte order (NOT locale-aware)\n const sorted = [...entries].sort((a, b) =>\n a.name < b.name ? -1 : a.name > b.name ? 1 : 0\n );\n\n const entryBuffers: Buffer[] = [];\n for (const entry of sorted) {\n const modeAndName = Buffer.from(`${entry.mode} ${entry.name}\\0`);\n // Raw 20-byte SHA-1 (NOT hex)\n const rawSha = Buffer.from(entry.sha, 'hex');\n entryBuffers.push(Buffer.concat([modeAndName, rawSha]));\n }\n\n return hashGitObject('tree', Buffer.concat(entryBuffers));\n}\n\n/**\n * Construct a git commit object.\n *\n * Format: commit <size>\\0tree <tree-sha>\\n[parent ...]\\nauthor ...\\ncommitter ...\\n\\n<message>\n * Tree/parent SHAs are hex-encoded (40 chars) in commits, unlike tree entries.\n */\nexport function createGitCommit(opts: {\n treeSha: string;\n parentSha?: string;\n authorName: string;\n authorPubkey: string;\n message: string;\n timestamp: number;\n}): GitObject {\n const lines = [\n `tree ${opts.treeSha}`,\n ...(opts.parentSha ? [`parent ${opts.parentSha}`] : []),\n `author ${opts.authorName} <${opts.authorPubkey}@nostr> ${opts.timestamp} +0000`,\n `committer ${opts.authorName} <${opts.authorPubkey}@nostr> ${opts.timestamp} +0000`,\n '',\n opts.message,\n ];\n return hashGitObject('commit', Buffer.from(lines.join('\\n'), 'utf-8'));\n}\n\n/**\n * Construct an annotated git tag object.\n *\n * Format: tag <size>\\0object <sha>\\ntype <type>\\ntag <name>\\ntagger ...\\n\\n<message>\n * The tagged object is usually a commit, but git allows tagging any object\n * type (including another tag).\n */\nexport function createGitTag(opts: {\n /** SHA-1 of the object being tagged (hex, 40 chars) */\n objectSha: string;\n /** Type of the tagged object (usually 'commit') */\n objectType: GitObjectType;\n /** Tag name, e.g. 'v1.0.0' */\n tagName: string;\n taggerName: string;\n taggerPubkey: string;\n message: string;\n timestamp: number;\n}): GitObject {\n const lines = [\n `object ${opts.objectSha}`,\n `type ${opts.objectType}`,\n `tag ${opts.tagName}`,\n `tagger ${opts.taggerName} <${opts.taggerPubkey}@nostr> ${opts.timestamp} +0000`,\n '',\n opts.message,\n ];\n return hashGitObject('tag', Buffer.from(lines.join('\\n'), 'utf-8'));\n}\n"],"mappings":";AAaA,SAAS,kBAAkB;AAsBpB,IAAM,kBAAkB,KAAK;AAW7B,IAAM,iBAAiB;AAUvB,SAAS,cAAc,MAAqB,MAAyB;AAC1E,QAAM,SAAS,OAAO,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,IAAI;A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