@btc-vision/walletconnect 1.9.0 → 1.9.1
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/browser/context/WalletConnectContext.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/wallets/controller.d.ts +2 -2
- package/build/context/WalletConnectContext.d.ts +1 -1
- package/build/provider/WalletConnectProvider.js +2 -3
- package/build/wallets/controller.d.ts +2 -2
- package/build/wallets/controller.js +6 -4
- package/package.json +4 -4
- package/src/context/WalletConnectContext.ts +1 -1
- package/src/provider/WalletConnectProvider.tsx +2 -3
- package/src/wallets/controller.ts +8 -6
- package/browser/consts.d.ts +0 -2
- package/build/consts.d.ts +0 -2
- package/build/consts.js +0 -8
- package/src/consts.ts +0 -9
|
@@ -12,8 +12,8 @@ declare class WalletController {
|
|
|
12
12
|
static getWalletInstance(): Unisat | null;
|
|
13
13
|
static getProvider(): Promise<AbstractRpcProvider | null>;
|
|
14
14
|
static getSigner(): Promise<UnisatSigner | null>;
|
|
15
|
-
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork;
|
|
16
|
-
static getNetwork(): Promise<WalletConnectNetwork>;
|
|
15
|
+
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork | null;
|
|
16
|
+
static getNetwork(): Promise<WalletConnectNetwork | null>;
|
|
17
17
|
static getPublicKey(): Promise<string | null>;
|
|
18
18
|
static canAutoConnect(walletName: string): Promise<boolean>;
|
|
19
19
|
static connect(walletName: string): Promise<ControllerResponse<ControllerConnectAccounts | ControllerErrorResponse>>;
|
|
@@ -7,7 +7,7 @@ export type WalletConnectContextType = {
|
|
|
7
7
|
walletType: string | null;
|
|
8
8
|
walletAddress: string | null;
|
|
9
9
|
walletInstance: Unisat | null;
|
|
10
|
-
network: WalletConnectNetwork;
|
|
10
|
+
network: WalletConnectNetwork | null;
|
|
11
11
|
publicKey: string | null;
|
|
12
12
|
address: Address | null;
|
|
13
13
|
openConnectModal: () => void;
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Address, UnisatSigner } from '@btc-vision/transaction';
|
|
3
3
|
import { AbstractRpcProvider } from 'opnet';
|
|
4
4
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { DefaultWalletConnectNetwork } from '../consts';
|
|
6
5
|
import { WalletConnectContext } from '../context/WalletConnectContext';
|
|
7
6
|
import '../utils/style.css';
|
|
8
7
|
import '../utils/theme.css';
|
|
@@ -12,7 +11,7 @@ const WalletConnectProvider = ({ theme, children }) => {
|
|
|
12
11
|
const [pageLoaded, setPageLoaded] = useState(false);
|
|
13
12
|
const [connectError, setConnectError] = useState(undefined);
|
|
14
13
|
const timeoutRef = useRef(null);
|
|
15
|
-
const [network, setNetwork] = useState(
|
|
14
|
+
const [network, setNetwork] = useState(null);
|
|
16
15
|
const [supportedWallets] = useState(WalletController.getWallets);
|
|
17
16
|
const [selectedWallet, setSelectedWallet] = useState(null);
|
|
18
17
|
const [connecting, setConnecting] = useState(false);
|
|
@@ -70,7 +69,7 @@ const WalletConnectProvider = ({ theme, children }) => {
|
|
|
70
69
|
WalletController.removeChainChangedHook();
|
|
71
70
|
WalletController.removeAccountsChangedHook();
|
|
72
71
|
await WalletController.disconnect();
|
|
73
|
-
setNetwork(
|
|
72
|
+
setNetwork(null);
|
|
74
73
|
}, []);
|
|
75
74
|
const connectToWallet = useCallback(async (wallet) => {
|
|
76
75
|
setConnecting(true);
|
|
@@ -12,8 +12,8 @@ declare class WalletController {
|
|
|
12
12
|
static getWalletInstance(): Unisat | null;
|
|
13
13
|
static getProvider(): Promise<AbstractRpcProvider | null>;
|
|
14
14
|
static getSigner(): Promise<UnisatSigner | null>;
|
|
15
|
-
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork;
|
|
16
|
-
static getNetwork(): Promise<WalletConnectNetwork>;
|
|
15
|
+
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork | null;
|
|
16
|
+
static getNetwork(): Promise<WalletConnectNetwork | null>;
|
|
17
17
|
static getPublicKey(): Promise<string | null>;
|
|
18
18
|
static canAutoConnect(walletName: string): Promise<boolean>;
|
|
19
19
|
static connect(walletName: string): Promise<ControllerResponse<ControllerConnectAccounts | ControllerErrorResponse>>;
|
|
@@ -2,7 +2,6 @@ var _a;
|
|
|
2
2
|
import { networks } from '@btc-vision/bitcoin';
|
|
3
3
|
import { UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
|
|
4
4
|
import { AbstractRpcProvider } from 'opnet';
|
|
5
|
-
import { DefaultWalletConnectNetwork } from '../consts';
|
|
6
5
|
import {} from '../types';
|
|
7
6
|
import { _e } from '../utils/accessibility/errorDecoder';
|
|
8
7
|
import {} from './index';
|
|
@@ -52,13 +51,13 @@ class WalletController {
|
|
|
52
51
|
case UnisatChainType.FRACTAL_BITCOIN_TESTNET:
|
|
53
52
|
case UnisatChainType.FRACTAL_BITCOIN_MAINNET:
|
|
54
53
|
default:
|
|
55
|
-
return
|
|
54
|
+
return null;
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
static async getNetwork() {
|
|
59
58
|
const wallet = this.currentWallet;
|
|
60
59
|
if (!wallet) {
|
|
61
|
-
return
|
|
60
|
+
return null;
|
|
62
61
|
}
|
|
63
62
|
const chainType = await wallet.controller.getNetwork();
|
|
64
63
|
return this.convertChainTypeToNetwork(chainType);
|
|
@@ -152,7 +151,10 @@ class WalletController {
|
|
|
152
151
|
try {
|
|
153
152
|
wallet.controller.removeChainChangedHook();
|
|
154
153
|
wallet.controller.setChainChangedHook((chainType) => {
|
|
155
|
-
|
|
154
|
+
const network = this.convertChainTypeToNetwork(chainType);
|
|
155
|
+
if (network) {
|
|
156
|
+
fn(network);
|
|
157
|
+
}
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/walletconnect",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.1",
|
|
5
5
|
"author": "impredmet",
|
|
6
6
|
"description": "The OP_NET Wallet Connect library helps your dApp connect to any compatible wallet.",
|
|
7
7
|
"engines": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@babel/preset-env": "^7.28.3",
|
|
71
71
|
"@babel/preset-react": "^7.27.1",
|
|
72
72
|
"@babel/preset-typescript": "^7.27.1",
|
|
73
|
-
"@types/react": "^19.1.
|
|
73
|
+
"@types/react": "^19.1.13",
|
|
74
74
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
75
75
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
76
76
|
"gulp": "^5.0.1",
|
|
@@ -92,9 +92,9 @@
|
|
|
92
92
|
"css-loader": "^7.1.2",
|
|
93
93
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
94
94
|
"gulp-clean": "^0.4.0",
|
|
95
|
-
"gulp-eslint-new": "^2.
|
|
95
|
+
"gulp-eslint-new": "^2.5.0",
|
|
96
96
|
"gulp-logger-new": "^1.0.1",
|
|
97
|
-
"opnet": "^1.6.
|
|
97
|
+
"opnet": "^1.6.34",
|
|
98
98
|
"style-loader": "^4.0.0",
|
|
99
99
|
"webpack": "^5.101.3"
|
|
100
100
|
}
|
|
@@ -9,7 +9,7 @@ export type WalletConnectContextType = {
|
|
|
9
9
|
walletType: string | null;
|
|
10
10
|
walletAddress: string | null;
|
|
11
11
|
walletInstance: Unisat | null;
|
|
12
|
-
network: WalletConnectNetwork;
|
|
12
|
+
network: WalletConnectNetwork | null;
|
|
13
13
|
publicKey: string | null;
|
|
14
14
|
address: Address | null;
|
|
15
15
|
openConnectModal: () => void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Address, type Unisat, UnisatSigner } from '@btc-vision/transaction';
|
|
2
2
|
import { AbstractRpcProvider } from 'opnet';
|
|
3
3
|
import React, { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { DefaultWalletConnectNetwork } from '../consts';
|
|
5
4
|
import { WalletConnectContext } from '../context/WalletConnectContext';
|
|
6
5
|
import type { WalletConnectNetwork, WalletInformation } from '../types.ts';
|
|
7
6
|
import '../utils/style.css';
|
|
@@ -26,7 +25,7 @@ const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({ theme, ch
|
|
|
26
25
|
const [connectError, setConnectError] = useState<string | undefined>(undefined);
|
|
27
26
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
28
27
|
|
|
29
|
-
const [network, setNetwork] = useState<WalletConnectNetwork>(
|
|
28
|
+
const [network, setNetwork] = useState<WalletConnectNetwork | null>(null);
|
|
30
29
|
|
|
31
30
|
const [supportedWallets] = useState<WalletConnectWallet[]>(WalletController.getWallets);
|
|
32
31
|
const [selectedWallet, setSelectedWallet] = useState<SupportedWallets | null>(null);
|
|
@@ -94,7 +93,7 @@ const WalletConnectProvider: React.FC<WalletConnectProviderProps> = ({ theme, ch
|
|
|
94
93
|
WalletController.removeChainChangedHook();
|
|
95
94
|
WalletController.removeAccountsChangedHook();
|
|
96
95
|
await WalletController.disconnect();
|
|
97
|
-
setNetwork(
|
|
96
|
+
setNetwork(null);
|
|
98
97
|
}, []);
|
|
99
98
|
|
|
100
99
|
const connectToWallet = useCallback(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Network, networks } from '@btc-vision/bitcoin';
|
|
2
2
|
import { type Unisat, UnisatChainType, UnisatSigner } from '@btc-vision/transaction';
|
|
3
3
|
import { AbstractRpcProvider } from 'opnet';
|
|
4
|
-
import { DefaultWalletConnectNetwork } from '../consts';
|
|
5
4
|
import { type WalletConnectNetwork } from '../types';
|
|
6
5
|
import { _e } from '../utils/accessibility/errorDecoder';
|
|
7
6
|
import { type SupportedWallets } from './index';
|
|
@@ -56,7 +55,7 @@ class WalletController {
|
|
|
56
55
|
|
|
57
56
|
//TODO: check if we really want to return a default network here
|
|
58
57
|
// instead of null. Default is there: DefaultWalletConnectChain.network
|
|
59
|
-
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork {
|
|
58
|
+
static convertChainTypeToNetwork(chainType: UnisatChainType): WalletConnectNetwork | null {
|
|
60
59
|
const walletNetwork = (network: Network, name: string): WalletConnectNetwork => {
|
|
61
60
|
return { ...network, chainType: chainType, network: name };
|
|
62
61
|
};
|
|
@@ -73,14 +72,14 @@ class WalletController {
|
|
|
73
72
|
case UnisatChainType.FRACTAL_BITCOIN_TESTNET:
|
|
74
73
|
case UnisatChainType.FRACTAL_BITCOIN_MAINNET:
|
|
75
74
|
default:
|
|
76
|
-
return
|
|
75
|
+
return null;
|
|
77
76
|
}
|
|
78
77
|
}
|
|
79
78
|
|
|
80
|
-
static async getNetwork(): Promise<WalletConnectNetwork> {
|
|
79
|
+
static async getNetwork(): Promise<WalletConnectNetwork | null> {
|
|
81
80
|
const wallet = this.currentWallet;
|
|
82
81
|
if (!wallet) {
|
|
83
|
-
return
|
|
82
|
+
return null;
|
|
84
83
|
}
|
|
85
84
|
|
|
86
85
|
const chainType = await wallet.controller.getNetwork();
|
|
@@ -182,7 +181,10 @@ class WalletController {
|
|
|
182
181
|
try {
|
|
183
182
|
wallet.controller.removeChainChangedHook();
|
|
184
183
|
wallet.controller.setChainChangedHook((chainType: UnisatChainType) => {
|
|
185
|
-
|
|
184
|
+
const network = this.convertChainTypeToNetwork(chainType);
|
|
185
|
+
if (network) {
|
|
186
|
+
fn(network);
|
|
187
|
+
}
|
|
186
188
|
});
|
|
187
189
|
} catch (error) {
|
|
188
190
|
console.error('Error setting network switch hook:', error);
|
package/browser/consts.d.ts
DELETED
package/build/consts.d.ts
DELETED
package/build/consts.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { networks } from '@btc-vision/bitcoin';
|
|
2
|
-
import { UnisatChainType } from '@btc-vision/transaction';
|
|
3
|
-
import {} from './types';
|
|
4
|
-
export const DefaultWalletConnectNetwork = {
|
|
5
|
-
...networks.regtest,
|
|
6
|
-
chainType: UnisatChainType.BITCOIN_REGTEST,
|
|
7
|
-
network: 'regtest',
|
|
8
|
-
};
|
package/src/consts.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { networks } from '@btc-vision/bitcoin';
|
|
2
|
-
import { UnisatChainType } from '@btc-vision/transaction';
|
|
3
|
-
import { type WalletConnectNetwork } from './types';
|
|
4
|
-
|
|
5
|
-
export const DefaultWalletConnectNetwork: WalletConnectNetwork = {
|
|
6
|
-
...networks.regtest,
|
|
7
|
-
chainType: UnisatChainType.BITCOIN_REGTEST,
|
|
8
|
-
network: 'regtest',
|
|
9
|
-
} as const;
|