@gluwa/connect-kit 0.1.0-next.3 → 0.2.0-next.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.
- package/CHANGELOG.md +6 -0
- package/dist/credit-connect.js +148 -133
- package/dist/index.css +561 -0
- package/dist/index.d.ts +39 -25
- package/dist/index.js +315 -655
- package/dist/package.json +11 -6
- package/package.json +8 -5
- package/src/ConnectKitProvider.tsx +75 -49
- package/src/ConnectModal.tsx +39 -25
- package/src/api/account.ts +21 -0
- package/src/api/balance.ts +10 -0
- package/src/api/chain.ts +17 -0
- package/src/api/contract.ts +33 -0
- package/src/api/transaction.ts +12 -0
- package/src/components/QRFrame.tsx +2 -2
- package/src/core/config.ts +83 -0
- package/src/creditConnectConnector.ts +175 -159
- package/src/events/account.ts +49 -0
- package/src/hooks/useWCState.ts +24 -9
- package/src/hooks/useWagmiConnect.ts +13 -8
- package/src/index.ts +33 -0
- package/src/types.ts +9 -0
- package/src/utils/platform.ts +1 -4
- package/src/views/CreditWalletView.tsx +0 -1
- package/src/views/MetaMaskView.tsx +4 -2
- package/src/views/SwitchChainView.tsx +9 -4
- package/tsup.config.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -3,624 +3,156 @@ import {
|
|
|
3
3
|
__name
|
|
4
4
|
} from "./chunk-DDA6FP6U.js";
|
|
5
5
|
|
|
6
|
-
// src/
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
// src/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
position: absolute;
|
|
21
|
-
inset: 0;
|
|
22
|
-
background: rgba(0, 0, 0, 0.6);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.ck-modal {
|
|
26
|
-
position: relative;
|
|
27
|
-
display: flex;
|
|
28
|
-
width: 1120px;
|
|
29
|
-
height: 620px;
|
|
30
|
-
border-radius: 16px;
|
|
31
|
-
overflow: hidden;
|
|
32
|
-
background: #1a1a1a;
|
|
33
|
-
color: #fff;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.ck-pane {
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
padding: 24px;
|
|
40
|
-
width: 560px;
|
|
41
|
-
flex-shrink: 0;
|
|
42
|
-
box-sizing: border-box;
|
|
43
|
-
}
|
|
44
|
-
.ck-pane--selector {
|
|
45
|
-
border-right: 1px solid rgba(255, 255, 255, 0.08);
|
|
46
|
-
}
|
|
47
|
-
.ck-pane--detail {
|
|
48
|
-
padding-inline: 20px;
|
|
49
|
-
overflow: hidden;
|
|
50
|
-
min-height: 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.ck-pane__header {
|
|
54
|
-
display: flex;
|
|
55
|
-
align-items: center;
|
|
56
|
-
gap: 8px;
|
|
57
|
-
margin-bottom: 20px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.ck-pane__title {
|
|
61
|
-
flex: 1;
|
|
62
|
-
font-size: 16px;
|
|
63
|
-
font-weight: 600;
|
|
64
|
-
margin: 0;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.ck-pane__body {
|
|
68
|
-
flex: 1;
|
|
69
|
-
display: flex;
|
|
70
|
-
flex-direction: column;
|
|
71
|
-
min-height: 0;
|
|
72
|
-
overflow: hidden;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.ck-pane__footer {
|
|
76
|
-
margin-top: auto;
|
|
77
|
-
padding-top: 16px;
|
|
78
|
-
text-align: center;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.ck-btn-close,
|
|
82
|
-
.ck-btn-back {
|
|
83
|
-
position: relative;
|
|
84
|
-
width: 28px;
|
|
85
|
-
height: 28px;
|
|
86
|
-
background: none;
|
|
87
|
-
border: none;
|
|
88
|
-
cursor: pointer;
|
|
89
|
-
padding: 0;
|
|
90
|
-
border-radius: 50%;
|
|
91
|
-
flex-shrink: 0;
|
|
92
|
-
display: flex;
|
|
93
|
-
align-items: center;
|
|
94
|
-
justify-content: center;
|
|
95
|
-
}
|
|
96
|
-
.ck-btn-close:hover,
|
|
97
|
-
.ck-btn-back:hover {
|
|
98
|
-
background: rgba(255, 255, 255, 0.08);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.ck-btn-close::before, .ck-btn-close::after {
|
|
102
|
-
content: "";
|
|
103
|
-
position: absolute;
|
|
104
|
-
width: 14px;
|
|
105
|
-
height: 2px;
|
|
106
|
-
background: rgba(255, 255, 255, 0.7);
|
|
107
|
-
border-radius: 1px;
|
|
108
|
-
}
|
|
109
|
-
.ck-btn-close::before {
|
|
110
|
-
transform: rotate(45deg);
|
|
111
|
-
}
|
|
112
|
-
.ck-btn-close::after {
|
|
113
|
-
transform: rotate(-45deg);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.ck-btn-back::before {
|
|
117
|
-
content: "";
|
|
118
|
-
position: absolute;
|
|
119
|
-
width: 8px;
|
|
120
|
-
height: 8px;
|
|
121
|
-
border-left: 2px solid rgba(255, 255, 255, 0.7);
|
|
122
|
-
border-bottom: 2px solid rgba(255, 255, 255, 0.7);
|
|
123
|
-
transform: rotate(45deg) translate(1px, -1px);
|
|
124
|
-
border-radius: 1px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.ck-btn-primary {
|
|
128
|
-
display: inline-flex;
|
|
129
|
-
align-items: center;
|
|
130
|
-
justify-content: center;
|
|
131
|
-
padding: 8px 16px;
|
|
132
|
-
border-radius: 8px;
|
|
133
|
-
font-size: 14px;
|
|
134
|
-
font-weight: 600;
|
|
135
|
-
text-decoration: none;
|
|
136
|
-
cursor: pointer;
|
|
137
|
-
white-space: nowrap;
|
|
138
|
-
color: #fff;
|
|
139
|
-
background: rgba(255, 255, 255, 0.15);
|
|
140
|
-
border: none;
|
|
141
|
-
}
|
|
142
|
-
.ck-btn-primary:hover {
|
|
143
|
-
background: rgba(255, 255, 255, 0.22);
|
|
144
|
-
}
|
|
145
|
-
.ck-btn-primary:disabled {
|
|
146
|
-
opacity: 0.6;
|
|
147
|
-
cursor: not-allowed;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.ck-btn-secondary {
|
|
151
|
-
display: inline-flex;
|
|
152
|
-
align-items: center;
|
|
153
|
-
justify-content: center;
|
|
154
|
-
padding: 8px 16px;
|
|
155
|
-
border-radius: 8px;
|
|
156
|
-
font-size: 14px;
|
|
157
|
-
font-weight: 500;
|
|
158
|
-
cursor: pointer;
|
|
159
|
-
white-space: nowrap;
|
|
160
|
-
color: rgba(255, 255, 255, 0.75);
|
|
161
|
-
background: transparent;
|
|
162
|
-
border: 1px solid rgba(255, 255, 255, 0.18);
|
|
163
|
-
}
|
|
164
|
-
.ck-btn-secondary:hover {
|
|
165
|
-
color: #fff;
|
|
166
|
-
border-color: rgba(255, 255, 255, 0.32);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.ck-view__actions {
|
|
170
|
-
display: flex;
|
|
171
|
-
flex-direction: column;
|
|
172
|
-
gap: 8px;
|
|
173
|
-
width: 100%;
|
|
174
|
-
margin-top: 16px;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.ck-view__caption--error {
|
|
178
|
-
color: #ff8080;
|
|
179
|
-
margin-top: 8px;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.ck-connector-list {
|
|
183
|
-
display: flex;
|
|
184
|
-
flex-direction: column;
|
|
185
|
-
gap: 8px;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.ck-connector-item {
|
|
189
|
-
display: flex;
|
|
190
|
-
align-items: center;
|
|
191
|
-
gap: 12px;
|
|
192
|
-
width: 100%;
|
|
193
|
-
padding: 12px 16px;
|
|
194
|
-
border: none;
|
|
195
|
-
border-radius: 12px;
|
|
196
|
-
cursor: pointer;
|
|
197
|
-
text-align: left;
|
|
198
|
-
color: #fff;
|
|
199
|
-
background: rgba(255, 255, 255, 0.05);
|
|
200
|
-
transition: background 0.15s;
|
|
201
|
-
}
|
|
202
|
-
.ck-connector-item:hover:not(:disabled) {
|
|
203
|
-
background: rgba(255, 255, 255, 0.08);
|
|
204
|
-
}
|
|
205
|
-
.ck-connector-item.is-active {
|
|
206
|
-
background: #3b82f6;
|
|
207
|
-
}
|
|
208
|
-
.ck-connector-item:disabled {
|
|
209
|
-
opacity: 0.5;
|
|
210
|
-
cursor: not-allowed;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.ck-connector-item__icon {
|
|
214
|
-
width: 32px;
|
|
215
|
-
height: 32px;
|
|
216
|
-
border-radius: 8px;
|
|
217
|
-
flex-shrink: 0;
|
|
218
|
-
background: rgba(255, 255, 255, 0.1);
|
|
219
|
-
display: block;
|
|
220
|
-
object-fit: cover;
|
|
221
|
-
}
|
|
222
|
-
.ck-connector-item__icon[src] {
|
|
223
|
-
background: none;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.ck-connector-item__label {
|
|
227
|
-
flex: 1;
|
|
228
|
-
font-size: 14px;
|
|
229
|
-
font-weight: 500;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.ck-connector-item__badge {
|
|
233
|
-
font-size: 11px;
|
|
234
|
-
font-weight: 600;
|
|
235
|
-
padding: 2px 6px;
|
|
236
|
-
border-radius: 4px;
|
|
237
|
-
background: rgba(255, 255, 255, 0.15);
|
|
238
|
-
color: rgba(255, 255, 255, 0.8);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.ck-divider {
|
|
242
|
-
display: flex;
|
|
243
|
-
align-items: center;
|
|
244
|
-
gap: 8px;
|
|
245
|
-
color: rgba(255, 255, 255, 0.3);
|
|
246
|
-
font-size: 12px;
|
|
247
|
-
margin: 4px 0;
|
|
248
|
-
}
|
|
249
|
-
.ck-divider::before, .ck-divider::after {
|
|
250
|
-
content: "";
|
|
251
|
-
flex: 1;
|
|
252
|
-
height: 1px;
|
|
253
|
-
background: rgba(255, 255, 255, 0.1);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.ck-link-no-wallet {
|
|
257
|
-
font-size: 13px;
|
|
258
|
-
text-decoration: none;
|
|
259
|
-
color: rgba(255, 255, 255, 0.5);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.ck-view {
|
|
263
|
-
display: flex;
|
|
264
|
-
flex-direction: column;
|
|
265
|
-
align-items: center;
|
|
266
|
-
flex: 1;
|
|
267
|
-
}
|
|
268
|
-
.ck-view--idle {
|
|
269
|
-
justify-content: center;
|
|
270
|
-
text-align: center;
|
|
271
|
-
gap: 12px;
|
|
272
|
-
}
|
|
273
|
-
.ck-view--qr {
|
|
274
|
-
gap: 16px;
|
|
275
|
-
}
|
|
276
|
-
.ck-view--extension {
|
|
277
|
-
justify-content: center;
|
|
278
|
-
align-items: center;
|
|
279
|
-
gap: 12px;
|
|
280
|
-
text-align: center;
|
|
281
|
-
}
|
|
282
|
-
.ck-view--wallet-list {
|
|
283
|
-
align-items: stretch;
|
|
284
|
-
gap: 12px;
|
|
285
|
-
height: 100%;
|
|
286
|
-
overflow: hidden;
|
|
287
|
-
width: 100%;
|
|
288
|
-
box-sizing: border-box;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.ck-view__illustration {
|
|
292
|
-
width: 180px;
|
|
293
|
-
height: auto;
|
|
294
|
-
display: block;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
.ck-view__wallet-icon {
|
|
298
|
-
width: 64px;
|
|
299
|
-
height: 64px;
|
|
300
|
-
border-radius: 16px;
|
|
301
|
-
background: rgba(255, 255, 255, 0.1);
|
|
302
|
-
}
|
|
303
|
-
.ck-view__title {
|
|
304
|
-
font-size: 18px;
|
|
305
|
-
font-weight: 600;
|
|
306
|
-
margin: 0;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.ck-view__description,
|
|
310
|
-
.ck-view__caption {
|
|
311
|
-
font-size: 13px;
|
|
312
|
-
opacity: 0.6;
|
|
313
|
-
margin: 0;
|
|
314
|
-
text-align: center;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
.ck-qr-frame {
|
|
318
|
-
width: 216px;
|
|
319
|
-
height: 216px;
|
|
320
|
-
border-radius: 16px;
|
|
321
|
-
display: flex;
|
|
322
|
-
align-items: center;
|
|
323
|
-
justify-content: center;
|
|
324
|
-
background: #fff;
|
|
325
|
-
overflow: hidden;
|
|
326
|
-
flex-shrink: 0;
|
|
327
|
-
}
|
|
328
|
-
.ck-qr-frame--loading {
|
|
329
|
-
background: rgba(255, 255, 255, 0.05);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.ck-qr-spinner,
|
|
333
|
-
.ck-spinner {
|
|
334
|
-
width: 32px;
|
|
335
|
-
height: 32px;
|
|
336
|
-
border: 3px solid rgba(255, 255, 255, 0.15);
|
|
337
|
-
border-top-color: rgba(255, 255, 255, 0.6);
|
|
338
|
-
border-radius: 50%;
|
|
339
|
-
animation: ck-spin 0.8s linear infinite;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
@keyframes ck-spin {
|
|
343
|
-
to {
|
|
344
|
-
transform: rotate(360deg);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
.ck-copy-link {
|
|
348
|
-
background: none;
|
|
349
|
-
border: none;
|
|
350
|
-
cursor: pointer;
|
|
351
|
-
font-size: 13px;
|
|
352
|
-
color: #fff;
|
|
353
|
-
opacity: 0.5;
|
|
354
|
-
display: flex;
|
|
355
|
-
align-items: center;
|
|
356
|
-
gap: 4px;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
.ck-download-card {
|
|
360
|
-
display: flex;
|
|
361
|
-
align-items: center;
|
|
362
|
-
justify-content: space-between;
|
|
363
|
-
width: 100%;
|
|
364
|
-
padding: 14px 16px;
|
|
365
|
-
border-radius: 12px;
|
|
366
|
-
background: rgba(255, 255, 255, 0.05);
|
|
367
|
-
margin-top: auto;
|
|
368
|
-
gap: 12px;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
.ck-download-card__text {
|
|
372
|
-
display: flex;
|
|
373
|
-
flex-direction: column;
|
|
374
|
-
gap: 2px;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
.ck-download-card__title {
|
|
378
|
-
font-size: 14px;
|
|
379
|
-
font-weight: 500;
|
|
380
|
-
margin: 0;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.ck-download-card__sub {
|
|
384
|
-
font-size: 12px;
|
|
385
|
-
opacity: 0.5;
|
|
386
|
-
margin: 0;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
.ck-all-wallets-btn {
|
|
390
|
-
display: flex;
|
|
391
|
-
align-items: center;
|
|
392
|
-
gap: 12px;
|
|
393
|
-
width: 100%;
|
|
394
|
-
padding: 14px 16px;
|
|
395
|
-
border: none;
|
|
396
|
-
border-radius: 12px;
|
|
397
|
-
background: rgba(255, 255, 255, 0.05);
|
|
398
|
-
color: #fff;
|
|
399
|
-
cursor: pointer;
|
|
400
|
-
margin-top: auto;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
.ck-all-wallets-btn__icon {
|
|
404
|
-
width: 32px;
|
|
405
|
-
height: 32px;
|
|
406
|
-
border-radius: 8px;
|
|
407
|
-
background: rgba(255, 255, 255, 0.1);
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
.ck-all-wallets-btn__label {
|
|
411
|
-
flex: 1;
|
|
412
|
-
font-size: 14px;
|
|
413
|
-
font-weight: 500;
|
|
414
|
-
text-align: left;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
.ck-all-wallets-btn__count {
|
|
418
|
-
font-size: 12px;
|
|
419
|
-
opacity: 0.5;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
.ck-wallet-search {
|
|
423
|
-
display: flex;
|
|
424
|
-
align-items: center;
|
|
425
|
-
gap: 8px;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
.ck-wallet-search__input {
|
|
429
|
-
flex: 1;
|
|
430
|
-
padding: 10px 14px;
|
|
431
|
-
border-radius: 10px;
|
|
432
|
-
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
433
|
-
background: rgba(255, 255, 255, 0.05);
|
|
434
|
-
font-size: 14px;
|
|
435
|
-
outline: none;
|
|
436
|
-
color: #fff;
|
|
437
|
-
}
|
|
438
|
-
.ck-wallet-search__input::placeholder {
|
|
439
|
-
color: rgba(255, 255, 255, 0.35);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
.ck-wc-filter {
|
|
443
|
-
display: flex;
|
|
444
|
-
align-items: center;
|
|
445
|
-
gap: 6px;
|
|
446
|
-
flex-shrink: 0;
|
|
447
|
-
border: none;
|
|
448
|
-
background: none;
|
|
449
|
-
cursor: pointer;
|
|
450
|
-
padding: 0;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.ck-wc-filter__icon {
|
|
454
|
-
width: 20px;
|
|
455
|
-
height: 20px;
|
|
456
|
-
border-radius: 4px;
|
|
457
|
-
display: block;
|
|
458
|
-
opacity: 0.5;
|
|
459
|
-
}
|
|
460
|
-
.ck-wc-filter.is-active .ck-wc-filter__icon {
|
|
461
|
-
opacity: 1;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.ck-wc-filter__track {
|
|
465
|
-
position: relative;
|
|
466
|
-
width: 36px;
|
|
467
|
-
height: 20px;
|
|
468
|
-
border-radius: 10px;
|
|
469
|
-
background: rgba(255, 255, 255, 0.15);
|
|
470
|
-
transition: background 0.2s;
|
|
471
|
-
}
|
|
472
|
-
.ck-wc-filter.is-active .ck-wc-filter__track {
|
|
473
|
-
background: #3b82f6;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
.ck-wc-filter__thumb {
|
|
477
|
-
position: absolute;
|
|
478
|
-
top: 2px;
|
|
479
|
-
left: 2px;
|
|
480
|
-
width: 16px;
|
|
481
|
-
height: 16px;
|
|
482
|
-
border-radius: 50%;
|
|
483
|
-
background: #fff;
|
|
484
|
-
transition: transform 0.2s;
|
|
485
|
-
}
|
|
486
|
-
.ck-wc-filter.is-active .ck-wc-filter__thumb {
|
|
487
|
-
transform: translateX(16px);
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
.ck-wallet-grid-scroll {
|
|
491
|
-
flex: 1;
|
|
492
|
-
min-height: 0;
|
|
493
|
-
width: 100%;
|
|
494
|
-
overflow-x: hidden;
|
|
495
|
-
overflow-y: auto;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
.ck-wallet-grid {
|
|
499
|
-
display: grid;
|
|
500
|
-
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
501
|
-
grid-auto-rows: max-content;
|
|
502
|
-
gap: 8px;
|
|
503
|
-
list-style: none;
|
|
504
|
-
margin: 0;
|
|
505
|
-
padding: 0;
|
|
506
|
-
width: 100%;
|
|
507
|
-
box-sizing: border-box;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
.ck-wallet-grid__item {
|
|
511
|
-
display: flex;
|
|
512
|
-
flex-direction: column;
|
|
513
|
-
align-items: center;
|
|
514
|
-
gap: 6px;
|
|
515
|
-
padding: 10px 4px;
|
|
516
|
-
width: 100%;
|
|
517
|
-
background: none;
|
|
518
|
-
border: none;
|
|
519
|
-
border-radius: 10px;
|
|
520
|
-
cursor: pointer;
|
|
521
|
-
color: #fff;
|
|
522
|
-
box-sizing: border-box;
|
|
523
|
-
}
|
|
524
|
-
.ck-wallet-grid__item:hover {
|
|
525
|
-
background: rgba(255, 255, 255, 0.05);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
.ck-wallet-grid__icon {
|
|
529
|
-
width: 48px;
|
|
530
|
-
height: 48px;
|
|
531
|
-
border-radius: 12px;
|
|
532
|
-
flex-shrink: 0;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
.ck-wallet-grid__icon-placeholder {
|
|
536
|
-
width: 48px;
|
|
537
|
-
height: 48px;
|
|
538
|
-
border-radius: 12px;
|
|
539
|
-
flex-shrink: 0;
|
|
540
|
-
background: rgba(255, 255, 255, 0.1);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
.ck-wallet-grid__name {
|
|
544
|
-
display: flex;
|
|
545
|
-
align-items: center;
|
|
546
|
-
justify-content: center;
|
|
547
|
-
gap: 3px;
|
|
548
|
-
width: 100%;
|
|
549
|
-
min-width: 0;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
.ck-wallet-grid__name-text {
|
|
553
|
-
flex: 1;
|
|
554
|
-
min-width: 0;
|
|
555
|
-
font-size: 11px;
|
|
556
|
-
overflow: hidden;
|
|
557
|
-
text-overflow: ellipsis;
|
|
558
|
-
white-space: nowrap;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
.ck-wallet-grid__wc-badge {
|
|
562
|
-
width: 10px;
|
|
563
|
-
height: 10px;
|
|
564
|
-
border-radius: 2px;
|
|
565
|
-
flex-shrink: 0;
|
|
566
|
-
opacity: 0.7;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
.ck-wallet-list-loading,
|
|
570
|
-
.ck-wallet-list-empty {
|
|
571
|
-
display: flex;
|
|
572
|
-
align-items: center;
|
|
573
|
-
justify-content: center;
|
|
574
|
-
padding: 32px;
|
|
575
|
-
opacity: 0.4;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
.ck-mobile-only {
|
|
579
|
-
display: none;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
@media (max-width: 1120px) {
|
|
583
|
-
.ck-root {
|
|
584
|
-
align-items: flex-end;
|
|
585
|
-
}
|
|
586
|
-
.ck-modal {
|
|
587
|
-
flex-direction: column;
|
|
588
|
-
width: 100%;
|
|
589
|
-
height: auto;
|
|
590
|
-
max-height: 90dvh;
|
|
591
|
-
border-radius: 20px 20px 0 0;
|
|
592
|
-
animation: ck-slide-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
|
|
593
|
-
overflow-y: auto;
|
|
6
|
+
// src/api/contract.ts
|
|
7
|
+
import { readContract as wagmiReadContract, writeContract as wagmiWriteContract } from "@wagmi/core";
|
|
8
|
+
|
|
9
|
+
// src/core/config.ts
|
|
10
|
+
import { createConfig, createStorage } from "wagmi";
|
|
11
|
+
import { metaMask, walletConnect, injected } from "wagmi/connectors";
|
|
12
|
+
var SLOT_KEY = Symbol.for("@gluwa/connect-kit:slot");
|
|
13
|
+
var getSlot = /* @__PURE__ */ __name(() => {
|
|
14
|
+
const g = globalThis;
|
|
15
|
+
if (!g[SLOT_KEY]) {
|
|
16
|
+
g[SLOT_KEY] = {
|
|
17
|
+
config: null,
|
|
18
|
+
kitConfig: null
|
|
19
|
+
};
|
|
594
20
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
21
|
+
return g[SLOT_KEY];
|
|
22
|
+
}, "getSlot");
|
|
23
|
+
var initConfig = /* @__PURE__ */ __name((kitConfig) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const slot = getSlot();
|
|
26
|
+
if (slot.config) {
|
|
27
|
+
if (slot.kitConfig !== kitConfig) {
|
|
28
|
+
console.warn("[connect-kit] initConfig called again with a different kitConfig \u2014 new chains/transports ignored. Call resetConfig() first to re-init.");
|
|
601
29
|
}
|
|
30
|
+
return slot.config;
|
|
602
31
|
}
|
|
603
|
-
|
|
604
|
-
|
|
32
|
+
const connectors = [];
|
|
33
|
+
if (kitConfig.wcProjectId) {
|
|
34
|
+
connectors.push(walletConnect({
|
|
35
|
+
projectId: kitConfig.wcProjectId,
|
|
36
|
+
showQrModal: false
|
|
37
|
+
}));
|
|
605
38
|
}
|
|
606
|
-
.
|
|
607
|
-
|
|
39
|
+
connectors.push(metaMask({
|
|
40
|
+
storage: {
|
|
41
|
+
enabled: true
|
|
42
|
+
}
|
|
43
|
+
}), injected({
|
|
44
|
+
shimDisconnect: false
|
|
45
|
+
}));
|
|
46
|
+
if ((_a = kitConfig.extraConnectors) == null ? void 0 : _a.length) {
|
|
47
|
+
connectors.push(...kitConfig.extraConnectors);
|
|
608
48
|
}
|
|
609
|
-
|
|
610
|
-
.
|
|
611
|
-
|
|
612
|
-
|
|
49
|
+
const isBrowser = typeof window !== "undefined";
|
|
50
|
+
slot.config = createConfig({
|
|
51
|
+
ssr: true,
|
|
52
|
+
chains: kitConfig.chains,
|
|
53
|
+
connectors,
|
|
54
|
+
transports: kitConfig.transports,
|
|
55
|
+
storage: isBrowser ? createStorage({
|
|
56
|
+
storage: window.localStorage
|
|
57
|
+
}) : void 0
|
|
58
|
+
});
|
|
59
|
+
slot.kitConfig = kitConfig;
|
|
60
|
+
return slot.config;
|
|
61
|
+
}, "initConfig");
|
|
62
|
+
var getConfig = /* @__PURE__ */ __name(() => {
|
|
63
|
+
const slot = getSlot();
|
|
64
|
+
if (!slot.config) {
|
|
65
|
+
throw new Error("ConnectKit config not initialized. Make sure ConnectKitProvider is mounted.");
|
|
613
66
|
}
|
|
614
|
-
.
|
|
615
|
-
|
|
67
|
+
return slot.config;
|
|
68
|
+
}, "getConfig");
|
|
69
|
+
var getKitConfig = /* @__PURE__ */ __name(() => {
|
|
70
|
+
const slot = getSlot();
|
|
71
|
+
if (!slot.kitConfig) {
|
|
72
|
+
throw new Error("ConnectKit config not initialized. Make sure ConnectKitProvider is mounted.");
|
|
616
73
|
}
|
|
617
|
-
.
|
|
618
|
-
|
|
74
|
+
return slot.kitConfig;
|
|
75
|
+
}, "getKitConfig");
|
|
76
|
+
|
|
77
|
+
// src/api/contract.ts
|
|
78
|
+
function readContract(parameters) {
|
|
79
|
+
return wagmiReadContract(getConfig(), parameters);
|
|
80
|
+
}
|
|
81
|
+
__name(readContract, "readContract");
|
|
82
|
+
function writeContract(parameters) {
|
|
83
|
+
return wagmiWriteContract(getConfig(), parameters);
|
|
84
|
+
}
|
|
85
|
+
__name(writeContract, "writeContract");
|
|
86
|
+
|
|
87
|
+
// src/api/balance.ts
|
|
88
|
+
import { getBalance as wagmiGetBalance } from "@wagmi/core";
|
|
89
|
+
var getBalance = /* @__PURE__ */ __name((params) => {
|
|
90
|
+
return wagmiGetBalance(getConfig(), params);
|
|
91
|
+
}, "getBalance");
|
|
92
|
+
|
|
93
|
+
// src/api/chain.ts
|
|
94
|
+
import { switchChain as wagmiSwitchChain, getPublicClient as wagmiGetPublicClient } from "@wagmi/core";
|
|
95
|
+
var switchChain = /* @__PURE__ */ __name((params) => {
|
|
96
|
+
return wagmiSwitchChain(getConfig(), params);
|
|
97
|
+
}, "switchChain");
|
|
98
|
+
var getPublicClient = /* @__PURE__ */ __name((params) => {
|
|
99
|
+
return wagmiGetPublicClient(getConfig(), params);
|
|
100
|
+
}, "getPublicClient");
|
|
101
|
+
|
|
102
|
+
// src/api/transaction.ts
|
|
103
|
+
import { waitForTransactionReceipt as wagmiWaitForTransactionReceipt } from "@wagmi/core";
|
|
104
|
+
var waitForTransactionReceipt = /* @__PURE__ */ __name((params) => {
|
|
105
|
+
return wagmiWaitForTransactionReceipt(getConfig(), params);
|
|
106
|
+
}, "waitForTransactionReceipt");
|
|
107
|
+
|
|
108
|
+
// src/api/account.ts
|
|
109
|
+
import { getAccount as wagmiGetAccount, signMessage as wagmiSignMessage, signTypedData as wagmiSignTypedData } from "@wagmi/core";
|
|
110
|
+
var getAccount = /* @__PURE__ */ __name(() => {
|
|
111
|
+
return wagmiGetAccount(getConfig());
|
|
112
|
+
}, "getAccount");
|
|
113
|
+
var signMessage = /* @__PURE__ */ __name((params) => {
|
|
114
|
+
return wagmiSignMessage(getConfig(), params);
|
|
115
|
+
}, "signMessage");
|
|
116
|
+
var signTypedData = /* @__PURE__ */ __name((params) => {
|
|
117
|
+
return wagmiSignTypedData(getConfig(), params);
|
|
118
|
+
}, "signTypedData");
|
|
119
|
+
|
|
120
|
+
// src/events/account.ts
|
|
121
|
+
import { watchAccount as wagmiWatchAccount, watchConnections as wagmiWatchConnections, reconnect as wagmiReconnect, disconnect as wagmiDisconnect } from "@wagmi/core";
|
|
122
|
+
var watchAccount = /* @__PURE__ */ __name((params) => {
|
|
123
|
+
return wagmiWatchAccount(getConfig(), params);
|
|
124
|
+
}, "watchAccount");
|
|
125
|
+
var watchConnections = /* @__PURE__ */ __name((params) => {
|
|
126
|
+
return wagmiWatchConnections(getConfig(), params);
|
|
127
|
+
}, "watchConnections");
|
|
128
|
+
var reconnect = /* @__PURE__ */ __name(() => {
|
|
129
|
+
return wagmiReconnect(getConfig());
|
|
130
|
+
}, "reconnect");
|
|
131
|
+
var disconnectAll = /* @__PURE__ */ __name(async (onLog) => {
|
|
132
|
+
const config = getConfig();
|
|
133
|
+
const results = await Promise.allSettled(config.connectors.map((connector) => wagmiDisconnect(config, {
|
|
134
|
+
connector
|
|
135
|
+
}).then(() => connector.id)));
|
|
136
|
+
const errors = [];
|
|
137
|
+
results.forEach((result, idx) => {
|
|
138
|
+
if (result.status === "rejected") {
|
|
139
|
+
const error = result.reason instanceof Error ? result.reason : new Error(String(result.reason));
|
|
140
|
+
const connectorId = config.connectors[idx].id;
|
|
141
|
+
errors.push({
|
|
142
|
+
connectorId,
|
|
143
|
+
error
|
|
144
|
+
});
|
|
145
|
+
onLog == null ? void 0 : onLog(`[connect-kit] disconnect failed for "${connectorId}": ${error.message}`, error);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
if (errors.length === config.connectors.length && errors.length > 0) {
|
|
149
|
+
const messages = errors.map((e) => `${e.connectorId}: ${e.error.message}`).join("; ");
|
|
150
|
+
throw new Error(`All disconnects failed \u2014 ${messages}`);
|
|
619
151
|
}
|
|
620
|
-
}
|
|
621
|
-
document.head.appendChild(document.createElement("style")).appendChild(document.createTextNode(css));
|
|
152
|
+
}, "disconnectAll");
|
|
622
153
|
|
|
623
154
|
// src/ConnectModal.tsx
|
|
155
|
+
import { useState as useState3, useEffect as useEffect6, useCallback as useCallback3, useMemo as useMemo4 } from "react";
|
|
624
156
|
import { useAccount, useConfig as useConfig2, useDisconnect } from "wagmi";
|
|
625
157
|
|
|
626
158
|
// assets/creditwallet.png
|
|
@@ -668,7 +200,7 @@ var isMobileDevice = /* @__PURE__ */ __name(() => {
|
|
|
668
200
|
}, "isMobileDevice");
|
|
669
201
|
var tryOpenDeepLink = /* @__PURE__ */ __name((uri, deepLinkBase2) => {
|
|
670
202
|
const sep = deepLinkBase2.endsWith("/") ? "" : "/";
|
|
671
|
-
window.location.
|
|
203
|
+
window.location.replace(`${deepLinkBase2}${sep}wc?uri=${encodeURIComponent(uri)}`);
|
|
672
204
|
}, "tryOpenDeepLink");
|
|
673
205
|
var detectMetaMaskExtension = /* @__PURE__ */ __name(() => {
|
|
674
206
|
var _a;
|
|
@@ -681,7 +213,12 @@ import { useConnect, useConfig } from "wagmi";
|
|
|
681
213
|
var hasMetaMaskKeyword = /* @__PURE__ */ __name((value) => value.toLowerCase().includes("metamask"), "hasMetaMaskKeyword");
|
|
682
214
|
var hasWalletConnectKeyword = /* @__PURE__ */ __name((value) => value.toLowerCase().includes("walletconnect"), "hasWalletConnectKeyword");
|
|
683
215
|
var isMetaMaskConnector = /* @__PURE__ */ __name((connector) => {
|
|
684
|
-
if (connector.id === "
|
|
216
|
+
if (connector.id === "metaMaskSDK") return true;
|
|
217
|
+
if (connector.id === "injected") {
|
|
218
|
+
if (typeof window === "undefined") return false;
|
|
219
|
+
const eth = window.ethereum;
|
|
220
|
+
return (eth == null ? void 0 : eth.isMetaMask) === true;
|
|
221
|
+
}
|
|
685
222
|
if (hasMetaMaskKeyword(connector.id) || hasMetaMaskKeyword(connector.name)) return true;
|
|
686
223
|
if (connector.rdns) {
|
|
687
224
|
const rdnsList = Array.isArray(connector.rdns) ? connector.rdns : [
|
|
@@ -712,6 +249,7 @@ var resolveWagmiConnector = /* @__PURE__ */ __name((connectors, connectorId) =>
|
|
|
712
249
|
var useWagmiConnect = /* @__PURE__ */ __name(({ onConnect, onError, onQrUri }) => {
|
|
713
250
|
const config = useConfig();
|
|
714
251
|
const pendingConnectorId = useRef(null);
|
|
252
|
+
const attemptCounter = useRef(0);
|
|
715
253
|
const onConnectRef = useRef(onConnect);
|
|
716
254
|
const onErrorRef = useRef(onError);
|
|
717
255
|
const onQrUriRef = useRef(onQrUri);
|
|
@@ -753,12 +291,13 @@ var useWagmiConnect = /* @__PURE__ */ __name(({ onConnect, onError, onQrUri }) =
|
|
|
753
291
|
return;
|
|
754
292
|
}
|
|
755
293
|
onQrUriRef.current(null);
|
|
294
|
+
const attemptId = ++attemptCounter.current;
|
|
756
295
|
pendingConnectorId.current = connectorId;
|
|
757
296
|
connectAsync({
|
|
758
297
|
connector
|
|
759
298
|
}).then((result) => {
|
|
760
299
|
var _a;
|
|
761
|
-
if (
|
|
300
|
+
if (attemptCounter.current !== attemptId) return;
|
|
762
301
|
const address = (_a = result.accounts) == null ? void 0 : _a[0];
|
|
763
302
|
if (!address) {
|
|
764
303
|
throw new Error("Connected but no account returned");
|
|
@@ -769,7 +308,7 @@ var useWagmiConnect = /* @__PURE__ */ __name(({ onConnect, onError, onQrUri }) =
|
|
|
769
308
|
connectorId
|
|
770
309
|
});
|
|
771
310
|
}).catch((error) => {
|
|
772
|
-
if (
|
|
311
|
+
if (attemptCounter.current !== attemptId) return;
|
|
773
312
|
pendingConnectorId.current = null;
|
|
774
313
|
onErrorRef.current(error, connectorId);
|
|
775
314
|
});
|
|
@@ -778,6 +317,7 @@ var useWagmiConnect = /* @__PURE__ */ __name(({ onConnect, onError, onQrUri }) =
|
|
|
778
317
|
connectAsync
|
|
779
318
|
]);
|
|
780
319
|
const cancelConnect = useCallback(() => {
|
|
320
|
+
attemptCounter.current += 1;
|
|
781
321
|
pendingConnectorId.current = null;
|
|
782
322
|
onQrUriRef.current(null);
|
|
783
323
|
reset();
|
|
@@ -792,18 +332,21 @@ var useWagmiConnect = /* @__PURE__ */ __name(({ onConnect, onError, onQrUri }) =
|
|
|
792
332
|
}, "useWagmiConnect");
|
|
793
333
|
|
|
794
334
|
// src/hooks/useWCState.ts
|
|
795
|
-
import { useState, useRef as useRef2, useCallback as useCallback2 } from "react";
|
|
796
|
-
var fetchWCWalletList = /* @__PURE__ */ __name(async (projectId) => {
|
|
335
|
+
import { useState, useRef as useRef2, useCallback as useCallback2, useEffect as useEffect2 } from "react";
|
|
336
|
+
var fetchWCWalletList = /* @__PURE__ */ __name(async (projectId, signal) => {
|
|
797
337
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
798
338
|
const all = [];
|
|
799
339
|
let page = 1;
|
|
800
340
|
const entries = 100;
|
|
801
341
|
while (page <= 10) {
|
|
342
|
+
if (signal == null ? void 0 : signal.aborted) throw new DOMException("Aborted", "AbortError");
|
|
802
343
|
const url = new URL("https://explorer-api.walletconnect.com/v3/wallets");
|
|
803
344
|
url.searchParams.set("projectId", projectId);
|
|
804
345
|
url.searchParams.set("entries", String(entries));
|
|
805
346
|
url.searchParams.set("page", String(page));
|
|
806
|
-
const res = await fetch(url.toString()
|
|
347
|
+
const res = await fetch(url.toString(), {
|
|
348
|
+
signal
|
|
349
|
+
});
|
|
807
350
|
if (!res.ok) throw new Error(`Failed to fetch wallet list: ${res.status}`);
|
|
808
351
|
const json = await res.json();
|
|
809
352
|
const listings = Object.values((_a = json.listings) != null ? _a : {});
|
|
@@ -834,17 +377,32 @@ var useWCState = /* @__PURE__ */ __name(() => {
|
|
|
834
377
|
const [filterActive, setFilterActive] = useState(false);
|
|
835
378
|
const [selectedWallet, setSelectedWallet] = useState(null);
|
|
836
379
|
const loadedRef = useRef2(false);
|
|
380
|
+
const abortControllerRef = useRef2(null);
|
|
381
|
+
const isMountedRef = useRef2(true);
|
|
382
|
+
useEffect2(() => {
|
|
383
|
+
isMountedRef.current = true;
|
|
384
|
+
return () => {
|
|
385
|
+
var _a;
|
|
386
|
+
isMountedRef.current = false;
|
|
387
|
+
(_a = abortControllerRef.current) == null ? void 0 : _a.abort();
|
|
388
|
+
abortControllerRef.current = null;
|
|
389
|
+
};
|
|
390
|
+
}, []);
|
|
837
391
|
const loadWalletList = useCallback2(async (projectId) => {
|
|
838
392
|
if (loadedRef.current) return;
|
|
839
393
|
loadedRef.current = true;
|
|
394
|
+
const controller = new AbortController();
|
|
395
|
+
abortControllerRef.current = controller;
|
|
840
396
|
setWalletListLoading(true);
|
|
841
397
|
try {
|
|
842
|
-
const list = await fetchWCWalletList(projectId);
|
|
843
|
-
setWalletList(list);
|
|
844
|
-
} catch {
|
|
845
|
-
|
|
398
|
+
const list = await fetchWCWalletList(projectId, controller.signal);
|
|
399
|
+
if (isMountedRef.current) setWalletList(list);
|
|
400
|
+
} catch (err) {
|
|
401
|
+
const isAbort = err instanceof DOMException && err.name === "AbortError";
|
|
402
|
+
if (!isAbort) loadedRef.current = false;
|
|
846
403
|
} finally {
|
|
847
|
-
setWalletListLoading(false);
|
|
404
|
+
if (isMountedRef.current) setWalletListLoading(false);
|
|
405
|
+
if (abortControllerRef.current === controller) abortControllerRef.current = null;
|
|
848
406
|
}
|
|
849
407
|
}, []);
|
|
850
408
|
const onShowList = useCallback2(() => setSubView("list"), []);
|
|
@@ -914,7 +472,7 @@ var IdleView = /* @__PURE__ */ __name(() => /* @__PURE__ */ React.createElement(
|
|
|
914
472
|
}, "Choose a wallet on the left to start connecting.")), "IdleView");
|
|
915
473
|
|
|
916
474
|
// src/views/CreditWalletView.tsx
|
|
917
|
-
import { useEffect as
|
|
475
|
+
import { useEffect as useEffect3, useMemo, useRef as useRef3 } from "react";
|
|
918
476
|
|
|
919
477
|
// src/components/QRFrame.tsx
|
|
920
478
|
import { QRCodeSVG } from "qrcode.react";
|
|
@@ -926,8 +484,8 @@ var QRFrame = /* @__PURE__ */ __name(({ qrUri, logoUrl }) => /* @__PURE__ */ Rea
|
|
|
926
484
|
level: "H",
|
|
927
485
|
imageSettings: logoUrl ? {
|
|
928
486
|
src: logoUrl,
|
|
929
|
-
width:
|
|
930
|
-
height:
|
|
487
|
+
width: 50,
|
|
488
|
+
height: 50,
|
|
931
489
|
excavate: true
|
|
932
490
|
} : void 0
|
|
933
491
|
}) : /* @__PURE__ */ React.createElement("div", {
|
|
@@ -940,7 +498,9 @@ var CopyLinkButton = /* @__PURE__ */ __name(({ qrUri }) => {
|
|
|
940
498
|
type: "button",
|
|
941
499
|
className: "ck-copy-link",
|
|
942
500
|
onClick: /* @__PURE__ */ __name(() => {
|
|
943
|
-
|
|
501
|
+
var _a;
|
|
502
|
+
(_a = navigator.clipboard) == null ? void 0 : _a.writeText(qrUri).catch(() => {
|
|
503
|
+
});
|
|
944
504
|
}, "onClick")
|
|
945
505
|
}, "Copy link");
|
|
946
506
|
}, "CopyLinkButton");
|
|
@@ -950,7 +510,7 @@ var CreditWalletView = /* @__PURE__ */ __name(({ connectorId, qrUri }) => {
|
|
|
950
510
|
const { downloadUrl: downloadUrl2, logoUrl, deepLinkBase: deepLinkBase2 } = CONNECTOR_META[connectorId];
|
|
951
511
|
const isMobile = useMemo(() => isMobileDevice(), []);
|
|
952
512
|
const hasRedirectedRef = useRef3(false);
|
|
953
|
-
|
|
513
|
+
useEffect3(() => {
|
|
954
514
|
if (isMobile && qrUri && deepLinkBase2 && !hasRedirectedRef.current) {
|
|
955
515
|
hasRedirectedRef.current = true;
|
|
956
516
|
tryOpenDeepLink(qrUri, deepLinkBase2);
|
|
@@ -989,12 +549,14 @@ var CreditWalletView = /* @__PURE__ */ __name(({ connectorId, qrUri }) => {
|
|
|
989
549
|
}, "CreditWalletView");
|
|
990
550
|
|
|
991
551
|
// src/views/MetaMaskView.tsx
|
|
992
|
-
import { useEffect as
|
|
552
|
+
import { useEffect as useEffect4, useMemo as useMemo2, useRef as useRef4 } from "react";
|
|
993
553
|
var { downloadUrl, deepLinkBase } = CONNECTOR_META.METAMASK;
|
|
994
554
|
var MetaMaskView = /* @__PURE__ */ __name(({ qrUri, hasExtension, logoUrl }) => {
|
|
995
555
|
const isMobile = useMemo2(() => isMobileDevice(), []);
|
|
996
|
-
|
|
997
|
-
|
|
556
|
+
const hasRedirectedRef = useRef4(false);
|
|
557
|
+
useEffect4(() => {
|
|
558
|
+
if (isMobile && qrUri && deepLinkBase && !hasRedirectedRef.current) {
|
|
559
|
+
hasRedirectedRef.current = true;
|
|
998
560
|
tryOpenDeepLink(qrUri, deepLinkBase);
|
|
999
561
|
}
|
|
1000
562
|
}, [
|
|
@@ -1208,11 +770,18 @@ var WalletQRView = /* @__PURE__ */ __name(({ wallet, qrUri }) => {
|
|
|
1208
770
|
}, "WalletQRView");
|
|
1209
771
|
|
|
1210
772
|
// src/views/SwitchChainView.tsx
|
|
1211
|
-
import { useState as useState2 } from "react";
|
|
773
|
+
import { useEffect as useEffect5, useRef as useRef5, useState as useState2 } from "react";
|
|
1212
774
|
import { useSwitchChain } from "wagmi";
|
|
1213
775
|
var SwitchChainView = /* @__PURE__ */ __name(({ currentChainId, requiredChainId, requiredChainName, onDisconnect, onLog }) => {
|
|
1214
776
|
const { switchChainAsync, isPending } = useSwitchChain();
|
|
1215
777
|
const [error, setError] = useState2(null);
|
|
778
|
+
const isMountedRef = useRef5(true);
|
|
779
|
+
useEffect5(() => {
|
|
780
|
+
isMountedRef.current = true;
|
|
781
|
+
return () => {
|
|
782
|
+
isMountedRef.current = false;
|
|
783
|
+
};
|
|
784
|
+
}, []);
|
|
1216
785
|
const targetLabel = requiredChainName != null ? requiredChainName : `chain ${requiredChainId}`;
|
|
1217
786
|
const handleSwitch = /* @__PURE__ */ __name(() => {
|
|
1218
787
|
setError(null);
|
|
@@ -1226,7 +795,7 @@ var SwitchChainView = /* @__PURE__ */ __name(({ currentChainId, requiredChainId,
|
|
|
1226
795
|
} else {
|
|
1227
796
|
onLog == null ? void 0 : onLog(`[connect-kit] switch chain failed: ${normalized.message}`, normalized);
|
|
1228
797
|
}
|
|
1229
|
-
setError(normalized);
|
|
798
|
+
if (isMountedRef.current) setError(normalized);
|
|
1230
799
|
});
|
|
1231
800
|
}, "handleSwitch");
|
|
1232
801
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -1253,25 +822,41 @@ var SwitchChainView = /* @__PURE__ */ __name(({ currentChainId, requiredChainId,
|
|
|
1253
822
|
|
|
1254
823
|
// src/ConnectModal.tsx
|
|
1255
824
|
var RECENT_KEY = "connect-kit:recent";
|
|
825
|
+
var VALID_CONNECTOR_IDS = /* @__PURE__ */ new Set([
|
|
826
|
+
"CREDIT_CONNECT",
|
|
827
|
+
"CREDIT_WALLET",
|
|
828
|
+
"METAMASK",
|
|
829
|
+
"WALLET_CONNECT"
|
|
830
|
+
]);
|
|
1256
831
|
var readRecentConnector = /* @__PURE__ */ __name(() => {
|
|
1257
832
|
try {
|
|
1258
|
-
|
|
833
|
+
const raw = localStorage.getItem(RECENT_KEY);
|
|
834
|
+
if (raw == null) return null;
|
|
835
|
+
return VALID_CONNECTOR_IDS.has(raw) ? raw : null;
|
|
1259
836
|
} catch {
|
|
1260
837
|
return null;
|
|
1261
838
|
}
|
|
1262
839
|
}, "readRecentConnector");
|
|
1263
|
-
var writeRecentConnector = /* @__PURE__ */ __name((id) => {
|
|
840
|
+
var writeRecentConnector = /* @__PURE__ */ __name((id, onLog) => {
|
|
1264
841
|
try {
|
|
1265
842
|
localStorage.setItem(RECENT_KEY, id);
|
|
1266
|
-
} catch {
|
|
843
|
+
} catch (err) {
|
|
844
|
+
const normalized = err instanceof Error ? err : new Error(String(err));
|
|
845
|
+
onLog == null ? void 0 : onLog(`[connect-kit] writeRecentConnector failed: ${normalized.message}`, normalized);
|
|
1267
846
|
}
|
|
1268
847
|
}, "writeRecentConnector");
|
|
848
|
+
var REJECTED_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
849
|
+
4001,
|
|
850
|
+
"ACTION_REJECTED"
|
|
851
|
+
]);
|
|
1269
852
|
var classifyError = /* @__PURE__ */ __name((error) => {
|
|
1270
853
|
var _a, _b;
|
|
1271
854
|
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
1272
|
-
if (code
|
|
855
|
+
if (code != null && REJECTED_ERROR_CODES.has(code)) return "rejected";
|
|
1273
856
|
const message = (_b = (_a = error.message) == null ? void 0 : _a.toLowerCase()) != null ? _b : "";
|
|
1274
|
-
if (message.includes("user rejected") || message.includes("user denied"))
|
|
857
|
+
if (message.includes("user rejected") || message.includes("user denied") || message.includes("user cancel") || message.includes("rejected by user") || message.includes("action_rejected") || message.includes("\uC0AC\uC6A9\uC790\uAC00 \uAC70\uBD80") || message.includes("\uC0AC\uC6A9\uC790\uAC00 \uCDE8\uC18C") || message.includes("\u30E6\u30FC\u30B6\u30FC\u304C\u62D2\u5426") || message.includes("\u30E6\u30FC\u30B6\u30FC\u304C\u30AD\u30E3\u30F3\u30BB\u30EB")) {
|
|
858
|
+
return "rejected";
|
|
859
|
+
}
|
|
1275
860
|
if (message.includes("unsupported") || message.includes("not installed")) return "unsupported";
|
|
1276
861
|
return "unknown";
|
|
1277
862
|
}, "classifyError");
|
|
@@ -1485,11 +1070,11 @@ var ConnectModalInner = /* @__PURE__ */ __name(({ open, connectors, onConnect, o
|
|
|
1485
1070
|
}, [
|
|
1486
1071
|
wagmiConfig.connectors
|
|
1487
1072
|
]);
|
|
1488
|
-
|
|
1073
|
+
useEffect6(() => {
|
|
1489
1074
|
setRecentConnector(readRecentConnector());
|
|
1490
1075
|
setHasMetaMaskExtension(detectMetaMaskExtension());
|
|
1491
1076
|
}, []);
|
|
1492
|
-
|
|
1077
|
+
useEffect6(() => {
|
|
1493
1078
|
if (!open) {
|
|
1494
1079
|
setSelectedConnector(null);
|
|
1495
1080
|
setQrUri(null);
|
|
@@ -1508,7 +1093,7 @@ var ConnectModalInner = /* @__PURE__ */ __name(({ open, connectors, onConnect, o
|
|
|
1508
1093
|
setQrUri(null);
|
|
1509
1094
|
setErrorState(null);
|
|
1510
1095
|
wc.resetView();
|
|
1511
|
-
writeRecentConnector(id);
|
|
1096
|
+
writeRecentConnector(id, onLog);
|
|
1512
1097
|
setRecentConnector(id);
|
|
1513
1098
|
if (id === "WALLET_CONNECT" && wcProjectId) {
|
|
1514
1099
|
wc.loadWalletList(wcProjectId);
|
|
@@ -1522,7 +1107,8 @@ var ConnectModalInner = /* @__PURE__ */ __name(({ open, connectors, onConnect, o
|
|
|
1522
1107
|
cancelConnect,
|
|
1523
1108
|
wcProjectId,
|
|
1524
1109
|
wc.resetView,
|
|
1525
|
-
wc.loadWalletList
|
|
1110
|
+
wc.loadWalletList,
|
|
1111
|
+
onLog
|
|
1526
1112
|
]);
|
|
1527
1113
|
const handleBack = useCallback3(() => {
|
|
1528
1114
|
if (errorState) {
|
|
@@ -1653,8 +1239,8 @@ var ConnectModalInner = /* @__PURE__ */ __name(({ open, connectors, onConnect, o
|
|
|
1653
1239
|
}, "ConnectModalInner");
|
|
1654
1240
|
|
|
1655
1241
|
// src/ConnectKitProvider.tsx
|
|
1656
|
-
import { createContext, useCallback as useCallback4, useContext, useEffect as
|
|
1657
|
-
import { WagmiProvider, useAccount as useAccount2, useDisconnect as useDisconnect2 } from "wagmi";
|
|
1242
|
+
import { createContext, useCallback as useCallback4, useContext, useEffect as useEffect7, useMemo as useMemo5, useRef as useRef6, useState as useState4 } from "react";
|
|
1243
|
+
import { WagmiProvider, useAccount as useAccount2, useDisconnect as useDisconnect2, useSwitchChain as useSwitchChain2 } from "wagmi";
|
|
1658
1244
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
1659
1245
|
var internalQueryClient = new QueryClient();
|
|
1660
1246
|
var ConnectKitContext = /* @__PURE__ */ createContext(null);
|
|
@@ -1668,29 +1254,80 @@ var resolveConnectorId = /* @__PURE__ */ __name((wagmiConnectorId) => {
|
|
|
1668
1254
|
return null;
|
|
1669
1255
|
}, "resolveConnectorId");
|
|
1670
1256
|
var ConnectKitProvider = /* @__PURE__ */ __name((props) => {
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1257
|
+
var _a;
|
|
1258
|
+
const wagmiConfig = useMemo5(() => props.kitConfig ? initConfig(props.kitConfig) : getConfig(), [
|
|
1259
|
+
props.kitConfig
|
|
1260
|
+
]);
|
|
1261
|
+
const resolvedKitConfig = (_a = props.kitConfig) != null ? _a : getKitConfig();
|
|
1262
|
+
return /* @__PURE__ */ React.createElement(WagmiProvider, {
|
|
1263
|
+
config: wagmiConfig,
|
|
1264
|
+
reconnectOnMount: false
|
|
1265
|
+
}, /* @__PURE__ */ React.createElement(QueryClientProvider, {
|
|
1266
|
+
client: internalQueryClient
|
|
1267
|
+
}, /* @__PURE__ */ React.createElement(ConnectKitProviderInner, {
|
|
1268
|
+
...props,
|
|
1269
|
+
kitConfig: resolvedKitConfig
|
|
1270
|
+
})));
|
|
1679
1271
|
}, "ConnectKitProvider");
|
|
1680
|
-
var ConnectKitProviderInner = /* @__PURE__ */ __name(({ children, connectors,
|
|
1272
|
+
var ConnectKitProviderInner = /* @__PURE__ */ __name(({ children, connectors, kitConfig, requiredChainId, onConnect, onLog, renderConnectError }) => {
|
|
1681
1273
|
var _a;
|
|
1682
1274
|
const [isOpen, setIsOpen] = useState4(false);
|
|
1683
1275
|
const [pendingResult, setPendingResult] = useState4(null);
|
|
1684
1276
|
const account = useAccount2();
|
|
1685
1277
|
const { disconnectAsync } = useDisconnect2();
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1278
|
+
const { switchChainAsync } = useSwitchChain2();
|
|
1279
|
+
const onConnectRef = useRef6(onConnect);
|
|
1280
|
+
useEffect7(() => {
|
|
1688
1281
|
onConnectRef.current = onConnect;
|
|
1689
1282
|
}, [
|
|
1690
1283
|
onConnect
|
|
1691
1284
|
]);
|
|
1692
1285
|
const chainMismatch = requiredChainId != null && account.status === "connected" && account.chainId != null && account.chainId !== requiredChainId;
|
|
1693
|
-
const
|
|
1286
|
+
const [autoSwitchFailedKey, setAutoSwitchFailedKey] = useState4(null);
|
|
1287
|
+
const autoSwitchInFlightRef = useRef6(false);
|
|
1288
|
+
const isMountedRef = useRef6(true);
|
|
1289
|
+
useEffect7(() => {
|
|
1290
|
+
isMountedRef.current = true;
|
|
1291
|
+
return () => {
|
|
1292
|
+
isMountedRef.current = false;
|
|
1293
|
+
};
|
|
1294
|
+
}, []);
|
|
1295
|
+
const mismatchKey = chainMismatch && account.chainId != null && requiredChainId != null ? `${account.chainId}->${requiredChainId}` : null;
|
|
1296
|
+
useEffect7(() => {
|
|
1297
|
+
if (!chainMismatch || requiredChainId == null) return;
|
|
1298
|
+
if (autoSwitchInFlightRef.current) return;
|
|
1299
|
+
if (mismatchKey != null && mismatchKey === autoSwitchFailedKey) return;
|
|
1300
|
+
autoSwitchInFlightRef.current = true;
|
|
1301
|
+
switchChainAsync({
|
|
1302
|
+
chainId: requiredChainId
|
|
1303
|
+
}).catch((err) => {
|
|
1304
|
+
if (!isMountedRef.current) return;
|
|
1305
|
+
const normalized = err instanceof Error ? err : new Error(String(err));
|
|
1306
|
+
onLog == null ? void 0 : onLog(`[connect-kit] silent switch chain failed: ${normalized.message}`, normalized);
|
|
1307
|
+
if (mismatchKey != null) {
|
|
1308
|
+
setAutoSwitchFailedKey(mismatchKey);
|
|
1309
|
+
}
|
|
1310
|
+
}).finally(() => {
|
|
1311
|
+
autoSwitchInFlightRef.current = false;
|
|
1312
|
+
});
|
|
1313
|
+
}, [
|
|
1314
|
+
chainMismatch,
|
|
1315
|
+
mismatchKey,
|
|
1316
|
+
requiredChainId,
|
|
1317
|
+
autoSwitchFailedKey,
|
|
1318
|
+
switchChainAsync,
|
|
1319
|
+
onLog
|
|
1320
|
+
]);
|
|
1321
|
+
useEffect7(() => {
|
|
1322
|
+
if (!chainMismatch && autoSwitchFailedKey != null) {
|
|
1323
|
+
setAutoSwitchFailedKey(null);
|
|
1324
|
+
}
|
|
1325
|
+
}, [
|
|
1326
|
+
chainMismatch,
|
|
1327
|
+
autoSwitchFailedKey
|
|
1328
|
+
]);
|
|
1329
|
+
const autoSwitchFailedForCurrent = mismatchKey != null && mismatchKey === autoSwitchFailedKey;
|
|
1330
|
+
const effectiveOpen = isOpen || chainMismatch && autoSwitchFailedForCurrent;
|
|
1694
1331
|
const open = useCallback4(() => {
|
|
1695
1332
|
setIsOpen(true);
|
|
1696
1333
|
}, []);
|
|
@@ -1705,7 +1342,7 @@ var ConnectKitProviderInner = /* @__PURE__ */ __name(({ children, connectors, wc
|
|
|
1705
1342
|
const handleModalConnect = useCallback4((result) => {
|
|
1706
1343
|
setPendingResult(result);
|
|
1707
1344
|
}, []);
|
|
1708
|
-
|
|
1345
|
+
useEffect7(() => {
|
|
1709
1346
|
var _a2;
|
|
1710
1347
|
if (!pendingResult) return;
|
|
1711
1348
|
if (account.status !== "connected") {
|
|
@@ -1749,7 +1386,7 @@ var ConnectKitProviderInner = /* @__PURE__ */ __name(({ children, connectors, wc
|
|
|
1749
1386
|
}, children, /* @__PURE__ */ React.createElement(ConnectModal, {
|
|
1750
1387
|
open: effectiveOpen,
|
|
1751
1388
|
connectors,
|
|
1752
|
-
wcProjectId,
|
|
1389
|
+
wcProjectId: kitConfig.wcProjectId,
|
|
1753
1390
|
requiredChainId,
|
|
1754
1391
|
renderConnectError,
|
|
1755
1392
|
onConnect: handleModalConnect,
|
|
@@ -1764,8 +1401,31 @@ var useConnectKit = /* @__PURE__ */ __name(() => {
|
|
|
1764
1401
|
}
|
|
1765
1402
|
return ctx;
|
|
1766
1403
|
}, "useConnectKit");
|
|
1404
|
+
|
|
1405
|
+
// src/index.ts
|
|
1406
|
+
var connectKit = {
|
|
1407
|
+
api: {
|
|
1408
|
+
readContract,
|
|
1409
|
+
writeContract,
|
|
1410
|
+
getBalance,
|
|
1411
|
+
switchChain,
|
|
1412
|
+
getPublicClient,
|
|
1413
|
+
waitForTransactionReceipt,
|
|
1414
|
+
getAccount,
|
|
1415
|
+
signMessage,
|
|
1416
|
+
signTypedData
|
|
1417
|
+
},
|
|
1418
|
+
events: {
|
|
1419
|
+
watchAccount,
|
|
1420
|
+
watchConnections,
|
|
1421
|
+
reconnect,
|
|
1422
|
+
disconnectAll
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1767
1425
|
export {
|
|
1768
1426
|
ConnectKitProvider,
|
|
1769
1427
|
ConnectModal,
|
|
1428
|
+
connectKit,
|
|
1429
|
+
initConfig,
|
|
1770
1430
|
useConnectKit
|
|
1771
1431
|
};
|