@sundaeswap/wallet-lite 0.0.27 → 0.0.28

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sundaeswap/wallet-lite",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -1,7 +1,9 @@
1
1
  import type { TransactionUnspentOutput } from "@cardano-sdk/core/dist/cjs/Serialization/index.js";
2
- import type {
3
- Cip30WalletApi,
4
- GetCollateral,
2
+ import {
3
+ APIErrorCode,
4
+ type ApiError,
5
+ type Cip30WalletApi,
6
+ type GetCollateral,
5
7
  } from "@cardano-sdk/dapp-connector";
6
8
  import { AssetAmount, type IAssetAmountMetadata } from "@sundaeswap/asset";
7
9
  import merge from "lodash/merge.js";
@@ -238,7 +240,8 @@ export class WalletObserver<
238
240
  const selectedWallet =
239
241
  activeWallet || (this._activeWallet as TSupportedWalletExtensions);
240
242
 
241
- while (!this.api) {
243
+ let shouldContinue = true;
244
+ while (!this.api && shouldContinue) {
242
245
  if (attempts === 10) {
243
246
  throw new Error(
244
247
  "Could not reconnect to the selected wallet. Please check your extension."
@@ -255,6 +258,14 @@ export class WalletObserver<
255
258
  this.api = api;
256
259
  this.network = await api.getNetworkId();
257
260
  } catch (e) {
261
+ if (
262
+ (e as Error)?.message === "user canceled connection" ||
263
+ (e as ApiError)?.code === APIErrorCode.Refused
264
+ ) {
265
+ shouldContinue = false;
266
+ return undefined;
267
+ }
268
+
258
269
  await new Promise((res) => setTimeout(res, 200));
259
270
  attempts++;
260
271
  }