@sundaeswap/wallet-lite 0.0.20 → 0.0.22

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.20",
3
+ "version": "0.0.22",
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
 
@@ -138,50 +141,55 @@ export class WalletObserver<
138
141
  );
139
142
  }
140
143
 
141
- this._performingSync = true;
142
- this.dispatch(EWalletObserverEvents.SYNCING_WALLET_START);
143
-
144
- let newNetwork: number;
145
144
  try {
146
- newNetwork = await this.getNetwork();
147
- } catch (e) {
145
+ this._performingSync = true;
146
+ this.dispatch(EWalletObserverEvents.SYNCING_WALLET_START);
147
+
148
+ let newNetwork: number;
148
149
  try {
149
- await this.syncApi();
150
150
  newNetwork = await this.getNetwork();
151
151
  } catch (e) {
152
- this.dispatch(EWalletObserverEvents.SYNCING_WALLET_END);
153
- this._performingSync = false;
154
- throw e;
152
+ try {
153
+ await this.syncApi();
154
+ newNetwork = await this.getNetwork();
155
+ } catch (e) {
156
+ this.dispatch(EWalletObserverEvents.SYNCING_WALLET_END);
157
+ this._performingSync = false;
158
+ throw e;
159
+ }
155
160
  }
156
- }
157
-
158
- const [
159
- newBalanceMap,
160
- newUsedAddresses,
161
- newUnusedAddresses,
162
- newOutputs,
163
- newCollateral,
164
- ] = await Promise.all([
165
- this.getBalanceMap(),
166
- this.getUsedAddresses(),
167
- this.getUnusedAddresses(),
168
- this.getUtxos(),
169
- this.getCollateral(),
170
- ]);
171
161
 
172
- const result = {
173
- balanceMap: newBalanceMap,
174
- usedAddresses: newUsedAddresses,
175
- unusedAddresses: newUnusedAddresses,
176
- utxos: newOutputs,
177
- collateral: newCollateral,
178
- network: newNetwork,
179
- };
162
+ const [
163
+ newBalanceMap,
164
+ newUsedAddresses,
165
+ newUnusedAddresses,
166
+ newOutputs,
167
+ newCollateral,
168
+ ] = await Promise.all([
169
+ this.getBalanceMap(),
170
+ this.getUsedAddresses(),
171
+ this.getUnusedAddresses(),
172
+ this.getUtxos(),
173
+ this.getCollateral(),
174
+ ]);
175
+
176
+ const result = {
177
+ balanceMap: newBalanceMap,
178
+ usedAddresses: newUsedAddresses,
179
+ unusedAddresses: newUnusedAddresses,
180
+ utxos: newOutputs,
181
+ collateral: newCollateral,
182
+ network: newNetwork,
183
+ };
180
184
 
181
- this.dispatch(EWalletObserverEvents.SYNCING_WALLET_END, result);
182
- this._performingSync = false;
185
+ this.dispatch(EWalletObserverEvents.SYNCING_WALLET_END, result);
186
+ this._performingSync = false;
183
187
 
184
- return result;
188
+ return result;
189
+ } catch (e) {
190
+ this._performingSync = false;
191
+ throw e;
192
+ }
185
193
  };
186
194
 
187
195
  /**
@@ -512,7 +520,16 @@ export class WalletObserver<
512
520
  }
513
521
 
514
522
  const [cbor, { Serialization }, { typedHex }] = await Promise.all([
515
- 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
+ })(),
516
533
  getCardanoCore(),
517
534
  getCardanoUtil(),
518
535
  ]);