@withautonomi/ant-sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. package/README.md +56 -2
  2. package/index.d.ts +62 -461
  3. package/index.js +121 -687
  4. package/native.d.ts +794 -0
  5. package/native.js +728 -0
  6. package/package.json +16 -14
package/native.d.ts ADDED
@@ -0,0 +1,794 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class Client {
4
+ /** Connect to a local test network (loopback). */
5
+ static connectLocal(dataDir?: string | undefined | null): Promise<Client>
6
+ /**
7
+ * Connect using explicit bootstrap peers (`/ip4/<ip>/udp/<port>/quic`
8
+ * multiaddr strings). Read-only; use a wallet/external-signer variant to
9
+ * write.
10
+ */
11
+ static connect(peers: Array<string>, dataDir?: string | undefined | null): Promise<Client>
12
+ /**
13
+ * Connect to the Autonomi **production network** using the SDK's vendored
14
+ * bootstrap peers — no configuration. Read-only.
15
+ */
16
+ static connectDefault(dataDir?: string | undefined | null): Promise<Client>
17
+ /**
18
+ * `connectDefault` with a wallet attached for writes, preset for the
19
+ * production EVM network.
20
+ */
21
+ static connectDefaultWithWallet(privateKey: string, dataDir?: string | undefined | null): Promise<Client>
22
+ /**
23
+ * `connectDefault` configured for the **external-signer** flow (mobile
24
+ * wallets / WalletConnect): production peers + EVM network for quotes, no
25
+ * wallet attached.
26
+ */
27
+ static connectDefaultForExternalSigner(dataDir?: string | undefined | null): Promise<Client>
28
+ /** Connect with a wallet configured for writes on a custom EVM network. */
29
+ static connectWithWallet(peers: Array<string>, privateKey: string, rpcUrl: string, paymentTokenAddress: string, paymentVaultAddress: string, dataDir?: string | undefined | null): Promise<Client>
30
+ /**
31
+ * Connect to a local devnet described by a devnet manifest JSON file (the
32
+ * file written by `ant-devnet`). **Development/testing only.** Fails if the
33
+ * manifest is missing, malformed, or has no `evm` section.
34
+ */
35
+ static connectFromDevnetManifest(manifestPath: string, dataDir?: string | undefined | null): Promise<Client>
36
+ /**
37
+ * Like `connectFromDevnetManifest` but for the **external-signer** flow:
38
+ * configures the devnet EVM network for quotes but attaches no wallet.
39
+ */
40
+ static connectFromDevnetManifestExternalSigner(manifestPath: string, dataDir?: string | undefined | null): Promise<Client>
41
+ /**
42
+ * Connect with an EVM network configured but **no wallet** — the
43
+ * external-signer entry point. Quote/price queries work; payment is signed
44
+ * off-device. Pay via `prepare*` + your signer + `finalize*`.
45
+ */
46
+ static connectForExternalSigner(peers: Array<string>, rpcUrl: string, paymentTokenAddress: string, paymentVaultAddress: string, dataDir?: string | undefined | null): Promise<Client>
47
+ /** Store a single chunk on the network. */
48
+ chunkPut(data: Uint8Array): Promise<ChunkPutResult>
49
+ /** Retrieve a chunk by hex-encoded address. */
50
+ chunkGet(addressHex: string): Promise<Buffer>
51
+ /** Check whether a chunk exists on the network. */
52
+ chunkExists(addressHex: string): Promise<boolean>
53
+ /** Upload data publicly (retrievable by the returned address). */
54
+ dataPutPublic(data: Uint8Array, paymentMode: PaymentMode): Promise<DataPutPublicResult>
55
+ /** Retrieve public data by its hex-encoded data-map address. */
56
+ dataGetPublic(addressHex: string): Promise<Buffer>
57
+ /**
58
+ * Upload data privately. Returns the serialized data map (hex) — keep it
59
+ * secret; it is required to retrieve the data.
60
+ */
61
+ dataPutPrivate(data: Uint8Array, paymentMode: PaymentMode): Promise<DataPutPrivateResult>
62
+ /** Retrieve private data using a hex-encoded data map. */
63
+ dataGetPrivate(dataMapHex: string): Promise<Buffer>
64
+ /**
65
+ * Upload a file from disk publicly. Returns the shareable address plus
66
+ * chunk/cost details.
67
+ */
68
+ fileUploadPublic(path: string, paymentMode: PaymentMode): Promise<FilePutPublicResult>
69
+ /** `fileUploadPublic` with live progress (`Encrypting`/`Quoting`/`Storing`). */
70
+ fileUploadPublicWithProgress(path: string, paymentMode: PaymentMode, onProgress: (progress: ProgressUpdate) => void): Promise<FilePutPublicResult>
71
+ /**
72
+ * Upload a file from disk privately. Returns the serialized data map (hex);
73
+ * keep it secret to retrieve the file later.
74
+ */
75
+ fileUploadPrivate(path: string, paymentMode: PaymentMode): Promise<FilePutPrivateResult>
76
+ /** `fileUploadPrivate` with live progress. */
77
+ fileUploadPrivateWithProgress(path: string, paymentMode: PaymentMode, onProgress: (progress: ProgressUpdate) => void): Promise<FilePutPrivateResult>
78
+ /** Download a public file to disk by hex-encoded address. */
79
+ fileDownloadPublic(addressHex: string, destPath: string): Promise<void>
80
+ /** Download a private file to disk by hex-encoded data map. */
81
+ fileDownloadPrivate(dataMapHex: string, destPath: string): Promise<void>
82
+ /**
83
+ * Publish an existing private data map (hex) as a public network chunk,
84
+ * returning its hex address — without re-uploading the underlying data.
85
+ */
86
+ dataMapStore(dataMapHex: string): Promise<string>
87
+ /**
88
+ * Fetch a public data map by hex address and return it serialized (hex) —
89
+ * the inverse of `dataMapStore`.
90
+ */
91
+ dataMapFetch(addressHex: string): Promise<string>
92
+ /**
93
+ * Estimate the cost of uploading a file *before* preparing or paying.
94
+ * Samples a few chunk addresses; fast and needs no wallet. Check
95
+ * `CostEstimate.confidence` before treating a `"0"` cost as free.
96
+ */
97
+ estimateFileCost(path: string, paymentMode: PaymentMode): Promise<CostEstimate>
98
+ /** `estimateFileCost` with live progress (the `Encrypting` phase). */
99
+ estimateFileCostWithProgress(path: string, paymentMode: PaymentMode, onProgress: (progress: ProgressUpdate) => void): Promise<CostEstimate>
100
+ /** Approve token spend for storage payments (one-time; wallet-backed client). */
101
+ walletApprove(): Promise<void>
102
+ /**
103
+ * Phase 1: encrypt `data`, collect quotes, and return the payment summary.
104
+ * The prepared state is retained under the returned `uploadId` until finalize.
105
+ */
106
+ prepareDataUpload(data: Uint8Array, visibility: Visibility): Promise<PreparedUploadInfo>
107
+ /** Phase 1 for a file on disk. */
108
+ prepareFileUpload(path: string, visibility: Visibility): Promise<PreparedUploadInfo>
109
+ /** Phase 1 for a file, with encryption/quoting progress. */
110
+ prepareFileUploadWithProgress(path: string, visibility: Visibility, onProgress: (progress: ProgressUpdate) => void): Promise<PreparedUploadInfo>
111
+ /**
112
+ * Phase 1.5: build the ordered transactions (ERC-20 `approve` + vault
113
+ * payment call(s)) the external wallet must sign to pay for a prepared
114
+ * upload. Empty when everything was already stored.
115
+ */
116
+ paymentTransactions(uploadId: string): Promise<Array<TxRequest>>
117
+ /**
118
+ * Phase 2 (wave-batch): after the wallet has paid, finalize by supplying the
119
+ * `quoteHash -> txHash` map (both 0x-prefixed hex). Pass an empty map if
120
+ * everything was already stored.
121
+ */
122
+ finalizeUpload(uploadId: string, txHashes: Record<string, string>): Promise<ExternalUploadResult>
123
+ /** `finalizeUpload` with live storing progress. */
124
+ finalizeUploadWithProgress(uploadId: string, txHashes: Record<string, string>, onProgress: (progress: ProgressUpdate) => void): Promise<ExternalUploadResult>
125
+ /**
126
+ * Phase 2 (merkle): finalize by supplying the `winnerPoolHash` read from the
127
+ * `MerklePaymentMade` event (see the `merkleWinnerPoolHash` free function).
128
+ */
129
+ finalizeUploadMerkle(uploadId: string, winnerPoolHash: string): Promise<ExternalUploadResult>
130
+ /** `finalizeUploadMerkle` with live storing progress. */
131
+ finalizeUploadMerkleWithProgress(uploadId: string, winnerPoolHash: string, onProgress: (progress: ProgressUpdate) => void): Promise<ExternalUploadResult>
132
+ /**
133
+ * Discard a prepared upload that will not be finalized, freeing the chunk
134
+ * content it holds in memory. Returns `true` if an upload with this id was
135
+ * present. Safe to call with an unknown/already-finalized id.
136
+ */
137
+ cancelUpload(uploadId: string): boolean
138
+ /**
139
+ * Download public data by address straight to a file on disk, reporting
140
+ * live progress (`Resolving` then `Downloading`). Returns bytes written.
141
+ */
142
+ downloadPublicToFile(addressHex: string, destPath: string, onProgress: (progress: ProgressUpdate) => void): Promise<number>
143
+ /**
144
+ * Download private data by hex-encoded data map straight to a file on disk,
145
+ * reporting live progress. Returns bytes written.
146
+ */
147
+ downloadPrivateToFile(dataMapHex: string, destPath: string, onProgress: (progress: ProgressUpdate) => void): Promise<number>
148
+ /**
149
+ * Build a manifest, embedding a shrunk DataMap's root where it fits
150
+ * (unless `keepShrunkDataMaps`).
151
+ */
152
+ manifestBuild(request: ManifestBuildRequest): Promise<ManifestBuilt>
153
+ /**
154
+ * Decode `.ant` bytes; with `resolve`, report each entry's exact size
155
+ * (or its `error`).
156
+ */
157
+ manifestDecode(bytes: Buffer, resolve: boolean): Promise<ManifestDecoded>
158
+ /** Decode a link or bare address, as `manifestDecode`. */
159
+ manifestDecodeLink(link: string, resolve: boolean): Promise<ManifestDecoded>
160
+ /**
161
+ * Create the pointer `ownerSeed` owns at counter 0. Pays from the wallet.
162
+ * Rejects with `AlreadyExists` before paying if it exists.
163
+ */
164
+ pointerCreate(ownerSeed: Buffer, target: string, kind: PointerKind): Promise<PointerWrite>
165
+ /**
166
+ * Point the pointer `ownerSeed` owns at `target`, one past the served
167
+ * counter (creates it if missing). Pays from the wallet. Rejects with
168
+ * `PointerFinal` / `PointerForked` before paying if it is final.
169
+ */
170
+ pointerUpdate(ownerSeed: Buffer, target: string, kind: PointerKind): Promise<PointerWrite>
171
+ /**
172
+ * Hand the pointer `ownerSeed` owns over to the pointer at `recipient`,
173
+ * for good. Pays from the wallet. Cannot be undone.
174
+ */
175
+ pointerTransfer(ownerSeed: Buffer, recipient: string): Promise<PointerTransfer>
176
+ /** The pointer at `address`, or `null` if the network holds none. */
177
+ pointerGet(address: string): Promise<PointerRecord | null>
178
+ /** Follow `address` through pointer targets to where the chain ends. */
179
+ pointerResolve(address: string): Promise<PointerResolved>
180
+ /** Ask the whole close group where `address` stands on finality. */
181
+ pointerFinality(address: string): Promise<PointerFinality>
182
+ /**
183
+ * Follow `address` through every transfer to the pointer whose owner
184
+ * now decides what it resolves to.
185
+ */
186
+ pointerController(address: string): Promise<PointerController>
187
+ /** External signer: sign and quote the creation of `ownerSeed`'s pointer. */
188
+ preparePointerCreate(ownerSeed: Buffer, target: string, kind: PointerKind): Promise<PreparedPointer>
189
+ /** External signer: sign and quote an update of `ownerSeed`'s pointer. */
190
+ preparePointerUpdate(ownerSeed: Buffer, target: string, kind: PointerKind): Promise<PreparedPointer>
191
+ /**
192
+ * External signer: sign and quote the transfer of `ownerSeed`'s pointer
193
+ * to `recipient`.
194
+ */
195
+ preparePointerTransfer(ownerSeed: Buffer, recipient: string): Promise<PreparedPointer>
196
+ /**
197
+ * External signer: the ordered transactions (`approve`, `payForQuotes`)
198
+ * that pay a prepared pointer write.
199
+ */
200
+ pointerPaymentTransactions(uploadId: string): Array<TxRequest>
201
+ /**
202
+ * External signer: store a prepared pointer write once paid. A
203
+ * `CloseGroupShortfall` keeps the paid attempt: call again with the same
204
+ * `uploadId` to retry against the same payment.
205
+ */
206
+ finalizePointer(uploadId: string, txHashes: Record<string, string>): Promise<PointerFinalized>
207
+ /** Abandon a prepared pointer write. `true` if it was pending. */
208
+ cancelPointer(uploadId: string): boolean
209
+ }
210
+
211
+ export declare class Wallet {
212
+ /**
213
+ * Create a wallet from an EVM private key on a custom network (RPC URL +
214
+ * token/vault contract addresses). The private key is zeroized inside the
215
+ * core as soon as the wallet is built.
216
+ */
217
+ static fromPrivateKey(privateKey: string, rpcUrl: string, paymentTokenAddress: string, paymentVaultAddress: string): Wallet
218
+ /** The wallet's public address (0x-prefixed hex). */
219
+ address(): string
220
+ /** Token balance in atto-tokens (base-10 string). */
221
+ balanceOfTokens(): Promise<string>
222
+ /** Gas-token balance in wei (base-10 string). */
223
+ balanceOfGasTokens(): Promise<string>
224
+ }
225
+
226
+ /**
227
+ * **Test hook — not part of the public API.** Fires `ticks` synthetic
228
+ * `Encrypting` progress updates through the same bridge every `*WithProgress`
229
+ * method uses, from a background thread, then resolves. Exists so the
230
+ * callback-exception containment (a throwing `onProgress` becomes an
231
+ * `AntProgressCallbackError` warning, never a fatal exception) has an offline
232
+ * regression test.
233
+ */
234
+ export declare function _emitProgressForTest(onProgress: (progress: ProgressUpdate) => void, ticks: number): Promise<void>
235
+
236
+ /**
237
+ * **Test hook — not part of the public API.** Returns an entry carrying
238
+ * `size` and `exactSize` (decimal strings, any `u64`) through the same
239
+ * conversion every build and decode result takes, so the size range has an
240
+ * offline test at its boundaries for both fields. An embedded DataMap that
241
+ * claims 2^53 bytes or more cannot be made offline.
242
+ */
243
+ export declare function _manifestEntrySizesForTest(size?: string | undefined | null, exactSize?: string | undefined | null): ManifestEntryInfo
244
+
245
+ /**
246
+ * **Test hook — not part of the public API.** Resolves, after a pause, with
247
+ * the pointer address of `ownerSeed`, taking the seed through the same
248
+ * [`spawn_with_seed`] every seed-taking method uses. Exists so the "seed is
249
+ * copied when the call is made" guarantee has an offline regression test: the
250
+ * test overwrites its `Buffer` during the pause.
251
+ */
252
+ export declare function _pointerAddressAfterPauseForTest(ownerSeed: Buffer, pauseMs: number): Promise<string>
253
+
254
+ /**
255
+ * **Test hook — not part of the public API.** Rejects with a sample of the
256
+ * client error variant whose code is `code` (e.g. `"NotFound"`), through the
257
+ * same `client_err` mapping every method uses, so the JS side's `err.code`
258
+ * handling has an offline test per variant (V2-1913). `reason`, when given,
259
+ * replaces the sample's reason text (for variants that carry one). An
260
+ * unknown `code` rejects with `InvalidInput`.
261
+ */
262
+ export declare function _rejectWithClientErrorForTest(code: string, reason?: string | undefined | null): Promise<void>
263
+
264
+ /**
265
+ * The AntFfi SDK version (e.g. `"0.0.8"`) — matches the released SDK version
266
+ * shared across all bindings.
267
+ */
268
+ export declare function antFfiVersion(): string
269
+
270
+ /** One candidate node inside a [`PoolCommitmentEntry`]. */
271
+ export interface CandidateNodeEntry {
272
+ /** 0x-prefixed EVM rewards address (20 bytes). */
273
+ rewardsAddress: string
274
+ /** Node price in atto-tokens (base-10 string). */
275
+ amount: string
276
+ }
277
+
278
+ /** Result of storing a single chunk on the network. */
279
+ export interface ChunkPutResult {
280
+ /** Hex-encoded chunk address (32 bytes). */
281
+ address: string
282
+ }
283
+
284
+ /** How much to trust a [`CostEstimate`]'s `storageCostAtto`. */
285
+ export declare enum CostConfidence {
286
+ /** Extrapolated from at least one live quote (the normal case). */
287
+ PricedSample = 0,
288
+ /** Every chunk was sampled and already stored; cost is exactly `"0"`. */
289
+ VerifiedAllAlreadyStored = 1,
290
+ /**
291
+ * Every *sampled* chunk was already stored but the tail was unsampled;
292
+ * `"0"` is a best-effort guess. Render as "likely already stored".
293
+ */
294
+ AllSamplesAlreadyStoredIncomplete = 2
295
+ }
296
+
297
+ /**
298
+ * Estimated cost of uploading a file, produced *before* any payment by
299
+ * sampling a few of the file's chunk addresses. No wallet required.
300
+ */
301
+ export interface CostEstimate {
302
+ /** Original file size in bytes. */
303
+ fileSize: number
304
+ /**
305
+ * Number of data chunks the file would split into (excludes the extra
306
+ * data-map chunk added for public uploads).
307
+ */
308
+ chunkCount: number
309
+ /** Estimated storage cost in atto-tokens (base-10 string; may exceed u64). */
310
+ storageCostAtto: string
311
+ /**
312
+ * Rough estimated gas cost in wei (base-10 string). A heuristic, NOT a live
313
+ * gas-price query.
314
+ */
315
+ estimatedGasCostWei: string
316
+ /** Payment mode that would be used. */
317
+ paymentMode: PaymentMode
318
+ /**
319
+ * How much to trust `storageCostAtto` — check before treating a `"0"` cost
320
+ * as free.
321
+ */
322
+ confidence: CostConfidence
323
+ }
324
+
325
+ /** Result of a private data upload (data map returned to caller, kept secret). */
326
+ export interface DataPutPrivateResult {
327
+ /** Hex-encoded serialized data map (caller keeps this secret). */
328
+ dataMap: string
329
+ /** Number of chunks stored. */
330
+ chunksStored: number
331
+ /** Payment mode that was used. */
332
+ paymentModeUsed: PaymentMode
333
+ }
334
+
335
+ /** Result of a public data upload (data map stored as a public chunk). */
336
+ export interface DataPutPublicResult {
337
+ /** Hex-encoded address of the stored data map. */
338
+ address: string
339
+ /** Number of chunks stored. */
340
+ chunksStored: number
341
+ /** Payment mode that was used. */
342
+ paymentModeUsed: PaymentMode
343
+ }
344
+
345
+ /** Result of finalizing an external-signer upload. */
346
+ export interface ExternalUploadResult {
347
+ /** Hex-encoded serialized data map (for private retrieval; always present). */
348
+ dataMap: string
349
+ /** For public uploads: hex data-map address (shareable). Absent if private. */
350
+ address?: string
351
+ /** Number of chunks stored on the network. */
352
+ chunksStored: number
353
+ /** Total storage cost paid, in atto-tokens (base-10). "0" if all pre-existed. */
354
+ storageCostAtto: string
355
+ /** Total gas cost in wei (base-10). */
356
+ gasCostWei: string
357
+ }
358
+
359
+ /**
360
+ * Result of uploading a private file. Keep `dataMap` secret — it is required
361
+ * to retrieve the file and is not recoverable from the network.
362
+ */
363
+ export interface FilePutPrivateResult {
364
+ /** Hex-encoded serialized data map (caller keeps this secret). */
365
+ dataMap: string
366
+ /** Number of chunks stored on the network. */
367
+ chunksStored: number
368
+ /** Total storage cost paid, in atto-tokens (base-10). "0" if all pre-existed. */
369
+ storageCostAtto: string
370
+ /** Total gas cost in wei (base-10). */
371
+ gasCostWei: string
372
+ /** Payment mode that was used. */
373
+ paymentModeUsed: PaymentMode
374
+ }
375
+
376
+ /** Result of uploading a public file. */
377
+ export interface FilePutPublicResult {
378
+ /** Hex-encoded address of the stored data map. */
379
+ address: string
380
+ /** Number of chunks stored on the network. */
381
+ chunksStored: number
382
+ /** Total storage cost paid, in atto-tokens (base-10). "0" if all pre-existed. */
383
+ storageCostAtto: string
384
+ /** Total gas cost in wei (base-10). */
385
+ gasCostWei: string
386
+ /** Payment mode that was used. */
387
+ paymentModeUsed: PaymentMode
388
+ }
389
+
390
+ /** Where a pointer stands with respect to finality. */
391
+ export declare enum FinalityStatus {
392
+ Open = 0,
393
+ Settling = 1,
394
+ Unconfirmed = 2,
395
+ Final = 3,
396
+ Forked = 4
397
+ }
398
+
399
+ /** What to build. */
400
+ export interface ManifestBuildRequest {
401
+ /** Suggested root directory name: one portable path component. */
402
+ name?: string
403
+ /** Up to two BitTorrent info hashes (hex): 40 characters v1, 64 v2. */
404
+ torrentInfoHashes?: Array<string>
405
+ entries: Array<ManifestEntryInput>
406
+ /**
407
+ * `client.manifestBuild` only: embed every DataMap as given, rather than
408
+ * a shrunk DataMap's root where it fits.
409
+ */
410
+ keepShrunkDataMaps?: boolean
411
+ }
412
+
413
+ /** A built manifest. */
414
+ export interface ManifestBuilt {
415
+ name?: string
416
+ /** The `.ant` file bytes. */
417
+ bytes: Buffer
418
+ /** The `ant://manifest/` link, only when it fits 1,500 bytes. */
419
+ link?: string
420
+ entries: Array<ManifestEntryInfo>
421
+ }
422
+
423
+ /** Decode `.ant` bytes. Offline. */
424
+ export declare function manifestDecode(bytes: Buffer): ManifestDecoded
425
+
426
+ /** A decoded manifest. */
427
+ export interface ManifestDecoded {
428
+ from: ManifestDecodedFrom
429
+ name?: string
430
+ torrent?: ManifestTorrent
431
+ entries: Array<ManifestEntryInfo>
432
+ }
433
+
434
+ /** What a decoded input turned out to be. */
435
+ export declare enum ManifestDecodedFrom {
436
+ /** `.ant` bytes or an `ant://manifest/` link. */
437
+ Manifest = 0,
438
+ /** A file link or bare address: one `Public` entry with no path. */
439
+ FileLink = 1
440
+ }
441
+
442
+ /**
443
+ * Decode an `ant://manifest/` link, an `ant://` file link or a bare address.
444
+ * Offline.
445
+ */
446
+ export declare function manifestDecodeLink(link: string): ManifestDecoded
447
+
448
+ /** Build a manifest with every DataMap embedded as given. Offline. */
449
+ export declare function manifestEncode(request: ManifestBuildRequest): ManifestBuilt
450
+
451
+ /** What a manifest says about one entry, in canonical order. */
452
+ export interface ManifestEntryInfo {
453
+ /** `path`, or the hex content address when there is none. */
454
+ effectiveName: string
455
+ path?: string
456
+ /**
457
+ * The recorded size: the creator's claim. Never more than
458
+ * `Number.MAX_SAFE_INTEGER`: a manifest recording a larger one is
459
+ * rejected with `InvalidInput`.
460
+ */
461
+ size?: number
462
+ /** The recorded SHA-256 (hex): the creator's claim. */
463
+ sha256?: string
464
+ kind: ManifestEntryKind
465
+ /** The file's public address (hex). */
466
+ contentAddress: string
467
+ /**
468
+ * Decoded `Embedded` entries only: the hex DataMap, ready for
469
+ * `dataGetPrivate` / `fileDownloadPrivate`.
470
+ */
471
+ dataMap?: string
472
+ /**
473
+ * The exact plaintext size, when known. Never more than
474
+ * `Number.MAX_SAFE_INTEGER`, as `size`.
475
+ */
476
+ exactSize?: number
477
+ /** `resolve` only: why this entry could not be resolved. */
478
+ error?: string
479
+ }
480
+
481
+ /** One entry of a build request. Give exactly one of `dataMap` and `address`. */
482
+ export interface ManifestEntryInput {
483
+ /** Relative path, subject to the portable path rules. */
484
+ path?: string
485
+ /**
486
+ * Plaintext size to record (the creator's claim): an integer from 0 to
487
+ * `Number.MAX_SAFE_INTEGER`. Anything else, a fraction or `NaN`
488
+ * included, is rejected with `InvalidInput`.
489
+ */
490
+ size?: number
491
+ /** SHA-256 of the plaintext to record (hex). */
492
+ sha256?: string
493
+ /** Hex DataMap, as the upload calls return it: an `Embedded` entry. */
494
+ dataMap?: string
495
+ /** Hex address of a public DataMap chunk: a `Public` entry. */
496
+ address?: string
497
+ }
498
+
499
+ /** How an entry's bytes are fetched. */
500
+ export declare enum ManifestEntryKind {
501
+ /** The DataMap is in the manifest (`dataMap`). */
502
+ Embedded = 0,
503
+ /** Fetch the public DataMap at `contentAddress`. */
504
+ Public = 1
505
+ }
506
+
507
+ /** A torrent the manifest's files are also published as. */
508
+ export interface ManifestTorrent {
509
+ infoHashV1?: string
510
+ infoHashV2?: string
511
+ }
512
+
513
+ /**
514
+ * Read the winning pool hash from a settled `payForMerkleTree` transaction (the
515
+ * `MerklePaymentMade` log emitted by `vaultAddress`), 0x-prefixed — pass it to
516
+ * `client.finalizeUploadMerkle`.
517
+ */
518
+ export declare function merkleWinnerPoolHash(rpcUrl: string, vaultAddress: string, txHash: string): Promise<string>
519
+
520
+ /**
521
+ * On-chain configuration for a known Autonomi EVM network. `name` is one of
522
+ * `"arbitrum-one"` / `"arbitrum-sepolia-test"` (and their short aliases).
523
+ */
524
+ export declare function networkInfo(name: string): NetworkInfo
525
+
526
+ /** On-chain configuration for a known Autonomi EVM network. */
527
+ export interface NetworkInfo {
528
+ /** EVM chain id (e.g. 42161 Arbitrum One, 421614 Arbitrum Sepolia). */
529
+ chainId: number
530
+ /** 0x-prefixed ANT payment-token address. */
531
+ tokenAddress: string
532
+ /** 0x-prefixed payment-vault address. */
533
+ vaultAddress: string
534
+ /** Default HTTPS RPC URL for the network. */
535
+ rpcUrl: string
536
+ }
537
+
538
+ /** A single on-chain payment the external wallet must settle. */
539
+ export interface PaymentEntry {
540
+ /** 0x-prefixed quote hash (32 bytes) — the key in the tx-hash map at finalize. */
541
+ quoteHash: string
542
+ /** 0x-prefixed EVM rewards address to pay. */
543
+ rewardsAddress: string
544
+ /** Amount to pay in atto-tokens (base-10 string; exceeds u64). */
545
+ amount: string
546
+ }
547
+
548
+ /** How an upload is paid for. */
549
+ export declare enum PaymentMode {
550
+ /** Let the SDK pick: merkle batching for large uploads, single otherwise. */
551
+ Auto = 0,
552
+ /** Merkle-batched payment — one on-chain payment covering many chunks. */
553
+ Merkle = 1,
554
+ /** Per-quote wave payment. */
555
+ Single = 2
556
+ }
557
+
558
+ /**
559
+ * Payment shape of a prepared external-signer upload — selects which finalize
560
+ * call to use (see [`PreparedUploadInfo`]).
561
+ */
562
+ export declare enum PaymentType {
563
+ WaveBatch = 0,
564
+ Merkle = 1
565
+ }
566
+
567
+ /** The address (hex) of the pointer `ownerSeed` owns. Offline. */
568
+ export declare function pointerAddress(ownerSeed: Buffer): string
569
+
570
+ /** Whose pointer decides what an address resolves to, after every transfer. */
571
+ export interface PointerController {
572
+ pointer: string
573
+ transfers: Array<string>
574
+ frozen: boolean
575
+ }
576
+
577
+ /** The whole close group's view of a pointer's finality. */
578
+ export interface PointerFinality {
579
+ address: string
580
+ group: number
581
+ answered: number
582
+ status: FinalityStatus
583
+ /** `Open` only: the corroborated state's counter (decimal string), if any. */
584
+ counter?: string
585
+ /** `Settling`, `Unconfirmed` and `Final`: the final state. */
586
+ state?: PointerFinalState
587
+ /** `Forked` only: every final state seen, most-held first. */
588
+ states: Array<PointerFinalState>
589
+ /** `Forked` only: the state a majority holds, if any. */
590
+ majority?: PointerFinalState
591
+ transferredTo?: string
592
+ }
593
+
594
+ /** What a pointer finalize stored. */
595
+ export interface PointerFinalized {
596
+ address: string
597
+ stateId: string
598
+ counter: string
599
+ /** Transfers only: the close group's view once the write landed. */
600
+ finality?: PointerFinality
601
+ }
602
+
603
+ /** One final state, as `pointerFinality` reports it. */
604
+ export interface PointerFinalState {
605
+ stateId: string
606
+ kind: PointerKind
607
+ kindTag: number
608
+ target: string
609
+ /** How many peers of the close group hold it. */
610
+ holders: number
611
+ transferredTo?: string
612
+ }
613
+
614
+ /** A fresh random 32-byte owner seed. Store it as safely as a wallet key. */
615
+ export declare function pointerGenerateSeed(): Buffer
616
+
617
+ /** What a pointer targets. */
618
+ export declare enum PointerKind {
619
+ /** A chunk: what reads resolve to. */
620
+ Chunk = 0,
621
+ /** Another pointer: reads follow it. */
622
+ Pointer = 1,
623
+ /** A kind tag this build does not know (see `kindTag`). Cannot be written. */
624
+ Unknown = 2
625
+ }
626
+
627
+ /** The write an external-signer prepare signed. */
628
+ export declare enum PointerOp {
629
+ Create = 0,
630
+ Update = 1,
631
+ Transfer = 2
632
+ }
633
+
634
+ /** A pointer's current state, as the network serves it. */
635
+ export interface PointerRecord {
636
+ address: string
637
+ /** The owner's ML-DSA-65 public key (hex). */
638
+ owner: string
639
+ /** Decimal string; a final state's is "18446744073709551615". */
640
+ counter: string
641
+ kind: PointerKind
642
+ kindTag: number
643
+ target: string
644
+ stateId: string
645
+ isFinal: boolean
646
+ transferredTo?: string
647
+ }
648
+
649
+ /** Where a pointer chain ends. */
650
+ export interface PointerResolved {
651
+ kind: PointerKind
652
+ kindTag: number
653
+ target: string
654
+ }
655
+
656
+ /** What a transfer stored, and the close group's view afterwards. */
657
+ export interface PointerTransfer {
658
+ address: string
659
+ stateId: string
660
+ finality?: PointerFinality
661
+ /** Why `finality` is missing; the transfer is stored and final all the same. */
662
+ finalityError?: string
663
+ }
664
+
665
+ /** What a create or update stored. */
666
+ export interface PointerWrite {
667
+ address: string
668
+ stateId: string
669
+ counter: string
670
+ }
671
+
672
+ /** One pool commitment for the merkle payment call. */
673
+ export interface PoolCommitmentEntry {
674
+ /** 0x-prefixed pool hash (32 bytes). */
675
+ poolHash: string
676
+ /** The pool's candidate nodes. */
677
+ candidates: Array<CandidateNodeEntry>
678
+ }
679
+
680
+ /** A pointer write signed and quoted, awaiting an external payment. */
681
+ export interface PreparedPointer {
682
+ uploadId: string
683
+ op: PointerOp
684
+ address: string
685
+ stateId: string
686
+ counter: string
687
+ payments: Array<PaymentEntry>
688
+ /** Atto-tokens, decimal string. */
689
+ totalAmount: string
690
+ }
691
+
692
+ /**
693
+ * Summary of a prepared external-signer upload. `paymentType` selects which
694
+ * fields are meaningful and which finalize call to use (see the client's
695
+ * `paymentTransactions` / `finalizeUpload*` docs).
696
+ */
697
+ export interface PreparedUploadInfo {
698
+ /** Opaque handle for this prepared upload; pass to the matching finalize call. */
699
+ uploadId: string
700
+ /** Payment shape — selects the finalize call. */
701
+ paymentType: PaymentType
702
+ /**
703
+ * Wave-batch only: per-quote payments to settle on-chain. Empty for merkle
704
+ * or if everything was already stored.
705
+ */
706
+ payments: Array<PaymentEntry>
707
+ /** Wave-batch: total across all payments (atto-tokens, base-10). `"0"` for merkle. */
708
+ totalAmount: string
709
+ /** Merkle only: merkle tree depth for the `payForMerkleTree` call. 0 for wave-batch. */
710
+ depth: number
711
+ /** Merkle only: pool commitments for the `payForMerkleTree` call. Empty for wave-batch. */
712
+ poolCommitments: Array<PoolCommitmentEntry>
713
+ /** Merkle only: timestamp for the `payForMerkleTree` call. 0 for wave-batch. */
714
+ merklePaymentTimestamp: number
715
+ /**
716
+ * For public uploads: hex address the data is retrievable from after
717
+ * finalize. Absent for private uploads.
718
+ */
719
+ dataMapAddress?: string
720
+ /** True if every chunk already existed on the network — nothing to pay. */
721
+ alreadyStored: boolean
722
+ }
723
+
724
+ /** Which phase a [`ProgressUpdate`] belongs to. */
725
+ export declare enum ProgressPhase {
726
+ Encrypting = 0,
727
+ Quoting = 1,
728
+ Storing = 2,
729
+ Resolving = 3,
730
+ Downloading = 4
731
+ }
732
+
733
+ /**
734
+ * A progress update for a long-running upload or download. `total` is 0 when
735
+ * unknown yet (show an indeterminate bar); otherwise `done / total` is a 0..1
736
+ * fraction of the current phase.
737
+ */
738
+ export interface ProgressUpdate {
739
+ phase: ProgressPhase
740
+ done: number
741
+ total: number
742
+ }
743
+
744
+ /** What a [`TxRequest`] is for. */
745
+ export declare enum TxKind {
746
+ /** ERC-20 allowance approval (sent to the token contract). */
747
+ Approve = 0,
748
+ /** The vault payment call. */
749
+ Pay = 1
750
+ }
751
+
752
+ /** Outcome of a settled transaction, from `waitForReceipt`. */
753
+ export interface TxReceipt {
754
+ /** `true` if the transaction succeeded (receipt status `0x1`). */
755
+ success: boolean
756
+ /** Gas units consumed (base-10 string). */
757
+ gasUsed: string
758
+ /** Effective gas price paid in wei (base-10 string). */
759
+ effectiveGasPrice: string
760
+ }
761
+
762
+ /**
763
+ * One transaction the external wallet must sign & send, in order, to pay for a
764
+ * prepared upload (produced by `client.paymentTransactions`).
765
+ */
766
+ export interface TxRequest {
767
+ /** 0x-prefixed contract address to send the transaction to. */
768
+ to: string
769
+ /** 0x-prefixed ABI-encoded calldata for the transaction's `data` field. */
770
+ data: string
771
+ /** What this transaction is for (allowance approval vs the payment call). */
772
+ kind: TxKind
773
+ /**
774
+ * Wave-batch `Pay` only: the 0x-prefixed quote hashes this payment settles.
775
+ * Map each to the resulting tx hash to build the `finalizeUpload` map.
776
+ */
777
+ quoteHashes: Array<string>
778
+ }
779
+
780
+ /**
781
+ * Whether an upload is publicly retrievable by address, or private (the data
782
+ * map is returned to the caller only).
783
+ */
784
+ export declare enum Visibility {
785
+ Public = 0,
786
+ Private = 1
787
+ }
788
+
789
+ /**
790
+ * Poll `rpcUrl` for the receipt of `txHash`, resolving once it's mined (or
791
+ * rejecting on revert / after `timeoutSecs`). Moves the app's hand-rolled
792
+ * `eth_getTransactionReceipt` polling loop into the SDK.
793
+ */
794
+ export declare function waitForReceipt(rpcUrl: string, txHash: string, timeoutSecs: number): Promise<TxReceipt>