@tomo-inc/wallet-connect-kit 0.0.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.
Files changed (2) hide show
  1. package/README.md +149 -0
  2. package/package.json +70 -0
package/README.md ADDED
@@ -0,0 +1,149 @@
1
+ # Wallet Connect SDK
2
+
3
+ A lightweight React SDK to integrate crypto wallet connection into your app. It ships with a configurable wallet list modal and basic account actions. The current focus is EVM, built on top of `@tomo-inc/wallet-adaptor-base`, and supports custom wallets and chain configuration.
4
+
5
+ ## Quick Start
6
+
7
+ ```tsx
8
+ // App.tsx — wrap your app with provider (comments in English)
9
+ import React from "react";
10
+ import { WalletConnectProvider } from "@tomo-inc/wallet-connect-kit";
11
+
12
+ export default function App() {
13
+ return (
14
+ <WalletConnectProvider>
15
+ <YourApp />
16
+ </WalletConnectProvider>
17
+ );
18
+ }
19
+ ```
20
+
21
+ ### Open modal, connect and disconnect
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { useWalletConnect } from "@tomo-inc/wallet-connect-kit";
26
+
27
+ export function ConnectButton() {
28
+ const { openModal, isConnected, disconnect } = useWalletConnect();
29
+
30
+ return (
31
+ <button onClick={() => (isConnected ? disconnect() : openModal())}>
32
+ {isConnected ? "Disconnect" : "Connect Wallet"}
33
+ </button>
34
+ );
35
+ }
36
+ ```
37
+
38
+ ### Read account and sign
39
+
40
+ ```tsx
41
+ import React from "react";
42
+ import { useAccount } from "@tomo-inc/wallet-connect-kit";
43
+
44
+ export function AccountInfo() {
45
+ const { address, chainId, signMessage, signInWithWallet } = useAccount();
46
+
47
+ const onSignMessage = async () => {
48
+ // Message signing for verification
49
+ const sig = await signMessage?.({ message: "Hello Tomo" });
50
+ console.log("signature:", sig);
51
+ };
52
+
53
+ const onSignin = async () => {
54
+ // SIW (sign-in with wallet) to get a token
55
+ const token = await signInWithWallet();
56
+ console.log("token:", token);
57
+ };
58
+
59
+ return (
60
+ <div>
61
+ <div>Address: {address}</div>
62
+ <div>ChainId: {chainId}</div>
63
+ <button onClick={onSignMessage}>Sign Message</button>
64
+ <button onClick={onSignin}>Sign In With Wallet</button>
65
+ </div>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ### Optional: custom wallets and chains
71
+
72
+ ```tsx
73
+ import React from "react";
74
+ import {
75
+ WalletConnectProvider,
76
+ type Chain,
77
+ } from "@tomo-inc/wallet-connect-kit";
78
+
79
+ const config = {
80
+ // Custom wallet connectors (merge with defaults)
81
+ connectors: [
82
+ {
83
+ id: "my-wallet",
84
+ name: "My Wallet",
85
+ namespace: "my.wallet",
86
+ icon: "https://example.com/icon.png",
87
+ iconBackground: "#000",
88
+ downloadUrls: { chrome: "https://example.com/install" },
89
+ },
90
+ ],
91
+ // Supported chains by chain type (compatible with viem/Chain for EVM)
92
+ chains: {
93
+ evm: [
94
+ {
95
+ id: 1,
96
+ name: "Ethereum",
97
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
98
+ rpcUrls: { default: { http: ["https://eth.merkle.io"] } },
99
+ blockExplorers: {
100
+ default: { name: "Etherscan", url: "https://etherscan.io" },
101
+ },
102
+ } as Chain,
103
+ ],
104
+ // aptos: [...],
105
+ // solana: [...],
106
+ },
107
+ // Optional: WalletConnect protocol configuration
108
+ // walletConnectConfig: { ... },
109
+
110
+ // Optional: Embedded wallet configuration for social login
111
+ embeddedWalletConfig: {
112
+ apiKey: "your-api-key",
113
+ // ... other embedded wallet settings
114
+ },
115
+
116
+ // Optional: Product type for UI theme (default: "tomo")
117
+ prodType: "mydoge", // or "tomo"
118
+ };
119
+
120
+ export function AppWithConfig() {
121
+ return (
122
+ <WalletConnectProvider config={config}>
123
+ <YourApp />
124
+ </WalletConnectProvider>
125
+ );
126
+ }
127
+ ```
128
+
129
+ ## Exports
130
+
131
+ - `WalletConnectProvider` - Main provider component with optional `config` prop
132
+ - `useWalletConnect` - Hook for modal control and connection state: `{ isOpenModal, openModal, closeModal, isConnected, isConnecting, error, connect, disconnect }`
133
+ - `useAccount` - Hook for account info and actions: `{ address, balance, chainType, chainId, currentWallet, currentProvider, switchChain, signMessage, signInWithWallet }`
134
+ - Types: `WalletConnectConfig`, `Chain`, `WalletProvider`, `UseAccount`, `UseWalletConnect`, `ChainType`, `ModalView`
135
+ - Views: `MyDogeSocialLoginView` - Custom MyDoge-styled social login view with Twitter, Google login and email support
136
+
137
+ ### WalletConnectProvider Config
138
+
139
+ The `config` prop accepts:
140
+
141
+ - `connectors?: WalletConfig[]` - Custom wallet connectors to merge with defaults
142
+ - `chains?: Partial<Record<ChainType, EvmChain[] | any[]>>` - Supported chains by chain type (e.g., `{ evm: [...], aptos: [...], solana: [...] }`)
143
+ - `walletConnectConfig?: WalletConnectProtocolConfig` - WalletConnect protocol configuration
144
+ - `embeddedWalletConfig?: InitConfig` - Embedded wallet configuration for social login features (API key, OAuth settings, etc.)
145
+ - `prodType?: ProdTypeEnum` - Product type to determine UI theme (`"tomo"` or `"mydoge"`). Controls which social login view is displayed by default
146
+
147
+ **Note:** When `prodType` is set to `"mydoge"`, the SDK will automatically use the MyDoge-styled UI theme for social login features. Set it to `"tomo"` or leave it unset for the default Tomo theme.
148
+
149
+ For more comprehensive examples, see `EXAMPLE.md` in the same directory.
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@tomo-inc/wallet-connect-kit",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist/**/*",
11
+ "README.md",
12
+ "package.json"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ },
19
+ "./style.css": {
20
+ "import": "./dist/wallet-connect-kit.css"
21
+ }
22
+ },
23
+ "dependencies": {
24
+ "@tanstack/react-query": "^5.90.5",
25
+ "copy-to-clipboard": "^3.3.3",
26
+ "qr-code-styling": "^1.9.2",
27
+ "qrcode": "^1.5.4",
28
+ "viem": "2.38.2",
29
+ "@tomo-inc/embedded-wallet-providers": "0.0.2",
30
+ "@tomo-inc/wallet-adaptor-base": "0.0.4",
31
+ "@tomo-inc/tomo-ui": "0.0.3"
32
+ },
33
+ "peerDependencies": {
34
+ "react": ">=18",
35
+ "react-dom": ">=18"
36
+ },
37
+ "devDependencies": {
38
+ "@eslint/js": "^9.36.0",
39
+ "@tailwindcss/cli": "^4.1.13",
40
+ "@tailwindcss/postcss": "^4.1.13",
41
+ "@types/node": "^24.6.0",
42
+ "@types/qrcode": "^1.5.5",
43
+ "@types/react": "^18.3.3",
44
+ "@types/react-dom": "^18.3.0",
45
+ "@vitejs/plugin-react": "^5.0.4",
46
+ "autoprefixer": "^10.4.21",
47
+ "eruda": "^3.4.1",
48
+ "eslint": "^9.36.0",
49
+ "eslint-plugin-react-hooks": "^5.2.0",
50
+ "eslint-plugin-react-refresh": "^0.4.22",
51
+ "globals": "^16.4.0",
52
+ "postcss": "^8.5.6",
53
+ "postcss-prefix-selector": "^1.16.1",
54
+ "react": "^18.3.3",
55
+ "react-dom": "^18.3.0",
56
+ "tailwindcss": "^4.1.15",
57
+ "typescript": "~5.9.3",
58
+ "typescript-eslint": "^8.45.0",
59
+ "vite": "^7.1.7",
60
+ "vite-plugin-dts": "^4.5.0",
61
+ "vite-plugin-node-polyfills": "^0.24.0"
62
+ },
63
+ "sideEffects": [
64
+ "**/*.css"
65
+ ],
66
+ "scripts": {
67
+ "dev": "npx nx dev wallet-connect-kit",
68
+ "build": "npx nx build wallet-connect-kit"
69
+ }
70
+ }