@ckb-ccc/core 0.0.6-alpha.0 → 0.0.7-alpha.1

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 (215) hide show
  1. package/dist/address/address.advanced.d.ts.map +1 -1
  2. package/dist/address/address.advanced.js +2 -5
  3. package/dist/address/index.d.ts +1 -1
  4. package/dist/address/index.d.ts.map +1 -1
  5. package/dist/address/index.js +2 -5
  6. package/dist/ckb/script.d.ts +43 -1
  7. package/dist/ckb/script.d.ts.map +1 -1
  8. package/dist/ckb/script.js +51 -0
  9. package/dist/ckb/transaction.d.ts +198 -21
  10. package/dist/ckb/transaction.d.ts.map +1 -1
  11. package/dist/ckb/transaction.js +440 -21
  12. package/dist/client/advanced.d.ts +2 -0
  13. package/dist/client/advanced.d.ts.map +1 -1
  14. package/dist/client/advanced.js +2 -0
  15. package/dist/client/client.advanced.d.ts +10 -0
  16. package/dist/client/client.advanced.d.ts.map +1 -0
  17. package/dist/client/client.advanced.js +80 -0
  18. package/dist/client/client.d.ts +44 -8
  19. package/dist/client/client.d.ts.map +1 -1
  20. package/dist/client/client.js +137 -9
  21. package/dist/client/clientPublicMainnet.advanced.d.ts +4 -2
  22. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  23. package/dist/client/clientPublicMainnet.advanced.js +102 -0
  24. package/dist/client/clientPublicMainnet.d.ts +4 -2
  25. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  26. package/dist/client/clientPublicMainnet.js +5 -1
  27. package/dist/client/clientPublicTestnet.advanced.d.ts +4 -2
  28. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  29. package/dist/client/clientPublicTestnet.advanced.js +151 -0
  30. package/dist/client/clientPublicTestnet.d.ts +4 -2
  31. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  32. package/dist/client/clientPublicTestnet.js +6 -1
  33. package/dist/client/clientTypes.advanced.d.ts +23 -0
  34. package/dist/client/clientTypes.advanced.d.ts.map +1 -0
  35. package/dist/client/clientTypes.advanced.js +4 -0
  36. package/dist/client/clientTypes.d.ts +22 -36
  37. package/dist/client/clientTypes.d.ts.map +1 -1
  38. package/dist/client/clientTypes.js +15 -12
  39. package/dist/client/jsonRpc/index.d.ts +3 -3
  40. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  41. package/dist/client/jsonRpc/index.js +3 -3
  42. package/dist/client/jsonRpc/transformers.d.ts +5 -7
  43. package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
  44. package/dist/client/jsonRpc/transformers.js +8 -6
  45. package/dist/hasher/index.d.ts +1 -1
  46. package/dist/hasher/index.d.ts.map +1 -1
  47. package/dist/hasher/index.js +4 -2
  48. package/dist/num/index.d.ts +12 -0
  49. package/dist/num/index.d.ts.map +1 -1
  50. package/dist/num/index.js +21 -0
  51. package/dist/signer/btc/signerBtc.d.ts.map +1 -1
  52. package/dist/signer/btc/signerBtc.js +2 -1
  53. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  54. package/dist/signer/evm/signerEvm.js +5 -3
  55. package/dist/signer/nostr/signerNostr.d.ts.map +1 -1
  56. package/dist/signer/nostr/signerNostr.js +2 -1
  57. package/dist/utils/index.d.ts +1 -1
  58. package/dist/utils/index.d.ts.map +1 -1
  59. package/dist/utils/index.js +1 -1
  60. package/dist.commonjs/address/address.advanced.d.ts +29 -24
  61. package/dist.commonjs/address/address.advanced.d.ts.map +1 -1
  62. package/dist.commonjs/address/address.advanced.js +115 -92
  63. package/dist.commonjs/address/advanced.d.ts +1 -1
  64. package/dist.commonjs/address/advanced.js +30 -14
  65. package/dist.commonjs/address/index.d.ts +51 -44
  66. package/dist.commonjs/address/index.d.ts.map +1 -1
  67. package/dist.commonjs/address/index.js +84 -68
  68. package/dist.commonjs/advanced.d.ts +1 -1
  69. package/dist.commonjs/advanced.js +47 -22
  70. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  71. package/dist.commonjs/advancedBarrel.js +30 -14
  72. package/dist.commonjs/barrel.d.ts +1 -1
  73. package/dist.commonjs/barrel.js +30 -14
  74. package/dist.commonjs/bytes/advanced.d.ts +11 -2
  75. package/dist.commonjs/bytes/index.d.ts +9 -3
  76. package/dist.commonjs/bytes/index.js +28 -26
  77. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  78. package/dist.commonjs/ckb/advanced.js +47 -22
  79. package/dist.commonjs/ckb/index.d.ts +1 -1
  80. package/dist.commonjs/ckb/index.js +30 -14
  81. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
  82. package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
  83. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  84. package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
  85. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  86. package/dist.commonjs/ckb/script.advanced.js +12 -9
  87. package/dist.commonjs/ckb/script.d.ts +123 -77
  88. package/dist.commonjs/ckb/script.d.ts.map +1 -1
  89. package/dist.commonjs/ckb/script.js +221 -126
  90. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  91. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  92. package/dist.commonjs/ckb/transaction.d.ts +796 -544
  93. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  94. package/dist.commonjs/ckb/transaction.js +1373 -725
  95. package/dist.commonjs/client/advanced.d.ts +3 -1
  96. package/dist.commonjs/client/advanced.d.ts.map +1 -1
  97. package/dist.commonjs/client/advanced.js +32 -14
  98. package/dist.commonjs/client/client.advanced.d.ts +27 -0
  99. package/dist.commonjs/client/client.advanced.d.ts.map +1 -0
  100. package/dist.commonjs/client/client.advanced.js +116 -0
  101. package/dist.commonjs/client/client.d.ts +118 -22
  102. package/dist.commonjs/client/client.d.ts.map +1 -1
  103. package/dist.commonjs/client/client.js +218 -56
  104. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +9 -3
  105. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  106. package/dist.commonjs/client/clientPublicMainnet.advanced.js +144 -25
  107. package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -5
  108. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  109. package/dist.commonjs/client/clientPublicMainnet.js +18 -12
  110. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +8 -3
  111. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  112. package/dist.commonjs/client/clientPublicTestnet.advanced.js +204 -28
  113. package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -5
  114. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  115. package/dist.commonjs/client/clientPublicTestnet.js +14 -9
  116. package/dist.commonjs/client/clientTypes.advanced.d.ts +23 -0
  117. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -0
  118. package/dist.commonjs/client/clientTypes.advanced.js +8 -0
  119. package/dist.commonjs/client/clientTypes.d.ts +57 -46
  120. package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
  121. package/dist.commonjs/client/clientTypes.js +60 -22
  122. package/dist.commonjs/client/index.d.ts +1 -1
  123. package/dist.commonjs/client/index.js +30 -14
  124. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  125. package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
  126. package/dist.commonjs/client/jsonRpc/index.d.ts +94 -75
  127. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  128. package/dist.commonjs/client/jsonRpc/index.js +135 -108
  129. package/dist.commonjs/client/jsonRpc/transformers.d.ts +76 -38
  130. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
  131. package/dist.commonjs/client/jsonRpc/transformers.js +174 -150
  132. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  133. package/dist.commonjs/fixedPoint/index.d.ts +9 -3
  134. package/dist.commonjs/fixedPoint/index.js +26 -20
  135. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  136. package/dist.commonjs/fixedPoint/index.test.js +42 -36
  137. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  138. package/dist.commonjs/hasher/index.d.ts +37 -37
  139. package/dist.commonjs/hasher/index.d.ts.map +1 -1
  140. package/dist.commonjs/hasher/index.js +55 -46
  141. package/dist.commonjs/hex/index.d.ts +1 -1
  142. package/dist.commonjs/hex/index.js +1 -1
  143. package/dist.commonjs/index.d.ts +1 -1
  144. package/dist.commonjs/index.js +47 -22
  145. package/dist.commonjs/num/index.d.ts +13 -1
  146. package/dist.commonjs/num/index.d.ts.map +1 -1
  147. package/dist.commonjs/num/index.js +53 -19
  148. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  149. package/dist.commonjs/signer/btc/index.js +30 -14
  150. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  151. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  152. package/dist.commonjs/signer/btc/signerBtc.js +89 -65
  153. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -45
  154. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -52
  155. package/dist.commonjs/signer/btc/verify.d.ts +6 -2
  156. package/dist.commonjs/signer/btc/verify.js +10 -3
  157. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  158. package/dist.commonjs/signer/ckb/index.js +30 -14
  159. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -45
  160. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -56
  161. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -2
  162. package/dist.commonjs/signer/ckb/verifyJoyId.js +11 -8
  163. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -4
  164. package/dist.commonjs/signer/dummy/alwaysError.js +7 -7
  165. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  166. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  167. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  168. package/dist.commonjs/signer/dummy/index.js +30 -14
  169. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -4
  170. package/dist.commonjs/signer/dummy/openLink.js +7 -7
  171. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  172. package/dist.commonjs/signer/evm/index.js +30 -14
  173. package/dist.commonjs/signer/evm/signerEvm.d.ts +42 -38
  174. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  175. package/dist.commonjs/signer/evm/signerEvm.js +105 -68
  176. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -37
  177. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -42
  178. package/dist.commonjs/signer/evm/verify.d.ts +6 -2
  179. package/dist.commonjs/signer/evm/verify.js +7 -2
  180. package/dist.commonjs/signer/index.d.ts +1 -1
  181. package/dist.commonjs/signer/index.js +30 -14
  182. package/dist.commonjs/signer/nostr/index.d.ts +1 -1
  183. package/dist.commonjs/signer/nostr/index.js +30 -14
  184. package/dist.commonjs/signer/nostr/signerNostr.d.ts +57 -57
  185. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -1
  186. package/dist.commonjs/signer/nostr/signerNostr.js +100 -70
  187. package/dist.commonjs/signer/nostr/verify.d.ts +9 -3
  188. package/dist.commonjs/signer/nostr/verify.js +50 -39
  189. package/dist.commonjs/signer/signer/index.d.ts +156 -150
  190. package/dist.commonjs/signer/signer/index.js +208 -181
  191. package/dist.commonjs/utils/index.d.ts +38 -8
  192. package/dist.commonjs/utils/index.d.ts.map +1 -1
  193. package/dist.commonjs/utils/index.js +18 -12
  194. package/package.json +2 -2
  195. package/src/address/address.advanced.ts +2 -5
  196. package/src/address/index.ts +2 -5
  197. package/src/ckb/script.ts +62 -2
  198. package/src/ckb/transaction.ts +637 -46
  199. package/src/client/advanced.ts +2 -0
  200. package/src/client/client.advanced.ts +134 -0
  201. package/src/client/client.ts +225 -16
  202. package/src/client/clientPublicMainnet.advanced.ts +116 -2
  203. package/src/client/clientPublicMainnet.ts +8 -3
  204. package/src/client/clientPublicTestnet.advanced.ts +171 -2
  205. package/src/client/clientPublicTestnet.ts +9 -3
  206. package/src/client/clientTypes.advanced.ts +26 -0
  207. package/src/client/clientTypes.ts +41 -43
  208. package/src/client/jsonRpc/index.ts +4 -4
  209. package/src/client/jsonRpc/transformers.ts +13 -11
  210. package/src/hasher/index.ts +4 -2
  211. package/src/num/index.ts +22 -0
  212. package/src/signer/btc/signerBtc.ts +2 -1
  213. package/src/signer/evm/signerEvm.ts +5 -3
  214. package/src/signer/nostr/signerNostr.ts +2 -1
  215. package/src/utils/index.ts +6 -2
@@ -1,43 +1,212 @@
1
1
  import { Script } from "../ckb";
2
- import { KnownScript } from "./client";
2
+ import { CellDepInfoLike, KnownScript } from "./client";
3
3
 
4
4
  export const TESTNET_SCRIPTS: Record<
5
5
  KnownScript,
6
- Pick<Script, "codeHash" | "hashType">
6
+ Pick<Script, "codeHash" | "hashType"> & { cellDeps: CellDepInfoLike[] }
7
7
  > = {
8
8
  [KnownScript.Secp256k1Blake160]: {
9
9
  codeHash:
10
10
  "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8",
11
11
  hashType: "type",
12
+ cellDeps: [
13
+ {
14
+ cellDep: {
15
+ outPoint: {
16
+ txHash:
17
+ "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
18
+ index: 0,
19
+ },
20
+ depType: "depGroup",
21
+ },
22
+ },
23
+ ],
12
24
  },
13
25
  [KnownScript.Secp256k1Multisig]: {
14
26
  codeHash:
15
27
  "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
16
28
  hashType: "type",
29
+ cellDeps: [
30
+ {
31
+ cellDep: {
32
+ outPoint: {
33
+ txHash:
34
+ "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
35
+ index: 1,
36
+ },
37
+ depType: "depGroup",
38
+ },
39
+ },
40
+ ],
17
41
  },
18
42
  [KnownScript.AnyoneCanPay]: {
19
43
  codeHash:
20
44
  "0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356",
21
45
  hashType: "type",
46
+ cellDeps: [
47
+ {
48
+ cellDep: {
49
+ outPoint: {
50
+ txHash:
51
+ "0xec26b0f85ed839ece5f11c4c4e837ec359f5adc4420410f6453b1f6b60fb96a6",
52
+ index: 0,
53
+ },
54
+ depType: "depGroup",
55
+ },
56
+ },
57
+ ],
58
+ },
59
+ [KnownScript.TypeId]: {
60
+ codeHash:
61
+ "0x00000000000000000000000000000000000000000000000000545950455f4944",
62
+ hashType: "type",
63
+ cellDeps: [],
64
+ },
65
+ [KnownScript.XUdt]: {
66
+ codeHash:
67
+ "0x25c29dc317811a6f6f3985a7a9ebc4838bd388d19d0feeecf0bcd60f6c0975bb",
68
+ hashType: "type",
69
+ cellDeps: [
70
+ {
71
+ cellDep: {
72
+ outPoint: {
73
+ txHash:
74
+ "0xbf6fb538763efec2a70a6a3dcb7242787087e1030c4e7d86585bc63a9d337f5f",
75
+ index: 0,
76
+ },
77
+ depType: "code",
78
+ },
79
+ type: {
80
+ codeHash:
81
+ "0x00000000000000000000000000000000000000000000000000545950455f4944",
82
+ hashType: "type",
83
+ args: "0x44ec8b96663e06cc94c8c468a4d46d7d9af69eaf418f6390c9f11bb763dda0ae",
84
+ },
85
+ },
86
+ ],
22
87
  },
23
88
  [KnownScript.JoyId]: {
24
89
  codeHash:
25
90
  "0xd23761b364210735c19c60561d213fb3beae2fd6172743719eff6920e020baac",
26
91
  hashType: "type",
92
+ cellDeps: [
93
+ {
94
+ cellDep: {
95
+ outPoint: {
96
+ txHash:
97
+ "0x4dcf3f3b09efac8995d6cbee87c5345e812d310094651e0c3d9a730f32dc9263",
98
+ index: 0,
99
+ },
100
+ depType: "depGroup",
101
+ },
102
+ },
103
+ ],
27
104
  },
28
105
  [KnownScript.COTA]: {
29
106
  codeHash:
30
107
  "0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8",
31
108
  hashType: "type",
109
+ cellDeps: [
110
+ {
111
+ cellDep: {
112
+ outPoint: {
113
+ txHash:
114
+ "0x636a786001f87cb615acfcf408be0f9a1f077001f0bbc75ca54eadfe7e221713",
115
+ index: 0,
116
+ },
117
+ depType: "depGroup",
118
+ },
119
+ },
120
+ ],
32
121
  },
33
122
  [KnownScript.OmniLock]: {
34
123
  codeHash:
35
124
  "0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb",
36
125
  hashType: "type",
126
+ cellDeps: [
127
+ {
128
+ cellDep: {
129
+ outPoint: {
130
+ txHash:
131
+ "0xf8de3bb47d055cdf460d93a2a6e1b05f7432f9777c8c474abf4eec1d4aee5d37",
132
+ index: 0,
133
+ },
134
+ depType: "depGroup",
135
+ },
136
+ },
137
+ {
138
+ cellDep: {
139
+ outPoint: {
140
+ txHash:
141
+ "0xec18bf0d857c981c3d1f4e17999b9b90c484b303378e94de1a57b0872f5d4602",
142
+ index: 0,
143
+ },
144
+ depType: "code",
145
+ },
146
+ type: {
147
+ codeHash:
148
+ "0x00000000000000000000000000000000000000000000000000545950455f4944",
149
+ hashType: "type",
150
+ args: "0x761f51fc9cd6a504c32c6ae64b3746594d1af27629b427c5ccf6c9a725a89144",
151
+ },
152
+ },
153
+ ],
37
154
  },
38
155
  [KnownScript.NostrLock]: {
39
156
  codeHash:
40
157
  "0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5",
41
158
  hashType: "type",
159
+ cellDeps: [
160
+ {
161
+ cellDep: {
162
+ outPoint: {
163
+ txHash:
164
+ "0xa2a434dcdbe280b9ed75bb7d6c7d68186a842456aba0fc506657dc5ed7c01d68",
165
+ index: 0,
166
+ },
167
+ depType: "code",
168
+ },
169
+ type: {
170
+ codeHash:
171
+ "0x00000000000000000000000000000000000000000000000000545950455f4944",
172
+ hashType: "type",
173
+ args: "0x8dc56c6f35f0c535e23ded1629b1f20535477a1b43e59f14617d11e32c50e0aa",
174
+ },
175
+ },
176
+ ],
177
+ },
178
+ [KnownScript.SingleUseLock]: {
179
+ codeHash:
180
+ "0x8290467a512e5b9a6b816469b0edabba1f4ac474e28ffdd604c2a7c76446bbaf",
181
+ hashType: "data1",
182
+ cellDeps: [
183
+ {
184
+ cellDep: {
185
+ outPoint: {
186
+ txHash:
187
+ "0x968c326f7a418f07a128f30d9a415251beaa2ec8bd6bbfda65780c94bebb2a85",
188
+ index: 4,
189
+ },
190
+ depType: "code",
191
+ },
192
+ },
193
+ ],
194
+ },
195
+ [KnownScript.OutputTypeProxyLock]: {
196
+ codeHash:
197
+ "0xc0382e4109cff68a4f536441c0266d2e22f2808e61573129c9289ee0e5e5ed43",
198
+ hashType: "data1",
199
+ cellDeps: [
200
+ {
201
+ cellDep: {
202
+ outPoint: {
203
+ txHash:
204
+ "0x968c326f7a418f07a128f30d9a415251beaa2ec8bd6bbfda65780c94bebb2a85",
205
+ index: 2,
206
+ },
207
+ depType: "code",
208
+ },
209
+ },
210
+ ],
42
211
  },
43
212
  };
@@ -1,5 +1,5 @@
1
1
  import { Script } from "../ckb";
2
- import { KnownScript } from "./client";
2
+ import { CellDepInfo, KnownScript } from "./client";
3
3
  import { TESTNET_SCRIPTS } from "./clientPublicTestnet.advanced";
4
4
  import { ClientJsonRpc } from "./jsonRpc";
5
5
 
@@ -14,7 +14,13 @@ export class ClientPublicTestnet extends ClientJsonRpc {
14
14
 
15
15
  async getKnownScript(
16
16
  script: KnownScript,
17
- ): Promise<Pick<Script, "codeHash" | "hashType">> {
18
- return { ...TESTNET_SCRIPTS[script] };
17
+ ): Promise<
18
+ Pick<Script, "codeHash" | "hashType"> & { cellDeps: CellDepInfo[] }
19
+ > {
20
+ const found = TESTNET_SCRIPTS[script];
21
+ return {
22
+ ...found,
23
+ cellDeps: found.cellDeps.map((c) => CellDepInfo.from(c)),
24
+ };
19
25
  }
20
26
  }
@@ -0,0 +1,26 @@
1
+ import { ScriptLike } from "../ckb";
2
+ import { HexLike } from "../hex";
3
+ import { Num, numFrom, NumLike } from "../num";
4
+
5
+ export function clientSearchKeyRangeFrom([a, b]: [NumLike, NumLike]): [
6
+ Num,
7
+ Num,
8
+ ] {
9
+ return [numFrom(a), numFrom(b)];
10
+ }
11
+
12
+ export type ClientCollectableSearchKeyFilterLike = {
13
+ script?: ScriptLike;
14
+ scriptLenRange?: [NumLike, NumLike];
15
+ outputData?: HexLike;
16
+ outputDataSearchMode?: "prefix" | "exact" | "partial";
17
+ outputDataLenRange?: [NumLike, NumLike];
18
+ outputCapacityRange?: [NumLike, NumLike];
19
+ };
20
+ export type ClientCollectableSearchKeyLike = {
21
+ script: ScriptLike;
22
+ scriptType: "lock" | "type";
23
+ scriptSearchMode: "prefix" | "exact" | "partial";
24
+ filter?: ClientCollectableSearchKeyFilterLike;
25
+ withData?: boolean;
26
+ };
@@ -1,7 +1,12 @@
1
- import { Cell, Script, ScriptLike, Transaction } from "../ckb";
2
- import { Hex, HexLike, hexFrom } from "../hex";
3
- import { Num, NumLike, numFrom } from "../num";
1
+ import { Cell, Script, Transaction } from "../ckb";
2
+ import { Hex, hexFrom } from "../hex";
3
+ import { Num, NumLike } from "../num";
4
4
  import { apply } from "../utils";
5
+ import {
6
+ ClientCollectableSearchKeyFilterLike,
7
+ ClientCollectableSearchKeyLike,
8
+ clientSearchKeyRangeFrom,
9
+ } from "./clientTypes.advanced";
5
10
 
6
11
  export type OutputsValidator = "passthrough" | "well_known_scripts_only";
7
12
 
@@ -14,44 +19,48 @@ export type TransactionStatus =
14
19
  export type ClientTransactionResponse = {
15
20
  transaction: Transaction;
16
21
  status: TransactionStatus;
17
- blockNumber: Num;
18
22
  };
19
23
 
20
- export type ClientIndexerSearchKeyLike = {
21
- script: ScriptLike;
22
- scriptType: "lock" | "type";
23
- scriptSearchMode?: "prefix" | "exact" | "partial";
24
- filter?: {
25
- script?: ScriptLike;
26
- scriptLenRange?: [NumLike, NumLike];
27
- outputData?: HexLike;
28
- outputDataSearchMode?: "prefix" | "exact" | "partial";
29
- outputDataLenRange?: [NumLike, NumLike];
30
- outputCapacityRange?: [NumLike, NumLike];
24
+ export type ClientIndexerSearchKeyFilterLike =
25
+ ClientCollectableSearchKeyFilterLike & {
31
26
  blockRange?: [NumLike, NumLike];
32
27
  };
33
- withData?: boolean;
34
- };
28
+ export class ClientIndexerSearchKeyFilter {
29
+ constructor(
30
+ public script: Script | undefined,
31
+ public scriptLenRange: [Num, Num] | undefined,
32
+ public outputData: Hex | undefined,
33
+ public outputDataSearchMode: "prefix" | "exact" | "partial" | undefined,
34
+ public outputDataLenRange: [Num, Num] | undefined,
35
+ public outputCapacityRange: [Num, Num] | undefined,
36
+ public blockRange: [Num, Num] | undefined,
37
+ ) {}
35
38
 
36
- function rangeFrom([a, b]: [NumLike, NumLike]): [Num, Num] {
37
- return [numFrom(a), numFrom(b)];
39
+ static from(
40
+ filterLike: ClientIndexerSearchKeyFilterLike,
41
+ ): ClientIndexerSearchKeyFilter {
42
+ return new ClientIndexerSearchKeyFilter(
43
+ apply(Script.from, filterLike.script),
44
+ apply(clientSearchKeyRangeFrom, filterLike.scriptLenRange),
45
+ apply(hexFrom, filterLike.outputData),
46
+ filterLike.outputDataSearchMode,
47
+ apply(clientSearchKeyRangeFrom, filterLike.outputDataLenRange),
48
+ apply(clientSearchKeyRangeFrom, filterLike.outputCapacityRange),
49
+ apply(clientSearchKeyRangeFrom, filterLike.blockRange),
50
+ );
51
+ }
38
52
  }
53
+
54
+ export type ClientIndexerSearchKeyLike = ClientCollectableSearchKeyLike & {
55
+ filter?: ClientIndexerSearchKeyFilterLike;
56
+ };
57
+
39
58
  export class ClientIndexerSearchKey {
40
59
  constructor(
41
60
  public script: Script,
42
61
  public scriptType: "lock" | "type",
43
- public scriptSearchMode: "prefix" | "exact" | "partial" | undefined,
44
- public filter:
45
- | {
46
- script?: Script;
47
- scriptLenRange?: [Num, Num];
48
- outputData?: Hex;
49
- outputDataSearchMode?: "prefix" | "exact" | "partial";
50
- outputDataLenRange?: [Num, Num];
51
- outputCapacityRange?: [Num, Num];
52
- blockRange?: [Num, Num];
53
- }
54
- | undefined,
62
+ public scriptSearchMode: "prefix" | "exact" | "partial",
63
+ public filter: ClientIndexerSearchKeyFilter | undefined,
55
64
  public withData: boolean | undefined,
56
65
  ) {}
57
66
 
@@ -60,18 +69,7 @@ export class ClientIndexerSearchKey {
60
69
  Script.from(keyLike.script),
61
70
  keyLike.scriptType,
62
71
  keyLike.scriptSearchMode,
63
- apply(
64
- (filter: NonNullable<ClientIndexerSearchKeyLike["filter"]>) => ({
65
- script: apply(Script.from, filter.script),
66
- scriptLenRange: apply(rangeFrom, filter.scriptLenRange),
67
- outputData: apply(hexFrom, filter.outputData),
68
- outputDataSearchMode: filter.outputDataSearchMode,
69
- outputDataLenRange: apply(rangeFrom, filter.outputDataLenRange),
70
- outputCapacityRange: apply(rangeFrom, filter.outputCapacityRange),
71
- blockRange: apply(rangeFrom, filter.blockRange),
72
- }),
73
- keyLike.filter,
74
- ),
72
+ apply(ClientIndexerSearchKeyFilter.from, keyLike.filter),
75
73
  keyLike.withData,
76
74
  );
77
75
  }
@@ -73,7 +73,7 @@ export abstract class ClientJsonRpc extends Client {
73
73
  * @returns Transaction hash.
74
74
  */
75
75
 
76
- sendTransaction = this.buildSender(
76
+ sendTransactionNoCache = this.buildSender(
77
77
  "send_transaction",
78
78
  [JsonRpcTransformers.transactionFrom],
79
79
  hexFrom,
@@ -89,11 +89,11 @@ export abstract class ClientJsonRpc extends Client {
89
89
  * @returns The transaction with status.
90
90
  */
91
91
 
92
- getTransaction = this.buildSender(
92
+ getTransactionNoCache = this.buildSender(
93
93
  "get_transaction",
94
94
  [hexFrom],
95
95
  JsonRpcTransformers.transactionResponseTo,
96
- ) as (txHash: HexLike) => Promise<ClientTransactionResponse>;
96
+ ) as (txHash: HexLike) => Promise<ClientTransactionResponse | null>;
97
97
 
98
98
  /**
99
99
  * find cells from node.
@@ -105,7 +105,7 @@ export abstract class ClientJsonRpc extends Client {
105
105
  * @returns The found cells.
106
106
  */
107
107
 
108
- findCellsPaged = this.buildSender(
108
+ findCellsPagedNoCache = this.buildSender(
109
109
  "get_cells",
110
110
  [
111
111
  JsonRpcTransformers.indexerSearchKeyFrom,
@@ -20,7 +20,7 @@ import {
20
20
  hashTypeFrom,
21
21
  } from "../../ckb";
22
22
  import { Hex } from "../../hex";
23
- import { NumLike, numFrom, numToHex } from "../../num";
23
+ import { NumLike, numToHex } from "../../num";
24
24
  import { apply } from "../../utils";
25
25
  import {
26
26
  ClientFindCellsResponse,
@@ -92,7 +92,8 @@ export class JsonRpcTransformers {
92
92
  txHash: outPoint.tx_hash,
93
93
  });
94
94
  }
95
- static cellInputFrom(cellInput: CellInputLike): JsonRpcCellInput {
95
+ static cellInputFrom(cellInputLike: CellInputLike): JsonRpcCellInput {
96
+ const cellInput = CellInput.from(cellInputLike);
96
97
  return {
97
98
  previous_output: JsonRpcTransformers.outPointFrom(
98
99
  cellInput.previousOutput,
@@ -156,16 +157,19 @@ export class JsonRpcTransformers {
156
157
  });
157
158
  }
158
159
  static transactionResponseTo({
159
- tx_status: { status, block_number },
160
+ tx_status: { status },
160
161
  transaction,
161
162
  }: {
162
- tx_status: { status: TransactionStatus; block_number: Hex };
163
- transaction: JsonRpcTransaction;
164
- }): ClientTransactionResponse {
163
+ tx_status: { status: TransactionStatus };
164
+ transaction: JsonRpcTransaction | null;
165
+ }): ClientTransactionResponse | null {
166
+ if (transaction == null) {
167
+ return null;
168
+ }
169
+
165
170
  return {
166
171
  transaction: JsonRpcTransformers.transactionTo(transaction),
167
172
  status,
168
- blockNumber: numFrom(block_number),
169
173
  };
170
174
  }
171
175
  static rangeFrom([a, b]: [NumLike, NumLike]): [Hex, Hex] {
@@ -209,20 +213,18 @@ export class JsonRpcTransformers {
209
213
  }: {
210
214
  last_cursor: string;
211
215
  objects: {
212
- block_number: Hex;
213
216
  out_point: JsonRpcOutPoint;
214
217
  output: JsonRpcCellOutput;
215
- output_data: Hex;
218
+ output_data?: Hex;
216
219
  }[];
217
220
  }): ClientFindCellsResponse {
218
221
  return {
219
222
  lastCursor: last_cursor,
220
223
  cells: objects.map((cell) =>
221
224
  Cell.from({
222
- blockNumber: cell.block_number,
223
225
  outPoint: JsonRpcTransformers.outPointTo(cell.out_point),
224
226
  cellOutput: JsonRpcTransformers.cellOutputTo(cell.output),
225
- outputData: cell.output_data,
227
+ outputData: cell.output_data ?? "0x",
226
228
  }),
227
229
  ),
228
230
  };
@@ -71,6 +71,8 @@ export class Hasher {
71
71
  * ```
72
72
  */
73
73
 
74
- export function ckbHash(data: BytesLike): Hex {
75
- return new Hasher().update(data).digest();
74
+ export function ckbHash(...data: BytesLike[]): Hex {
75
+ const hasher = new Hasher();
76
+ data.forEach((d) => hasher.update(d));
77
+ return hasher.digest();
76
78
  }
package/src/num/index.ts CHANGED
@@ -12,6 +12,28 @@ export type Num = bigint;
12
12
  */
13
13
  export type NumLike = string | number | bigint | HexLike;
14
14
 
15
+ /**
16
+ * Get the max among all numbers.
17
+ *
18
+ * @param numbers - numbers.
19
+ * @returns The max numbers among them.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * numMax(1, 2, 3); // Outputs 3n
24
+ * ```
25
+ */
26
+ export function numMax(a: NumLike, ...numbers: NumLike[]): Num {
27
+ let max = numFrom(a);
28
+ numbers.forEach((nLike) => {
29
+ const n = numFrom(nLike);
30
+ if (n > max) {
31
+ max = n;
32
+ }
33
+ });
34
+ return max;
35
+ }
36
+
15
37
  /**
16
38
  * Converts a NumLike value to a Num (bigint).
17
39
  *
@@ -65,9 +65,9 @@ export abstract class SignerBtc extends Signer {
65
65
 
66
66
  return [
67
67
  await Address.fromKnownScript(
68
+ this.client,
68
69
  KnownScript.OmniLock,
69
70
  hexFrom([0x04, ...hash, 0x00]),
70
- this.client,
71
71
  ),
72
72
  ];
73
73
  }
@@ -81,6 +81,7 @@ export abstract class SignerBtc extends Signer {
81
81
  async prepareTransaction(txLike: TransactionLike): Promise<Transaction> {
82
82
  const tx = Transaction.from(txLike);
83
83
  const { script } = await this.getRecommendedAddressObj();
84
+ await tx.addCellDepsOfKnownScripts(this.client, KnownScript.OmniLock);
84
85
  await tx.prepareSighashAllWitness(script, 85, this.client);
85
86
  return tx;
86
87
  }
@@ -51,17 +51,17 @@ export abstract class SignerEvm extends Signer {
51
51
 
52
52
  async _getOmniLockEvmAddressObj(account: string): Promise<Address> {
53
53
  return Address.fromKnownScript(
54
+ this.client,
54
55
  KnownScript.OmniLock,
55
56
  hexFrom([0x12, ...bytesFrom(account), 0x00]),
56
- this.client,
57
57
  );
58
58
  }
59
59
 
60
60
  async _getOmniLockOldEvmAddressObj(account: string): Promise<Address> {
61
61
  return Address.fromKnownScript(
62
+ this.client,
62
63
  KnownScript.OmniLock,
63
64
  hexFrom([0x1, ...bytesFrom(account), 0x00]),
64
- this.client,
65
65
  );
66
66
  }
67
67
 
@@ -72,11 +72,13 @@ export abstract class SignerEvm extends Signer {
72
72
  * @returns A promise that resolves to the prepared Transaction object.
73
73
  */
74
74
  async prepareTransaction(txLike: TransactionLike): Promise<Transaction> {
75
+ const tx = Transaction.from(txLike);
76
+ await tx.addCellDepsOfKnownScripts(this.client, KnownScript.OmniLock);
75
77
  return reduceAsync(
76
78
  await this.getAddressObjs(),
77
79
  (tx: Transaction, { script }) =>
78
80
  tx.prepareSighashAllWitness(script, 85, this.client),
79
- Transaction.from(txLike),
81
+ tx,
80
82
  );
81
83
  }
82
84
 
@@ -78,9 +78,9 @@ export abstract class SignerNostr extends Signer {
78
78
  const publicKey = await this.getNostrPublicKey();
79
79
  return [
80
80
  await Address.fromKnownScript(
81
+ this.client,
81
82
  KnownScript.NostrLock,
82
83
  hexFrom(bytesConcat([0x00], ckbHash(publicKey).slice(0, 42))),
83
- this.client,
84
84
  ),
85
85
  ];
86
86
  }
@@ -94,6 +94,7 @@ export abstract class SignerNostr extends Signer {
94
94
  async prepareTransaction(txLike: TransactionLike): Promise<Transaction> {
95
95
  const tx = Transaction.from(txLike);
96
96
  const { script } = await this.getRecommendedAddressObj();
97
+ await tx.addCellDepsOfKnownScripts(this.client, KnownScript.NostrLock);
97
98
  await tx.prepareSighashAllWitness(script, 572, this.client);
98
99
  return tx;
99
100
  }
@@ -103,6 +103,8 @@ export async function reduceAsync<T, V>(
103
103
  accumulator: (
104
104
  a: T,
105
105
  b: V,
106
+ i: number,
107
+ values: V[],
106
108
  ) => Promise<T | undefined | null | void> | T | undefined | null | void,
107
109
  init: T,
108
110
  ): Promise<T>;
@@ -111,6 +113,8 @@ export async function reduceAsync<T, V>(
111
113
  accumulator: (
112
114
  a: T,
113
115
  b: T | V,
116
+ i: number,
117
+ values: (V | T)[],
114
118
  ) => Promise<T | undefined | null | void> | T | undefined | null | void,
115
119
  init?: T,
116
120
  ): Promise<T> {
@@ -123,9 +127,9 @@ export async function reduceAsync<T, V>(
123
127
  }
124
128
 
125
129
  return values.reduce(
126
- (current: Promise<T>, b: T | V) =>
130
+ (current: Promise<T>, b: T | V, i, array) =>
127
131
  current.then((v) =>
128
- Promise.resolve(accumulator(v, b)).then((r) => r ?? v),
132
+ Promise.resolve(accumulator(v, b, i, array)).then((r) => r ?? v),
129
133
  ),
130
134
  Promise.resolve(init),
131
135
  );