@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.
- package/README.md +31 -6
- package/RFC.v3.md +210 -0
- package/dist/index.d.ts +72 -7
- package/dist/index.js +440 -75
- package/dist/utils/checksum.d.ts +16 -0
- package/dist/utils/checksum.js +74 -8
- package/dist/utils/constants.d.ts +2 -1
- package/dist/utils/constants.js +12 -2
- package/dist/utils/file.d.ts +44 -0
- package/dist/utils/file.js +303 -30
- package/dist/utils/molecule.d.ts +13 -1
- package/dist/utils/molecule.js +32 -5
- package/dist/utils/transaction-backup.d.ts +117 -0
- package/dist/utils/transaction-backup.js +624 -0
- package/dist/utils/transaction.d.ts +7 -105
- package/dist/utils/transaction.js +45 -565
- package/dist/utils/transactions/index.d.ts +8 -0
- package/dist/utils/transactions/index.js +31 -0
- package/dist/utils/transactions/shared.d.ts +57 -0
- package/dist/utils/transactions/shared.js +17 -0
- package/dist/utils/transactions/v1v2.d.ts +80 -0
- package/dist/utils/transactions/v1v2.js +592 -0
- package/dist/utils/transactions/v3.d.ts +124 -0
- package/dist/utils/transactions/v3.js +369 -0
- package/dist/utils/witness.d.ts +45 -0
- package/dist/utils/witness.js +145 -3
- package/examples/append-v3.ts +310 -0
- package/examples/chunked-publish.ts +307 -0
- package/examples/publish-v3.ts +152 -0
- package/examples/publish.ts +4 -4
- package/examples/retrieve-v3.ts +222 -0
- package/package.json +6 -2
- package/small-example.txt +1 -0
- package/src/index.ts +568 -87
- package/src/utils/checksum.ts +90 -9
- package/src/utils/constants.ts +19 -2
- package/src/utils/file.ts +386 -35
- package/src/utils/molecule.ts +43 -6
- package/src/utils/transaction-backup.ts +849 -0
- package/src/utils/transaction.ts +39 -848
- package/src/utils/transactions/index.ts +16 -0
- package/src/utils/transactions/shared.ts +64 -0
- package/src/utils/transactions/v1v2.ts +791 -0
- package/src/utils/transactions/v3.ts +564 -0
- package/src/utils/witness.ts +193 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transaction utilities for all CKBFS protocol versions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Shared utilities and interfaces
|
|
6
|
+
export * from "./shared";
|
|
7
|
+
|
|
8
|
+
// V1 and V2 transaction utilities
|
|
9
|
+
export * from "./v1v2";
|
|
10
|
+
|
|
11
|
+
// V3 transaction utilities
|
|
12
|
+
export * from "./v3";
|
|
13
|
+
|
|
14
|
+
// Re-export for backward compatibility
|
|
15
|
+
export { createCKBFSCell } from "./v1v2";
|
|
16
|
+
export { createCKBFSV3Cell } from "./v3";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Script, Transaction } from "@ckb-ccc/core";
|
|
2
|
+
import { CKBFSDataType } from "../molecule";
|
|
3
|
+
import { NetworkType, ProtocolVersionType } from "../constants";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared interfaces and utilities for transaction handling across all versions
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Ensures a string is prefixed with '0x'
|
|
11
|
+
* @param value The string to ensure is hex prefixed
|
|
12
|
+
* @returns A hex prefixed string
|
|
13
|
+
*/
|
|
14
|
+
export function ensureHexPrefix(value: string): `0x${string}` {
|
|
15
|
+
if (value.startsWith("0x")) {
|
|
16
|
+
return value as `0x${string}`;
|
|
17
|
+
}
|
|
18
|
+
return `0x${value}` as `0x${string}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base options for creating a CKBFS cell
|
|
23
|
+
*/
|
|
24
|
+
export interface BaseCKBFSCellOptions {
|
|
25
|
+
contentType: string;
|
|
26
|
+
filename: string;
|
|
27
|
+
capacity?: bigint;
|
|
28
|
+
lock: Script;
|
|
29
|
+
network?: NetworkType;
|
|
30
|
+
version?: ProtocolVersionType;
|
|
31
|
+
useTypeID?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Base options for publishing a file to CKBFS
|
|
36
|
+
*/
|
|
37
|
+
export interface BasePublishOptions extends BaseCKBFSCellOptions {
|
|
38
|
+
contentChunks: Uint8Array[];
|
|
39
|
+
feeRate?: number;
|
|
40
|
+
from?: Transaction;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Base options for appending content to a CKBFS file
|
|
45
|
+
*/
|
|
46
|
+
export interface BaseAppendOptions {
|
|
47
|
+
ckbfsCell: {
|
|
48
|
+
outPoint: { txHash: string; index: number };
|
|
49
|
+
data: CKBFSDataType;
|
|
50
|
+
type: Script;
|
|
51
|
+
lock: Script;
|
|
52
|
+
capacity: bigint;
|
|
53
|
+
};
|
|
54
|
+
contentChunks: Uint8Array[];
|
|
55
|
+
feeRate?: number;
|
|
56
|
+
network?: NetworkType;
|
|
57
|
+
version?: ProtocolVersionType;
|
|
58
|
+
from?: Transaction;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Common CKBFS cell creation options
|
|
63
|
+
*/
|
|
64
|
+
export interface CKBFSCellOptions extends BaseCKBFSCellOptions {}
|