@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.
Files changed (84) hide show
  1. package/.prettierrc.json +1 -1
  2. package/CHANGELOG.md +83 -0
  3. package/README.md +11 -11
  4. package/browser/consts.d.ts +2 -0
  5. package/browser/context/WalletConnectContext.d.ts +18 -0
  6. package/browser/hooks/WalletConnectHook.d.ts +2 -0
  7. package/browser/index.d.ts +4 -2
  8. package/browser/index.js +1 -1
  9. package/browser/index.js.LICENSE.txt +0 -2
  10. package/browser/provider/WalletConnectProvider.d.ts +9 -0
  11. package/browser/types.d.ts +11 -0
  12. package/browser/utils/accessibility/definitions.d.ts +2 -0
  13. package/browser/utils/accessibility/errorDecoder.d.ts +2 -0
  14. package/browser/utils/accessibility/patterns.d.ts +13 -0
  15. package/browser/wallets/controller.d.ts +29 -0
  16. package/browser/wallets/index.d.ts +4 -0
  17. package/browser/wallets/opwallet/controller.d.ts +26 -0
  18. package/browser/wallets/opwallet/interface.d.ts +5 -0
  19. package/browser/wallets/types.d.ts +34 -0
  20. package/browser/wallets/unisat/controller.d.ts +26 -0
  21. package/browser/wallets/unisat/interface.d.ts +5 -0
  22. package/build/consts.d.ts +2 -0
  23. package/build/consts.js +6 -0
  24. package/build/context/WalletConnectContext.d.ts +18 -0
  25. package/build/context/WalletConnectContext.js +2 -0
  26. package/build/hooks/WalletConnectHook.d.ts +2 -0
  27. package/build/hooks/WalletConnectHook.js +9 -0
  28. package/build/index.d.ts +4 -2
  29. package/build/index.js +4 -2
  30. package/build/provider/WalletConnectProvider.d.ts +9 -0
  31. package/build/provider/WalletConnectProvider.js +178 -0
  32. package/build/types.d.ts +11 -0
  33. package/build/types.js +1 -0
  34. package/build/utils/accessibility/definitions.d.ts +2 -0
  35. package/build/utils/accessibility/definitions.js +8 -0
  36. package/build/utils/accessibility/errorDecoder.d.ts +2 -0
  37. package/build/utils/accessibility/errorDecoder.js +73 -0
  38. package/build/utils/accessibility/patterns.d.ts +13 -0
  39. package/build/utils/accessibility/patterns.js +51 -0
  40. package/build/wallets/controller.d.ts +29 -0
  41. package/build/wallets/controller.js +205 -0
  42. package/build/wallets/index.d.ts +4 -0
  43. package/build/wallets/index.js +16 -0
  44. package/build/wallets/opwallet/controller.d.ts +26 -0
  45. package/build/wallets/opwallet/controller.js +132 -0
  46. package/build/wallets/opwallet/interface.d.ts +5 -0
  47. package/build/wallets/opwallet/interface.js +35 -0
  48. package/build/wallets/types.d.ts +34 -0
  49. package/build/wallets/types.js +1 -0
  50. package/build/wallets/unisat/controller.d.ts +26 -0
  51. package/build/wallets/unisat/controller.js +135 -0
  52. package/build/wallets/unisat/interface.d.ts +5 -0
  53. package/build/wallets/unisat/interface.js +285 -0
  54. package/eslint.config.js +23 -2
  55. package/package.json +10 -5
  56. package/src/README.md +24 -0
  57. package/src/consts.ts +8 -0
  58. package/src/context/WalletConnectContext.ts +21 -0
  59. package/src/hooks/WalletConnectHook.tsx +13 -0
  60. package/src/index.ts +5 -2
  61. package/src/provider/WalletConnectProvider.tsx +341 -0
  62. package/src/types.ts +13 -0
  63. package/src/utils/accessibility/definitions.ts +9 -0
  64. package/src/utils/accessibility/errorDecoder.ts +105 -0
  65. package/src/utils/accessibility/patterns.ts +86 -0
  66. package/src/utils/style.css +131 -0
  67. package/src/utils/theme.css +26 -0
  68. package/src/wallets/controller.ts +231 -0
  69. package/src/wallets/index.ts +22 -0
  70. package/src/wallets/opwallet/controller.ts +177 -0
  71. package/src/wallets/opwallet/interface.ts +42 -0
  72. package/src/wallets/types.ts +39 -0
  73. package/src/wallets/unisat/controller.ts +179 -0
  74. package/src/wallets/unisat/interface.ts +292 -0
  75. package/tsconfig.webpack.json +2 -6
  76. package/webpack.config.js +4 -0
  77. package/browser/WalletConnection.d.ts +0 -21
  78. package/browser/WalletProvider.d.ts +0 -25
  79. package/build/WalletConnection.d.ts +0 -21
  80. package/build/WalletConnection.js +0 -152
  81. package/build/WalletProvider.d.ts +0 -25
  82. package/build/WalletProvider.js +0 -178
  83. package/src/WalletConnection.ts +0 -210
  84. package/src/WalletProvider.tsx +0 -240
package/.prettierrc.json CHANGED
@@ -9,4 +9,4 @@
9
9
  "bracketSameLine": true,
10
10
  "arrowParens": "always",
11
11
  "singleAttributePerLine": true
12
- }
12
+ }
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
- - Node.js version 22.x
23
- - npm (Node Package Manager)
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
- ```bash
39
- git clone https://github.com/btc-vision/walletconnect.git
40
- ```
38
+ ```bash
39
+ git clone https://github.com/btc-vision/walletconnect.git
40
+ ```
41
41
  2. Navigate to the repository directory:
42
- ```bash
43
- cd walletconnect
44
- ```
42
+ ```bash
43
+ cd walletconnect
44
+ ```
45
45
  3. Install the required dependencies:
46
- ```bash
47
- npm i
48
- ```
46
+ ```bash
47
+ npm i
48
+ ```
49
49
 
50
50
  ## Contribution
51
51
 
@@ -0,0 +1,2 @@
1
+ import { WalletConnectNetwork } from './types';
2
+ export declare const DefaultWalletConnectNetwork: WalletConnectNetwork;
@@ -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>;
@@ -0,0 +1,2 @@
1
+ import { type WalletConnectContextType } from '../context/WalletConnectContext';
2
+ export declare const useWalletConnect: () => WalletConnectContextType;
@@ -1,2 +1,4 @@
1
- export * from './WalletConnection';
2
- export * from './WalletProvider';
1
+ export { WalletConnectContext } from './context/WalletConnectContext';
2
+ export { useWalletConnect } from './hooks/WalletConnectHook';
3
+ export * from './types';
4
+ export { default as WalletConnectProvider } from './provider/WalletConnectProvider';