@@ -2,11 +2,12 @@ import { err, ok, Result } from '@synonymdev/result';
22
33import { EAvailableNetwork } from '../networks' ;
44import {
5+ ITransaction ,
56 getCustomElectrumPeers ,
6- getOnChainWallet ,
7+ getOnChainWalletAsync ,
78 getOnChainWalletElectrum ,
9+ getOnChainWalletElectrumAsync ,
810 getSelectedNetwork ,
9- ITransaction ,
1011 refreshWallet ,
1112} from './index' ;
1213import {
@@ -35,7 +36,7 @@ export type TUnspentAddressScriptHashData = {
3536 * @returns {Promise<boolean> }
3637 */
3738export const isConnectedElectrum = async ( ) : Promise < boolean > => {
38- const electrum = getOnChainWalletElectrum ( ) ;
39+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
3940 return electrum . isConnected ( ) ;
4041} ;
4142
@@ -65,7 +66,7 @@ export const listUnspentAddressScriptHashes = async ({
6566} : {
6667 addresses : TUnspentAddressScriptHashData ;
6768} ) : Promise < Result < IGetUtxosResponse > > => {
68- const electrum = getOnChainWalletElectrum ( ) ;
69+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
6970 const unspentAddressResult = await electrum . listUnspentAddressScriptHashes ( {
7071 addresses,
7172 } ) ;
@@ -89,7 +90,7 @@ export const subscribeToAddresses = async ({
8990 scriptHashes ?: string [ ] ;
9091 onReceive ?: ( ) => void ;
9192} = { } ) : Promise < Result < string > > => {
92- const electrum = getOnChainWalletElectrum ( ) ;
93+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
9394 return electrum . subscribeToAddresses ( { scriptHashes, onReceive } ) ;
9495} ;
9596
@@ -132,7 +133,7 @@ export const getTransactions = async ({
132133} : {
133134 txHashes : ITxHash [ ] ;
134135} ) : Promise < Result < IGetTransactions > > => {
135- const electrum = getOnChainWalletElectrum ( ) ;
136+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
136137 return await electrum . getTransactions ( { txHashes } ) ;
137138} ;
138139
@@ -147,7 +148,7 @@ export interface IPeerData {
147148 * @return {Promise<Result<IPeerData>> }
148149 */
149150export const getConnectedPeer = async ( ) : Promise < Result < IPeerData > > => {
150- const electrum = getOnChainWalletElectrum ( ) ;
151+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
151152 const peerData = await electrum . getConnectedPeer ( ) ;
152153 return peerData as Result < IPeerData > ;
153154} ;
@@ -173,7 +174,7 @@ export const getTransactionsFromInputs = async ({
173174} : {
174175 txHashes : ITxHash [ ] ;
175176} ) : Promise < Result < IGetTransactionsFromInputs > > => {
176- const electrum = getOnChainWalletElectrum ( ) ;
177+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
177178 return await electrum . getTransactionsFromInputs ( { txHashes } ) ;
178179} ;
179180
@@ -197,7 +198,7 @@ export const getAddressHistory = async ({
197198 scriptHashes ?: IAddress [ ] ;
198199 scanAllAddresses ?: boolean ;
199200} ) : Promise < Result < IGetAddressHistoryResponse [ ] > > => {
200- const electrum = getOnChainWalletElectrum ( ) ;
201+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
201202 return await electrum . getAddressHistory ( { scriptHashes, scanAllAddresses } ) ;
202203} ;
203204
@@ -217,7 +218,7 @@ export const connectToElectrum = async ({
217218 showNotification ?: boolean ;
218219 selectedNetwork ?: EAvailableNetwork ;
219220} = { } ) : Promise < Result < string > > => {
220- const electrum = getOnChainWalletElectrum ( ) ;
221+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
221222
222223 // Attempt to disconnect from any old/lingering connections
223224 await electrum ?. disconnect ( ) ;
@@ -254,7 +255,7 @@ export const getAddressBalance = async ({
254255} : {
255256 addresses : string [ ] ;
256257} ) : Promise < Result < number > > => {
257- const wallet = getOnChainWallet ( ) ;
258+ const wallet = await getOnChainWalletAsync ( ) ;
258259 return await wallet . getAddressesBalance ( addresses ) ;
259260} ;
260261
@@ -269,7 +270,7 @@ export const getBlockHex = async ({
269270} : {
270271 height ?: number ;
271272} ) : Promise < Result < string > > => {
272- const electrum = getOnChainWalletElectrum ( ) ;
273+ const electrum = await getOnChainWalletElectrumAsync ( ) ;
273274 return await electrum . getBlockHex ( { height } ) ;
274275} ;
275276
@@ -280,14 +281,14 @@ export const getBlockHex = async ({
280281 * @param {EAvailableNetwork } [selectedNetwork]
281282 * @returns {string }
282283 */
283- export const getBlockHashFromHex = ( {
284- blockHex,
285- } : {
286- blockHex ?: string ;
287- } ) : string => {
288- const electrum = getOnChainWalletElectrum ( ) ;
289- return electrum . getBlockHashFromHex ( { blockHex } ) ;
290- } ;
284+ // export const getBlockHashFromHex = ({
285+ // blockHex,
286+ // }: {
287+ // blockHex?: string;
288+ // }): string => {
289+ // const electrum = getOnChainWalletElectrum();
290+ // return electrum.getBlockHashFromHex({ blockHex });
291+ // };
291292
292293/**
293294 * Returns last known block height, and it's corresponding hex from local storage.
0 commit comments