@ckbfs/api 1.5.0 → 2.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.
Files changed (45) hide show
  1. package/README.md +31 -6
  2. package/RFC.v3.md +210 -0
  3. package/dist/index.d.ts +72 -7
  4. package/dist/index.js +440 -75
  5. package/dist/utils/checksum.d.ts +16 -0
  6. package/dist/utils/checksum.js +74 -8
  7. package/dist/utils/constants.d.ts +2 -1
  8. package/dist/utils/constants.js +12 -2
  9. package/dist/utils/file.d.ts +44 -0
  10. package/dist/utils/file.js +303 -30
  11. package/dist/utils/molecule.d.ts +13 -1
  12. package/dist/utils/molecule.js +32 -5
  13. package/dist/utils/transaction-backup.d.ts +117 -0
  14. package/dist/utils/transaction-backup.js +624 -0
  15. package/dist/utils/transaction.d.ts +7 -105
  16. package/dist/utils/transaction.js +45 -565
  17. package/dist/utils/transactions/index.d.ts +8 -0
  18. package/dist/utils/transactions/index.js +31 -0
  19. package/dist/utils/transactions/shared.d.ts +57 -0
  20. package/dist/utils/transactions/shared.js +17 -0
  21. package/dist/utils/transactions/v1v2.d.ts +80 -0
  22. package/dist/utils/transactions/v1v2.js +592 -0
  23. package/dist/utils/transactions/v3.d.ts +124 -0
  24. package/dist/utils/transactions/v3.js +369 -0
  25. package/dist/utils/witness.d.ts +45 -0
  26. package/dist/utils/witness.js +145 -3
  27. package/examples/append-v3.ts +310 -0
  28. package/examples/chunked-publish.ts +307 -0
  29. package/examples/publish-v3.ts +152 -0
  30. package/examples/publish.ts +4 -4
  31. package/examples/retrieve-v3.ts +222 -0
  32. package/package.json +6 -2
  33. package/small-example.txt +1 -0
  34. package/src/index.ts +568 -87
  35. package/src/utils/checksum.ts +90 -9
  36. package/src/utils/constants.ts +19 -2
  37. package/src/utils/file.ts +386 -35
  38. package/src/utils/molecule.ts +43 -6
  39. package/src/utils/transaction-backup.ts +849 -0
  40. package/src/utils/transaction.ts +39 -848
  41. package/src/utils/transactions/index.ts +16 -0
  42. package/src/utils/transactions/shared.ts +64 -0
  43. package/src/utils/transactions/v1v2.ts +791 -0
  44. package/src/utils/transactions/v3.ts +564 -0
  45. package/src/utils/witness.ts +193 -0
@@ -1,107 +1,9 @@
1
- import { ccc, Transaction, Script, Signer } from "@ckb-ccc/core";
2
- import { CKBFSDataType } from "./molecule";
3
- import { NetworkType, ProtocolVersionType } from "./constants";
4
1
  /**
5
- * Utility functions for CKB transaction creation and handling
2
+ * Legacy transaction utilities - re-exports from version-specific modules
3
+ * This file maintains backward compatibility while the actual implementation
4
+ * has been moved to version-specific files in the transactions/ directory
6
5
  */
7
- /**
8
- * Options for creating a CKBFS cell
9
- */
10
- export interface CKBFSCellOptions {
11
- contentType: string;
12
- filename: string;
13
- capacity?: bigint;
14
- lock: Script;
15
- network?: NetworkType;
16
- version?: ProtocolVersionType;
17
- useTypeID?: boolean;
18
- }
19
- /**
20
- * Options for publishing a file to CKBFS
21
- */
22
- export interface PublishOptions extends CKBFSCellOptions {
23
- contentChunks: Uint8Array[];
24
- feeRate?: number;
25
- from?: Transaction;
26
- }
27
- /**
28
- * Options for appending content to a CKBFS file
29
- */
30
- export interface AppendOptions {
31
- ckbfsCell: {
32
- outPoint: {
33
- txHash: string;
34
- index: number;
35
- };
36
- data: CKBFSDataType;
37
- type: Script;
38
- lock: Script;
39
- capacity: bigint;
40
- };
41
- contentChunks: Uint8Array[];
42
- feeRate?: number;
43
- network?: NetworkType;
44
- version?: ProtocolVersionType;
45
- }
46
- /**
47
- * Ensures a string is prefixed with '0x'
48
- * @param value The string to ensure is hex prefixed
49
- * @returns A hex prefixed string
50
- */
51
- export declare function ensureHexPrefix(value: string): `0x${string}`;
52
- /**
53
- * Creates a CKBFS cell
54
- * @param options Options for creating the CKBFS cell
55
- * @returns The created cell output
56
- */
57
- export declare function createCKBFSCell(options: CKBFSCellOptions): {
58
- lock: ccc.Script;
59
- type: ccc.Script;
60
- capacity: bigint;
61
- };
62
- /**
63
- * Prepares a transaction for publishing a file to CKBFS without fee and change handling
64
- * You will need to manually set the typeID if you did not provide inputs, or just check is return value emptyTypeID is true
65
- * @param options Options for publishing the file
66
- * @returns Promise resolving to the prepared transaction and the output index of CKBFS Cell
67
- */
68
- export declare function preparePublishTransaction(options: PublishOptions): Promise<{
69
- tx: Transaction;
70
- outputIndex: number;
71
- emptyTypeID: boolean;
72
- }>;
73
- /**
74
- * Creates a transaction for publishing a file to CKBFS
75
- * @param signer The signer to use for the transaction
76
- * @param options Options for publishing the file
77
- * @returns Promise resolving to the created transaction
78
- */
79
- export declare function createPublishTransaction(signer: Signer, options: PublishOptions): Promise<Transaction>;
80
- /**
81
- * Creates a transaction for appending content to a CKBFS file
82
- * @param signer The signer to use for the transaction
83
- * @param options Options for appending content
84
- * @returns Promise resolving to the created transaction
85
- */
86
- export declare function createAppendTransaction(signer: Signer, options: AppendOptions): Promise<Transaction>;
87
- /**
88
- * Creates a transaction for appending content to a CKBFS file
89
- * @param signer The signer to use for the transaction
90
- * @param options Options for appending content
91
- * @returns Promise resolving to the created transaction
92
- */
93
- export declare function createAppendTransactionDry(signer: Signer, options: AppendOptions): Promise<Transaction>;
94
- /**
95
- * Creates a complete transaction for publishing a file to CKBFS
96
- * @param signer The signer to use for the transaction
97
- * @param options Options for publishing the file
98
- * @returns Promise resolving to the signed transaction
99
- */
100
- export declare function publishCKBFS(signer: Signer, options: PublishOptions): Promise<Transaction>;
101
- /**
102
- * Creates a complete transaction for appending content to a CKBFS file
103
- * @param signer The signer to use for the transaction
104
- * @param options Options for appending content
105
- * @returns Promise resolving to the signed transaction
106
- */
107
- export declare function appendCKBFS(signer: Signer, options: AppendOptions): Promise<Transaction>;
6
+ export { ensureHexPrefix, CKBFSCellOptions } from "./transactions/shared";
7
+ export { PublishOptions, AppendOptions, createCKBFSCell, preparePublishTransaction, createPublishTransaction, prepareAppendTransaction, createAppendTransaction, createAppendTransactionDry, publishCKBFS, appendCKBFS, } from "./transactions/v1v2";
8
+ export { PublishV3Options, AppendV3Options, TransferV3Options, createCKBFSV3Cell, preparePublishV3Transaction, createPublishV3Transaction, createAppendV3Transaction, createTransferV3Transaction, publishCKBFSV3, appendCKBFSV3, transferCKBFSV3, } from "./transactions/v3";
9
+ export * from "./transactions";