Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
swansontec committed Apr 8, 2021
2 parents de7fa16 + 5328a8d commit 5222443
Show file tree
Hide file tree
Showing 23 changed files with 182 additions and 146 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# edge-react-gui

## 2.0.8 (2021-04-08)

- Reset the slider on the send screen when the pending state changes.
- Hide 0 crypto amount if balance is hidden.
- Fix tokens not showing the correct icon on Request Scene.
- Fix a crash when initiating password recovery.
- Remove the BPay option for Banxa Australia.
- edge-currency-bitcoin v4.9.14
- Fix the BECH32 Litecoin prefix.
- edge-login-ui-rn to v0.8.0
- Re-theme the change password recovery modals.
- Fix broken links when setting up password recovery using the "share" option.

## 2.0.7 (2021-03-19)

- Brand new themed send screen and workflow
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PODS:
- disklet (0.4.5):
- React
- DoubleConversion (1.1.6)
- edge-login-ui-rn (0.8.1):
- edge-login-ui-rn (0.8.2):
- React
- FBLazyVector (0.63.4)
- FBReactNativeSpec (0.63.4):
Expand Down Expand Up @@ -737,7 +737,7 @@ SPEC CHECKSUMS:
CocoaLibEvent: 2fab71b8bd46dd33ddb959f7928ec5909f838e3f
disklet: 4f586f90b70fdb46f06614a5b7342eda5c90f253
DoubleConversion: cde416483dac037923206447da6e1454df403714
edge-login-ui-rn: 349ea377e7a4fd2068dc467a631e10789c07f38d
edge-login-ui-rn: cd93e2dcabc89a20b30cee9f7a0909b86b3e8ece
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Firebase: 458d109512200d1aca2e1b9b6cf7d68a869a4a46
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edge-react-gui",
"version": "2.0.7",
"version": "2.0.8",
"private": true,
"description": "Edge Wallet React GUI",
"homepage": "https://edge.app",
Expand Down Expand Up @@ -133,10 +133,10 @@
"edge-components": "^0.0.31",
"edge-core-js": "^0.17.29",
"edge-currency-accountbased": "^0.7.51",
"edge-currency-bitcoin": "^4.9.13",
"edge-currency-bitcoin": "^4.9.14",
"edge-currency-monero": "^0.2.9",
"edge-exchange-plugins": "^0.11.23",
"edge-login-ui-rn": "^0.8.1",
"edge-login-ui-rn": "^0.8.2",
"lodash": "^4.17.19",
"qrcode-generator": "^1.4.4",
"react": "16.13.1",
Expand Down
110 changes: 59 additions & 51 deletions src/actions/CryptoExchangeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import {
type EdgeSwapQuote,
type EdgeSwapRequest,
type EdgeSwapResult,
errorNames
} from 'edge-core-js/types'
asMaybeInsufficientFundsError,
asMaybeSwapAboveLimitError,
asMaybeSwapBelowLimitError,
asMaybeSwapCurrencyError,
asMaybeSwapPermissionError
} from 'edge-core-js'
import * as React from 'react'
import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
Expand Down Expand Up @@ -67,8 +71,9 @@ export const getQuoteForTransaction = (info: SetNativeAmountInfo) => async (disp
dispatch({ type: 'UPDATE_SWAP_QUOTE', data: swapInfo })
} catch (error) {
Actions.popTo(Constants.EXCHANGE_SCENE)
if (error.name === 'InsufficientFundsError' && error.currencyCode != null && fromCurrencyCode !== error.currencyCode) {
const { currencyCode } = error
const insufficientFunds = asMaybeInsufficientFundsError(error)
if (insufficientFunds != null && insufficientFunds.currencyCode != null && fromCurrencyCode !== insufficientFunds.currencyCode) {
const { currencyCode } = insufficientFunds
const result = await Airship.show(bridge => (
<ButtonsModal
bridge={bridge}
Expand All @@ -88,7 +93,7 @@ export const getQuoteForTransaction = (info: SetNativeAmountInfo) => async (disp
case 'exchange':
dispatch({ type: 'SHIFT_COMPLETE' })
if (fromWallet != null) {
dispatch(selectWalletForExchange(fromWallet.id, error.currencyCode, 'to'))
dispatch(selectWalletForExchange(fromWallet.id, currencyCode, 'to'))
}
break
}
Expand Down Expand Up @@ -222,7 +227,7 @@ async function fetchSwapQuote(state: RootState, request: EdgeSwapRequest): Promi
return swapInfo
}

const processSwapQuoteError = (error: any) => (dispatch: Dispatch, getState: GetState) => {
const processSwapQuoteError = (error: mixed) => (dispatch: Dispatch, getState: GetState) => {
const state = getState()
const { fromCurrencyCode, toCurrencyCode } = state.cryptoExchange

Expand All @@ -231,70 +236,73 @@ const processSwapQuoteError = (error: any) => (dispatch: Dispatch, getState: Get
if (fromCurrencyCode == null || toCurrencyCode == null) return

// Check for known error types:
switch (error.name) {
case errorNames.InsufficientFundsError: {
return dispatch({ type: 'RECEIVED_INSUFFICENT_FUNDS_ERROR' })
}
const insufficientFunds = asMaybeInsufficientFundsError(error)
if (insufficientFunds != null) {
return dispatch({ type: 'RECEIVED_INSUFFICENT_FUNDS_ERROR' })
}

case errorNames.SwapAboveLimitError: {
const settings = SETTINGS_SELECTORS.getSettings(state)
const currentCurrencyDenomination = SETTINGS_SELECTORS.getDisplayDenominationFromSettings(settings, fromCurrencyCode)
const aboveLimit = asMaybeSwapAboveLimitError(error)
if (aboveLimit != null) {
const settings = SETTINGS_SELECTORS.getSettings(state)
const currentCurrencyDenomination = SETTINGS_SELECTORS.getDisplayDenominationFromSettings(settings, fromCurrencyCode)

const nativeMax: string = error.nativeMax
const displayDenomination = SETTINGS_SELECTORS.getDisplayDenomination(state, fromCurrencyCode)
const nativeToDisplayRatio = displayDenomination.multiplier
const displayMax = UTILS.convertNativeToDisplay(nativeToDisplayRatio)(nativeMax)
const { nativeMax } = aboveLimit
const displayDenomination = SETTINGS_SELECTORS.getDisplayDenomination(state, fromCurrencyCode)
const nativeToDisplayRatio = displayDenomination.multiplier
const displayMax = UTILS.convertNativeToDisplay(nativeToDisplayRatio)(nativeMax)

return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.amount_above_limit, displayMax, currentCurrencyDenomination.name)
})
}
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.amount_above_limit, displayMax, currentCurrencyDenomination.name)
})
}

case errorNames.SwapBelowLimitError: {
const settings = SETTINGS_SELECTORS.getSettings(state)
const currentCurrencyDenomination = SETTINGS_SELECTORS.getDisplayDenominationFromSettings(settings, fromCurrencyCode)
const belowLimit = asMaybeSwapBelowLimitError(error)
if (belowLimit) {
const settings = SETTINGS_SELECTORS.getSettings(state)
const currentCurrencyDenomination = SETTINGS_SELECTORS.getDisplayDenominationFromSettings(settings, fromCurrencyCode)

const nativeMin: string = error.nativeMin
const displayDenomination = SETTINGS_SELECTORS.getDisplayDenomination(state, fromCurrencyCode)
const nativeToDisplayRatio = displayDenomination.multiplier
const displayMin = UTILS.convertNativeToDisplay(nativeToDisplayRatio)(nativeMin)
const { nativeMin } = belowLimit
const displayDenomination = SETTINGS_SELECTORS.getDisplayDenomination(state, fromCurrencyCode)
const nativeToDisplayRatio = displayDenomination.multiplier
const displayMin = UTILS.convertNativeToDisplay(nativeToDisplayRatio)(nativeMin)

return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.amount_below_limit, displayMin, currentCurrencyDenomination.name)
})
}
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.amount_below_limit, displayMin, currentCurrencyDenomination.name)
})
}

case errorNames.SwapCurrencyError: {
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.ss_unable, fromCurrencyCode, toCurrencyCode)
})
}
const currencyError = asMaybeSwapCurrencyError(error)
if (currencyError != null) {
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: sprintf(s.strings.ss_unable, fromCurrencyCode, toCurrencyCode)
})
}

case errorNames.SwapPermissionError: {
switch (error.reason) {
case 'geoRestriction': {
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: s.strings.ss_geolock
})
}
const permissionError = asMaybeSwapPermissionError(error)
if (permissionError != null) {
switch (permissionError.reason) {
case 'geoRestriction': {
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: s.strings.ss_geolock
})
}
break // Not handled
}
}

// Some plugins get this error wrong:
if (error.message === errorNames.InsufficientFundsError) {
if (error.message === 'InsufficientFundsError') {
return dispatch({ type: 'RECEIVED_INSUFFICENT_FUNDS_ERROR' })
}

// Anything else:
const typeHack: any = error
return dispatch({
type: 'GENERIC_SHAPE_SHIFT_ERROR',
data: error.message
data: typeHack.message
})
}

Expand Down
32 changes: 16 additions & 16 deletions src/actions/SendConfirmationActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// @flow

import { bns } from 'biggystring'
import type { EdgeCurrencyWallet, EdgeMetadata, EdgeParsedUri, EdgeSpendInfo, EdgeTransaction } from 'edge-core-js'
import {
type EdgeCurrencyWallet,
type EdgeMetadata,
type EdgeParsedUri,
type EdgeSpendInfo,
type EdgeTransaction,
asMaybeInsufficientFundsError
} from 'edge-core-js'
import * as React from 'react'
import { Alert } from 'react-native'
import { Actions } from 'react-native-router-flux'
Expand Down Expand Up @@ -146,10 +153,11 @@ export const sendConfirmationUpdateTx = (
.then(edgeTransaction => {
return dispatch(updateTransaction(edgeTransaction, guiMakeSpendInfoClone, forceUpdateGui, null))
})
.catch(async e => {
console.log(e)
if (e.name === 'InsufficientFundsError' && e.currencyCode != null && spendInfo.currencyCode !== e.currencyCode) {
const { currencyCode } = e
.catch(async (error: mixed) => {
console.log(error)
const insufficientFunds = asMaybeInsufficientFundsError(error)
if (insufficientFunds != null && insufficientFunds.currencyCode != null && spendInfo.currencyCode !== insufficientFunds.currencyCode) {
const { currencyCode } = insufficientFunds
const result = await Airship.show(bridge => (
<ButtonsModal
bridge={bridge}
Expand All @@ -172,7 +180,8 @@ export const sendConfirmationUpdateTx = (
break
}
}
return dispatch(updateTransaction(null, guiMakeSpendInfoClone, forceUpdateGui, e))
const typeHack: any = error
return dispatch(updateTransaction(null, guiMakeSpendInfoClone, forceUpdateGui, typeHack))
})
}

Expand Down Expand Up @@ -273,7 +282,7 @@ export const signBroadcastAndSave = (fioSender?: FioSenderInfo, walletId?: strin
try {
if (authRequired === 'pin') {
const isAuthorized = await account.checkPin(pin)
if (!isAuthorized) throw new IncorrectPinError()
if (!isAuthorized) throw new Error(s.strings.incorrect_pin)
}
edgeSignedTransaction = await wallet.signTx(edgeUnsignedTransaction)
edgeSignedTransaction = await wallet.broadcastTx(edgeSignedTransaction)
Expand Down Expand Up @@ -399,15 +408,6 @@ export const signBroadcastAndSave = (fioSender?: FioSenderInfo, walletId?: strin
}
}

const errorNames = {
IncorrectPinError: 'IncorrectPinError'
}
export function IncorrectPinError(message: ?string = s.strings.incorrect_pin) {
const error = new Error(message)
error.name = errorNames.IncorrectPinError
return error
}

export const displayFeeAlert = async (feeAmountInFiatSyntax: string) => {
const resolveValue = await Airship.show(bridge => (
<ButtonsModal
Expand Down
Binary file not shown.
6 changes: 5 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import { EdgeCoreManager } from './services/EdgeCoreManager.js'
import { ErrorBoundary } from './services/ErrorBoundary.js'
import { ThemeProvider } from './services/ThemeContext.js'

function logCrash(error: { originalError: mixed }) {
console.log('Showing crash screen:', error.originalError)
}

export function App(props: {}) {
return (
<ThemeProvider>
<ErrorBoundary FallbackComponent={CrashScene}>
<ErrorBoundary FallbackComponent={CrashScene} onError={logCrash}>
<EdgeCoreManager />
</ErrorBoundary>
</ThemeProvider>
Expand Down
4 changes: 2 additions & 2 deletions src/components/modals/FlipInputModal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import { bns } from 'biggystring'
import { errorNames } from 'edge-core-js'
import { asMaybeNoAmountSpecifiedError } from 'edge-core-js'
import * as React from 'react'
import { TouchableOpacity, View } from 'react-native'
import { type AirshipBridge } from 'react-native-airship'
Expand Down Expand Up @@ -278,7 +278,7 @@ export const FlipInputModal = connect(
// Error
const error = state.ui.scenes.sendConfirmation.error
let errorMessage
if (error && error.message !== 'broadcastError' && error.message !== 'transactionCancelled' && error.name !== errorNames.NoAmountSpecifiedError) {
if (error && error.message !== 'broadcastError' && error.message !== 'transactionCancelled' && asMaybeNoAmountSpecifiedError(error) == null) {
errorMessage = error.message
}

Expand Down
1 change: 0 additions & 1 deletion src/components/scenes/GuiPluginListScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const paymentTypeLogosById = {
applepay: 'paymentTypeLogoApplePay',
bank: 'paymentTypeLogoBankTransfer',
bankgirot: 'paymentTypeLogoBankgirot',
bpay: 'paymentTypeLogoBpay',
cash: 'paymentTypeLogoCash',
debit: 'paymentTypeLogoDebitCard',
fasterPayments: 'paymentTypeLogoFasterPayments',
Expand Down
17 changes: 14 additions & 3 deletions src/components/scenes/RequestScene.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type RequestStateProps = {
currencyCode: string,
currencyInfo: EdgeCurrencyInfo | null,
edgeWallet: EdgeCurrencyWallet,
currencyIcon?: string,
exchangeSecondaryToPrimaryRatio: number,
guiWallet: GuiWallet,
loading: false,
Expand All @@ -55,6 +56,7 @@ export type RequestLoadingProps = {
edgeWallet: null,
currencyCode: null,
currencyInfo: null,
currencyIcon?: string,
exchangeSecondaryToPrimaryRatio: null,
guiWallet: null,
loading: true,
Expand Down Expand Up @@ -291,7 +293,7 @@ export class RequestComponent extends React.PureComponent<Props, State> {
}

render() {
const { theme } = this.props
const { currencyIcon, theme } = this.props
const styles = getStyles(theme)

if (this.props.loading) {
Expand All @@ -301,7 +303,6 @@ export class RequestComponent extends React.PureComponent<Props, State> {
const { primaryCurrencyInfo, secondaryCurrencyInfo, exchangeSecondaryToPrimaryRatio, guiWallet } = this.props
const requestAddress = this.props.useLegacyAddress ? this.state.legacyAddress : this.state.publicAddress
const flipInputHeaderText = guiWallet ? sprintf(s.strings.send_to_wallet, guiWallet.name) : ''
const flipInputHeaderLogo = guiWallet.symbolImageDarkMono
const { keysOnlyMode = false } = Constants.getSpecialCurrencyInfo(primaryCurrencyInfo.displayCurrencyCode)

return (
Expand All @@ -313,7 +314,7 @@ export class RequestComponent extends React.PureComponent<Props, State> {
<ExchangedFlipInput
ref={this.flipInputRef}
headerText={flipInputHeaderText}
headerLogo={flipInputHeaderLogo}
headerLogo={currencyIcon}
primaryCurrencyInfo={primaryCurrencyInfo}
secondaryCurrencyInfo={secondaryCurrencyInfo}
exchangeSecondaryToPrimaryRatio={exchangeSecondaryToPrimaryRatio}
Expand Down Expand Up @@ -595,9 +596,19 @@ export const Request = connect(
const displayBalance = truncateDecimals(bns.div(nativeBalance, primaryDisplayDenomination.multiplier, DIVIDE_PRECISION), 6)
const balance = formatNumber(decimalOrZero(displayBalance, 6)) // check if infinitesimal (would display as zero), cut off trailing zeroes

// Icon
let currencyIcon
if (guiWallet.currencyCode === currencyCode) {
currencyIcon = guiWallet.symbolImage
} else {
const meta = guiWallet.metaTokens.find(token => token.currencyCode === currencyCode)
currencyIcon = meta ? meta.symbolImage : undefined
}

return {
currencyCode,
currencyInfo: currencyInfo || null,
currencyIcon,
edgeWallet,
exchangeSecondaryToPrimaryRatio,
guiWallet,
Expand Down
Loading

0 comments on commit 5222443

Please sign in to comment.