@tomo-inc/wallet-connect-kit 0.0.17 → 0.0.19
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 +53 -17
- package/dist/index.d.ts +54 -38
- package/dist/index.js +6181 -10
- package/dist/wallet-connect-kit.css +1 -1
- package/package.json +7 -4
- package/dist/features-animation-C9buMQ2V.js +0 -2509
- package/dist/index-Bc0f3Cwf.js +0 -1423
- package/dist/index-DrBi1SXh.js +0 -35049
- package/dist/index-huu0-LA6.js +0 -18
- package/dist/src-UW24ZMRV-CvlP3YUJ.js +0 -5
package/README.md
CHANGED
|
@@ -646,33 +646,69 @@ export function SwitchChainButton() {
|
|
|
646
646
|
|
|
647
647
|
### Get Wallet Providers and Connectors
|
|
648
648
|
|
|
649
|
-
Use the `useConnectors` hook to get all available
|
|
649
|
+
Use the `useConnectors` hook to get all available providers from the currently connected wallet, grouped by chain type.
|
|
650
|
+
This is useful for multi-chain wallets (for example, OKX Wallet supports EVM, Solana, Aptos, Dogecoin, etc.).
|
|
651
|
+
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.
|
|
650
652
|
|
|
651
653
|
```tsx
|
|
652
654
|
import { useConnectors } from "@tomo-inc/wallet-connect-kit";
|
|
653
655
|
|
|
654
|
-
export function
|
|
655
|
-
const { connectors
|
|
656
|
+
export function SignMessageExamples() {
|
|
657
|
+
const { connectors } = useConnectors();
|
|
656
658
|
|
|
657
659
|
if (!connectors) {
|
|
658
660
|
return <div>No wallet connected</div>;
|
|
659
661
|
}
|
|
660
662
|
|
|
661
663
|
// connectors is an object with chain types as keys
|
|
662
|
-
// e.g., { evm: { provider, protocol, standard },
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
// e.g., { evm: { provider, protocol, standard }, dogecoin: { provider, protocol, standard }, ... }
|
|
665
|
+
const evmConnector = connectors.evm ?? null;
|
|
666
|
+
const dogeConnector = connectors.dogecoin ?? null;
|
|
667
|
+
|
|
668
|
+
// EVM provider usually follows EIP-1193 standard
|
|
669
|
+
const evmProvider = evmConnector?.provider;
|
|
670
|
+
// Dogecoin provider usually comes from a Unisat-compatible provider
|
|
671
|
+
const dogeProvider = dogeConnector?.provider;
|
|
672
|
+
|
|
673
|
+
const handleEvmSignMessage = async () => {
|
|
674
|
+
if (!evmProvider) return;
|
|
675
|
+
|
|
676
|
+
const accounts = await evmProvider.request({
|
|
677
|
+
method: "eth_requestAccounts",
|
|
678
|
+
});
|
|
679
|
+
const from = accounts[0];
|
|
680
|
+
|
|
681
|
+
const message = "Hello from EVM";
|
|
682
|
+
|
|
683
|
+
// EIP-1193 personal_sign example
|
|
684
|
+
const signature = await evmProvider.request({
|
|
685
|
+
method: "personal_sign",
|
|
686
|
+
params: [message, from],
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
console.log("EVM signature:", signature);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const handleDogeSignMessage = async () => {
|
|
693
|
+
if (!dogeProvider) return;
|
|
694
|
+
|
|
695
|
+
const message = "Hello from Dogecoin";
|
|
696
|
+
|
|
697
|
+
// Unisat-like Dogecoin signMessage example
|
|
698
|
+
// Most Unisat-compatible providers expose a signMessage method
|
|
699
|
+
const signature = await dogeProvider.signMessage(message);
|
|
700
|
+
|
|
701
|
+
console.log("Dogecoin signature:", signature);
|
|
702
|
+
};
|
|
666
703
|
|
|
667
704
|
return (
|
|
668
705
|
<div>
|
|
669
|
-
<
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
</
|
|
675
|
-
<p>Current Provider: {currentProvider ? "Connected" : "Not connected"}</p>
|
|
706
|
+
<button disabled={!evmProvider} onClick={handleEvmSignMessage}>
|
|
707
|
+
Sign EVM Message
|
|
708
|
+
</button>
|
|
709
|
+
<button disabled={!dogeProvider} onClick={handleDogeSignMessage}>
|
|
710
|
+
Sign Dogecoin Message
|
|
711
|
+
</button>
|
|
676
712
|
</div>
|
|
677
713
|
);
|
|
678
714
|
}
|
|
@@ -681,15 +717,15 @@ export function ProvidersInfo() {
|
|
|
681
717
|
**Returns:**
|
|
682
718
|
|
|
683
719
|
```tsx
|
|
684
|
-
interface
|
|
720
|
+
interface UseConnectors {
|
|
685
721
|
// All available providers from the current wallet, keyed by chain type
|
|
686
722
|
connectors: ConnectorProviders | null;
|
|
687
|
-
// The currently active provider
|
|
723
|
+
// The currently active provider for the selected chain
|
|
688
724
|
currentProvider: WalletProvider | null;
|
|
689
725
|
}
|
|
690
726
|
```
|
|
691
727
|
|
|
692
|
-
**Note:** `connectors` contains all connectors supported by the current wallet. For example, if you connect OKX Wallet, `connectors` may include `evm`, `solana`, and `aptos` connectors.
|
|
728
|
+
**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.
|
|
693
729
|
|
|
694
730
|
### Integration with Wagmi
|
|
695
731
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,15 @@ import { ConnectorProvider } from '../../../wallet-adaptor-base';
|
|
|
7
7
|
import { ConnectorProviders } from '../../../../wallet-adaptor-base';
|
|
8
8
|
import { default as default_2 } from 'react';
|
|
9
9
|
import type { DefaultThemeType } from '@heroui/theme';
|
|
10
|
+
import { EmbeddedWallet } from '@tomo-inc/embedded-wallet-providers';
|
|
10
11
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
11
12
|
import type { LayoutTheme } from '@heroui/theme';
|
|
12
13
|
import { SignInParams } from '../../../wallet-adaptor-base';
|
|
13
14
|
import { WalletConfig } from '../../../wallet-adaptor-base';
|
|
14
15
|
import { WalletConfig as WalletConfig_2 } from '../../../../wallet-adaptor-base';
|
|
16
|
+
import { WalletInfo } from '../../../wallet-adaptor-base';
|
|
15
17
|
import { WalletProvider } from '@tomo-inc/inject-providers';
|
|
18
|
+
import { WalletProvider as WalletProvider_2 } from '../../../wallet-adaptor-base';
|
|
16
19
|
import { WalletProvider as WalletProvider_3 } from '../../../../wallet-adaptor-base';
|
|
17
20
|
|
|
18
21
|
export declare type BasicLoginType = "email" | "externalWallets";
|
|
@@ -65,6 +68,23 @@ export declare interface ConnectVariables {
|
|
|
65
68
|
chainId?: string;
|
|
66
69
|
}
|
|
67
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Connected information from embedded wallet
|
|
73
|
+
*/
|
|
74
|
+
declare interface EmbeddedWalletConnectedInfo {
|
|
75
|
+
evmProvider?: ProviderConnectionInfo;
|
|
76
|
+
solanaProvider?: ProviderConnectionInfo;
|
|
77
|
+
dogeProvider?: ProviderConnectionInfo;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare interface EmbeddedWalletState {
|
|
81
|
+
wallet: EmbeddedWallet | null;
|
|
82
|
+
isAvailable: boolean;
|
|
83
|
+
message: string | null;
|
|
84
|
+
connectedInfo: EmbeddedWalletConnectedInfo | null;
|
|
85
|
+
isLoading: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
68
88
|
export declare type EvmChain = Chain_2;
|
|
69
89
|
|
|
70
90
|
/**
|
|
@@ -101,8 +121,16 @@ export declare enum ModalView {
|
|
|
101
121
|
SignInWallet = "SIGN_IN_WALLET",
|
|
102
122
|
WalletConnect = "WALLET_CONNECT",
|
|
103
123
|
UnsupportChain = "UNSUPPORT_CHAIN",
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
WalletHome = "WALLET_HOME"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Provider connection information
|
|
129
|
+
*/
|
|
130
|
+
declare interface ProviderConnectionInfo {
|
|
131
|
+
chainType: ChainTypeEnum;
|
|
132
|
+
connected: boolean;
|
|
133
|
+
address?: string[];
|
|
106
134
|
}
|
|
107
135
|
|
|
108
136
|
/**
|
|
@@ -137,6 +165,7 @@ export declare type SwitchChainOptions = {
|
|
|
137
165
|
export declare type ThemeConfig = ThemeConfig_2;
|
|
138
166
|
|
|
139
167
|
declare type ThemeConfig_2 = {
|
|
168
|
+
prefix?: string;
|
|
140
169
|
layout?: LayoutTheme;
|
|
141
170
|
themes?: ConfigThemes;
|
|
142
171
|
defaultTheme?: DefaultThemeType;
|
|
@@ -170,6 +199,25 @@ export declare const useConnectors: () => {
|
|
|
170
199
|
currentProvider: WalletProvider_3 | null;
|
|
171
200
|
};
|
|
172
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Hook to access embedded wallet from anywhere in the app
|
|
204
|
+
* Make sure your component is wrapped with WalletConnectProvider
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```tsx
|
|
208
|
+
* const { wallet, isAvailable, message, connectedInfo, isLoading } = useEmbeddedWallet();
|
|
209
|
+
*
|
|
210
|
+
* if (isLoading) {
|
|
211
|
+
* return <div>Loading embedded wallet...</div>;
|
|
212
|
+
* }
|
|
213
|
+
*
|
|
214
|
+
* if (isAvailable && wallet) {
|
|
215
|
+
* // Use embedded wallet
|
|
216
|
+
* }
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export declare const useEmbeddedWallet: () => EmbeddedWalletState;
|
|
220
|
+
|
|
173
221
|
export declare interface UserLoginConfig {
|
|
174
222
|
basicLogins?: BasicLoginType[];
|
|
175
223
|
socialLogins?: SocialLoginProvider[];
|
|
@@ -243,7 +291,7 @@ export declare interface WalletConnectKitConfig {
|
|
|
243
291
|
* ```tsx
|
|
244
292
|
* import { WalletConnectProvider } from "@tomo-inc/wallet-connect-kit";
|
|
245
293
|
* const config: WalletConnectKitConfig = {
|
|
246
|
-
* defaultConnectChain: ChainTypeEnum.EVM,
|
|
294
|
+
* defaultConnectChain: ChainTypeEnum.EVM as ChainType,
|
|
247
295
|
* };
|
|
248
296
|
*/
|
|
249
297
|
defaultConnectChain?: ChainType;
|
|
@@ -287,15 +335,11 @@ export declare interface WalletConnectKitConfig {
|
|
|
287
335
|
* Based on standard Connector from wallet-adaptor-base
|
|
288
336
|
*/
|
|
289
337
|
export declare type WalletConnector = Connector & {
|
|
338
|
+
providers?: any;
|
|
290
339
|
isEmbeddedWallet?: boolean;
|
|
291
340
|
logout?: () => Promise<boolean>;
|
|
292
341
|
};
|
|
293
342
|
|
|
294
|
-
/**
|
|
295
|
-
* Thin wrapper: only derives config and renders QueryClientProvider > Content.
|
|
296
|
-
* All wallet/context state and useEmbeddedWalletInternal (useQuery) run inside Content,
|
|
297
|
-
* so they are under QueryClientProvider and WalletConnectContext.Provider.
|
|
298
|
-
*/
|
|
299
343
|
export declare const WalletConnectProvider: ({ children, config }: WalletConnectProviderProps) => JSX_2.Element | null;
|
|
300
344
|
|
|
301
345
|
declare interface WalletConnectProviderProps {
|
|
@@ -303,36 +347,8 @@ declare interface WalletConnectProviderProps {
|
|
|
303
347
|
config?: WalletConnectKitConfig;
|
|
304
348
|
}
|
|
305
349
|
|
|
306
|
-
export {
|
|
350
|
+
export { WalletInfo }
|
|
307
351
|
|
|
308
|
-
|
|
309
|
-
* Wallet metadata information (business layer)
|
|
310
|
-
* Contains wallet display information like name, icon, links, etc.
|
|
311
|
-
* This is different from WalletProviderType (actual provider implementation)
|
|
312
|
-
*/
|
|
313
|
-
declare interface WalletProvider_2 {
|
|
314
|
-
uuid: string;
|
|
315
|
-
name: string;
|
|
316
|
-
namespace?: string;
|
|
317
|
-
icon: string;
|
|
318
|
-
iconBackground?: string;
|
|
319
|
-
rdns?: string;
|
|
320
|
-
links: {
|
|
321
|
-
homepage?: string;
|
|
322
|
-
ios_install?: string;
|
|
323
|
-
android_install?: string;
|
|
324
|
-
chrome_install?: string;
|
|
325
|
-
mobile?: string;
|
|
326
|
-
qrCode?: string;
|
|
327
|
-
edge?: string;
|
|
328
|
-
firefox?: string;
|
|
329
|
-
opera?: string;
|
|
330
|
-
safari?: string;
|
|
331
|
-
macos?: string;
|
|
332
|
-
windows?: string;
|
|
333
|
-
linux?: string;
|
|
334
|
-
desktop?: string;
|
|
335
|
-
};
|
|
336
|
-
}
|
|
352
|
+
export { WalletProvider }
|
|
337
353
|
|
|
338
354
|
export { }
|