Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
swansontec committed Aug 11, 2023
2 parents a35faff + c779ec3 commit a46622e
Show file tree
Hide file tree
Showing 25 changed files with 426 additions and 372 deletions.
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ PODS:
- React-Core
- edge-currency-accountbased (1.4.11):
- React-Core
- edge-login-ui-rn (2.6.5):
- edge-login-ui-rn (2.6.6):
- React
- FBLazyVector (0.71.11)
- FBReactNativeSpec (0.71.11):
Expand Down Expand Up @@ -1190,7 +1190,7 @@ SPEC CHECKSUMS:
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
edge-core-js: 1691cc53dce8bab2e04c44ccf74c837eee1ea462
edge-currency-accountbased: ce9b39cc0413ecc4ac14040d3ce9e12280672e67
edge-login-ui-rn: 7a6ee882c613d4140fc09408d493488797687217
edge-login-ui-rn: a1d8d281819e235bcd97f61cf69f94a42db854eb
FBLazyVector: c511d4cd0210f416cb5c289bd5ae6b36d909b048
FBReactNativeSpec: a911fb22def57aef1d74215e8b6b8761d25c1c54
Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d
Expand Down
8 changes: 0 additions & 8 deletions maestro/99-misc/C999002-pin-login.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ tags:
- extendedWaitUntil:
visible: FIRO
timeout: 120000
- tapOn: FIRO
- extendedWaitUntil:
visible: 0.369074 FIRO
timeout: 120000

- stopApp
- launchApp
Expand All @@ -38,9 +34,5 @@ tags:
- extendedWaitUntil:
visible: FIRO
timeout: 120000
- tapOn: FIRO
- extendedWaitUntil:
visible: 0.369074 FIRO
timeout: 120000

- stopApp
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edge-react-gui",
"version": "3.14.1",
"version": "3.15.0",
"private": true,
"description": "Edge Wallet React GUI",
"homepage": "https://edge.app",
Expand Down Expand Up @@ -40,7 +40,9 @@
"lint": "eslint .",
"localize": "node -r sucrase/register ./scripts/localizeLanguage.ts; git add ./src/locales/strings",
"logging-server": "node -r sucrase/register scripts/loggingServer.ts",
"maestro": "node -r sucrase/register ./scripts/runMaestro.ts",
"maestro": "node -r sucrase/register ./scripts/runMaestro.ts test",
"maestro:ios": "node -r sucrase/register ./scripts/runMaestro.ts test --include-tags all,ios maestro",
"maestro:android": "node -r sucrase/register ./scripts/runMaestro.ts test --include-tags all,android maestro",
"copy-checkpoints": "cp -r node_modules/edge-currency-accountbased/android/src/main/assets/saplingtree/mainnet ios/Pods/ZcashLightClientKit/Sources/ZcashLightClientKit/Resources/saplingtree-checkpoints && cp -r node_modules/edge-currency-accountbased/android/src/main/assets/piratesaplingtree/mainnet ios/Pods/PirateLightClientKit/Sources/PirateLightClientKit/Resources/piratesaplingtree-checkpoints",
"precommit": "npm run localize && lint-staged && tsc && npm test",
"prepare.ios": "(cd ios; pod repo update; pod install) && npm run copy-checkpoints",
Expand Down Expand Up @@ -143,7 +145,7 @@
"edge-currency-monero": "^1.0.0",
"edge-currency-plugins": "^2.0.4",
"edge-exchange-plugins": "^0.19.8",
"edge-login-ui-rn": "^2.6.5",
"edge-login-ui-rn": "^2.6.6",
"ethers": "^5.6.0",
"paraswap": "^5.2.0",
"prompts": "^2.4.2",
Expand Down Expand Up @@ -236,7 +238,6 @@
"babel-jest": "^29.2.1",
"body-parser": "^1.18.2",
"buffer": "^6.0.3",
"cac": "^6.7.14",
"crypto-browserify": "^3.12.0",
"esbuild-loader": "^2.20.0",
"eslint": "^8.19.0",
Expand Down
102 changes: 33 additions & 69 deletions scripts/runMaestro.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,42 @@
import cac from 'cac'
import { execSync, ExecSyncOptions } from 'child_process'
import { asObject, asString } from 'cleaners'
import fs from 'fs'
import { makeConfig } from 'cleaner-config'
import { asObject, asOptional, asString } from 'cleaners'
import { join } from 'path'

const cwd = join(__dirname, '..')
const TESTER_CONFIG = 'testerConfig.json'
const maestroDir = join(cwd, 'maestro')

// const redANSII = '\x1b[31m'
const blueANSII = '\x1b[34m'
const resetANSII = '\x1b[0m'

// const error = console.error.bind(console, redANSII, 'ERROR:' + resetANSII)
// const warn = console.warn.bind(console, yellowANSII, 'WARN:' + resetANSII)
const info = console.info.bind(console, blueANSII, 'INFO:' + resetANSII)

const asTestConfig = asObject({
env: asObject(asString)
})

const runMaestro = async (options: CLIOptions, env?: { [key: string]: string }): Promise<void> => {
const { device, dryRun, excludeTags, includeTags, test } = options
const group = test ?? maestroDir

const dev = device == null ? '' : `--device ${device} `
const inc = includeTags == null ? '' : `--include-tags=${includeTags} `
const exc = excludeTags == null ? '' : `--exclude-tags=${excludeTags} `

const cmd = `maestro --no-ansi ${dev}test ${inc}${exc}${group}`
if (!dryRun) {
info(cmd)
const execSyncOpts: ExecSyncOptions = { cwd, stdio: 'inherit', env: { ...process.env, ...env } }
const result = execSync(cmd, execSyncOpts)
const output = result != null ? result.toString() : 'No output result'
info(output)
} else {
info(cmd)
}
}

const cli = cac('Edge Maestro CLI')

interface CLIOptions {
test?: string
device?: string
includeTags?: string
excludeTags?: string
dryRun?: boolean
}

cli
.command('[param]', 'runMaestro.ts')
.option('--test, -t [test]', 'Run specific test or group. Must specify the full path to test or directory relative to the repo working directory')
.option('--device, -d [device]', 'Run test on specificied adb device id', { default: undefined })
.option('--include-tags, --it [includeTag]', 'Comma-separated list of test tags to include', { default: undefined })
.option('--exclude-tags, --et [excludeTags]', 'Comma-separated list of test tags to exclude', { default: undefined })
.option('--dry-run, --dr', 'Print the list of tests that would be run, but do not run them', { default: false })
.action((param: string, options: CLIOptions) => {
if (param != null) {
console.log(`Unknown param ${param}`)
process.exit(-1)
}
let testerConfig
if (fs.existsSync(TESTER_CONFIG)) {
const testerConfigJson = fs.readFileSync(TESTER_CONFIG, { encoding: 'utf8' })
testerConfig = asTestConfig(JSON.parse(testerConfigJson))
env: asOptional(
asObject({
MAESTRO_APP_ID: asOptional(asString, 'co.edgesecure.app'),
MAESTRO_EDGE_UTXO_USERNAME: asOptional(asString, 'user'),
MAESTRO_EDGE_UTXO_PASSWORD: asOptional(asString, 'passwd'),
MAESTRO_EDGE_UTXO_PIN_1: asOptional(asString, '1'),
MAESTRO_EDGE_UTXO_PIN_2: asOptional(asString, '1'),
MAESTRO_EDGE_UTXO_PIN_3: asOptional(asString, '1'),
MAESTRO_EDGE_UTXO_PIN_4: asOptional(asString, '1'),
MAESTRO_EDGE_IP2FA_MEXICO_USERNAME: asOptional(asString, 'user'),
MAESTRO_EDGE_IP2FA_MEXICO_PASSWORD: asOptional(asString, 'passwd')
}),
{
MAESTRO_APP_ID: 'co.edgesecure.app',
MAESTRO_EDGE_UTXO_USERNAME: 'user',
MAESTRO_EDGE_UTXO_PASSWORD: 'passwd',
MAESTRO_EDGE_UTXO_PIN_1: '1',
MAESTRO_EDGE_UTXO_PIN_2: '1',
MAESTRO_EDGE_UTXO_PIN_3: '1',
MAESTRO_EDGE_UTXO_PIN_4: '1',
MAESTRO_EDGE_IP2FA_MEXICO_USERNAME: 'user',
MAESTRO_EDGE_IP2FA_MEXICO_PASSWORD: 'passwd'
}
)
}).withRest

const cwd = join(__dirname, '..')

runMaestro(options, testerConfig?.env).catch(e => {
console.error(e)
process.exit(-1)
})
})
const { env } = makeConfig(asTestConfig, TESTER_CONFIG)

cli.help()
cli.parse()
const execSyncOpts: ExecSyncOptions = { cwd, stdio: 'inherit', env: { ...process.env, ...env } }
const args = process.argv.slice(2).join(' ')
const cmd = `maestro ${args}`
execSync(cmd, execSyncOpts)
2 changes: 2 additions & 0 deletions src/__tests__/scenes/SettingsScene.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('MyComponent', () => {
<FakeProviders>
<SettingsSceneComponent
{...fakeSceneProps('settingsOverview', {})}
username="some user"
theme={config.darkTheme}
// StateProps:
account={account}
Expand Down Expand Up @@ -62,6 +63,7 @@ describe('MyComponent', () => {
<FakeProviders>
<SettingsSceneComponent
{...fakeSceneProps('settingsOverview', {})}
username="some user"
theme={config.darkTheme}
// StateProps:
account={account}
Expand Down
6 changes: 3 additions & 3 deletions src/components/buttons/ButtonsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export const ButtonsContainer = React.memo(({ primary, secondary, escape, layout
)
})

const StyledButtonContainer = styled(View)<{ layout: 'row' | 'column' }>(props => {
const StyledButtonContainer = styled(View)<{ layout: 'row' | 'column' }>(theme => props => {
const isRowLayout = props.layout === 'row'
return {
flexDirection: isRowLayout ? 'row-reverse' : 'column',
justifyContent: 'space-evenly',
margin: props.theme.rem(0.5),
marginHorizontal: isRowLayout ? 0 : props.theme.rem(0.5)
margin: theme.rem(0.5),
marginHorizontal: isRowLayout ? 0 : theme.rem(0.5)
}
})
71 changes: 60 additions & 11 deletions src/components/hoc/styled.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,72 @@
import * as React from 'react'
import { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native'
import { ImageStyle, StyleProp, StyleSheet, TextStyle, ViewStyle } from 'react-native'

import { ThemeProps, useTheme } from '../services/ThemeContext'
import { cacheStyles, getTheme, Theme, useTheme } from '../services/ThemeContext'

interface StyleProps {
style?: StyleProp<any>
}
type ValidStyles = ImageStyle | TextStyle | ViewStyle | ValidStyles[]

type ValidStyles = ImageStyle | TextStyle | ViewStyle

type Styler<Props> = ValidStyles | ((theme: Theme) => ValidStyles | ((props: Props) => ValidStyles | ValidStyles[]))

/**
* Creates a styled component using a `styler` parameter. The `styler` can be the
* styles itself, a function with the current theme and component props as
* curried arguments (e.g. `theme => props => styles` or `theme => styles`).
* The styles are cached when no `props` parameter is required by the `styler`.
*
* **Example Usage**
*
* ```
* const Colorful = styled(Text)({ fontWeight: 'Red' })
* const Themed = styled(Text)(theme => ({ color: theme.color }))
* const Dynamic = styled(Text)(theme => props => ({ color: props.color ?? theme.color }))
* const DynamicSansTheme = styled(Text)(_theme => props => ({ color: props.color }))
* ```
*/
export function styled<BaseProps extends StyleProps>(Component: React.ComponentType<BaseProps>) {
function makeStyledComponent<Props extends object>(getStyles: (props: Omit<BaseProps, 'style'> & Props & ThemeProps) => ValidStyles) {
const StyledComponent: React.ComponentType<Omit<BaseProps, 'style'> & Props> = props => {
const theme = useTheme()
const styles = getStyles({ ...props, theme })
const allProps: BaseProps = { ...props, style: styles } as any
return <Component {...allProps} />
function makeStyledComponent<Props extends object>(styler: Styler<Props>): React.ComponentType<Omit<BaseProps, 'style'> & Props> {
function addName<P extends Omit<BaseProps, 'style'> & Props>(StyledComponent: React.ComponentType<P>) {
StyledComponent.displayName = Component.displayName != null ? `StyledComponent(${Component.displayName})` : `StyledComponent`

return StyledComponent
}

if (typeof styler === 'function') {
const rv = styler(getTheme())
if (typeof rv === 'function') {
const stylerNarrowed = styler as (theme: Theme) => (props: Props) => ValidStyles | ValidStyles[]
return addName(function StyledComponent(props) {
const theme = useTheme()
const style = stylerNarrowed(theme)(props)

const allProps: Omit<BaseProps, 'style'> & BaseProps['style'] = { ...props, style: style }
return <Component {...allProps} />
})
} else {
const stylerNarrowed = styler as (theme: Theme) => ValidStyles
const getStyles = cacheStyles((theme: Theme) => ({
style: stylerNarrowed(theme)
}))

return addName(function StyledComponent(props) {
const theme = useTheme()
const stylesheet = getStyles(theme)

const allProps: Omit<BaseProps, 'style'> & BaseProps['style'] = { ...props, style: stylesheet.style }
return <Component {...allProps} />
})
}
} else {
const stylesheet = StyleSheet.create({ style: styler })

return addName(function StyledComponent(props) {
const allProps: Omit<BaseProps, 'style'> & BaseProps['style'] = { ...props, style: stylesheet.style }
return <Component {...allProps} />
})
}
StyledComponent.displayName = Component.displayName != null ? `StyledComponent(${Component.displayName})` : `StyledComponent`
return StyledComponent
}
return makeStyledComponent
}
10 changes: 5 additions & 5 deletions src/components/modals/FioCreateHandleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const FioCreateHandleModal = (props: Props) => {
)
}

const GetFioHandleTitle = styled(Text)(props => ({
color: props.theme.primaryText,
fontSize: props.theme.rem(1.75),
fontFamily: props.theme.fontFaceDefault,
const GetFioHandleTitle = styled(Text)(theme => ({
color: theme.primaryText,
fontSize: theme.rem(1.75),
fontFamily: theme.fontFaceDefault,
fontWeight: 'bold',
marginBottom: props.theme.rem(1),
marginBottom: theme.rem(1),
textAlign: 'center'
}))

Expand Down
34 changes: 17 additions & 17 deletions src/components/notification/NotificationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@ const NotificationCardComponent = (props: Props) => {
)
}

const CardContainer = styled(TouchableOpacity)(props => ({
const CardContainer = styled(TouchableOpacity)(theme => ({
alignItems: 'center',
backgroundColor: props.theme.modal,
borderRadius: props.theme.rem(0.5),
backgroundColor: theme.modal,
borderRadius: theme.rem(0.5),
elevation: 6,
flexDirection: 'row',
justifyContent: 'center',
padding: props.theme.rem(0.5),
padding: theme.rem(0.5),
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.7,
shadowRadius: props.theme.rem(0.5)
shadowRadius: theme.rem(0.5)
}))

const Icon = styled(FastImage)(props => ({
height: props.theme.rem(2.5),
width: props.theme.rem(2.5)
const Icon = styled(FastImage)(theme => ({
height: theme.rem(2.5),
width: theme.rem(2.5)
}))

const TitleText = styled(EdgeText)(props => ({
color: props.theme.warningIcon,
marginLeft: props.theme.rem(0.5),
fontSize: props.theme.rem(0.75),
fontFamily: props.theme.fontFaceBold
const TitleText = styled(EdgeText)(theme => ({
color: theme.warningIcon,
marginLeft: theme.rem(0.5),
fontSize: theme.rem(0.75),
fontFamily: theme.fontFaceBold
}))

const MessageText = styled(EdgeText)(props => ({
color: props.theme.warningIcon,
marginLeft: props.theme.rem(0.5),
fontSize: props.theme.rem(0.75)
const MessageText = styled(EdgeText)(theme => ({
color: theme.warningIcon,
marginLeft: theme.rem(0.5),
fontSize: theme.rem(0.75)
}))

export const NotificationCard = React.memo(NotificationCardComponent)
8 changes: 4 additions & 4 deletions src/components/notification/NotificationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const NotificationViewComponent = (props: Props) => {
)
}

const NotificationCardsContainer = styled(View)(props => ({
const NotificationCardsContainer = styled(View)(theme => ({
alignSelf: 'center',
height: props.theme.rem(3.5),
marginHorizontal: props.theme.rem(0.5),
bottom: props.theme.rem(0.5),
height: theme.rem(3.5),
marginHorizontal: theme.rem(0.5),
bottom: theme.rem(0.5),
position: 'absolute'
}))

Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/Fio/FioAddressSettingsScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class FioAddressSettingsComponent extends React.Component<Props, LocalSta
onSuccess={this.afterAddBundledTxsSuccess}
getOperationFee={getAddBundledTxsFee}
successMessage={lstrings.fio_request_add_bundled_txs_ok_text}
cancelOperation={this.cancelOperation}
onCancel={this.cancelOperation}
fioWallet={fioWallet}
addressTitles
showPaymentWalletPicker
Expand Down
Loading

0 comments on commit a46622e

Please sign in to comment.