Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
into release/0.8.0
  • Loading branch information
veado committed Feb 17, 2022
2 parents 1dc5361 + 2149af8 commit fb65bbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
6 changes: 0 additions & 6 deletions src/renderer/contexts/BitcoinContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {
addressUI$,
reloadBalances,
balances$,
balancesConfirmed$,
getBalanceByAddress$,
getBalanceConfirmedByAddress$,
txRD$,
reloadFees,
fees$,
Expand All @@ -31,9 +29,7 @@ export type BitcoinContextValue = {
addressUI$: typeof addressUI$
reloadBalances: typeof reloadBalances
balances$: typeof balances$
balancesConfirmed$: typeof balancesConfirmed$
getBalanceByAddress$: typeof getBalanceByAddress$
getBalanceConfirmedByAddress$: typeof getBalanceConfirmedByAddress$
reloadFees: typeof reloadFees
fees$: typeof fees$
reloadFeesWithRates: typeof reloadFeesWithRates
Expand All @@ -55,9 +51,7 @@ const initialContext: BitcoinContextValue = {
addressUI$,
reloadBalances,
balances$,
balancesConfirmed$,
getBalanceByAddress$,
getBalanceConfirmedByAddress$,
reloadFees,
fees$,
reloadFeesWithRates,
Expand Down
32 changes: 9 additions & 23 deletions src/renderer/services/bitcoin/balances.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletType } from '../../../shared/wallet/types'
import { WalletBalanceType, WalletType } from '../../../shared/wallet/types'
import { observableState } from '../../helpers/stateHelper'
import * as C from '../clients'
import { client$ } from './common'
Expand All @@ -19,28 +19,14 @@ const reloadBalances = () => {
}

// State of balances loaded by Client
const balances$ = (walletType: WalletType, walletIndex: number): C.WalletBalancesLD =>
C.balances$({ client$, trigger$: reloadBalances$, walletType, walletIndex, walletBalanceType: 'all' })

// State of balances loaded by Client
const balancesConfirmed$ = (walletType: WalletType, walletIndex: number): C.WalletBalancesLD =>
C.balances$({ client$, trigger$: reloadBalances$, walletType, walletIndex, walletBalanceType: 'confirmed' })
const balances$ = (
walletType: WalletType,
walletIndex: number,
walletBalanceType: WalletBalanceType
): C.WalletBalancesLD => C.balances$({ client$, trigger$: reloadBalances$, walletType, walletIndex, walletBalanceType })

// State of balances loaded by Client and Address
const getBalanceByAddress$ = C.balancesByAddress$({ client$, trigger$: reloadBalances$, walletBalanceType: 'all' })
const getBalanceByAddress$ = (walletBalanceType: WalletBalanceType) =>
C.balancesByAddress$({ client$, trigger$: reloadBalances$, walletBalanceType })

const getBalanceConfirmedByAddress$ = C.balancesByAddress$({
client$,
trigger$: reloadBalances$,
walletBalanceType: 'confirmed'
})

export {
balances$,
balancesConfirmed$,
reloadBalances,
getBalanceByAddress$,
getBalanceConfirmedByAddress$,
reloadBalances$,
resetReloadBalances
}
export { balances$, reloadBalances, getBalanceByAddress$, reloadBalances$, resetReloadBalances }
12 changes: 1 addition & 11 deletions src/renderer/services/bitcoin/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { network$ } from '../app/service'
import {
balances$,
balancesConfirmed$,
reloadBalances,
getBalanceByAddress$,
getBalanceConfirmedByAddress$,
reloadBalances$,
resetReloadBalances
} from './balances'
import { balances$, reloadBalances, getBalanceByAddress$, reloadBalances$, resetReloadBalances } from './balances'
import { client$, clientState$, address$, addressUI$, explorerUrl$ } from './common'
import { createFeesService } from './fees'
import { createLedgerService } from './ledger'
Expand All @@ -28,9 +20,7 @@ export {
reloadBalances$,
resetReloadBalances,
balances$,
balancesConfirmed$,
getBalanceByAddress$,
getBalanceConfirmedByAddress$,
reloadFees,
fees$,
reloadFeesWithRates,
Expand Down
10 changes: 3 additions & 7 deletions src/renderer/services/wallet/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ export const createBalancesService = ({
return {
reloadBalances: BTC.reloadBalances,
resetReloadBalances: BTC.resetReloadBalances,
balances$:
walletBalanceType === 'confirmed'
? BTC.balancesConfirmed$(walletType, walletIndex)
: BTC.balances$(walletType, walletIndex),
balances$: BTC.balances$(walletType, walletIndex, walletBalanceType),
reloadBalances$: BTC.reloadBalances$
}
case BCHChain:
Expand Down Expand Up @@ -225,7 +222,6 @@ export const createBalancesService = ({

return FP.pipe(
reload$,
// chainService.reloadBalances$,
RxOp.switchMap((shouldReloadData) => {
const savedResult = walletBalancesState.get({ chain, walletType, walletBalanceType })
// For every new simple subscription return cached results if they exist
Expand Down Expand Up @@ -408,15 +404,15 @@ export const createBalancesService = ({
const btcLedgerChainBalance$: ChainBalance$ = ledgerChainBalance$({
chain: BTCChain,
walletBalanceType: 'all',
getBalanceByAddress$: BTC.getBalanceByAddress$
getBalanceByAddress$: BTC.getBalanceByAddress$('all')
})
/**
* BTC Ledger confirmed balances
*/
const btcLedgerChainBalanceConfirmed$: ChainBalance$ = ledgerChainBalance$({
chain: BTCChain,
walletBalanceType: 'confirmed',
getBalanceByAddress$: BTC.getBalanceByAddress$
getBalanceByAddress$: BTC.getBalanceByAddress$('confirmed')
})

/**
Expand Down

0 comments on commit fb65bbd

Please sign in to comment.