@btc-vision/walletconnect 1.0.7 → 1.0.9

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.
@@ -131,8 +131,6 @@ export class WalletConnection {
131
131
  return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
132
132
  case UnisatChainType.BITCOIN_REGTEST:
133
133
  return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
134
- case UnisatChainType.FRACTAL_BITCOIN_MAINNET:
135
- return new JSONRpcProvider('https://fractal.opnet.org', networks.bitcoin);
136
134
  default:
137
135
  throw new Error('Unsupported network');
138
136
  }
@@ -42,19 +42,37 @@ export const WalletProvider = ({ children }) => {
42
42
  walletConnection.walletWindowInstance.on('accountsChanged', async () => {
43
43
  if (!walletConnection.walletWindowInstance)
44
44
  return;
45
- setAddress(await walletConnection.getAddress());
45
+ try {
46
+ setAddress(await walletConnection.getAddress());
47
+ }
48
+ catch (error) {
49
+ disconnect();
50
+ throw error;
51
+ }
46
52
  });
47
53
  walletConnection.walletWindowInstance.on('chainChanged', async () => {
48
54
  if (!walletConnection.walletWindowInstance)
49
55
  return;
50
- setNetwork(await walletConnection.getNetwork());
51
- setProvider(await walletConnection.getProvider());
56
+ try {
57
+ setNetwork(await walletConnection.getNetwork());
58
+ setProvider(await walletConnection.getProvider());
59
+ }
60
+ catch (error) {
61
+ disconnect();
62
+ throw error;
63
+ }
52
64
  });
53
65
  walletConnection.walletWindowInstance.on('networkChanged', async () => {
54
66
  if (!walletConnection.walletWindowInstance)
55
67
  return;
56
- setNetwork(await walletConnection.getNetwork());
57
- setProvider(await walletConnection.getProvider());
68
+ try {
69
+ setNetwork(await walletConnection.getNetwork());
70
+ setProvider(await walletConnection.getProvider());
71
+ }
72
+ catch (error) {
73
+ disconnect();
74
+ throw error;
75
+ }
58
76
  });
59
77
  }
60
78
  }, [walletConnection]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/walletconnect",
3
3
  "type": "module",
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "author": "impredmet",
6
6
  "description": "The OP_NET Wallet Connect library helps your dApp connect to any compatible wallet.",
7
7
  "engines": {
@@ -176,8 +176,7 @@ export class WalletConnection {
176
176
  return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
177
177
  case UnisatChainType.BITCOIN_REGTEST:
178
178
  return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
179
- case UnisatChainType.FRACTAL_BITCOIN_MAINNET:
180
- return new JSONRpcProvider('https://fractal.opnet.org', networks.bitcoin);
179
+ // TODO: Add Fractal Mainnet & Testnet when available
181
180
  default:
182
181
  throw new Error('Unsupported network');
183
182
  }
@@ -79,21 +79,36 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
79
79
  walletConnection.walletWindowInstance.on('accountsChanged', async () => {
80
80
  if (!walletConnection.walletWindowInstance) return;
81
81
 
82
- setAddress(await walletConnection.getAddress());
82
+ try {
83
+ setAddress(await walletConnection.getAddress());
84
+ } catch (error) {
85
+ disconnect();
86
+ throw error;
87
+ }
83
88
  });
84
89
 
85
90
  walletConnection.walletWindowInstance.on('chainChanged', async () => {
86
91
  if (!walletConnection.walletWindowInstance) return;
87
92
 
88
- setNetwork(await walletConnection.getNetwork());
89
- setProvider(await walletConnection.getProvider());
93
+ try {
94
+ setNetwork(await walletConnection.getNetwork());
95
+ setProvider(await walletConnection.getProvider());
96
+ } catch (error) {
97
+ disconnect();
98
+ throw error;
99
+ }
90
100
  });
91
101
 
92
102
  walletConnection.walletWindowInstance.on('networkChanged', async () => {
93
103
  if (!walletConnection.walletWindowInstance) return;
94
104
 
95
- setNetwork(await walletConnection.getNetwork());
96
- setProvider(await walletConnection.getProvider());
105
+ try {
106
+ setNetwork(await walletConnection.getNetwork());
107
+ setProvider(await walletConnection.getProvider());
108
+ } catch (error) {
109
+ disconnect();
110
+ throw error;
111
+ }
97
112
  });
98
113
  }
99
114
  },