@ckb-ccc/core 0.0.5-alpha.8 → 0.0.7-alpha.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 (265) 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 +215 -27
  10. package/dist/ckb/transaction.d.ts.map +1 -1
  11. package/dist/ckb/transaction.js +472 -32
  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 +50 -13
  19. package/dist/client/client.d.ts.map +1 -1
  20. package/dist/client/client.js +145 -15
  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 +103 -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 +9 -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 +155 -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 +6 -3
  53. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
  54. package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  55. package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
  56. package/dist/signer/btc/verify.d.ts.map +1 -1
  57. package/dist/signer/btc/verify.js +5 -2
  58. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +0 -6
  59. package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  60. package/dist/signer/ckb/signerCkbScriptReadonly.js +0 -8
  61. package/dist/signer/dummy/alwaysError.d.ts +0 -1
  62. package/dist/signer/dummy/alwaysError.d.ts.map +1 -1
  63. package/dist/signer/dummy/alwaysError.js +0 -3
  64. package/dist/signer/dummy/openLink.d.ts +0 -1
  65. package/dist/signer/dummy/openLink.d.ts.map +1 -1
  66. package/dist/signer/dummy/openLink.js +0 -3
  67. package/dist/signer/evm/signerEvm.d.ts.map +1 -1
  68. package/dist/signer/evm/signerEvm.js +7 -5
  69. package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
  70. package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  71. package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
  72. package/dist/signer/index.d.ts +1 -0
  73. package/dist/signer/index.d.ts.map +1 -1
  74. package/dist/signer/index.js +1 -0
  75. package/dist/signer/nostr/index.d.ts +2 -0
  76. package/dist/signer/nostr/index.d.ts.map +1 -0
  77. package/dist/signer/nostr/index.js +1 -0
  78. package/dist/signer/nostr/signerNostr.d.ts +66 -0
  79. package/dist/signer/nostr/signerNostr.d.ts.map +1 -0
  80. package/dist/signer/nostr/signerNostr.js +85 -0
  81. package/dist/signer/nostr/verify.d.ts +5 -0
  82. package/dist/signer/nostr/verify.d.ts.map +1 -0
  83. package/dist/signer/nostr/verify.js +48 -0
  84. package/dist/signer/signer/index.d.ts +7 -12
  85. package/dist/signer/signer/index.d.ts.map +1 -1
  86. package/dist/signer/signer/index.js +11 -4
  87. package/dist/utils/index.d.ts +59 -0
  88. package/dist/utils/index.d.ts.map +1 -1
  89. package/dist/utils/index.js +17 -0
  90. package/dist.commonjs/address/address.advanced.d.ts +29 -24
  91. package/dist.commonjs/address/address.advanced.d.ts.map +1 -1
  92. package/dist.commonjs/address/address.advanced.js +115 -92
  93. package/dist.commonjs/address/advanced.d.ts +1 -1
  94. package/dist.commonjs/address/advanced.js +30 -14
  95. package/dist.commonjs/address/index.d.ts +51 -44
  96. package/dist.commonjs/address/index.d.ts.map +1 -1
  97. package/dist.commonjs/address/index.js +84 -68
  98. package/dist.commonjs/advanced.d.ts +1 -1
  99. package/dist.commonjs/advanced.js +47 -22
  100. package/dist.commonjs/advancedBarrel.d.ts +1 -1
  101. package/dist.commonjs/advancedBarrel.js +30 -14
  102. package/dist.commonjs/barrel.d.ts +1 -1
  103. package/dist.commonjs/barrel.js +30 -14
  104. package/dist.commonjs/bytes/advanced.d.ts +11 -2
  105. package/dist.commonjs/bytes/index.d.ts +9 -3
  106. package/dist.commonjs/bytes/index.js +28 -26
  107. package/dist.commonjs/ckb/advanced.d.ts +1 -1
  108. package/dist.commonjs/ckb/advanced.js +47 -22
  109. package/dist.commonjs/ckb/index.d.ts +1 -1
  110. package/dist.commonjs/ckb/index.js +30 -14
  111. package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
  112. package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
  113. package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
  114. package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
  115. package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
  116. package/dist.commonjs/ckb/script.advanced.js +12 -9
  117. package/dist.commonjs/ckb/script.d.ts +123 -77
  118. package/dist.commonjs/ckb/script.d.ts.map +1 -1
  119. package/dist.commonjs/ckb/script.js +221 -126
  120. package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
  121. package/dist.commonjs/ckb/transaction.advanced.js +4 -4
  122. package/dist.commonjs/ckb/transaction.d.ts +796 -533
  123. package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
  124. package/dist.commonjs/ckb/transaction.js +1372 -702
  125. package/dist.commonjs/client/advanced.d.ts +3 -1
  126. package/dist.commonjs/client/advanced.d.ts.map +1 -1
  127. package/dist.commonjs/client/advanced.js +32 -14
  128. package/dist.commonjs/client/client.advanced.d.ts +27 -0
  129. package/dist.commonjs/client/client.advanced.d.ts.map +1 -0
  130. package/dist.commonjs/client/client.advanced.js +116 -0
  131. package/dist.commonjs/client/client.d.ts +118 -21
  132. package/dist.commonjs/client/client.d.ts.map +1 -1
  133. package/dist.commonjs/client/client.js +219 -55
  134. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +9 -3
  135. package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  136. package/dist.commonjs/client/clientPublicMainnet.advanced.js +144 -24
  137. package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -5
  138. package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
  139. package/dist.commonjs/client/clientPublicMainnet.js +18 -8
  140. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +8 -3
  141. package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  142. package/dist.commonjs/client/clientPublicTestnet.advanced.js +204 -24
  143. package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -5
  144. package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
  145. package/dist.commonjs/client/clientPublicTestnet.js +14 -9
  146. package/dist.commonjs/client/clientTypes.advanced.d.ts +23 -0
  147. package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -0
  148. package/dist.commonjs/client/clientTypes.advanced.js +8 -0
  149. package/dist.commonjs/client/clientTypes.d.ts +57 -46
  150. package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
  151. package/dist.commonjs/client/clientTypes.js +60 -22
  152. package/dist.commonjs/client/index.d.ts +1 -1
  153. package/dist.commonjs/client/index.js +30 -14
  154. package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
  155. package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
  156. package/dist.commonjs/client/jsonRpc/index.d.ts +94 -75
  157. package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
  158. package/dist.commonjs/client/jsonRpc/index.js +135 -108
  159. package/dist.commonjs/client/jsonRpc/transformers.d.ts +76 -38
  160. package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
  161. package/dist.commonjs/client/jsonRpc/transformers.js +174 -150
  162. package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
  163. package/dist.commonjs/fixedPoint/index.d.ts +9 -3
  164. package/dist.commonjs/fixedPoint/index.js +26 -20
  165. package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
  166. package/dist.commonjs/fixedPoint/index.test.js +42 -36
  167. package/dist.commonjs/hasher/advanced.d.ts +1 -1
  168. package/dist.commonjs/hasher/index.d.ts +37 -37
  169. package/dist.commonjs/hasher/index.d.ts.map +1 -1
  170. package/dist.commonjs/hasher/index.js +55 -46
  171. package/dist.commonjs/hex/index.d.ts +1 -1
  172. package/dist.commonjs/hex/index.js +1 -1
  173. package/dist.commonjs/index.d.ts +1 -1
  174. package/dist.commonjs/index.js +47 -22
  175. package/dist.commonjs/num/index.d.ts +13 -1
  176. package/dist.commonjs/num/index.d.ts.map +1 -1
  177. package/dist.commonjs/num/index.js +53 -19
  178. package/dist.commonjs/signer/btc/index.d.ts +1 -1
  179. package/dist.commonjs/signer/btc/index.js +30 -14
  180. package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
  181. package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
  182. package/dist.commonjs/signer/btc/signerBtc.js +89 -63
  183. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
  184. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
  185. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
  186. package/dist.commonjs/signer/btc/verify.d.ts +6 -2
  187. package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
  188. package/dist.commonjs/signer/btc/verify.js +13 -3
  189. package/dist.commonjs/signer/ckb/index.d.ts +1 -1
  190. package/dist.commonjs/signer/ckb/index.js +30 -14
  191. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -51
  192. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
  193. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -64
  194. package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -2
  195. package/dist.commonjs/signer/ckb/verifyJoyId.js +11 -8
  196. package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -5
  197. package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -1
  198. package/dist.commonjs/signer/dummy/alwaysError.js +7 -10
  199. package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
  200. package/dist.commonjs/signer/dummy/dummy.js +16 -16
  201. package/dist.commonjs/signer/dummy/index.d.ts +1 -1
  202. package/dist.commonjs/signer/dummy/index.js +30 -14
  203. package/dist.commonjs/signer/dummy/openLink.d.ts +4 -5
  204. package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -1
  205. package/dist.commonjs/signer/dummy/openLink.js +7 -10
  206. package/dist.commonjs/signer/evm/index.d.ts +1 -1
  207. package/dist.commonjs/signer/evm/index.js +30 -14
  208. package/dist.commonjs/signer/evm/signerEvm.d.ts +42 -38
  209. package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
  210. package/dist.commonjs/signer/evm/signerEvm.js +106 -69
  211. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
  212. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
  213. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
  214. package/dist.commonjs/signer/evm/verify.d.ts +6 -2
  215. package/dist.commonjs/signer/evm/verify.js +7 -2
  216. package/dist.commonjs/signer/index.d.ts +2 -1
  217. package/dist.commonjs/signer/index.d.ts.map +1 -1
  218. package/dist.commonjs/signer/index.js +31 -14
  219. package/dist.commonjs/signer/nostr/index.d.ts +2 -0
  220. package/dist.commonjs/signer/nostr/index.d.ts.map +1 -0
  221. package/dist.commonjs/signer/nostr/index.js +33 -0
  222. package/dist.commonjs/signer/nostr/signerNostr.d.ts +66 -0
  223. package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -0
  224. package/dist.commonjs/signer/nostr/signerNostr.js +118 -0
  225. package/dist.commonjs/signer/nostr/verify.d.ts +11 -0
  226. package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -0
  227. package/dist.commonjs/signer/nostr/verify.js +64 -0
  228. package/dist.commonjs/signer/signer/index.d.ts +156 -155
  229. package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
  230. package/dist.commonjs/signer/signer/index.js +209 -175
  231. package/dist.commonjs/utils/index.d.ts +95 -6
  232. package/dist.commonjs/utils/index.d.ts.map +1 -1
  233. package/dist.commonjs/utils/index.js +30 -6
  234. package/package.json +4 -3
  235. package/src/address/address.advanced.ts +2 -5
  236. package/src/address/index.ts +2 -5
  237. package/src/ckb/script.ts +62 -2
  238. package/src/ckb/transaction.ts +678 -58
  239. package/src/client/advanced.ts +2 -0
  240. package/src/client/client.advanced.ts +134 -0
  241. package/src/client/client.ts +236 -25
  242. package/src/client/clientPublicMainnet.advanced.ts +117 -2
  243. package/src/client/clientPublicMainnet.ts +14 -3
  244. package/src/client/clientPublicTestnet.advanced.ts +176 -2
  245. package/src/client/clientPublicTestnet.ts +9 -3
  246. package/src/client/clientTypes.advanced.ts +26 -0
  247. package/src/client/clientTypes.ts +41 -43
  248. package/src/client/jsonRpc/index.ts +4 -4
  249. package/src/client/jsonRpc/transformers.ts +13 -11
  250. package/src/hasher/index.ts +4 -2
  251. package/src/num/index.ts +22 -0
  252. package/src/signer/btc/signerBtc.ts +6 -8
  253. package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
  254. package/src/signer/btc/verify.ts +6 -3
  255. package/src/signer/ckb/signerCkbScriptReadonly.ts +0 -9
  256. package/src/signer/dummy/alwaysError.ts +0 -4
  257. package/src/signer/dummy/openLink.ts +0 -4
  258. package/src/signer/evm/signerEvm.ts +11 -11
  259. package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
  260. package/src/signer/index.ts +1 -0
  261. package/src/signer/nostr/index.ts +1 -0
  262. package/src/signer/nostr/signerNostr.ts +135 -0
  263. package/src/signer/nostr/verify.ts +63 -0
  264. package/src/signer/signer/index.ts +15 -11
  265. package/src/utils/index.ts +108 -0
@@ -1,38 +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
+ ],
154
+ },
155
+ [KnownScript.NostrLock]: {
156
+ codeHash:
157
+ "0x6ae5ee0cb887b2df5a9a18137315b9bdc55be8d52637b2de0624092d5f0c91d5",
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
+ ],
37
211
  },
38
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
  }
@@ -79,12 +79,11 @@ export abstract class SignerBtc extends Signer {
79
79
  * @returns A promise that resolves to the prepared Transaction object.
80
80
  */
81
81
  async prepareTransaction(txLike: TransactionLike): Promise<Transaction> {
82
+ const tx = Transaction.from(txLike);
82
83
  const { script } = await this.getRecommendedAddressObj();
83
- return Transaction.from(txLike).prepareSighashAllWitness(
84
- script,
85
- 85,
86
- this.client,
87
- );
84
+ await tx.addCellDepsOfKnownScripts(this.client, KnownScript.OmniLock);
85
+ await tx.prepareSighashAllWitness(script, 85, this.client);
86
+ return tx;
88
87
  }
89
88
 
90
89
  /**
@@ -121,8 +120,7 @@ export abstract class SignerBtc extends Signer {
121
120
  ),
122
121
  );
123
122
 
124
- tx.witnesses[info.position] = hexFrom(witness.toBytes());
125
-
123
+ tx.setWitnessArgsAt(info.position, witness);
126
124
  return tx;
127
125
  }
128
126
  }
@@ -26,15 +26,6 @@ export class SignerBtcPublicKeyReadonly extends SignerBtc {
26
26
  this.publicKey = hexFrom(publicKey);
27
27
  }
28
28
 
29
- /**
30
- * Construct a new signer with the client replaced.
31
- *
32
- * @returns A promise that resolves the new Signer.
33
- */
34
- async replaceClient(client: Client): Promise<SignerBtcPublicKeyReadonly> {
35
- return new SignerBtcPublicKeyReadonly(client, this.account, this.publicKey);
36
- }
37
-
38
29
  /**
39
30
  * Connects to the client. This implementation does nothing as the class is read-only.
40
31
  *
@@ -1,5 +1,6 @@
1
- import { verifyMessage } from "@unisat/wallet-utils";
2
- import { BytesLike } from "../../bytes";
1
+ import { secp256k1 } from "@noble/curves/secp256k1";
2
+ import { magicHash } from "bitcoinjs-message";
3
+ import { BytesLike, bytesFrom } from "../../bytes";
3
4
  import { hexFrom } from "../../hex";
4
5
 
5
6
  export function verifyMessageBtcEcdsa(
@@ -10,5 +11,7 @@ export function verifyMessageBtcEcdsa(
10
11
  const challenge =
11
12
  typeof message === "string" ? message : hexFrom(message).slice(2);
12
13
 
13
- return verifyMessage(publicKey, challenge, signature);
14
+ const [_, ...rawSign] = bytesFrom(signature, "base64");
15
+
16
+ return secp256k1.verify(bytesFrom(rawSign), magicHash(challenge), publicKey);
14
17
  }
@@ -30,15 +30,6 @@ export class SignerCkbScriptReadonly extends Signer {
30
30
  this.script = Script.from(script);
31
31
  }
32
32
 
33
- /**
34
- * Construct a new signer with the client replaced.
35
- *
36
- * @returns A promise that resolves the new Signer.
37
- */
38
- async replaceClient(client: Client): Promise<SignerCkbScriptReadonly> {
39
- return new SignerCkbScriptReadonly(client, this.script);
40
- }
41
-
42
33
  /**
43
34
  * Connects to the client. This implementation does nothing as the class is read-only.
44
35
  *
@@ -11,10 +11,6 @@ export class SignerAlwaysError extends SignerDummy {
11
11
  super(client, type);
12
12
  }
13
13
 
14
- async replaceClient(client: Client): Promise<SignerAlwaysError> {
15
- return new SignerAlwaysError(client, this.type, this.message);
16
- }
17
-
18
14
  async connect(): Promise<void> {
19
15
  throw new Error(this.message);
20
16
  }
@@ -11,10 +11,6 @@ export class SignerOpenLink extends SignerDummy {
11
11
  super(client, type);
12
12
  }
13
13
 
14
- async replaceClient(client: Client): Promise<SignerOpenLink> {
15
- return new SignerOpenLink(client, this.type, this.link);
16
- }
17
-
18
14
  async connect(): Promise<void> {
19
15
  window.open(this.link, "_blank")?.focus();
20
16
  }
@@ -4,6 +4,7 @@ import { Script, Transaction, TransactionLike, WitnessArgs } from "../../ckb";
4
4
  import { KnownScript } from "../../client";
5
5
  import { hexFrom } from "../../hex";
6
6
  import { numToBytes } from "../../num";
7
+ import { reduceAsync } from "../../utils";
7
8
  import { Signer, SignerSignType, SignerType } from "../signer";
8
9
 
9
10
  /**
@@ -50,17 +51,17 @@ export abstract class SignerEvm extends Signer {
50
51
 
51
52
  async _getOmniLockEvmAddressObj(account: string): Promise<Address> {
52
53
  return Address.fromKnownScript(
54
+ this.client,
53
55
  KnownScript.OmniLock,
54
56
  hexFrom([0x12, ...bytesFrom(account), 0x00]),
55
- this.client,
56
57
  );
57
58
  }
58
59
 
59
60
  async _getOmniLockOldEvmAddressObj(account: string): Promise<Address> {
60
61
  return Address.fromKnownScript(
62
+ this.client,
61
63
  KnownScript.OmniLock,
62
64
  hexFrom([0x1, ...bytesFrom(account), 0x00]),
63
- this.client,
64
65
  );
65
66
  }
66
67
 
@@ -71,14 +72,13 @@ export abstract class SignerEvm extends Signer {
71
72
  * @returns A promise that resolves to the prepared Transaction object.
72
73
  */
73
74
  async prepareTransaction(txLike: TransactionLike): Promise<Transaction> {
74
- const addresses = await this.getAddressObjs();
75
-
76
- return addresses.reduce(
77
- (txPromise, { script }) =>
78
- txPromise.then((tx) =>
79
- tx.prepareSighashAllWitness(script, 85, this.client),
80
- ),
81
- Promise.resolve(Transaction.from(txLike)),
75
+ const tx = Transaction.from(txLike);
76
+ await tx.addCellDepsOfKnownScripts(this.client, KnownScript.OmniLock);
77
+ return reduceAsync(
78
+ await this.getAddressObjs(),
79
+ (tx: Transaction, { script }) =>
80
+ tx.prepareSighashAllWitness(script, 85, this.client),
81
+ tx,
82
82
  );
83
83
  }
84
84
 
@@ -139,7 +139,7 @@ export abstract class SignerEvm extends Signer {
139
139
  ),
140
140
  );
141
141
 
142
- tx.witnesses[info.position] = hexFrom(witness.toBytes());
142
+ tx.setWitnessArgsAt(info.position, witness);
143
143
 
144
144
  return tx;
145
145
  }