@gardenfi/wallet-connectors 2.4.2 → 2.4.3
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 +63 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @gardenfi/wallet-connectors
|
|
2
|
+
|
|
3
|
+
The `@gardenfi/wallet-connectors` package handles bitcoin wallet connections across different providers (OKX, Unisat, Xverse, Phantom, Keplr, Leap) with a unified interface. It supports mainnet and testnet networks, provides balance checking capabilities, and offers a React context for managing wallet state throughout your application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @gardenfi/wallet-connectors
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Setup Provider
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { BTCWalletProvider } from '@gardenfi/wallet-connectors';
|
|
17
|
+
import { Network } from '@gardenfi/utils';
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<BTCWalletProvider network={Network.MAINNET} store={localStorage}>
|
|
22
|
+
<YourApp />
|
|
23
|
+
</BTCWalletProvider>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Connect to Wallet
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useBitcoinWallet } from '@gardenfi/wallet-connectors';
|
|
32
|
+
|
|
33
|
+
function WalletConnect() {
|
|
34
|
+
const { availableWallets, connect, account, isConnected, disconnect } =
|
|
35
|
+
useBitcoinWallet();
|
|
36
|
+
|
|
37
|
+
const handleConnect = async (wallet) => {
|
|
38
|
+
const result = await connect(wallet);
|
|
39
|
+
if (result.ok) {
|
|
40
|
+
console.log('Connected to wallet');
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div>
|
|
46
|
+
{!isConnected ? (
|
|
47
|
+
<div>
|
|
48
|
+
{Object.values(availableWallets).map((wallet) => (
|
|
49
|
+
<button key={wallet.id} onClick={() => handleConnect(wallet)}>
|
|
50
|
+
Connect {wallet.name}
|
|
51
|
+
</button>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
) : (
|
|
55
|
+
<div>
|
|
56
|
+
<p>Connected: {account}</p>
|
|
57
|
+
<button onClick={disconnect}>Disconnect</button>
|
|
58
|
+
</div>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/wallet-connectors",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@gardenfi/core": "2.5.
|
|
41
|
-
"@gardenfi/utils": "2.5.
|
|
40
|
+
"@gardenfi/core": "2.5.3",
|
|
41
|
+
"@gardenfi/utils": "2.5.3",
|
|
42
42
|
"axios": "^1.7.9",
|
|
43
43
|
"bitcoinjs-lib": "^6.1.7",
|
|
44
44
|
"react": "^18.3.1",
|