diff --git a/android/app/build.gradle b/android/app/build.gradle index 6d7e82a..28de5af 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -95,7 +95,7 @@ android { applicationId "com.minibits_wallet" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 58020 + versionCode 58022 versionName "0.2.0" } @@ -176,6 +176,15 @@ dependencies { } else { implementation jscFlavor } + + // Fetch request hang issue + // define a BOM and its version + implementation(platform("com.squareup.okhttp3:okhttp-bom:5.0.0-alpha.12")) + + // define any required OkHttp artifacts without version + implementation("com.squareup.okhttp3:okhttp") + implementation("com.squareup.okhttp3:logging-interceptor") + implementation("com.squareup.okhttp3:okhttp-urlconnection") } // code-push diff --git a/src/App.tsx b/src/App.tsx index 1a28cd9..07520fd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useState } from 'react' import * as Sentry from '@sentry/react-native' import { APP_ENV, @@ -26,7 +26,10 @@ import Config from './config' import {log} from './services' import {Env} from './utils/envtypes' import AppError from './utils/AppError' -import { Image, View } from 'react-native' +import { Image, TextStyle, View } from 'react-native' +import { spacing, typography } from './theme' +import { displayName } from '../app.json' +import { Text } from './components/Text' /* Set default size ratio for styling */ setSizeMattersBaseWidth(375) @@ -49,10 +52,10 @@ if (!__DEV__) { }) } - function App() { - const {userSettingsStore, relaysStore} = useStores() + const {userSettingsStore, relaysStore} = useStores() + const [isAuthenticated, setIsAuthenticated] = useState(false) const {rehydrated} = useInitialRootStore(async() => { log.trace('[useInitialRootStore]', 'Root store rehydrated') @@ -63,6 +66,7 @@ function App() { if(userSettingsStore.isAuthOn) { try { const authToken = await KeyChain.getOrCreateAuthToken(userSettingsStore.isAuthOn) + setIsAuthenticated(true) log.trace('[useInitialRootStore]', {authToken}) } catch (e: any) { log.warn('[useInitialRootStore]', 'Authentication failed', {message: e.message}) @@ -92,10 +96,11 @@ function App() { - if (!rehydrated) { + if (!rehydrated || !isAuthenticated) { return ( + @@ -112,6 +117,13 @@ function App() { ) } +const $title: TextStyle = { + textAlign: "center", + fontFamily: typography.logo.normal, + fontSize: spacing.large, + color: 'white' +} + const deploymentKey = APP_ENV === Env.PROD ? CODEPUSH_PRODUCTION_DEPLOYMENT_KEY : CODEPUSH_STAGING_DEPLOYMENT_KEY const codePushOptions = { deploymentKey, checkFrequency: codePush.CheckFrequency.MANUAL } export default codePush(codePushOptions)(App) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 6def581..000fc4a 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -18,7 +18,7 @@ import { displayName as appName } from '../../app.json' import { ExtendedEdge, useSafeAreaInsetsStyle } from "../utils/useSafeAreaInsetsStyle" import { Icon, IconTypes } from "./Icon" import { Text, TextProps } from "./Text" -import { verticalScale } from "@gocodingnow/rn-size-matters" + export interface HeaderProps { /** @@ -187,7 +187,7 @@ export function Header(props: HeaderProps) { rightTxOptions, safeAreaEdges = ["top"], TitleActionComponent, - title= appName, + title = appName, titleMode = "center", titleTx, titleTxOptions, diff --git a/src/screens/ContactDetailScreen.tsx b/src/screens/ContactDetailScreen.tsx index c2c464b..823f6f4 100644 --- a/src/screens/ContactDetailScreen.tsx +++ b/src/screens/ContactDetailScreen.tsx @@ -75,7 +75,9 @@ export const ContactDetailScreen = observer(function ({ route }: Props) { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL_ADDRESS, encoded: contact.lud16 - }, userSettingsStore.preferredUnit) + }, + navigation, + userSettingsStore.preferredUnit) return } catch (e: any) { diff --git a/src/screens/Contacts/PrivateContacts.tsx b/src/screens/Contacts/PrivateContacts.tsx index d829b77..702d8e2 100644 --- a/src/screens/Contacts/PrivateContacts.tsx +++ b/src/screens/Contacts/PrivateContacts.tsx @@ -208,7 +208,7 @@ export const PrivateContacts = observer(function (props: { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL_ADDRESS, encoded: contact.lud16 - }, userSettingsStore.preferredUnit) + }, navigation, userSettingsStore.preferredUnit) //reset navigation.setParams({ diff --git a/src/screens/Contacts/PublicContacts.tsx b/src/screens/Contacts/PublicContacts.tsx index edf68cd..f130c3d 100644 --- a/src/screens/Contacts/PublicContacts.tsx +++ b/src/screens/Contacts/PublicContacts.tsx @@ -390,7 +390,7 @@ export const PublicContacts = observer(function (props: { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL_ADDRESS, encoded: contact.lud16 - }, userSettingsStore.preferredUnit) + }, navigation, userSettingsStore.preferredUnit) setIsLoading(false) diff --git a/src/screens/LightningPayScreen.tsx b/src/screens/LightningPayScreen.tsx index 1d49ff0..b69892c 100644 --- a/src/screens/LightningPayScreen.tsx +++ b/src/screens/LightningPayScreen.tsx @@ -123,15 +123,15 @@ export const LightningPayScreen = function LightningPayScreen({ route }: Props) log.trace('[onConfirm]', {mintUrl: mint?.mintUrl, unit, resultType: result.type}) if(result.type === IncomingDataType.INVOICE) { - return IncomingParser.navigateWithIncomingData(result, unit, mint && mint.mintUrl) + return IncomingParser.navigateWithIncomingData(result, navigation, unit, mint && mint.mintUrl) } if(result.type === IncomingDataType.LNURL) { - await IncomingParser.navigateWithIncomingData(result, unit, mint && mint.mintUrl) + await IncomingParser.navigateWithIncomingData(result, navigation, unit, mint && mint.mintUrl) } if(result.type === IncomingDataType.LNURL_ADDRESS) { - await IncomingParser.navigateWithIncomingData(result, unit, mint && mint.mintUrl) + await IncomingParser.navigateWithIncomingData(result, navigation, unit, mint && mint.mintUrl) } } catch (e: any) { diff --git a/src/screens/ReceiveScreen.tsx b/src/screens/ReceiveScreen.tsx index 5273185..23db588 100644 --- a/src/screens/ReceiveScreen.tsx +++ b/src/screens/ReceiveScreen.tsx @@ -45,7 +45,7 @@ export enum ReceiveOption { } type Props = StaticScreenProps<{ - encodedToken?: string + encodedToken?: string }> export const ReceiveScreen = observer(function ReceiveScreen({ route }: Props) { diff --git a/src/screens/ScanScreen.tsx b/src/screens/ScanScreen.tsx index 59fbbeb..768a37a 100644 --- a/src/screens/ScanScreen.tsx +++ b/src/screens/ScanScreen.tsx @@ -7,6 +7,7 @@ import { View, TextStyle, } from 'react-native' +// @ts-ignore import {Camera, CameraType} from 'react-native-camera-kit' import { URDecoder } from '@gandlaf21/bc-ur' import {spacing, typography, useThemeColor} from '../theme' @@ -134,7 +135,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { log.trace('TokenReceive') try { const tokenResult = IncomingParser.findAndExtract(incoming, IncomingDataType.CASHU) - return IncomingParser.navigateWithIncomingData(tokenResult, unit, mint && mint.mintUrl) + return IncomingParser.navigateWithIncomingData(tokenResult, navigation, unit, mint && mint.mintUrl) } catch (e: any) { const maybeLnurl = LnurlUtils.findEncodedLnurl(incoming) @@ -148,7 +149,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL, encoded: encodedLnurl - }, unit, mint && mint.mintUrl) + }, navigation, unit, mint && mint.mintUrl) } return } catch (e2: any) { @@ -165,7 +166,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { case 'LightningPay': try { const invoiceResult = IncomingParser.findAndExtract(incoming, IncomingDataType.INVOICE) - return IncomingParser.navigateWithIncomingData(invoiceResult, unit, mint && mint.mintUrl) + return IncomingParser.navigateWithIncomingData(invoiceResult, navigation, unit, mint && mint.mintUrl) } catch (e: any) { const maybeLnurlAddress = LnurlUtils.findEncodedLnurlAddress(incoming) @@ -179,7 +180,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL_ADDRESS, encoded: validAddress - }, unit, mint && mint.mintUrl) + }, navigation, unit, mint && mint.mintUrl) } return } catch (e3: any) { @@ -199,7 +200,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.LNURL, encoded: encodedLnurl - }, unit, mint && mint.mintUrl) + }, navigation, unit, mint && mint.mintUrl) } return } catch (e2: any) { @@ -219,7 +220,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { await IncomingParser.navigateWithIncomingData({ type: IncomingDataType.CASHU_PAYMENT_REQUEST, encoded: encodedPr - }, unit, mint && mint.mintUrl) + }, navigation, unit, mint && mint.mintUrl) } return } catch (e3: any) { @@ -236,7 +237,7 @@ export const ScanScreen = function ScanScreen({ route }: Props) { try { // generic scan button on wallet screen const incomingData = IncomingParser.findAndExtract(incoming) - return IncomingParser.navigateWithIncomingData(incomingData, unit, mint && mint.mintUrl) + return IncomingParser.navigateWithIncomingData(incomingData, navigation, unit, mint && mint.mintUrl) } catch (e: any) { e.name = Err.VALIDATION_ERROR e.params = {caller: 'onIncomingData', clipboard: incoming.slice(0, 100)} diff --git a/src/screens/TokenReceiveScreen.tsx b/src/screens/TokenReceiveScreen.tsx index 205d71d..aabdb03 100644 --- a/src/screens/TokenReceiveScreen.tsx +++ b/src/screens/TokenReceiveScreen.tsx @@ -109,7 +109,7 @@ export const TokenReceiveScreen = function TokenReceiveScreen({ route }: Props) try { const tokenResult = IncomingParser.findAndExtract(encodedToken, IncomingDataType.CASHU) - return IncomingParser.navigateWithIncomingData(tokenResult, unit, mint && mint.mintUrl) + return IncomingParser.navigateWithIncomingData(tokenResult, navigation, unit, mint && mint.mintUrl) } catch (e: any) { handleError(e) diff --git a/src/screens/WalletScreen.tsx b/src/screens/WalletScreen.tsx index 9c48814..4227719 100644 --- a/src/screens/WalletScreen.tsx +++ b/src/screens/WalletScreen.tsx @@ -91,7 +91,7 @@ export const WalletScreen = observer(function WalletScreen({ route }: Props) { const [routes] = useState( groupedMints.map((mintUnit) => ({ key: mintUnit.unit, - title: getCurrency(mintUnit.unit).code, + title: getCurrency(mintUnit.unit).code })) ) const [tabIndex, setTabIndex] = useState(0) @@ -242,7 +242,8 @@ export const WalletScreen = observer(function WalletScreen({ route }: Props) { const incomingData = IncomingParser.findAndExtract(url) await IncomingParser.navigateWithIncomingData( - incomingData, + incomingData, + navigation, currentUnit ) @@ -386,13 +387,17 @@ export const WalletScreen = observer(function WalletScreen({ route }: Props) { const gotoProfile = function () { // @ts-ignore - navigation.navigate('ContactsNavigator', {screen: 'Profile'}) + navigation.navigate('ContactsNavigator', { + screen: 'Profile' + }) } const gotoMintInfo = function (mintUrl: string) { - setIsMintsModalVisible(false) - navigation.navigate('MintInfo', { - mintUrl + setIsMintsModalVisible(false) + //@ts-ignore + navigation.navigate('SettingsNavigator', { + screen: 'MintInfo', + params: {mintUrl} }) } @@ -529,7 +534,7 @@ export const WalletScreen = observer(function WalletScreen({ route }: Props) { ( , "getState">, + unit: MintUnit, mintUrl?: string ) { - const navigation = RootNavigation + switch (incoming.type) { case IncomingDataType.CASHU: return navigation.navigate('Receive', { encodedToken: incoming.encoded, - unit, - mintUrl }) case IncomingDataType.CASHU_PAYMENT_REQUEST: @@ -223,7 +223,7 @@ const navigateWithIncomingData = async function ( const addressParamsResult = await LnurlClient.getLnurlAddressParams(incoming.encoded) // throws return navigation.navigate('Transfer', { - lnurlParams: addressParamsResult.lnurlParams, + lnurlParams: addressParamsResult.lnurlParams as LNURLPayParams, paymentOption: SendOption.LNURL_PAY, unit, mintUrl