Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Wallet] Local currency v1.1 #1137

Merged
merged 11 commits into from
Oct 1, 2019
Merged

Conversation

jeanregisser
Copy link
Contributor

Description

This PR improves support for local currencies:

  • enabled for all builds
  • auto detects currency from the user locale settings
  • adds a new setting to manually select the local currency
  • currently supported currency codes: USD, CAD, EUR, MXN, PHP
  • no local currency displayed when USD is selected

Tested

Updated tests. Changes the new currency setting, observed the selected currency rate is fetched and the displayed amounts are updated.

iTerm2 WMyOH8
iTerm2 1hLl6H

Other changes

  • Migrate to react-native-localize (formerly react-native-languages), to be able to leverage its currency API
  • Fix Sentry pod version

Related issues

Backwards compatibility

Yes.

@codecov
Copy link

codecov bot commented Sep 30, 2019

Codecov Report

Merging #1137 into master will increase coverage by 0.1%.
The diff coverage is 78.94%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1137     +/-   ##
========================================
+ Coverage   66.59%   66.7%   +0.1%     
========================================
  Files         257     259      +2     
  Lines        7394    7454     +60     
  Branches      430     498     +68     
========================================
+ Hits         4924    4972     +48     
- Misses       2375    2384      +9     
- Partials       95      98      +3
Flag Coverage Δ
#mobile 66.7% <78.94%> (+0.1%) ⬆️
Impacted Files Coverage Δ
packages/mobile/src/redux/store.ts 96% <ø> (ø) ⬆️
packages/mobile/src/config.ts 94.28% <ø> (-0.16%) ⬇️
packages/mobile/src/localCurrency/reducer.ts 58.33% <0%> (-5.96%) ⬇️
packages/mobile/src/navigator/Navigator.tsx 0% <0%> (ø) ⬆️
packages/mobile/src/i18n.ts 0% <0%> (ø) ⬆️
packages/mobile/src/account/Account.tsx 67.5% <0%> (-0.86%) ⬇️
packages/mobile/src/home/CeloDollarsOverview.tsx 100% <100%> (ø) ⬆️
packages/mobile/src/localCurrency/actions.ts 100% <100%> (ø) ⬆️
packages/mobile/src/localCurrency/consts.ts 100% <100%> (ø)
...le/src/paymentRequest/PaymentRequestReviewCard.tsx 96.29% <100%> (ø) ⬆️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0393811...7633275. Read the comment docs.

import { headerWithCancelButton } from 'src/navigator/Headers'
import { navigateBack } from 'src/navigator/NavigationService'

const DEFAULT_CURRENCY_CODE = 'USD'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, how about using your currency enum here instead of a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 👍

throw new Error("Can't fetch local currency rate without a currency code")
}
const rate = yield call(fetchExchangeRate, localCurrencyCode)
yield put(fetchCurrentRateSuccess(localCurrencyCode, rate, Date.now()))
} catch (error) {
Logger.error(`${TAG}@fetchLocalCurrencyRateSaga`, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to yield put(showError... here with a custom message

Copy link
Contributor Author

@jeanregisser jeanregisser Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a background task, I think it would be a surprising experience to have an error banner displayed on unrelated screens.

I'm thinking also specifically about the case where the blockchain api endpoint is down and this error would trigger continuously until it succeeds. Pretty annoying for the user.
We would need additional logic to ensure we don't display the error too often.

In conclusion, I'd rather avoid that for now and keep it as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point :)

@@ -8,7 +8,6 @@ interface Props {
word: string
selected: boolean
onSelectAnswer: (word: string, data: any) => void
key: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm this doesn't affect the other consumers of this component (the language selection screen and the backup phrase quiz)?

Copy link
Contributor Author

@jeanregisser jeanregisser Oct 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked it doesn't affect other consumers of this component 👍

The key property is implicitly handled by React. The explicit type addition here wasn't necessary, I guess the intention was to force consumers of SelectionOption to pass it? Passing or not key depends on the usage. This PR showed a new use case which doesn't require it (FlatList items are already wrapped by keyed components).

@jmrossy
Copy link
Contributor

jmrossy commented Oct 1, 2019

Really nice work! Just a few small comments

Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@jeanregisser jeanregisser merged commit 41103b2 into master Oct 1, 2019
@jeanregisser jeanregisser deleted the jeanregisser/local-currency-v1.1 branch October 1, 2019 12:48
aaronmgdr added a commit that referenced this pull request Oct 1, 2019
* master: (31 commits)
  Upgrade to Node 10 (#1148)
  [faucet] Add custom metrics (#1143)
  Add IdentityMetadata to Contractkit (#1126)
  [Wallet] Local currency v1.1 (#1137)
  Add attestation-service deploy (#1128)
  [Wallet] A few docs and build cleanup (#1138)
  [CircleCI]Add comment on how to fix lint checks (#1134)
  2019-09-30 integration deployment (#1149)
  Update web3 provider to new integration url (#1151)
  [celotool]Add fast mode to celotool invite (#1135)
  Revert "Feature/909 proxy delegatecall" (#1146)
  Use contractkit in notification service (#1118)
  Feature/909 proxy delegatecall (#1003)
  integration deployment for 2019-09-29 (#1139)
  Add instructions for npm publication to tag commit (#1117)
  Client Logs Data Flow script update (#1055)
  Deploying latest proxy code in genesis (#1122)
  Enable floating promises check everywhere (fix issues) (#1115)
  [cli] Solution for build error contractkit on Linux 19.04 distro (#960)
  [Wallet] Merge back changes made for mx pilot (#1113)
  ...

# Conflicts:
#	yarn.lock
aaronmgdr added a commit that referenced this pull request Oct 1, 2019
* master: (35 commits)
  [Wallet] Network fee in transaction feed (#1145)
  New About Page Cover (#905)
  Upgrade to Node 10 (#1148)
  [faucet] Add custom metrics (#1143)
  Add IdentityMetadata to Contractkit (#1126)
  [Wallet] Local currency v1.1 (#1137)
  Add attestation-service deploy (#1128)
  [Wallet] A few docs and build cleanup (#1138)
  [CircleCI]Add comment on how to fix lint checks (#1134)
  2019-09-30 integration deployment (#1149)
  Update web3 provider to new integration url (#1151)
  [celotool]Add fast mode to celotool invite (#1135)
  Revert "Feature/909 proxy delegatecall" (#1146)
  Use contractkit in notification service (#1118)
  Feature/909 proxy delegatecall (#1003)
  integration deployment for 2019-09-29 (#1139)
  Add instructions for npm publication to tag commit (#1117)
  Client Logs Data Flow script update (#1055)
  Deploying latest proxy code in genesis (#1122)
  Enable floating promises check everywhere (fix issues) (#1115)
  ...

# Conflicts:
#	packages/web/src/about/About.tsx
#	packages/web/src/about/images/index.ts
#	packages/web/static/locales/en/about.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local Currency V1.1
2 participants