@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/dist/cjs/classes/WalletObserver.class.js +87 -59
- package/dist/cjs/classes/WalletObserver.class.js.map +1 -1
- package/dist/esm/classes/WalletObserver.class.js +33 -22
- package/dist/esm/classes/WalletObserver.class.js.map +1 -1
- package/dist/types/classes/WalletObserver.class.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/classes/WalletObserver.class.ts +55 -38
package/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { TransactionUnspentOutput } from "@cardano-sdk/core/dist/cjs/Serialization/index.js";
|
|
2
|
-
import type {
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
182
|
-
|
|
185
|
+
this.dispatch(EWalletObserverEvents.SYNCING_WALLET_END, result);
|
|
186
|
+
this._performingSync = false;
|
|
183
187
|
|
|
184
|
-
|
|
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
|
-
|
|
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
|
]);
|