@hashgraph/hedera-wallet-connect 1.4.4-canary.fc5ac42.0 → 1.5.1-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.
@@ -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).
@@ -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 approval();
180
- await this.onSessionConnected(session);
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 signer = this.signers.find((signer) => signer.topic === topic);
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 (Boolean(signer)) {
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 (!Boolean(signer)) {
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.4.4-canary.fc5ac42.0",
3
+ "version": "1.5.1-0",
4
4
  "description": "A library to facilitate integrating Hedera with WalletConnect",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,19 +14,22 @@
14
14
  "walletconnect",
15
15
  "hashgraph"
16
16
  ],
17
+ "overrides": {
18
+ "elliptic": "6.6.1"
19
+ },
17
20
  "license": "Apache-2.0",
18
21
  "devDependencies": {
19
- "@hashgraph/hedera-wallet-connect": "^1.3.4",
22
+ "@hashgraph/hedera-wallet-connect": "^1.5.0",
20
23
  "@swc/core": "^1.7.40",
21
24
  "@swc/jest": "^0.2.36",
22
25
  "@types/jest": "^29.5.3",
23
26
  "@types/node": "^22.5.0",
24
- "@types/react-dom": "^18.2.21",
27
+ "@types/react-dom": "^19.0.3",
25
28
  "@walletconnect/modal": "^2.7.0",
26
- "@walletconnect/sign-client": "^2.17.3",
27
- "@walletconnect/types": "^2.17.3",
29
+ "@walletconnect/sign-client": "^2.19.1",
30
+ "@walletconnect/types": "^2.19.1",
28
31
  "concurrently": "^9.0.1",
29
- "esbuild": "^0.24.0",
32
+ "esbuild": "^0.25.0",
30
33
  "esbuild-plugin-copy": "^2.1.1",
31
34
  "eslint-plugin-tsdoc": "^0.4.0",
32
35
  "husky": "^9.0.6",
@@ -40,10 +43,10 @@
40
43
  "react-dom": "^19.0.0",
41
44
  "rimraf": "^5.0.5",
42
45
  "ts-node": "^10.9.2",
43
- "typedoc": "^0.26.3",
44
- "typedoc-theme-hierarchy": "^4.1.2",
45
- "typescript": "^5.2.2",
46
- "tweetnacl": "^1.0.3"
46
+ "tweetnacl": "^1.0.3",
47
+ "typedoc": "^0.27.6",
48
+ "typedoc-theme-hierarchy": "^5.0.0",
49
+ "typescript": "^5.2.2"
47
50
  },
48
51
  "scripts": {
49
52
  "build": "rimraf dist && tsc",
@@ -69,10 +72,10 @@
69
72
  "test:coverage:html": "jest --coverage --coverageReporters='text-summary' --coverageReporters='html'"
70
73
  },
71
74
  "peerDependencies": {
72
- "@hashgraph/sdk": "^2.40.0",
75
+ "@hashgraph/sdk": "^2.61.0",
73
76
  "@walletconnect/qrcode-modal": "^1.8.0",
74
- "@walletconnect/types": "^2.17.0",
75
- "@walletconnect/utils": "^2.17.0",
77
+ "@walletconnect/types": "^2.19.1",
78
+ "@walletconnect/utils": "^2.19.1",
76
79
  "@walletconnect/web3wallet": "^1.16.0"
77
80
  }
78
81
  }