Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/GoodDollar/GoodDAPP

  • Loading branch information...
sirpy committed Sep 8, 2019
2 parents 66d8abc + 657ba08 commit 872f9fc81faea1480b3cbec2408b24004341c21e
Showing with 2,559 additions and 142 deletions.
  1. +1 −0 .env.dev
  2. +1 −1 .env.test
  3. +56 −6 package-lock.json
  4. +1 −1 package.json
  5. +1 −1 src/App.js
  6. +42 −1 src/{RouterSelector.js → RouterSelector.web.js}
  7. +2 −1 src/SignupRouter.js
  8. +2 −2 src/components/appNavigation/__tests__/__snapshots__/AppNavigation.js.snap
  9. +2 −2 src/components/appSwitch/AppSwitch.js
  10. +14 −1 src/components/auth/Auth.js
  11. +6 −6 src/components/common/buttons/CustomButton.js
  12. +47 −0 src/components/common/buttons/ShareButton.js
  13. +2 −0 src/components/common/index.js
  14. +65 −45 src/components/common/modal/ModalActionsByFeedType.js
  15. +6 −21 src/components/dashboard/Confirmation.js
  16. +3 −1 src/components/dashboard/SendConfirmation.web.js
  17. +13 −16 src/components/dashboard/__tests__/GoodWallet.js
  18. +2 −2 src/components/dashboard/__tests__/__snapshots__/Dashboard.js.snap
  19. +3 −3 src/components/dashboard/__tests__/__util__/AdminWallet.js
  20. +19 −0 src/components/sidemenu/__tests__/SideMenuPanel.js
  21. +1,106 −0 src/components/sidemenu/__tests__/__snapshots__/SideMenuPanel.js.snap
  22. +16 −4 src/components/signin/Mnemonics.js
  23. +22 −7 src/components/signin/__tests__/__snapshots__/Mnemonics.js.snap
  24. +1 −1 src/components/signup/EmailForm.js
  25. +94 −0 src/components/signup/InvalidWeb3TokenError.js
  26. +124 −9 src/components/signup/SignupState.js
  27. +20 −0 src/components/signup/__tests__/InvalidWeb3TokenError.js
  28. +434 −0 src/components/signup/__tests__/__snapshots__/InvalidWeb3TokenError.js.snap
  29. +290 −0 src/components/signup/__tests__/__snapshots__/signUpWrapper.js.snap
  30. +20 −0 src/components/signup/__tests__/signUpWrapper.js
  31. +1 −0 src/config/config.js
  32. +70 −2 src/lib/API/api.js
  33. +66 −0 src/lib/gundb/UserStorageClass.js
  34. +5 −0 src/lib/gundb/__tests__/UserStorage.js
  35. +2 −9 src/lib/login/LoginService.js
@@ -11,3 +11,4 @@ REACT_APP_SKIP_EMAIL_VERIFICATION=true
REACT_APP_AMPLITUDE_API_KEY=
REACT_APP_ROLLBAR_API_KEY=
REACT_APP_THROW_SAVE_PROFILE_ERRORS=true
REACT_APP_WEB3_SITE_URL=https://w3.gooddollar.org
@@ -5,7 +5,7 @@ REACT_APP_GUN_PUBLIC_URL=http://localhost:8765/gun
REACT_APP_INFURA_KEY=
REACT_APP_NETWORK=fuse
REACT_APP_WEB3_RPC=
REACT_APP_WEB3_TRANSPORT_PROVIDER=WebSocket
REACT_APP_WEB3_TRANSPORT_PROVIDER=WebSocketProvider
REACT_APP_ZOOM_LICENSE_KEY=
REACT_APP_SKIP_EMAIL_VERIFICATION=true
REACT_APP_AMPLITUDE_API_KEY=

Some generated files are not rendered by default. Learn more.

@@ -61,7 +61,7 @@
"FormData": "^0.10.1",
"abi-decoder": "^1.2.0",
"await-mutex": "^1.0.2",
"axios": "^0.18.0",
"axios": "^0.19.0",
"bip39-light": "^1.0.7",
"ethereumjs-util": "^6.1.0",
"ethereumjs-wallet": "^0.6.3",
@@ -5,7 +5,7 @@ import { Platform, SafeAreaView, StyleSheet } from 'react-native'
import PaperProvider from 'react-native-paper/src/core/Provider'
import { theme } from './components/theme/styles'
import SimpleStore from './lib/undux/SimpleStore'
import RouterSelector from './RouterSelector'
import RouterSelector from './RouterSelector.web'
import { SimpleStoreDialog } from './components/common/dialogs/CustomDialog'
import LoadingIndicator from './components/common/view/LoadingIndicator'
import SplashDesktop from './components/splash/SplashDesktop'
@@ -1,5 +1,6 @@
import React, { useEffect } from 'react'
import { AsyncStorage } from 'react-native'
import bip39 from 'bip39-light'
import { DESTINATION_PATH } from './lib/constants/localStorage'
import SimpleStore from './lib/undux/SimpleStore'
import Splash from './components/splash/Splash'
@@ -11,8 +12,42 @@ const log = logger.child({ from: 'RouterSelector' })

// import Router from './SignupRouter'
let SignupRouter = React.lazy(() =>
Promise.all([delay(2000), import(/* webpackChunkName: "signuprouter" */ './SignupRouter')]).then(r => r[1])
Promise.all([
import(/* webpackChunkName: "signuprouter" */ './SignupRouter'),
recoverByMagicLink(),
delay(2000),
]).then(r => r[0])
)

/**
* Recover user by MagicLink
*
* @returns {Promise<boolean>}
*/
const recoverByMagicLink = async () => {
const { magiclink } = extractQueryParams(window.location.href)
if (magiclink) {
let userNameAndPWD = Buffer.from(magiclink, 'base64').toString('ascii')
let userNameAndPWDArray = userNameAndPWD.split('+')
log.debug('recoverByMagicLink', { magiclink, userNameAndPWDArray })
if (userNameAndPWDArray.length === 2) {
const userName = userNameAndPWDArray[0]
const userPwd = userNameAndPWDArray[1]
const UserStorage = await import('./lib/gundb/UserStorageClass').then(_ => _.UserStorage)

const mnemonic = await UserStorage.getMnemonic(userName, userPwd)

if (mnemonic && bip39.validateMnemonic(mnemonic)) {
const mnemonicsHelpers = import('./lib/wallet/SoftwareWalletProvider')
const { saveMnemonics } = await mnemonicsHelpers
await saveMnemonics(mnemonic)
await AsyncStorage.setItem('GOODDAPP_isLoggedIn', true)
window.location = '/'
}
}
}
}

let AppRouter = React.lazy(() => {
log.debug('initializing storage and wallet...')
let walletAndStorageReady = import(/* webpackChunkName: "init" */ './init')
@@ -24,6 +59,7 @@ let AppRouter = React.lazy(() => {
})
.then(r => r[1])
})

const RouterSelector = () => {
const store = SimpleStore.useStore()

@@ -39,6 +75,11 @@ const RouterSelector = () => {
return
}
const params = extractQueryParams(window.location.href)

if (params.web3) {
AsyncStorage.setItem('web3Token', params.web3)
}

if (params && Object.keys(params).length > 0) {
const dest = { path: window.location.pathname.slice(1), params }
log.debug('Saving destination url', dest)
@@ -6,11 +6,12 @@ import { Platform } from 'react-native'
import Signup from './components/signup/SignupState'
import SigninInfo from './components/signin/SigninInfo'
import Auth from './components/auth/Auth'

import InvalidW3TokenError from './components/signup/InvalidWeb3TokenError'
const router = createSwitchNavigator(
{
Auth,
Signup,
InvalidW3TokenError,
SigninInfo,
},
{
@@ -857,7 +857,7 @@ exports[`AppNavigation matches snapshot 1`] = `
Object {
"color": "rgba(255,255,255,1.00)",
"fontFamily": "gooddollar",
"fontSize": "16px",
"fontSize": "14px",
"fontStyle": "normal",
"fontWeight": "normal",
"marginRight": "16px",
@@ -1256,7 +1256,7 @@ exports[`AppNavigation matches snapshot 1`] = `
Object {
"color": "rgba(255,255,255,1.00)",
"fontFamily": "gooddollar",
"fontSize": "16px",
"fontSize": "14px",
"fontStyle": "normal",
"fontWeight": "normal",
"marginLeft": "16px",
@@ -24,17 +24,17 @@ const log = logger.child({ from: 'AppSwitch' })
const AppSwitch = (props: LoadingProps) => {
const store = SimpleStore.useStore()
const gdstore = GDStore.useStore()
const { router, state } = props.navigation

/*
Check if user is incoming with a URL with action details, such as payment link or email confirmation
*/
const getParams = async () => {
const { router, state } = props.navigation

// const navInfo = router.getPathAndParamsForState(state)
const destinationPath = await AsyncStorage.getItem(DESTINATION_PATH).then(JSON.parse)
AsyncStorage.removeItem(DESTINATION_PATH)
log.debug('getParams', { destinationPath, router, state })

if (destinationPath) {
const app = router.getActionForPathAndParams(destinationPath.path)
const destRoute = actions => (some(actions, 'action') ? destRoute(actions.action) : actions.action)
@@ -1,6 +1,6 @@
// @flow
import React from 'react'
import { Image, View } from 'react-native'
import { AsyncStorage, Image, View } from 'react-native'
import Mnemonics from '../signin/Mnemonics'
import logger from '../../lib/logger/pino-logger'
import CustomButton from '../common/buttons/CustomButton'
@@ -23,6 +23,19 @@ type Props = {
Image.prefetch(illustration)
const log = logger.child({ from: 'Auth' })
class Auth extends React.Component<Props> {
async componentWillMount() {
await this.checkWeb3Token()
}

checkWeb3Token = async () => {
const { navigation } = this.props
const web3Token = await AsyncStorage.getItem('web3Token')

if (web3Token) {
navigation.navigate('Signup')
}
}

handleSignUp = () => {
this.props.navigation.navigate('Signup')

@@ -20,7 +20,7 @@ export type ButtonProps = {
mode?: string,
onPress: any,
style?: any,
styles?: any,
styles: any,
textStyle?: any,
theme: DefaultTheme,
uppercase?: boolean,
@@ -29,6 +29,7 @@ export type ButtonProps = {
type TextContentProps = {
children: any,
dark?: boolean,
color?: string,
styles: any,
textStyle: any,
uppercase?: boolean,
@@ -151,18 +152,17 @@ const CustomButton = (props: ButtonProps) => {
<BaseButton
dark={dark}
mode={mode}
style={[styles.buttonStyle, style]}
contentStyle={styles.contentStyle}
theme={{ ...theme, roundness: 50 }}
uppercase={uppercase}
disabled={disabled || loading}
onPress={props.onPress}
color={color}
{...buttonProps}
color={color}
style={[styles.buttonStyle, style]}
>
<View style={styles.contentWrapper}>
{icon && (!iconAlignment || iconAlignment === 'left') && (
<IconButton icon={icon} theme={theme} dark={dark} size={iconSize} style={styles.leftIcon} />
<IconButton icon={icon} theme={theme} dark={dark} size={iconSize || 14} style={styles.leftIcon} />
)}
{loading && (
<ActivityIndicator
@@ -176,7 +176,7 @@ const CustomButton = (props: ButtonProps) => {
{children}
</TextContent>
{icon && iconAlignment === 'right' && (
<IconButton icon={icon} theme={theme} dark={dark} size={iconSize} style={styles.rightIcon} />
<IconButton icon={icon} theme={theme} dark={dark} size={iconSize || 14} style={styles.rightIcon} />
)}
</View>
</BaseButton>
@@ -0,0 +1,47 @@
// @flow
import React from 'react'
import { isMobile } from 'mobile-device-detect'
import { useErrorDialog } from '../../../lib/undux/utils/dialog'
import CustomButton from './CustomButton'
import CopyButton from './CopyButton'

type ShareButtonProps = {
share: any,
onPressDone?: Function,
actionText: string,
buttonProps: any,
}

const ShareButton = ({ share, onPressDone, actionText, ...buttonProps }: ShareButtonProps) => {
const [showErrorDialog] = useErrorDialog()

console.info('getPaymentLink', { share })
const shareAction = async () => {
try {
await navigator.share(share)
} catch (e) {
if (e.name !== 'AbortError') {
showErrorDialog(e)
}
}
}

if (isMobile && navigator.share) {
return (
<CustomButton onPress={shareAction} {...buttonProps}>
{actionText}
</CustomButton>
)
}
return (
<CopyButton toCopy={share.url} onPressDone={onPressDone} {...buttonProps}>
{actionText}
</CopyButton>
)
}

ShareButton.defaultProps = {
buttonProps: {},
}

export default ShareButton

0 comments on commit 872f9fc

Please sign in to comment.
You can’t perform that action at this time.