@btc-vision/walletconnect 1.5.1 → 1.5.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.
@@ -1,3 +1,5 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+
1
3
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
2
4
 
3
5
  /**
@@ -2,13 +2,15 @@ import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { WalletConnectNetwork } from '../types';
3
3
  import { SupportedWallets } from './index';
4
4
  import type { ControllerConnectAccounts, ControllerErrorResponse, ControllerResponse, WalletConnectWallet } from './types.ts';
5
+ import { AbstractRpcProvider } from 'opnet';
5
6
  declare class WalletController {
6
7
  private static wallets;
7
8
  private static currentWallet;
8
9
  static getWallets: () => WalletConnectWallet[];
9
10
  static isWalletInstalled(wallet: string): boolean;
10
11
  static getWalletType(): SupportedWallets | null;
11
- static getProvider(): Unisat | null;
12
+ static getWalletInstance(): Unisat | null;
13
+ static getProvider(): Promise<AbstractRpcProvider | null>;
12
14
  static getSigner(): Promise<UnisatSigner | null>;
13
15
  static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork;
14
16
  static getNetwork(): Promise<WalletConnectNetwork>;
@@ -1,5 +1,6 @@
1
1
  import { Unisat, UnisatChainType } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  declare class OPWallet implements WalletBase {
4
5
  private walletBase;
5
6
  private accountsChangedHookWrapper?;
@@ -12,7 +13,8 @@ declare class OPWallet implements WalletBase {
12
13
  getChainId(): void;
13
14
  connect(): Promise<string[]>;
14
15
  disconnect(): Promise<void>;
15
- getProvider(): Unisat | null;
16
+ getWalletInstance(): Unisat | null;
17
+ getProvider(): Promise<AbstractRpcProvider | null>;
16
18
  getSigner(): Promise<null>;
17
19
  getPublicKey(): Promise<string>;
18
20
  getNetwork(): Promise<UnisatChainType>;
@@ -1,11 +1,13 @@
1
1
  import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { SupportedWallets } from './index';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  export type { AbstractRpcProvider } from 'opnet';
4
5
  export interface WalletBase {
5
6
  isInstalled(): boolean;
6
7
  isConnected(): boolean;
7
8
  canAutoConnect(): Promise<boolean>;
8
- getProvider(): Unisat | null;
9
+ getWalletInstance(): Unisat | null;
10
+ getProvider(): Promise<AbstractRpcProvider | null>;
9
11
  getSigner(): Promise<UnisatSigner | null>;
10
12
  connect(): Promise<string[] | undefined>;
11
13
  disconnect(): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  declare class UnisatWallet implements WalletBase {
4
5
  private walletBase;
5
6
  private accountsChangedHookWrapper?;
@@ -9,7 +10,8 @@ declare class UnisatWallet implements WalletBase {
9
10
  isInstalled(): boolean;
10
11
  isConnected(): boolean;
11
12
  canAutoConnect(): Promise<boolean>;
12
- getProvider(): Unisat | null;
13
+ getWalletInstance(): Unisat | null;
14
+ getProvider(): Promise<AbstractRpcProvider | null>;
13
15
  getSigner(): Promise<UnisatSigner>;
14
16
  getChainId(): void;
15
17
  connect(): Promise<string[]>;
@@ -1,10 +1,12 @@
1
1
  import { Address, Unisat, UnisatSigner } from '@btc-vision/transaction';
2
2
  import type { WalletConnectNetwork, WalletInformation } from '../types.ts';
3
3
  import { SupportedWallets } from '../wallets';
4
+ import { AbstractRpcProvider } from 'opnet';
4
5
  export type WalletConnectContextType = {
5
6
  allWallets: WalletInformation[];
6
7
  walletType: string | null;
7
8
  walletAddress: string | null;
9
+ walletInstance: Unisat | null;
8
10
  network: WalletConnectNetwork;
9
11
  publicKey: string | null;
10
12
  address: Address | null;
@@ -12,7 +14,7 @@ export type WalletConnectContextType = {
12
14
  connectToWallet: (wallet: SupportedWallets) => void;
13
15
  connecting: boolean;
14
16
  disconnect: () => void;
15
- provider: Unisat | null;
17
+ provider: AbstractRpcProvider | null;
16
18
  signer: UnisatSigner | null;
17
19
  };
18
20
  export declare const WalletConnectContext: import("react").Context<WalletConnectContextType | undefined>;
@@ -18,6 +18,7 @@ const WalletConnectProvider = ({ theme, children }) => {
18
18
  const [walletAddress, setWalletAddress] = useState(null);
19
19
  const [publicKey, setPublicKey] = useState(null);
20
20
  const [walletType, setWalletType] = useState(null);
21
+ const [walletInstance, setWalletInstance] = useState(null);
21
22
  const [provider, setProvider] = useState(null);
22
23
  const [signer, setSigner] = useState(null);
23
24
  const clearConnectError = useCallback(() => {
@@ -141,9 +142,16 @@ const WalletConnectProvider = ({ theme, children }) => {
141
142
  useEffect(() => {
142
143
  const walletType = walletAddress ? WalletController.getWalletType() : null;
143
144
  setWalletType(walletType);
144
- const provider = walletAddress ? WalletController.getProvider() : null;
145
- setProvider(provider);
145
+ const walletInstance = walletAddress ? WalletController.getWalletInstance() : null;
146
+ setWalletInstance(walletInstance);
146
147
  }, [walletAddress]);
148
+ useEffect(() => {
149
+ const updateWalletInfo = async () => {
150
+ const provider = walletAddress ? (await WalletController.getProvider()) : null;
151
+ setProvider(provider);
152
+ };
153
+ void updateWalletInfo();
154
+ }, [walletAddress, network]);
147
155
  useEffect(() => {
148
156
  const updateSigner = async () => {
149
157
  const signer = publicKey ? await WalletController.getSigner() : null;
@@ -168,6 +176,7 @@ const WalletConnectProvider = ({ theme, children }) => {
168
176
  openConnectModal,
169
177
  network,
170
178
  allWallets,
179
+ walletInstance,
171
180
  provider,
172
181
  signer,
173
182
  walletType,
@@ -2,13 +2,15 @@ import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { WalletConnectNetwork } from '../types';
3
3
  import { SupportedWallets } from './index';
4
4
  import type { ControllerConnectAccounts, ControllerErrorResponse, ControllerResponse, WalletConnectWallet } from './types.ts';
5
+ import { AbstractRpcProvider } from 'opnet';
5
6
  declare class WalletController {
6
7
  private static wallets;
7
8
  private static currentWallet;
8
9
  static getWallets: () => WalletConnectWallet[];
9
10
  static isWalletInstalled(wallet: string): boolean;
10
11
  static getWalletType(): SupportedWallets | null;
11
- static getProvider(): Unisat | null;
12
+ static getWalletInstance(): Unisat | null;
13
+ static getProvider(): Promise<AbstractRpcProvider | null>;
12
14
  static getSigner(): Promise<UnisatSigner | null>;
13
15
  static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork;
14
16
  static getNetwork(): Promise<WalletConnectNetwork>;
@@ -10,12 +10,20 @@ class WalletController {
10
10
  static getWalletType() {
11
11
  return _a.currentWallet?.name || null;
12
12
  }
13
- static getProvider() {
13
+ static getWalletInstance() {
14
14
  const wallet = this.currentWallet;
15
15
  if (!wallet) {
16
16
  return null;
17
17
  }
18
- const provider = wallet.controller.getProvider();
18
+ const walletInstance = wallet.controller.getWalletInstance();
19
+ return walletInstance ? new Proxy(walletInstance, {}) : null;
20
+ }
21
+ static async getProvider() {
22
+ const wallet = this.currentWallet;
23
+ if (!wallet) {
24
+ return null;
25
+ }
26
+ const provider = await wallet.controller.getProvider();
19
27
  return provider ? new Proxy(provider, {}) : null;
20
28
  }
21
29
  static async getSigner() {
@@ -1,5 +1,6 @@
1
1
  import { Unisat, UnisatChainType } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  declare class OPWallet implements WalletBase {
4
5
  private walletBase;
5
6
  private accountsChangedHookWrapper?;
@@ -12,7 +13,8 @@ declare class OPWallet implements WalletBase {
12
13
  getChainId(): void;
13
14
  connect(): Promise<string[]>;
14
15
  disconnect(): Promise<void>;
15
- getProvider(): Unisat | null;
16
+ getWalletInstance(): Unisat | null;
17
+ getProvider(): Promise<AbstractRpcProvider | null>;
16
18
  getSigner(): Promise<null>;
17
19
  getPublicKey(): Promise<string>;
18
20
  getNetwork(): Promise<UnisatChainType>;
@@ -1,3 +1,6 @@
1
+ import { UnisatChainType } from '@btc-vision/transaction';
2
+ import { JSONRpcProvider } from 'opnet';
3
+ import { networks } from '@btc-vision/bitcoin';
1
4
  const notInstalledError = 'OP_WALLET is not installed';
2
5
  class OPWallet {
3
6
  constructor() {
@@ -36,9 +39,24 @@ class OPWallet {
36
39
  })
37
40
  : undefined;
38
41
  }
39
- getProvider() {
42
+ getWalletInstance() {
40
43
  return (this._isConnected && this.walletBase) || null;
41
44
  }
45
+ async getProvider() {
46
+ if (!this._isConnected || !this.walletBase)
47
+ return null;
48
+ const chain = await this.walletBase.getChain();
49
+ switch (chain.enum) {
50
+ case UnisatChainType.BITCOIN_MAINNET:
51
+ return new JSONRpcProvider('https://api.opnet.org', networks.bitcoin);
52
+ case UnisatChainType.BITCOIN_TESTNET:
53
+ return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
54
+ case UnisatChainType.BITCOIN_REGTEST:
55
+ return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
56
+ default:
57
+ return null;
58
+ }
59
+ }
42
60
  async getSigner() {
43
61
  return Promise.resolve(null);
44
62
  }
@@ -1,11 +1,13 @@
1
1
  import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { SupportedWallets } from './index';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  export type { AbstractRpcProvider } from 'opnet';
4
5
  export interface WalletBase {
5
6
  isInstalled(): boolean;
6
7
  isConnected(): boolean;
7
8
  canAutoConnect(): Promise<boolean>;
8
- getProvider(): Unisat | null;
9
+ getWalletInstance(): Unisat | null;
10
+ getProvider(): Promise<AbstractRpcProvider | null>;
9
11
  getSigner(): Promise<UnisatSigner | null>;
10
12
  connect(): Promise<string[] | undefined>;
11
13
  disconnect(): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
+ import { AbstractRpcProvider } from 'opnet';
3
4
  declare class UnisatWallet implements WalletBase {
4
5
  private walletBase;
5
6
  private accountsChangedHookWrapper?;
@@ -9,7 +10,8 @@ declare class UnisatWallet implements WalletBase {
9
10
  isInstalled(): boolean;
10
11
  isConnected(): boolean;
11
12
  canAutoConnect(): Promise<boolean>;
12
- getProvider(): Unisat | null;
13
+ getWalletInstance(): Unisat | null;
14
+ getProvider(): Promise<AbstractRpcProvider | null>;
13
15
  getSigner(): Promise<UnisatSigner>;
14
16
  getChainId(): void;
15
17
  connect(): Promise<string[]>;
@@ -1,4 +1,6 @@
1
- import { UnisatSigner } from '@btc-vision/transaction';
1
+ import { UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
+ import { JSONRpcProvider } from 'opnet';
3
+ import { networks } from '@btc-vision/bitcoin';
2
4
  const notInstalledError = 'UNISAT is not installed';
3
5
  class UnisatWallet {
4
6
  constructor() {
@@ -15,9 +17,24 @@ class UnisatWallet {
15
17
  const accounts = (await this.walletBase?.getAccounts()) || [];
16
18
  return accounts.length > 0;
17
19
  }
18
- getProvider() {
20
+ getWalletInstance() {
19
21
  return (this._isConnected && this.walletBase) || null;
20
22
  }
23
+ async getProvider() {
24
+ if (!this._isConnected || !this.walletBase)
25
+ return null;
26
+ const chain = await this.walletBase.getChain();
27
+ switch (chain.enum) {
28
+ case UnisatChainType.BITCOIN_MAINNET:
29
+ return new JSONRpcProvider('https://api.opnet.org', networks.bitcoin);
30
+ case UnisatChainType.BITCOIN_TESTNET:
31
+ return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
32
+ case UnisatChainType.BITCOIN_REGTEST:
33
+ return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
34
+ default:
35
+ return null;
36
+ }
37
+ }
21
38
  async getSigner() {
22
39
  const signer = new UnisatSigner();
23
40
  await signer.init();
package/eslint.config.js CHANGED
@@ -6,7 +6,7 @@ import reactRefresh from 'eslint-plugin-react-refresh';
6
6
  import tseslint from 'typescript-eslint';
7
7
 
8
8
  export default tseslint.config(
9
- { ignores: ['dist'] },
9
+ { ignores: ['dist', 'browser', 'build'] },
10
10
  {
11
11
  extends: [
12
12
  eslint.configs.recommended,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/walletconnect",
3
3
  "type": "module",
4
- "version": "1.5.1",
4
+ "version": "1.5.3",
5
5
  "author": "impredmet",
6
6
  "description": "The OP_NET Wallet Connect library helps your dApp connect to any compatible wallet.",
7
7
  "engines": {
@@ -87,14 +87,14 @@
87
87
  },
88
88
  "dependencies": {
89
89
  "@btc-vision/bitcoin": "^6.4.8",
90
- "@btc-vision/transaction": "^1.6.8",
90
+ "@btc-vision/transaction": "^1.6.9",
91
91
  "@eslint/js": "^9.34.0",
92
92
  "css-loader": "^7.1.2",
93
93
  "eslint-plugin-react-hooks": "^5.2.0",
94
94
  "gulp-clean": "^0.4.0",
95
95
  "gulp-eslint-new": "^2.4.0",
96
96
  "gulp-logger-new": "^1.0.1",
97
- "opnet": "^1.6.17",
97
+ "opnet": "^1.6.18",
98
98
  "style-loader": "^4.0.0",
99
99
  "webpack": "^5.101.3"
100
100
  }
@@ -2,11 +2,13 @@ import { Address, Unisat, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { createContext } from 'react';
3
3
  import type { WalletConnectNetwork, WalletInformation } from '../types.ts';
4
4
  import { SupportedWallets } from '../wallets';
5
+ import { AbstractRpcProvider } from 'opnet';
5
6
 
6
7
  export type WalletConnectContextType = {
7
8
  allWallets: WalletInformation[];
8
9
  walletType: string | null;
9
10
  walletAddress: string | null;
11
+ walletInstance: Unisat | null;
10
12
  network: WalletConnectNetwork;
11
13
  publicKey: string | null;
12
14
  address: Address | null;
@@ -14,7 +16,7 @@ export type WalletConnectContextType = {
14
16
  connectToWallet: (wallet: SupportedWallets) => void;
15
17
  connecting: boolean;
16
18
  disconnect: () => void;
17
- provider: Unisat | null;
19
+ provider: AbstractRpcProvider | null;
18
20
  signer: UnisatSigner | null;
19
21
  };
20
22
 
@@ -12,6 +12,7 @@ import type {
12
12
  ControllerResponse,
13
13
  WalletConnectWallet,
14
14
  } from '../wallets/types.ts';
15
+ import { AbstractRpcProvider } from 'opnet';
15
16
 
16
17
  const AUTO_RECONNECT_RETRIES = 5;
17
18
 
@@ -36,7 +37,8 @@ const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({ theme, ch
36
37
  const [walletAddress, setWalletAddress] = useState<string | null>(null);
37
38
  const [publicKey, setPublicKey] = useState<string | null>(null);
38
39
  const [walletType, setWalletType] = useState<SupportedWallets | null>(null);
39
- const [provider, setProvider] = useState<Unisat | null>(null);
40
+ const [walletInstance, setWalletInstance] = useState<Unisat | null>(null);
41
+ const [provider, setProvider] = useState<AbstractRpcProvider | null>(null);
40
42
  const [signer, setSigner] = useState<UnisatSigner | null>(null);
41
43
 
42
44
  const clearConnectError = useCallback(() => {
@@ -193,10 +195,18 @@ const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({ theme, ch
193
195
  useEffect(() => {
194
196
  const walletType = walletAddress ? WalletController.getWalletType() : null;
195
197
  setWalletType(walletType);
196
- const provider = walletAddress ? WalletController.getProvider() : null;
197
- setProvider(provider);
198
+ const walletInstance = walletAddress ? WalletController.getWalletInstance() : null;
199
+ setWalletInstance(walletInstance);
198
200
  }, [walletAddress]);
199
201
 
202
+ useEffect(() => {
203
+ const updateWalletInfo = async () => {
204
+ const provider = walletAddress ? (await WalletController.getProvider()) : null;
205
+ setProvider(provider);
206
+ }
207
+ void updateWalletInfo();
208
+ }, [walletAddress,network]);
209
+
200
210
  useEffect(() => {
201
211
  const updateSigner = async () => {
202
212
  const signer = publicKey ? await WalletController.getSigner() : null;
@@ -226,6 +236,7 @@ const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({ theme, ch
226
236
  openConnectModal,
227
237
  network,
228
238
  allWallets,
239
+ walletInstance,
229
240
  provider,
230
241
  signer,
231
242
  walletType,
@@ -10,6 +10,7 @@ import type {
10
10
  ControllerResponse,
11
11
  WalletConnectWallet,
12
12
  } from './types.ts';
13
+ import { AbstractRpcProvider } from 'opnet';
13
14
 
14
15
  class WalletController {
15
16
  private static wallets: Map<string, WalletConnectWallet> = new Map();
@@ -25,13 +26,23 @@ class WalletController {
25
26
  return WalletController.currentWallet?.name || null;
26
27
  }
27
28
 
28
- static getProvider(): Unisat | null {
29
+ static getWalletInstance(): Unisat | null {
29
30
  const wallet = this.currentWallet;
30
31
  if (!wallet) {
31
32
  return null;
32
33
  }
33
34
  // Needs to return a Proxy to be sure useEffects are triggered
34
- const provider = wallet.controller.getProvider();
35
+ const walletInstance = wallet.controller.getWalletInstance();
36
+ return walletInstance ? new Proxy(walletInstance, {}) : null;
37
+ }
38
+
39
+ static async getProvider(): Promise<AbstractRpcProvider | null> {
40
+ const wallet = this.currentWallet;
41
+ if (!wallet) {
42
+ return null;
43
+ }
44
+ // Needs to return a Proxy to be sure useEffects are triggered
45
+ const provider = await wallet.controller.getProvider()
35
46
  return provider ? new Proxy(provider, {}) : null;
36
47
  }
37
48
 
@@ -1,6 +1,8 @@
1
1
  import { Unisat, UnisatChainInfo, UnisatChainType } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
3
  import type { OPWalletInterface } from './interface';
4
+ import { AbstractRpcProvider, JSONRpcProvider } from 'opnet';
5
+ import { networks } from '@btc-vision/bitcoin';
4
6
 
5
7
  interface OPWalletWindow extends Window {
6
8
  opnet?: OPWalletInterface;
@@ -54,10 +56,27 @@ class OPWallet implements WalletBase {
54
56
  : undefined;
55
57
  }
56
58
 
57
- getProvider(): Unisat | null {
59
+ getWalletInstance(): Unisat | null {
58
60
  return (this._isConnected && this.walletBase) || null;
59
61
  }
60
62
 
63
+ public async getProvider(): Promise<AbstractRpcProvider | null> {
64
+ if (!this._isConnected || !this.walletBase) return null;
65
+
66
+ const chain = await this.walletBase.getChain();
67
+ switch (chain.enum) {
68
+ case UnisatChainType.BITCOIN_MAINNET:
69
+ return new JSONRpcProvider('https://api.opnet.org', networks.bitcoin);
70
+ case UnisatChainType.BITCOIN_TESTNET:
71
+ return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
72
+ case UnisatChainType.BITCOIN_REGTEST:
73
+ return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
74
+ // TODO: Add Fractal Mainnet & Testnet when available
75
+ default:
76
+ return null;
77
+ }
78
+ }
79
+
61
80
  async getSigner(): Promise<null> {
62
81
  return Promise.resolve(null);
63
82
  }
@@ -1,12 +1,14 @@
1
1
  import { Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import { SupportedWallets } from './index';
3
+ import { AbstractRpcProvider } from 'opnet'
3
4
  export type { AbstractRpcProvider } from 'opnet';
4
5
 
5
6
  export interface WalletBase {
6
7
  isInstalled(): boolean;
7
8
  isConnected(): boolean;
8
9
  canAutoConnect(): Promise<boolean>;
9
- getProvider(): Unisat | null;
10
+ getWalletInstance(): Unisat | null;
11
+ getProvider(): Promise<AbstractRpcProvider | null>;
10
12
  getSigner(): Promise<UnisatSigner | null>;
11
13
  connect(): Promise<string[] | undefined>;
12
14
  disconnect(): Promise<void>;
@@ -1,6 +1,8 @@
1
1
  import { Unisat, UnisatChainInfo, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
2
2
  import type { WalletBase } from '../types.ts';
3
3
  import type { UnisatWalletInterface } from './interface';
4
+ import { AbstractRpcProvider, JSONRpcProvider } from 'opnet';
5
+ import { networks } from '@btc-vision/bitcoin';
4
6
 
5
7
  interface UnisatWalletWindow extends Window {
6
8
  unisat?: UnisatWalletInterface;
@@ -29,10 +31,27 @@ class UnisatWallet implements WalletBase {
29
31
  return accounts.length > 0;
30
32
  }
31
33
 
32
- getProvider(): Unisat | null {
34
+ getWalletInstance(): Unisat | null {
33
35
  return (this._isConnected && this.walletBase) || null;
34
36
  }
35
37
 
38
+ public async getProvider(): Promise<AbstractRpcProvider | null> {
39
+ if (!this._isConnected || !this.walletBase) return null;
40
+
41
+ const chain = await this.walletBase.getChain();
42
+ switch (chain.enum) {
43
+ case UnisatChainType.BITCOIN_MAINNET:
44
+ return new JSONRpcProvider('https://api.opnet.org', networks.bitcoin);
45
+ case UnisatChainType.BITCOIN_TESTNET:
46
+ return new JSONRpcProvider('https://testnet.opnet.org', networks.testnet);
47
+ case UnisatChainType.BITCOIN_REGTEST:
48
+ return new JSONRpcProvider('https://regtest.opnet.org', networks.regtest);
49
+ // TODO: Add Fractal Mainnet & Testnet when available
50
+ default:
51
+ return null;
52
+ }
53
+ }
54
+
36
55
  async getSigner(): Promise<UnisatSigner> {
37
56
  const signer = new UnisatSigner();
38
57
  await signer.init();