Skip to content

Commit

Permalink
(Feature) GoodWallet Ethereum support - enhancements (#4091)
Browse files Browse the repository at this point in the history
* add replace hardcoded title, find solution for unsafe wallet passing

* remove wallet reference from realmdb

* Apply suggestions from code review

* fix snapshots
  • Loading branch information
johnsmith-gooddollar authored Oct 30, 2023
1 parent c238dca commit aa65e73
Show file tree
Hide file tree
Showing 14 changed files with 111 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,10 @@ exports[`AppNavigation matches snapshot 1`] = `
className="css-view-1dbjc4n r-alignItems-1awozwy r-display-6koalj r-flexDirection-18u37iz r-justifyContent-1wtj0ep r-width-13qz1uu"
>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-14lw9ot r-borderRadius-1f0042m r-paddingBottom-1mdbw0j r-paddingHorizontal-1e081e0 r-paddingTop-wk8lta r-paddingVertical-1yzf0co"
className="css-view-1dbjc4n r-alignItems-1awozwy r-paddingBottom-1mdbw0j r-paddingTop-wk8lta r-width-1j6l8hp"
>
<div
className="css-view-1dbjc4n"
style={
Object {
"WebkitAlignItems": "flex-start",
"WebkitBoxAlign": "start",
"alignItems": "flex-start",
"msFlexAlign": "start",
}
}
className="css-view-1dbjc4n r-flexDirection-18u37iz r-justifyContent-1wtj0ep r-width-13qz1uu"
>
<div
className="css-view-1dbjc4n r-flexDirection-18u37iz r-justifyContent-1wtj0ep"
Expand All @@ -218,7 +210,7 @@ exports[`AppNavigation matches snapshot 1`] = `
>
<div
aria-disabled={true}
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-1niwhzg r-borderColor-y68mpx r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-justifyContent-1777fci r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-width-13qz1uu"
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-1niwhzg r-borderColor-y68mpx r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-justifyContent-1777fci r-marginTop-1bymd8e r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-width-13qz1uu"
onClick={[Function]}
onContextMenu={[Function]}
onKeyDown={[Function]}
Expand All @@ -231,29 +223,30 @@ exports[`AppNavigation matches snapshot 1`] = `
tabIndex="-1"
>
<div
className="css-view-1dbjc4n r-backgroundColor-1niwhzg r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-width-13qz1uu"
className="css-view-1dbjc4n r-backgroundColor-1niwhzg r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-marginTop-1bymd8e r-width-13qz1uu"
>
<unknownProfile.svg />
</div>
</div>
</div>
</div>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-justifyContent-1777fci r-marginTop-knv0ih"
style={
Object {
"marginBottom": "8px",
"opacity": 1,
"zIndex": -1,
}
</div>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-justifyContent-1777fci r-marginTop-knv0ih"
style={
Object {
"marginBottom": "8px",
"opacity": 1,
"right": "15px",
"zIndex": -1,
}
}
>
<div
className="css-text-901oao r-color-1mtiv16 r-fontFamily-vnw8o6 r-fontSize-1enofrn r-fontWeight-1it3c9n r-lineHeight-1cwl3u0 r-textAlign-q4m81j r-textDecorationLine-13wfysu r-textTransform-3twk1y"
dir="auto"
>
<div
className="css-text-901oao r-color-1mtiv16 r-fontFamily-vnw8o6 r-fontSize-1enofrn r-fontWeight-1it3c9n r-lineHeight-1cwl3u0 r-textAlign-q4m81j r-textDecorationLine-13wfysu r-textTransform-3twk1y"
dir="auto"
>
</div>
</div>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/components/dashboard/SendQRSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BackButton, useScreenState } from '../appNavigation/stackNavigation'
import { CustomButton, Section, Wrapper } from '../common'
import SummaryTable from '../common/view/SummaryTable'
import TopBar from '../common/view/TopBar'
import { SEND_TITLE } from './utils/sendReceiveFlow'
import { navigationOptions, SEND_TITLE } from './utils/sendReceiveFlow'

export type AmountProps = {
screenProps: any,
Expand Down Expand Up @@ -168,9 +168,10 @@ const SendQRSummary = ({ screenProps }: AmountProps, params) => {
)
}

SendQRSummary.navigationOptions = {
SendQRSummary.navigationOptions = props => ({
title: SEND_TITLE,
}
...navigationOptions(props),
})

SendQRSummary.shouldNavigateToComponent = props => {
const { screenState } = props.screenProps
Expand Down
14 changes: 5 additions & 9 deletions src/components/dashboard/TransactionConfirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { fireEvent, SEND_CONFIRMATION_SHARE } from '../../lib/analytics/analytic
import ConfirmTransactionSVG from '../../assets/confirmTransaction.svg'
import useCachedScreenState from '../../lib/hooks/useCachedScreenState'
import { isSharingAvailable } from '../../lib/share'
import { ACTION_RECEIVE, ACTION_SEND, PARAM_ACTION, RECEIVE_TITLE, SEND_TITLE } from './utils/sendReceiveFlow'
import { ACTION_SEND, navigationOptions } from './utils/sendReceiveFlow'

export type ReceiveProps = {
screenProps: any,
Expand Down Expand Up @@ -125,13 +125,9 @@ const getStylesFromProps = ({ theme }) => ({
},
})

TransactionConfirmation.navigationOptions = ({ navigation }) => {
const action = navigation.getParam(PARAM_ACTION)

return {
title: action === ACTION_RECEIVE ? RECEIVE_TITLE : SEND_TITLE,
backButtonHidden: true,
}
}
TransactionConfirmation.navigationOptions = props => ({
backButtonHidden: true,
...navigationOptions(props),
})

export default withStyles(getStylesFromProps)(TransactionConfirmation)
63 changes: 25 additions & 38 deletions src/components/dashboard/__tests__/__snapshots__/Dashboard.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,10 @@ exports[`Dashboard matches snapshot 1`] = `
className="css-view-1dbjc4n r-alignItems-1awozwy r-display-6koalj r-flexDirection-18u37iz r-justifyContent-1wtj0ep r-width-13qz1uu"
>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-14lw9ot r-borderRadius-1f0042m r-paddingBottom-1mdbw0j r-paddingHorizontal-1e081e0 r-paddingTop-wk8lta r-paddingVertical-1yzf0co"
className="css-view-1dbjc4n r-alignItems-1awozwy r-paddingBottom-1mdbw0j r-paddingTop-wk8lta r-width-1j6l8hp"
>
<div
className="css-view-1dbjc4n"
style={
Object {
"WebkitAlignItems": "flex-start",
"WebkitBoxAlign": "start",
"alignItems": "flex-start",
"msFlexAlign": "start",
}
}
className="css-view-1dbjc4n r-flexDirection-18u37iz r-justifyContent-1wtj0ep r-width-13qz1uu"
>
<div
className="css-view-1dbjc4n r-flexDirection-18u37iz r-justifyContent-1wtj0ep"
Expand All @@ -217,7 +209,7 @@ exports[`Dashboard matches snapshot 1`] = `
>
<div
aria-disabled={true}
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-1niwhzg r-borderColor-y68mpx r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-justifyContent-1777fci r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-width-13qz1uu"
className="css-view-1dbjc4n r-alignItems-1awozwy r-backgroundColor-1niwhzg r-borderColor-y68mpx r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-justifyContent-1777fci r-marginTop-1bymd8e r-transitionProperty-1i6wzkk r-userSelect-lrvibr r-width-13qz1uu"
onClick={[Function]}
onContextMenu={[Function]}
onKeyDown={[Function]}
Expand All @@ -230,29 +222,30 @@ exports[`Dashboard matches snapshot 1`] = `
tabIndex="-1"
>
<div
className="css-view-1dbjc4n r-backgroundColor-1niwhzg r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-width-13qz1uu"
className="css-view-1dbjc4n r-backgroundColor-1niwhzg r-borderRadius-ieixw r-borderWidth-1yadl64 r-height-1pi2tsx r-marginTop-1bymd8e r-width-13qz1uu"
>
<unknownProfile.svg />
</div>
</div>
</div>
</div>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-justifyContent-1777fci r-marginTop-knv0ih"
style={
Object {
"marginBottom": "8px",
"opacity": 1,
"zIndex": -1,
}
</div>
<div
className="css-view-1dbjc4n r-alignItems-1awozwy r-justifyContent-1777fci r-marginTop-knv0ih"
style={
Object {
"marginBottom": "8px",
"opacity": 1,
"right": "15px",
"zIndex": -1,
}
}
>
<div
className="css-text-901oao r-color-1mtiv16 r-fontFamily-vnw8o6 r-fontSize-1enofrn r-fontWeight-1it3c9n r-lineHeight-1cwl3u0 r-textAlign-q4m81j r-textDecorationLine-13wfysu r-textTransform-3twk1y"
dir="auto"
>
<div
className="css-text-901oao r-color-1mtiv16 r-fontFamily-vnw8o6 r-fontSize-1enofrn r-fontWeight-1it3c9n r-lineHeight-1cwl3u0 r-textAlign-q4m81j r-textDecorationLine-13wfysu r-textTransform-3twk1y"
dir="auto"
>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -1010,12 +1003,11 @@ exports[`Dashboard matches snapshot 1`] = `
}
>
<div
className="css-view-1dbjc4n"
className="css-view-1dbjc4n r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down Expand Up @@ -1053,12 +1045,11 @@ exports[`Dashboard matches snapshot 1`] = `
className="css-view-1dbjc4n r-alignItems-1awozwy r-flexDirection-18u37iz r-justifyContent-1wtj0ep"
>
<div
className="css-view-1dbjc4n r-marginTop-14gqq1x"
className="css-view-1dbjc4n r-marginTop-14gqq1x r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down Expand Up @@ -1153,12 +1144,11 @@ exports[`Dashboard matches snapshot 1`] = `
}
>
<div
className="css-view-1dbjc4n"
className="css-view-1dbjc4n r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down Expand Up @@ -1196,12 +1186,11 @@ exports[`Dashboard matches snapshot 1`] = `
className="css-view-1dbjc4n r-alignItems-1awozwy r-flexDirection-18u37iz r-justifyContent-1wtj0ep"
>
<div
className="css-view-1dbjc4n r-marginTop-14gqq1x"
className="css-view-1dbjc4n r-marginTop-14gqq1x r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down Expand Up @@ -1296,12 +1285,11 @@ exports[`Dashboard matches snapshot 1`] = `
}
>
<div
className="css-view-1dbjc4n"
className="css-view-1dbjc4n r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down Expand Up @@ -1339,12 +1327,11 @@ exports[`Dashboard matches snapshot 1`] = `
className="css-view-1dbjc4n r-alignItems-1awozwy r-flexDirection-18u37iz r-justifyContent-1wtj0ep"
>
<div
className="css-view-1dbjc4n r-marginTop-14gqq1x"
className="css-view-1dbjc4n r-marginTop-14gqq1x r-width-1q42mak"
style={
Object {
"backgroundColor": "rgba(238,238,238,1.00)",
"height": "10px",
"width": "74px",
}
}
/>
Expand Down
26 changes: 7 additions & 19 deletions src/components/dashboard/utils/sendReceiveFlow.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,35 @@
import React, { useContext } from 'react'
import { t } from '@lingui/macro'
import Config from '../../../config/config'
import AppNavBar from '../../appNavigation/NavBar'
import { TokenContext } from '../../../lib/wallet/GoodWalletProvider'
import { NetworkName } from '../../appNavigation/TabsView'

const NavBar = ({ title, goBack }) => {
const NavBar = ({ title, goBack, isBridge }) => {
const { token } = useContext(TokenContext)

return (
<AppNavBar goBack={goBack} title={`${title} ${token}`}>
<AppNavBar goBack={goBack} title={isBridge ? title : `${title} ${token}`}>
<NetworkName icon={false} />
</AppNavBar>
)
}

export const navigationOptions = ({ navigation, screenProps }) => {
export const navigationOptions = ({ navigation }) => {
const { routeName } = navigation.state
const action = navigation.getParam(PARAM_ACTION)

const isBridge = navigation.getParam('isBridge')
const isReceive = action === ACTION_RECEIVE || ['Receive', 'ReceiveToAddress'].includes(routeName)

let options = {
return {
title: isReceive ? RECEIVE_TITLE : isBridge ? BRIDGE_TITLE : SEND_TITLE,
navigationBar: NavBar,
isBridge,
}

if (Config.isDeltaApp && !isBridge) {
options.title = isReceive ? RECEIVE_NATIVE_TITLE : SEND_NATIVE_TITLE

if (['Amount', 'Receive'].includes(routeName)) {
options.navigationBar = NavBar
}
}

return options
}

export const RECEIVE_TITLE = t`Receive G$`
export const RECEIVE_NATIVE_TITLE = t`Receive`
export const SEND_TITLE = t`Send G$`
export const SEND_NATIVE_TITLE = t`Send`
export const RECEIVE_TITLE = t`Receive`
export const SEND_TITLE = t`Send`
export const BRIDGE_TITLE = t`Bridge G$`
export const ACTION_RECEIVE = 'Receive'
export const ACTION_SEND = 'Send'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getDesignRelativeHeight, getDesignRelativeWidth, isLargeDevice } from '
import { withStyles } from '../../../lib/styles'
import SwitchToAnotherDeviceSVG from '../../../assets/FRSwitchToAnotherDevice.svg'

const SwitchToAnotherDevice = ({ styles, displayTitle, exception, nav, isFVFlow }) => (
const SwitchToAnotherDevice = ({ styles, displayTitle }) => (
<Section style={styles.descriptionContainer} justifyContent="space-between">
<Section.Title fontWeight="medium" textTransform="none" color="red">
{displayTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,4 @@ describe('FaceVerification SwitchToAnotherDevice', () => {

expect(tree.toJSON()).toMatchSnapshot()
})

it('should execute screenProps.goToRoot on "OK" press', async () => {
let tree

// eslint-disable-next-line require-await
await renderer.act(async () => (tree = renderer.create(<SwitchToAnotherDevice nav={nav} />)))
const button = tree.root.findByProps({ testID: 'ok_button' })

button.props.onPress()
expect(nav.goToRoot).toHaveBeenCalled()
})
})
10 changes: 7 additions & 3 deletions src/lib/realmdb/RealmDB.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @flow
import { assign, filter, first, isPlainObject, once } from 'lodash'
import { assign, filter, first, isPlainObject, noop, once } from 'lodash'
import * as Realm from 'realm-web'
import TextileCrypto from '@textile/crypto' // eslint-disable-line import/default
import EventEmitter from 'eventemitter3'
Expand Down Expand Up @@ -65,6 +65,10 @@ class RealmDB implements DB, ProfileDB {

isReady: boolean = false

account: string

onBalanceChanged = noop

dbEvents = new EventEmitter()

sources = [
Expand Down Expand Up @@ -100,9 +104,9 @@ class RealmDB implements DB, ProfileDB {
*/
async init(db: ThreadDB) {
try {
const { privateKey, wallet, Feed } = db
const { privateKey, Feed } = db

assign(this, { db, privateKey, wallet })
assign(this, { db, privateKey })

Feed.table.hook('creating', (id, event) => this._notifyChange({ id, event }))
Feed.table.hook('updating', (modify, id, event) => this._notifyChange({ modify, id, event }))
Expand Down
Loading

0 comments on commit aa65e73

Please sign in to comment.