@ckbfs/api 1.3.0 → 1.4.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/README.md ADDED
@@ -0,0 +1,570 @@
1
+ # CKBFS API
2
+
3
+ A TypeScript SDK for the CKBFS (CKB File System) protocol on the Nervos CKB blockchain. This library provides a high-level interface for publishing, appending, and retrieving files on the decentralized CKB network.
4
+
5
+ ## Overview
6
+
7
+ CKBFS is a file system protocol built on top of the CKB blockchain that enables decentralized file storage with content integrity verification. Files are stored in transaction witnesses with Adler32 checksums for data integrity and support for file versioning through backlinks.
8
+
9
+ ## Features
10
+
11
+ - **File Publishing**: Store files of any type on the CKB blockchain
12
+ - **File Appending**: Add content to existing files with automatic checksum updates
13
+ - **Content Integrity**: Adler32 checksum verification for all file operations
14
+ - **Protocol Versions**: Support for both V1 and V2 CKBFS protocol versions
15
+ - **Network Support**: Compatible with CKB mainnet and testnet
16
+ - **Chunked Storage**: Automatic file chunking for large files
17
+ - **TypeScript**: Full type safety with comprehensive type definitions
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @ckbfs/api
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ```typescript
28
+ import { CKBFS, NetworkType, ProtocolVersion } from '@ckbfs/api';
29
+
30
+ // Initialize with private key
31
+ const ckbfs = new CKBFS(
32
+ 'your-private-key-here',
33
+ NetworkType.Testnet,
34
+ {
35
+ version: ProtocolVersion.V2,
36
+ chunkSize: 30 * 1024, // 30KB chunks
37
+ useTypeID: false
38
+ }
39
+ );
40
+
41
+ // Publish a file
42
+ const txHash = await ckbfs.publishFile('./example.txt', {
43
+ contentType: 'text/plain',
44
+ filename: 'example.txt'
45
+ });
46
+
47
+ console.log(`File published: ${txHash}`);
48
+ ```
49
+
50
+ ## API Reference
51
+
52
+ ### CKBFS Class
53
+
54
+ #### Constructor
55
+
56
+ ```typescript
57
+ new CKBFS(signerOrPrivateKey, networkOrOptions?, options?)
58
+ ```
59
+
60
+ **Parameters:**
61
+ - `signerOrPrivateKey`: `Signer | string` - CKB signer instance or private key
62
+ - `networkOrOptions`: `NetworkType | CKBFSOptions` - Network type or configuration options
63
+ - `options`: `CKBFSOptions` - Additional configuration when using private key
64
+
65
+ **CKBFSOptions:**
66
+ ```typescript
67
+ interface CKBFSOptions {
68
+ chunkSize?: number; // Default: 30KB
69
+ version?: string; // Default: V2
70
+ useTypeID?: boolean; // Default: false
71
+ network?: NetworkType; // Default: Testnet
72
+ }
73
+ ```
74
+
75
+ #### Methods
76
+
77
+ ##### publishFile(filePath, options?)
78
+
79
+ Publishes a file to CKBFS from the file system.
80
+
81
+ ```typescript
82
+ async publishFile(filePath: string, options?: FileOptions): Promise<string>
83
+ ```
84
+
85
+ ##### publishContent(content, options)
86
+
87
+ Publishes content directly without reading from file system.
88
+
89
+ ```typescript
90
+ async publishContent(
91
+ content: string | Uint8Array,
92
+ options: PublishContentOptions
93
+ ): Promise<string>
94
+ ```
95
+
96
+ ##### appendFile(filePath, ckbfsCell, options?)
97
+
98
+ Appends content from a file to an existing CKBFS file.
99
+
100
+ ```typescript
101
+ async appendFile(
102
+ filePath: string,
103
+ ckbfsCell: AppendOptions['ckbfsCell'],
104
+ options?: Omit<FileOptions, 'contentType' | 'filename'>
105
+ ): Promise<string>
106
+ ```
107
+
108
+ ##### appendContent(content, ckbfsCell, options?)
109
+
110
+ Appends content directly to an existing CKBFS file.
111
+
112
+ ```typescript
113
+ async appendContent(
114
+ content: string | Uint8Array,
115
+ ckbfsCell: AppendOptions['ckbfsCell'],
116
+ options?: AppendContentOptions
117
+ ): Promise<string>
118
+ ```
119
+
120
+ ##### Transaction Creation Methods
121
+
122
+ Create unsigned transactions for custom signing workflows:
123
+
124
+ - `createPublishTransaction(filePath, options?)`
125
+ - `createPublishContentTransaction(content, options)`
126
+ - `createAppendTransaction(filePath, ckbfsCell, options?)`
127
+ - `createAppendContentTransaction(content, ckbfsCell, options?)`
128
+
129
+ ### Types
130
+
131
+ #### FileOptions
132
+
133
+ ```typescript
134
+ interface FileOptions {
135
+ contentType?: string;
136
+ filename?: string;
137
+ capacity?: bigint;
138
+ feeRate?: number;
139
+ network?: NetworkType;
140
+ version?: string;
141
+ useTypeID?: boolean;
142
+ }
143
+ ```
144
+
145
+ #### PublishContentOptions
146
+
147
+ ```typescript
148
+ type PublishContentOptions = Omit<FileOptions, 'capacity' | 'contentType' | 'filename'> &
149
+ Required<Pick<FileOptions, 'contentType' | 'filename'>> &
150
+ { capacity?: bigint };
151
+ ```
152
+
153
+ #### NetworkType
154
+
155
+ ```typescript
156
+ enum NetworkType {
157
+ Mainnet = 'mainnet',
158
+ Testnet = 'testnet'
159
+ }
160
+ ```
161
+
162
+ #### Protocol Versions
163
+
164
+ ```typescript
165
+ const ProtocolVersion = {
166
+ V1: '20240906.ce6724722cf6', // Original version
167
+ V2: '20241025.db973a8e8032' // Enhanced version with multi-witness support
168
+ } as const;
169
+ ```
170
+
171
+ ## Examples
172
+
173
+ ### Publishing a File
174
+
175
+ ```typescript
176
+ import { CKBFS, NetworkType, ProtocolVersion } from '@ckbfs/api';
177
+
178
+ const ckbfs = new CKBFS('your-private-key', NetworkType.Testnet);
179
+
180
+ // Publish with automatic content type detection
181
+ const txHash = await ckbfs.publishFile('./document.pdf');
182
+
183
+ // Publish with custom options
184
+ const txHash2 = await ckbfs.publishFile('./data.json', {
185
+ contentType: 'application/json',
186
+ filename: 'my-data.json',
187
+ capacity: 300n * 100000000n // 300 CKB
188
+ });
189
+ ```
190
+
191
+ ### Publishing Content Directly
192
+
193
+ ```typescript
194
+ const content = "Hello, CKBFS!";
195
+ const txHash = await ckbfs.publishContent(content, {
196
+ contentType: 'text/plain',
197
+ filename: 'greeting.txt'
198
+ });
199
+ ```
200
+
201
+ ### Appending to a File
202
+
203
+ ```typescript
204
+ // First, get the CKBFS cell information from a previous transaction
205
+ const ckbfsCell = await getCellInfoFromTransaction(previousTxHash);
206
+
207
+ // Append content from a file
208
+ const appendTxHash = await ckbfs.appendFile('./additional-content.txt', ckbfsCell);
209
+
210
+ // Or append content directly
211
+ const appendTxHash2 = await ckbfs.appendContent(
212
+ "Additional content to append",
213
+ ckbfsCell
214
+ );
215
+ ```
216
+
217
+ ### Retrieving Files
218
+
219
+ #### Traditional Method (with blockchain queries)
220
+
221
+ ```typescript
222
+ import { getFileContentFromChain, saveFileFromChain } from '@ckbfs/api';
223
+ import { ClientPublicTestnet } from '@ckb-ccc/core';
224
+
225
+ const client = new ClientPublicTestnet();
226
+
227
+ // Get file content from blockchain (follows backlinks automatically)
228
+ const content = await getFileContentFromChain(
229
+ client,
230
+ { txHash: 'transaction-hash', index: 0 },
231
+ ckbfsData
232
+ );
233
+
234
+ // Save to disk
235
+ const savedPath = saveFileFromChain(content, ckbfsData, './downloaded-file.txt');
236
+ ```
237
+
238
+ #### Generic Identifier Retrieval (flexible interface)
239
+
240
+ ```typescript
241
+ import {
242
+ getFileContentFromChainByIdentifier,
243
+ saveFileFromChainByIdentifier,
244
+ decodeFileFromChainByIdentifier,
245
+ parseIdentifier,
246
+ IdentifierType
247
+ } from '@ckbfs/api';
248
+ import { ClientPublicTestnet } from '@ckb-ccc/core';
249
+
250
+ const client = new ClientPublicTestnet();
251
+
252
+ // Supported identifier formats:
253
+ const typeIdHex = '0xbce89252cece632ef819943bed9cd0e2576f8ce26f9f02075b621b1c9a28056a';
254
+ const ckbfsTypeIdUri = 'ckbfs://bce89252cece632ef819943bed9cd0e2576f8ce26f9f02075b621b1c9a28056a';
255
+ const ckbfsOutPointUri = 'ckbfs://431c9d668c1815d26eb4f7ac6256eb350ab351474daea8d588400146ab228780i0';
256
+
257
+ // Parse identifier to see what type it is
258
+ const parsed = parseIdentifier(ckbfsTypeIdUri);
259
+ console.log(`Type: ${parsed.type}`); // "typeId" or "outPoint"
260
+
261
+ // Get file content using any identifier format (follows backlinks automatically)
262
+ const fileData = await getFileContentFromChainByIdentifier(client, ckbfsTypeIdUri, {
263
+ network: 'testnet',
264
+ version: ProtocolVersion.V2,
265
+ useTypeID: false
266
+ });
267
+
268
+ if (fileData) {
269
+ console.log(`File: ${fileData.filename}`);
270
+ console.log(`Size: ${fileData.size} bytes`);
271
+ console.log(`Content type: ${fileData.contentType}`);
272
+ console.log(`Parsed as: ${fileData.parsedId.type}`);
273
+ }
274
+
275
+ // Save file using outPoint format
276
+ const savedPath = await saveFileFromChainByIdentifier(
277
+ client,
278
+ ckbfsOutPointUri,
279
+ './downloaded-file.txt'
280
+ );
281
+
282
+ // Decode using direct witness method with TypeID hex
283
+ const decodedData = await decodeFileFromChainByIdentifier(client, typeIdHex);
284
+ ```
285
+
286
+ #### TypeID-based Retrieval (legacy interface)
287
+
288
+ ```typescript
289
+ import {
290
+ getFileContentFromChainByTypeId,
291
+ saveFileFromChainByTypeId,
292
+ decodeFileFromChainByTypeId
293
+ } from '@ckbfs/api';
294
+
295
+ // Legacy functions still work with TypeID strings
296
+ const fileData = await getFileContentFromChainByTypeId(client, typeId);
297
+ const savedPath = await saveFileFromChainByTypeId(client, typeId, './file.txt');
298
+ const decodedData = await decodeFileFromChainByTypeId(client, typeId);
299
+ ```
300
+
301
+ #### Direct Witness Decoding (new method)
302
+
303
+ ```typescript
304
+ import {
305
+ decodeWitnessContent,
306
+ decodeFileFromWitnessData,
307
+ saveFileFromWitnessData
308
+ } from '@ckbfs/api';
309
+
310
+ // Decode individual witness
311
+ const decoded = decodeWitnessContent(witnessHex);
312
+ if (decoded && decoded.isValid) {
313
+ console.log(`Content: ${decoded.content.length} bytes`);
314
+ }
315
+
316
+ // Decode complete file from witness data
317
+ const file = decodeFileFromWitnessData({
318
+ witnesses: tx.witnesses,
319
+ indexes: [1, 2, 3], // witness indexes containing content
320
+ filename: 'example.txt',
321
+ contentType: 'text/plain'
322
+ });
323
+
324
+ // Save directly from witness data
325
+ const savedPath = saveFileFromWitnessData({
326
+ witnesses: tx.witnesses,
327
+ indexes: [1, 2, 3],
328
+ filename: 'example.txt',
329
+ contentType: 'text/plain'
330
+ }, './decoded-file.txt');
331
+ ```
332
+
333
+ ## Utility Functions
334
+
335
+ The SDK exports various utility functions for advanced use cases:
336
+
337
+ ### Checksum Operations
338
+
339
+ ```typescript
340
+ import { calculateChecksum, verifyChecksum, updateChecksum } from '@ckbfs/api';
341
+
342
+ const checksum = await calculateChecksum(fileData);
343
+ const isValid = await verifyChecksum(fileData, expectedChecksum);
344
+ const newChecksum = await updateChecksum(oldChecksum, appendedData);
345
+ ```
346
+
347
+ ### File Operations
348
+
349
+ ```typescript
350
+ import {
351
+ readFileAsUint8Array,
352
+ getContentType,
353
+ splitFileIntoChunks,
354
+ getFileContentFromChainByIdentifier,
355
+ saveFileFromChainByIdentifier,
356
+ decodeFileFromChainByIdentifier,
357
+ parseIdentifier,
358
+ IdentifierType
359
+ } from '@ckbfs/api';
360
+
361
+ const fileData = readFileAsUint8Array('./file.txt');
362
+ const mimeType = getContentType('./file.txt');
363
+ const chunks = splitFileIntoChunks('./large-file.bin', 30 * 1024);
364
+
365
+ // Generic identifier-based file operations
366
+ const client = new ClientPublicTestnet();
367
+ const identifier = 'ckbfs://bce89252cece632ef819943bed9cd0e2576f8ce26f9f02075b621b1c9a28056a';
368
+ const parsed = parseIdentifier(identifier);
369
+ const fileContent = await getFileContentFromChainByIdentifier(client, identifier);
370
+ const savedPath = await saveFileFromChainByIdentifier(client, identifier, './output.txt');
371
+ const decodedFile = await decodeFileFromChainByIdentifier(client, identifier);
372
+ ```
373
+
374
+ ### Witness Operations
375
+
376
+ ```typescript
377
+ import {
378
+ createCKBFSWitness,
379
+ extractCKBFSWitnessContent,
380
+ isCKBFSWitness
381
+ } from '@ckbfs/api';
382
+
383
+ const witness = createCKBFSWitness(contentBytes);
384
+ const { version, content } = extractCKBFSWitnessContent(witness);
385
+ const isValid = isCKBFSWitness(witness);
386
+ ```
387
+
388
+ ## Identifier Formats
389
+
390
+ CKBFS supports multiple identifier formats for flexible file access:
391
+
392
+ ### 1. TypeID Hex String
393
+ ```
394
+ 0xbce89252cece632ef819943bed9cd0e2576f8ce26f9f02075b621b1c9a28056a
395
+ ```
396
+ Direct TypeID from the CKBFS cell's type script args.
397
+
398
+ ### 2. CKBFS TypeID URI
399
+ ```
400
+ ckbfs://bce89252cece632ef819943bed9cd0e2576f8ce26f9f02075b621b1c9a28056a
401
+ ```
402
+ CKBFS URI format using TypeID (without 0x prefix).
403
+
404
+ ### 3. CKBFS OutPoint URI
405
+ ```
406
+ ckbfs://431c9d668c1815d26eb4f7ac6256eb350ab351474daea8d588400146ab228780i0
407
+ ```
408
+ CKBFS URI format using transaction hash and output index: `ckbfs://{txHash}i{index}`
409
+
410
+ ### Identifier Detection
411
+
412
+ ```typescript
413
+ import { parseIdentifier, IdentifierType } from '@ckbfs/api';
414
+
415
+ const parsed = parseIdentifier('ckbfs://abc123...i0');
416
+ console.log(parsed.type); // IdentifierType.OutPoint
417
+ console.log(parsed.txHash); // '0xabc123...'
418
+ console.log(parsed.index); // 0
419
+ ```
420
+
421
+ ## Protocol Details
422
+
423
+ ### CKBFS Data Structure
424
+
425
+ CKBFS uses a molecule-encoded data structure stored in cell output data:
426
+
427
+ **V1 Format:**
428
+ ```
429
+ {
430
+ index: number, // Single witness index
431
+ checksum: number, // Adler32 checksum
432
+ contentType: string, // MIME type
433
+ filename: string, // Original filename
434
+ backLinks: BackLink[] // Previous versions
435
+ }
436
+ ```
437
+
438
+ **V2 Format:**
439
+ ```
440
+ {
441
+ indexes: number[], // Multiple witness indexes
442
+ checksum: number, // Adler32 checksum
443
+ contentType: string, // MIME type
444
+ filename: string, // Original filename
445
+ backLinks: BackLink[] // Previous versions
446
+ }
447
+ ```
448
+
449
+ ### Witness Format
450
+
451
+ CKBFS witnesses contain:
452
+ - 5-byte header: "CKBFS" (0x43, 0x4B, 0x42, 0x46, 0x53)
453
+ - 1-byte version: 0x00
454
+ - Variable-length content data
455
+
456
+ ### Checksum Algorithm
457
+
458
+ CKBFS uses Adler32 for content integrity verification. When appending content, the checksum is updated using the rolling Adler32 algorithm to maintain cumulative integrity across all file versions.
459
+
460
+ ## Development
461
+
462
+ ### Building
463
+
464
+ ```bash
465
+ npm run build
466
+ ```
467
+
468
+ ### Testing
469
+
470
+ ```bash
471
+ npm test
472
+ ```
473
+
474
+ ### Running Examples
475
+
476
+ ```bash
477
+ # Publish example
478
+ npm run example:publish
479
+
480
+ # Append example (requires existing transaction hash)
481
+ npm run example:append -- --txhash=0x123456...
482
+
483
+ # Retrieve example (demonstrates witness decoding and generic identifier APIs)
484
+ npm run example:retrieve -- --txhash=0x123456...
485
+
486
+ # All examples
487
+ npm run example
488
+ ```
489
+
490
+ ## Environment Variables
491
+
492
+ - `CKB_PRIVATE_KEY`: Your CKB private key for examples
493
+ - `PUBLISH_TX_HASH`: Transaction hash for append examples
494
+ - `TARGET_TX_HASH`: Transaction hash for retrieve examples
495
+
496
+ ## Advanced Usage
497
+
498
+ ### Working with Different Identifier Formats
499
+
500
+ ```typescript
501
+ import {
502
+ getFileContentFromChainByIdentifier,
503
+ parseIdentifier,
504
+ IdentifierType
505
+ } from '@ckbfs/api';
506
+
507
+ // Example identifiers
508
+ const identifiers = [
509
+ '0xabc123...', // TypeID hex
510
+ 'ckbfs://abc123...', // CKBFS TypeID URI
511
+ 'ckbfs://def456...i0' // CKBFS OutPoint URI
512
+ ];
513
+
514
+ // Process any identifier format
515
+ for (const id of identifiers) {
516
+ const parsed = parseIdentifier(id);
517
+ console.log(`Processing ${parsed.type} identifier`);
518
+
519
+ const fileData = await getFileContentFromChainByIdentifier(client, id);
520
+ if (fileData) {
521
+ console.log(`Retrieved: ${fileData.filename}`);
522
+ }
523
+ }
524
+ ```
525
+
526
+ ### Batch File Operations
527
+
528
+ ```typescript
529
+ // Retrieve multiple files using different identifier formats
530
+ const fileIdentifiers = [
531
+ 'ckbfs://file1-typeid...',
532
+ 'ckbfs://tx-hash1...i0',
533
+ '0xfile2-typeid...'
534
+ ];
535
+
536
+ const files = await Promise.all(
537
+ fileIdentifiers.map(id =>
538
+ getFileContentFromChainByIdentifier(client, id)
539
+ )
540
+ );
541
+
542
+ files.forEach((file, index) => {
543
+ if (file) {
544
+ console.log(`File ${index + 1}: ${file.filename} (${file.size} bytes)`);
545
+ }
546
+ });
547
+ ```
548
+
549
+ ## Network Configuration
550
+
551
+ The SDK supports both CKB mainnet and testnet with different deployed contract addresses:
552
+
553
+ ### Testnet (Default)
554
+ - CKBFS V1: `0xe8905ad29a02cf8befa9c258f4f941773839a618d75a64afc22059de9413f712`
555
+ - CKBFS V2: `0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a`
556
+
557
+ ### Mainnet
558
+ - CKBFS V2: `0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a`
559
+
560
+ ## License
561
+
562
+ MIT
563
+
564
+ ## Contributing
565
+
566
+ Contributions are welcome. Please ensure all tests pass and follow the existing code style.
567
+
568
+ ## Support
569
+
570
+ For issues and questions, please use the GitHub issue tracker.
package/code.png ADDED
Binary file
@@ -0,0 +1 @@
1
+ Hollo, WKBFS! This is a test file. More content in second chunk. Last churk of the test file.
@@ -0,0 +1 @@
1
+ Hello CKBFS from direct content!
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Script, Signer, Transaction } from "@ckb-ccc/core";
2
- import { calculateChecksum, verifyChecksum, updateChecksum, verifyWitnessChecksum } from './utils/checksum';
3
- import { createCKBFSCell, createPublishTransaction as utilCreatePublishTransaction, createAppendTransaction as utilCreateAppendTransaction, publishCKBFS as utilPublishCKBFS, appendCKBFS as utilAppendCKBFS, CKBFSCellOptions, PublishOptions, AppendOptions } from './utils/transaction';
4
- import { readFile, readFileAsText, readFileAsUint8Array, writeFile, getContentType, splitFileIntoChunks, combineChunksToFile, getFileContentFromChain, saveFileFromChain } from './utils/file';
5
- import { createCKBFSWitness, createTextCKBFSWitness, extractCKBFSWitnessContent, isCKBFSWitness, createChunkedCKBFSWitnesses } from './utils/witness';
6
- import { CKBFSData, BackLinkV1, BackLinkV2, CKBFSDataType, BackLinkType, CKBFS_HEADER, CKBFS_HEADER_STRING } from './utils/molecule';
7
- import { NetworkType, ProtocolVersion, DEFAULT_NETWORK, DEFAULT_VERSION, CKBFS_CODE_HASH, CKBFS_TYPE_ID, ADLER32_CODE_HASH, ADLER32_TYPE_ID, DEP_GROUP_TX_HASH, DEPLOY_TX_HASH, getCKBFSScriptConfig, CKBFSScriptConfig } from './utils/constants';
2
+ import { calculateChecksum, verifyChecksum, updateChecksum, verifyWitnessChecksum } from "./utils/checksum";
3
+ import { createCKBFSCell, createPublishTransaction as utilCreatePublishTransaction, createAppendTransaction as utilCreateAppendTransaction, publishCKBFS as utilPublishCKBFS, appendCKBFS as utilAppendCKBFS, CKBFSCellOptions, PublishOptions, AppendOptions } from "./utils/transaction";
4
+ import { readFile, readFileAsText, readFileAsUint8Array, writeFile, getContentType, splitFileIntoChunks, combineChunksToFile, getFileContentFromChain, saveFileFromChain, getFileContentFromChainByTypeId, saveFileFromChainByTypeId, decodeFileFromChainByTypeId, getFileContentFromChainByIdentifier, saveFileFromChainByIdentifier, decodeFileFromChainByIdentifier, parseIdentifier, IdentifierType, decodeWitnessContent, decodeMultipleWitnessContents, extractFileFromWitnesses, decodeFileFromWitnessData, saveFileFromWitnessData } from "./utils/file";
5
+ import { createCKBFSWitness, createTextCKBFSWitness, extractCKBFSWitnessContent, isCKBFSWitness, createChunkedCKBFSWitnesses } from "./utils/witness";
6
+ import { CKBFSData, BackLinkV1, BackLinkV2, CKBFSDataType, BackLinkType, CKBFS_HEADER, CKBFS_HEADER_STRING } from "./utils/molecule";
7
+ import { NetworkType, ProtocolVersion, ProtocolVersionType, DEFAULT_NETWORK, DEFAULT_VERSION, CKBFS_CODE_HASH, CKBFS_TYPE_ID, ADLER32_CODE_HASH, ADLER32_TYPE_ID, DEP_GROUP_TX_HASH, DEPLOY_TX_HASH, getCKBFSScriptConfig, CKBFSScriptConfig } from "./utils/constants";
8
8
  /**
9
9
  * Custom options for file publishing and appending
10
10
  */
@@ -14,19 +14,19 @@ export interface FileOptions {
14
14
  capacity?: bigint;
15
15
  feeRate?: number;
16
16
  network?: NetworkType;
17
- version?: string;
17
+ version?: ProtocolVersionType;
18
18
  useTypeID?: boolean;
19
19
  }
20
20
  /**
21
21
  * Options required when publishing content directly (string or Uint8Array)
22
22
  */
23
- export type PublishContentOptions = Omit<FileOptions, 'capacity' | 'contentType' | 'filename'> & Required<Pick<FileOptions, 'contentType' | 'filename'>> & {
23
+ export type PublishContentOptions = Omit<FileOptions, "capacity" | "contentType" | "filename"> & Required<Pick<FileOptions, "contentType" | "filename">> & {
24
24
  capacity?: bigint;
25
25
  };
26
26
  /**
27
27
  * Options required when appending content directly (string or Uint8Array)
28
28
  */
29
- export type AppendContentOptions = Omit<FileOptions, 'contentType' | 'filename' | 'capacity'> & {
29
+ export type AppendContentOptions = Omit<FileOptions, "contentType" | "filename" | "capacity"> & {
30
30
  capacity?: bigint;
31
31
  };
32
32
  /**
@@ -34,7 +34,7 @@ export type AppendContentOptions = Omit<FileOptions, 'contentType' | 'filename'
34
34
  */
35
35
  export interface CKBFSOptions {
36
36
  chunkSize?: number;
37
- version?: string;
37
+ version?: ProtocolVersionType;
38
38
  useTypeID?: boolean;
39
39
  network?: NetworkType;
40
40
  }
@@ -90,7 +90,7 @@ export declare class CKBFS {
90
90
  * @param options Additional options for the append operation
91
91
  * @returns Promise resolving to the transaction hash
92
92
  */
93
- appendFile(filePath: string, ckbfsCell: AppendOptions['ckbfsCell'], options?: Omit<FileOptions, 'contentType' | 'filename'>): Promise<string>;
93
+ appendFile(filePath: string, ckbfsCell: AppendOptions["ckbfsCell"], options?: Omit<FileOptions, "contentType" | "filename">): Promise<string>;
94
94
  /**
95
95
  * Appends content (string or Uint8Array) directly to an existing CKBFS file
96
96
  * @param content The content string or byte array to append
@@ -98,7 +98,7 @@ export declare class CKBFS {
98
98
  * @param options Additional options for the append operation
99
99
  * @returns Promise resolving to the transaction hash
100
100
  */
101
- appendContent(content: string | Uint8Array, ckbfsCell: AppendOptions['ckbfsCell'], options?: AppendContentOptions): Promise<string>;
101
+ appendContent(content: string | Uint8Array, ckbfsCell: AppendOptions["ckbfsCell"], options?: AppendContentOptions): Promise<string>;
102
102
  /**
103
103
  * Creates a new transaction for publishing a file but doesn't sign or send it
104
104
  * @param filePath The path to the file to publish
@@ -120,7 +120,7 @@ export declare class CKBFS {
120
120
  * @param options Additional options for the append operation
121
121
  * @returns Promise resolving to the unsigned transaction
122
122
  */
123
- createAppendTransaction(filePath: string, ckbfsCell: AppendOptions['ckbfsCell'], options?: Omit<FileOptions, 'contentType' | 'filename'>): Promise<Transaction>;
123
+ createAppendTransaction(filePath: string, ckbfsCell: AppendOptions["ckbfsCell"], options?: Omit<FileOptions, "contentType" | "filename">): Promise<Transaction>;
124
124
  /**
125
125
  * Creates a new transaction for appending content (string or Uint8Array) directly, but doesn't sign or send it
126
126
  * @param content The content string or byte array to append
@@ -128,6 +128,6 @@ export declare class CKBFS {
128
128
  * @param options Additional options for the append operation
129
129
  * @returns Promise resolving to the unsigned transaction
130
130
  */
131
- createAppendContentTransaction(content: string | Uint8Array, ckbfsCell: AppendOptions['ckbfsCell'], options?: AppendContentOptions): Promise<Transaction>;
131
+ createAppendContentTransaction(content: string | Uint8Array, ckbfsCell: AppendOptions["ckbfsCell"], options?: AppendContentOptions): Promise<Transaction>;
132
132
  }
133
- export { calculateChecksum, verifyChecksum, updateChecksum, verifyWitnessChecksum, createCKBFSCell, utilCreatePublishTransaction as createPublishTransaction, utilCreateAppendTransaction as createAppendTransaction, utilPublishCKBFS as publishCKBFS, utilAppendCKBFS as appendCKBFS, readFile, readFileAsText, readFileAsUint8Array, writeFile, getContentType, splitFileIntoChunks, combineChunksToFile, getFileContentFromChain, saveFileFromChain, createCKBFSWitness, createTextCKBFSWitness, extractCKBFSWitnessContent, isCKBFSWitness, createChunkedCKBFSWitnesses, CKBFSData, BackLinkV1, BackLinkV2, CKBFSDataType, BackLinkType, CKBFSCellOptions, PublishOptions, AppendOptions, CKBFS_HEADER, CKBFS_HEADER_STRING, NetworkType, ProtocolVersion, DEFAULT_NETWORK, DEFAULT_VERSION, CKBFS_CODE_HASH, CKBFS_TYPE_ID, ADLER32_CODE_HASH, ADLER32_TYPE_ID, DEP_GROUP_TX_HASH, DEPLOY_TX_HASH, getCKBFSScriptConfig, CKBFSScriptConfig };
133
+ export { calculateChecksum, verifyChecksum, updateChecksum, verifyWitnessChecksum, createCKBFSCell, utilCreatePublishTransaction as createPublishTransaction, utilCreateAppendTransaction as createAppendTransaction, utilPublishCKBFS as publishCKBFS, utilAppendCKBFS as appendCKBFS, readFile, readFileAsText, readFileAsUint8Array, writeFile, getContentType, splitFileIntoChunks, combineChunksToFile, getFileContentFromChain, saveFileFromChain, getFileContentFromChainByTypeId, saveFileFromChainByTypeId, decodeFileFromChainByTypeId, getFileContentFromChainByIdentifier, saveFileFromChainByIdentifier, decodeFileFromChainByIdentifier, parseIdentifier, IdentifierType, decodeWitnessContent, decodeMultipleWitnessContents, extractFileFromWitnesses, decodeFileFromWitnessData, saveFileFromWitnessData, createCKBFSWitness, createTextCKBFSWitness, extractCKBFSWitnessContent, isCKBFSWitness, createChunkedCKBFSWitnesses, CKBFSData, BackLinkV1, BackLinkV2, CKBFSDataType, BackLinkType, CKBFSCellOptions, PublishOptions, AppendOptions, CKBFS_HEADER, CKBFS_HEADER_STRING, NetworkType, ProtocolVersion, ProtocolVersionType, DEFAULT_NETWORK, DEFAULT_VERSION, CKBFS_CODE_HASH, CKBFS_TYPE_ID, ADLER32_CODE_HASH, ADLER32_TYPE_ID, DEP_GROUP_TX_HASH, DEPLOY_TX_HASH, getCKBFSScriptConfig, CKBFSScriptConfig, };