@@ -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 ,
@@ -38,7 +39,7 @@ import {
3839 getWalletStore ,
3940} from '../helpers' ;
4041import { EAvailableNetwork } from '../../utils/networks' ;
41- import { removeKeyFromObject } from '../../utils/helpers' ;
42+ import { removeKeyFromObject , sleep } from '../../utils/helpers' ;
4243import { TGetImpactedAddressesRes } from '../types/checks' ;
4344import { updateActivityList } from '../utils/activity' ;
4445import { ETransactionSpeed } from '../types/settings' ;
@@ -94,6 +95,7 @@ export const createWalletThunk = async ({
9495 return err ( response . error . message ) ;
9596 }
9697 dispatch ( createWallet ( response . value ) ) ;
98+ await sleep ( 1000 ) ; // give Beignet some time to propagate the data
9799 dispatch ( setWalletExits ( ) ) ;
98100 return ok ( '' ) ;
99101 } catch ( e ) {
@@ -125,7 +127,7 @@ export const generateNewReceiveAddress = async ({
125127 keyDerivationPath ?: IKeyDerivationPath ;
126128} ) : Promise < Result < IAddress > > => {
127129 try {
128- const wallet = getOnChainWallet ( ) ;
130+ const wallet = await getOnChainWalletAsync ( ) ;
129131 return wallet . generateNewReceiveAddress ( { addressType, keyDerivationPath } ) ;
130132 } catch ( e ) {
131133 console . log ( e ) ;
@@ -138,23 +140,10 @@ export const generateNewReceiveAddress = async ({
138140 * @returns {Promise<string> }
139141 */
140142export const clearUtxos = async ( ) : Promise < string > => {
141- const wallet = getOnChainWallet ( ) ;
143+ const wallet = await getOnChainWalletAsync ( ) ;
142144 return await wallet . clearUtxos ( ) ;
143145} ;
144146
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- } ;
157-
158147/**
159148 * Parses and adds unconfirmed transactions to the store.
160149 * @param {TWalletName } [selectedWallet]
@@ -216,7 +205,7 @@ export const injectFakeTransaction = (
216205// scanAllAddresses?: boolean;
217206// replaceStoredTransactions?: boolean;
218207// }): Promise<Result<string | undefined>> => {
219- // const wallet = getOnChainWallet ();
208+ // const wallet = async getOnChainWalletAsync ();
220209// return await wallet.updateTransactions({
221210// scanAllAddresses,
222211// replaceStoredTransactions,
@@ -233,7 +222,7 @@ export const deleteOnChainTransactionById = async ({
233222} : {
234223 txid : string ;
235224} ) : Promise < void > => {
236- const wallet = getOnChainWallet ( ) ;
225+ const wallet = await getOnChainWalletAsync ( ) ;
237226 return await wallet . deleteOnChainTransactionById ( { txid } ) ;
238227} ;
239228
@@ -255,7 +244,7 @@ export const addBoostedTransaction = async ({
255244 type ?: EBoostType ;
256245 fee : number ;
257246} ) : Promise < Result < IBoostedTransaction > > => {
258- const wallet = getOnChainWallet ( ) ;
247+ const wallet = await getOnChainWalletAsync ( ) ;
259248 return await wallet . addBoostedTransaction ( {
260249 newTxId,
261250 oldTxId,
@@ -290,7 +279,7 @@ export const setupOnChainTransaction = async ({
290279 outputs ?: IOutput [ ] ; // Used to pre-specify outputs to use.
291280} = { } ) : Promise < TSetupTransactionResponse > => {
292281 rbf = rbf ?? getSettingsStore ( ) . rbf ;
293- const transaction = getOnChainWalletTransaction ( ) ;
282+ const transaction = await getOnChainWalletTransactionAsync ( ) ;
294283 return await transaction . setupTransaction ( {
295284 inputTxHashes,
296285 utxos,
@@ -310,7 +299,7 @@ export const getChangeAddress = async ({
310299} : {
311300 addressType ?: EAddressType ;
312301} ) : Promise < Result < IAddress > > => {
313- const wallet = getOnChainWallet ( ) ;
302+ const wallet = await getOnChainWalletAsync ( ) ;
314303 return await wallet . getChangeAddress ( addressType ) ;
315304} ;
316305
@@ -331,8 +320,7 @@ export const updateSendTransaction = (
331320 * @returns {Result<string> }
332321 */
333322export const resetSendTransaction = async ( ) : Promise < Result < string > > => {
334- await waitForWallet ( ) ;
335- const transaction = getOnChainWalletTransaction ( ) ;
323+ const transaction = await getOnChainWalletTransactionAsync ( ) ;
336324 return transaction . resetSendTransaction ( ) ;
337325} ;
338326
@@ -341,7 +329,7 @@ export const updateSelectedAddressType = async ({
341329} : {
342330 addressType : EAddressType ;
343331} ) : Promise < void > => {
344- const wallet = getOnChainWallet ( ) ;
332+ const wallet = await getOnChainWalletAsync ( ) ;
345333 const addressTypesToMonitor = wallet . addressTypesToMonitor ;
346334 if ( ! addressTypesToMonitor . includes ( addressType ) ) {
347335 // Append the new address type so we monitor it in subsequent sessions.
0 commit comments