@gluwa/connect-kit 0.1.0-next.0 → 0.1.0-next.2
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 +12 -0
- package/dist/index.d.ts +52 -4
- package/dist/index.js +651 -308
- package/dist/package.json +3 -1
- package/package.json +3 -1
- package/src/ConnectKitProvider.tsx +169 -0
- package/src/ConnectModal.scss +38 -0
- package/src/ConnectModal.tsx +246 -199
- package/src/components/QRFrame.tsx +43 -0
- package/src/creditConnectConnector.ts +61 -13
- package/src/hooks/useWCState.ts +150 -0
- package/src/hooks/useWagmiConnect.ts +68 -45
- package/src/index.ts +13 -1
- package/src/types.ts +22 -4
- package/src/views/CreditWalletView.tsx +4 -17
- package/src/views/MetaMaskView.tsx +5 -30
- package/src/views/SwitchChainView.tsx +67 -0
- package/src/views/WalletConnectView.tsx +10 -70
- package/tsup.config.ts +12 -1
- package/dist/_esm-PE6HOEBI.js +0 -3909
- package/dist/ccip-UBX2BH3T.js +0 -15
- package/dist/chunk-6KUZ225H.js +0 -5259
- package/dist/chunk-EVEWD66F.js +0 -447
- package/dist/chunk-U2IU7TQD.js +0 -45
- package/dist/secp256k1-FYSVLDVL.js +0 -2311
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { ReactNode, FC } from 'react';
|
|
2
2
|
import { createConnector } from '@wagmi/core';
|
|
3
3
|
import { StorageProvider } from '@gluwa/credit-connect-sdk/storage';
|
|
4
4
|
import { E2EEProvider } from '@gluwa/credit-connect-sdk/e2ee';
|
|
5
5
|
import { HubFactoryProvider } from '@gluwa/credit-connect-sdk/hub';
|
|
6
6
|
|
|
7
7
|
type ConnectorId = 'CREDIT_WALLET' | 'CREDIT_CONNECT' | 'METAMASK' | 'WALLET_CONNECT';
|
|
8
|
-
type
|
|
8
|
+
type CreditWalletStrategy = 'walletConnect' | 'creditConnect';
|
|
9
|
+
interface Connectors {
|
|
10
|
+
creditWallet?: CreditWalletStrategy | false;
|
|
11
|
+
metamask?: boolean;
|
|
12
|
+
walletConnect?: boolean;
|
|
13
|
+
}
|
|
9
14
|
interface WCWallet {
|
|
10
15
|
id: string;
|
|
11
16
|
name: string;
|
|
@@ -23,17 +28,60 @@ interface ConnectResult {
|
|
|
23
28
|
address: `0x${string}`;
|
|
24
29
|
connectorId: ConnectorId;
|
|
25
30
|
}
|
|
31
|
+
type ConnectErrorReason = 'rejected' | 'unsupported' | 'unknown';
|
|
32
|
+
interface ConnectErrorContext {
|
|
33
|
+
connectorId: ConnectorId;
|
|
34
|
+
reason: ConnectErrorReason;
|
|
35
|
+
error: Error;
|
|
36
|
+
retry: () => void;
|
|
37
|
+
dismiss: () => void;
|
|
38
|
+
}
|
|
26
39
|
interface ConnectModalProps {
|
|
27
40
|
open: boolean;
|
|
28
|
-
connectors:
|
|
41
|
+
connectors: Connectors;
|
|
29
42
|
onConnect: (result: ConnectResult) => void;
|
|
30
43
|
onClose: () => void;
|
|
31
44
|
onLog?: (message: string, error?: Error) => void;
|
|
32
45
|
wcProjectId?: string;
|
|
46
|
+
requiredChainId?: number;
|
|
47
|
+
renderConnectError?: (ctx: ConnectErrorContext) => ReactNode;
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
declare const ConnectModal: FC<ConnectModalProps>;
|
|
36
51
|
|
|
52
|
+
interface ConnectKitProviderProps {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
connectors: Connectors;
|
|
55
|
+
wcProjectId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* 연결돼 있는 동안 강제할 체인 ID. 다른 체인에 연결돼 있으면
|
|
58
|
+
* 자동으로 스위치 모달이 떠서 사용자에게 전환 또는 disconnect를 요구.
|
|
59
|
+
*/
|
|
60
|
+
requiredChainId?: number;
|
|
61
|
+
/**
|
|
62
|
+
* 연결이 정상적으로 끝나고(체인 검증까지 통과) "사용 가능한 상태"가 됐을 때 한 번 호출.
|
|
63
|
+
* 재연결(reconnect)에서는 호출되지 않음 — 그쪽은 dApp의 watchAccount 책임.
|
|
64
|
+
*/
|
|
65
|
+
onConnect?: (result: ConnectResult) => void;
|
|
66
|
+
onLog?: (message: string, error?: Error) => void;
|
|
67
|
+
/**
|
|
68
|
+
* 연결 실패(거절/미설치/기타) 시 모달 안에 표시할 fallback UI를 dApp이 직접 그리고 싶을 때.
|
|
69
|
+
* 미제공 시 기본 동작은 selector로 복귀.
|
|
70
|
+
*/
|
|
71
|
+
renderConnectError?: (ctx: ConnectErrorContext) => ReactNode;
|
|
72
|
+
}
|
|
73
|
+
interface ConnectKitContextValue {
|
|
74
|
+
isOpen: boolean;
|
|
75
|
+
open: () => void;
|
|
76
|
+
close: () => void;
|
|
77
|
+
isConnected: boolean;
|
|
78
|
+
address: `0x${string}` | undefined;
|
|
79
|
+
connectorId: ConnectorId | null;
|
|
80
|
+
disconnect: () => Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
declare const ConnectKitProvider: FC<ConnectKitProviderProps>;
|
|
83
|
+
declare const useConnectKit: () => ConnectKitContextValue;
|
|
84
|
+
|
|
37
85
|
type CreditConnectConnectorOptions = {
|
|
38
86
|
projectKey: string;
|
|
39
87
|
serverUrl: string;
|
|
@@ -44,4 +92,4 @@ type CreditConnectConnectorOptions = {
|
|
|
44
92
|
};
|
|
45
93
|
declare const creditConnectConnector: (options: CreditConnectConnectorOptions) => ReturnType<typeof createConnector>;
|
|
46
94
|
|
|
47
|
-
export { ConnectModal, type ConnectModalProps, type ConnectResult, type ConnectorId, type CreditConnectConnectorOptions, type WCSubView, type WCWallet, creditConnectConnector };
|
|
95
|
+
export { type ConnectErrorContext, type ConnectErrorReason, type ConnectKitContextValue, ConnectKitProvider, type ConnectKitProviderProps, ConnectModal, type ConnectModalProps, type ConnectResult, type ConnectorId, type Connectors, type CreditConnectConnectorOptions, type CreditWalletStrategy, type WCSubView, type WCWallet, creditConnectConnector, useConnectKit };
|