@ckbfs/api 1.2.3 → 1.2.5
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 +506 -74
- package/code.png +0 -0
- package/demo-output.txt +1 -0
- package/direct_direct_content_example.txt +1 -0
- package/dist/index.d.ts +55 -13
- package/dist/index.js +143 -18
- package/dist/utils/constants.d.ts +7 -3
- package/dist/utils/constants.js +41 -34
- package/dist/utils/file.d.ts +179 -0
- package/dist/utils/file.js +599 -31
- package/dist/utils/molecule.d.ts +3 -2
- package/dist/utils/molecule.js +22 -24
- package/dist/utils/transaction.d.ts +10 -4
- package/dist/utils/transaction.js +34 -32
- package/examples/example.txt +1 -0
- package/examples/identifier-test.ts +178 -0
- package/examples/index.ts +36 -24
- package/examples/publish.ts +39 -5
- package/examples/retrieve.ts +542 -77
- package/examples/witness-decode-demo.ts +190 -0
- package/identifier_direct_content_example.txt +1 -0
- package/package-lock.json +4978 -0
- package/package.json +3 -2
- package/src/index.ts +312 -96
- package/src/utils/constants.ts +77 -43
- package/src/utils/file.ts +864 -59
- package/src/utils/molecule.ts +41 -36
- package/src/utils/transaction.ts +177 -151
- package/traditional_direct_content_example.txt +1 -0
- package/typeid_direct_content_example.txt +1 -0
- package/.cursor/rules/typescript.mdc +0 -49
- package/ABC.LOGS +0 -1
- package/RFC.v2.md +0 -341
- package/append.txt +0 -1
- package/example.txt +0 -1
- package/publish-tx-hash-v1.txt +0 -1
- package/src/utils/createPublishTransaction +0 -24
- package/test-download.txt +0 -2
package/src/utils/constants.ts
CHANGED
@@ -3,89 +3,115 @@
|
|
3
3
|
*/
|
4
4
|
|
5
5
|
export enum NetworkType {
|
6
|
-
Mainnet =
|
7
|
-
Testnet =
|
6
|
+
Mainnet = "mainnet",
|
7
|
+
Testnet = "testnet",
|
8
8
|
}
|
9
9
|
|
10
10
|
// Use string literals for version values to avoid TypeScript indexing issues
|
11
11
|
export const ProtocolVersion = {
|
12
|
-
V1:
|
13
|
-
V2:
|
12
|
+
V1: "20240906.ce6724722cf6", // Original version, compact and simple, suitable for small files
|
13
|
+
V2: "20241025.db973a8e8032", // New version, more features and can do complex operations
|
14
14
|
} as const;
|
15
15
|
|
16
|
-
export type ProtocolVersionType =
|
16
|
+
export type ProtocolVersionType =
|
17
|
+
| (typeof ProtocolVersion)[keyof typeof ProtocolVersion]
|
18
|
+
| string;
|
17
19
|
|
18
20
|
// CKBFS Type Script Constants
|
19
21
|
export const CKBFS_CODE_HASH: Record<NetworkType, Record<string, string>> = {
|
20
22
|
[NetworkType.Mainnet]: {
|
21
|
-
[ProtocolVersion.V2]:
|
23
|
+
[ProtocolVersion.V2]:
|
24
|
+
"0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a",
|
22
25
|
},
|
23
26
|
[NetworkType.Testnet]: {
|
24
|
-
[ProtocolVersion.V1]:
|
25
|
-
|
26
|
-
|
27
|
+
[ProtocolVersion.V1]:
|
28
|
+
"0xe8905ad29a02cf8befa9c258f4f941773839a618d75a64afc22059de9413f712",
|
29
|
+
[ProtocolVersion.V2]:
|
30
|
+
"0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a",
|
31
|
+
},
|
27
32
|
};
|
28
33
|
|
29
34
|
export const CKBFS_TYPE_ID: Record<NetworkType, Record<string, string>> = {
|
30
35
|
[NetworkType.Mainnet]: {
|
31
|
-
[ProtocolVersion.V2]:
|
36
|
+
[ProtocolVersion.V2]:
|
37
|
+
"0xfd2058c9a0c0183354cf637e25d2707ffa9bb6fa2ba9b29f4ebc6be3e54ad7eb",
|
32
38
|
},
|
33
39
|
[NetworkType.Testnet]: {
|
34
|
-
[ProtocolVersion.V1]:
|
35
|
-
|
36
|
-
|
40
|
+
[ProtocolVersion.V1]:
|
41
|
+
"0x88ef4d436af35684a27edda0d44dd8771318330285f90f02d13606e095aea86f",
|
42
|
+
[ProtocolVersion.V2]:
|
43
|
+
"0x7c6dcab8268201f064dc8676b5eafa60ca2569e5c6209dcbab0eb64a9cb3aaa3",
|
44
|
+
},
|
37
45
|
};
|
38
46
|
|
39
47
|
// Adler32 Hasher Constants
|
40
48
|
export const ADLER32_CODE_HASH: Record<NetworkType, Record<string, string>> = {
|
41
49
|
[NetworkType.Mainnet]: {
|
42
|
-
[ProtocolVersion.V2]:
|
50
|
+
[ProtocolVersion.V2]:
|
51
|
+
"0x2138683f76944437c0c643664120d620bdb5858dd6c9d1d156805e279c2c536f",
|
43
52
|
},
|
44
53
|
[NetworkType.Testnet]: {
|
45
|
-
[ProtocolVersion.V1]:
|
46
|
-
|
47
|
-
|
54
|
+
[ProtocolVersion.V1]:
|
55
|
+
"0x8af42cd329cf1bcffb4c73b48252e99cb32346fdbc1cdaa5ae1d000232d47e84",
|
56
|
+
[ProtocolVersion.V2]:
|
57
|
+
"0x2138683f76944437c0c643664120d620bdb5858dd6c9d1d156805e279c2c536f",
|
58
|
+
},
|
48
59
|
};
|
49
60
|
|
50
61
|
export const ADLER32_TYPE_ID: Record<NetworkType, Record<string, string>> = {
|
51
62
|
[NetworkType.Mainnet]: {
|
52
|
-
[ProtocolVersion.V2]:
|
63
|
+
[ProtocolVersion.V2]:
|
64
|
+
"0x641c01d590833a3f5471bd441651d9f2a8a200141949cdfeef2d68d8094c5876",
|
53
65
|
},
|
54
66
|
[NetworkType.Testnet]: {
|
55
|
-
[ProtocolVersion.V1]:
|
56
|
-
|
57
|
-
|
67
|
+
[ProtocolVersion.V1]:
|
68
|
+
"0xccf29a0d8e860044a3d2f6a6e709f6572f77e4fe245fadd212fc342337048d60",
|
69
|
+
[ProtocolVersion.V2]:
|
70
|
+
"0x5f73f128be76e397f5a3b56c94ca16883a8ee91b498bc0ee80473818318c05ac",
|
71
|
+
},
|
58
72
|
};
|
59
73
|
|
60
74
|
// Dep Group Transaction Constants
|
61
75
|
export const DEP_GROUP_TX_HASH: Record<NetworkType, Record<string, string>> = {
|
62
76
|
[NetworkType.Mainnet]: {
|
63
|
-
[ProtocolVersion.V2]:
|
77
|
+
[ProtocolVersion.V2]:
|
78
|
+
"0xfab07962ed7178ed88d450774e2a6ecd50bae856bdb9b692980be8c5147d1bfa",
|
64
79
|
},
|
65
80
|
[NetworkType.Testnet]: {
|
66
|
-
[ProtocolVersion.V1]:
|
67
|
-
|
68
|
-
|
81
|
+
[ProtocolVersion.V1]:
|
82
|
+
"0xc8fd44aba36f0c4b37536b6c7ea3b88df65fa97e02f77cd33b9bf20bf241a09b",
|
83
|
+
[ProtocolVersion.V2]:
|
84
|
+
"0x469af0d961dcaaedd872968a9388b546717a6ccfa47b3165b3f9c981e9d66aaa",
|
85
|
+
},
|
69
86
|
};
|
70
87
|
|
71
88
|
// Deploy Transaction Constants
|
72
|
-
export const DEPLOY_TX_HASH: Record<
|
89
|
+
export const DEPLOY_TX_HASH: Record<
|
90
|
+
NetworkType,
|
91
|
+
Record<string, { ckbfs: string; adler32: string }>
|
92
|
+
> = {
|
73
93
|
[NetworkType.Mainnet]: {
|
74
94
|
[ProtocolVersion.V2]: {
|
75
|
-
ckbfs:
|
76
|
-
|
77
|
-
|
95
|
+
ckbfs:
|
96
|
+
"0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc",
|
97
|
+
adler32:
|
98
|
+
"0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc",
|
99
|
+
},
|
78
100
|
},
|
79
101
|
[NetworkType.Testnet]: {
|
80
102
|
[ProtocolVersion.V1]: {
|
81
|
-
ckbfs:
|
82
|
-
|
103
|
+
ckbfs:
|
104
|
+
"0xde8eb09151fbcdcba398423159ce348cc89a38a736de3fd0960b18b084465382",
|
105
|
+
adler32:
|
106
|
+
"0x042f264d7397a181437b51ff9981cf536f252ab5740b61ce52ce31ada04ed54b",
|
83
107
|
},
|
84
108
|
[ProtocolVersion.V2]: {
|
85
|
-
ckbfs:
|
86
|
-
|
87
|
-
|
88
|
-
|
109
|
+
ckbfs:
|
110
|
+
"0x2c8c9ad3134743368b5a79977648f96c5bd0aba187021a72fb624301064d3616",
|
111
|
+
adler32:
|
112
|
+
"0x2c8c9ad3134743368b5a79977648f96c5bd0aba187021a72fb624301064d3616",
|
113
|
+
},
|
114
|
+
},
|
89
115
|
};
|
90
116
|
|
91
117
|
// Default values - V2 is now the default
|
@@ -95,7 +121,7 @@ export const DEFAULT_NETWORK = NetworkType.Testnet;
|
|
95
121
|
// Helper function to get CKBFS script configuration
|
96
122
|
export interface CKBFSScriptConfig {
|
97
123
|
codeHash: string;
|
98
|
-
hashType:
|
124
|
+
hashType: "data1" | "type";
|
99
125
|
depTxHash: string;
|
100
126
|
depIndex?: number;
|
101
127
|
}
|
@@ -109,15 +135,23 @@ export interface CKBFSScriptConfig {
|
|
109
135
|
*/
|
110
136
|
export function getCKBFSScriptConfig(
|
111
137
|
network: NetworkType = DEFAULT_NETWORK,
|
112
|
-
version:
|
113
|
-
useTypeID: boolean = false
|
138
|
+
version: ProtocolVersionType = DEFAULT_VERSION,
|
139
|
+
useTypeID: boolean = false,
|
114
140
|
): CKBFSScriptConfig {
|
115
141
|
return {
|
116
|
-
codeHash: useTypeID
|
117
|
-
? CKBFS_TYPE_ID[network][version]
|
142
|
+
codeHash: useTypeID
|
143
|
+
? CKBFS_TYPE_ID[network][version]
|
118
144
|
: CKBFS_CODE_HASH[network][version],
|
119
|
-
hashType: useTypeID ?
|
145
|
+
hashType: useTypeID ? "type" : "data1",
|
120
146
|
depTxHash: DEP_GROUP_TX_HASH[network][version],
|
121
|
-
depIndex: 0
|
147
|
+
depIndex: 0,
|
122
148
|
};
|
123
|
-
}
|
149
|
+
}
|
150
|
+
|
151
|
+
import { Hex, HashType, CellDepInfo, ScriptInfo } from "@ckb-ccc/core";
|
152
|
+
|
153
|
+
export class CKBFSScriptInfo extends ScriptInfo {
|
154
|
+
constructor(codeHash: Hex, hashType: HashType, cellDeps: CellDepInfo[]) {
|
155
|
+
super(codeHash, hashType, cellDeps);
|
156
|
+
}
|
157
|
+
}
|