@toon-protocol/rig 2.13.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AA4RBCSI.js → chunk-4CAOEXGQ.js} +47 -90
- package/dist/chunk-4CAOEXGQ.js.map +1 -0
- package/dist/{chunk-35ALWUDJ.js → chunk-B5ISARMU.js} +2 -10
- package/dist/chunk-B5ISARMU.js.map +1 -0
- package/dist/{chunk-EEUHZNWS.js → chunk-FBIHO3RS.js} +27 -11
- package/dist/chunk-FBIHO3RS.js.map +1 -0
- package/dist/{chunk-FQXNLPUR.js → chunk-LCYCKWAT.js} +10 -1
- package/dist/chunk-LCYCKWAT.js.map +1 -0
- package/dist/cli/rig.js +78 -28
- package/dist/cli/rig.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -4
- package/dist/{publisher-ftQeZSib.d.ts → publisher-BFcnZeJI.d.ts} +19 -20
- package/dist/standalone/index.d.ts +58 -40
- package/dist/standalone/index.js +3 -3
- package/dist/{standalone-mode-RG4PGALC.js → standalone-mode-X6W2RLTE.js} +30 -9
- package/dist/standalone-mode-X6W2RLTE.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-35ALWUDJ.js.map +0 -1
- package/dist/chunk-AA4RBCSI.js.map +0 -1
- package/dist/chunk-EEUHZNWS.js.map +0 -1
- package/dist/chunk-FQXNLPUR.js.map +0 -1
- package/dist/standalone-mode-RG4PGALC.js.map +0 -1
|
@@ -4,14 +4,13 @@ import {
|
|
|
4
4
|
checkDaemonIdentity,
|
|
5
5
|
contentTypeForPath,
|
|
6
6
|
recordKey
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LCYCKWAT.js";
|
|
8
8
|
import {
|
|
9
|
-
MAX_OBJECT_SIZE
|
|
10
|
-
|
|
11
|
-
} from "./chunk-35ALWUDJ.js";
|
|
9
|
+
MAX_OBJECT_SIZE
|
|
10
|
+
} from "./chunk-B5ISARMU.js";
|
|
12
11
|
|
|
13
12
|
// src/standalone/standalone-publisher.ts
|
|
14
|
-
import { ToonClient,
|
|
13
|
+
import { ToonClient, extractArweaveTxId } from "@toon-protocol/client";
|
|
15
14
|
var StandalonePublishError = class extends Error {
|
|
16
15
|
constructor(message) {
|
|
17
16
|
super(message);
|
|
@@ -26,48 +25,6 @@ function deriveRouteDestinations(anchor) {
|
|
|
26
25
|
}
|
|
27
26
|
return { publish: anchor, store: anchor };
|
|
28
27
|
}
|
|
29
|
-
var ARWEAVE_TX_ID_REGEX = /^[A-Za-z0-9_-]{43}$/;
|
|
30
|
-
function extractArweaveTxId(base64Data) {
|
|
31
|
-
const http = parseFulfillHttp(base64Data);
|
|
32
|
-
if (!http.isHttp) {
|
|
33
|
-
const legacy = Buffer.from(base64Data, "base64").toString("utf8");
|
|
34
|
-
if (!ARWEAVE_TX_ID_REGEX.test(legacy)) {
|
|
35
|
-
throw new StandalonePublishError(
|
|
36
|
-
`FULFILL data is not a valid Arweave tx ID: "${legacy}"`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return legacy;
|
|
40
|
-
}
|
|
41
|
-
if (http.status < 200 || http.status >= 300) {
|
|
42
|
-
throw new StandalonePublishError(
|
|
43
|
-
`git-object upload failed: store returned HTTP ${http.status}` + (http.body ? ` - ${http.body}` : "")
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
let parsed;
|
|
47
|
-
try {
|
|
48
|
-
parsed = JSON.parse(http.body);
|
|
49
|
-
} catch {
|
|
50
|
-
throw new StandalonePublishError(
|
|
51
|
-
`git-object upload response body was not valid JSON: "${http.body}"`
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
if (parsed.accept === false) {
|
|
55
|
-
const reason = typeof parsed.error === "string" ? `: ${parsed.error}` : "";
|
|
56
|
-
throw new StandalonePublishError(
|
|
57
|
-
`git-object upload rejected by store (accept:false)${reason}`
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
if (typeof parsed.txId === "string" && ARWEAVE_TX_ID_REGEX.test(parsed.txId)) {
|
|
61
|
-
return parsed.txId;
|
|
62
|
-
}
|
|
63
|
-
if (typeof parsed.data === "string" && parsed.data.length > 0) {
|
|
64
|
-
const decoded = Buffer.from(parsed.data, "base64").toString("utf8");
|
|
65
|
-
if (ARWEAVE_TX_ID_REGEX.test(decoded)) return decoded;
|
|
66
|
-
}
|
|
67
|
-
throw new StandalonePublishError(
|
|
68
|
-
`git-object upload response did not contain a valid Arweave tx ID: "${http.body}"`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
28
|
function channelInternals(client) {
|
|
72
29
|
const c = client;
|
|
73
30
|
const negotiations = c.peerNegotiations instanceof Map ? c.peerNegotiations : void 0;
|
|
@@ -86,9 +43,9 @@ var StandalonePublisher = class {
|
|
|
86
43
|
storeDestination;
|
|
87
44
|
channelDestination;
|
|
88
45
|
eventFee;
|
|
89
|
-
uploadFeePerByte;
|
|
90
46
|
routePrices;
|
|
91
47
|
daemonPort;
|
|
48
|
+
skipDaemonCheck;
|
|
92
49
|
lockDir;
|
|
93
50
|
fetchImpl;
|
|
94
51
|
channelMap;
|
|
@@ -126,9 +83,9 @@ var StandalonePublisher = class {
|
|
|
126
83
|
this.storeDestination = options.storeDestination ?? routes?.store;
|
|
127
84
|
this.channelDestination = options.channelDestination;
|
|
128
85
|
this.eventFee = options.eventFee ?? 1n;
|
|
129
|
-
this.uploadFeePerByte = options.uploadFeePerByte ?? 10n;
|
|
130
86
|
this.routePrices = options.routePrices;
|
|
131
87
|
this.daemonPort = options.daemonPort;
|
|
88
|
+
this.skipDaemonCheck = options.skipDaemonCheck ?? false;
|
|
132
89
|
this.lockDir = options.lockDir;
|
|
133
90
|
this.fetchImpl = options.fetchImpl;
|
|
134
91
|
this.channelMap = options.channelMap;
|
|
@@ -178,10 +135,12 @@ var StandalonePublisher = class {
|
|
|
178
135
|
}
|
|
179
136
|
async doStartClient() {
|
|
180
137
|
const pubkey = this.client.getPublicKey();
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
138
|
+
if (!this.skipDaemonCheck) {
|
|
139
|
+
await checkDaemonIdentity(pubkey, {
|
|
140
|
+
...this.daemonPort !== void 0 ? { port: this.daemonPort } : {},
|
|
141
|
+
...this.fetchImpl ? { fetchImpl: this.fetchImpl } : {}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
185
144
|
this.lock = await NonceLock.acquire(pubkey, {
|
|
186
145
|
...this.lockDir !== void 0 ? { dir: this.lockDir } : {}
|
|
187
146
|
});
|
|
@@ -249,7 +208,11 @@ var StandalonePublisher = class {
|
|
|
249
208
|
const identity = this.client.getPublicKey();
|
|
250
209
|
const candidates = map.listFor(identity, anchor);
|
|
251
210
|
const internals = channelInternals(this.client);
|
|
252
|
-
const resumed = await this.resumeRecordedChannel(
|
|
211
|
+
const resumed = await this.resumeRecordedChannel(
|
|
212
|
+
map,
|
|
213
|
+
candidates,
|
|
214
|
+
internals
|
|
215
|
+
);
|
|
253
216
|
const channelId = await this.client.openChannel(this.channelDestination);
|
|
254
217
|
if (resumed && channelId === resumed.channelId) {
|
|
255
218
|
this.lastOpenResumed = true;
|
|
@@ -474,28 +437,24 @@ var StandalonePublisher = class {
|
|
|
474
437
|
* client (no nonce guard, no uplink, no channel). The client derives the
|
|
475
438
|
* Solana/Mina addresses from the mnemonic on demand, so ALL configured chains
|
|
476
439
|
* appear even before a start. Best-effort per chain (an unreachable RPC yields
|
|
477
|
-
* an `unreadable` chain, not a failure).
|
|
440
|
+
* an `unreadable` chain, not a failure). `fallback` supplies Solana/Mina RPC
|
|
441
|
+
* defaults (e.g. the network preset) for chains the config has no channel for.
|
|
478
442
|
*/
|
|
479
|
-
async readWalletChainBalances() {
|
|
443
|
+
async readWalletChainBalances(fallback) {
|
|
480
444
|
if (!this.client.getWalletBalances) return [];
|
|
481
|
-
return await this.client.getWalletBalances();
|
|
445
|
+
return await this.client.getWalletBalances(fallback);
|
|
482
446
|
}
|
|
483
447
|
// ── Publisher ─────────────────────────────────────────────────────────────
|
|
484
448
|
/**
|
|
485
|
-
* Fee rates for `planPush` estimation
|
|
486
|
-
*
|
|
487
|
-
*
|
|
488
|
-
*
|
|
489
|
-
* `eventFee` is returned pre-floored at the publish route price, and the
|
|
490
|
-
* store route price rides as `minUploadFee` (the per-upload floor —
|
|
491
|
-
* per-byte pricing can't fold a flat floor into the rate).
|
|
449
|
+
* Fee rates for `planPush` estimation, both flat per packet (ADR 0020),
|
|
450
|
+
* with the announced route prices folded in so the ESTIMATE always equals
|
|
451
|
+
* the CLAIMS: `eventFee` is returned pre-floored at the publish route price,
|
|
452
|
+
* and `uploadFee` IS the store route price.
|
|
492
453
|
*/
|
|
493
454
|
getFeeRates() {
|
|
494
|
-
const minUploadFee = this.routePrices?.store;
|
|
495
455
|
return Promise.resolve({
|
|
496
|
-
|
|
497
|
-
eventFee: this.effectiveEventFee()
|
|
498
|
-
...minUploadFee !== void 0 ? { minUploadFee } : {}
|
|
456
|
+
uploadFee: this.uploadFee(),
|
|
457
|
+
eventFee: this.effectiveEventFee()
|
|
499
458
|
});
|
|
500
459
|
}
|
|
501
460
|
/**
|
|
@@ -507,21 +466,20 @@ var StandalonePublisher = class {
|
|
|
507
466
|
return this.eventFee > min ? this.eventFee : min;
|
|
508
467
|
}
|
|
509
468
|
/**
|
|
510
|
-
* The per-upload claim:
|
|
511
|
-
*
|
|
469
|
+
* The per-upload claim: the store route's flat price, whatever the object's
|
|
470
|
+
* size. Byte-proportional pricing has no successor (ADR 0020) — the route
|
|
471
|
+
* table is the price list — and the connector charges this figure whether
|
|
472
|
+
* the body is 100 bytes or 100 KB.
|
|
512
473
|
*/
|
|
513
|
-
uploadFee(
|
|
514
|
-
return
|
|
515
|
-
bytes,
|
|
516
|
-
this.uploadFeePerByte,
|
|
517
|
-
this.routePrices?.store
|
|
518
|
-
);
|
|
474
|
+
uploadFee() {
|
|
475
|
+
return this.routePrices?.store ?? 0n;
|
|
519
476
|
}
|
|
520
477
|
/**
|
|
521
478
|
* Upload one git object as a kind:5094 store write (Git-SHA/Git-Type/Repo
|
|
522
479
|
* tagged — the proven seed-pipeline shape), signing one balance-proof claim
|
|
523
|
-
* for
|
|
524
|
-
*
|
|
480
|
+
* for the store route's flat price
|
|
481
|
+
* ({@link StandalonePublisherOptions.routePrices}) — ADR 0020 prices a
|
|
482
|
+
* packet per handler, not per byte.
|
|
525
483
|
*
|
|
526
484
|
* #368: a blob's `Content-Type` is derived from its path extension (else
|
|
527
485
|
* octet-stream) and sent in the `output` tag, which the store forwards onto
|
|
@@ -538,7 +496,7 @@ var StandalonePublisher = class {
|
|
|
538
496
|
await this.start();
|
|
539
497
|
const channelId = this.requireChannel();
|
|
540
498
|
const contentType = upload.type === "blob" ? contentTypeForPath(upload.path) : DEFAULT_CONTENT_TYPE;
|
|
541
|
-
const fee = this.uploadFee(
|
|
499
|
+
const fee = this.uploadFee();
|
|
542
500
|
const event = this.client.signEvent({
|
|
543
501
|
kind: 5094,
|
|
544
502
|
content: "",
|
|
@@ -565,12 +523,12 @@ var StandalonePublisher = class {
|
|
|
565
523
|
`git-object upload rejected (${upload.sha}): ${result.error ?? "store rejected the write"}`
|
|
566
524
|
);
|
|
567
525
|
}
|
|
568
|
-
if (!result.
|
|
526
|
+
if (!result.response) {
|
|
569
527
|
throw new StandalonePublishError(
|
|
570
|
-
`git-object upload FULFILL carried no
|
|
528
|
+
`git-object upload FULFILL carried no sealed response (${upload.sha}); expected the Arweave tx ID`
|
|
571
529
|
);
|
|
572
530
|
}
|
|
573
|
-
return { txId: extractArweaveTxId(result.
|
|
531
|
+
return { txId: extractArweaveTxId(result.response), feePaid: fee };
|
|
574
532
|
}
|
|
575
533
|
/**
|
|
576
534
|
* Upload one raw blob (no git envelope) with an explicit `Content-Type`
|
|
@@ -578,8 +536,7 @@ var StandalonePublisher = class {
|
|
|
578
536
|
* tags (and an optional `Repo` provenance tag), NOT the Git-SHA/Git-Type
|
|
579
537
|
* tags. Without those the store keeps the bytes verbatim instead of
|
|
580
538
|
* re-deriving a git envelope, which is exactly what the ar.io path manifest
|
|
581
|
-
* needs. One balance-proof claim for
|
|
582
|
-
* floored at the store route's announced price.
|
|
539
|
+
* needs. One balance-proof claim for the store route's flat price.
|
|
583
540
|
*/
|
|
584
541
|
async uploadBlob(upload) {
|
|
585
542
|
if (upload.body.length > MAX_OBJECT_SIZE) {
|
|
@@ -589,7 +546,7 @@ var StandalonePublisher = class {
|
|
|
589
546
|
}
|
|
590
547
|
await this.start();
|
|
591
548
|
const channelId = this.requireChannel();
|
|
592
|
-
const fee = this.uploadFee(
|
|
549
|
+
const fee = this.uploadFee();
|
|
593
550
|
const event = this.client.signEvent({
|
|
594
551
|
kind: 5094,
|
|
595
552
|
content: "",
|
|
@@ -613,12 +570,12 @@ var StandalonePublisher = class {
|
|
|
613
570
|
`blob upload rejected: ${result.error ?? "store rejected the write"}`
|
|
614
571
|
);
|
|
615
572
|
}
|
|
616
|
-
if (!result.
|
|
573
|
+
if (!result.response) {
|
|
617
574
|
throw new StandalonePublishError(
|
|
618
|
-
"blob upload FULFILL carried no
|
|
575
|
+
"blob upload FULFILL carried no sealed response; expected the Arweave tx ID"
|
|
619
576
|
);
|
|
620
577
|
}
|
|
621
|
-
return { txId: extractArweaveTxId(result.
|
|
578
|
+
return { txId: extractArweaveTxId(result.response), feePaid: fee };
|
|
622
579
|
}
|
|
623
580
|
/**
|
|
624
581
|
* Sign the event with the embedded identity and pay-to-publish it through
|
|
@@ -666,9 +623,9 @@ function nowSeconds() {
|
|
|
666
623
|
}
|
|
667
624
|
|
|
668
625
|
export {
|
|
626
|
+
extractArweaveTxId,
|
|
669
627
|
StandalonePublishError,
|
|
670
628
|
deriveRouteDestinations,
|
|
671
|
-
extractArweaveTxId,
|
|
672
629
|
StandalonePublisher
|
|
673
630
|
};
|
|
674
|
-
//# sourceMappingURL=chunk-
|
|
631
|
+
//# sourceMappingURL=chunk-4CAOEXGQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/standalone/standalone-publisher.ts"],"sourcesContent":["/**\n * StandalonePublisher — impl 2 of the {@link Publisher} seam (#228): an\n * EMBEDDED ToonClient constructed from the caller's config (mnemonic +\n * account index, the exact `packages/client/src/config.ts` shape) instead of\n * routing through a running toon-clientd. Made for CI jobs, servers, and\n * one-shot CLI runs where no daemon exists.\n *\n * Paid-write mechanics mirror the production daemon path\n * (`client-mcp/src/daemon/client-runner.ts`) and the proven seed pipeline\n * (`rig/tests/e2e/seed/lib/{publish,git-builder}.ts`):\n *\n * - one signed balance-proof CLAIM per write (`signBalanceProof(channelId,\n * fee)` — the ChannelManager accumulates the cumulative watermark),\n * - publishes route to the relay write destination with a flat per-event\n * fee (the daemon's `feePerEvent` convention),\n * - git objects upload as kind:5094 store writes tagged\n * Git-SHA/Git-Type/Repo, priced at bytes × per-byte rate (the seed\n * pipeline's bid), routed to the store destination via `proxyPath:\n * '/store'`, with the Arweave txId decoded from the FULFILL data.\n *\n * Because the embedded client signs claims on the SAME channels a daemon on\n * the same identity would, every paid operation is preceded by the nonce\n * guard (./nonce-guard.ts): refuse if a toon-clientd holds this identity,\n * and hold an exclusive per-pubkey lockfile against other standalone\n * processes for the lifetime of this publisher.\n *\n * Channel REUSE (#262): with a `channelMap` configured, start() resumes the\n * channel recorded for (identity, channel anchor) — `trackChannel` rehydrates\n * the cumulative-claim watermark from the client's channels.json — and\n * records any fresh lazy open, so sequential CLI invocations share ONE\n * on-chain channel instead of stranding a deposit per run (./channel-map.ts).\n */\n\nimport type {\n PublishEventResult,\n SignedBalanceProof,\n ToonClientConfig,\n} from '@toon-protocol/client';\nimport { ToonClient, extractArweaveTxId } from '@toon-protocol/client';\nimport { MAX_OBJECT_SIZE } from '../objects.js';\nimport { contentTypeForPath, DEFAULT_CONTENT_TYPE } from '../mime.js';\nimport type { UnsignedEvent } from '../nip34-events.js';\nimport {\n type BlobUpload,\n type FeeRates,\n type GitObjectUpload,\n type PublishReceipt,\n type Publisher,\n type UploadReceipt,\n} from '../publisher.js';\nimport {\n recordKey,\n type ChannelMapRecord,\n type ChannelMapStore,\n type PersistedChannelContext,\n} from './channel-map.js';\nimport type {\n ChannelCloseOutcome,\n ChannelOpenOutcome,\n ChannelSettleOutcome,\n WalletChainBalanceInfo,\n} from './money.js';\nimport { checkDaemonIdentity, NonceLock } from './nonce-guard.js';\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** A fully-signed Nostr event (structural subset of nostr-tools' NostrEvent). */\nexport interface SignedNostrEvent extends UnsignedEvent {\n id: string;\n pubkey: string;\n sig: string;\n}\n\n/**\n * The slice of `ToonClient` the publisher drives. Kept structural so tests\n * inject a mock and alternative client builds stay compatible.\n */\nexport interface ToonClientLike {\n start(): Promise<unknown>;\n stop(): Promise<void>;\n isStarted?(): boolean;\n getPublicKey(): string;\n signEvent(template: UnsignedEvent): SignedNostrEvent;\n openChannel(destination?: string): Promise<string>;\n signBalanceProof(\n channelId: string,\n amount: bigint\n ): Promise<SignedBalanceProof>;\n publishEvent(\n event: SignedNostrEvent,\n options?: {\n destination?: string;\n claim?: SignedBalanceProof;\n ilpAmount?: bigint;\n proxyPath?: string;\n }\n ): Promise<PublishEventResult>;\n /** On-chain deposit total for a tracked channel (channel-map bookkeeping). */\n getChannelDepositTotal?(channelId: string): bigint;\n /** Re-read a RESUMED channel's on-chain deposit (persisted state omits it). */\n rehydrateChannelDeposit?(\n channelId: string,\n opts: { chain: string; tokenNetworkAddress: string }\n ): Promise<bigint | undefined>;\n // ── money lifecycle (#263) — optional, matches ToonClient's surface ──────\n /** Deposit extra collateral (base-unit delta) into an open channel. */\n depositToChannel?(\n channelId: string,\n amount: string | bigint\n ): Promise<{ channelId: string; txHash?: string; depositTotal: string }>;\n /** Close a channel — starts the settlement challenge window (on-chain). */\n closeChannel?(channelId: string): Promise<{\n channelId: string;\n txHash?: string;\n /** Unix SECONDS, string-encoded. */\n closedAt: string;\n settleableAt: string;\n }>;\n /** Settle a closed channel after its window — releases funds (on-chain). */\n settleChannel?(\n channelId: string\n ): Promise<{ channelId: string; txHash?: string }>;\n /**\n * Free FULL multi-chain wallet view (#299) — native coin + configured tokens\n * per chain — works on an UNSTARTED client (Solana/Mina addresses are derived\n * from the mnemonic on demand). `fallback` supplies Solana/Mina channel params\n * to read WHEN the client config has none, without touching settlement config.\n */\n getWalletBalances?(\n fallback?: WalletViewFallback\n ): Promise<WalletChainBalanceInfo[]>;\n}\n\n/**\n * Wallet-view-only Solana/Mina channel defaults (#299): RPC/GraphQL + token used\n * to READ the balance of a chain the identity has no configured channel for, so\n * `rig balance` shows all three chains (0 for a not-yet-on-chain account). These\n * NEVER enter the client's settlement config — they cannot influence chain\n * negotiation — so a preset default here is safe even for a chain the wallet\n * cannot yet settle on.\n */\nexport interface WalletViewFallback {\n solanaChannel?: ToonClientConfig['solanaChannel'];\n minaChannel?: ToonClientConfig['minaChannel'];\n}\n\nexport interface StandalonePublisherOptions {\n /**\n * ToonClient config (mnemonic + mnemonicAccountIndex + proxy/BTP uplink +\n * settlement fields — see `packages/client/src/config.ts`). Exactly one of\n * `clientConfig` | `client` is required.\n */\n clientConfig?: ToonClientConfig;\n /** Pre-built client (tests / advanced callers). */\n client?: ToonClientLike;\n /**\n * ILP route for event publishes (relay `/write`). Default: derived from the\n * config's `destinationAddress` anchor (`<base>.relay.store` → `<base>.relay`,\n * matching the daemon's route derivation), else the anchor itself.\n */\n publishDestination?: string;\n /**\n * ILP route for git-object uploads (store `/store` → Arweave). Default:\n * derived like `publishDestination` (`<base>.relay.store` → `<base>.store`).\n */\n storeDestination?: string;\n /**\n * ILP destination the payment channel anchors to. Default: the client\n * config's `destinationAddress`.\n */\n channelDestination?: string;\n /** Flat fee per published event (daemon `feePerEvent` convention). Default 1n. */\n eventFee?: bigint;\n /**\n * FLAT per-packet route prices for the publish/store destinations, as the\n * payment peer announces them (kind:10032 `capabilities` — e.g.\n * `{capability:'os.publish', address:'g.proxy.relay', price:'1000'}`) or as\n * the terminating connector reports them from `GET /ilp/routes/price`.\n *\n * The connector gates every paid packet at the destination route's price: a\n * balance-proof claim advancing the channel by less is rejected (F06). Since\n * ADR 0020 (toon-client#452) a price is flat per handler, so `store` is the\n * WHOLE upload fee rather than a floor under a per-byte computation — an\n * upload of any size costs it. `publish` still floors {@link eventFee},\n * which remains a caller-chosen flat figure.\n *\n * A destination without a known price prices its packets at 0 here and lets\n * the connector be the one to refuse — this class never invents a rate.\n */\n routePrices?: { publish?: bigint; store?: bigint };\n /** Daemon control API port probed by the nonce guard. */\n daemonPort?: number;\n /**\n * Skip Guard 1 (the same-identity daemon refusal, {@link checkDaemonIdentity})\n * — the force-standalone override ({@link standaloneForced} / RIG_STANDALONE\n * / `rig --standalone`). Guard 2, the exclusive per-identity {@link NonceLock},\n * ALWAYS runs regardless, so two standalone processes still can't race the\n * channel watermark. Default false (daemon-aware).\n */\n skipDaemonCheck?: boolean;\n /** Directory for the per-identity advisory lockfile. */\n lockDir?: string;\n /** Fetch impl for the daemon probe (tests). */\n fetchImpl?: typeof fetch;\n /**\n * Peer→channel map store (#262): start() resumes the channel recorded for\n * (identity, channel anchor) instead of opening a fresh one, and records\n * any fresh lazy open for the next invocation. Absent (embedded callers\n * managing their own channel lifecycle): the historical behaviour — open\n * lazily every run, record nothing.\n */\n channelMap?: ChannelMapStore;\n /**\n * Per-chain settlement parameters to BACK-FILL into the client's peer\n * negotiations after start (#264/#260): peers whose kind:10032 announce\n * carries no `tokenNetworks`/`preferredTokens` negotiate with those fields\n * empty, and the on-chain channel open then fails (\"tokenNetwork address\n * is required\"). Values here never override what a peer DID announce —\n * they only fill gaps, keyed by the negotiated chain id.\n */\n negotiationFallbacks?: {\n tokenNetworks?: Record<string, string>;\n preferredTokens?: Record<string, string>;\n };\n /** Sink for non-fatal channel-persistence warnings (default: stderr). */\n warn?: (line: string) => void;\n}\n\n/** A relay/store rejected a paid write (fee NOT spent iff the claim failed too). */\nexport class StandalonePublishError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'StandalonePublishError';\n }\n}\n\n// ---------------------------------------------------------------------------\n// Route derivation (duplicated from client-mcp daemon/config.ts — that\n// package depends on this one for #227, so importing it back would be\n// circular; keep in sync)\n// ---------------------------------------------------------------------------\n\n/**\n * Derive publish/store routes from the channel anchor. Behind the devnet\n * proxy the anchor is `<base>.relay.store` (e.g. `g.proxy.relay.store`):\n * publishes terminate at `<base>.relay`, uploads at `<base>.store`. Anchors\n * not matching the convention pass through unchanged.\n */\nexport function deriveRouteDestinations(anchor: string): {\n publish: string;\n store: string;\n} {\n const segs = anchor.split('.');\n if (segs.at(-1) === 'store' && segs.at(-2) === 'relay') {\n const base = segs.slice(0, -2).join('.');\n return { publish: `${base}.relay`, store: `${base}.store` };\n }\n return { publish: anchor, store: anchor };\n}\n\n// ---------------------------------------------------------------------------\n// FULFILL → Arweave txId\n// ---------------------------------------------------------------------------\n\n/**\n * Decode the Arweave txId from a store-write answer.\n *\n * Re-exported from `@toon-protocol/client` rather than reimplemented: this\n * file used to carry its own copy because the client's extractor was thought\n * not to be exported. It is (and always was), and now that the answer is a\n * sealed response envelope rather than HTTP text there is exactly one shape\n * to read — a second reader of it could only drift.\n */\nexport { extractArweaveTxId };\n\n// ---------------------------------------------------------------------------\n// Channel-resume introspection (#262)\n//\n// The peer negotiation table and the ChannelManager's peer→channel map are\n// PRIVATE on ToonClient, so resuming a channel reaches into them through a\n// structural runtime cast — the exact pattern the daemon uses\n// (client-mcp/src/daemon/client-runner.ts, openOrResumeApexChannel /\n// routeChildPeersThroughApexChannel). Keep the shapes in sync with\n// @toon-protocol/client's ToonClient/ChannelManager.\n// ---------------------------------------------------------------------------\n\n/** The slice of a `PeerNegotiation` the channel map records. */\ninterface NegotiationLike {\n chain: string;\n chainType: string;\n chainId: number | string;\n settlementAddress: string;\n tokenAddress?: string;\n tokenNetwork?: string;\n}\n\ninterface ChannelInternals {\n peerNegotiations?: Map<string, NegotiationLike>;\n channelManager?: {\n trackChannel?: (\n channelId: string,\n context: PersistedChannelContext\n ) => void;\n peerChannels?: Map<string, string>;\n };\n /**\n * The client's on-chain channel client caches per-channel chain context at\n * OPEN time only; close/settle/deposit on a channel resumed from the map\n * would throw \"No on-chain context\" without re-seeding it (#263). Same\n * structural-cast contract as the rest of this block — keep in sync with\n * `@toon-protocol/client`'s OnChainChannelClient.\n */\n onChainChannelClient?: {\n channelContext?: Map<\n string,\n { chain: string; tokenNetworkAddress: string; tokenAddress?: string }\n >;\n };\n}\n\n/** Best-effort access to the client's private negotiation/channel state. */\nfunction channelInternals(client: ToonClientLike): ChannelInternals {\n const c = client as unknown as ChannelInternals;\n const negotiations =\n c.peerNegotiations instanceof Map ? c.peerNegotiations : undefined;\n const cm =\n c.channelManager &&\n typeof c.channelManager.trackChannel === 'function' &&\n c.channelManager.peerChannels instanceof Map\n ? c.channelManager\n : undefined;\n const onChain =\n c.onChainChannelClient &&\n c.onChainChannelClient.channelContext instanceof Map\n ? c.onChainChannelClient\n : undefined;\n return {\n ...(negotiations ? { peerNegotiations: negotiations } : {}),\n ...(cm ? { channelManager: cm } : {}),\n ...(onChain ? { onChainChannelClient: onChain } : {}),\n };\n}\n\n// ---------------------------------------------------------------------------\n// StandalonePublisher\n// ---------------------------------------------------------------------------\n\nexport class StandalonePublisher implements Publisher {\n private readonly client: ToonClientLike;\n private readonly ownsClient: boolean;\n private readonly publishDestination: string | undefined;\n private readonly storeDestination: string | undefined;\n private readonly channelDestination: string | undefined;\n private readonly eventFee: bigint;\n private readonly routePrices:\n | StandalonePublisherOptions['routePrices']\n | undefined;\n private readonly daemonPort: number | undefined;\n private readonly skipDaemonCheck: boolean;\n private readonly lockDir: string | undefined;\n private readonly fetchImpl: typeof fetch | undefined;\n private readonly channelMap: ChannelMapStore | undefined;\n /** ILP anchor the channel is keyed by in the map (peer/apex destination). */\n private readonly channelAnchor: string | undefined;\n private readonly negotiationFallbacks:\n | StandalonePublisherOptions['negotiationFallbacks']\n | undefined;\n private readonly warn: (line: string) => void;\n\n private lock: NonceLock | undefined;\n private channelId: string | undefined;\n private readyPromise: Promise<void> | undefined;\n /** Guard + client start only (no channel) — see {@link startClientOnly}. */\n private clientReadyPromise: Promise<void> | undefined;\n /** True when the last start() RESUMED the recorded channel (#263). */\n private lastOpenResumed = false;\n\n constructor(options: StandalonePublisherOptions) {\n if (options.client && options.clientConfig) {\n throw new Error(\n 'StandalonePublisher: provide either `clientConfig` or `client`, not both'\n );\n }\n if (options.client) {\n this.client = options.client;\n this.ownsClient = false;\n } else if (options.clientConfig) {\n this.client = new ToonClient(options.clientConfig);\n this.ownsClient = true;\n } else {\n throw new Error(\n 'StandalonePublisher: one of `clientConfig` (mnemonic-based ToonClient config) or `client` is required'\n );\n }\n\n // Routes: explicit option → derived from the channel anchor (same\n // `<base>.relay.store` convention the daemon resolves).\n const anchor =\n options.channelDestination ?? options.clientConfig?.destinationAddress;\n const routes = anchor ? deriveRouteDestinations(anchor) : undefined;\n this.publishDestination = options.publishDestination ?? routes?.publish;\n this.storeDestination = options.storeDestination ?? routes?.store;\n this.channelDestination = options.channelDestination;\n\n this.eventFee = options.eventFee ?? 1n;\n this.routePrices = options.routePrices;\n this.daemonPort = options.daemonPort;\n this.skipDaemonCheck = options.skipDaemonCheck ?? false;\n this.lockDir = options.lockDir;\n this.fetchImpl = options.fetchImpl;\n this.channelMap = options.channelMap;\n this.channelAnchor = anchor;\n this.negotiationFallbacks = options.negotiationFallbacks;\n this.warn = options.warn ?? ((line) => process.stderr.write(`${line}\\n`));\n }\n\n /** Hex Nostr pubkey of the embedded identity (available before start). */\n getPublicKey(): string {\n return this.client.getPublicKey();\n }\n\n /**\n * Run the nonce guard, start the embedded client, and open (or resume) the\n * payment channel. Called lazily by the first paid operation; safe to call\n * eagerly to fail fast. Idempotent.\n */\n start(): Promise<void> {\n this.readyPromise ??= (async () => {\n await this.startClientOnly();\n try {\n this.channelId = await this.openOrResumeChannel();\n } catch (err) {\n // Release the identity lock on a failed channel open (pre-#263\n // behaviour): nothing holds claims yet, so another process may go.\n this.lock?.release();\n this.lock = undefined;\n this.clientReadyPromise = undefined;\n throw err;\n }\n })().catch((err: unknown) => {\n // Let a later call retry (e.g. after the conflicting daemon stops).\n this.readyPromise = undefined;\n throw err;\n });\n return this.readyPromise;\n }\n\n /**\n * Run the nonce guard and start the embedded client WITHOUT touching the\n * payment channel (#263): `channel close`/`settle` operate on a RECORDED\n * channel and must never open a fresh one as a side effect of starting.\n * Idempotent; `start()` layers the channel open/resume on top of this.\n */\n startClientOnly(): Promise<void> {\n this.clientReadyPromise ??= this.doStartClient().catch((err: unknown) => {\n this.clientReadyPromise = undefined;\n throw err;\n });\n return this.clientReadyPromise;\n }\n\n private async doStartClient(): Promise<void> {\n const pubkey = this.client.getPublicKey();\n\n // Guard 1: refuse while a toon-clientd holds this identity — UNLESS the\n // force-standalone override is set (RIG_STANDALONE / `rig --standalone`),\n // in which case the caller has explicitly chosen to sign for itself and\n // ignore the daemon. Guard 2 (the NonceLock below) still runs either way.\n if (!this.skipDaemonCheck) {\n await checkDaemonIdentity(pubkey, {\n ...(this.daemonPort !== undefined ? { port: this.daemonPort } : {}),\n ...(this.fetchImpl ? { fetchImpl: this.fetchImpl } : {}),\n });\n }\n\n // Guard 2: exclusive advisory lock against other standalone processes.\n this.lock = await NonceLock.acquire(pubkey, {\n ...(this.lockDir !== undefined ? { dir: this.lockDir } : {}),\n });\n\n try {\n if (this.client.isStarted?.() !== true) {\n await this.client.start();\n }\n // #264: back-fill negotiation gaps as soon as the client's bootstrap\n // negotiation exists — before any channel open (start()) or recorded-\n // channel operation reads them.\n this.applyNegotiationFallbacks();\n } catch (err) {\n this.lock.release();\n this.lock = undefined;\n throw err;\n }\n }\n\n /**\n * Back-fill negotiated peer metadata the announce did not carry\n * (#264/#260 root cause 3): after the client's bootstrap negotiation, any\n * peer negotiation missing `tokenNetwork`/`tokenAddress` gets the derived\n * per-chain fallback for its negotiated chain, BEFORE the lazy channel\n * open reads them. Announced values are never overridden.\n */\n private applyNegotiationFallbacks(): void {\n const fallbacks = this.negotiationFallbacks;\n if (!fallbacks) return;\n const negotiations = channelInternals(this.client).peerNegotiations;\n if (!negotiations) {\n this.warn(\n 'rig: settlement fallbacks configured but the client does not ' +\n 'expose negotiation internals — on-chain channel opening may fail ' +\n 'if the peer announced no TokenNetwork'\n );\n return;\n }\n for (const negotiation of negotiations.values()) {\n if (!negotiation.tokenNetwork) {\n const tokenNetwork = fallbacks.tokenNetworks?.[negotiation.chain];\n if (tokenNetwork) negotiation.tokenNetwork = tokenNetwork;\n }\n if (!negotiation.tokenAddress) {\n const tokenAddress = fallbacks.preferredTokens?.[negotiation.chain];\n if (tokenAddress) negotiation.tokenAddress = tokenAddress;\n }\n }\n }\n\n /**\n * Open the payment channel — or, when the channel map has a record for\n * (identity, anchor), RESUME the recorded on-chain channel (#262).\n *\n * Resume seeds the client's ChannelManager (`trackChannel` rehydrates the\n * cumulative-claim watermark from channels.json; `peerChannels` makes the\n * subsequent `openChannel` return the same id instead of opening on-chain).\n * A fresh open is RECORDED so the next invocation resumes it. A corrupt map\n * file throws BEFORE anything is opened — never a silent duplicate open.\n */\n private async openOrResumeChannel(): Promise<string> {\n const map = this.channelMap;\n if (!map) {\n // No persistence configured: historical lazy open, nothing recorded.\n return this.client.openChannel(this.channelDestination);\n }\n if (!this.channelAnchor) {\n this.warn(\n 'rig: no channel anchor destination configured — the peer→channel ' +\n 'mapping cannot be persisted, so this run may open a fresh channel'\n );\n return this.client.openChannel(this.channelDestination);\n }\n\n const anchor = this.channelAnchor;\n const identity = this.client.getPublicKey();\n // Corruption check happens HERE, before any on-chain open (throws).\n const candidates = map.listFor(identity, anchor);\n const internals = channelInternals(this.client);\n const resumed = await this.resumeRecordedChannel(\n map,\n candidates,\n internals\n );\n\n // Idempotent — returns the (resumed or existing) channel for the peer if\n // one is tracked, else opens lazily on-chain.\n const channelId = await this.client.openChannel(this.channelDestination);\n\n if (resumed && channelId === resumed.channelId) {\n this.lastOpenResumed = true;\n map.touch(recordKey(resumed));\n } else {\n this.lastOpenResumed = false;\n this.recordOpenedChannel(map, internals, identity, anchor, channelId);\n }\n return channelId;\n }\n\n /**\n * Try to resume one recorded channel: the first candidate whose peer is\n * still negotiated on the SAME chain + tokenNetwork and whose watermark\n * does not show it closed/settled. Returns the resumed record, if any.\n */\n private async resumeRecordedChannel(\n map: ChannelMapStore,\n candidates: ChannelMapRecord[],\n internals: ChannelInternals\n ): Promise<ChannelMapRecord | undefined> {\n if (candidates.length === 0) return undefined;\n const cm = internals.channelManager;\n if (!cm?.trackChannel || !cm.peerChannels) {\n this.warn(\n 'rig: a recorded channel exists but the client does not expose ' +\n 'channel internals to resume it — a fresh channel may be opened'\n );\n return undefined;\n }\n\n for (const record of candidates) {\n // The peer must still be negotiated on the recorded chain/tokenNetwork;\n // a rotated peer identity or re-negotiated settlement gets a fresh\n // channel (recorded under its own key) instead of stale claims.\n const negotiation = internals.peerNegotiations?.get(record.peerId);\n if (\n !negotiation ||\n negotiation.chain !== record.chain ||\n (negotiation.tokenNetwork ?? '') !== record.tokenNetwork\n ) {\n continue;\n }\n\n // Never resume a channel the withdraw flow already closed/settled.\n const watermark = map.readWatermark(record.channelId);\n if (\n watermark?.closedAt !== undefined ||\n watermark?.settledAt !== undefined\n ) {\n continue;\n }\n if (!watermark) {\n // Fresh channels are seeded at record time, so a missing entry means\n // the watermark store was lost. Resuming from nonce 0 fails SAFE: a\n // regressed cumulative claim is rejected by the peer (no double\n // spend), but warn so the failure is diagnosable.\n this.warn(\n `rig: resuming channel ${record.channelId} with no local claim ` +\n `watermark (${map.watermarkPath}) — if this channel was claimed ` +\n 'against before, the peer will reject the stale claims; remove ' +\n `its entry from ${map.mapPath} to open a fresh channel instead`\n );\n }\n\n // trackChannel rehydrates nonce/cumulative from the watermark store;\n // seeding peerChannels makes ensureChannel/openChannel reuse the id.\n cm.trackChannel(record.channelId, record.context);\n cm.peerChannels.set(record.peerId, record.channelId);\n\n // Persisted channel state omits the on-chain deposit — re-read it so\n // fee/balance accounting is right (EVM only; mirrors the daemon).\n // #279 latency trim: skipped when the record already carries a\n // depositTotal — deposits only change through rig's own flows (open\n // --deposit / a later resume), which update the record; this is\n // display/accounting state, not the claim watermark, so a stale value\n // can never double-spend (the peer enforces the cumulative claim).\n if (\n record.context.chainType === 'evm' &&\n record.depositTotal === undefined &&\n this.client.rehydrateChannelDeposit\n ) {\n try {\n const deposit = await this.client.rehydrateChannelDeposit(\n record.channelId,\n {\n chain: record.chain,\n tokenNetworkAddress: record.context.tokenNetworkAddress,\n }\n );\n if (deposit !== undefined) {\n map.touch(recordKey(record), {\n depositTotal: deposit.toString(),\n });\n }\n } catch (err) {\n this.warn(\n `rig: deposit re-read for resumed channel ${record.channelId} ` +\n `failed: ${err instanceof Error ? err.message : String(err)}`\n );\n }\n }\n return record;\n }\n return undefined;\n }\n\n /** Record a freshly opened channel (+ seed its claim watermark at 0/0). */\n private recordOpenedChannel(\n map: ChannelMapStore,\n internals: ChannelInternals,\n identity: string,\n destination: string,\n channelId: string\n ): void {\n let peerId: string | undefined;\n for (const [peer, channel] of internals.channelManager?.peerChannels ??\n []) {\n if (channel === channelId) {\n peerId = peer;\n break;\n }\n }\n const negotiation =\n peerId !== undefined\n ? internals.peerNegotiations?.get(peerId)\n : undefined;\n if (peerId === undefined || !negotiation) {\n this.warn(\n `rig: opened channel ${channelId} but could not record the ` +\n 'peer→channel mapping (client does not expose negotiation ' +\n 'internals) — the NEXT invocation may open another channel'\n );\n return;\n }\n\n let depositTotal: bigint | undefined;\n try {\n depositTotal = this.client.getChannelDepositTotal?.(channelId);\n } catch {\n // deposit unknown — recorded without it; a later resume re-reads it\n }\n\n map.record({\n channelId,\n peerId,\n identity,\n destination,\n chain: negotiation.chain,\n tokenNetwork: negotiation.tokenNetwork ?? '',\n // Context mirrors the daemon's persistApexChannel shape — exactly what\n // trackChannel needs on resume.\n context: {\n chainType: negotiation.chainType,\n chainId:\n typeof negotiation.chainId === 'number' ? negotiation.chainId : 0,\n tokenNetworkAddress: negotiation.tokenNetwork ?? '',\n ...(negotiation.tokenAddress\n ? { tokenAddress: negotiation.tokenAddress }\n : {}),\n recipient: negotiation.settlementAddress,\n },\n ...(depositTotal !== undefined && depositTotal > 0n\n ? { depositTotal: depositTotal.toString() }\n : {}),\n });\n // Seed nonce 0 / cumulative 0 so a later resume can tell \"never claimed\n // against\" apart from \"watermark lost\" (which only fails claim-rejected).\n map.seedWatermark(channelId);\n }\n\n /** Release the identity lock and stop the embedded client (if we own it). */\n async stop(): Promise<void> {\n this.lock?.release();\n this.lock = undefined;\n this.readyPromise = undefined;\n this.clientReadyPromise = undefined;\n this.channelId = undefined;\n // Never stop a client that was never started (`ToonClient.stop()` throws\n // INVALID_STATE) — e.g. after a free `rig balance` read (#263).\n if (this.ownsClient && this.client.isStarted?.() !== false) {\n await this.client.stop();\n }\n }\n\n // ── Money lifecycle (#263) ──────────────────────────────────────────────────\n\n /**\n * Explicit `rig channel open`: the SAME resume-or-open path the lazy paid\n * writes use (guard → start → resume the recorded channel or open + record\n * a fresh one), surfaced with a receipt — plus an optional extra collateral\n * deposit on top of the open/resume.\n */\n async openChannelExplicit(opts?: {\n /** Extra collateral to deposit AFTER the open/resume (base units). */\n deposit?: bigint;\n }): Promise<ChannelOpenOutcome> {\n await this.start();\n const channelId = this.requireChannel();\n const identity = this.client.getPublicKey();\n const destination = this.channelAnchor ?? '';\n const record =\n this.channelMap && this.channelAnchor\n ? this.channelMap\n .listFor(identity, this.channelAnchor)\n .find((r) => r.channelId === channelId)\n : undefined;\n\n const outcome: ChannelOpenOutcome = {\n channelId,\n resumed: this.lastOpenResumed,\n destination,\n ...(record ? { chain: record.chain, peerId: record.peerId } : {}),\n ...(record?.depositTotal !== undefined\n ? { depositTotal: record.depositTotal }\n : {}),\n };\n\n if (opts?.deposit !== undefined && opts.deposit > 0n) {\n if (!this.client.depositToChannel) {\n throw new StandalonePublishError(\n 'this client build does not support channel deposits ' +\n '(depositToChannel is unavailable)'\n );\n }\n const deposited = await this.client.depositToChannel(\n channelId,\n opts.deposit\n );\n outcome.depositAdded = opts.deposit.toString();\n outcome.depositTotal = deposited.depositTotal;\n if (deposited.txHash) outcome.depositTxHash = deposited.txHash;\n if (record) {\n this.channelMap?.touch(recordKey(record), {\n depositTotal: deposited.depositTotal,\n });\n }\n }\n return outcome;\n }\n\n /**\n * Adopt a RECORDED channel into the running client so on-chain close/\n * settle/deposit can act on it: `trackChannel` rehydrates the claim\n * watermark + withdraw timers from channels.json, `peerChannels` binds the\n * peer, and the on-chain client's context cache is re-seeded (it only\n * learns context at open time — a resumed channel would otherwise throw\n * \"No on-chain context\").\n */\n private adoptRecordedChannel(record: ChannelMapRecord): void {\n const internals = channelInternals(this.client);\n const cm = internals.channelManager;\n if (cm?.trackChannel && cm.peerChannels) {\n cm.trackChannel(record.channelId, record.context);\n cm.peerChannels.set(record.peerId, record.channelId);\n }\n const contextCache = internals.onChainChannelClient?.channelContext;\n if (contextCache && !contextCache.has(record.channelId)) {\n contextCache.set(record.channelId, {\n chain: record.chain,\n tokenNetworkAddress: record.context.tokenNetworkAddress,\n ...(record.context.tokenAddress\n ? { tokenAddress: record.context.tokenAddress }\n : {}),\n });\n }\n }\n\n /**\n * Close a recorded channel: starts the on-chain settlement challenge\n * window. The client persists `closedAt`/`settleableAt` into the claim\n * watermark store, which is exactly where `rig channel list`/`balance`\n * derive the closing/settleable/settled status from. Guard + client start,\n * but NEVER a channel open ({@link startClientOnly}).\n */\n async closeRecordedChannel(\n record: ChannelMapRecord\n ): Promise<ChannelCloseOutcome> {\n await this.startClientOnly();\n if (!this.client.closeChannel) {\n throw new StandalonePublishError(\n 'this client build does not support closing channels ' +\n '(closeChannel is unavailable)'\n );\n }\n this.adoptRecordedChannel(record);\n const result = await this.client.closeChannel(record.channelId);\n this.channelMap?.touch(recordKey(record));\n return result;\n }\n\n /**\n * Settle a recorded channel after its challenge window — releases the\n * remaining collateral. The client enforces the `now >= settleableAt` time\n * guard BEFORE spending gas (a too-early call throws its retryable\n * SettleTooEarlyError) and persists `settledAt` into the watermark store.\n */\n async settleRecordedChannel(\n record: ChannelMapRecord\n ): Promise<ChannelSettleOutcome> {\n await this.startClientOnly();\n if (!this.client.settleChannel) {\n throw new StandalonePublishError(\n 'this client build does not support settling channels ' +\n '(settleChannel is unavailable)'\n );\n }\n this.adoptRecordedChannel(record);\n const result = await this.client.settleChannel(record.channelId);\n this.channelMap?.touch(recordKey(record));\n return result;\n }\n\n /**\n * The full multi-chain wallet view (#299) for the embedded identity — native\n * coin + configured tokens (USDC) per chain — a FREE read on the UNSTARTED\n * client (no nonce guard, no uplink, no channel). The client derives the\n * Solana/Mina addresses from the mnemonic on demand, so ALL configured chains\n * appear even before a start. Best-effort per chain (an unreachable RPC yields\n * an `unreadable` chain, not a failure). `fallback` supplies Solana/Mina RPC\n * defaults (e.g. the network preset) for chains the config has no channel for.\n */\n async readWalletChainBalances(\n fallback?: WalletViewFallback\n ): Promise<WalletChainBalanceInfo[]> {\n if (!this.client.getWalletBalances) return [];\n return await this.client.getWalletBalances(fallback);\n }\n\n // ── Publisher ─────────────────────────────────────────────────────────────\n\n /**\n * Fee rates for `planPush` estimation, both flat per packet (ADR 0020),\n * with the announced route prices folded in so the ESTIMATE always equals\n * the CLAIMS: `eventFee` is returned pre-floored at the publish route price,\n * and `uploadFee` IS the store route price.\n */\n getFeeRates(): Promise<FeeRates> {\n return Promise.resolve({\n uploadFee: this.uploadFee(),\n eventFee: this.effectiveEventFee(),\n });\n }\n\n /**\n * The flat per-event claim: `eventFee`, floored at the publish route's\n * announced price (the connector rejects a claim below it — F06).\n */\n private effectiveEventFee(): bigint {\n const min = this.routePrices?.publish ?? 0n;\n return this.eventFee > min ? this.eventFee : min;\n }\n\n /**\n * The per-upload claim: the store route's flat price, whatever the object's\n * size. Byte-proportional pricing has no successor (ADR 0020) — the route\n * table is the price list — and the connector charges this figure whether\n * the body is 100 bytes or 100 KB.\n */\n private uploadFee(): bigint {\n return this.routePrices?.store ?? 0n;\n }\n\n /**\n * Upload one git object as a kind:5094 store write (Git-SHA/Git-Type/Repo\n * tagged — the proven seed-pipeline shape), signing one balance-proof claim\n * for the store route's flat price\n * ({@link StandalonePublisherOptions.routePrices}) — ADR 0020 prices a\n * packet per handler, not per byte.\n *\n * #368: a blob's `Content-Type` is derived from its path extension (else\n * octet-stream) and sent in the `output` tag, which the store forwards onto\n * the Arweave upload's Content-Type — so a gateway serves `index.html` as\n * `text/html`, not `application/octet-stream`. Non-blob objects (trees,\n * commits, tags) are never served as files, so they stay octet-stream.\n */\n async uploadGitObject(upload: GitObjectUpload): Promise<UploadReceipt> {\n if (upload.body.length > MAX_OBJECT_SIZE) {\n throw new StandalonePublishError(\n `git object ${upload.sha} exceeds the ${MAX_OBJECT_SIZE}-byte limit: ${upload.body.length} bytes`\n );\n }\n await this.start();\n const channelId = this.requireChannel();\n\n const contentType =\n upload.type === 'blob'\n ? contentTypeForPath(upload.path)\n : DEFAULT_CONTENT_TYPE;\n\n const fee = this.uploadFee();\n const event = this.client.signEvent({\n kind: 5094,\n content: '',\n created_at: nowSeconds(),\n tags: [\n ['i', upload.body.toString('base64'), 'blob'],\n ['bid', fee.toString(), 'usdc'],\n ['output', contentType],\n ['Git-SHA', upload.sha],\n ['Git-Type', upload.type],\n ['Repo', upload.repoId],\n ],\n });\n\n const claim = await this.client.signBalanceProof(channelId, fee);\n const result = await this.client.publishEvent(event, {\n ...(this.storeDestination ? { destination: this.storeDestination } : {}),\n claim,\n ilpAmount: fee,\n // The store backend serves POST /store (not the relay's /write).\n proxyPath: '/store',\n });\n if (!result.success) {\n throw new StandalonePublishError(\n `git-object upload rejected (${upload.sha}): ${result.error ?? 'store rejected the write'}`\n );\n }\n if (!result.response) {\n throw new StandalonePublishError(\n `git-object upload FULFILL carried no sealed response (${upload.sha}); expected the Arweave tx ID`\n );\n }\n return { txId: extractArweaveTxId(result.response), feePaid: fee };\n }\n\n /**\n * Upload one raw blob (no git envelope) with an explicit `Content-Type`\n * (#368) — a kind:5094 store write carrying just the `i`/`bid`/`output`\n * tags (and an optional `Repo` provenance tag), NOT the Git-SHA/Git-Type\n * tags. Without those the store keeps the bytes verbatim instead of\n * re-deriving a git envelope, which is exactly what the ar.io path manifest\n * needs. One balance-proof claim for the store route's flat price.\n */\n async uploadBlob(upload: BlobUpload): Promise<UploadReceipt> {\n if (upload.body.length > MAX_OBJECT_SIZE) {\n throw new StandalonePublishError(\n `blob exceeds the ${MAX_OBJECT_SIZE}-byte limit: ${upload.body.length} bytes`\n );\n }\n await this.start();\n const channelId = this.requireChannel();\n\n const fee = this.uploadFee();\n const event = this.client.signEvent({\n kind: 5094,\n content: '',\n created_at: nowSeconds(),\n tags: [\n ['i', upload.body.toString('base64'), 'blob'],\n ['bid', fee.toString(), 'usdc'],\n ['output', upload.contentType],\n ...(upload.repoId ? [['Repo', upload.repoId]] : []),\n ],\n });\n\n const claim = await this.client.signBalanceProof(channelId, fee);\n const result = await this.client.publishEvent(event, {\n ...(this.storeDestination ? { destination: this.storeDestination } : {}),\n claim,\n ilpAmount: fee,\n proxyPath: '/store',\n });\n if (!result.success) {\n throw new StandalonePublishError(\n `blob upload rejected: ${result.error ?? 'store rejected the write'}`\n );\n }\n if (!result.response) {\n throw new StandalonePublishError(\n 'blob upload FULFILL carried no sealed response; expected the Arweave tx ID'\n );\n }\n return { txId: extractArweaveTxId(result.response), feePaid: fee };\n }\n\n /**\n * Sign the event with the embedded identity and pay-to-publish it through\n * the relay write route, one claim for the flat per-event fee.\n *\n * `relayUrls` is the interface's plural forward-compat surface (parked\n * #84): the standalone impl routes over ILP to its single configured\n * publish destination, so more than one relay is refused rather than\n * silently half-published.\n */\n async publishEvent(\n event: UnsignedEvent,\n relayUrls: string[]\n ): Promise<PublishReceipt> {\n if (relayUrls.length > 1) {\n throw new StandalonePublishError(\n `multi-relay publish is not supported yet (got ${relayUrls.length} relays) — the standalone publisher routes to a single relay destination (#84 parked)`\n );\n }\n await this.start();\n const channelId = this.requireChannel();\n\n const signed = this.client.signEvent(event);\n const fee = this.effectiveEventFee();\n const claim = await this.client.signBalanceProof(channelId, fee);\n const result = await this.client.publishEvent(signed, {\n ...(this.publishDestination\n ? { destination: this.publishDestination }\n : {}),\n claim,\n ilpAmount: fee,\n });\n if (!result.success) {\n throw new StandalonePublishError(\n `publish rejected (kind ${event.kind}): ${result.error ?? 'relay rejected the event'}`\n );\n }\n return { eventId: result.eventId ?? signed.id, feePaid: fee };\n }\n\n private requireChannel(): string {\n if (!this.channelId) {\n throw new StandalonePublishError(\n 'no payment channel open — start() did not complete'\n );\n }\n return this.channelId;\n }\n}\n\nfunction nowSeconds(): number {\n return Math.floor(Date.now() / 1000);\n}\n"],"mappings":";;;;;;;;;;;;AAsCA,SAAS,YAAY,0BAA0B;AAiMxC,IAAM,yBAAN,cAAqC,MAAM;AAAA,EAChD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AAcO,SAAS,wBAAwB,QAGtC;AACA,QAAM,OAAO,OAAO,MAAM,GAAG;AAC7B,MAAI,KAAK,GAAG,EAAE,MAAM,WAAW,KAAK,GAAG,EAAE,MAAM,SAAS;AACtD,UAAM,OAAO,KAAK,MAAM,GAAG,EAAE,EAAE,KAAK,GAAG;AACvC,WAAO,EAAE,SAAS,GAAG,IAAI,UAAU,OAAO,GAAG,IAAI,SAAS;AAAA,EAC5D;AACA,SAAO,EAAE,SAAS,QAAQ,OAAO,OAAO;AAC1C;AA+DA,SAAS,iBAAiB,QAA0C;AAClE,QAAM,IAAI;AACV,QAAM,eACJ,EAAE,4BAA4B,MAAM,EAAE,mBAAmB;AAC3D,QAAM,KACJ,EAAE,kBACF,OAAO,EAAE,eAAe,iBAAiB,cACzC,EAAE,eAAe,wBAAwB,MACrC,EAAE,iBACF;AACN,QAAM,UACJ,EAAE,wBACF,EAAE,qBAAqB,0BAA0B,MAC7C,EAAE,uBACF;AACN,SAAO;AAAA,IACL,GAAI,eAAe,EAAE,kBAAkB,a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AAmB,IACvC,CAAC;AAAA,MACL;AAAA,MACA,WAAW;AAAA,IACb,CAAC;AACD,QAAI,CAAC,OAAO,SAAS;AACnB,YAAM,IAAI;AAAA,QACR,0BAA0B,MAAM,IAAI,MAAM,OAAO,SAAS,0BAA0B;AAAA,MACtF;AAAA,IACF;AACA,WAAO,EAAE,SAAS,OAAO,WAAW,OAAO,IAAI,SAAS,IAAI;AAAA,EAC9D;AAAA,EAEQ,iBAAyB;AAC/B,QAAI,CAAC,KAAK,WAAW;AACnB,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,WAAO,KAAK;AAAA,EACd;AACF;AAEA,SAAS,aAAqB;AAC5B,SAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI;AACrC;","names":[]}
|
|
@@ -46,13 +46,6 @@ function createGitTag(opts) {
|
|
|
46
46
|
return hashGitObject("tag", Buffer.from(lines.join("\n"), "utf-8"));
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
// src/publisher.ts
|
|
50
|
-
function flooredUploadFee(bytes, ratePerByte, minFee) {
|
|
51
|
-
const fee = BigInt(bytes) * ratePerByte;
|
|
52
|
-
const min = minFee ?? 0n;
|
|
53
|
-
return fee > min ? fee : min;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
export {
|
|
57
50
|
MAX_OBJECT_SIZE,
|
|
58
51
|
EMPTY_BLOB_SHA,
|
|
@@ -60,7 +53,6 @@ export {
|
|
|
60
53
|
createGitBlob,
|
|
61
54
|
createGitTree,
|
|
62
55
|
createGitCommit,
|
|
63
|
-
createGitTag
|
|
64
|
-
flooredUploadFee
|
|
56
|
+
createGitTag
|
|
65
57
|
};
|
|
66
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-B5ISARMU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AACrD,QAAM,aAAa,OAAO,OAAO,CAAC,QAAQ,IAAI,CAAC;AAC/C,QAAM,MAAM,WAAW,MAAM,EAAE,OAAO,UAAU,EAAE,OAAO,KAAK;AAC9D,SAAO,EAAE,KAAK,QAAQ,YAAY,KAAK;AACzC;AAYO,SAAS,cAAc,SAA4B;AACxD,SAAO,cAAc,QAAQ,OAAO,KAAK,SAAS,OAAO,CAAC;AAC5D;AASO,SAAS,cACd,SACW;AAEX,QAAM,SAAS,CAAC,GAAG,OAAO,EAAE;AAAA,IAAK,CAAC,GAAG,MACnC,EAAE,OAAO,EAAE,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,IAAI;AAAA,EAC/C;AAEA,QAAM,eAAyB,CAAC;AAChC,aAAW,SAAS,QAAQ;AAC1B,UAAM,cAAc,OAAO,KAAK,GAAG,MAAM,IAAI,IAAI,MAAM,IAAI,IAAI;AAE/D,UAAM,SAAS,OAAO,KAAK,MAAM,KAAK,KAAK;AAC3C,iBAAa,KAAK,OAAO,OAAO,CAAC,aAAa,MAAM,CAAC,CAAC;AAAA,EACxD;AAEA,SAAO,cAAc,QAAQ,OAAO,OAAO,YAAY,CAAC;AAC1D;AAQO,SAAS,gBAAgB,MAOlB;AACZ,QAAM,QAAQ;AAAA,IACZ,QAAQ,KAAK,OAAO;AAAA,IACpB,GAAI,KAAK,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE,IAAI,CAAC;AAAA,IACrD,UAAU,KAAK,UAAU,KAAK,KAAK,YAAY,WAAW,KAAK,SAAS;AAAA,IACxE,aAAa,KAAK,UAAU,KAAK,KAAK,YAAY,WAAW,KAAK,SAAS;AAAA,IAC3E;AAAA,IACA,KAAK;AAAA,EACP;AACA,SAAO,cAAc,UAAU,OAAO,KAAK,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;AACvE;AASO,SAAS,aAAa,MAWf;AACZ,QAAM,QAAQ;AAAA,IACZ,UAAU,KAAK,SAAS;AAAA,IACxB,QAAQ,KAAK,UAAU;AAAA,IACvB,OAAO,KAAK,OAAO;AAAA,IACnB,UAAU,KAAK,UAAU,KAAK,KAAK,YAAY,WAAW,KAAK,SAAS;AAAA,IACxE;AAAA,IACA,KAAK;AAAA,EACP;AACA,SAAO,cAAc,OAAO,OAAO,KAAK,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;AACpE;","names":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EMPTY_BLOB_SHA,
|
|
3
3
|
MAX_OBJECT_SIZE,
|
|
4
|
-
flooredUploadFee,
|
|
5
4
|
hashGitObject
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-B5ISARMU.js";
|
|
7
6
|
import {
|
|
8
7
|
ARWEAVE_FETCH_TIMEOUT_MS,
|
|
9
8
|
ARWEAVE_GATEWAYS,
|
|
@@ -997,11 +996,21 @@ async function planPush(options) {
|
|
|
997
996
|
for (const ref of selected) {
|
|
998
997
|
const remoteSha = remoteState.refs.get(ref.refname) ?? null;
|
|
999
998
|
if (remoteSha === null) {
|
|
1000
|
-
refUpdates.push({
|
|
999
|
+
refUpdates.push({
|
|
1000
|
+
refname: ref.refname,
|
|
1001
|
+
localSha: ref.sha,
|
|
1002
|
+
remoteSha,
|
|
1003
|
+
kind: "new"
|
|
1004
|
+
});
|
|
1001
1005
|
continue;
|
|
1002
1006
|
}
|
|
1003
1007
|
if (remoteSha === ref.sha) {
|
|
1004
|
-
refUpdates.push({
|
|
1008
|
+
refUpdates.push({
|
|
1009
|
+
refname: ref.refname,
|
|
1010
|
+
localSha: ref.sha,
|
|
1011
|
+
remoteSha,
|
|
1012
|
+
kind: "up-to-date"
|
|
1013
|
+
});
|
|
1005
1014
|
continue;
|
|
1006
1015
|
}
|
|
1007
1016
|
let fastForward = false;
|
|
@@ -1012,9 +1021,19 @@ async function planPush(options) {
|
|
|
1012
1021
|
fastForward = false;
|
|
1013
1022
|
}
|
|
1014
1023
|
if (fastForward) {
|
|
1015
|
-
refUpdates.push({
|
|
1024
|
+
refUpdates.push({
|
|
1025
|
+
refname: ref.refname,
|
|
1026
|
+
localSha: ref.sha,
|
|
1027
|
+
remoteSha,
|
|
1028
|
+
kind: "fast-forward"
|
|
1029
|
+
});
|
|
1016
1030
|
} else if (force) {
|
|
1017
|
-
refUpdates.push({
|
|
1031
|
+
refUpdates.push({
|
|
1032
|
+
refname: ref.refname,
|
|
1033
|
+
localSha: ref.sha,
|
|
1034
|
+
remoteSha,
|
|
1035
|
+
kind: "forced"
|
|
1036
|
+
});
|
|
1018
1037
|
} else {
|
|
1019
1038
|
rejected.push({ refname: ref.refname, localSha: ref.sha, remoteSha });
|
|
1020
1039
|
}
|
|
@@ -1076,10 +1095,7 @@ async function planPush(options) {
|
|
|
1076
1095
|
}
|
|
1077
1096
|
const announceNeeded = !remoteState.announced;
|
|
1078
1097
|
const totalObjectBytes = objects.reduce((sum, o) => sum + o.size, 0);
|
|
1079
|
-
const uploadFee = objects.
|
|
1080
|
-
(sum, o) => sum + flooredUploadFee(o.size, feeRates.uploadFeePerByte, feeRates.minUploadFee),
|
|
1081
|
-
0n
|
|
1082
|
-
);
|
|
1098
|
+
const uploadFee = BigInt(objects.length) * feeRates.uploadFee;
|
|
1083
1099
|
const eventCount = 1 + (announceNeeded ? 1 : 0);
|
|
1084
1100
|
const eventFees = BigInt(eventCount) * feeRates.eventFee;
|
|
1085
1101
|
return {
|
|
@@ -1227,4 +1243,4 @@ export {
|
|
|
1227
1243
|
planPush,
|
|
1228
1244
|
executePush
|
|
1229
1245
|
};
|
|
1230
|
-
//# sourceMappingURL=chunk-
|
|
1246
|
+
//# sourceMappingURL=chunk-FBIHO3RS.js.map
|