@dogeos/dogeos-sdk 4.0.4-beta.0 → 4.0.4

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 +98 -833
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,909 +1,174 @@
1
- # DogeOS Connect Kit
1
+ # DogeOS SDK
2
2
 
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.
3
+ Connect your React app to DogeOS wallets. Let users sign in with email, Google or X, connect an external wallet, and use their MyDoge wallet inside the MyDoge dApp browser.
4
4
 
5
- ## Requirements
5
+ [Quickstart](https://docs.dogeos.com/en/sdk) · [API reference](https://docs.dogeos.com/en/sdk/api/hooks) · [Developer console](https://console.dogeos.com/)
6
6
 
7
- - React 18 or higher
8
- - TypeScript 5 or higher (recommended)
7
+ ## Install
9
8
 
10
- ## SDK deployment configuration
11
-
12
- The npm package is built with deployment-owned public service destinations. The release job must provide:
13
-
14
- - `DOGEOS_SDK_WEB3_ASSETS_BASE_URL`
15
- - `DOGEOS_OIDC_AUTH_RELAY_BASE_URL`
16
- - `DOGEOS_EMBEDDED_WALLET_BASE_URL`
17
- - `DOGEOS_EMBEDDED_WALLET_STAGE`
18
- - `DOGEOS_SDK_AUTH_SERVICE_ORIGINS` (comma-separated gateway/service origins)
19
-
20
- The build fails when any required value is missing or invalid. These values are compiled into the published SDK and are not consumer provider options.
21
-
22
- The SDK directory is a library-only package. Consumers resolve it through its public `dist` export.
23
-
24
- ## Installation
25
-
26
- Install Wallet Connect Kit using your preferred package manager:
27
-
28
- ```bash
29
- npm install @dogeos/dogeos-sdk
30
- ```
9
+ Use React 18 or later and React DOM 18 or later. Install `wagmi`, a required peer dependency, even if you use only the SDK hooks. TypeScript is supported.
31
10
 
32
11
  ```bash
33
- pnpm add @dogeos/dogeos-sdk
12
+ npm install @dogeos/dogeos-sdk wagmi
34
13
  ```
35
14
 
36
15
  ```bash
37
- yarn add @dogeos/dogeos-sdk
16
+ pnpm add @dogeos/dogeos-sdk wagmi
38
17
  ```
39
18
 
40
- ### Dependencies
41
-
42
- Wallet Connect Kit requires the following peer dependencies:
43
-
44
- - `react >= 18`
45
- - `react-dom >= 18`
46
- - `wagmi >= 2.0.0` (optional, if using WagmiProvider)
47
-
48
- ## Quick Start
49
-
50
- ### 0. Prerequisites
51
-
52
- This guide assumes you have already installed Wallet Connect Kit. If you haven't, please refer to the installation steps above.
19
+ ## Get a client ID
53
20
 
54
- ### 1. Setup Provider
21
+ Create a project in the [developer console](https://console.dogeos.com/) and copy its client ID into your app. A project has separate Sandbox and Live client IDs.
55
22
 
56
- First, wrap your app root component with `WalletConnectProvider`:
23
+ Use a Sandbox client ID during development. Your project overview shows whether automatic access from `localhost` and `127.0.0.1` is ready. Add your hosted application origins to the matching environment before connecting from those domains. An origin includes the scheme, hostname and port, such as `https://app.example.com`.
57
24
 
58
- ```tsx
59
- // App.tsx
60
- import React from "react";
61
- import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
62
-
63
- const dogeConfig = {
64
- clientId: "your-client-id",
65
- };
66
-
67
- export default function App() {
68
- return (
69
- <WalletConnectProvider config={dogeConfig}>
70
- <YourApp />
71
- </WalletConnectProvider>
72
- );
73
- }
74
- ```
25
+ Your client ID is public and belongs in the browser bundle. Your app needs one client ID to configure the SDK.
75
26
 
76
- ### 2. Connect Wallet
27
+ ## Connect a wallet
77
28
 
78
- Use the `useWalletConnect` hook to open the wallet connection modal and manage connection state:
29
+ Wrap your app with `WalletConnectProvider` and import the stylesheet once. Components under the provider can use the SDK hooks.
79
30
 
80
31
  ```tsx
81
- // ConnectButton.tsx
82
- import React from "react";
83
- import { useWalletConnect } from "@dogeos/dogeos-sdk";
84
-
85
- export function ConnectButton() {
86
- const { openModal, isConnected, disconnect, isConnecting } =
87
- useWalletConnect();
88
-
89
- if (isConnecting) {
90
- return <button disabled>Connecting...</button>;
91
- }
92
-
93
- return (
94
- <button onClick={() => (isConnected ? disconnect() : openModal())}>
95
- {isConnected ? "Disconnect" : "Connect Wallet"}
96
- </button>
97
- );
98
- }
99
- ```
100
-
101
- ### 3. Read Account Information
32
+ "use client";
102
33
 
103
- Use the `useAccount` hook to get the currently connected account information:
104
-
105
- ```tsx
106
- // AccountInfo.tsx
107
- import React from "react";
108
- import { useAccount } from "@dogeos/dogeos-sdk";
34
+ import {
35
+ WalletConnectProvider,
36
+ useAccount,
37
+ useWalletConnect,
38
+ type WalletConnectKitConfig,
39
+ } from "@dogeos/dogeos-sdk";
40
+ import "@dogeos/dogeos-sdk/style.css";
109
41
 
110
- export function AccountInfo() {
111
- const { address, chainId, chainType, currentWallet } = useAccount();
42
+ const config: WalletConnectKitConfig = {
43
+ clientId: "YOUR_DOGEOS_CLIENT_ID",
44
+ };
112
45
 
113
- if (!address) {
114
- return <div>No wallet connected</div>;
115
- }
46
+ function WalletButton() {
47
+ const { openModal, isConnected, isConnecting, error } = useWalletConnect();
48
+ const { address } = useAccount();
116
49
 
117
50
  return (
118
51
  <div>
119
- <div>Address: {address}</div>
120
- <div>Chain ID: {chainId}</div>
121
- <div>Chain Type: {chainType}</div>
122
- <div>Wallet: {currentWallet?.info?.name}</div>
52
+ <button type="button" disabled={isConnecting} onClick={openModal}>
53
+ {isConnecting ? "Connecting..." : isConnected ? address : "Connect wallet"}
54
+ </button>
55
+ {error ? <p role="alert">{error}</p> : null}
123
56
  </div>
124
57
  );
125
58
  }
126
- ```
127
-
128
- ### 4. Sign Message
129
-
130
- Use the `signMessage` method from the `useAccount` hook to sign messages:
131
-
132
- ```tsx
133
- // SignMessageButton.tsx
134
- import React from "react";
135
- import { useAccount } from "@dogeos/dogeos-sdk";
136
-
137
- export function SignMessageButton() {
138
- const { signMessage, address } = useAccount();
139
-
140
- const handleSignMessage = async () => {
141
- if (!signMessage) {
142
- console.error("Signing functionality not available");
143
- return;
144
- }
145
-
146
- try {
147
- const signature = await signMessage({
148
- message: "Hello Dogeos Wallet",
149
- });
150
- console.log("Signature result:", signature);
151
- } catch (error) {
152
- console.error("Signing failed:", error);
153
- }
154
- };
155
-
156
- if (!address) {
157
- return null;
158
- }
159
-
160
- return <button onClick={handleSignMessage}>Sign Message</button>;
161
- }
162
- ```
163
-
164
- ### 5. Sign In with Wallet (SIW)
165
-
166
- `signInWithWallet` constructs a message and returns its signature. It does not create a server session or return an authentication token. For EVM wallets it constructs an ERC-4361 (SIWE) message using the connected address and decimal chain ID. Supply your server-issued nonce and issuedAt, together with the expected domain and URI, so your server can reconstruct and verify the challenge. The helper preserves nonce and URI, normalizes issuedAt to ISO UTC, and signs the constructed bytes unchanged. A supplied address or chain ID must match the connected wallet. If your server already returns the complete message, use `signMessage({ message })` to sign those exact bytes instead.
167
-
168
- ```tsx
169
- // SignInButton.tsx
170
- import React from "react";
171
- import { useAccount } from "@dogeos/dogeos-sdk";
172
-
173
- export function SignInButton() {
174
- const { signInWithWallet, address } = useAccount();
175
-
176
- const handleSignIn = async () => {
177
- try {
178
- // Your server creates and retains these SIWE fields, including nonce and issuedAt.
179
- const challenge = await fetchSignInChallenge(address);
180
- const proof = await signInWithWallet(challenge);
181
- // Send the short-lived proof directly to your backend. Never log it or persist it in localStorage.
182
- await sendProofToBackend(proof);
183
- } catch (error) {
184
- console.error("Sign in failed:", error);
185
- }
186
- };
187
-
188
- if (!address) {
189
- return null;
190
- }
191
-
192
- return <button onClick={handleSignIn}>Sign In with Wallet</button>;
193
- }
194
- ```
195
-
196
- `fetchSignInChallenge` and `sendProofToBackend` above are application callbacks, not SDK endpoints. The server must verify the signature and expected challenge fields before creating a session. Version 4.0.1 corrects the EVM helper's previously nonstandard message format; custom verifiers that reconstructed the old text must adopt the SIWE format. No legacy-format fallback is performed.
197
-
198
- ## Configuration
199
-
200
- `WalletConnectProvider` accepts a `config` prop to customize the SDK's behavior.
201
-
202
- ### Basic Configuration
203
-
204
- ```tsx
205
- import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
206
- import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
207
-
208
- const dogeConfig: WalletConnectKitConfig = {
209
- clientId: "your-client-id",
210
- };
211
-
212
- export function App() {
213
- return (
214
- <WalletConnectProvider config={dogeConfig}>
215
- <YourApp />
216
- </WalletConnectProvider>
217
- );
218
- }
219
- ```
220
-
221
- ### Configure Supported Chains
222
-
223
- Chains are automatically loaded by default. If you need to customize chains, use the `getChains()` method:
224
- The examples below extend the `dogeConfig` object from the basic configuration example.
225
-
226
- ```tsx
227
- import { WalletConnectProvider, getChains } from "@dogeos/dogeos-sdk";
228
- import { useEffect, useState } from "react";
229
-
230
- export function App() {
231
- const [chains, setChains] = useState<
232
- Awaited<ReturnType<typeof getChains>> | undefined
233
- >(undefined);
234
-
235
- useEffect(() => {
236
- getChains().then(setChains);
237
- }, []);
238
-
239
- return (
240
- <WalletConnectProvider config={{ ...dogeConfig, chains }}>
241
- <YourApp />
242
- </WalletConnectProvider>
243
- );
244
- }
245
- ```
246
-
247
- ### Configure Custom Wallets
248
-
249
- Connectors are automatically loaded by default. If you need to customize connectors, use the `getConnectors()` method:
250
-
251
- ```tsx
252
- import { WalletConnectProvider, getConnectors } from "@dogeos/dogeos-sdk";
253
- import { useEffect, useState } from "react";
254
-
255
- export function App() {
256
- const [connectors, setConnectors] = useState<
257
- Awaited<ReturnType<typeof getConnectors>> | undefined
258
- >(undefined);
259
-
260
- useEffect(() => {
261
- getConnectors().then(setConnectors);
262
- }, []);
263
-
264
- return (
265
- <WalletConnectProvider config={{ ...dogeConfig, connectors }}>
266
- <YourApp />
267
- </WalletConnectProvider>
268
- );
269
- }
270
- ```
271
-
272
- ### Configure Login Options
273
-
274
- You can configure supported login methods, including basic logins (email, external wallets) and social logins (Google, X/Twitter):
275
-
276
- ```tsx
277
- import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
278
-
279
- const config = {
280
- ...dogeConfig,
281
- login: {
282
- // Basic login methods
283
- basicLogins: ["email", "externalWallets"], // or ["email"] or ["externalWallets"]
284
-
285
- // Social login methods
286
- socialLogins: [
287
- { type: "google" },
288
- { type: "x" },
289
- ],
290
- },
291
- };
292
-
293
- export function App() {
294
- return (
295
- <WalletConnectProvider config={config}>
296
- <YourApp />
297
- </WalletConnectProvider>
298
- );
299
- }
300
- ```
301
-
302
- Provider OAuth client IDs and credentials are owned by the DogeOS authentication
303
- authority for each environment. Consumer applications select the enabled login
304
- controls and provide only their registered DogeOS client ID. A successful SDK
305
- login continues to the associated embedded wallet automatically; returning
306
- wallet connections are restored by the provider without consumer session
307
- plumbing.
308
-
309
- ### Configure Theme
310
-
311
- You can customize the UI theme:
312
-
313
- ```tsx
314
- import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
315
- import type { ThemeConfig } from "@dogeos/dogeos-sdk";
316
-
317
- const config = {
318
- ...dogeConfig,
319
- theme: {
320
- themes: {
321
- light: {
322
- colors: {
323
- primary: {
324
- DEFAULT: "#FCD436",
325
- foreground: "#FFF",
326
- },
327
- background: "#FFFFFF",
328
- foreground: "#000000",
329
- },
330
- },
331
- dark: {
332
- colors: {
333
- primary: {
334
- DEFAULT: "#FF5CB8",
335
- foreground: "#FFF",
336
- },
337
- background: "#000000",
338
- foreground: "#FFFFFF",
339
- },
340
- },
341
- },
342
- } as ThemeConfig,
343
- };
344
-
345
- export function App() {
346
- return (
347
- <WalletConnectProvider config={config}>
348
- <YourApp />
349
- </WalletConnectProvider>
350
- );
351
- }
352
- ```
353
-
354
- ### Complete Configuration Example
355
-
356
- ```tsx
357
- import {
358
- WalletConnectProvider,
359
- getChains,
360
- getConnectors,
361
- } from "@dogeos/dogeos-sdk";
362
- import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
363
- import { useEffect, useState } from "react";
364
-
365
- export function App() {
366
- const [chains, setChains] = useState<
367
- Awaited<ReturnType<typeof getChains>> | undefined
368
- >(undefined);
369
- const [connectors, setConnectors] = useState<
370
- Awaited<ReturnType<typeof getConnectors>> | undefined
371
- >(undefined);
372
-
373
- useEffect(() => {
374
- const loadConfig = async () => {
375
- const [loadedChains, loadedConnectors] = await Promise.all([
376
- getChains(),
377
- getConnectors(),
378
- ]);
379
- setChains(loadedChains);
380
- setConnectors(loadedConnectors);
381
- };
382
- loadConfig();
383
- }, []);
384
-
385
- const config: WalletConnectKitConfig = {
386
- // WalletConnect configuration
387
- walletConnectProjectId: "your-project-id",
388
- clientId: "your-client-id",
389
- // DApp application metadata
390
- metadata: {
391
- name: "My DApp",
392
- description: "My decentralized application",
393
- url: "https://myapp.com",
394
- icons: ["https://myapp.com/icon.png"],
395
- },
396
-
397
- // Supported chains (must use getChains)
398
- chains,
399
-
400
- // Custom wallets (must use getConnectors)
401
- connectors,
402
-
403
- // Login configuration
404
- login: {
405
- basicLogins: ["email", "externalWallets"],
406
- socialLogins: [
407
- { type: "google" },
408
- { type: "x" },
409
- ],
410
- },
411
-
412
- // Theme configuration
413
- theme: {
414
- themes: {
415
- light: {
416
- colors: {
417
- primary: {
418
- DEFAULT: "#FCD436",
419
- foreground: "#FFF",
420
- },
421
- },
422
- },
423
- },
424
- },
425
- };
426
-
427
- if (!chains || !connectors) {
428
- return <div>Loading configuration...</div>;
429
- }
430
59
 
60
+ export default function App() {
431
61
  return (
432
62
  <WalletConnectProvider config={config}>
433
- <div>
434
- <h1>MyDoge Wallet Connect Example</h1>
435
- <ConnectButton />
436
- </div>
63
+ <WalletButton />
437
64
  </WalletConnectProvider>
438
65
  );
439
66
  }
440
67
  ```
441
68
 
442
- ## API Reference
443
-
444
- ### WalletConnectProvider
445
-
446
- Main Provider component for wrapping your application.
447
-
448
- **Props:**
449
-
450
- ```tsx
451
- interface WalletConnectProviderProps {
452
- children: React.ReactNode;
453
- config: WalletConnectKitConfig;
454
- }
455
- ```
456
-
457
- ### useWalletConnect
458
-
459
- Hook for controlling the wallet connection modal and managing connection state.
460
-
461
- **Returns:**
462
-
463
- ```tsx
464
- interface UseWalletConnect {
465
- // Modal control
466
- isOpenModal: boolean;
467
- openModal: () => void;
468
- closeModal: () => void;
469
-
470
- // Connection state
471
- isConnected: boolean;
472
- isConnecting: boolean;
473
- error: Error | null;
474
-
475
- // Connection operations
476
- connect: (variables?: ConnectVariables) => Promise<ConnectData>;
477
- disconnect: () => Promise<void>;
478
- }
479
- ```
480
-
481
- **Example:**
482
-
483
- ```tsx
484
- const {
485
- isOpenModal,
486
- openModal,
487
- closeModal,
488
- isConnected,
489
- isConnecting,
490
- connect,
491
- disconnect,
492
- } = useWalletConnect();
493
- ```
494
-
495
- On mobile, selecting a wallet without an injected provider may open the dApp in
496
- that wallet's browser. The SDK picker closes and clears its connecting state;
497
- the source tab is not connected by this handoff. If you call `connect()` directly,
498
- its promise rejects with `code: "WALLET_BROWSER_REDIRECT"` for this outcome.
499
- Handle that code as a browser handoff, not a completed connection. An existing
500
- connection in the source tab is preserved. Injected providers and WalletConnect
501
- sessions continue to resolve normally after connection approval.
502
-
503
- ### useAccount
504
-
505
- Hook for getting the currently connected account information and performing account-related operations.
506
-
507
- **Returns:**
508
-
509
- ```tsx
510
- interface UseAccount {
511
- // Account information
512
- address: string;
513
- balance?: string;
514
- chainType?: ChainType;
515
- chainId?: string;
516
- currentWallet?: Connector | null;
517
- currentProvider?: any;
518
-
519
- // Operations
520
- switchChain: (options: SwitchChainOptions) => Promise<boolean>;
521
- signMessage?: (params: {
522
- message: string;
523
- nonce?: string;
524
- }) => Promise<string | Uint8Array>;
525
- signInWithWallet: (params?: SignInParams) => Promise<string | Uint8Array>;
526
- }
527
- ```
528
-
529
- **Example:**
530
-
531
- ```tsx
532
- const {
533
- address,
534
- chainId,
535
- chainType,
536
- signMessage,
537
- signInWithWallet,
538
- switchChain,
539
- } = useAccount();
540
- ```
541
-
542
- ### getChains
543
-
544
- Utility function to get all available chains. Automatically fetches chains from the backend API and returns them in the config format.
545
-
546
- **Signature:**
547
-
548
- ```tsx
549
- function getChains(): Promise<Partial<Record<ChainType, EvmChain[] | any[]>>>;
550
- ```
551
-
552
- **Returns:**
553
-
554
- - A Promise that resolves to a chain configuration object containing all available chains
555
- - Automatically includes EVM, Solana, Aptos, and Dogecoin chains
556
- - Falls back to default chains if the API request fails
557
-
558
- **Example:**
559
-
560
- ```tsx
561
- import { getChains } from "@dogeos/dogeos-sdk";
562
- import { useEffect, useState } from "react";
563
-
564
- export function MyComponent() {
565
- const [chains, setChains] = useState<
566
- Awaited<ReturnType<typeof getChains>> | undefined
567
- >(undefined);
568
-
569
- useEffect(() => {
570
- const loadChains = async () => {
571
- const allChains = await getChains();
572
- setChains(allChains);
573
- };
574
- loadChains();
575
- }, []);
576
-
577
- // Use chains in your config
578
- const config = { ...dogeConfig, chains };
579
- }
580
- ```
581
-
582
- ## Advanced Usage
583
-
584
- ### Switch Chain
69
+ `openModal()` opens the connection flow. Once connected, it opens the account view. Use `disconnect()` from `useWalletConnect()` to disconnect the active wallet.
585
70
 
586
- Use the `switchChain` method from the `useAccount` hook to switch chains:
587
-
588
- ```tsx
589
- import { useAccount } from "@dogeos/dogeos-sdk";
590
- import type { Chain } from "@dogeos/dogeos-sdk";
591
-
592
- export function SwitchChainButton() {
593
- const { switchChain, chainId } = useAccount();
594
-
595
- const handleSwitchChain = async () => {
596
- const targetChain: Chain = {
597
- id: 137,
598
- name: "Polygon",
599
- nativeCurrency: {
600
- name: "MATIC",
601
- symbol: "MATIC",
602
- decimals: 18,
603
- },
604
- rpcUrls: {
605
- default: {
606
- http: ["https://polygon-rpc.com"],
607
- },
608
- },
609
- blockExplorers: {
610
- default: {
611
- name: "PolygonScan",
612
- url: "https://polygonscan.com",
613
- },
614
- },
615
- };
616
-
617
- try {
618
- const success = await switchChain({
619
- chainType: "evm",
620
- chainInfo: targetChain,
621
- });
622
-
623
- if (success) {
624
- console.log("Chain switched successfully");
625
- }
626
- } catch (error) {
627
- console.error("Chain switch failed:", error);
628
- }
629
- };
630
-
631
- return <button onClick={handleSwitchChain}>Switch to Polygon</button>;
632
- }
633
- ```
71
+ In Next.js App Router, put the provider in a client component, as above. See the [Next.js setup guide](https://docs.dogeos.com/en/sdk#nextjs) for a layout example.
634
72
 
635
- ### Get Wallet Providers and Connectors
73
+ ## Read the connected account
636
74
 
637
- Use the `useConnectors` hook to get all available providers from the currently connected wallet, grouped by chain type.
638
- This is useful for multi-chain wallets (for example, OKX Wallet supports EVM, Solana, Aptos, Dogecoin, etc.).
639
- Different chain providers are usually based on different underlying protocols, for example EVM providers commonly follow the EIP-1193 standard, while Dogecoin providers may come from Unisat-compatible implementations.
75
+ `useAccount()` exposes the active address, chain, wallet and provider.
640
76
 
641
77
  ```tsx
642
- import { useConnectors } from "@dogeos/dogeos-sdk";
643
-
644
- export function SignMessageExamples() {
645
- const { connectors } = useConnectors();
646
-
647
- if (!connectors) {
648
- return <div>No wallet connected</div>;
649
- }
650
-
651
- // connectors is an object with chain types as keys
652
- // e.g., { evm: { provider, protocol, standard }, dogecoin: { provider, protocol, standard }, ... }
653
- const evmConnector = connectors.evm ?? null;
654
- const dogeConnector = connectors.dogecoin ?? null;
655
-
656
- // EVM provider usually follows EIP-1193 standard
657
- const evmProvider = evmConnector?.provider;
658
- // Dogecoin provider usually comes from a Unisat-compatible provider
659
- const dogeProvider = dogeConnector?.provider;
660
-
661
- const handleEvmSignMessage = async () => {
662
- if (!evmProvider) return;
663
-
664
- const accounts = await evmProvider.request({
665
- method: "eth_requestAccounts",
666
- });
667
- const from = accounts[0];
78
+ "use client";
668
79
 
669
- const message = "Hello from EVM";
80
+ import { useAccount, useWalletConnect } from "@dogeos/dogeos-sdk";
670
81
 
671
- // EIP-1193 personal_sign example
672
- const signature = await evmProvider.request({
673
- method: "personal_sign",
674
- params: [message, from],
675
- });
82
+ export function AccountDetails() {
83
+ const { isConnected } = useWalletConnect();
84
+ const { address, chainType, chainId } = useAccount();
676
85
 
677
- console.log("EVM signature:", signature);
678
- };
679
-
680
- const handleDogeSignMessage = async () => {
681
- if (!dogeProvider) return;
682
-
683
- const message = "Hello from Dogecoin";
684
-
685
- // Unisat-like Dogecoin signMessage example
686
- // Most Unisat-compatible providers expose a signMessage method
687
- const signature = await dogeProvider.signMessage(message);
688
-
689
- console.log("Dogecoin signature:", signature);
690
- };
86
+ if (!isConnected) return <p>Connect a wallet to continue.</p>;
691
87
 
692
88
  return (
693
89
  <div>
694
- <button disabled={!evmProvider} onClick={handleEvmSignMessage}>
695
- Sign EVM Message
696
- </button>
697
- <button disabled={!dogeProvider} onClick={handleDogeSignMessage}>
698
- Sign Dogecoin Message
699
- </button>
90
+ <p>{address}</p>
91
+ <p>{chainType}: {chainId}</p>
700
92
  </div>
701
93
  );
702
94
  }
703
95
  ```
704
96
 
705
- **Returns:**
97
+ The same hook provides `switchChain()`, `signMessage()` and `signInWithWallet()`. Use `currentProvider` for chain-specific requests, or `useConnectors()` to access the connected wallet's other chain providers. See [account actions and signing examples](https://docs.dogeos.com/en/sdk/guides).
706
98
 
707
- ```tsx
708
- interface UseConnectors {
709
- // All available providers from the current wallet, keyed by chain type
710
- connectors: ConnectorProviders | null;
711
- // The currently active provider for the selected chain
712
- currentProvider: WalletProvider | null;
713
- }
714
- ```
99
+ A wallet connection or signature alone does not create an authenticated session for your backend. For wallet-based sign-in, have your server issue and verify a fresh challenge before creating a session. Follow the [sign-in guide](https://docs.dogeos.com/en/sdk/guides#sign-in-with-wallet).
715
100
 
716
- **Note:** `connectors` contains all connectors supported by the current wallet. For example, if you connect OKX Wallet, `connectors` may include `evm`, `dogecoin`, `solana`, and `aptos` connectors. Each entry provides a `provider` instance that you can use directly to call chain-specific RPC methods.
101
+ ## Connection and readiness
717
102
 
718
- ### Integration with Wagmi
103
+ Use the state that matches what your app needs.
719
104
 
720
- 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:
105
+ | Field | Meaning |
106
+ | --- | --- |
107
+ | `isConnected` | A wallet is connected. Use it with the current account and provider for wallet actions. |
108
+ | `isConnecting` | A wallet connection attempt is in progress. |
109
+ | `connectionStatus` | `disconnected`, `connecting` or `connected`. |
110
+ | `walletStatus` | Embedded wallet state: `disabled`, `initializing`, `ready`, `unavailable` or `error`. |
111
+ | `isWalletReady` | The embedded wallet is ready to accept login. |
721
112
 
722
- ```tsx
723
- import { WagmiProvider } from "wagmi";
724
- import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
725
- import { config } from "./wagmi-config";
113
+ Inside MyDoge, the SDK selects the native wallet automatically. Keep your normal provider configuration and connection button. A native or external wallet can be connected while the embedded wallet is disabled, so do not require `isWalletReady` for all wallet actions. See [native wallet connections](https://docs.dogeos.com/en/sdk/embedded-wallets#native-first-connection-in-mydoge).
726
114
 
727
- export function App() {
728
- return (
729
- <WagmiProvider config={config}>
730
- <WalletConnectProvider config={dogeConfig}>
731
- <YourApp />
732
- </WalletConnectProvider>
733
- </WagmiProvider>
734
- );
735
- }
736
- ```
115
+ ## Configure your app
737
116
 
738
- ### Error Handling
117
+ Pass optional settings alongside `clientId` in `WalletConnectKitConfig`.
739
118
 
740
- Always handle errors in connections and operations:
119
+ | Option | Use it to |
120
+ | --- | --- |
121
+ | `chains` | Choose supported networks, grouped by chain family. |
122
+ | `defaultConnectChain` | Choose the initial chain family, such as `"evm"`. |
123
+ | `login` | Choose which email, social and external wallet options appear. |
124
+ | `metadata` | Set your app's name, description, URL and icon. |
125
+ | `theme` | Set colors and light or dark mode. |
126
+ | `walletConnectProjectId` | Enable WalletConnect with your own project ID. |
127
+ | `connectors` | Customize the wallet list using `getConnectors()`. |
741
128
 
742
- ```tsx
743
- import { useWalletConnect, useAccount } from "@dogeos/dogeos-sdk";
744
-
745
- export function WalletComponent() {
746
- const { error, isConnecting } = useWalletConnect();
747
- const { signMessage } = useAccount();
748
-
749
- const handleSign = async () => {
750
- try {
751
- if (!signMessage) {
752
- throw new Error("Signing functionality not available");
753
- }
754
-
755
- const signature = await signMessage({ message: "Hello" });
756
- console.log("Signing successful:", signature);
757
- } catch (error) {
758
- console.error("Signing failed:", error);
759
- // Display error message to user
760
- }
761
- };
762
-
763
- if (error) {
764
- return <div>Error: {error.message}</div>;
765
- }
766
-
767
- if (isConnecting) {
768
- return <div>Connecting...</div>;
769
- }
770
-
771
- return <button onClick={handleSign}>Sign</button>;
772
- }
773
- ```
129
+ See [configuration](https://docs.dogeos.com/en/sdk/configuration) for examples, including [DogeOS Chikyū Testnet](https://docs.dogeos.com/en/sdk/configuration#chains).
774
130
 
775
- ## Type Definitions
776
-
777
- ### WalletConnectKitConfig
778
-
779
- `walletConnectProjectId` is optional and has no SDK default. To enable WalletConnect,
780
- create a project in the [Reown Dashboard](https://dashboard.reown.com/) for your
781
- application, configure its allowed origins, and pass that project's ID. This public
782
- project ID is separate from your DogeOS `clientId`. Omitting it or passing a blank
783
- value hides WalletConnect and skips its discovery and initialization; injected
784
- wallets and the other configured login methods remain available. Rejected project
785
- IDs surface the provider error without a fallback project.
786
-
787
- ````tsx
788
- interface WalletConnectKitConfig {
789
- connectors?: WalletConfig[];
790
- chains?: Partial<Record<ChainType, EvmChain[] | any[]>>;
791
- walletConnectProjectId?: string;
792
- /**
793
- * Default connect chain
794
- * @default undefined
795
- * @example
796
- * ```tsx
797
- * import { WalletConnectProvider } from "@dogeos/dogeos-sdk";
798
- * const config: WalletConnectKitConfig = {
799
- * defaultConnectChain: 'evm',
800
- * };
801
- */
802
- defaultConnectChain?: ChainType;
803
- metadata?: {
804
- name: string;
805
- description: string;
806
- url: string;
807
- icons: string[];
808
- };
809
- clientId: string;
810
- theme?: ThemeConfig;
811
- login?: UserLoginConfig;
812
- embeddedWalletConfig?: {
813
- /**
814
- * @default "prod-dogeos"
815
- */
816
- stage?: "prod-dogeos" | "prod" | "pre" | "dev";
817
- };
818
- }
819
- ````
820
-
821
- ### Chain
822
-
823
- ```tsx
824
- interface Chain {
825
- id: number;
826
- name: string;
827
- nativeCurrency: {
828
- name: string;
829
- symbol: string;
830
- decimals: number;
831
- };
832
- rpcUrls: {
833
- default: {
834
- http: readonly string[];
835
- };
836
- };
837
- blockExplorers?: {
838
- default: {
839
- name: string;
840
- url: string;
841
- };
842
- };
843
- testnet?: boolean;
844
- }
845
- ```
131
+ ### WalletConnect
846
132
 
847
- ### ChainType
133
+ To enable WalletConnect, create a project in the [Reown dashboard](https://dashboard.reown.com/) and pass its project ID. It is separate from your DogeOS client ID.
848
134
 
849
135
  ```tsx
850
- type ChainType = "evm" | "solana" | "aptos" | "dogecoin";
851
- ```
852
-
853
- ## Exports
854
-
855
- - `WalletConnectProvider` - Main Provider component
856
- - `useAccount` - Account information Hook
857
- - `useWalletConnect` - Connect Hook
858
- - `useConnectors` - Providers information Hook (get all available providers from current wallet)
859
- - `getChains` - Utility function to configure chains (can wrap backend API chains)
860
- - Types: `WalletConnectKitConfig`, `Chain`, `WalletConfig`, `UseAccount`, `ChainType`, `ModalView`, `ThemeConfig`, `UserLoginConfig`
861
-
862
- ## FAQ
863
-
864
- ### How to use with Next.js?
136
+ import type { WalletConnectKitConfig } from "@dogeos/dogeos-sdk";
865
137
 
866
- ```js
867
- "use client"; // add "use client" at your index router page
138
+ const config: WalletConnectKitConfig = {
139
+ clientId: "YOUR_DOGEOS_CLIENT_ID",
140
+ walletConnectProjectId: "YOUR_WALLETCONNECT_PROJECT_ID",
141
+ metadata: {
142
+ name: "My DogeOS app",
143
+ description: "My DogeOS application",
144
+ url: "https://app.example.com",
145
+ icons: ["https://app.example.com/icon.png"],
146
+ },
147
+ };
868
148
  ```
869
149
 
870
- ### Supported Next.js version
871
-
872
- - Next.js 14 and 15 are supported.
873
-
874
- ### What Content Security Policy entries are required?
875
-
876
- If your app uses a restrictive CSP, allow the embedded-wallet, Social Relay, and Web3 Assets origins documented for the published SDK release you install. Those origins are compiled into the SDK by the release pipeline and cannot be overridden by the consumer app.
877
-
878
- Use the exact origins from that release in `frame-src` and `connect-src`; do not substitute consumer-controlled endpoints.
150
+ Without `walletConnectProjectId`, WalletConnect is hidden. Email, social login and supported injected wallets remain available. Add your app's origins to your Reown project if you use its origin allowlist.
879
151
 
880
- ### How to get WalletConnect Project ID?
152
+ ## Render the wallet UI inline
881
153
 
882
- 1. Visit [WalletConnect Cloud](https://cloud.walletconnect.com)
883
- 2. Create a new project or select an existing project
884
- 3. Copy the Project ID and use it in your configuration
885
-
886
- ### How to customize chains and connectors?
887
-
888
- You can use `getChains()` and `getConnectors()` methods to customize chains and connectors:
154
+ Use `WalletConnectEmbed` inside your existing provider when the wallet flow belongs in a page instead of a modal.
889
155
 
890
156
  ```tsx
891
- import { getChains, getConnectors } from "@dogeos/dogeos-sdk";
892
-
893
- // Get all available chains
894
- const chains = await getChains();
157
+ "use client";
895
158
 
896
- // Get all available connectors
897
- const connectors = await getConnectors();
159
+ import { WalletConnectEmbed } from "@dogeos/dogeos-sdk";
898
160
 
899
- // Use in config
900
- const config = { ...dogeConfig, chains, connectors };
161
+ export function WalletPanel() {
162
+ return <WalletConnectEmbed style={{ width: "100%", maxWidth: 448 }} />;
163
+ }
901
164
  ```
902
165
 
903
- 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.
904
-
905
- ### What chain types are supported?
906
-
907
- Currently, EVM chains are primarily supported, along with Solana, Aptos, and Dogecoin chains.
166
+ ## Documentation
908
167
 
909
- > For internal release and publishing workflow, see `RELEASE.md` in the repository root (not published to npm).
168
+ - [Quickstart](https://docs.dogeos.com/en/sdk) for installation and provider setup.
169
+ - [Configuration](https://docs.dogeos.com/en/sdk/configuration) for chains, login options and themes.
170
+ - [Core workflows](https://docs.dogeos.com/en/sdk/guides) for signing, network changes and provider requests.
171
+ - [Embedded wallets](https://docs.dogeos.com/en/sdk/embedded-wallets) for inline UI and native MyDoge behavior.
172
+ - [Wagmi integration](https://docs.dogeos.com/en/sdk/wagmi) for apps that already use Wagmi hooks.
173
+ - [API reference](https://docs.dogeos.com/en/sdk/api/hooks) for components, hooks and helpers.
174
+ - [Troubleshooting](https://docs.dogeos.com/en/sdk/troubleshooting) for connection errors and browser requirements.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dogeos/dogeos-sdk",
3
3
  "private": false,
4
- "version": "4.0.4-beta.0",
4
+ "version": "4.0.4",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -87,11 +87,11 @@
87
87
  "vitest": "^4.0.18",
88
88
  "wagmi": "^2.0.0",
89
89
  "@dogeos/dogeos-ui": "0.0.14",
90
- "@dogeos/inject-providers": "0.0.21",
91
90
  "@dogeos/embedded-wallet-providers": "0.0.28",
91
+ "@dogeos/inject-providers": "0.0.21",
92
92
  "@dogeos/oidc-auth": "0.0.20",
93
- "@dogeos/wallet-utils": "0.0.23",
94
- "@dogeos/wallet-adaptor-base": "0.0.25"
93
+ "@dogeos/wallet-adaptor-base": "0.0.25",
94
+ "@dogeos/wallet-utils": "0.0.23"
95
95
  },
96
96
  "sideEffects": [
97
97
  "**/*.css",