@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/dist/index.css ADDED
@@ -0,0 +1,561 @@
1
+ /* src/ConnectModal.scss */
2
+ .ck-root {
3
+ position: fixed;
4
+ inset: 0;
5
+ z-index: 9999;
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ }
10
+ .ck-overlay {
11
+ position: absolute;
12
+ inset: 0;
13
+ background: rgba(0, 0, 0, 0.6);
14
+ }
15
+ .ck-modal {
16
+ position: relative;
17
+ display: flex;
18
+ width: 1120px;
19
+ height: 620px;
20
+ border-radius: 16px;
21
+ overflow: hidden;
22
+ background: #1a1a1a;
23
+ color: #fff;
24
+ }
25
+ .ck-pane {
26
+ display: flex;
27
+ flex-direction: column;
28
+ padding: 24px;
29
+ width: 560px;
30
+ flex-shrink: 0;
31
+ box-sizing: border-box;
32
+ }
33
+ .ck-pane--selector {
34
+ border-right: 1px solid rgba(255, 255, 255, 0.08);
35
+ }
36
+ .ck-pane--detail {
37
+ padding-inline: 20px;
38
+ overflow: hidden;
39
+ min-height: 0;
40
+ }
41
+ .ck-pane__header {
42
+ display: flex;
43
+ align-items: center;
44
+ gap: 8px;
45
+ margin-bottom: 20px;
46
+ }
47
+ .ck-pane__title {
48
+ flex: 1;
49
+ font-size: 16px;
50
+ font-weight: 600;
51
+ margin: 0;
52
+ }
53
+ .ck-pane__body {
54
+ flex: 1;
55
+ display: flex;
56
+ flex-direction: column;
57
+ min-height: 0;
58
+ overflow: hidden;
59
+ }
60
+ .ck-pane__footer {
61
+ margin-top: auto;
62
+ padding-top: 16px;
63
+ text-align: center;
64
+ }
65
+ .ck-btn-close,
66
+ .ck-btn-back {
67
+ position: relative;
68
+ width: 28px;
69
+ height: 28px;
70
+ background: none;
71
+ border: none;
72
+ cursor: pointer;
73
+ padding: 0;
74
+ border-radius: 50%;
75
+ flex-shrink: 0;
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: center;
79
+ }
80
+ .ck-btn-close:hover,
81
+ .ck-btn-back:hover {
82
+ background: rgba(255, 255, 255, 0.08);
83
+ }
84
+ .ck-btn-close::before,
85
+ .ck-btn-close::after {
86
+ content: "";
87
+ position: absolute;
88
+ width: 14px;
89
+ height: 2px;
90
+ background: rgba(255, 255, 255, 0.7);
91
+ border-radius: 1px;
92
+ }
93
+ .ck-btn-close::before {
94
+ transform: rotate(45deg);
95
+ }
96
+ .ck-btn-close::after {
97
+ transform: rotate(-45deg);
98
+ }
99
+ .ck-btn-back::before {
100
+ content: "";
101
+ position: absolute;
102
+ width: 8px;
103
+ height: 8px;
104
+ border-left: 2px solid rgba(255, 255, 255, 0.7);
105
+ border-bottom: 2px solid rgba(255, 255, 255, 0.7);
106
+ transform: rotate(45deg) translate(1px, -1px);
107
+ border-radius: 1px;
108
+ }
109
+ .ck-btn-primary {
110
+ display: inline-flex;
111
+ align-items: center;
112
+ justify-content: center;
113
+ padding: 8px 16px;
114
+ border-radius: 8px;
115
+ font-size: 14px;
116
+ font-weight: 600;
117
+ text-decoration: none;
118
+ cursor: pointer;
119
+ white-space: nowrap;
120
+ color: #fff;
121
+ background: rgba(255, 255, 255, 0.15);
122
+ border: none;
123
+ }
124
+ .ck-btn-primary:hover {
125
+ background: rgba(255, 255, 255, 0.22);
126
+ }
127
+ .ck-btn-primary:disabled {
128
+ opacity: 0.6;
129
+ cursor: not-allowed;
130
+ }
131
+ .ck-btn-secondary {
132
+ display: inline-flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ padding: 8px 16px;
136
+ border-radius: 8px;
137
+ font-size: 14px;
138
+ font-weight: 500;
139
+ cursor: pointer;
140
+ white-space: nowrap;
141
+ color: rgba(255, 255, 255, 0.75);
142
+ background: transparent;
143
+ border: 1px solid rgba(255, 255, 255, 0.18);
144
+ }
145
+ .ck-btn-secondary:hover {
146
+ color: #fff;
147
+ border-color: rgba(255, 255, 255, 0.32);
148
+ }
149
+ .ck-view__actions {
150
+ display: flex;
151
+ flex-direction: column;
152
+ gap: 8px;
153
+ width: 100%;
154
+ margin-top: 16px;
155
+ }
156
+ .ck-view__caption--error {
157
+ color: #ff8080;
158
+ margin-top: 8px;
159
+ }
160
+ .ck-connector-list {
161
+ display: flex;
162
+ flex-direction: column;
163
+ gap: 8px;
164
+ }
165
+ .ck-connector-item {
166
+ display: flex;
167
+ align-items: center;
168
+ gap: 12px;
169
+ width: 100%;
170
+ padding: 12px 16px;
171
+ border: none;
172
+ border-radius: 12px;
173
+ cursor: pointer;
174
+ text-align: left;
175
+ color: #fff;
176
+ background: rgba(255, 255, 255, 0.05);
177
+ transition: background 0.15s;
178
+ }
179
+ .ck-connector-item:hover:not(:disabled) {
180
+ background: rgba(255, 255, 255, 0.08);
181
+ }
182
+ .ck-connector-item.is-active {
183
+ background: #3b82f6;
184
+ }
185
+ .ck-connector-item:disabled {
186
+ opacity: 0.5;
187
+ cursor: not-allowed;
188
+ }
189
+ .ck-connector-item__icon {
190
+ width: 32px;
191
+ height: 32px;
192
+ border-radius: 8px;
193
+ flex-shrink: 0;
194
+ background: rgba(255, 255, 255, 0.1);
195
+ display: block;
196
+ object-fit: cover;
197
+ }
198
+ .ck-connector-item__icon[src] {
199
+ background: none;
200
+ }
201
+ .ck-connector-item__label {
202
+ flex: 1;
203
+ font-size: 14px;
204
+ font-weight: 500;
205
+ }
206
+ .ck-connector-item__badge {
207
+ font-size: 11px;
208
+ font-weight: 600;
209
+ padding: 2px 6px;
210
+ border-radius: 4px;
211
+ background: rgba(255, 255, 255, 0.15);
212
+ color: rgba(255, 255, 255, 0.8);
213
+ }
214
+ .ck-divider {
215
+ display: flex;
216
+ align-items: center;
217
+ gap: 8px;
218
+ color: rgba(255, 255, 255, 0.3);
219
+ font-size: 12px;
220
+ margin: 4px 0;
221
+ }
222
+ .ck-divider::before,
223
+ .ck-divider::after {
224
+ content: "";
225
+ flex: 1;
226
+ height: 1px;
227
+ background: rgba(255, 255, 255, 0.1);
228
+ }
229
+ .ck-link-no-wallet {
230
+ font-size: 13px;
231
+ text-decoration: none;
232
+ color: rgba(255, 255, 255, 0.5);
233
+ }
234
+ .ck-view {
235
+ display: flex;
236
+ flex-direction: column;
237
+ align-items: center;
238
+ flex: 1;
239
+ }
240
+ .ck-view--idle {
241
+ justify-content: center;
242
+ text-align: center;
243
+ gap: 12px;
244
+ }
245
+ .ck-view--qr {
246
+ gap: 16px;
247
+ }
248
+ .ck-view--extension {
249
+ justify-content: center;
250
+ align-items: center;
251
+ gap: 12px;
252
+ text-align: center;
253
+ }
254
+ .ck-view--wallet-list {
255
+ align-items: stretch;
256
+ gap: 12px;
257
+ height: 100%;
258
+ overflow: hidden;
259
+ width: 100%;
260
+ box-sizing: border-box;
261
+ }
262
+ .ck-view__illustration {
263
+ width: 180px;
264
+ height: auto;
265
+ display: block;
266
+ }
267
+ .ck-view__wallet-icon {
268
+ width: 64px;
269
+ height: 64px;
270
+ border-radius: 16px;
271
+ background: rgba(255, 255, 255, 0.1);
272
+ }
273
+ .ck-view__title {
274
+ font-size: 18px;
275
+ font-weight: 600;
276
+ margin: 0;
277
+ }
278
+ .ck-view__description,
279
+ .ck-view__caption {
280
+ font-size: 13px;
281
+ opacity: 0.6;
282
+ margin: 0;
283
+ text-align: center;
284
+ }
285
+ .ck-qr-frame {
286
+ width: 216px;
287
+ height: 216px;
288
+ border-radius: 16px;
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: center;
292
+ background: #fff;
293
+ overflow: hidden;
294
+ flex-shrink: 0;
295
+ }
296
+ .ck-qr-frame--loading {
297
+ background: rgba(255, 255, 255, 0.05);
298
+ }
299
+ .ck-qr-spinner,
300
+ .ck-spinner {
301
+ width: 32px;
302
+ height: 32px;
303
+ border: 3px solid rgba(255, 255, 255, 0.15);
304
+ border-top-color: rgba(255, 255, 255, 0.6);
305
+ border-radius: 50%;
306
+ animation: ck-spin 0.8s linear infinite;
307
+ }
308
+ @keyframes ck-spin {
309
+ to {
310
+ transform: rotate(360deg);
311
+ }
312
+ }
313
+ .ck-copy-link {
314
+ background: none;
315
+ border: none;
316
+ cursor: pointer;
317
+ font-size: 13px;
318
+ color: #fff;
319
+ opacity: 0.5;
320
+ display: flex;
321
+ align-items: center;
322
+ gap: 4px;
323
+ }
324
+ .ck-download-card {
325
+ display: flex;
326
+ align-items: center;
327
+ justify-content: space-between;
328
+ width: 100%;
329
+ padding: 14px 16px;
330
+ border-radius: 12px;
331
+ background: rgba(255, 255, 255, 0.05);
332
+ margin-top: auto;
333
+ gap: 12px;
334
+ }
335
+ .ck-download-card__text {
336
+ display: flex;
337
+ flex-direction: column;
338
+ gap: 2px;
339
+ }
340
+ .ck-download-card__title {
341
+ font-size: 14px;
342
+ font-weight: 500;
343
+ margin: 0;
344
+ }
345
+ .ck-download-card__sub {
346
+ font-size: 12px;
347
+ opacity: 0.5;
348
+ margin: 0;
349
+ }
350
+ .ck-all-wallets-btn {
351
+ display: flex;
352
+ align-items: center;
353
+ gap: 12px;
354
+ width: 100%;
355
+ padding: 14px 16px;
356
+ border: none;
357
+ border-radius: 12px;
358
+ background: rgba(255, 255, 255, 0.05);
359
+ color: #fff;
360
+ cursor: pointer;
361
+ margin-top: auto;
362
+ }
363
+ .ck-all-wallets-btn__icon {
364
+ width: 32px;
365
+ height: 32px;
366
+ border-radius: 8px;
367
+ background: rgba(255, 255, 255, 0.1);
368
+ }
369
+ .ck-all-wallets-btn__label {
370
+ flex: 1;
371
+ font-size: 14px;
372
+ font-weight: 500;
373
+ text-align: left;
374
+ }
375
+ .ck-all-wallets-btn__count {
376
+ font-size: 12px;
377
+ opacity: 0.5;
378
+ }
379
+ .ck-wallet-search {
380
+ display: flex;
381
+ align-items: center;
382
+ gap: 8px;
383
+ }
384
+ .ck-wallet-search__input {
385
+ flex: 1;
386
+ padding: 10px 14px;
387
+ border-radius: 10px;
388
+ border: 1px solid rgba(255, 255, 255, 0.1);
389
+ background: rgba(255, 255, 255, 0.05);
390
+ font-size: 14px;
391
+ outline: none;
392
+ color: #fff;
393
+ }
394
+ .ck-wallet-search__input::placeholder {
395
+ color: rgba(255, 255, 255, 0.35);
396
+ }
397
+ .ck-wc-filter {
398
+ display: flex;
399
+ align-items: center;
400
+ gap: 6px;
401
+ flex-shrink: 0;
402
+ border: none;
403
+ background: none;
404
+ cursor: pointer;
405
+ padding: 0;
406
+ }
407
+ .ck-wc-filter__icon {
408
+ width: 20px;
409
+ height: 20px;
410
+ border-radius: 4px;
411
+ display: block;
412
+ opacity: 0.5;
413
+ }
414
+ .ck-wc-filter.is-active .ck-wc-filter__icon {
415
+ opacity: 1;
416
+ }
417
+ .ck-wc-filter__track {
418
+ position: relative;
419
+ width: 36px;
420
+ height: 20px;
421
+ border-radius: 10px;
422
+ background: rgba(255, 255, 255, 0.15);
423
+ transition: background 0.2s;
424
+ }
425
+ .ck-wc-filter.is-active .ck-wc-filter__track {
426
+ background: #3b82f6;
427
+ }
428
+ .ck-wc-filter__thumb {
429
+ position: absolute;
430
+ top: 2px;
431
+ left: 2px;
432
+ width: 16px;
433
+ height: 16px;
434
+ border-radius: 50%;
435
+ background: #fff;
436
+ transition: transform 0.2s;
437
+ }
438
+ .ck-wc-filter.is-active .ck-wc-filter__thumb {
439
+ transform: translateX(16px);
440
+ }
441
+ .ck-wallet-grid-scroll {
442
+ flex: 1;
443
+ min-height: 0;
444
+ width: 100%;
445
+ overflow-x: hidden;
446
+ overflow-y: auto;
447
+ }
448
+ .ck-wallet-grid {
449
+ display: grid;
450
+ grid-template-columns: repeat(4, minmax(0, 1fr));
451
+ grid-auto-rows: max-content;
452
+ gap: 8px;
453
+ list-style: none;
454
+ margin: 0;
455
+ padding: 0;
456
+ width: 100%;
457
+ box-sizing: border-box;
458
+ }
459
+ .ck-wallet-grid__item {
460
+ display: flex;
461
+ flex-direction: column;
462
+ align-items: center;
463
+ gap: 6px;
464
+ padding: 10px 4px;
465
+ width: 100%;
466
+ background: none;
467
+ border: none;
468
+ border-radius: 10px;
469
+ cursor: pointer;
470
+ color: #fff;
471
+ box-sizing: border-box;
472
+ }
473
+ .ck-wallet-grid__item:hover {
474
+ background: rgba(255, 255, 255, 0.05);
475
+ }
476
+ .ck-wallet-grid__icon {
477
+ width: 48px;
478
+ height: 48px;
479
+ border-radius: 12px;
480
+ flex-shrink: 0;
481
+ }
482
+ .ck-wallet-grid__icon-placeholder {
483
+ width: 48px;
484
+ height: 48px;
485
+ border-radius: 12px;
486
+ flex-shrink: 0;
487
+ background: rgba(255, 255, 255, 0.1);
488
+ }
489
+ .ck-wallet-grid__name {
490
+ display: flex;
491
+ align-items: center;
492
+ justify-content: center;
493
+ gap: 3px;
494
+ width: 100%;
495
+ min-width: 0;
496
+ }
497
+ .ck-wallet-grid__name-text {
498
+ flex: 1;
499
+ min-width: 0;
500
+ font-size: 11px;
501
+ overflow: hidden;
502
+ text-overflow: ellipsis;
503
+ white-space: nowrap;
504
+ }
505
+ .ck-wallet-grid__wc-badge {
506
+ width: 10px;
507
+ height: 10px;
508
+ border-radius: 2px;
509
+ flex-shrink: 0;
510
+ opacity: 0.7;
511
+ }
512
+ .ck-wallet-list-loading,
513
+ .ck-wallet-list-empty {
514
+ display: flex;
515
+ align-items: center;
516
+ justify-content: center;
517
+ padding: 32px;
518
+ opacity: 0.4;
519
+ }
520
+ .ck-mobile-only {
521
+ display: none;
522
+ }
523
+ @media (max-width: 1120px) {
524
+ .ck-root {
525
+ align-items: flex-end;
526
+ }
527
+ .ck-modal {
528
+ flex-direction: column;
529
+ width: 100%;
530
+ height: auto;
531
+ max-height: 90dvh;
532
+ border-radius: 20px 20px 0 0;
533
+ animation: ck-slide-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
534
+ overflow-y: auto;
535
+ }
536
+ @keyframes ck-slide-up {
537
+ from {
538
+ transform: translateY(100%);
539
+ }
540
+ to {
541
+ transform: translateY(0);
542
+ }
543
+ }
544
+ .ck-modal:not(.ck-modal--has-detail) .ck-pane--detail {
545
+ display: none;
546
+ }
547
+ .ck-modal.ck-modal--has-detail .ck-pane--selector {
548
+ display: none;
549
+ }
550
+ .ck-pane--selector,
551
+ .ck-pane--detail {
552
+ width: 100%;
553
+ border-right: none;
554
+ }
555
+ .ck-pane--detail {
556
+ min-height: 420px;
557
+ }
558
+ .ck-mobile-only {
559
+ display: block;
560
+ }
561
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,21 @@
1
+ import * as viem from 'viem';
2
+ import { Abi, ContractFunctionName, ContractFunctionArgs, Chain, Transport } from 'viem';
3
+ import * as _wagmi_core from '@wagmi/core';
4
+ import { ReadContractParameters, Config, ReadContractReturnType, WriteContractParameters, WriteContractReturnType } from '@wagmi/core';
5
+ export * from '@wagmi/core';
1
6
  import { ReactNode, FC } from 'react';
2
- import { Config } from 'wagmi';
7
+ import { CreateConnectorFn, Config as Config$1 } from 'wagmi';
8
+
9
+ declare function readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, 'pure' | 'view'>, args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>>(parameters: ReadContractParameters<abi, functionName, args, Config>): Promise<ReadContractReturnType<abi, functionName, args>>;
10
+ declare function writeContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>, args extends ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>>(parameters: WriteContractParameters<abi, functionName, args, Config>): Promise<WriteContractReturnType>;
3
11
 
4
12
  type ConnectorId = 'CREDIT_WALLET' | 'CREDIT_CONNECT' | 'METAMASK' | 'WALLET_CONNECT';
13
+ interface ConnectKitConfig {
14
+ chains: [Chain, ...Chain[]];
15
+ transports: Record<number, Transport>;
16
+ wcProjectId?: string;
17
+ extraConnectors?: CreateConnectorFn[];
18
+ }
5
19
  type CreditWalletStrategy = 'walletConnect' | 'creditConnect';
6
20
  interface Connectors {
7
21
  creditWallet?: CreditWalletStrategy | false;
@@ -48,34 +62,12 @@ declare const ConnectModal: FC<ConnectModalProps>;
48
62
 
49
63
  interface ConnectKitProviderProps {
50
64
  children: ReactNode;
65
+ kitConfig?: ConnectKitConfig;
51
66
  connectors: Connectors;
52
- wcProjectId?: string;
53
- /**
54
- * 연결돼 있는 동안 강제할 체인 ID. 다른 체인에 연결돼 있으면
55
- * 자동으로 스위치 모달이 떠서 사용자에게 전환 또는 disconnect를 요구.
56
- */
57
67
  requiredChainId?: number;
58
- /**
59
- * 연결이 정상적으로 끝나고(체인 검증까지 통과) "사용 가능한 상태"가 됐을 때 한 번 호출.
60
- * 재연결(reconnect)에서는 호출되지 않음 — 그쪽은 dApp의 watchAccount 책임.
61
- */
62
68
  onConnect?: (result: ConnectResult) => void;
63
69
  onLog?: (message: string, error?: Error) => void;
64
- /**
65
- * 연결 실패(거절/미설치/기타) 시 모달 안에 표시할 fallback UI를 dApp이 직접 그리고 싶을 때.
66
- * 미제공 시 기본 동작은 selector로 복귀.
67
- */
68
70
  renderConnectError?: (ctx: ConnectErrorContext) => ReactNode;
69
- /**
70
- * 기존 프로젝트 통합용. wagmi config를 넘기면 ConnectKitProvider 내부에서
71
- * WagmiProvider를 직접 세운다.
72
- *
73
- * - 기존 프로젝트: 앱에 WagmiProvider가 없으므로 wagmiConfig를 넘긴다.
74
- * ConnectKitProvider가 같은 config 인스턴스로 WagmiProvider를 셀프 마운트하므로
75
- * 기존 wagmi 상태 store와 단일 config를 공유한다.
76
- * - 신규 프로젝트: 앱이 이미 WagmiProvider를 감싸므로 이 prop은 불필요하다.
77
- */
78
- wagmiConfig?: Config;
79
71
  }
80
72
  interface ConnectKitContextValue {
81
73
  isOpen: boolean;
@@ -89,4 +81,26 @@ interface ConnectKitContextValue {
89
81
  declare const ConnectKitProvider: FC<ConnectKitProviderProps>;
90
82
  declare const useConnectKit: () => ConnectKitContextValue;
91
83
 
92
- export { type ConnectErrorContext, type ConnectErrorReason, type ConnectKitContextValue, ConnectKitProvider, type ConnectKitProviderProps, ConnectModal, type ConnectModalProps, type ConnectResult, type ConnectorId, type Connectors, type CreditWalletStrategy, type WCSubView, type WCWallet, useConnectKit };
84
+ declare const initConfig: (kitConfig: ConnectKitConfig) => Config$1;
85
+
86
+ declare const connectKit: {
87
+ readonly api: {
88
+ readonly readContract: typeof readContract;
89
+ readonly writeContract: typeof writeContract;
90
+ readonly getBalance: (params: _wagmi_core.GetBalanceParameters) => Promise<_wagmi_core.GetBalanceReturnType>;
91
+ readonly switchChain: (params: _wagmi_core.SwitchChainParameters) => Promise<viem.Chain>;
92
+ readonly getPublicClient: (params?: _wagmi_core.GetPublicClientParameters) => _wagmi_core.GetPublicClientReturnType;
93
+ readonly waitForTransactionReceipt: (params: _wagmi_core.WaitForTransactionReceiptParameters) => Promise<_wagmi_core.WaitForTransactionReceiptReturnType>;
94
+ readonly getAccount: () => _wagmi_core.GetAccountReturnType;
95
+ readonly signMessage: (params: _wagmi_core.SignMessageParameters) => Promise<`0x${string}`>;
96
+ readonly signTypedData: (params: _wagmi_core.SignTypedDataParameters) => Promise<`0x${string}`>;
97
+ };
98
+ readonly events: {
99
+ readonly watchAccount: (params: _wagmi_core.WatchAccountParameters) => (() => void);
100
+ readonly watchConnections: (params: _wagmi_core.WatchConnectionsParameters) => (() => void);
101
+ readonly reconnect: () => Promise<_wagmi_core.ReconnectReturnType>;
102
+ readonly disconnectAll: (onLog?: (message: string, error?: Error) => void) => Promise<void>;
103
+ };
104
+ };
105
+
106
+ export { type ConnectErrorContext, type ConnectErrorReason, type ConnectKitConfig, type ConnectKitContextValue, ConnectKitProvider, type ConnectKitProviderProps, ConnectModal, type ConnectModalProps, type ConnectResult, type ConnectorId, type Connectors, type CreditWalletStrategy, type WCSubView, type WCWallet, connectKit, initConfig, useConnectKit };