@btc-vision/walletconnect 1.5.0 → 1.5.2
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/.prettierrc.json +1 -1
- package/CHANGELOG.md +83 -0
- package/README.md +11 -11
- package/browser/consts.d.ts +2 -0
- package/browser/context/WalletConnectContext.d.ts +18 -0
- package/browser/hooks/WalletConnectHook.d.ts +2 -0
- package/browser/index.d.ts +4 -2
- package/browser/index.js +1 -1
- package/browser/index.js.LICENSE.txt +0 -2
- package/browser/provider/WalletConnectProvider.d.ts +9 -0
- package/browser/types.d.ts +11 -0
- package/browser/utils/accessibility/definitions.d.ts +2 -0
- package/browser/utils/accessibility/errorDecoder.d.ts +2 -0
- package/browser/utils/accessibility/patterns.d.ts +13 -0
- package/browser/wallets/controller.d.ts +29 -0
- package/browser/wallets/index.d.ts +4 -0
- package/browser/wallets/opwallet/controller.d.ts +26 -0
- package/browser/wallets/opwallet/interface.d.ts +5 -0
- package/browser/wallets/types.d.ts +34 -0
- package/browser/wallets/unisat/controller.d.ts +26 -0
- package/browser/wallets/unisat/interface.d.ts +5 -0
- package/build/consts.d.ts +2 -0
- package/build/consts.js +6 -0
- package/build/context/WalletConnectContext.d.ts +18 -0
- package/build/context/WalletConnectContext.js +2 -0
- package/build/hooks/WalletConnectHook.d.ts +2 -0
- package/build/hooks/WalletConnectHook.js +9 -0
- package/build/index.d.ts +4 -2
- package/build/index.js +4 -2
- package/build/provider/WalletConnectProvider.d.ts +9 -0
- package/build/provider/WalletConnectProvider.js +178 -0
- package/build/types.d.ts +11 -0
- package/build/types.js +1 -0
- package/build/utils/accessibility/definitions.d.ts +2 -0
- package/build/utils/accessibility/definitions.js +8 -0
- package/build/utils/accessibility/errorDecoder.d.ts +2 -0
- package/build/utils/accessibility/errorDecoder.js +73 -0
- package/build/utils/accessibility/patterns.d.ts +13 -0
- package/build/utils/accessibility/patterns.js +51 -0
- package/build/wallets/controller.d.ts +29 -0
- package/build/wallets/controller.js +205 -0
- package/build/wallets/index.d.ts +4 -0
- package/build/wallets/index.js +16 -0
- package/build/wallets/opwallet/controller.d.ts +26 -0
- package/build/wallets/opwallet/controller.js +132 -0
- package/build/wallets/opwallet/interface.d.ts +5 -0
- package/build/wallets/opwallet/interface.js +35 -0
- package/build/wallets/types.d.ts +34 -0
- package/build/wallets/types.js +1 -0
- package/build/wallets/unisat/controller.d.ts +26 -0
- package/build/wallets/unisat/controller.js +135 -0
- package/build/wallets/unisat/interface.d.ts +5 -0
- package/build/wallets/unisat/interface.js +285 -0
- package/eslint.config.js +23 -2
- package/package.json +10 -5
- package/src/README.md +24 -0
- package/src/consts.ts +8 -0
- package/src/context/WalletConnectContext.ts +21 -0
- package/src/hooks/WalletConnectHook.tsx +13 -0
- package/src/index.ts +5 -2
- package/src/provider/WalletConnectProvider.tsx +341 -0
- package/src/types.ts +13 -0
- package/src/utils/accessibility/definitions.ts +9 -0
- package/src/utils/accessibility/errorDecoder.ts +105 -0
- package/src/utils/accessibility/patterns.ts +86 -0
- package/src/utils/style.css +131 -0
- package/src/utils/theme.css +26 -0
- package/src/wallets/controller.ts +231 -0
- package/src/wallets/index.ts +22 -0
- package/src/wallets/opwallet/controller.ts +177 -0
- package/src/wallets/opwallet/interface.ts +42 -0
- package/src/wallets/types.ts +39 -0
- package/src/wallets/unisat/controller.ts +179 -0
- package/src/wallets/unisat/interface.ts +292 -0
- package/tsconfig.webpack.json +2 -6
- package/webpack.config.js +4 -0
- package/browser/WalletConnection.d.ts +0 -21
- package/browser/WalletProvider.d.ts +0 -25
- package/build/WalletConnection.d.ts +0 -21
- package/build/WalletConnection.js +0 -152
- package/build/WalletProvider.d.ts +0 -25
- package/build/WalletProvider.js +0 -178
- package/src/WalletConnection.ts +0 -210
- package/src/WalletProvider.tsx +0 -240
package/.prettierrc.json
CHANGED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# OP_NET - WalletConnect
|
|
2
|
+
|
|
3
|
+
## V2
|
|
4
|
+
|
|
5
|
+
This new version makes it easier for developer to use the library to connect to wallets and to implements support for new wallets.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
- Themes support (current themes are light, dark and moto)
|
|
10
|
+
- Auto reconnect only if already logged in the wallet
|
|
11
|
+
|
|
12
|
+
### Breaking changes
|
|
13
|
+
|
|
14
|
+
- Some properties are moved to the WalletConnect context for easier use
|
|
15
|
+
|
|
16
|
+
### Migration
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Old version --> New version
|
|
20
|
+
{ {
|
|
21
|
+
allWallets
|
|
22
|
+
openConnectModal
|
|
23
|
+
connect connectToWallet
|
|
24
|
+
disconnect disconnect
|
|
25
|
+
walletType walletType
|
|
26
|
+
walletWindowInstance provider
|
|
27
|
+
account -
|
|
28
|
+
- isConnected publicKey != null
|
|
29
|
+
- signer signer
|
|
30
|
+
- address address (Address.fromString(publicKey))
|
|
31
|
+
publicKey (account publicKey)
|
|
32
|
+
walletAddress (account address)
|
|
33
|
+
- addressTyped
|
|
34
|
+
- network network
|
|
35
|
+
- provider -
|
|
36
|
+
connecting
|
|
37
|
+
} = useWallet() } = useWalletConnect()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
walletAddress,
|
|
41
|
+
|
|
42
|
+
### Sample use of new version (snipets)
|
|
43
|
+
|
|
44
|
+
**App.tsx**
|
|
45
|
+
|
|
46
|
+
```typescript jsx
|
|
47
|
+
createRoot(document.getElementById('root')!).render(
|
|
48
|
+
<StrictMode>
|
|
49
|
+
<WalletConnectProvider theme="light">
|
|
50
|
+
<App />
|
|
51
|
+
</WalletConnectProvider>
|
|
52
|
+
</StrictMode>,
|
|
53
|
+
);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Main.tsx**
|
|
57
|
+
|
|
58
|
+
```typescript jsx
|
|
59
|
+
function App() {
|
|
60
|
+
const { openConnectModal, publicKey, provider } = useWalletConnect();
|
|
61
|
+
|
|
62
|
+
const [balance, setBalance] = useState<number | undefined>(undefined);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const updateBalance = async () => {
|
|
66
|
+
const balance = await provider?.getBalance();
|
|
67
|
+
setBalance(balance?.total);
|
|
68
|
+
};
|
|
69
|
+
void updateBalance();
|
|
70
|
+
}, [provider, setBalance]);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div>
|
|
74
|
+
<button onClick={() => openConnectModal()}>Connect Wallet</button>
|
|
75
|
+
|
|
76
|
+
<div>
|
|
77
|
+
<div>Public Key: {publicKey}</div>
|
|
78
|
+
<div>Balance: {balance}</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
```
|
package/README.md
CHANGED
|
@@ -19,8 +19,8 @@ from the connected wallet.
|
|
|
19
19
|
|
|
20
20
|
### Prerequisites
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- Node.js version 22.x
|
|
23
|
+
- npm (Node Package Manager)
|
|
24
24
|
|
|
25
25
|
### Installation
|
|
26
26
|
|
|
@@ -35,17 +35,17 @@ Documentation is available at [docs.opnet.org](https://docs.opnet.org)
|
|
|
35
35
|
#### Development
|
|
36
36
|
|
|
37
37
|
1. Clone the repository:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/btc-vision/walletconnect.git
|
|
40
|
+
```
|
|
41
41
|
2. Navigate to the repository directory:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
```bash
|
|
43
|
+
cd walletconnect
|
|
44
|
+
```
|
|
45
45
|
3. Install the required dependencies:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
```bash
|
|
47
|
+
npm i
|
|
48
|
+
```
|
|
49
49
|
|
|
50
50
|
## Contribution
|
|
51
51
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Address, Unisat, UnisatSigner } from '@btc-vision/transaction';
|
|
2
|
+
import type { WalletConnectNetwork, WalletInformation } from '../types.ts';
|
|
3
|
+
import { SupportedWallets } from '../wallets';
|
|
4
|
+
export type WalletConnectContextType = {
|
|
5
|
+
allWallets: WalletInformation[];
|
|
6
|
+
walletType: string | null;
|
|
7
|
+
walletAddress: string | null;
|
|
8
|
+
network: WalletConnectNetwork;
|
|
9
|
+
publicKey: string | null;
|
|
10
|
+
address: Address | null;
|
|
11
|
+
openConnectModal: () => void;
|
|
12
|
+
connectToWallet: (wallet: SupportedWallets) => void;
|
|
13
|
+
connecting: boolean;
|
|
14
|
+
disconnect: () => void;
|
|
15
|
+
provider: Unisat | null;
|
|
16
|
+
signer: UnisatSigner | null;
|
|
17
|
+
};
|
|
18
|
+
export declare const WalletConnectContext: import("react").Context<WalletConnectContextType | undefined>;
|
package/browser/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { WalletConnectContext } from './context/WalletConnectContext';
|
|
2
|
+
export { useWalletConnect } from './hooks/WalletConnectHook';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export { default as WalletConnectProvider } from './provider/WalletConnectProvider';
|