@hashgraph/hedera-wallet-connect 1.4.4-canary.fc5ac42.0 → 1.5.1-canary.06a599b.0
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/dist/lib/dapp/index.d.ts +2 -1
- package/dist/lib/dapp/index.js +23 -21
- package/package.json +7 -7
package/dist/lib/dapp/index.d.ts
CHANGED
@@ -63,9 +63,10 @@ export declare class DAppConnector {
|
|
63
63
|
/**
|
64
64
|
* Initiates the WalletConnect connection flow using a QR code.
|
65
65
|
* @param pairingTopic - The pairing topic for the connection (optional).
|
66
|
+
* @param throwErrorOnReject - Whether to show an error when the user rejects the pairing (default: false).
|
66
67
|
* @returns {Promise<SessionTypes.Struct>} - A Promise that resolves when the connection process is complete.
|
67
68
|
*/
|
68
|
-
openModal(pairingTopic?: string): Promise<SessionTypes.Struct>;
|
69
|
+
openModal(pairingTopic?: string, throwErrorOnReject?: boolean): Promise<SessionTypes.Struct>;
|
69
70
|
/**
|
70
71
|
* Initiates the WallecConnect connection flow using URI.
|
71
72
|
* @param pairingTopic - The pairing topic for the connection (optional).
|
package/dist/lib/dapp/index.js
CHANGED
@@ -111,10 +111,6 @@ export class DAppConnector {
|
|
111
111
|
this.signers = existingSessions.flatMap((session) => this.createSigners(session));
|
112
112
|
else
|
113
113
|
this.checkIframeConnect();
|
114
|
-
// Validate and refresh signers every 10 seconds
|
115
|
-
setInterval(() => {
|
116
|
-
this.validateAndRefreshSigners();
|
117
|
-
}, 10000);
|
118
114
|
this.walletConnectClient.on('session_event', this.handleSessionEvent.bind(this));
|
119
115
|
this.walletConnectClient.on('session_update', this.handleSessionUpdate.bind(this));
|
120
116
|
this.walletConnectClient.on('session_delete', this.handleSessionDelete.bind(this));
|
@@ -170,14 +166,31 @@ export class DAppConnector {
|
|
170
166
|
/**
|
171
167
|
* Initiates the WalletConnect connection flow using a QR code.
|
172
168
|
* @param pairingTopic - The pairing topic for the connection (optional).
|
169
|
+
* @param throwErrorOnReject - Whether to show an error when the user rejects the pairing (default: false).
|
173
170
|
* @returns {Promise<SessionTypes.Struct>} - A Promise that resolves when the connection process is complete.
|
174
171
|
*/
|
175
|
-
async openModal(pairingTopic) {
|
172
|
+
async openModal(pairingTopic, throwErrorOnReject = false) {
|
176
173
|
try {
|
177
174
|
const { uri, approval } = await this.connectURI(pairingTopic);
|
178
175
|
this.walletConnectModal.openModal({ uri });
|
179
|
-
const session = await
|
180
|
-
|
176
|
+
const session = await new Promise(async (resolve, reject) => {
|
177
|
+
if (throwErrorOnReject) {
|
178
|
+
this.walletConnectModal.subscribeModal((state) => {
|
179
|
+
// the modal was closed so reject the promise
|
180
|
+
if (!state.open) {
|
181
|
+
reject(new Error('User rejected pairing'));
|
182
|
+
}
|
183
|
+
});
|
184
|
+
}
|
185
|
+
try {
|
186
|
+
const approvedSession = await approval();
|
187
|
+
await this.onSessionConnected(approvedSession);
|
188
|
+
resolve(approvedSession);
|
189
|
+
}
|
190
|
+
catch (error) {
|
191
|
+
reject(error);
|
192
|
+
}
|
193
|
+
});
|
181
194
|
return session;
|
182
195
|
}
|
183
196
|
finally {
|
@@ -235,30 +248,19 @@ export class DAppConnector {
|
|
235
248
|
return false;
|
236
249
|
}
|
237
250
|
const session = this.walletConnectClient.session.get(topic);
|
238
|
-
const
|
251
|
+
const hasSigner = this.signers.some((signer) => signer.topic === topic);
|
239
252
|
if (!session) {
|
240
253
|
// If session doesn't exist but we have a signer for it, clean up
|
241
|
-
if (
|
254
|
+
if (hasSigner) {
|
242
255
|
this.logger.warn(`Signer exists but no session found for topic: ${topic}`);
|
243
256
|
this.handleSessionDelete({ topic });
|
244
257
|
}
|
245
258
|
return false;
|
246
259
|
}
|
247
|
-
if (!
|
260
|
+
if (!hasSigner) {
|
248
261
|
this.logger.warn(`Session exists but no signer found for topic: ${topic}`);
|
249
262
|
return false;
|
250
263
|
}
|
251
|
-
this.logger.info(`Session validated for topic: ${topic} - will extend expiry`);
|
252
|
-
this.walletConnectClient
|
253
|
-
.extend({
|
254
|
-
topic: topic,
|
255
|
-
})
|
256
|
-
.then(() => {
|
257
|
-
this.logger.info(`Session extended for topic: ${topic}`);
|
258
|
-
})
|
259
|
-
.catch((e) => {
|
260
|
-
this.logger.error('Error extending session:', e);
|
261
|
-
});
|
262
264
|
return true;
|
263
265
|
}
|
264
266
|
catch (e) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hashgraph/hedera-wallet-connect",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.1-canary.06a599b.0",
|
4
4
|
"description": "A library to facilitate integrating Hedera with WalletConnect",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -21,12 +21,12 @@
|
|
21
21
|
"@swc/jest": "^0.2.36",
|
22
22
|
"@types/jest": "^29.5.3",
|
23
23
|
"@types/node": "^22.5.0",
|
24
|
-
"@types/react-dom": "^
|
24
|
+
"@types/react-dom": "^19.0.3",
|
25
25
|
"@walletconnect/modal": "^2.7.0",
|
26
|
-
"@walletconnect/sign-client": "^2.17.
|
27
|
-
"@walletconnect/types": "^2.17.
|
26
|
+
"@walletconnect/sign-client": "^2.17.0",
|
27
|
+
"@walletconnect/types": "^2.17.0",
|
28
28
|
"concurrently": "^9.0.1",
|
29
|
-
"esbuild": "^0.
|
29
|
+
"esbuild": "^0.25.0",
|
30
30
|
"esbuild-plugin-copy": "^2.1.1",
|
31
31
|
"eslint-plugin-tsdoc": "^0.4.0",
|
32
32
|
"husky": "^9.0.6",
|
@@ -40,8 +40,8 @@
|
|
40
40
|
"react-dom": "^19.0.0",
|
41
41
|
"rimraf": "^5.0.5",
|
42
42
|
"ts-node": "^10.9.2",
|
43
|
-
"typedoc": "^0.
|
44
|
-
"typedoc-theme-hierarchy": "^
|
43
|
+
"typedoc": "^0.27.6",
|
44
|
+
"typedoc-theme-hierarchy": "^5.0.0",
|
45
45
|
"typescript": "^5.2.2",
|
46
46
|
"tweetnacl": "^1.0.3"
|
47
47
|
},
|