@sundaeswap/wallet-lite 0.0.21 → 0.0.23

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.21",
3
+ "version": "0.0.23",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.js",
@@ -1,5 +1,8 @@
1
1
  import type { TransactionUnspentOutput } from "@cardano-sdk/core/dist/cjs/Serialization/index.js";
2
- import type { Cip30WalletApi } from "@cardano-sdk/dapp-connector";
2
+ import type {
3
+ Cip30WalletApi,
4
+ GetCollateral,
5
+ } from "@cardano-sdk/dapp-connector";
3
6
  import { AssetAmount, type IAssetAmountMetadata } from "@sundaeswap/asset";
4
7
  import merge from "lodash/merge.js";
5
8
 
@@ -517,7 +520,16 @@ export class WalletObserver<
517
520
  }
518
521
 
519
522
  const [cbor, { Serialization }, { typedHex }] = await Promise.all([
520
- this.api.getCollateral(),
523
+ (async () => {
524
+ const funcCall =
525
+ this.api?.getCollateral ||
526
+ (this.api?.experimental.getCollateral as GetCollateral);
527
+ if (typeof funcCall !== "function") {
528
+ return [];
529
+ }
530
+
531
+ return await funcCall();
532
+ })(),
521
533
  getCardanoCore(),
522
534
  getCardanoUtil(),
523
535
  ]);
@@ -558,11 +570,28 @@ export class WalletObserver<
558
570
  }
559
571
  }
560
572
 
561
- const newMetadata = await this._options.metadataResolver(
562
- assetIds.map(normalizeAssetIdWithDot),
563
- normalizeAssetIdWithDot,
564
- isAdaAsset
565
- );
573
+ let attempts = 0;
574
+ let newMetadata: Map<string, AssetMetadata> | undefined;
575
+ while (attempts <= 3) {
576
+ try {
577
+ newMetadata = await this._options.metadataResolver(
578
+ assetIds.map(normalizeAssetIdWithDot),
579
+ normalizeAssetIdWithDot,
580
+ isAdaAsset
581
+ );
582
+ } catch (e) {
583
+ attempts++;
584
+ }
585
+ }
586
+
587
+ if (!newMetadata) {
588
+ newMetadata = await this.fallbackMetadataResolver(
589
+ assetIds.map(normalizeAssetIdWithDot),
590
+ normalizeAssetIdWithDot,
591
+ isAdaAsset
592
+ );
593
+ }
594
+
566
595
  this._cachedMetadata = newMetadata;
567
596
  return newMetadata;
568
597
  };