@ckbfs/api 1.2.4 → 1.2.6

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.
@@ -3,89 +3,115 @@
3
3
  */
4
4
 
5
5
  export enum NetworkType {
6
- Mainnet = 'mainnet',
7
- Testnet = '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: '20240906.ce6724722cf6', // Original version, compact and simple, suitable for small files
13
- V2: '20241025.db973a8e8032' // New version, more features and can do complex operations
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 = typeof ProtocolVersion[keyof typeof ProtocolVersion];
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]: '0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a'
23
+ [ProtocolVersion.V2]:
24
+ "0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a",
22
25
  },
23
26
  [NetworkType.Testnet]: {
24
- [ProtocolVersion.V1]: '0xe8905ad29a02cf8befa9c258f4f941773839a618d75a64afc22059de9413f712',
25
- [ProtocolVersion.V2]: '0x31e6376287d223b8c0410d562fb422f04d1d617b2947596a14c3d2efb7218d3a'
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]: '0xfd2058c9a0c0183354cf637e25d2707ffa9bb6fa2ba9b29f4ebc6be3e54ad7eb'
36
+ [ProtocolVersion.V2]:
37
+ "0xfd2058c9a0c0183354cf637e25d2707ffa9bb6fa2ba9b29f4ebc6be3e54ad7eb",
32
38
  },
33
39
  [NetworkType.Testnet]: {
34
- [ProtocolVersion.V1]: '0x88ef4d436af35684a27edda0d44dd8771318330285f90f02d13606e095aea86f',
35
- [ProtocolVersion.V2]: '0x7c6dcab8268201f064dc8676b5eafa60ca2569e5c6209dcbab0eb64a9cb3aaa3'
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]: '0x2138683f76944437c0c643664120d620bdb5858dd6c9d1d156805e279c2c536f'
50
+ [ProtocolVersion.V2]:
51
+ "0x2138683f76944437c0c643664120d620bdb5858dd6c9d1d156805e279c2c536f",
43
52
  },
44
53
  [NetworkType.Testnet]: {
45
- [ProtocolVersion.V1]: '0x8af42cd329cf1bcffb4c73b48252e99cb32346fdbc1cdaa5ae1d000232d47e84',
46
- [ProtocolVersion.V2]: '0x2138683f76944437c0c643664120d620bdb5858dd6c9d1d156805e279c2c536f'
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]: '0x641c01d590833a3f5471bd441651d9f2a8a200141949cdfeef2d68d8094c5876'
63
+ [ProtocolVersion.V2]:
64
+ "0x641c01d590833a3f5471bd441651d9f2a8a200141949cdfeef2d68d8094c5876",
53
65
  },
54
66
  [NetworkType.Testnet]: {
55
- [ProtocolVersion.V1]: '0xccf29a0d8e860044a3d2f6a6e709f6572f77e4fe245fadd212fc342337048d60',
56
- [ProtocolVersion.V2]: '0x5f73f128be76e397f5a3b56c94ca16883a8ee91b498bc0ee80473818318c05ac'
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]: '0xfab07962ed7178ed88d450774e2a6ecd50bae856bdb9b692980be8c5147d1bfa'
77
+ [ProtocolVersion.V2]:
78
+ "0xfab07962ed7178ed88d450774e2a6ecd50bae856bdb9b692980be8c5147d1bfa",
64
79
  },
65
80
  [NetworkType.Testnet]: {
66
- [ProtocolVersion.V1]: '0xc8fd44aba36f0c4b37536b6c7ea3b88df65fa97e02f77cd33b9bf20bf241a09b',
67
- [ProtocolVersion.V2]: '0x469af0d961dcaaedd872968a9388b546717a6ccfa47b3165b3f9c981e9d66aaa'
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<NetworkType, Record<string, { ckbfs: string; adler32: string }>> = {
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: '0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc',
76
- adler32: '0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc'
77
- }
95
+ ckbfs:
96
+ "0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc",
97
+ adler32:
98
+ "0xc9b6698f44c3b80e7e1c48823b2714e432b93f0206ffaf9df885d23267ed2ebc",
99
+ },
78
100
  },
79
101
  [NetworkType.Testnet]: {
80
102
  [ProtocolVersion.V1]: {
81
- ckbfs: '0xde8eb09151fbcdcba398423159ce348cc89a38a736de3fd0960b18b084465382',
82
- adler32: '0x042f264d7397a181437b51ff9981cf536f252ab5740b61ce52ce31ada04ed54b'
103
+ ckbfs:
104
+ "0xde8eb09151fbcdcba398423159ce348cc89a38a736de3fd0960b18b084465382",
105
+ adler32:
106
+ "0x042f264d7397a181437b51ff9981cf536f252ab5740b61ce52ce31ada04ed54b",
83
107
  },
84
108
  [ProtocolVersion.V2]: {
85
- ckbfs: '0x2c8c9ad3134743368b5a79977648f96c5bd0aba187021a72fb624301064d3616',
86
- adler32: '0x2c8c9ad3134743368b5a79977648f96c5bd0aba187021a72fb624301064d3616'
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: 'data1' | 'type';
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: string = DEFAULT_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 ? 'type' : 'data1',
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
+ }