@dogeos/dogeos-sdk 3.0.7 → 3.0.9-beta.0

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/README.md CHANGED
@@ -1,59 +1,51 @@
1
- # dogeos-sdk
1
+ # Wallet Connect Kit
2
2
 
3
- A lightweight React SDK for integrating crypto wallet connections into your app. It ships with a configurable wallet list modal and basic account actions. Currently focused on EVM chains, built on top of `@tomo-inc/wallet-adaptor-base`, and supports custom wallets and chain configuration.
3
+ A lightweight React SDK for integrating crypto wallet connection functionality into your applications. It provides a configurable wallet list modal and basic account operations.
4
4
 
5
- ## On This Page
5
+ ## Requirements
6
6
 
7
- - [Installation](#installation)
8
- - [Setup Provider](#setup-provider)
9
- - [Displaying the Modal](#displaying-the-modal)
10
- - [Account Actions](#account-actions)
11
- - [Additional Reference](#additional-reference)
12
-
13
- ---
7
+ - React 18 or higher
8
+ - TypeScript 5 or higher (recommended)
14
9
 
15
10
  ## Installation
16
11
 
12
+ Install Wallet Connect Kit using your preferred package manager:
13
+
17
14
  ```bash
18
15
  npm install @dogeos/dogeos-sdk
19
-
20
16
  ```
21
17
 
22
- Or using yarn:
18
+ ```bash
19
+ pnpm add @dogeos/dogeos-sdk
20
+ ```
23
21
 
24
22
  ```bash
25
23
  yarn add @dogeos/dogeos-sdk
26
-
27
24
  ```
28
25
 
29
- Or using pnpm:
26
+ ### Dependencies
30
27
 
31
- ```bash
32
- pnpm add @dogeos/dogeos-sdk
28
+ Wallet Connect Kit requires the following peer dependencies:
33
29
 
34
- ```
30
+ - `react >= 18`
31
+ - `react-dom >= 18`
32
+ - `wagmi >= 2.0.0` (optional, if using WagmiProvider)
35
33
 
36
- ---
34
+ ## Quick Start
37
35
 
38
- ## Setup Provider
36
+ ### 0. Prerequisites
39
37
 
40
- ### Use React
38
+ This guide assumes you have already installed Wallet Connect Kit. If you haven't, please refer to the installation steps above.
41
39
 
42
- Wrap your app with `WalletConnectProvider` at the root component.
40
+ ### 1. Setup Provider
41
+
42
+ First, wrap your app root component with `WalletConnectProvider`:
43
43
 
44
44
  ```tsx
45
45
  // App.tsx
46
+ // App.tsx
46
47
  import React from "react";
47
48
  import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
48
- import type { WalletConfig, WalletConnectKitConfig, WalletConnectProtocolConfig, clientId } from "@dogeos/dogeos-sdk"
49
-
50
- const config = {
51
- connectors?: WalletConfig[];
52
- // Supported chains (for EVM, compatible with viem/Chain)
53
- chains?: Partial<Record<ChainType, EvmChain[] | any[]>>;
54
- walletConnectConfig?: WalletConnectProtocolConfig;
55
- clientId?: string;
56
- } as WalletConnectConfig;
57
49
 
58
50
  export default function App() {
59
51
  return (
@@ -64,157 +56,358 @@ export default function App() {
64
56
  }
65
57
  ```
66
58
 
67
- Embedded Wallet Evm Provider Method
59
+ ### 2. Connect Wallet
68
60
 
69
- support:
61
+ Use the `useWalletConnect` hook to open the wallet connection modal and manage connection state:
70
62
 
71
- ```
72
- // methods
73
- connect;
74
- disconnect;
75
- getChainId;
76
- switchChain;
77
- signMessage(siweSign);
78
- signTypedData;
79
- eth_signTransaction;
80
- sendTransaction;
81
- ```
63
+ ```tsx
64
+ // ConnectButton.tsx
65
+ import React from "react";
66
+ import { useWalletConnect } from "@dogeos/dogeos-sdk";
67
+ import { useWalletConnect } from "@dogeos/dogeos-sdk";
82
68
 
83
- -[MateMask Provider Doc](#https://docs.metamask.io/wallet/reference/provider-api/)
69
+ export function ConnectButton() {
70
+ const { openModal, isConnected, disconnect, isConnecting } =
71
+ useWalletConnect();
84
72
 
85
- ---
73
+ if (isConnecting) {
74
+ return <button disabled>Connecting...</button>;
75
+ }
86
76
 
87
- ## Displaying the Modal
77
+ return (
78
+ <button onClick={() => (isConnected ? disconnect() : openModal())}>
79
+ {isConnected ? "Disconnect" : "Connect Wallet"}
80
+ </button>
81
+ );
82
+ }
83
+ ```
88
84
 
89
- To display the modal for wallet connection, you can use the hooks provided by **dogeos-sdk**.
85
+ ### 3. Read Account Information
90
86
 
91
- ### Example Code
87
+ Use the `useAccount` hook to get the currently connected account information:
92
88
 
93
89
  ```tsx
90
+ // AccountInfo.tsx
94
91
  import React from "react";
95
- import { useWalletConnect } from "@dogeos/dogeos-sdk";
92
+ import { useAccount } from "@dogeos/dogeos-sdk";
93
+ import { useAccount } from "@dogeos/dogeos-sdk";
96
94
 
97
- const ConnectButton = () => {
98
- const { openModal, isConnected, disconnect } = useWalletConnect();
95
+ export function AccountInfo() {
96
+ const { address, chainId, chainType, currentWallet } = useAccount();
97
+
98
+ if (!address) {
99
+ return <div>No wallet connected</div>;
100
+ }
99
101
 
100
102
  return (
101
- <button onClick={() => (isConnected ? disconnect() : openModal())}>
102
- {isConnected ? "Disconnect" : "Connect Wallet"}
103
- </button>
103
+ <div>
104
+ <div>Address: {address}</div>
105
+ <div>Chain ID: {chainId}</div>
106
+ <div>Chain Type: {chainType}</div>
107
+ <div>Wallet: {currentWallet?.info?.name}</div>
108
+ </div>
104
109
  );
105
- };
106
-
107
- export default ConnectButton;
110
+ }
108
111
  ```
109
112
 
110
- ### MyDoge Social Login Experience
113
+ ### 4. Sign Message
111
114
 
112
- When using the MyDoge theme, the modal will first display the social login interface, supporting:
115
+ Use the `signMessage` method from the `useAccount` hook to sign messages:
113
116
 
114
- - **Twitter Login** - Quick login with Twitter/X account
115
- - **Google Login** - Quick login with Google account
116
- - **Email Login** - Login with email address
117
+ ```tsx
118
+ // SignMessageButton.tsx
119
+ import React from "react";
120
+ import { useAccount } from "@dogeos/dogeos-sdk";
117
121
 
118
- Users can also select "Or connect a wallet" to directly connect traditional crypto wallets.
122
+ export function SignMessageButton() {
123
+ const { signMessage, address } = useAccount();
124
+
125
+ const handleSignMessage = async () => {
126
+ if (!signMessage) {
127
+ console.error("Signing functionality not available");
128
+ return;
129
+ }
130
+
131
+ try {
132
+ const signature = await signMessage({
133
+ message: "Hello Tomo Wallet",
134
+ });
135
+ console.log("Signature result:", signature);
136
+ } catch (error) {
137
+ console.error("Signing failed:", error);
138
+ }
139
+ };
119
140
 
120
- ---
141
+ if (!address) {
142
+ return null;
143
+ }
121
144
 
122
- ## Account Actions
145
+ return <button onClick={handleSignMessage}>Sign Message</button>;
146
+ }
147
+ ```
123
148
 
124
- ### Reading Account Info and Signing
149
+ ### 5. Sign In with Wallet (SIW)
125
150
 
126
- After connecting a wallet, you can use the `useAccount` hook to access account information and perform signing operations.
151
+ Use the `signInWithWallet` method to sign in with wallet and obtain an authentication token:
127
152
 
128
153
  ```tsx
154
+ // SignInButton.tsx
129
155
  import React from "react";
130
156
  import { useAccount } from "@dogeos/dogeos-sdk";
131
157
 
132
- export function AccountInfo() {
133
- const { address, chainId, signMessage, signInWithWallet } = useAccount();
134
-
135
- const onSignMessage = async () => {
136
- // Message signing for verification
137
- const sig = await signMessage?.({ message: "Hello MyDoge" });
138
- console.log("signature:", sig);
158
+ export function SignInButton() {
159
+ const { signInWithWallet, address } = useAccount();
160
+
161
+ const handleSignIn = async () => {
162
+ try {
163
+ const token = await signInWithWallet();
164
+ console.log("Authentication token:", token);
165
+ // Save token to localStorage or send to backend
166
+ } catch (error) {
167
+ console.error("Sign in failed:", error);
168
+ }
139
169
  };
140
170
 
141
- const onSignin = async () => {
142
- // Sign in with wallet to get a token
143
- const token = await signInWithWallet();
144
- console.log("token:", token);
145
- };
171
+ if (!address) {
172
+ return null;
173
+ }
146
174
 
175
+ return <button onClick={handleSignIn}>Sign In with Wallet</button>;
176
+ }
177
+ ```
178
+
179
+ ## Configuration
180
+
181
+ `WalletConnectProvider` accepts an optional `config` prop to customize the SDK's behavior.
182
+
183
+ ### Basic Configuration
184
+
185
+ ```tsx
186
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
187
+ import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
188
+
189
+ const config: WalletConnectKitConfig = {
190
+ // WalletConnect project ID (obtain from https://cloud.walletconnect.com)
191
+ walletConnectProjectId: "your-project-id",
192
+
193
+ // Application metadata
194
+ metadata: {
195
+ name: "My DApp",
196
+ description: "My decentralized application",
197
+ url: "https://myapp.com",
198
+ icons: ["https://myapp.com/icon.png"],
199
+ },
200
+ };
201
+
202
+ export function App() {
147
203
  return (
148
- <div>
149
- <div>Address: {address}</div>
150
- <div>Chain ID: {chainId}</div>
151
- <button onClick={onSignMessage}>Sign Message</button>
152
- <button onClick={onSignin}>Sign In With Wallet</button>
153
- </div>
204
+ <WalletConnectProvider config={config}>
205
+ <YourApp />
206
+ </WalletConnectProvider>
154
207
  );
155
208
  }
156
209
  ```
157
210
 
158
- ### Available Account Actions
211
+ ### Configure Supported Chains
159
212
 
160
- - **address** - Current connected wallet address
161
- - **chainId** - Current connected chain ID
162
- - **balance** - Account balance
163
- - **chainType** - Chain type (e.g., "evm")
164
- - **currentWallet** - Current wallet information
165
- - **currentProvider** - Current wallet provider
166
- - **switchChain** - Switch network
167
- - **signMessage** - Sign message
168
- - **signInWithWallet** - Sign in with wallet
213
+ Chains are automatically loaded by default. If you need to customize chains, use the `getChains()` method:
169
214
 
170
- ---
215
+ ```tsx
216
+ import { WalletConnectProvider, getChains } from "@dogeos/dogeos-sdk";
217
+ import { useEffect, useState } from "react";
171
218
 
172
- ## Additional Reference
219
+ export function App() {
220
+ const [chains, setChains] = useState<
221
+ Awaited<ReturnType<typeof getChains>> | undefined
222
+ >(undefined);
173
223
 
174
- ### SDK Exports
224
+ useEffect(() => {
225
+ getChains().then(setChains);
226
+ }, []);
175
227
 
176
- The SDK provides the following main exports:
228
+ return (
229
+ <WalletConnectProvider config={{ chains }}>
230
+ <YourApp />
231
+ </WalletConnectProvider>
232
+ );
233
+ }
234
+ ```
177
235
 
178
- - **WalletConnectProvider** - Main provider component with optional `config` prop
179
- - **useWalletConnect** - Hook for modal control and connection state
180
- - `{ isOpenModal, openModal, closeModal, isConnected, isConnecting, error, connect, disconnect }`
181
- - **useAccount** - Hook for account info and actions
182
- - `{ address, balance, chainType, chainId, currentWallet, currentProvider, switchChain, signMessage, signInWithWallet }`
183
- - **Type Definitions**: `WalletConnectConfig`, `Chain`, `WalletProvider`, `UseAccount`, `UseWalletConnect`, `ChainType`, `ModalView`
236
+ ### Configure Custom Wallets
184
237
 
185
- ### Complete Example
238
+ Connectors are automatically loaded by default. If you need to customize connectors, use the `getConnectors()` method:
186
239
 
187
240
  ```tsx
188
- import React from "react";
189
- import {
190
- WalletConnectProvider,
191
- useWalletConnect,
192
- useAccount,
193
- } from "@dogeos/dogeos-sdk";
241
+ import { WalletConnectProvider, getConnectors } from "@dogeos/dogeos-sdk";
242
+ import { useEffect, useState } from "react";
194
243
 
195
- // Connect Button Component
196
- function ConnectButton() {
197
- const { openModal, isConnected, disconnect } = useWalletConnect();
198
- const { address } = useAccount();
244
+ export function App() {
245
+ const [connectors, setConnectors] = useState<
246
+ Awaited<ReturnType<typeof getConnectors>> | undefined
247
+ >(undefined);
199
248
 
200
- if (isConnected && address) {
201
- return (
202
- <div>
203
- <p>
204
- Connected: {address.slice(0, 6)}...{address.slice(-4)}
205
- </p>
206
- <button onClick={disconnect}>Disconnect</button>
207
- </div>
208
- );
209
- }
249
+ useEffect(() => {
250
+ getConnectors().then(setConnectors);
251
+ }, []);
252
+
253
+ return (
254
+ <WalletConnectProvider config={{ connectors }}>
255
+ <YourApp />
256
+ </WalletConnectProvider>
257
+ );
258
+ }
259
+ ```
260
+
261
+ ### Configure Login Options
262
+
263
+ You can configure supported login methods, including basic logins (email, external wallets) and social logins (Google, X/Twitter):
264
+
265
+ ```tsx
266
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
267
+
268
+ const config = {
269
+ login: {
270
+ // Basic login methods
271
+ basicLogins: ["email", "externalWallets"], // or ["email"] or ["externalWallets"]
272
+
273
+ // Social login methods
274
+ socialLogins: [
275
+ {
276
+ type: "google",
277
+ },
278
+ {
279
+ type: "x",
280
+ },
281
+ ],
282
+ },
283
+ };
284
+
285
+ export function App() {
286
+ return (
287
+ <WalletConnectProvider config={config}>
288
+ <YourApp />
289
+ </WalletConnectProvider>
290
+ );
291
+ }
292
+ ```
293
+
294
+ ### Configure Theme
295
+
296
+ You can customize the UI theme:
297
+
298
+ ```tsx
299
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
300
+ import type { ThemeConfig } from "@dogeos/dogeos-sdk";
301
+
302
+ const config = {
303
+ theme: {
304
+ themes: {
305
+ light: {
306
+ colors: {
307
+ primary: {
308
+ DEFAULT: "#FCD436",
309
+ foreground: "#FFF",
310
+ },
311
+ background: "#FFFFFF",
312
+ foreground: "#000000",
313
+ },
314
+ },
315
+ dark: {
316
+ colors: {
317
+ primary: {
318
+ DEFAULT: "#FF5CB8",
319
+ foreground: "#FFF",
320
+ },
321
+ background: "#000000",
322
+ foreground: "#FFFFFF",
323
+ },
324
+ },
325
+ },
326
+ } as ThemeConfig,
327
+ };
210
328
 
211
- return <button onClick={openModal}>Connect Wallet</button>;
329
+ export function App() {
330
+ return (
331
+ <WalletConnectProvider config={config}>
332
+ <YourApp />
333
+ </WalletConnectProvider>
334
+ );
212
335
  }
336
+ ```
213
337
 
214
- // App Component
215
- function App() {
216
- // Configuration
217
- const config = {};
338
+ ### Complete Configuration Example
339
+
340
+ ```tsx
341
+ import {
342
+ WalletConnectProvider,
343
+ getChains,
344
+ getConnectors,
345
+ } from "@dogeos/dogeos-sdk";
346
+ import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
347
+ import { useEffect, useState } from "react";
348
+
349
+ export function App() {
350
+ const [chains, setChains] = useState<
351
+ Awaited<ReturnType<typeof getChains>> | undefined
352
+ >(undefined);
353
+ const [connectors, setConnectors] = useState<
354
+ Awaited<ReturnType<typeof getConnectors>> | undefined
355
+ >(undefined);
356
+
357
+ useEffect(() => {
358
+ const loadConfig = async () => {
359
+ const [loadedChains, loadedConnectors] = await Promise.all([
360
+ getChains(),
361
+ getConnectors(),
362
+ ]);
363
+ setChains(loadedChains);
364
+ setConnectors(loadedConnectors);
365
+ };
366
+ loadConfig();
367
+ }, []);
368
+
369
+ const config: WalletConnectKitConfig = {
370
+ // WalletConnect configuration
371
+ walletConnectProjectId: "your-project-id",
372
+
373
+ // DApp application metadata
374
+ metadata: {
375
+ name: "My DApp",
376
+ description: "My decentralized application",
377
+ url: "https://myapp.com",
378
+ icons: ["https://myapp.com/icon.png"],
379
+ },
380
+
381
+ // Supported chains (must use getChains)
382
+ chains,
383
+
384
+ // Custom wallets (must use getConnectors)
385
+ connectors,
386
+
387
+ // Login configuration
388
+ login: {
389
+ basicLogins: ["email", "externalWallets"],
390
+ socialLogins: [{ type: "google" }, { type: "x" }],
391
+ },
392
+
393
+ // Theme configuration
394
+ theme: {
395
+ themes: {
396
+ light: {
397
+ colors: {
398
+ primary: {
399
+ DEFAULT: "#FCD436",
400
+ foreground: "#FFF",
401
+ },
402
+ },
403
+ },
404
+ },
405
+ },
406
+ };
407
+
408
+ if (!chains || !connectors) {
409
+ return <div>Loading configuration...</div>;
410
+ }
218
411
 
219
412
  return (
220
413
  <WalletConnectProvider config={config}>
@@ -225,36 +418,348 @@ function App() {
225
418
  </WalletConnectProvider>
226
419
  );
227
420
  }
421
+ ```
422
+
423
+ ## API Reference
424
+
425
+ ### WalletConnectProvider
426
+
427
+ Main Provider component for wrapping your application.
228
428
 
229
- export default App;
429
+ **Props:**
430
+
431
+ ```tsx
432
+ interface WalletConnectProviderProps {
433
+ children: React.ReactNode;
434
+ config?: WalletConnectKitConfig;
435
+ }
230
436
  ```
231
437
 
232
- ---
438
+ ### useWalletConnect
233
439
 
234
- ## Support
440
+ Hook for controlling the wallet connection modal and managing connection state.
235
441
 
236
- For more help or if you encounter issues, please visit:
442
+ **Returns:**
237
443
 
238
- - [GitHub Issues](https://github.com/DogeOS69/mydoge-sdk)
239
- - [Support](support@dogeos.com)
240
- - [Documentation](https://docs.dogeos.com)
444
+ ```tsx
445
+ interface UseWalletConnect {
446
+ // Modal control
447
+ isOpenModal: boolean;
448
+ openModal: () => void;
449
+ closeModal: () => void;
450
+
451
+ // Connection state
452
+ isConnected: boolean;
453
+ isConnecting: boolean;
454
+ error: Error | null;
455
+
456
+ // Connection operations
457
+ connect: (variables?: ConnectVariables) => Promise<ConnectData>;
458
+ disconnect: () => Promise<void>;
459
+ }
460
+ ```
241
461
 
242
- ---
462
+ **Example:**
243
463
 
244
- ## FAQ
464
+ ```tsx
465
+ const {
466
+ isOpenModal,
467
+ openModal,
468
+ closeModal,
469
+ isConnected,
470
+ isConnecting,
471
+ connect,
472
+ disconnect,
473
+ } = useWalletConnect();
474
+ ```
475
+
476
+ ### useAccount
477
+
478
+ Hook for getting the currently connected account information and performing account-related operations.
245
479
 
246
- 1. How to use with Next.js?
480
+ **Returns:**
247
481
 
248
- ```js
249
- "use client"; // add "use client" at your index router page
482
+ ```tsx
483
+ interface UseAccount {
484
+ // Account information
485
+ address: string;
486
+ balance?: string;
487
+ chainType?: ChainType;
488
+ chainId?: string;
489
+ currentWallet?: Connector | null;
490
+ currentProvider?: any;
491
+
492
+ // Operations
493
+ switchChain: (options: SwitchChainOptions) => Promise<boolean>;
494
+ signMessage?: (params: {
495
+ message: string;
496
+ nonce?: string;
497
+ }) => Promise<string | Uint8Array>;
498
+ signInWithWallet: (params?: SignInParams) => Promise<string | Uint8Array>;
499
+ }
250
500
  ```
251
501
 
252
- 2. Supported Next.js version
502
+ **Example:**
503
+
504
+ ```tsx
505
+ const {
506
+ address,
507
+ chainId,
508
+ chainType,
509
+ signMessage,
510
+ signInWithWallet,
511
+ switchChain,
512
+ } = useAccount();
513
+ ```
514
+
515
+ ### getChains
516
+
517
+ Utility function to get all available chains. Automatically fetches chains from the backend API and returns them in the config format.
518
+
519
+ **Signature:**
520
+
521
+ ```tsx
522
+ function getChains(): Promise<Partial<Record<ChainType, EvmChain[] | any[]>>>;
523
+ ```
524
+
525
+ **Returns:**
526
+
527
+ - A Promise that resolves to a chain configuration object containing all available chains
528
+ - Automatically includes EVM, Solana, Aptos, and Dogecoin chains
529
+ - Falls back to default chains if the API request fails
530
+
531
+ **Example:**
532
+
533
+ ```tsx
534
+ import { getChains } from "@dogeos/dogeos-sdk";
535
+ import { useEffect, useState } from "react";
536
+
537
+ export function MyComponent() {
538
+ const [chains, setChains] = useState<
539
+ Awaited<ReturnType<typeof getChains>> | undefined
540
+ >(undefined);
541
+
542
+ useEffect(() => {
543
+ const loadChains = async () => {
544
+ const allChains = await getChains();
545
+ setChains(allChains);
546
+ };
547
+ loadChains();
548
+ }, []);
549
+
550
+ // Use chains in your config
551
+ const config = { chains };
552
+ }
553
+ ```
554
+
555
+ ## Advanced Usage
556
+
557
+ ### Switch Chain
558
+
559
+ Use the `switchChain` method from the `useAccount` hook to switch chains:
560
+
561
+ ```tsx
562
+ import { useAccount } from "@dogeos/dogeos-sdk";
563
+ import type { Chain } from "@dogeos/dogeos-sdk";
564
+
565
+ export function SwitchChainButton() {
566
+ const { switchChain, chainId } = useAccount();
567
+
568
+ const handleSwitchChain = async () => {
569
+ const targetChain: Chain = {
570
+ id: 137,
571
+ name: "Polygon",
572
+ nativeCurrency: {
573
+ name: "MATIC",
574
+ symbol: "MATIC",
575
+ decimals: 18,
576
+ },
577
+ rpcUrls: {
578
+ default: {
579
+ http: ["https://polygon-rpc.com"],
580
+ },
581
+ },
582
+ blockExplorers: {
583
+ default: {
584
+ name: "PolygonScan",
585
+ url: "https://polygonscan.com",
586
+ },
587
+ },
588
+ };
589
+
590
+ try {
591
+ const success = await switchChain({
592
+ chainType: "evm",
593
+ chainInfo: targetChain,
594
+ });
595
+
596
+ if (success) {
597
+ console.log("Chain switched successfully");
598
+ }
599
+ } catch (error) {
600
+ console.error("Chain switch failed:", error);
601
+ }
602
+ };
253
603
 
254
- - Next.js 14/15 version had supported
604
+ return <button onClick={handleSwitchChain}>Switch to Polygon</button>;
605
+ }
606
+ ```
607
+
608
+ ### Integration with Wagmi
609
+
610
+ Wallet Connect Kit can seamlessly integrate with Wagmi. If you're already using `WagmiProvider`, Wallet Connect Kit will automatically detect and use Wagmi's configuration:
611
+
612
+ ```tsx
613
+ import { WagmiProvider } from "wagmi";
614
+ import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
615
+ import { config } from "./wagmi-config";
616
+
617
+ export function App() {
618
+ return (
619
+ <WagmiProvider config={config}>
620
+ <WalletConnectProvider>
621
+ <YourApp />
622
+ </WalletConnectProvider>
623
+ </WagmiProvider>
624
+ );
625
+ }
626
+ ```
627
+
628
+ ### Error Handling
629
+
630
+ Always handle errors in connections and operations:
631
+
632
+ ```tsx
633
+ import { useWalletConnect, useAccount } from "@dogeos/dogeos-sdk";
634
+
635
+ export function WalletComponent() {
636
+ const { error, isConnecting } = useWalletConnect();
637
+ const { signMessage } = useAccount();
638
+
639
+ const handleSign = async () => {
640
+ try {
641
+ if (!signMessage) {
642
+ throw new Error("Signing functionality not available");
643
+ }
644
+
645
+ const signature = await signMessage({ message: "Hello" });
646
+ console.log("Signing successful:", signature);
647
+ } catch (error) {
648
+ console.error("Signing failed:", error);
649
+ // Display error message to user
650
+ }
651
+ };
652
+
653
+ if (error) {
654
+ return <div>Error: {error.message}</div>;
655
+ }
656
+
657
+ if (isConnecting) {
658
+ return <div>Connecting...</div>;
659
+ }
660
+
661
+ return <button onClick={handleSign}>Sign</button>;
662
+ }
663
+ ```
664
+
665
+ ## Type Definitions
666
+
667
+ ### WalletConnectKitConfig
668
+
669
+ ````tsx
670
+ interface WalletConnectKitConfig {
671
+ connectors?: WalletConfig[];
672
+ chains?: Partial<Record<ChainType, EvmChain[] | any[]>>;
673
+ walletConnectProjectId?: string;
674
+ /**
675
+ * Default connect chain
676
+ * @default undefined
677
+ * @example
678
+ * ```tsx
679
+ * import { WalletConnectProvider } from "@tomo-inc/wallet-connect-kit";
680
+ * const config: WalletConnectKitConfig = {
681
+ * defaultConnectChain: 'evm',
682
+ * };
683
+ */
684
+ defaultConnectChain?: ChainType;
685
+ metadata?: {
686
+ name: string;
687
+ description: string;
688
+ url: string;
689
+ icons: string[];
690
+ };
691
+ theme?: ThemeConfig;
692
+ login?: UserLoginConfig;
693
+ }
694
+ ````
695
+
696
+ ### Chain
697
+
698
+ ```tsx
699
+ interface Chain {
700
+ id: number;
701
+ name: string;
702
+ nativeCurrency: {
703
+ name: string;
704
+ symbol: string;
705
+ decimals: number;
706
+ };
707
+ rpcUrls: {
708
+ default: {
709
+ http: string[];
710
+ };
711
+ };
712
+ blockExplorers?: {
713
+ default: {
714
+ name: string;
715
+ url: string;
716
+ };
717
+ };
718
+ testnet?: boolean;
719
+ }
720
+ ```
721
+
722
+ ### ChainType
723
+
724
+ ```tsx
725
+ type ChainType = "evm" | "solana" | "aptos" | "dogecoin";
726
+ ```
727
+
728
+ ## Exports
729
+
730
+ - `WalletConnectProvider` - Main Provider component
731
+ - `useAccount` - Account information Hook
732
+ - `useWalletConnect` - Connect Hook
733
+ - `getChains` - Utility function to configure chains (can wrap backend API chains)
734
+ - Types: `WalletConnectKitConfig`, `Chain`, `WalletConfig`, `UseAccount`, `ChainType`, `ModalView`, `ThemeConfig`, `UserLoginConfig`
735
+
736
+ ## FAQ
737
+
738
+ ### How to get WalletConnect Project ID?
739
+
740
+ 1. Visit [WalletConnect Cloud](https://cloud.walletconnect.com)
741
+ 2. Create a new project or select an existing project
742
+ 3. Copy the Project ID and use it in your configuration
743
+
744
+ ### How to customize chains and connectors?
745
+
746
+ You can use `getChains()` and `getConnectors()` methods to customize chains and connectors:
747
+
748
+ ```tsx
749
+ import { getChains, getConnectors } from "@dogeos/dogeos-sdk";
750
+
751
+ // Get all available chains
752
+ const chains = await getChains();
753
+
754
+ // Get all available connectors
755
+ const connectors = await getConnectors();
756
+
757
+ // Use in config
758
+ const config = { chains, connectors };
759
+ ```
255
760
 
256
- ---
761
+ The `getChains()` method automatically fetches chains from the backend API and includes EVM, Solana, Aptos, and Dogecoin chains. The `getConnectors()` method loads all available connectors including EIP6963, Wallet Standard, and WalletConnect wallets.
257
762
 
258
- ## License
763
+ ### What chain types are supported?
259
764
 
260
- Please check the project's LICENSE file for details.
765
+ Currently, EVM chains are primarily supported, along with Solana, Aptos, and Dogecoin chains.