@ckbfs/api 1.5.1 → 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 +437 -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 -115
  16. package/dist/utils/transaction.js +45 -622
  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,117 +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
- from?: Transaction;
46
- }
47
- /**
48
- * Ensures a string is prefixed with '0x'
49
- * @param value The string to ensure is hex prefixed
50
- * @returns A hex prefixed string
51
- */
52
- export declare function ensureHexPrefix(value: string): `0x${string}`;
53
- /**
54
- * Creates a CKBFS cell
55
- * @param options Options for creating the CKBFS cell
56
- * @returns The created cell output
57
- */
58
- export declare function createCKBFSCell(options: CKBFSCellOptions): {
59
- lock: ccc.Script;
60
- type: ccc.Script;
61
- capacity: bigint;
62
- };
63
- /**
64
- * Prepares a transaction for publishing a file to CKBFS without fee and change handling
65
- * You will need to manually set the typeID if you did not provide inputs, or just check is return value emptyTypeID is true
66
- * @param options Options for publishing the file
67
- * @returns Promise resolving to the prepared transaction and the output index of CKBFS Cell
68
- */
69
- export declare function preparePublishTransaction(options: PublishOptions): Promise<{
70
- tx: Transaction;
71
- outputIndex: number;
72
- emptyTypeID: boolean;
73
- }>;
74
- /**
75
- * Creates a transaction for publishing a file to CKBFS
76
- * @param signer The signer to use for the transaction
77
- * @param options Options for publishing the file
78
- * @returns Promise resolving to the created transaction
79
- */
80
- export declare function createPublishTransaction(signer: Signer, options: PublishOptions): Promise<Transaction>;
81
- /**
82
- * Prepares a transaction for appending content to a CKBFS file without fee and change handling
83
- * @param options Options for appending content
84
- * @returns Promise resolving to the prepared transaction and the output index of CKBFS Cell
85
- */
86
- export declare function prepareAppendTransaction(options: AppendOptions): Promise<{
87
- tx: Transaction;
88
- outputIndex: number;
89
- }>;
90
- /**
91
- * Creates a transaction for appending content to a CKBFS file
92
- * @param signer The signer to use for the transaction
93
- * @param options Options for appending content
94
- * @returns Promise resolving to the created transaction
95
- */
96
- export declare function createAppendTransaction(signer: Signer, options: AppendOptions): Promise<Transaction>;
97
- /**
98
- * Creates a transaction for appending content to a CKBFS file
99
- * @param signer The signer to use for the transaction
100
- * @param options Options for appending content
101
- * @returns Promise resolving to the created transaction
102
- */
103
- export declare function createAppendTransactionDry(signer: Signer, options: AppendOptions): Promise<Transaction>;
104
- /**
105
- * Creates a complete transaction for publishing a file to CKBFS
106
- * @param signer The signer to use for the transaction
107
- * @param options Options for publishing the file
108
- * @returns Promise resolving to the signed transaction
109
- */
110
- export declare function publishCKBFS(signer: Signer, options: PublishOptions): Promise<Transaction>;
111
- /**
112
- * Creates a complete transaction for appending content to a CKBFS file
113
- * @param signer The signer to use for the transaction
114
- * @param options Options for appending content
115
- * @returns Promise resolving to the signed transaction
116
- */
117
- 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";