Skip to content

Commit

Permalink
fix: sync with master
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Jul 26, 2023
2 parents e392e01 + d9b3e13 commit bf542f2
Show file tree
Hide file tree
Showing 109 changed files with 1,309 additions and 793 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DerivedData
*.ipa
*.xcuserstate
ios/.xcode.env.local
IDEWorkspaceChecks.plist

# Android/IntelliJ
#
Expand Down
10 changes: 5 additions & 5 deletions __tests__/fiat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getWalletStore } from '../src/store/helpers';
import { updateExchangeRates } from '../src/store/actions/wallet';
import { getDisplayValues } from '../src/utils/displayValues';
import { resetExchangeRates } from '../src/store/actions/wallet';
import { EBitcoinUnit } from '../src/store/types/wallet';
import { EUnit } from '../src/store/types/wallet';

global.fetch = require('node-fetch');

Expand All @@ -15,7 +15,7 @@ describe('Pulls latest fiat exchange rates and checks the wallet store for valid
it('handles missing exchange rate by returning the correct fiat fallback', () => {
const dv = getDisplayValues({
satoshis: 1010101,
bitcoinUnit: EBitcoinUnit.BTC,
unit: EUnit.BTC,
});

// expected fiat fallback
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Pulls latest fiat exchange rates and checks the wallet store for valid
satoshis: 1010101,
exchangeRate: 100000,
currency: 'USD',
bitcoinUnit: EBitcoinUnit.BTC,
unit: EUnit.BTC,
locale: 'en-US',
});

Expand All @@ -89,7 +89,7 @@ describe('Pulls latest fiat exchange rates and checks the wallet store for valid
exchangeRate: 100000,
currency: 'RUB',
currencySymbol: '₽',
bitcoinUnit: EBitcoinUnit.satoshi,
unit: EUnit.satoshi,
locale: 'en-US',
});

Expand All @@ -109,7 +109,7 @@ describe('Pulls latest fiat exchange rates and checks the wallet store for valid
it('Can convert small amount of sats without scientific notation', () => {
const dv = getDisplayValues({
satoshis: 10,
bitcoinUnit: EBitcoinUnit.BTC,
unit: EUnit.BTC,
});

expect(dv.bitcoinFormatted).toBe('0.0000001');
Expand Down
Binary file added android/app/src/main/res/drawable/recovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="android:navigationBarColor">#000000</item>
<item name="android:windowBackground">@color/black</item>
<item name="android:navigationBarColor">@color/black</item>
</style>

<style name="AppTheme.Launcher">
Expand Down
6 changes: 3 additions & 3 deletions e2e/channels.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ d('LN Channel Onboarding', () => {
// should show 80% limit note
await element(by.id('SliderHandle')).swipe('right', 'slow', NaN, 0.8);
await expect(element(by.id('QuickSetupReserveNote'))).toBeVisible();
await element(by.id('QuickSetupNumberField')).tap();
await element(by.id('QuickSetupCustomAmount')).tap();
await element(by.id('NumberPadButtonsMax')).tap();
await element(by.id('NumberPadButtonsDone')).tap();
await expect(element(by.id('QuickSetupReserveNote'))).toBeVisible();
Expand All @@ -113,14 +113,14 @@ d('LN Channel Onboarding', () => {
// should show Blocktank limit note
await element(by.id('SliderHandle')).swipe('right', 'slow', NaN, 0.8);
await expect(element(by.id('QuickSetupBlocktankNote'))).toBeVisible();
await element(by.id('QuickSetupNumberField')).tap();
await element(by.id('QuickSetupCustomAmount')).tap();
await element(by.id('NumberPadButtonsMax')).tap();
await element(by.id('NumberPadButtonsDone')).tap();
await expect(element(by.id('QuickSetupBlocktankNote'))).toBeVisible();

// NumberPad
await element(by.id('SliderHandle')).swipe('left');
await element(by.id('QuickSetupNumberField')).tap();
await element(by.id('QuickSetupCustomAmount')).tap();
await element(by.id('N2').withAncestor(by.id('QuickSetup'))).tap();
await element(by.id('N0').withAncestor(by.id('QuickSetup'))).multiTap(5);
await element(by.id('NumberPadButtonsDone')).tap();
Expand Down
29 changes: 0 additions & 29 deletions e2e/newWallet.e2e.js

This file was deleted.

1 change: 0 additions & 1 deletion e2e/settings.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ d('Settings', () => {
await element(by.id('DisplaySuggestions')).tap();
await element(by.id('ResetSuggestions')).tap();
await element(by.id('DialogConfirm')).tap();
await element(by.id('NavigationClose')).tap();

// backupSeedPhrase should be visible again
await expect(element(by.id('Suggestion-backupSeedPhrase'))).toBeVisible();
Expand Down
6 changes: 6 additions & 0 deletions ios/bitkit/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import <React/RCTBundleURLProvider.h>
#import <React/RCTLinkingManager.h>
#import <React/RCTRootView.h>
#import "RNQuickActionManager.h"

@implementation AppDelegate

Expand Down Expand Up @@ -42,4 +43,9 @@ - (BOOL)application:(UIApplication *)application
return [RCTLinkingManager application:application openURL:url options:options];
}

// Quick action
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {
[RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];
}

@end
23 changes: 23 additions & 0 deletions ios/bitkit/Images.xcassets/recovery.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "recovery.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "recovery 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "recovery 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@shopify/react-native-skia": "0.1.197",
"@synonymdev/blocktank-client": "0.0.50",
"@synonymdev/react-native-ldk": "^0.0.102",
"@synonymdev/react-native-lnurl": "0.0.4",
"@synonymdev/react-native-lnurl": "0.0.5",
"@synonymdev/result": "0.0.2",
"@synonymdev/slashtags-auth": "^1.0.0-alpha.5",
"@synonymdev/slashtags-sdk": "1.0.0-alpha.38",
Expand Down Expand Up @@ -115,6 +115,7 @@
"react-native-modal": "^13.0.1",
"react-native-permissions": "^3.7.3",
"react-native-qrcode-svg": "^6.2.0",
"react-native-quick-actions": "^0.3.13",
"react-native-randombytes": "^3.6.1",
"react-native-rate": "^1.2.12",
"react-native-reanimated": "^3.3.0",
Expand Down
62 changes: 28 additions & 34 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ import React, {
useCallback,
useState,
} from 'react';
import { Platform, NativeModules, StyleSheet } from 'react-native';
import { Platform, NativeModules } from 'react-native';
import { useSelector } from 'react-redux';
import Toast from 'react-native-toast-message';
import QuickActions from 'react-native-quick-actions';
import { ThemeProvider } from 'styled-components/native';

import { SafeAreaProvider, StatusBar, View } from './styles/components';
import { SafeAreaProvider, StatusBar } from './styles/components';
import { getTheme } from './styles/themes';
import OnboardingNavigator from './navigation/onboarding/OnboardingNavigator';
import { SlashtagsProvider } from './components/SlashtagsProvider';
import TwoFingerPressable from './components/TwoFingerPressable';
import { toastConfig } from './components/Toast';
import RecoveryNavigator from './screens/Recovery/RecoveryNavigator';
import RestoringScreen from './screens/Onboarding/Restoring';
import AppUpdate from './screens/AppUpdate';
import AppOnboarded from './AppOnboarded';

import './utils/i18n';
import './utils/quick-actions';
import { checkForAppUpdate } from './store/actions/ui';
import { RECOVERY_DELAY } from './utils/startup/constants';
import { themeSelector } from './store/reselect/settings';
import { walletExistsSelector } from './store/reselect/wallet';
import { requiresRemoteRestoreSelector } from './store/reselect/user';
import { availableUpdateSelector } from './store/reselect/ui';
import { criticalUpdateSelector } from './store/reselect/ui';

const App = (): ReactElement => {
const [isListening, setIsListening] = useState(true);
const [isReady, setIsReady] = useState(false);
const [showRecovery, setShowRecovery] = useState(false);
const theme = useSelector(themeSelector);
const walletExists = useSelector(walletExistsSelector);
const updateInfo = useSelector(availableUpdateSelector);
const hasCriticalUpdate = useSelector(criticalUpdateSelector);
const requiresRemoteRestore = useSelector(requiresRemoteRestoreSelector);

// on App start
Expand All @@ -45,26 +45,29 @@ const App = (): ReactElement => {
setTimeout(NativeModules.SplashScreenModule.hide, 100);
}

// check for Bitkit update
checkForAppUpdate();
const checkForRecovery = async (): Promise<void> => {
const action = await QuickActions.popInitialAction();
if (action?.title === 'Recovery') {
setShowRecovery(true);
}

setIsReady(true);
};

// Tap twice anywhere in the first 500ms of startup to enter recovery
setTimeout((): void => setIsListening(false), RECOVERY_DELAY);
checkForRecovery();
checkForAppUpdate();
}, []);

const onTwoFingerPress = useCallback(() => {
if (isListening) {
setShowRecovery(true);
setIsListening(false);
const RootComponent = useCallback((): ReactElement => {
if (!isReady) {
return <></>;
}
}, [isListening]);

const RootComponent = useCallback((): ReactElement => {
if (showRecovery) {
return <RecoveryNavigator />;
}

if (updateInfo?.critical) {
if (hasCriticalUpdate) {
return <AppUpdate />;
}

Expand All @@ -77,34 +80,25 @@ const App = (): ReactElement => {
}

return <OnboardingNavigator />;
}, [showRecovery, updateInfo?.critical, walletExists, requiresRemoteRestore]);
}, [
isReady,
showRecovery,
hasCriticalUpdate,
walletExists,
requiresRemoteRestore,
]);

const currentTheme = useMemo(() => getTheme(theme), [theme]);

return (
<ThemeProvider theme={currentTheme}>
<SafeAreaProvider>
<StatusBar />
<TwoFingerPressable onGesture={onTwoFingerPress}>
<View style={[styles.tapListener, !isListening && styles.hide]} />
</TwoFingerPressable>
<RootComponent />
<Toast config={toastConfig} />
</SafeAreaProvider>
</ThemeProvider>
);
};

const styles = StyleSheet.create({
tapListener: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'transparent',
flex: 1,
zIndex: 1,
},
hide: {
zIndex: -1,
},
});

export default memo(App);
7 changes: 1 addition & 6 deletions src/AppOnboarded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useTranslation } from 'react-i18next';
import RootNavigator from './navigation/root/RootNavigator';
import InactivityTracker from './components/InactivityTracker';
import { startWalletServices } from './utils/startup';
import { RECOVERY_DELAY } from './utils/startup/constants';
import { electrumConnection } from './utils/electrum';
import { unsubscribeFromLightningSubscriptions } from './utils/lightning';
import i18n from './utils/i18n';
Expand Down Expand Up @@ -55,16 +54,12 @@ const AppOnboarded = (): ReactElement => {

// on App start
useEffect(() => {
// Delay service startup to make time for entering recovery
const timerId = setTimeout(() => {
startWalletServices({ selectedNetwork, selectedWallet });
}, RECOVERY_DELAY);
startWalletServices({ selectedNetwork, selectedWallet });

const needsAuth = pin && pinOnLaunch;
updateUi({ isAuthenticated: !needsAuth });

return () => {
clearTimeout(timerId);
unsubscribeFromLightningSubscriptions();
};
// onMount
Expand Down
20 changes: 10 additions & 10 deletions src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ enableScreens(true);
enableFreeze(true);

const Root = (): ReactElement => {
const content = (
<Provider store={store}>
<PersistGate
loading={<View style={styles.container} />}
persistor={persistor}>
<App />
</PersistGate>
</Provider>
return (
<ErrorBoundary>
<Provider store={store}>
<PersistGate
loading={<View style={styles.container} />}
persistor={persistor}>
<App />
</PersistGate>
</Provider>
</ErrorBoundary>
);

return <ErrorBoundary>{content}</ErrorBoundary>;
};

const styles = StyleSheet.create({
Expand Down
1 change: 0 additions & 1 deletion src/assets/animations/boost.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/assets/icons/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const chevronRightIcon = (
color = 'white',
): string => `<svg width="7" height="12" viewBox="0 0 7 12" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.822528 0C0.357621 0 0 0.347721 0 0.81135C0 1.04316 0.0983458 1.23932 0.241394 1.39089L5.00626 6L0.241394 10.6091C0.0983458 10.7607 0 10.9658 0 11.1886C0 11.6523 0.357621 12 0.822528 12C1.05498 12 1.25167 11.9198 1.40366 11.7682L6.74967 6.58845C6.91954 6.42797 7 6.2229 7 6C7 5.7771 6.91954 5.58095 6.74967 5.41155L1.40366 0.24073C1.25167 0.0802431 1.05498 0 0.822528 0Z" fill="${color}"/>
): string => `<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M11.2929 6.29289C11.6834 5.90237 12.3166 5.90237 12.7071 6.29289L21.7071 15.2929C22.0976 15.6834 22.0976 16.3166 21.7071 16.7071L12.7071 25.7071C12.3166 26.0976 11.6834 26.0976 11.2929 25.7071C10.9024 25.3166 10.9024 24.6834 11.2929 24.2929L19.5858 16L11.2929 7.70711C10.9024 7.31658 10.9024 6.68342 11.2929 6.29289Z" fill="${color}"/>
</svg>
`;

Expand Down
Loading

0 comments on commit bf542f2

Please sign in to comment.