Skip to content

Commit

Permalink
sort bch imported addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
schnogz committed May 10, 2019
1 parent 498cefc commit 63918c1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
import {
assoc,
curry,
assocPath,
compose,
concat,
compose,
curry,
descend,
filter,
has,
head,
isNil,
lensIndex,
lensProp,
lift,
map,
not,
map,
path,
prop,
prepend,
prop,
reduce,
set,
sequence,
reduce
sort
} from 'ramda'
import { Exchange, Remote } from 'blockchain-wallet-v4/src'
import { selectors } from 'data'
Expand Down Expand Up @@ -106,9 +112,21 @@ export const getData = (state, ownProps) => {
.map(toGroup('Wallet')),
excludeImported
? Remote.of([])
: lift(formatImportedAddressesData)(relevantAddresses).map(
toGroup('Imported Addresses')
),
: lift(formatImportedAddressesData)(relevantAddresses)
.map(toGroup('Imported Addresses'))
.map(x =>
set(
compose(
lensIndex(0),
lensProp('options')
),
sort(
descend(path(['value', 'balance'])),
prop('options', head(x))
),
x
)
),
excludeLockbox
? Remote.of([])
: selectors.core.common.bch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,20 @@ export const getData = (state, ownProps) => {
: selectors.core.common.btc
.getAddressesBalances(state)
.map(toDropdown)
.map(toGroup('Imported Addresses')),
.map(toGroup('Imported Addresses'))
.map(x =>
set(
compose(
lensIndex(0),
lensProp('options')
),
sort(
descend(path(['value', 'balance'])),
prop('options', head(x))
),
x
)
),
excludeLockbox
? Remote.of([])
: selectors.core.common.btc
Expand All @@ -84,15 +97,7 @@ export const getData = (state, ownProps) => {
.map(toDropdown)
.map(toGroup('Lockbox'))
]).map(([b1, b2, b3]) => {
const importedAddressesSorted = set(
compose(
lensIndex(0),
lensProp('options')
),
sort(descend(path(['value', 'balance'])), prop('options', head(b2))),
b2
)
const data = reduce(concat, [], [b1, importedAddressesSorted, b3])
const data = reduce(concat, [], [b1, b2, b3])
if (includeAll) {
return { data: prepend(allWallets, data) }
} else if (excludeHDWallets) {
Expand Down

0 comments on commit 63918c1

Please sign in to comment.