@ckb-ccc/connector-react 0.0.0-canary-20250214032000
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/CHANGELOG.md +403 -0
- package/README.md +51 -0
- package/dist/advanced.d.ts +3 -0
- package/dist/advanced.d.ts.map +1 -0
- package/dist/advanced.js +2 -0
- package/dist/advancedBarrel.d.ts +2 -0
- package/dist/advancedBarrel.d.ts.map +1 -0
- package/dist/advancedBarrel.js +1 -0
- package/dist/barrel.d.ts +4 -0
- package/dist/barrel.d.ts.map +1 -0
- package/dist/barrel.js +3 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useCcc.d.ts +29 -0
- package/dist/hooks/useCcc.d.ts.map +1 -0
- package/dist/hooks/useCcc.js +83 -0
- package/dist/hooks/useSigner.d.ts +3 -0
- package/dist/hooks/useSigner.d.ts.map +1 -0
- package/dist/hooks/useSigner.js +4 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/package.json +48 -0
- package/src/advanced.ts +2 -0
- package/src/advancedBarrel.ts +1 -0
- package/src/barrel.ts +3 -0
- package/src/components/index.ts +15 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useCcc.tsx +186 -0
- package/src/hooks/useSigner.tsx +6 -0
- package/src/index.ts +2 -0
- package/typedoc.json +6 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
# @ckb-ccc/connector-react
|
|
2
|
+
|
|
3
|
+
## 0.0.0-canary-20250214032000
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @ckb-ccc/connector@0.0.0-canary-20250214032000
|
|
9
|
+
|
|
10
|
+
## 1.0.11
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies []:
|
|
15
|
+
- @ckb-ccc/connector@1.0.11
|
|
16
|
+
|
|
17
|
+
## 1.0.10
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies []:
|
|
22
|
+
- @ckb-ccc/connector@1.0.10
|
|
23
|
+
|
|
24
|
+
## 1.0.9
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies []:
|
|
29
|
+
- @ckb-ccc/connector@1.0.9
|
|
30
|
+
|
|
31
|
+
## 1.0.8
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies []:
|
|
36
|
+
- @ckb-ccc/connector@1.0.8
|
|
37
|
+
|
|
38
|
+
## 1.0.7
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies []:
|
|
43
|
+
- @ckb-ccc/connector@1.0.7
|
|
44
|
+
|
|
45
|
+
## 1.0.6
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies []:
|
|
50
|
+
- @ckb-ccc/connector@1.0.6
|
|
51
|
+
|
|
52
|
+
## 1.0.5
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies []:
|
|
57
|
+
- @ckb-ccc/connector@1.0.5
|
|
58
|
+
|
|
59
|
+
## 1.0.4
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies []:
|
|
64
|
+
- @ckb-ccc/connector@1.0.4
|
|
65
|
+
|
|
66
|
+
## 1.0.3
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Updated dependencies []:
|
|
71
|
+
- @ckb-ccc/connector@1.0.3
|
|
72
|
+
|
|
73
|
+
## 1.0.2
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- Updated dependencies []:
|
|
78
|
+
- @ckb-ccc/connector@1.0.2
|
|
79
|
+
|
|
80
|
+
## 1.0.1
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies []:
|
|
85
|
+
- @ckb-ccc/connector@1.0.1
|
|
86
|
+
|
|
87
|
+
## 1.0.0
|
|
88
|
+
|
|
89
|
+
### Major Changes
|
|
90
|
+
|
|
91
|
+
- [#107](https://github.com/ckb-devrel/ccc/pull/107) [`b99f55f`](https://github.com/ckb-devrel/ccc/commit/b99f55f74e64106391ce53f7d0bd0fa7522023cc) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: molecule
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [[`b99f55f`](https://github.com/ckb-devrel/ccc/commit/b99f55f74e64106391ce53f7d0bd0fa7522023cc)]:
|
|
96
|
+
- @ckb-ccc/connector@1.0.0
|
|
97
|
+
|
|
98
|
+
## 0.0.19
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies []:
|
|
103
|
+
- @ckb-ccc/connector@0.0.19
|
|
104
|
+
|
|
105
|
+
## 0.0.18
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies []:
|
|
110
|
+
- @ckb-ccc/connector@0.0.18
|
|
111
|
+
|
|
112
|
+
## 0.0.17
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- [#62](https://github.com/ckb-devrel/ccc/pull/62) [`543c765`](https://github.com/ckb-devrel/ccc/commit/543c76523b3864f2203631762c27b8fc4c942cd7) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): Powered by CCC
|
|
117
|
+
|
|
118
|
+
- [#69](https://github.com/ckb-devrel/ccc/pull/69) [`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Client.waitTransaction
|
|
119
|
+
|
|
120
|
+
- [#70](https://github.com/ckb-devrel/ccc/pull/70) [`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): websocket transport
|
|
121
|
+
|
|
122
|
+
- [#78](https://github.com/ckb-devrel/ccc/pull/78) [`517dd3a`](https://github.com/ckb-devrel/ccc/commit/517dd3a28a0d6bf14df68450101f82e94a230801) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector-react): useCcc().isOpen
|
|
123
|
+
|
|
124
|
+
- [#67](https://github.com/ckb-devrel/ccc/pull/67) [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): auto fee rate
|
|
125
|
+
|
|
126
|
+
- [#60](https://github.com/ckb-devrel/ccc/pull/60) [`e904963`](https://github.com/ckb-devrel/ccc/commit/e904963a16f12c410d861eb3ae01b87d68cb3e34) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: support Xverse
|
|
127
|
+
|
|
128
|
+
- Updated dependencies [[`543c765`](https://github.com/ckb-devrel/ccc/commit/543c76523b3864f2203631762c27b8fc4c942cd7), [`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a), [`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366), [`e63a06e`](https://github.com/ckb-devrel/ccc/commit/e63a06ee75ac8595208d216dec88a4228c465e23), [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f), [`e904963`](https://github.com/ckb-devrel/ccc/commit/e904963a16f12c410d861eb3ae01b87d68cb3e34)]:
|
|
129
|
+
- @ckb-ccc/connector@0.0.17
|
|
130
|
+
|
|
131
|
+
## 0.0.17-alpha.11
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies []:
|
|
136
|
+
- @ckb-ccc/connector@0.0.17-alpha.10
|
|
137
|
+
|
|
138
|
+
## 0.0.17-alpha.10
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Updated dependencies []:
|
|
143
|
+
- @ckb-ccc/connector@0.0.17-alpha.9
|
|
144
|
+
|
|
145
|
+
## 0.0.17-alpha.9
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Updated dependencies []:
|
|
150
|
+
- @ckb-ccc/connector@0.0.17-alpha.8
|
|
151
|
+
|
|
152
|
+
## 0.0.17-alpha.8
|
|
153
|
+
|
|
154
|
+
### Patch Changes
|
|
155
|
+
|
|
156
|
+
- Updated dependencies []:
|
|
157
|
+
- @ckb-ccc/connector@0.0.17-alpha.7
|
|
158
|
+
|
|
159
|
+
## 0.0.17-alpha.7
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- [#78](https://github.com/ckb-devrel/ccc/pull/78) [`517dd3a`](https://github.com/ckb-devrel/ccc/commit/517dd3a28a0d6bf14df68450101f82e94a230801) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector-react): useCcc().isOpen
|
|
164
|
+
|
|
165
|
+
## 0.0.17-alpha.6
|
|
166
|
+
|
|
167
|
+
### Patch Changes
|
|
168
|
+
|
|
169
|
+
- Updated dependencies []:
|
|
170
|
+
- @ckb-ccc/connector@0.0.17-alpha.6
|
|
171
|
+
|
|
172
|
+
## 0.0.17-alpha.5
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- Updated dependencies []:
|
|
177
|
+
- @ckb-ccc/connector@0.0.17-alpha.5
|
|
178
|
+
|
|
179
|
+
## 0.0.17-alpha.4
|
|
180
|
+
|
|
181
|
+
### Patch Changes
|
|
182
|
+
|
|
183
|
+
- [#70](https://github.com/ckb-devrel/ccc/pull/70) [`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): websocket transport
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [[`acfc050`](https://github.com/ckb-devrel/ccc/commit/acfc0502cd6beb48b9310dec8411dcd630507366)]:
|
|
186
|
+
- @ckb-ccc/connector@0.0.17-alpha.4
|
|
187
|
+
|
|
188
|
+
## 0.0.17-alpha.3
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- [#69](https://github.com/ckb-devrel/ccc/pull/69) [`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Client.waitTransaction
|
|
193
|
+
|
|
194
|
+
- [#67](https://github.com/ckb-devrel/ccc/pull/67) [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): auto fee rate
|
|
195
|
+
|
|
196
|
+
- Updated dependencies [[`8824ff2`](https://github.com/ckb-devrel/ccc/commit/8824ff27af3b76186f1a7d6db8c907cd66f09d6a), [`c092988`](https://github.com/ckb-devrel/ccc/commit/c092988e7765b9ac79498d6bd72a6a2f62859b6f)]:
|
|
197
|
+
- @ckb-ccc/connector@0.0.17-alpha.3
|
|
198
|
+
|
|
199
|
+
## 0.0.17-alpha.2
|
|
200
|
+
|
|
201
|
+
### Patch Changes
|
|
202
|
+
|
|
203
|
+
- Updated dependencies []:
|
|
204
|
+
- @ckb-ccc/connector@0.0.17-alpha.2
|
|
205
|
+
|
|
206
|
+
## 0.0.17-alpha.1
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- [#62](https://github.com/ckb-devrel/ccc/pull/62) [`543c765`](https://github.com/ckb-devrel/ccc/commit/543c76523b3864f2203631762c27b8fc4c942cd7) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): Powered by CCC
|
|
211
|
+
|
|
212
|
+
- Updated dependencies [[`543c765`](https://github.com/ckb-devrel/ccc/commit/543c76523b3864f2203631762c27b8fc4c942cd7)]:
|
|
213
|
+
- @ckb-ccc/connector@0.0.17-alpha.1
|
|
214
|
+
|
|
215
|
+
## 0.0.17-alpha.0
|
|
216
|
+
|
|
217
|
+
### Patch Changes
|
|
218
|
+
|
|
219
|
+
- [#60](https://github.com/ckb-devrel/ccc/pull/60) [`e904963`](https://github.com/ckb-devrel/ccc/commit/e904963a16f12c410d861eb3ae01b87d68cb3e34) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: support Xverse
|
|
220
|
+
|
|
221
|
+
- Updated dependencies [[`e904963`](https://github.com/ckb-devrel/ccc/commit/e904963a16f12c410d861eb3ae01b87d68cb3e34)]:
|
|
222
|
+
- @ckb-ccc/connector@0.0.17-alpha.0
|
|
223
|
+
|
|
224
|
+
## 0.0.16
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- Updated dependencies []:
|
|
229
|
+
- @ckb-ccc/connector@0.0.16
|
|
230
|
+
|
|
231
|
+
## 0.0.15
|
|
232
|
+
|
|
233
|
+
### Patch Changes
|
|
234
|
+
|
|
235
|
+
- [`2483637`](https://github.com/ckb-devrel/ccc/commit/2483637c89a2e012ed6408d8cabc123b8a45faa9) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): animation
|
|
236
|
+
|
|
237
|
+
- Updated dependencies [[`2483637`](https://github.com/ckb-devrel/ccc/commit/2483637c89a2e012ed6408d8cabc123b8a45faa9)]:
|
|
238
|
+
- @ckb-ccc/connector@0.0.15
|
|
239
|
+
|
|
240
|
+
## 0.0.14
|
|
241
|
+
|
|
242
|
+
### Patch Changes
|
|
243
|
+
|
|
244
|
+
- [#56](https://github.com/ckb-devrel/ccc/pull/56) [`b4aa690`](https://github.com/ckb-devrel/ccc/commit/b4aa69085d69fc0953629fd907212922d7d106dd) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): manage button
|
|
245
|
+
|
|
246
|
+
- [#56](https://github.com/ckb-devrel/ccc/pull/56) [`f13f4d3`](https://github.com/ckb-devrel/ccc/commit/f13f4d319ca66b571029a65e945e3a038bfeea25) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findTransactions
|
|
247
|
+
|
|
248
|
+
- [#48](https://github.com/ckb-devrel/ccc/pull/48) [`4fb114b`](https://github.com/ckb-devrel/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(okx): make okx wallet happy
|
|
249
|
+
|
|
250
|
+
- [#54](https://github.com/ckb-devrel/ccc/pull/54) [`3f49876`](https://github.com/ckb-devrel/ccc/commit/3f49876826f5a9eeff8d14c7d8d7b9cf2cea0f32) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): useless back button
|
|
251
|
+
|
|
252
|
+
- [#53](https://github.com/ckb-devrel/ccc/pull/53) [`32bffff`](https://github.com/ckb-devrel/ccc/commit/32bffff407934ec5d16bf7c5701b128d8b29c452) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): select client
|
|
253
|
+
|
|
254
|
+
- Updated dependencies [[`b4aa690`](https://github.com/ckb-devrel/ccc/commit/b4aa69085d69fc0953629fd907212922d7d106dd), [`f13f4d3`](https://github.com/ckb-devrel/ccc/commit/f13f4d319ca66b571029a65e945e3a038bfeea25), [`4fb114b`](https://github.com/ckb-devrel/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6), [`3f49876`](https://github.com/ckb-devrel/ccc/commit/3f49876826f5a9eeff8d14c7d8d7b9cf2cea0f32), [`32bffff`](https://github.com/ckb-devrel/ccc/commit/32bffff407934ec5d16bf7c5701b128d8b29c452)]:
|
|
255
|
+
- @ckb-ccc/connector@0.0.14
|
|
256
|
+
|
|
257
|
+
## 0.0.14-alpha.3
|
|
258
|
+
|
|
259
|
+
### Patch Changes
|
|
260
|
+
|
|
261
|
+
- [#54](https://github.com/ckb-devrel/ccc/pull/54) [`3f49876`](https://github.com/ckb-devrel/ccc/commit/3f49876826f5a9eeff8d14c7d8d7b9cf2cea0f32) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector): useless back button
|
|
262
|
+
|
|
263
|
+
- Updated dependencies [[`3f49876`](https://github.com/ckb-devrel/ccc/commit/3f49876826f5a9eeff8d14c7d8d7b9cf2cea0f32)]:
|
|
264
|
+
- @ckb-ccc/connector@0.0.14-alpha.3
|
|
265
|
+
|
|
266
|
+
## 0.0.14-alpha.2
|
|
267
|
+
|
|
268
|
+
### Patch Changes
|
|
269
|
+
|
|
270
|
+
- [#53](https://github.com/ckb-devrel/ccc/pull/53) [`32bffff`](https://github.com/ckb-devrel/ccc/commit/32bffff407934ec5d16bf7c5701b128d8b29c452) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(connector): select client
|
|
271
|
+
|
|
272
|
+
- Updated dependencies [[`32bffff`](https://github.com/ckb-devrel/ccc/commit/32bffff407934ec5d16bf7c5701b128d8b29c452)]:
|
|
273
|
+
- @ckb-ccc/connector@0.0.14-alpha.2
|
|
274
|
+
|
|
275
|
+
## 0.0.14-alpha.1
|
|
276
|
+
|
|
277
|
+
### Patch Changes
|
|
278
|
+
|
|
279
|
+
- [#48](https://github.com/ckb-devrel/ccc/pull/48) [`4fb114b`](https://github.com/ckb-devrel/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(okx): make okx wallet happy
|
|
280
|
+
|
|
281
|
+
- Updated dependencies [[`4fb114b`](https://github.com/ckb-devrel/ccc/commit/4fb114bc421c7250eed7388c16f1c026875153e6)]:
|
|
282
|
+
- @ckb-ccc/connector@0.0.14-alpha.1
|
|
283
|
+
|
|
284
|
+
## 0.0.14-alpha.0
|
|
285
|
+
|
|
286
|
+
### Patch Changes
|
|
287
|
+
|
|
288
|
+
- Updated dependencies []:
|
|
289
|
+
- @ckb-ccc/connector@0.0.14-alpha.0
|
|
290
|
+
|
|
291
|
+
## 0.0.13
|
|
292
|
+
|
|
293
|
+
### Patch Changes
|
|
294
|
+
|
|
295
|
+
- [`9e6b9fd`](https://github.com/ckb-devrel/ccc/commit/9e6b9fd40274015a0964dec8e0ee58dcbc06c786) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector-react): if the filter is undefined, accept all
|
|
296
|
+
|
|
297
|
+
- [`6d62032`](https://github.com/ckb-devrel/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): recordCells should not add usableCells
|
|
298
|
+
|
|
299
|
+
- [`3658797`](https://github.com/ckb-devrel/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): node.js websocket
|
|
300
|
+
|
|
301
|
+
- [#25](https://github.com/ckb-devrel/ccc/pull/25) [`69c10fd`](https://github.com/ckb-devrel/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(utxo-global): switchNetwork
|
|
302
|
+
|
|
303
|
+
- [`44c7fee`](https://github.com/ckb-devrel/ccc/commit/44c7feed37369836268fba21884418682f15254b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): completeInputs
|
|
304
|
+
|
|
305
|
+
- [`079e20e`](https://github.com/ckb-devrel/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): more APIs. Since parsing.
|
|
306
|
+
|
|
307
|
+
- [`ed154d1`](https://github.com/ckb-devrel/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findCells
|
|
308
|
+
|
|
309
|
+
- Updated dependencies [[`6d62032`](https://github.com/ckb-devrel/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97), [`3658797`](https://github.com/ckb-devrel/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f), [`69c10fd`](https://github.com/ckb-devrel/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97), [`44c7fee`](https://github.com/ckb-devrel/ccc/commit/44c7feed37369836268fba21884418682f15254b), [`079e20e`](https://github.com/ckb-devrel/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11), [`ed154d1`](https://github.com/ckb-devrel/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895)]:
|
|
310
|
+
- @ckb-ccc/connector@0.0.13
|
|
311
|
+
|
|
312
|
+
## 0.0.13-alpha.8
|
|
313
|
+
|
|
314
|
+
### Patch Changes
|
|
315
|
+
|
|
316
|
+
- Updated dependencies []:
|
|
317
|
+
- @ckb-ccc/connector@0.0.13-alpha.8
|
|
318
|
+
|
|
319
|
+
## 0.0.13-alpha.7
|
|
320
|
+
|
|
321
|
+
### Patch Changes
|
|
322
|
+
|
|
323
|
+
- [`079e20e`](https://github.com/ckb-devrel/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): more APIs. Since parsing.
|
|
324
|
+
|
|
325
|
+
- [`ed154d1`](https://github.com/ckb-devrel/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): Signer.findCells
|
|
326
|
+
|
|
327
|
+
- Updated dependencies [[`079e20e`](https://github.com/ckb-devrel/ccc/commit/079e20ef14cf9a7c06bbaddf3e92cbfbb005da11), [`ed154d1`](https://github.com/ckb-devrel/ccc/commit/ed154d189e239907ad686ec51ac8133b6d5eb895)]:
|
|
328
|
+
- @ckb-ccc/connector@0.0.13-alpha.7
|
|
329
|
+
|
|
330
|
+
## 0.0.13-alpha.6
|
|
331
|
+
|
|
332
|
+
### Patch Changes
|
|
333
|
+
|
|
334
|
+
- [#25](https://github.com/ckb-devrel/ccc/pull/25) [`69c10fd`](https://github.com/ckb-devrel/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(utxo-global): switchNetwork
|
|
335
|
+
|
|
336
|
+
- [`44c7fee`](https://github.com/ckb-devrel/ccc/commit/44c7feed37369836268fba21884418682f15254b) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): completeInputs
|
|
337
|
+
|
|
338
|
+
- Updated dependencies [[`69c10fd`](https://github.com/ckb-devrel/ccc/commit/69c10fdfcd507433c13b15d17015dca4687afb97), [`44c7fee`](https://github.com/ckb-devrel/ccc/commit/44c7feed37369836268fba21884418682f15254b)]:
|
|
339
|
+
- @ckb-ccc/connector@0.0.13-alpha.6
|
|
340
|
+
|
|
341
|
+
## 0.0.13-alpha.5
|
|
342
|
+
|
|
343
|
+
### Patch Changes
|
|
344
|
+
|
|
345
|
+
- [`9e6b9fd`](https://github.com/ckb-devrel/ccc/commit/9e6b9fd40274015a0964dec8e0ee58dcbc06c786) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(connector-react): if the filter is undefined, accept all
|
|
346
|
+
|
|
347
|
+
- [`6d62032`](https://github.com/ckb-devrel/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97) Thanks [@Hanssen0](https://github.com/Hanssen0)! - fix(core): recordCells should not add usableCells
|
|
348
|
+
|
|
349
|
+
- Updated dependencies [[`6d62032`](https://github.com/ckb-devrel/ccc/commit/6d620326f42f8c48eff9deb95578cf28d7bf5c97)]:
|
|
350
|
+
- @ckb-ccc/connector@0.0.13-alpha.5
|
|
351
|
+
|
|
352
|
+
## 0.0.13-alpha.4
|
|
353
|
+
|
|
354
|
+
### Patch Changes
|
|
355
|
+
|
|
356
|
+
- [`3658797`](https://github.com/ckb-devrel/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat(core): node.js websocket
|
|
357
|
+
|
|
358
|
+
- Updated dependencies [[`3658797`](https://github.com/ckb-devrel/ccc/commit/3658797e67c42c56b20fa66481d0455ed019e69f)]:
|
|
359
|
+
- @ckb-ccc/connector@0.0.13-alpha.4
|
|
360
|
+
|
|
361
|
+
## 0.0.13-alpha.3
|
|
362
|
+
|
|
363
|
+
### Patch Changes
|
|
364
|
+
|
|
365
|
+
- Updated dependencies []:
|
|
366
|
+
- @ckb-ccc/connector@0.0.13-alpha.3
|
|
367
|
+
|
|
368
|
+
## 0.0.13-alpha.2
|
|
369
|
+
|
|
370
|
+
### Patch Changes
|
|
371
|
+
|
|
372
|
+
- Updated dependencies []:
|
|
373
|
+
- @ckb-ccc/connector@0.0.13-alpha.2
|
|
374
|
+
|
|
375
|
+
## 0.0.13-alpha.1
|
|
376
|
+
|
|
377
|
+
### Patch Changes
|
|
378
|
+
|
|
379
|
+
- Updated dependencies []:
|
|
380
|
+
- @ckb-ccc/connector@0.0.13-alpha.1
|
|
381
|
+
|
|
382
|
+
## 0.0.13-alpha.0
|
|
383
|
+
|
|
384
|
+
### Patch Changes
|
|
385
|
+
|
|
386
|
+
- Updated dependencies []:
|
|
387
|
+
- @ckb-ccc/connector@0.0.13-alpha.0
|
|
388
|
+
|
|
389
|
+
## 0.0.12
|
|
390
|
+
|
|
391
|
+
### Patch Changes
|
|
392
|
+
|
|
393
|
+
- [`591e779`](https://github.com/ckb-devrel/ccc/commit/591e7794ce3d07ceaad55b7a80d2277fe0aa9fe7) Thanks [@Hanssen0](https://github.com/Hanssen0)! - feat: custom SignersController
|
|
394
|
+
|
|
395
|
+
- Updated dependencies [[`6bee006`](https://github.com/ckb-devrel/ccc/commit/6bee006fbcb96986c65ca4d2d896fca21db2503b), [`591e779`](https://github.com/ckb-devrel/ccc/commit/591e7794ce3d07ceaad55b7a80d2277fe0aa9fe7)]:
|
|
396
|
+
- @ckb-ccc/connector@0.0.12
|
|
397
|
+
|
|
398
|
+
## 0.0.12-alpha.7
|
|
399
|
+
|
|
400
|
+
### Patch Changes
|
|
401
|
+
|
|
402
|
+
- Updated dependencies
|
|
403
|
+
- @ckb-ccc/connector@0.0.12-alpha.7
|
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://app.ckbccc.com/">
|
|
3
|
+
<img alt="Logo" src="https://raw.githubusercontent.com/ckb-devrel/ccc/master/assets/logoAndText.svg" style="height: 8rem; max-width: 90%; padding: 0.5rem 0;" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<h1 align="center" style="font-size: 48px;">
|
|
8
|
+
CCC Connector for React
|
|
9
|
+
</h1>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@ckb-ccc/connector-react"><img
|
|
13
|
+
alt="NPM Version" src="https://img.shields.io/npm/v/%40ckb-ccc%2Fconnector-react"
|
|
14
|
+
/></a>
|
|
15
|
+
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/ckb-devrel/ccc" />
|
|
16
|
+
<img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/ckb-devrel/ccc/master" />
|
|
17
|
+
<img alt="GitHub branch check runs" src="https://img.shields.io/github/check-runs/ckb-devrel/ccc/master" />
|
|
18
|
+
<a href="https://live.ckbccc.com/"><img
|
|
19
|
+
alt="Playground" src="https://img.shields.io/website?url=https%3A%2F%2Flive.ckbccc.com%2F&label=Playground"
|
|
20
|
+
/></a>
|
|
21
|
+
<a href="https://app.ckbccc.com/"><img
|
|
22
|
+
alt="App" src="https://img.shields.io/website?url=https%3A%2F%2Fapp.ckbccc.com%2F&label=App"
|
|
23
|
+
/></a>
|
|
24
|
+
<a href="https://docs.ckbccc.com/"><img
|
|
25
|
+
alt="Docs" src="https://img.shields.io/website?url=https%3A%2F%2Fdocs.ckbccc.com%2F&label=Docs"
|
|
26
|
+
/></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
CCC - CKBers' Codebase is a one-stop solution for your CKB JS/TS ecosystem development.
|
|
31
|
+
<br />
|
|
32
|
+
Empower yourself with CCC to discover the unlimited potential of CKB.
|
|
33
|
+
<br />
|
|
34
|
+
Interoperate with wallets from different chain ecosystems.
|
|
35
|
+
<br />
|
|
36
|
+
Fully enabling CKB's Turing completeness and cryptographic freedom power.
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
## Use the Connector UI
|
|
40
|
+
|
|
41
|
+
Before using the Connector, wrap your UI with the CCC Provider:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
<ccc.Provider>{/* Your application */}</ccc.Provider>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Check [the document for @ckb-ccc/connector-react](https://docs.ckbccc.com/modules/_ckb_ccc_connector_react.index.ccc.html) for more information.
|
|
48
|
+
|
|
49
|
+
<h3 align="center">
|
|
50
|
+
Read more about CCC on <a href="https://docs.ckbccc.com">our website</a> or <a href="https://github.com/ckb-devrel/ccc">GitHub Repo</a>.
|
|
51
|
+
</h3>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../src/advanced.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,qBAAqB,CAAC"}
|
package/dist/advanced.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advancedBarrel.d.ts","sourceRoot":"","sources":["../src/advancedBarrel.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ckb-ccc/connector/advancedBarrel";
|
package/dist/barrel.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"barrel.d.ts","sourceRoot":"","sources":["../src/barrel.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dist/barrel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAIzC,eAAO,MAAM,SAAS;;;EAQpB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { ccc } from "@ckb-ccc/connector";
|
|
3
|
+
import { createComponent } from "@lit/react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
export const Connector = createComponent({
|
|
6
|
+
tagName: "ccc-connector",
|
|
7
|
+
elementClass: ccc.WebComponentConnector,
|
|
8
|
+
react: React,
|
|
9
|
+
events: {
|
|
10
|
+
onWillUpdate: "willUpdate",
|
|
11
|
+
onClose: "close",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/connector";
|
|
2
|
+
import React, { HTMLAttributes, ReactNode } from "react";
|
|
3
|
+
export declare function Provider({ children, connectorProps, hideMark, name, icon, signerFilter, signersController, defaultClient, clientOptions, preferredNetworks, }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
connectorProps?: HTMLAttributes<{}>;
|
|
6
|
+
hideMark?: boolean;
|
|
7
|
+
name?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
signerFilter?: (signerInfo: ccc.SignerInfo, wallet: ccc.Wallet) => Promise<boolean>;
|
|
10
|
+
signersController?: ccc.SignersController;
|
|
11
|
+
defaultClient?: ccc.Client;
|
|
12
|
+
clientOptions?: {
|
|
13
|
+
icon?: string;
|
|
14
|
+
client: ccc.Client;
|
|
15
|
+
name: string;
|
|
16
|
+
}[];
|
|
17
|
+
preferredNetworks?: ccc.NetworkPreference[];
|
|
18
|
+
}): React.JSX.Element;
|
|
19
|
+
export declare function useCcc(): {
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
open: () => unknown;
|
|
22
|
+
close: () => unknown;
|
|
23
|
+
disconnect: () => unknown;
|
|
24
|
+
setClient: (client: ccc.Client) => unknown;
|
|
25
|
+
client: ccc.Client;
|
|
26
|
+
wallet?: ccc.Wallet;
|
|
27
|
+
signerInfo?: ccc.SignerInfo;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=useCcc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCcc.d.ts","sourceRoot":"","sources":["../../src/hooks/useCcc.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,KAAK,EAAE,EAEZ,cAAc,EACd,SAAS,EAQV,MAAM,OAAO,CAAC;AA4Cf,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CACb,UAAU,EAAE,GAAG,CAAC,UAAU,EAC1B,MAAM,EAAE,GAAG,CAAC,MAAM,KACf,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC1C,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACtE,iBAAiB,CAAC,EAAE,GAAG,CAAC,iBAAiB,EAAE,CAAC;CAC7C,qBA8FA;AAED,wBAAgB,MAAM;YAhKR,OAAO;UACT,MAAM,OAAO;WACZ,MAAM,OAAO;gBACR,MAAM,OAAO;eACd,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,KAAK,OAAO;YAClC,GAAG,CAAC,MAAM;aACT,GAAG,CAAC,MAAM;iBACN,GAAG,CAAC,UAAU;EAiKhC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/connector";
|
|
2
|
+
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
|
|
3
|
+
import { Connector } from "../components/index.js";
|
|
4
|
+
const CCC_CONTEXT = createContext(undefined);
|
|
5
|
+
class SignersControllerWithFilter extends ccc.SignersController {
|
|
6
|
+
constructor(filter) {
|
|
7
|
+
super();
|
|
8
|
+
this.filter = filter;
|
|
9
|
+
}
|
|
10
|
+
async addSigner(walletName, icon, signerInfo, context) {
|
|
11
|
+
if (this.filter &&
|
|
12
|
+
!(await this.filter(signerInfo, { name: walletName, icon }))) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
return super.addSigner(walletName, icon, signerInfo, context);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function Provider({ children, connectorProps, hideMark, name, icon, signerFilter, signersController, defaultClient, clientOptions, preferredNetworks, }) {
|
|
19
|
+
const [ref, setRef] = useState(null);
|
|
20
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
21
|
+
const [_, setFlag] = useState(0);
|
|
22
|
+
const defaultSignersController = useRef(undefined);
|
|
23
|
+
const client = useMemo(() => ref?.client ?? new ccc.ClientPublicTestnet(), [ref?.client]);
|
|
24
|
+
const open = useCallback(() => {
|
|
25
|
+
setIsOpen(true);
|
|
26
|
+
ref?.requestUpdate();
|
|
27
|
+
}, [setIsOpen, ref, ref?.requestUpdate]);
|
|
28
|
+
const close = useCallback(() => {
|
|
29
|
+
setIsOpen(false);
|
|
30
|
+
ref?.requestUpdate();
|
|
31
|
+
}, [setIsOpen, ref, ref?.requestUpdate]);
|
|
32
|
+
const disconnect = useMemo(() => ref?.disconnect.bind(ref) ?? (() => { }), [ref, ref?.disconnect]);
|
|
33
|
+
const setClient = useMemo(() => ref?.setClient.bind(ref) ?? (() => { }), [ref, ref?.setClient]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (defaultClient) {
|
|
36
|
+
setClient(defaultClient);
|
|
37
|
+
}
|
|
38
|
+
}, [setClient]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!defaultSignersController.current) {
|
|
41
|
+
defaultSignersController.current = new SignersControllerWithFilter(signerFilter);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
defaultSignersController.current.filter = signerFilter;
|
|
45
|
+
}
|
|
46
|
+
}, [signerFilter]);
|
|
47
|
+
return (React.createElement(CCC_CONTEXT.Provider, { value: {
|
|
48
|
+
isOpen,
|
|
49
|
+
open,
|
|
50
|
+
close,
|
|
51
|
+
disconnect,
|
|
52
|
+
setClient,
|
|
53
|
+
client,
|
|
54
|
+
wallet: ref?.wallet,
|
|
55
|
+
signerInfo: ref?.signer,
|
|
56
|
+
} },
|
|
57
|
+
React.createElement(Connector, { hideMark: hideMark, name: name, icon: icon, signersController: signersController ?? defaultSignersController.current, ref: setRef, onWillUpdate: () => setFlag((f) => f + 1), onClose: close, preferredNetworks: preferredNetworks, clientOptions: clientOptions, ...connectorProps,
|
|
58
|
+
style: {
|
|
59
|
+
zIndex: 999,
|
|
60
|
+
...(isOpen ? {} : { display: "none" }),
|
|
61
|
+
...{
|
|
62
|
+
"--background": "#fff",
|
|
63
|
+
"--divider": "#eee",
|
|
64
|
+
"--btn-primary": "#f8f8f8",
|
|
65
|
+
"--btn-primary-hover": "#efeeee",
|
|
66
|
+
"--btn-secondary": "#ddd",
|
|
67
|
+
"--btn-secondary-hover": "#ccc",
|
|
68
|
+
"--icon-primary": "#1E1E1E",
|
|
69
|
+
"--icon-secondary": "#666666",
|
|
70
|
+
color: "#1e1e1e",
|
|
71
|
+
"--tip-color": "#666",
|
|
72
|
+
},
|
|
73
|
+
...connectorProps?.style,
|
|
74
|
+
} }),
|
|
75
|
+
children));
|
|
76
|
+
}
|
|
77
|
+
export function useCcc() {
|
|
78
|
+
const context = useContext(CCC_CONTEXT);
|
|
79
|
+
if (!context) {
|
|
80
|
+
throw Error("The component which invokes the useCcc hook should be placed in a ccc.Provider.");
|
|
81
|
+
}
|
|
82
|
+
return context;
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSigner.d.ts","sourceRoot":"","sources":["../../src/hooks/useSigner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGzC,wBAAgB,SAAS,IAAI,GAAG,CAAC,MAAM,GAAG,SAAS,CAElD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ckb-ccc/connector-react",
|
|
3
|
+
"version": "0.0.0-canary-20250214032000",
|
|
4
|
+
"description": "CCC - CKBer's Codebase. Common Chains Connector UI Component for React",
|
|
5
|
+
"author": "Hanssen0 <hanssen0@hanssen0.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"private": false,
|
|
8
|
+
"homepage": "https://github.com/ckb-devrel/ccc",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git://github.com/ckb-devrel/ccc.git"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": "./dist/index.js",
|
|
17
|
+
"./barrel": "./dist/barrel.js",
|
|
18
|
+
"./advancedBarrel": "./dist/advancedBarrel.js",
|
|
19
|
+
"./advanced": "./dist/advanced.js"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@eslint/js": "^9.1.1",
|
|
23
|
+
"@types/react": "^18",
|
|
24
|
+
"eslint": "^9.1.0",
|
|
25
|
+
"eslint-config-prettier": "^9.1.0",
|
|
26
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
27
|
+
"prettier": "^3.2.5",
|
|
28
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
29
|
+
"rimraf": "^5.0.5",
|
|
30
|
+
"typescript": "^5.4.5",
|
|
31
|
+
"typescript-eslint": "^7.7.0"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@lit/react": "^1.0.5",
|
|
38
|
+
"@ckb-ccc/connector": "0.0.0-canary-20250214032000"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": ">=16"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "rimraf ./dist && tsc",
|
|
45
|
+
"lint": "eslint ./src",
|
|
46
|
+
"format": "prettier --write . && eslint --fix ./src"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/advanced.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ckb-ccc/connector/advancedBarrel";
|
package/src/barrel.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ccc } from "@ckb-ccc/connector";
|
|
4
|
+
import { createComponent } from "@lit/react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
export const Connector = createComponent({
|
|
8
|
+
tagName: "ccc-connector",
|
|
9
|
+
elementClass: ccc.WebComponentConnector,
|
|
10
|
+
react: React,
|
|
11
|
+
events: {
|
|
12
|
+
onWillUpdate: "willUpdate",
|
|
13
|
+
onClose: "close",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { ccc } from "@ckb-ccc/connector";
|
|
2
|
+
import React, {
|
|
3
|
+
CSSProperties,
|
|
4
|
+
HTMLAttributes,
|
|
5
|
+
ReactNode,
|
|
6
|
+
createContext,
|
|
7
|
+
useCallback,
|
|
8
|
+
useContext,
|
|
9
|
+
useEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useRef,
|
|
12
|
+
useState,
|
|
13
|
+
} from "react";
|
|
14
|
+
import { Connector } from "../components/index.js";
|
|
15
|
+
|
|
16
|
+
const CCC_CONTEXT = createContext<
|
|
17
|
+
| {
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
open: () => unknown;
|
|
20
|
+
close: () => unknown;
|
|
21
|
+
disconnect: () => unknown;
|
|
22
|
+
setClient: (client: ccc.Client) => unknown;
|
|
23
|
+
client: ccc.Client;
|
|
24
|
+
wallet?: ccc.Wallet;
|
|
25
|
+
signerInfo?: ccc.SignerInfo;
|
|
26
|
+
}
|
|
27
|
+
| undefined
|
|
28
|
+
>(undefined);
|
|
29
|
+
|
|
30
|
+
class SignersControllerWithFilter extends ccc.SignersController {
|
|
31
|
+
constructor(
|
|
32
|
+
public filter?: (
|
|
33
|
+
signerInfo: ccc.SignerInfo,
|
|
34
|
+
wallet: ccc.Wallet,
|
|
35
|
+
) => Promise<boolean>,
|
|
36
|
+
) {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async addSigner(
|
|
41
|
+
walletName: string,
|
|
42
|
+
icon: string,
|
|
43
|
+
signerInfo: ccc.SignerInfo,
|
|
44
|
+
context: ccc.SignersControllerRefreshContext,
|
|
45
|
+
) {
|
|
46
|
+
if (
|
|
47
|
+
this.filter &&
|
|
48
|
+
!(await this.filter(signerInfo, { name: walletName, icon }))
|
|
49
|
+
) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return super.addSigner(walletName, icon, signerInfo, context);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function Provider({
|
|
58
|
+
children,
|
|
59
|
+
connectorProps,
|
|
60
|
+
hideMark,
|
|
61
|
+
name,
|
|
62
|
+
icon,
|
|
63
|
+
signerFilter,
|
|
64
|
+
signersController,
|
|
65
|
+
defaultClient,
|
|
66
|
+
clientOptions,
|
|
67
|
+
preferredNetworks,
|
|
68
|
+
}: {
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
connectorProps?: HTMLAttributes<{}>;
|
|
71
|
+
hideMark?: boolean;
|
|
72
|
+
name?: string;
|
|
73
|
+
icon?: string;
|
|
74
|
+
signerFilter?: (
|
|
75
|
+
signerInfo: ccc.SignerInfo,
|
|
76
|
+
wallet: ccc.Wallet,
|
|
77
|
+
) => Promise<boolean>;
|
|
78
|
+
signersController?: ccc.SignersController;
|
|
79
|
+
defaultClient?: ccc.Client;
|
|
80
|
+
clientOptions?: { icon?: string; client: ccc.Client; name: string }[];
|
|
81
|
+
preferredNetworks?: ccc.NetworkPreference[];
|
|
82
|
+
}) {
|
|
83
|
+
const [ref, setRef] = useState<ccc.WebComponentConnector | null>(null);
|
|
84
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
85
|
+
const [_, setFlag] = useState(0);
|
|
86
|
+
const defaultSignersController = useRef<
|
|
87
|
+
SignersControllerWithFilter | undefined
|
|
88
|
+
>(undefined);
|
|
89
|
+
|
|
90
|
+
const client = useMemo(
|
|
91
|
+
() => ref?.client ?? new ccc.ClientPublicTestnet(),
|
|
92
|
+
[ref?.client],
|
|
93
|
+
);
|
|
94
|
+
const open = useCallback(() => {
|
|
95
|
+
setIsOpen(true);
|
|
96
|
+
ref?.requestUpdate();
|
|
97
|
+
}, [setIsOpen, ref, ref?.requestUpdate]);
|
|
98
|
+
const close = useCallback(() => {
|
|
99
|
+
setIsOpen(false);
|
|
100
|
+
ref?.requestUpdate();
|
|
101
|
+
}, [setIsOpen, ref, ref?.requestUpdate]);
|
|
102
|
+
const disconnect = useMemo(
|
|
103
|
+
() => ref?.disconnect.bind(ref) ?? (() => {}),
|
|
104
|
+
[ref, ref?.disconnect],
|
|
105
|
+
);
|
|
106
|
+
const setClient = useMemo(
|
|
107
|
+
() => ref?.setClient.bind(ref) ?? (() => {}),
|
|
108
|
+
[ref, ref?.setClient],
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (defaultClient) {
|
|
113
|
+
setClient(defaultClient);
|
|
114
|
+
}
|
|
115
|
+
}, [setClient]);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (!defaultSignersController.current) {
|
|
118
|
+
defaultSignersController.current = new SignersControllerWithFilter(
|
|
119
|
+
signerFilter,
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
defaultSignersController.current.filter = signerFilter;
|
|
123
|
+
}
|
|
124
|
+
}, [signerFilter]);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<CCC_CONTEXT.Provider
|
|
128
|
+
value={{
|
|
129
|
+
isOpen,
|
|
130
|
+
open,
|
|
131
|
+
close,
|
|
132
|
+
disconnect,
|
|
133
|
+
setClient,
|
|
134
|
+
|
|
135
|
+
client,
|
|
136
|
+
wallet: ref?.wallet,
|
|
137
|
+
signerInfo: ref?.signer,
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
<Connector
|
|
141
|
+
hideMark={hideMark}
|
|
142
|
+
name={name}
|
|
143
|
+
icon={icon}
|
|
144
|
+
signersController={
|
|
145
|
+
signersController ?? defaultSignersController.current
|
|
146
|
+
}
|
|
147
|
+
ref={setRef}
|
|
148
|
+
onWillUpdate={() => setFlag((f) => f + 1)}
|
|
149
|
+
onClose={close}
|
|
150
|
+
preferredNetworks={preferredNetworks}
|
|
151
|
+
clientOptions={clientOptions}
|
|
152
|
+
{...{
|
|
153
|
+
...connectorProps,
|
|
154
|
+
style: {
|
|
155
|
+
zIndex: 999,
|
|
156
|
+
...(isOpen ? {} : { display: "none" }),
|
|
157
|
+
...({
|
|
158
|
+
"--background": "#fff",
|
|
159
|
+
"--divider": "#eee",
|
|
160
|
+
"--btn-primary": "#f8f8f8",
|
|
161
|
+
"--btn-primary-hover": "#efeeee",
|
|
162
|
+
"--btn-secondary": "#ddd",
|
|
163
|
+
"--btn-secondary-hover": "#ccc",
|
|
164
|
+
"--icon-primary": "#1E1E1E",
|
|
165
|
+
"--icon-secondary": "#666666",
|
|
166
|
+
color: "#1e1e1e",
|
|
167
|
+
"--tip-color": "#666",
|
|
168
|
+
} as CSSProperties),
|
|
169
|
+
...connectorProps?.style,
|
|
170
|
+
},
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
173
|
+
{children}
|
|
174
|
+
</CCC_CONTEXT.Provider>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function useCcc() {
|
|
179
|
+
const context = useContext(CCC_CONTEXT);
|
|
180
|
+
if (!context) {
|
|
181
|
+
throw Error(
|
|
182
|
+
"The component which invokes the useCcc hook should be placed in a ccc.Provider.",
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return context;
|
|
186
|
+
}
|
package/src/index.ts
ADDED