@tomo-inc/wallet-connect-kit 0.0.16 → 0.0.18
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/{features-animation-C9buMQ2V.js → features-animation-Czbt7YWI.js} +1 -1
- package/dist/{index-DrBi1SXh.js → index-CKW2YGSw.js} +5085 -5126
- package/dist/index-CuWvAl7U.js +1423 -0
- package/dist/index-Cvucm6Hk.js +18 -0
- package/dist/index.d.ts +8 -38
- package/dist/index.js +2 -2
- package/dist/src-UW24ZMRV-dmt8vgSd.js +5 -0
- package/dist/wallet-connect-kit.css +1 -1
- package/package.json +3 -3
- package/dist/index-Bc0f3Cwf.js +0 -1423
- 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
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as Ct, H as Z, I as Ie, d as q, J as Ee, e as Mt, K as Mn, p as Ae, N as Fn, O as Dn, Q as Rn, a as P, R as le, T as On, U as In, V as Ne, W as H, X as Ft, b as Y, Y as En, Z as Nn, f as ne, w as Dt, B as ue, n as I, c as se, _ as ce, $ as Kn, h as Bn, r as Rt, a0 as Ke, a1 as Ln, x as kn, a2 as _n, j as O, a3 as Ot, a4 as It, a5 as Et, a6 as He, a7 as Nt, E as Gn, a8 as Un, a9 as $n, aa as qe, ab as jn, ac as Wn, ad as zn, ae as Hn, af as qn, ag as Yn, ah as Xn, ai as Zn, aj as Jn, ak as Qn, al as es } from "./index-
|
|
1
|
+
import { G as Ct, H as Z, I as Ie, d as q, J as Ee, e as Mt, K as Mn, p as Ae, N as Fn, O as Dn, Q as Rn, a as P, R as le, T as On, U as In, V as Ne, W as H, X as Ft, b as Y, Y as En, Z as Nn, f as ne, w as Dt, B as ue, n as I, c as se, _ as ce, $ as Kn, h as Bn, r as Rt, a0 as Ke, a1 as Ln, x as kn, a2 as _n, j as O, a3 as Ot, a4 as It, a5 as Et, a6 as He, a7 as Nt, E as Gn, a8 as Un, a9 as $n, aa as qe, ab as jn, ac as Wn, ad as zn, ae as Hn, af as qn, ag as Yn, ah as Xn, ai as Zn, aj as Jn, ak as Qn, al as es } from "./index-CKW2YGSw.js";
|
|
2
2
|
import { Fragment as ts } from "react";
|
|
3
3
|
function Kt(t, e) {
|
|
4
4
|
if (!Array.isArray(e))
|