@@ -25,11 +25,12 @@ import {
2525 createDefaultWallet ,
2626 getCurrentWallet ,
2727 getOnChainWallet ,
28+ getOnChainWalletAsync ,
2829 getOnChainWalletTransaction ,
30+ getOnChainWalletTransactionAsync ,
2931 getSelectedNetwork ,
3032 getSelectedWallet ,
3133 refreshWallet ,
32- waitForWallet ,
3334} from '../../utils/wallet' ;
3435import {
3536 dispatch ,
@@ -125,7 +126,7 @@ export const generateNewReceiveAddress = async ({
125126 keyDerivationPath ?: IKeyDerivationPath ;
126127} ) : Promise < Result < IAddress > > => {
127128 try {
128- const wallet = getOnChainWallet ( ) ;
129+ const wallet = await getOnChainWalletAsync ( ) ;
129130 return wallet . generateNewReceiveAddress ( { addressType, keyDerivationPath } ) ;
130131 } catch ( e ) {
131132 console . log ( e ) ;
@@ -138,22 +139,22 @@ export const generateNewReceiveAddress = async ({
138139 * @returns {Promise<string> }
139140 */
140141export const clearUtxos = async ( ) : Promise < string > => {
141- const wallet = getOnChainWallet ( ) ;
142+ const wallet = await getOnChainWalletAsync ( ) ;
142143 return await wallet . clearUtxos ( ) ;
143144} ;
144145
145- export const updateWalletBalance = ( {
146- balance,
147- } : {
148- balance : number ;
149- } ) : Result < string > => {
150- try {
151- const wallet = getOnChainWallet ( ) ;
152- return wallet . updateWalletBalance ( { balance } ) ;
153- } catch ( e ) {
154- return err ( e ) ;
155- }
156- } ;
146+ // export const updateWalletBalance = ({
147+ // balance,
148+ // }: {
149+ // balance: number;
150+ // }): Result<string> => {
151+ // try {
152+ // const wallet = getOnChainWalletAsync ();
153+ // return wallet.updateWalletBalance({ balance });
154+ // } catch (e) {
155+ // return err(e);
156+ // }
157+ // };
157158
158159/**
159160 * Parses and adds unconfirmed transactions to the store.
@@ -216,7 +217,7 @@ export const injectFakeTransaction = (
216217// scanAllAddresses?: boolean;
217218// replaceStoredTransactions?: boolean;
218219// }): Promise<Result<string | undefined>> => {
219- // const wallet = getOnChainWallet ();
220+ // const wallet = async getOnChainWalletAsync ();
220221// return await wallet.updateTransactions({
221222// scanAllAddresses,
222223// replaceStoredTransactions,
@@ -233,7 +234,7 @@ export const deleteOnChainTransactionById = async ({
233234} : {
234235 txid : string ;
235236} ) : Promise < void > => {
236- const wallet = getOnChainWallet ( ) ;
237+ const wallet = await getOnChainWalletAsync ( ) ;
237238 return await wallet . deleteOnChainTransactionById ( { txid } ) ;
238239} ;
239240
@@ -255,7 +256,7 @@ export const addBoostedTransaction = async ({
255256 type ?: EBoostType ;
256257 fee : number ;
257258} ) : Promise < Result < IBoostedTransaction > > => {
258- const wallet = getOnChainWallet ( ) ;
259+ const wallet = await getOnChainWalletAsync ( ) ;
259260 return await wallet . addBoostedTransaction ( {
260261 newTxId,
261262 oldTxId,
@@ -290,7 +291,7 @@ export const setupOnChainTransaction = async ({
290291 outputs ?: IOutput [ ] ; // Used to pre-specify outputs to use.
291292} = { } ) : Promise < TSetupTransactionResponse > => {
292293 rbf = rbf ?? getSettingsStore ( ) . rbf ;
293- const transaction = getOnChainWalletTransaction ( ) ;
294+ const transaction = await getOnChainWalletTransactionAsync ( ) ;
294295 return await transaction . setupTransaction ( {
295296 inputTxHashes,
296297 utxos,
@@ -310,7 +311,7 @@ export const getChangeAddress = async ({
310311} : {
311312 addressType ?: EAddressType ;
312313} ) : Promise < Result < IAddress > > => {
313- const wallet = getOnChainWallet ( ) ;
314+ const wallet = await getOnChainWalletAsync ( ) ;
314315 return await wallet . getChangeAddress ( addressType ) ;
315316} ;
316317
@@ -331,8 +332,7 @@ export const updateSendTransaction = (
331332 * @returns {Result<string> }
332333 */
333334export const resetSendTransaction = async ( ) : Promise < Result < string > > => {
334- await waitForWallet ( ) ;
335- const transaction = getOnChainWalletTransaction ( ) ;
335+ const transaction = await getOnChainWalletTransactionAsync ( ) ;
336336 return transaction . resetSendTransaction ( ) ;
337337} ;
338338
@@ -341,7 +341,7 @@ export const updateSelectedAddressType = async ({
341341} : {
342342 addressType : EAddressType ;
343343} ) : Promise < void > => {
344- const wallet = getOnChainWallet ( ) ;
344+ const wallet = await getOnChainWalletAsync ( ) ;
345345 const addressTypesToMonitor = wallet . addressTypesToMonitor ;
346346 if ( ! addressTypesToMonitor . includes ( addressType ) ) {
347347 // Append the new address type so we monitor it in subsequent sessions.
0 commit comments