@gluwa/connect-kit 0.1.0-next.3 → 0.2.0-next.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/assets/fonts/Inter-Medium.ttf +0 -0
  3. package/assets/fonts/Inter-Medium.woff2 +0 -0
  4. package/assets/fonts/Inter-Regular.ttf +0 -0
  5. package/assets/fonts/Inter-Regular.woff2 +0 -0
  6. package/assets/fonts/Inter-SemiBold.ttf +0 -0
  7. package/assets/fonts/Inter-SemiBold.woff2 +0 -0
  8. package/assets/graphic.png +0 -0
  9. package/assets/metamask.png +0 -0
  10. package/assets/penguinwallet.png +0 -0
  11. package/assets/wc-logo.svg +3 -0
  12. package/assets/wc-search.png +0 -0
  13. package/dist/chunk-VE5LB7BN.js +405 -0
  14. package/dist/credit-connect.js +2 -394
  15. package/dist/index.css +2075 -0
  16. package/dist/index.d.ts +58 -33
  17. package/dist/index.js +1748 -1503
  18. package/dist/package.json +16 -10
  19. package/package.json +14 -11
  20. package/src/ConnectKitProvider.tsx +133 -75
  21. package/src/api/account.ts +21 -0
  22. package/src/api/asset.ts +10 -0
  23. package/src/api/balance.ts +10 -0
  24. package/src/api/chain.ts +17 -0
  25. package/src/api/contract.ts +33 -0
  26. package/src/api/transaction.ts +12 -0
  27. package/src/assets.d.ts +5 -0
  28. package/src/components/actionItem/index.tsx +50 -0
  29. package/src/components/actionItem/style.scss +47 -0
  30. package/src/components/copyLink/index.tsx +16 -0
  31. package/src/components/copyLink/style.scss +16 -0
  32. package/src/components/qrArea/index.tsx +72 -0
  33. package/src/components/qrArea/style.scss +122 -0
  34. package/src/components/searchBar/asset/Search.tsx +20 -0
  35. package/src/components/searchBar/asset/XMarkCircle.tsx +24 -0
  36. package/src/components/searchBar/index.tsx +44 -0
  37. package/src/components/searchBar/style.scss +58 -0
  38. package/src/components/toast/index.tsx +41 -0
  39. package/src/components/toast/style.scss +108 -0
  40. package/src/components/toggle/index.tsx +27 -0
  41. package/src/components/toggle/style.scss +53 -0
  42. package/src/components/walletGrid/index.tsx +64 -0
  43. package/src/components/walletGrid/style.scss +108 -0
  44. package/src/components/walletItem/index.tsx +49 -0
  45. package/src/components/walletItem/style.scss +70 -0
  46. package/src/connector-meta.ts +16 -11
  47. package/src/core/config.ts +102 -0
  48. package/src/creditConnectConnector.ts +198 -184
  49. package/src/events/account.ts +76 -0
  50. package/src/hooks/useConnectBanner.ts +79 -0
  51. package/src/hooks/useConnectTimeout.ts +92 -0
  52. package/src/hooks/useMetaMaskExtension.ts +29 -0
  53. package/src/hooks/useWCState.ts +45 -14
  54. package/src/hooks/useWagmiConnect.ts +42 -11
  55. package/src/index.ts +38 -2
  56. package/src/layout/allWallets/index.tsx +52 -0
  57. package/src/layout/allWallets/style.scss +57 -0
  58. package/src/layout/connectDialog/asset/backIcon.tsx +24 -0
  59. package/src/layout/connectDialog/asset/checkIcon.tsx +28 -0
  60. package/src/layout/connectDialog/asset/closeIcon.tsx +21 -0
  61. package/src/layout/connectDialog/asset/copyIcon.tsx +28 -0
  62. package/src/layout/connectDialog/asset/linkIcon.tsx +24 -0
  63. package/src/layout/connectDialog/asset/spinner.tsx +21 -0
  64. package/src/layout/connectDialog/asset/warningIcon.tsx +21 -0
  65. package/src/layout/connectDialog/idle/assets/banner-placeholder.png +0 -0
  66. package/src/layout/connectDialog/idle/index.tsx +55 -0
  67. package/src/layout/connectDialog/idle/style.scss +52 -0
  68. package/src/layout/connectDialog/index.tsx +432 -0
  69. package/src/layout/connectDialog/loading/index.tsx +13 -0
  70. package/src/layout/connectDialog/loading/style.scss +19 -0
  71. package/src/layout/connectDialog/metaMask/index.tsx +61 -0
  72. package/src/layout/connectDialog/metaMask/style.scss +65 -0
  73. package/src/layout/connectDialog/qr/index.tsx +33 -0
  74. package/src/layout/connectDialog/style.scss +48 -0
  75. package/src/layout/connectDialog/timeout/index.tsx +31 -0
  76. package/src/layout/connectDialog/timeout/style.scss +64 -0
  77. package/src/layout/connectDialog/walletConnect/index.tsx +45 -0
  78. package/src/layout/connectDialog/walletConnect/style.scss +48 -0
  79. package/src/layout/connectDialog/walletQR/index.tsx +37 -0
  80. package/src/layout/detailPanel/index.tsx +175 -0
  81. package/src/layout/detailPanel/style.scss +70 -0
  82. package/src/layout/selectorPanel/index.tsx +100 -0
  83. package/src/layout/selectorPanel/style.scss +113 -0
  84. package/src/style/color.scss +417 -0
  85. package/src/style/font.scss +28 -0
  86. package/src/style/index.scss +5 -0
  87. package/src/style/mixin.scss +217 -0
  88. package/src/style/reset.scss +110 -0
  89. package/src/style/variables.scss +13 -0
  90. package/src/types.ts +40 -7
  91. package/src/utils/platform.ts +6 -7
  92. package/src/wallet-display-override.ts +15 -0
  93. package/tsconfig.json +5 -1
  94. package/tsup.config.ts +32 -2
  95. package/assets/creditwallet.png +0 -0
  96. package/dist/chunk-DDA6FP6U.js +0 -7
  97. package/src/ConnectModal.scss +0 -665
  98. package/src/ConnectModal.tsx +0 -559
  99. package/src/components/QRFrame.tsx +0 -43
  100. package/src/views/CreditWalletView.tsx +0 -59
  101. package/src/views/IdleView.tsx +0 -10
  102. package/src/views/MetaMaskView.tsx +0 -64
  103. package/src/views/SwitchChainView.tsx +0 -67
  104. package/src/views/WalletConnectView.tsx +0 -206
@@ -0,0 +1,108 @@
1
+ @use '../../style/mixin.scss' as *;
2
+
3
+ .ck-wallet-grid-scroll {
4
+ flex: 1;
5
+ min-height: 0;
6
+ overflow-y: auto;
7
+ overflow-x: hidden;
8
+ width: 100%;
9
+ @include themedScrollbar;
10
+ }
11
+
12
+ .ck-wallet-grid {
13
+ display: grid;
14
+ grid-template-columns: repeat(4, minmax(0, 1fr));
15
+ grid-auto-rows: auto;
16
+ column-gap: 16px;
17
+ row-gap: 16px;
18
+ list-style: none;
19
+ margin: 0;
20
+ padding: 0;
21
+ width: 100%;
22
+
23
+ @include small-mobile {
24
+ row-gap: 3px;
25
+ }
26
+ @include max-width(392px) {
27
+ grid-template-columns: repeat(3, minmax(0, 1fr));
28
+ }
29
+ }
30
+
31
+ .ck-root .ck-wallet-grid-item {
32
+ display: flex;
33
+ flex-direction: column;
34
+ align-items: center;
35
+ justify-content: center;
36
+ gap: 6px;
37
+ padding: 20px 12px;
38
+ width: 100%;
39
+ cursor: pointer;
40
+ }
41
+
42
+ .ck-wallet-grid-icon {
43
+ width: 54px;
44
+ height: 54px;
45
+ max-width: none;
46
+ border-radius: 12px;
47
+ flex-shrink: 0;
48
+ background: var(--scale-gray-200);
49
+ overflow: hidden;
50
+ cursor: pointer;
51
+
52
+ img {
53
+ width: 100%;
54
+ height: 100%;
55
+ object-fit: cover;
56
+ display: block;
57
+ }
58
+ }
59
+
60
+ .ck-wallet-grid-name-wrap {
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ gap: 2px;
65
+ width: 100%;
66
+ min-width: 0;
67
+ }
68
+
69
+ .ck-wallet-grid-name {
70
+ @include textToken('label6-bold');
71
+ color: var(--scale-gray-900);
72
+ text-align: center;
73
+ overflow: hidden;
74
+ text-overflow: ellipsis;
75
+ white-space: nowrap;
76
+ min-width: 0;
77
+ flex-shrink: 1;
78
+ }
79
+
80
+ .ck-wallet-grid-wc-badge {
81
+ width: 16px;
82
+ height: 16px;
83
+ flex-shrink: 0;
84
+ }
85
+
86
+ // ── Skeleton ──────────────────────────────────────────────────────────────────
87
+ .ck-wallet-grid-loading .ck-wallet-grid-item {
88
+ cursor: default;
89
+ }
90
+
91
+ .ck-wallet-grid-icon-skeleton {
92
+ background: var(--scale-gray-100);
93
+ animation: ck-grid-pulse 1.5s ease-in-out infinite;
94
+ }
95
+
96
+ .ck-wallet-grid-name-skeleton {
97
+ height: 12px;
98
+ border-radius: 4px;
99
+ background: var(--scale-gray-100);
100
+ width: 60%;
101
+ margin: 0 auto;
102
+ animation: ck-grid-pulse 1.5s ease-in-out infinite;
103
+ }
104
+
105
+ @keyframes ck-grid-pulse {
106
+ 0%, 100% { opacity: 1; }
107
+ 50% { opacity: 0.4; }
108
+ }
@@ -0,0 +1,49 @@
1
+ import { type FC } from 'react';
2
+ import './style.scss';
3
+ import { type ConnectorId } from '../../types';
4
+
5
+ interface WalletItemProps {
6
+ id: ConnectorId;
7
+ label: string;
8
+ logoUrl?: string;
9
+ isSelected: boolean;
10
+ isRecent?: boolean;
11
+ onSelect: (id: ConnectorId) => void;
12
+ }
13
+
14
+ export const WalletItem: FC<WalletItemProps> = ({
15
+ id,
16
+ label,
17
+ logoUrl,
18
+ isSelected,
19
+ isRecent = false,
20
+ onSelect,
21
+ }) => {
22
+ return (
23
+ <button
24
+ type="button"
25
+ className={`ck-wallet-item${isSelected ? ' is-selected' : ''}`}
26
+ onClick={() => onSelect(id)}
27
+ aria-pressed={isSelected}
28
+ >
29
+ {logoUrl ? (
30
+ <img
31
+ className={`ck-wallet-item-icon${id === 'METAMASK' ? ' has-bg' : ''}`}
32
+ src={logoUrl}
33
+ alt=""
34
+ aria-hidden="true"
35
+ />
36
+ ) : (
37
+ <span className="ck-wallet-item-icon" aria-hidden="true" />
38
+ )}
39
+ <span className="ck-wallet-item-txt">
40
+ <span className="ck-wallet-item-label">{label}</span>
41
+ {isRecent && (
42
+ <span className="ck-wallet-item-badge" aria-label="Recently used">
43
+ Recent
44
+ </span>
45
+ )}
46
+ </span>
47
+ </button>
48
+ );
49
+ };
@@ -0,0 +1,70 @@
1
+ @use '../../style/mixin.scss' as *;
2
+
3
+ .ck-root .ck-wallet-item {
4
+ display: flex;
5
+ align-items: center;
6
+ gap: 12px;
7
+ width: 100%;
8
+ padding: 14px 20px;
9
+ border-radius: 12px;
10
+ background: var(--scale-gray-100);
11
+ cursor: pointer;
12
+ transition: background 0.15s ease;
13
+
14
+ &:hover {
15
+ background: var(--scale-gray-200);
16
+ }
17
+
18
+ &.is-selected {
19
+ background: var(--semantic-brand-trugi-primary);
20
+
21
+ .ck-wallet-item-label {
22
+ color: var(--static-white-main);
23
+ }
24
+
25
+ .ck-wallet-item-badge {
26
+ background: var(--static-white-alpha-200);
27
+ color: var(--static-white-main);
28
+ }
29
+ }
30
+ }
31
+
32
+ .ck-wallet-item-icon {
33
+ width: 36px;
34
+ height: 36px;
35
+ border-radius: 8px;
36
+ flex-shrink: 0;
37
+ overflow: hidden;
38
+ object-fit: cover;
39
+
40
+ &.has-bg {
41
+ background: var(--static-white-main);
42
+ padding: 2px;
43
+ }
44
+ }
45
+
46
+ .ck-wallet-item-txt {
47
+ display: flex;
48
+ align-items: center;
49
+ gap: 6px;
50
+ flex: 1;
51
+ min-width: 0;
52
+ }
53
+
54
+ .ck-wallet-item-label {
55
+ @include textToken('label3-bold');
56
+ color: var(--scale-gray-900);
57
+ overflow: hidden;
58
+ text-overflow: ellipsis;
59
+ white-space: nowrap;
60
+ flex-shrink: 1;
61
+ }
62
+
63
+ .ck-wallet-item-badge {
64
+ @include textToken('caption3-bold');
65
+ color: var(--semantic-brand-trugi-primary);
66
+ background: var(--scale-blue2-alpha-100);
67
+ padding: 4px 8px;
68
+ border-radius: 500px;
69
+ flex-shrink: 0;
70
+ }
@@ -1,5 +1,5 @@
1
1
  import { type ConnectorId } from './types';
2
- import creditWalletIcon from '../assets/creditwallet.png';
2
+ import penguinWalletIcon from '../assets/penguinwallet.png';
3
3
  import metaMaskIcon from '../assets/metamask.png';
4
4
  import wcIcon from '../assets/wc.png';
5
5
 
@@ -13,17 +13,10 @@ export interface ConnectorMeta {
13
13
 
14
14
  export const CONNECTOR_META: Record<ConnectorId, ConnectorMeta> = {
15
15
  CREDIT_CONNECT: {
16
- label: 'Continue with Credit Wallet',
17
- detailTitle: 'Scan with Credit Wallet',
16
+ label: 'Continue with PenguinWallet',
17
+ detailTitle: 'Scan with PenguinWallet',
18
18
  downloadUrl: 'https://creditwallet.onelink.me/Jv54',
19
- logoUrl: creditWalletIcon,
20
- // deepLinkBase: TODO — 앱 측 CC 딥링크 스킴 확정 후 추가
21
- },
22
- CREDIT_WALLET: {
23
- label: 'Credit Wallet',
24
- detailTitle: 'Scan with Credit Wallet',
25
- downloadUrl: 'https://creditwallet.onelink.me/Jv54',
26
- logoUrl: creditWalletIcon,
19
+ logoUrl: penguinWalletIcon,
27
20
  deepLinkBase: 'creditwallet://',
28
21
  },
29
22
  METAMASK: {
@@ -39,3 +32,15 @@ export const CONNECTOR_META: Record<ConnectorId, ConnectorMeta> = {
39
32
  logoUrl: wcIcon,
40
33
  },
41
34
  };
35
+
36
+ // wagmi connector id (예: 'credit-connect' · 'metaMaskSDK' · 'walletConnect') → kit ConnectorId.
37
+ // wagmi storage 의 recentConnectorId 복원 · account.connector 식별에 공용 사용.
38
+ export const resolveConnectorId = (wagmiConnectorId: string | undefined): ConnectorId | null => {
39
+ if (!wagmiConnectorId) return null;
40
+ if (wagmiConnectorId === 'credit-connect') return 'CREDIT_CONNECT';
41
+ if (wagmiConnectorId === 'walletConnect') return 'WALLET_CONNECT';
42
+ const lower = wagmiConnectorId.toLowerCase();
43
+ if (lower.includes('metamask') || wagmiConnectorId === 'injected') return 'METAMASK';
44
+ if (lower.includes('walletconnect')) return 'WALLET_CONNECT';
45
+ return null;
46
+ };
@@ -0,0 +1,102 @@
1
+ import { createConfig, createStorage } from 'wagmi';
2
+ import { metaMask, walletConnect, injected } from 'wagmi/connectors';
3
+ import type { Config } from 'wagmi';
4
+ import type { ConnectKitConfig } from '../types';
5
+ import { creditConnectConnector } from '../creditConnectConnector';
6
+ import { LocalStorageProvider } from '@gluwa/credit-connect-storage-local';
7
+ import { tweetNaclE2EE } from '@gluwa/credit-connect-e2ee-tweetnacl';
8
+ import { wsHubFactory } from '@gluwa/credit-connect-hub-node-ws';
9
+
10
+ type KitSlot = {
11
+ config: Config | null;
12
+ kitConfig: ConnectKitConfig | null;
13
+ };
14
+
15
+ const SLOT_KEY = Symbol.for('@gluwa/connect-kit:slot');
16
+
17
+ type GlobalWithSlot = typeof globalThis & {
18
+ [SLOT_KEY]?: KitSlot;
19
+ };
20
+
21
+ const getSlot = (): KitSlot => {
22
+ const g = globalThis as GlobalWithSlot;
23
+ if (!g[SLOT_KEY]) {
24
+ g[SLOT_KEY] = { config: null, kitConfig: null };
25
+ }
26
+ return g[SLOT_KEY];
27
+ };
28
+
29
+ export const initConfig = (kitConfig: ConnectKitConfig): Config => {
30
+ const slot = getSlot();
31
+ if (slot.config) {
32
+ if (slot.kitConfig !== kitConfig) {
33
+ // eslint-disable-next-line no-console
34
+ console.warn(
35
+ '[connect-kit] initConfig called again with a different kitConfig — new chains/transports ignored. Call resetConfig() first to re-init.',
36
+ );
37
+ }
38
+ return slot.config;
39
+ }
40
+
41
+ const connectors = [];
42
+
43
+ if (kitConfig.wcProjectId) {
44
+ connectors.push(walletConnect({ projectId: kitConfig.wcProjectId, showQrModal: false }));
45
+ }
46
+
47
+ connectors.push(
48
+ metaMask({ headless: true, storage: { enabled: true } }),
49
+ injected({ shimDisconnect: false }),
50
+ );
51
+
52
+ if (kitConfig.creditConnect) {
53
+ connectors.push(
54
+ creditConnectConnector({
55
+ projectKey: kitConfig.creditConnect.projectId,
56
+ serverUrl: kitConfig.creditConnect.serverUrl,
57
+ storage: new LocalStorageProvider(),
58
+ e2ee: tweetNaclE2EE,
59
+ createHub: wsHubFactory.createHubFromDapp,
60
+ }),
61
+ );
62
+ }
63
+
64
+ if (kitConfig.extraConnectors?.length) {
65
+ connectors.push(...kitConfig.extraConnectors);
66
+ }
67
+
68
+ const isBrowser = typeof window !== 'undefined';
69
+
70
+ slot.config = createConfig({
71
+ ssr: true,
72
+ chains: kitConfig.chains,
73
+ connectors,
74
+ transports: kitConfig.transports,
75
+ storage: isBrowser ? createStorage({ storage: window.localStorage }) : undefined,
76
+ });
77
+ slot.kitConfig = kitConfig;
78
+
79
+ return slot.config;
80
+ };
81
+
82
+ export const getConfig = (): Config => {
83
+ const slot = getSlot();
84
+ if (!slot.config) {
85
+ throw new Error('ConnectKit config not initialized. Make sure ConnectKitProvider is mounted.');
86
+ }
87
+ return slot.config;
88
+ };
89
+
90
+ export const getKitConfig = (): ConnectKitConfig => {
91
+ const slot = getSlot();
92
+ if (!slot.kitConfig) {
93
+ throw new Error('ConnectKit config not initialized. Make sure ConnectKitProvider is mounted.');
94
+ }
95
+ return slot.kitConfig;
96
+ };
97
+
98
+ export const resetConfig = (): void => {
99
+ const slot = getSlot();
100
+ slot.config = null;
101
+ slot.kitConfig = null;
102
+ };