@btc-vision/walletconnect 1.1.4 → 1.1.6
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/WalletConnection.d.ts +1 -0
- package/browser/WalletProvider.d.ts +1 -0
- package/browser/index.js +1 -1
- package/build/WalletConnection.d.ts +1 -0
- package/build/WalletConnection.js +10 -0
- package/build/WalletProvider.d.ts +1 -0
- package/build/WalletProvider.js +4 -0
- package/package.json +7 -7
- package/src/WalletConnection.ts +19 -0
- package/src/WalletProvider.tsx +5 -0
|
@@ -14,6 +14,7 @@ export declare class WalletConnection {
|
|
|
14
14
|
connect(walletType: SupportedWallets): Promise<void>;
|
|
15
15
|
disconnect(): void;
|
|
16
16
|
getAddress(): Promise<Address>;
|
|
17
|
+
getAddressTyped(): Promise<string>;
|
|
17
18
|
getNetwork(): Promise<Network>;
|
|
18
19
|
getProvider(): Promise<AbstractRpcProvider>;
|
|
19
20
|
}
|
|
@@ -95,6 +95,16 @@ export class WalletConnection {
|
|
|
95
95
|
}
|
|
96
96
|
throw new Error('Unsupported wallet');
|
|
97
97
|
}
|
|
98
|
+
async getAddressTyped() {
|
|
99
|
+
if (!this.walletWindowInstance)
|
|
100
|
+
throw new Error('Wallet not connected');
|
|
101
|
+
if (this.walletType === SupportedWallets.OP_WALLET ||
|
|
102
|
+
this.walletType === SupportedWallets.UNISAT) {
|
|
103
|
+
const accounts = await this.walletWindowInstance.getAccounts();
|
|
104
|
+
return accounts[0];
|
|
105
|
+
}
|
|
106
|
+
throw new Error('Unsupported wallet');
|
|
107
|
+
}
|
|
98
108
|
async getNetwork() {
|
|
99
109
|
if (!this.walletWindowInstance)
|
|
100
110
|
throw new Error('Wallet not connected');
|
package/build/WalletProvider.js
CHANGED
|
@@ -28,12 +28,14 @@ export const WalletProvider = ({ children }) => {
|
|
|
28
28
|
localStorage.setItem('walletType', walletType);
|
|
29
29
|
const signer = walletConnection.signer;
|
|
30
30
|
const address = await walletConnection.getAddress();
|
|
31
|
+
const addressTyped = await walletConnection.getAddressTyped();
|
|
31
32
|
const network = await walletConnection.getNetwork();
|
|
32
33
|
const provider = await walletConnection.getProvider();
|
|
33
34
|
setAccount({
|
|
34
35
|
isConnected: true,
|
|
35
36
|
signer,
|
|
36
37
|
address,
|
|
38
|
+
addressTyped,
|
|
37
39
|
network,
|
|
38
40
|
provider,
|
|
39
41
|
});
|
|
@@ -47,12 +49,14 @@ export const WalletProvider = ({ children }) => {
|
|
|
47
49
|
instance.on('accountsChanged', async () => {
|
|
48
50
|
try {
|
|
49
51
|
const updatedAddress = await walletConnection.getAddress();
|
|
52
|
+
const updatedAddressTyped = await walletConnection.getAddressTyped();
|
|
50
53
|
const updatedNetwork = await walletConnection.getNetwork();
|
|
51
54
|
const updatedProvider = await walletConnection.getProvider();
|
|
52
55
|
setAccount((prevAccount) => prevAccount
|
|
53
56
|
? {
|
|
54
57
|
...prevAccount,
|
|
55
58
|
address: updatedAddress,
|
|
59
|
+
addressTyped: updatedAddressTyped,
|
|
56
60
|
network: updatedNetwork,
|
|
57
61
|
provider: updatedProvider,
|
|
58
62
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/walletconnect",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.6",
|
|
5
5
|
"author": "impredmet",
|
|
6
6
|
"description": "The OP_NET Wallet Connect library helps your dApp connect to any compatible wallet.",
|
|
7
7
|
"engines": {
|
|
@@ -69,28 +69,28 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@babel/preset-env": "^7.26.9",
|
|
71
71
|
"@babel/preset-react": "^7.26.3",
|
|
72
|
-
"@babel/preset-typescript": "^7.
|
|
72
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
73
73
|
"@types/react": "^19.0.12",
|
|
74
74
|
"gulp": "^5.0.0",
|
|
75
75
|
"gulp-cached": "^1.1.1",
|
|
76
76
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
77
|
-
"react": "^19.
|
|
78
|
-
"react-dom": "^19.
|
|
77
|
+
"react": "^19.1.0",
|
|
78
|
+
"react-dom": "^19.1.0",
|
|
79
79
|
"stream-http": "^3.2.0",
|
|
80
80
|
"https-browserify": "^1.0.0",
|
|
81
81
|
"os-browserify": "^0.3.0",
|
|
82
82
|
"stream-browserify": "^3.0.0",
|
|
83
|
-
"typescript-eslint": "^8.
|
|
83
|
+
"typescript-eslint": "^8.28.0",
|
|
84
84
|
"webpack-cli": "^6.0.1"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@btc-vision/bitcoin": "^6.3.6",
|
|
88
|
-
"@btc-vision/transaction": "^1.3.
|
|
88
|
+
"@btc-vision/transaction": "^1.3.6",
|
|
89
89
|
"@eslint/js": "^9.23.0",
|
|
90
90
|
"gulp-clean": "^0.4.0",
|
|
91
91
|
"gulp-eslint-new": "^2.4.0",
|
|
92
92
|
"gulp-logger-new": "^1.0.1",
|
|
93
|
-
"opnet": "^1.3.
|
|
93
|
+
"opnet": "^1.3.16",
|
|
94
94
|
"webpack": "^5.98.0"
|
|
95
95
|
}
|
|
96
96
|
}
|
package/src/WalletConnection.ts
CHANGED
|
@@ -124,6 +124,25 @@ export class WalletConnection {
|
|
|
124
124
|
throw new Error('Unsupported wallet');
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @description Get the address typed (P2TR or Native Segwit, etc.) of the connected wallet
|
|
129
|
+
* @returns {Promise<string>}
|
|
130
|
+
*/
|
|
131
|
+
public async getAddressTyped(): Promise<string> {
|
|
132
|
+
if (!this.walletWindowInstance) throw new Error('Wallet not connected');
|
|
133
|
+
|
|
134
|
+
if (
|
|
135
|
+
this.walletType === SupportedWallets.OP_WALLET ||
|
|
136
|
+
this.walletType === SupportedWallets.UNISAT
|
|
137
|
+
) {
|
|
138
|
+
const accounts = await this.walletWindowInstance.getAccounts();
|
|
139
|
+
|
|
140
|
+
return accounts[0];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
throw new Error('Unsupported wallet');
|
|
144
|
+
}
|
|
145
|
+
|
|
127
146
|
/**
|
|
128
147
|
* @description Get the network of the connected wallet
|
|
129
148
|
* @returns {Promise<Network>}
|
package/src/WalletProvider.tsx
CHANGED
|
@@ -8,6 +8,7 @@ export interface Account {
|
|
|
8
8
|
isConnected: boolean;
|
|
9
9
|
signer: Signers | null;
|
|
10
10
|
address: Address;
|
|
11
|
+
addressTyped: string;
|
|
11
12
|
network: Network;
|
|
12
13
|
provider: AbstractRpcProvider;
|
|
13
14
|
}
|
|
@@ -59,6 +60,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|
|
59
60
|
|
|
60
61
|
const signer = walletConnection.signer;
|
|
61
62
|
const address = await walletConnection.getAddress();
|
|
63
|
+
const addressTyped = await walletConnection.getAddressTyped();
|
|
62
64
|
const network = await walletConnection.getNetwork();
|
|
63
65
|
const provider = await walletConnection.getProvider();
|
|
64
66
|
|
|
@@ -66,6 +68,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|
|
66
68
|
isConnected: true,
|
|
67
69
|
signer,
|
|
68
70
|
address,
|
|
71
|
+
addressTyped,
|
|
69
72
|
network,
|
|
70
73
|
provider,
|
|
71
74
|
});
|
|
@@ -84,6 +87,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|
|
84
87
|
instance.on('accountsChanged', async () => {
|
|
85
88
|
try {
|
|
86
89
|
const updatedAddress = await walletConnection.getAddress();
|
|
90
|
+
const updatedAddressTyped = await walletConnection.getAddressTyped();
|
|
87
91
|
const updatedNetwork = await walletConnection.getNetwork();
|
|
88
92
|
const updatedProvider = await walletConnection.getProvider();
|
|
89
93
|
|
|
@@ -92,6 +96,7 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr
|
|
|
92
96
|
? {
|
|
93
97
|
...prevAccount,
|
|
94
98
|
address: updatedAddress,
|
|
99
|
+
addressTyped: updatedAddressTyped,
|
|
95
100
|
network: updatedNetwork,
|
|
96
101
|
provider: updatedProvider,
|
|
97
102
|
}
|