Skip to content

Commit

Permalink
Merge branch 'main' into preview
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 committed Sep 5, 2023
2 parents de56e3d + 2c1b48b commit a84accb
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 102 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/eas_preview.yml

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<h2>eNuts – A Cashu wallet for Android and iOS</h2>
<div style="display: flex; align-items: center; justify-content: center">

[![Website eNuts](https://img.shields.io/badge/Website-eNuts-%230088cc?style=plastic&logo=WebMoney&logoColor=white&labelColor=%23666&color=%235DB075)](https://www.enuts.cash)
[![codecov](https://codecov.io/gh/cashubtc/eNuts/branch/main/graph/badge.svg?token=MGBC95KGHQ)](https://codecov.io/gh/cashubtc/eNuts)
![example workflow](https://github.com/cashubtc/eNuts/actions/workflows/node.js.yml/badge.svg)
![ts](https://badgen.net/badge/Built%20with/TypeScript/blue)
Expand All @@ -18,7 +19,7 @@
## 🐿️ Join the research and development groups

[![Cashu R&D](https://img.shields.io/badge/Cashu_R&D-Telegram-0088cc.svg)](https://t.me/CashuBTC)
[![Cashu R&D](https://img.shields.io/badge/eNuts_R&D-Telegram-0088cc.svg)](https://t.me/eNutsWallet)
[![eNuts R&D](https://img.shields.io/badge/eNuts_R&D-Telegram-0088cc.svg)](https://t.me/eNutsWallet)

## Contents

Expand Down
3 changes: 2 additions & 1 deletion assets/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@
"next": "Weiter",
"donateLn": "Spenden über Lightning",
"supportDev": "Zap die Entwicklung",
"supportHint": "Jeder Beitrag, ganz gleich in welcher Höhe, hat eine bedeutende Auswirkung. (Die eNuts Bestätigungsseite befindet sich in der Entwicklung)"
"supportHint": "Jeder Beitrag, ganz gleich in welcher Höhe, hat eine bedeutende Auswirkung. Die Zap Bestätigungsseite befindet sich in der Entwicklung",
"newToken": "Neuer Cashu Token"
},
"error": {
"addAllMintIdsErr": "Fehler beim Abrufen der Schlüsselsatz-IDs von Mint",
Expand Down
5 changes: 3 additions & 2 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"scanTokenOrLn": "Scan Cashu token or Lightning invoice",
"scanLn": "Scan Lightning invoice",
"scan": "Scan",
"enutsBeta": "eNuts is beta software &#8594;",
"enutsBeta": "eNuts is beta software",
"seconds": "seconds",
"selectAmount": "Select amount",
"selected": "Selected",
Expand Down Expand Up @@ -214,7 +214,8 @@
"next": "Next",
"donateLn": "Donate via Lightning",
"supportDev": "Zap the devs",
"supportHint": "Every contribution, no matter the size, makes a significant impact. (eNuts confirmation screen is under development)"
"supportHint": "Every contribution, no matter the size, makes a significant impact. Zap confirmation screen is under development",
"newToken": "New Cashu token"
},
"error": {
"addAllMintIdsErr": "Error while getting keyset ids from mint",
Expand Down
3 changes: 2 additions & 1 deletion assets/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@
"next": "Suivant",
"donateLn": "Faire un don via Lightning",
"supportDev": "Zap le développement",
"supportHint": "Chaque contribution, quelle que soit sa taille, a un impact significatif. (L'écran de confirmation eNuts est en cours de développement)"
"supportHint": "Chaque contribution, quelle que soit sa taille, a un impact significatif. L'écran de confirmation est en cours de développement",
"newToken": "Nouveau Cashu Token"
},
"error": {
"addAllMintIdsErr": "Erreur lors de l'obtention de l'ensemble de clés de la mint",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
"blind-signatures",
"lightning-network"
],
"version": "0.0.1-beta",
"version": "0.0.2",
"license": "AGPL-3.0-only",
"bugs": {
"url": "https://github.com/cashubtc/eNuts/issues"
Expand Down
45 changes: 33 additions & 12 deletions src/components/Balance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EcashIcon, SwapCurrencyIcon, ZapIcon } from '@comps/Icons'
import { ChevronRightIcon, EcashIcon, HistoryIcon, SwapCurrencyIcon, ZapIcon } from '@comps/Icons'
import { setPreferences } from '@db'
import type { IHistoryEntry } from '@model'
import type { RootStackParamList } from '@model/nav'
Expand Down Expand Up @@ -82,8 +82,14 @@ export default function Balance({ balance, nav }: IBalanceProps) {
</TouchableOpacity>
}
<Separator style={[styles.separator]} />
{/* No transactions yet */}
{!history.length &&
<View style={{ padding: 10 }}>
<Txt txt={t('noTX')} styles={[globals(color).pressTxt, { color: mainColors.WHITE }]} />
</View>
}
{/* latest 3 history entries */}
{history.length && !hidden.txs ?
{history.length > 0 && !hidden.txs ?
history.map(h => (
<HistoryEntry
key={h.timestamp}
Expand All @@ -99,19 +105,24 @@ export default function Balance({ balance, nav }: IBalanceProps) {
/>
))
:
!hidden.txs ?
<View style={{ padding: 10 }}>
<Txt txt={t('noTX')} styles={[globals(color).pressTxt, { color: mainColors.WHITE }]} />
</View>
hidden.txs ?
<>
<TouchableOpacity
style={styles.boardEntry}
onPress={() => nav?.navigate('history')}
>
<View style={styles.hiddenTxtWrap}>
<View style={styles.iconWrap}>
<HistoryIcon color={mainColors.WHITE} />
</View>
<Txt txt={t('hiddenTxs')} styles={[{ color: mainColors.WHITE }]} />
</View>
<ChevronRightIcon color={mainColors.WHITE} />
</TouchableOpacity>
</>
:
null
}
{hidden.txs &&
<Txt
txt={t('hiddenTxs')}
styles={[globals(color).pressTxt, { color: mainColors.WHITE, marginVertical: 50 }]}
/>
}
{history.length === 3 && !hidden.txs &&
<TxtButton
txt={t('seeFullHistory')}
Expand Down Expand Up @@ -193,6 +204,12 @@ const styles = StyleSheet.create({
minWidth: 45,
paddingTop: 3,
},
boardEntry: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginVertical: 10,
},
entry: {
flexDirection: 'row',
alignItems: 'center',
Expand All @@ -203,4 +220,8 @@ const styles = StyleSheet.create({
flexDirection: 'row',
alignItems: 'center',
},
hiddenTxtWrap: {
flexDirection: 'row',
alignItems: 'center',
},
})
3 changes: 3 additions & 0 deletions src/consts/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { IExpoConfig } from '@model'
import { default as Consts, ExecutionEnvironment as ExecEnv } from 'expo-constants'
import { Platform } from 'react-native'

import { version } from '../../package.json'

const { executionEnvironment: execEnv } = Consts
// `true` when running in Expo Go.
const isExpoDev = execEnv && ExecEnv?.StoreClient && execEnv === ExecEnv?.StoreClient
Expand Down Expand Up @@ -67,3 +69,4 @@ export const isTestMode = (typeof __TEST__ === 'boolean' && __TEST__)
|| process?.env?.NODE_ENV === 'test' || config?.extra?.NODE_ENV === 'test'

export const isIOS = Platform.OS === 'ios'
export const appVersion = `eNuts v${version}-beta`
1 change: 1 addition & 0 deletions src/model/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type RootStackParamList = {
disclaimer: undefined
history: undefined
mints: {
defaultMint?: boolean
newMint?: boolean
} | undefined
Settings: undefined
Expand Down
4 changes: 4 additions & 0 deletions src/screens/Addressbook/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import { StyleSheet, Text, View } from 'react-native'
import ContactPreview from './ContactPreview'
import UserProfile from './UserProfile'

/****************************************************************************/
/* State issues will occur while debugging Android and IOS at the same time */
/****************************************************************************/

const marginBottom = isIOS ? 100 : 75
const marginBottomPayment = isIOS ? 25 : 0

Expand Down
36 changes: 22 additions & 14 deletions src/screens/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Balance from '@comps/Balance'
import { IconBtn } from '@comps/Button'
import useLoading from '@comps/hooks/Loading'
import useCashuToken from '@comps/hooks/Token'
import { AboutIcon, ChevronRightIcon, ReceiveIcon, ScanQRIcon, SendIcon } from '@comps/Icons'
import { AboutIcon, ChevronRightIcon, PlusIcon, ReceiveIcon, ScanQRIcon, SendIcon } from '@comps/Icons'
import InitialModal from '@comps/InitialModal'
import Txt from '@comps/Txt'
import { _testmintUrl } from '@consts'
Expand All @@ -24,7 +24,7 @@ import { STORE_KEYS } from '@store/consts'
import { addToHistory } from '@store/latestHistoryEntries'
import { getCustomMintNames, saveDefaultOnInit } from '@store/mintStore'
import { highlight as hi, mainColors } from '@styles'
import { getStrFromClipboard, hasTrustedMint, isCashuToken } from '@util'
import { getStrFromClipboard, hasTrustedMint, isCashuToken, isErr } from '@util'
import { claimToken } from '@wallet'
import { getTokenInfo } from '@wallet/proofs'
import { useEffect, useState } from 'react'
Expand Down Expand Up @@ -85,11 +85,17 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
const handleMintModal = async (forEnutsMint = false) => {
setModal({ ...modal, mint: false })
await store.set(STORE_KEYS.explainer, '1')
navigation.navigate('mints', { newMint: forEnutsMint })
navigation.navigate('mints', { defaultMint: forEnutsMint, newMint: !forEnutsMint })
}

const handleEnutsMint = async () => {
await saveDefaultOnInit()
try {
await saveDefaultOnInit()
} catch (e) {
openPromptAutoClose({ msg: isErr(e) ? e.message : t('smthWrong') })
await handleMintModal(false)
return
}
await handleMintModal(true)
}

Expand Down Expand Up @@ -256,20 +262,22 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
{/* Balance, Disclaimer & History */}
<Balance balance={balance} nav={navigation} />
{/* Receive/send/mints buttons */}
<View style={[styles.actionWrap, { paddingHorizontal: !hasMint || balance < 1 ? 75 : 30 }]}>
{(hasMint && balance > 0) &&
<View style={[styles.actionWrap, { paddingHorizontal: 30 }]}>
{/* Send button or add first mint */}
{(hasMint && balance > 0) ?
<ActionBtn
icon={
<SendIcon
width={32}
height={32}
color={hi[highlight]}
/>
}
icon={<SendIcon width={32} height={32} color={hi[highlight]} />}
txt={t('send', { ns: NS.wallet })}
color={hi[highlight]}
onPress={() => setModal({ ...modal, sendOpts: true })}
/>
:
<ActionBtn
icon={<PlusIcon width={36} height={36} color={hi[highlight]} />}
txt='Mint'
color={hi[highlight]}
onPress={() => setModal({ ...modal, mint: true })}
/>
}
<ActionBtn
icon={<ScanQRIcon width={32} height={32} color={hi[highlight]} />}
Expand All @@ -284,7 +292,7 @@ export default function Dashboard({ navigation, route }: TDashboardPageProps) {
onPress={() => setModal({ ...modal, receiveOpts: true })}
/>
</View>
{/* scan QR */}
{/* beta warning */}
<View style={styles.hintWrap}>
<TouchableOpacity
onPress={() => navigation.navigate('disclaimer')}
Expand Down
44 changes: 26 additions & 18 deletions src/screens/Mints/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,28 +129,37 @@ export default function Mints({ navigation, route }: TMintsPageProps) {
await handleMintInput(clipboard || '')
}

const handleInitialRender = async () => {
// user comes from dashboard and wants to add his own mint url, open prompt
if (route.params?.newMint) {
// timeout is needed on IOS only when different prompts are called synchronously
const t = setTimeout(() => {
setNewMintModal(true)
clearTimeout(t)
}, 200)
return
}
await handleMintsState()
const defaultt = await getDefaultMint()
setDefaultM(defaultt ?? '')
// this is the case when user adds the initial default mint
if (route.params?.defaultMint) {
// ask to mint new token
openTopUpModal()
}
}

// Show user mints with balances and default mint icon
useEffect(() => {
void (async () => {
await handleMintsState()
setDefaultM(await getDefaultMint() ?? '')
if (route.params?.newMint) {
openTopUpModal()
}
})()
void handleInitialRender()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

// get mints balances and default mint after navigating to this page
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const focusHandler = navigation.addListener('focus', async () => {
await handleMintsState()
const defaultt = await getDefaultMint()
setDefaultM(defaultt ?? '')
if (route.params?.newMint) {
openTopUpModal()
}
await handleInitialRender()
})
return focusHandler
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -269,12 +278,11 @@ export default function Mints({ navigation, route }: TMintsPageProps) {
topBtnTxt={t('yes')}
topBtnAction={() => {
setTopUpModal(false)
if (!selectedMint) {
openPromptAutoClose({ msg: '' })
return
}
l({ selectedMint })
navigation.navigate('selectAmount', {
mint: selectedMint,
// either for initial default mint (selectedMint->undefined & userMints.length == 1 (user has only the 1 initial mint))
// or mint via input (selectedMint->defined)
mint: !selectedMint ? { mintUrl: usertMints[0].mintUrl, customName: usertMints[0].customName } : selectedMint,
balance: 0,
})
}}
Expand Down
4 changes: 3 additions & 1 deletion src/screens/Payment/Send/EncodedToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export default function EncodedTokenPage({ navigation, route }: TEncodedTokenPag
<View style={[globals(color).container, styles.container, { paddingBottom: isIOS ? 50 : 20 }]}>
<TopNav
withBackBtn
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
screenName={`${t('newToken')} 🥜🐿️`}
handlePress={() => navigation.navigate('dashboard')}
/>
{/* The amount of the created token */}
Expand Down Expand Up @@ -96,7 +98,7 @@ const styles = StyleSheet.create({
},
qrWrap: {
alignItems: 'center',
marginTop: 75,
marginTop: 90,
},
tokenAmount: {
fontSize: 36,
Expand Down
Loading

0 comments on commit a84accb

Please sign in to comment.