Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix send ecash over contacts screen #211

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/screens/Payment/SelectMint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Screen from '@comps/Screen'
import Separator from '@comps/Separator'
import Txt from '@comps/Txt'
import { _testmintUrl } from '@consts'
import { l } from '@log'
import type { IMintBalWithName } from '@model'
import type { TSelectMintPageProps } from '@model/nav'
import { usePromptContext } from '@src/context/Prompt'
Expand Down Expand Up @@ -59,6 +60,7 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
openPromptAutoClose({ msg: t('noFundsForFee', { ns: NS.common, fee: estFee }), ms: 4000 })
return
}
l('user has scanned an invoice, navigate to payment overview')
navigation.navigate('coinSelection', {
mint,
balance: mint.amount,
Expand All @@ -69,12 +71,25 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
})
return
}
// choose a target for a lightning payment
// choose a target for a payment
if (isMelt || isSendEcash) {
// get remaining mints for a possible multimint swap
const remainingMints = userMints
.filter(m => m.mintUrl !== mint.mintUrl && m.mintUrl !== _testmintUrl)
.map(m => ({ mintUrl: m.mintUrl, customName: m.customName }))
// user has already selected a nostr target
if (nostr) {
l('user has already selected a nostr target, navigate to amount selection')
// select ecash amount to send
navigation.navigate('selectAmount', {
mint,
nostr,
balance: mint.amount,
isSendEcash
})
return
}
l('user wants to send payment, navigate to target selection')
navigation.navigate('selectTarget', {
mint,
balance: mint.amount,
Expand All @@ -84,14 +99,15 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
})
return
}
// select ecash amount to send
l('[last condition] navigate to amount selection')
navigation.navigate('selectAmount', {
mint,
nostr,
balance: mint.amount,
isSendEcash
})
}

// Show user mints with balances and default mint icon
useEffect(() => {
void (async () => {
Expand All @@ -105,6 +121,7 @@ export default function SelectMintScreen({ navigation, route }: TSelectMintPageP
setDefaultM(await getDefaultMint() ?? '')
})()
}, [mints, mintsWithBal])

return (
<Screen
screenName={t(getScreenName(), { ns: NS.common })}
Expand Down
Loading