@hashgraph/hedera-wallet-connect 1.4.3-canary.dc50d18.0 → 1.4.3-canary.eb2a8b3.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 +20 -3
- package/package.json +2 -2
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
@@ -166,14 +166,31 @@ export class DAppConnector {
|
|
166
166
|
/**
|
167
167
|
* Initiates the WalletConnect connection flow using a QR code.
|
168
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).
|
169
170
|
* @returns {Promise<SessionTypes.Struct>} - A Promise that resolves when the connection process is complete.
|
170
171
|
*/
|
171
|
-
async openModal(pairingTopic) {
|
172
|
+
async openModal(pairingTopic, throwErrorOnReject = false) {
|
172
173
|
try {
|
173
174
|
const { uri, approval } = await this.connectURI(pairingTopic);
|
174
175
|
this.walletConnectModal.openModal({ uri });
|
175
|
-
const session = await
|
176
|
-
|
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
|
+
});
|
177
194
|
return session;
|
178
195
|
}
|
179
196
|
finally {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hashgraph/hedera-wallet-connect",
|
3
|
-
"version": "1.4.3-canary.
|
3
|
+
"version": "1.4.3-canary.eb2a8b3.0",
|
4
4
|
"description": "A library to facilitate integrating Hedera with WalletConnect",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -26,7 +26,7 @@
|
|
26
26
|
"@walletconnect/sign-client": "^2.17.0",
|
27
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",
|