Skip to content
Permalink
Browse files

PR #428 user from W3 login flow (#478)

* #428 - make registration flow

* #428 - make registration flow

* #428 - make registration flow

* #429 - User already opened wallet not through web3

* #428 - User can click on W3 link to login to DAPP

* #428 - User can click on W3 link to login to DAPP. Changes required in PR by sirpy

* add: verification of web3 user email on server (#59)

* refactor: "get base64 from image url through fetch library"

* refactor: "move checkWeb3Email request to goToPhone section"

* add: "log error in case if W3 email verification failed"

* fix "add data:image prefix for avatar base64 string"

* fix "update snapshots"

* add "add test for InvalidW3TokenError component render"

* add "add test for InvalidW3TokenError component render"

* refactor: "add missed comma"

* refactor: "indents"

* add: "new tests to pass coverage"

* add: "new tests to pass coverage"

* refactor: "use axios for get base64 image"

* fix: "remove await for methods which result is not used"

* fix: "remove cross-fetch lib"

* fix: "web3transport configs"

* fix: "fix Payment Cancel GoodWallet test"

* refactor "test"

* fix "test with PaymentCancel event"
  • Loading branch information...
yaroslav-fedyshyn-nordwhale authored and sirpy committed Sep 8, 2019
1 parent 62d063d commit bb997d720bab071dbf8d107b17c6744e9e9d4923
@@ -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",
@@ -75,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,
},
{
@@ -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')

@@ -4,7 +4,7 @@ import { gdToWei } from '../../../lib/wallet/utils'
import adminWallet from './__util__/AdminWallet'

describe('GoodWalletShare/ReceiveTokens', () => {
jest.setTimeout(60000)
jest.setTimeout(90000)

const amount = gdToWei(0.1)
const reason = 'Test_Reason'
@@ -24,6 +24,9 @@ describe('GoodWalletShare/ReceiveTokens', () => {

await adminWallet.whitelistUser(testWallet.account, 'did:gd')
await adminWallet.whitelistUser(testWallet2.account, 'did:gd')

await adminWallet.topWallet(testWallet.account)
await adminWallet.topWallet(testWallet2.account)
})

it('should emit `transfer` event filtered by `to` block', async () => {
@@ -41,17 +44,12 @@ describe('GoodWalletShare/ReceiveTokens', () => {
expect(event[0].event).toBe('Transfer')
})

await adminWallet.topWallet(testWallet.account)

await testWallet.claim()
})

it('should emit `PaymentWithdraw` and `transfer` event filtered by `from` block', async () => {
const lastBlock = await testWallet.getBlockNumber()

await adminWallet.topWallet(testWallet.account)
await adminWallet.topWallet(testWallet2.account)

const linkData = testWallet.generateLink(amount, reason, () => {})

testWallet.listenTxUpdates(lastBlock, ({ toBlock, event }) => {
@@ -69,18 +67,17 @@ describe('GoodWalletShare/ReceiveTokens', () => {
testWallet2.withdraw(linkData.hashedCode)
})

it('should emit `PaymentCancel` event', async () => {
const lastBlock = await testWallet2.getBlockNumber()
it('should emit `PaymentCancel` event', () => {
const linkData = testWallet.generateLink(amount, reason, async () => {
const lastBlock = await testWallet.getBlockNumber()

adminWallet.topWallet(testWallet2.account)
const linkData = testWallet2.generateLink(amount, reason, () => {})
testWallet.listenTxUpdates(lastBlock, ({ toBlock, event }) => {
expect(event).toBeTruthy()
expect(event.event).toBe('PaymentCancel')
expect(toBlock).toBeTruthy()
})

testWallet2.listenTxUpdates(lastBlock, ({ toBlock, event }) => {
expect(event).toBeTruthy()
expect(event.event).toBe('PaymentCancel')
expect(toBlock).toBeTruthy()
testWallet.cancelOTL(linkData.hashedCode)
})

testWallet2.cancelOTL(linkData.hashedCode)
})
})
@@ -218,14 +218,14 @@ export class Wallet {
const isVerified = force || (await this.isVerified(address))
if (isVerified) {
let userBalance = await this.web3.eth.getBalance(address)
let toTop = parseInt(web3Utils.toWei('1000000', 'gwei')) - userBalance
let toTop = parseInt(web3Utils.toWei('5000000', 'gwei')) - userBalance
log.debug('TopWallet:', { userBalance, toTop })
if (force || toTop / 1000000 >= 0.75) {
if (force || toTop / 5000000 >= 0.75) {
let res = await this.sendNative({
from: this.address,
to: address,
value: toTop,
gas: 100000,
gas: 1000000,
gasPrice: web3Utils.toWei('1', 'gwei'),
})
log.debug('Topwallet result:', res)
@@ -0,0 +1,19 @@
import React from 'react'
import renderer from 'react-test-renderer'
import SideMenuPanel from '../SideMenuPanel'
import { withThemeProvider } from '../../../__tests__/__util__'

const SideMenuPanelTheme = withThemeProvider(SideMenuPanel)

describe('SideMenuPanel', () => {
it('renders without errors', () => {
const tree = renderer.create(<SideMenuPanelTheme />)
expect(tree.toJSON()).toBeTruthy()
})

it('matches snapshot', () => {
const component = renderer.create(<SideMenuPanelTheme />)
const tree = component.toJSON()
expect(tree).toMatchSnapshot()
})
})

0 comments on commit bb997d7

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