mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-08-11 08:59:18 +00:00
Navigation and auth fixes
This commit is contained in:
@@ -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
|
||||
|
||||
+17
-5
@@ -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 (
|
||||
<ErrorBoundary catchErrors={Config.catchErrors}>
|
||||
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
|
||||
<Text text={displayName} style={$title} />
|
||||
<Image source={require('../android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png')} />
|
||||
</View>
|
||||
</ErrorBoundary>
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -45,7 +45,7 @@ export enum ReceiveOption {
|
||||
}
|
||||
|
||||
type Props = StaticScreenProps<{
|
||||
encodedToken?: string
|
||||
encodedToken?: string
|
||||
}>
|
||||
|
||||
export const ReceiveScreen = observer(function ReceiveScreen({ route }: Props) {
|
||||
|
||||
@@ -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)}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
<View style={{backgroundColor: headerBg, marginTop: -spacing.small}}>
|
||||
<View style={{width: routes.length * tabWidth, alignSelf: 'center', backgroundColor: headerBg}}>
|
||||
<TabBar
|
||||
{...props}
|
||||
{...props}
|
||||
tabStyle={{width: tabWidth}}
|
||||
renderTabBarItem={({ route }) => (
|
||||
<CurrencySign
|
||||
|
||||
@@ -5,9 +5,10 @@ import { log } from './logService'
|
||||
import { CashuUtils } from './cashu/cashuUtils'
|
||||
import { LightningUtils } from './lightning/lightningUtils'
|
||||
import { LnurlUtils } from './lnurl/lnurlUtils'
|
||||
import { LnurlClient } from './lnurlService'
|
||||
import { LNURLPayParams, LnurlClient } from './lnurlService'
|
||||
import { MintUnit } from './wallet/currency'
|
||||
import { RootNavigation } from '../navigation'
|
||||
import { NavigationProp } from '@react-navigation/native'
|
||||
|
||||
export enum IncomingDataType {
|
||||
CASHU = 'CASHU',
|
||||
@@ -157,18 +158,17 @@ const navigateWithIncomingData = async function (
|
||||
incoming: {
|
||||
type: IncomingDataType,
|
||||
encoded: any
|
||||
},
|
||||
unit: MintUnit,
|
||||
},
|
||||
navigation: Omit<NavigationProp<ReactNavigation.RootParamList>, "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
|
||||
|
||||
Reference in New Issue
Block a user