Skip to content

Commit

Permalink
dev: sort fidelity bond by value and lock state
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Nov 2, 2022
1 parent 3232b58 commit 846cee6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/Earn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const persistFormValues = (values) => {
}
}

const initialFormValues = (settings) => ({
const initialFormValues = () => ({
offertype:
window.localStorage.getItem(FORM_INPUT_LOCAL_STORAGE_KEYS.offertype) || FORM_INPUT_DEFAULT_VALUES.offertype,
feeRel:
Expand Down Expand Up @@ -301,7 +301,7 @@ export default function Earn({ wallet }) {
const feeRelMax = 0.1 // 10%
const feeRelPercentageStep = 0.0001

const initialValues = initialFormValues(settings)
const initialValues = initialFormValues()

const validate = (values) => {
const errors = {}
Expand Down
13 changes: 12 additions & 1 deletion src/context/WalletContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,18 @@ const toAddressSummary = (data: CombinedRawWalletData): AddressSummary => {
}

const toFidelityBondSummary = (data: CombinedRawWalletData): FidenlityBondSummary => {
const fbOutputs = data.utxos.utxos.filter((utxo) => fb.utxo.isFidelityBond(utxo))
const fbOutputs = data.utxos.utxos
.filter((utxo) => fb.utxo.isFidelityBond(utxo))
.sort((a, b) => {
const aLocked = fb.utxo.isLocked(a)
const bLocked = fb.utxo.isLocked(b)

if (aLocked && bLocked) {
return b.value - a.value
} else {
return aLocked ? -1 : 1
}
})
return {
fbOutputs,
}
Expand Down

0 comments on commit 846cee6

Please sign in to comment.