Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

BAT integration (BAT Mercury) #11231

Merged
merged 14 commits into from
Oct 6, 2017
Merged

BAT integration (BAT Mercury) #11231

merged 14 commits into from
Oct 6, 2017

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented Oct 2, 2017

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #9740 - Second key for Brave Payments is not displayed on the UI after recovering wallet
Resolves #10945 - Implement BAT into payments
Resolves #11193 - Implement new add-funds wizard UI to support BAT
Resolves #11251 - Error in undefined: "getWalletProperties" on master
Resolves #11264 - Add 2 decimal places (rounded for display) to BAT wallet balance
Resolves #11278 - Ledger table data is not cleared properly
Resolves #11285 - Missing text in BAT add funds modal
Resolves #11289 - Copied text overlaps on the info message
Resolves #11292 - Brave wallet backup key 2 overflows
Resolves #11293 - Recovery keys fail both manual/import
Resolves #11308 - Transition the wallet from BTC to BAT

Test Plan:

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@codecov-io
Copy link

codecov-io commented Oct 2, 2017

Codecov Report

Merging #11231 into master will increase coverage by 0.58%.
The diff coverage is 40.56%.

@@            Coverage Diff             @@
##           master   #11231      +/-   ##
==========================================
+ Coverage   51.93%   52.52%   +0.58%     
==========================================
  Files         263      267       +4     
  Lines       24777    24984     +207     
  Branches     3948     3997      +49     
==========================================
+ Hits        12869    13122     +253     
+ Misses      11908    11862      -46
Flag Coverage Δ
#unittest 52.52% <40.56%> (+0.58%) ⬆️
Impacted Files Coverage Δ
app/locale.js 35.23% <ø> (ø) ⬆️
app/renderer/components/styles/global.js 100% <ø> (ø) ⬆️
js/constants/appConfig.js 100% <ø> (ø) ⬆️
js/constants/config.js 55.55% <ø> (ø) ⬆️
js/constants/appConstants.js 100% <ø> (ø) ⬆️
js/about/aboutActions.js 9.32% <0%> (ø) ⬆️
js/about/preferences.js 45.85% <0%> (ø) ⬆️
app/renderer/components/common/clipboardButton.js 35.48% <0%> (ø)
app/browser/tabs.js 26.08% <0%> (-0.61%) ⬇️
...rer/components/preferences/payment/ledgerBackup.js 37.83% <100%> (+1.94%) ⬆️
... and 40 more

secondaryColor
custom={[
styles.currencyIcon,
styles.ethIcon
Copy link
Contributor

Choose a reason for hiding this comment

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

how about styles.icon_currency and styles.icon_currency_eth?

secondaryColor
custom={[
styles.currencyIcon,
styles.btcIcon
Copy link
Contributor

@luixxiul luixxiul Oct 3, 2017

Choose a reason for hiding this comment

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

how about styles.icon_currency_btc like above?

also styles.icon_curerncy_ltc and styles.icon_currency_bat below.

<div>
<header data-l10n-id='addFundsWizardAddressHeader' />
<div className={css(styles.addFundsWizardAddress)}>
<main className={css(styles.addFundsWizardAddress__address)}>
Copy link
Contributor

@luixxiul luixxiul Oct 3, 2017

Choose a reason for hiding this comment

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

I'd pick styles.wizard and styles.wizard__address to shrink the length (because it should be already clear what kind of wizard it is, from the name addFundsWizardAddress). We could normalize the classnames later.

class AddFundsDialogFooter extends ImmutableComponent {
render () {
return (
<section className={css(styles.addFundsFooter)} data-test-id='AddFundsDialogFooter'>
Copy link
Contributor

@luixxiul luixxiul Oct 3, 2017

Choose a reason for hiding this comment

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

Ditto. I would pick styles.footer to shrink the classname.

<section className={css(styles.addFundsFooter)} data-test-id='AddFundsDialogFooter'>
<div className={css(styles.addFundsFooter__start)}>
<img src={upholdLogo}
className={css(styles.addFundsFooter__init__uphold_logo)}
Copy link
Contributor

Choose a reason for hiding this comment

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

As long as there is not another common element, why wouldn't you change this into styles.addFundsFooter__start__uphold_logo?

<img src={upholdLogo}
className={css(styles.addFundsFooter__init__uphold_logo)}
/>
<div className={css(styles.addFundsFooter__init__uphold_text)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto. We could replace it with styles.addFundsFooter__start__uphold_text

font-weight: 400;
-webkit-font-smoothing: antialiased;
}

strong {
font-weight: 600
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this change cause a visual regression?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so, only other <strong> tag we have is in URL bar, which is not affected by this

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. the file will eventually be removed so not a great issue anyway.

? <aside className={css(styles.dialog__header__subTitle)}>
<div className={cx({
[css(styles.dialog__header__subTitle_text)]: true,
[customTitleClassesStr]: true
Copy link
Contributor

Choose a reason for hiding this comment

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

(TODO: we would remove customTitleClassesStr etc. later to avoid cx which sometimes prevents properties from cascading properly)

Copy link
Contributor

@luixxiul luixxiul left a comment

Choose a reason for hiding this comment

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

I left some feedback. @cezaraugusto: would you please check and address them if you would agree? thanks!

@luixxiul
Copy link
Contributor

luixxiul commented Oct 3, 2017

https://travis-ci.org/brave/browser-laptop/jobs/282646416#L1292

    ERROR in ./app/renderer/components/preferences/payment/addFundsDialog/addFundsDialog.js
    Module not found: Error: Can't resolve '../../../../../extensions/brave/img/ledger/fakeQRCode.png' in '/home/travis/build/brave/browser-laptop/app/renderer/components/preferences/payment/addFundsDialog'
     @ ./app/renderer/components/preferences/payment/addFundsDialog/addFundsDialog.js 16:15-83
     @ ./app/renderer/components/preferences/paymentsTab.js
     @ ./js/about/preferences.js
     @ ./js/about/entry.js
     @ multi ./js/about/entry.js

margin: '15px 0'
},

addFundsWizardAddress__main__text_bold: {
Copy link
Contributor

Choose a reason for hiding this comment

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

redundant

<header data-l10n-id='addFundsWizardAddressHeader' />
<div className={css(styles.addFundsWizardAddress__main)}>
<main className={css(styles.addFundsWizardAddress__inputBox)}>
<GroupedFormTextbox type='text'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not be applied here? #7164 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so. works normally in this case

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for checking :-)

/>
<BrowserButton groupedItem secondaryColor
onClick={this.onClickETH}
custom={[styles.addFundsWizardMain__currencyIcon, styles.ethIcon]}
Copy link
Contributor

@luixxiul luixxiul Oct 3, 2017

Choose a reason for hiding this comment

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

styles.ethIcon -> styles.addFundsWizardMain__currencyIcon_eth

/>
<BrowserButton groupedItem secondaryColor
onClick={this.onClickBTC}
custom={[styles.addFundsWizardMain__currencyIcon, styles.btcIcon]}
Copy link
Contributor

@luixxiul luixxiul Oct 3, 2017

Choose a reason for hiding this comment

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

styles.btcIcon -> styles.addFundsWizardMain__currencyIcon_btc

/>
<BrowserButton groupedItem secondaryColor
onClick={this.onClickLTC}
custom={[styles.addFundsWizardMain__currencyIcon, styles.ltcIcon]}
Copy link
Contributor

Choose a reason for hiding this comment

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

styles.ltcIcon -> styles.addFundsWizardMain__currencyIcon_ltc

/>
<BrowserButton groupedItem secondaryColor
onClick={this.onClickBAT}
custom={[styles.addFundsWizardMain__currencyIcon, styles.batIcon]}
Copy link
Contributor

Choose a reason for hiding this comment

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

styles.batIcon -> styles.addFundsWizardMain__currencyIcon_bat

package.json Outdated
"bat-balance": "^0.9.6",
"bat-client": "^0.9.0",
"bat-publisher": "^0.9.0",
"bignumber.js": "^4.0.4",
Copy link
Member

Choose a reason for hiding this comment

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

[minor] there's a new version of bignumber.js out now https://github.com/MikeMcl/bignumber.js/

@@ -86,7 +86,6 @@ module.exports = {
pinterestExtensionPublicKey: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDB95q2hyt49ZDuVnYI91XaZhqQkbXu0X3fzoNxPxhFbfqGKwtts90LJ7lD5DCIfnBg8WGFhp3eW4GxOglAKrnksmJoyAD5PnSAufx8fD3trZvo/ZAqFx1x5Xm3Rm34EgvVXdralgHSYiqcEU/FX3kYnLLhr2TS4lcrsn1KZd/lcQIDAQAB',
metamaskExtensionId: 'nkbihfbeogaeaoehlefnkodbefgpgknn',
metamaskPublicKey: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlcgI4VVL4JUvo6hlSgeCZp9mGltZrzFvc2Asqzb1dDGO9baoYOe+QRoh27/YyVXugxni480Q/R147INhBOyQZVMhZOD5pFMVutia9MHMaZhgRXzrK3BHtNSkKLL1c5mhutQNwiLqLtFkMSGvka91LoMEC8WTI0wi4tACnJ5FyFZQYzvtqy5sXo3VS3gzfOBluLKi7BxYcaUJjNrhOIxl1xL2qgK5lDrDOLKcbaurDiwqofVtAFOL5sM3uJ6D8nOO9tG+T7hoobRFN+nxk43PHgCv4poicOv+NMZQEk3da1m/xfuzXV88NcE/YRbRLwAS82m3gsJZKc6mLqm4wZHzBwIDAQAB',
coinbaseOrigin: 'https://buy.coinbase.com',
Copy link
Member

Choose a reason for hiding this comment

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

please remove buy.coinbase.com from the CSP in app/extensions.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@diracdeltas
Copy link
Member

diracdeltas commented Oct 4, 2017

Not sure if this has been logged already, but on the welcome screen before payments is enabled:
screen shot 2017-10-04 at 10 23 46 pm

does the 'Our Partners' text need to be changed? also the FAQ links are pointing to https://brave.com/faq-payments/#brave-payments which is out of date

@diracdeltas
Copy link
Member

diracdeltas commented Oct 4, 2017

on the second screen:
screen shot 2017-10-04 at 10 26 55 pm

  1. clicking the settings button doesn't do anything, but it appears enabled instead of greyed-out
  2. clicking the 'create wallet' button also doesn't do anything - console shows ledger client error(1): "Error: HTTP response 404 for GET /v2/wallet/c2f6c9c9-c6da-4071-8ed7-fa9496923469?refresh=true&amount=5&currency=USD"

When i restart the browser and go to Payments, it shows the same error again and then the browser either crashes or the Preferences page no longer works. A non-200 response from the ledger server should not cause browser functionality to break, since this can happen any time.

NejcZdovc and others added 12 commits October 7, 2017 00:30
Resolves #9740
Resolves #10945
Resolves #11251 
Resolves #11264
Resolves #11285
Resolves #11289
Resolves #11292
Resolves #11293
Fixes balance and transactions with help of @mrose17

use "the latest and greatest" of bat-*

and also prepare for new anonymizing proxy
- remove contrib panel
- set wallet address as readonly
- set wallet adress as auto selected
- several strings change
- changed coins order in wizard
- small tweaks on design
Fixes backup key overflow
to allow GET wallet to use altcurrency parameter, as needed;
always set both amount/denomination when setting budget
unskip preferences and paymentsTab tests

Auditors: @NejcZdovc

Test Plan:
npm run test -- --grep="PaymentsTab component"
npm run test -- --grep="Preferences component unittest"

Note that this undercovered two failing tests:
npm run test -- grep="PaymentsTab component fundsamount functionality renders full balance correctly"
npm run test-- --grep="PaymentsTab component fundsamount functionality renders partial balance correctl"
Fixes clear  #11278
Fixes default monthly budget
Fixes #11308

Auditors: @NejcZdovc, @mrose17

Test Plan:
`npm run unittest -- --grep="ledger api unit tests"`
`npm run unittest -- --grep="ledgerReducer unit tests"`
Adds dynamic min ammount to the wizard

Changes min amount in note into users selected amount
Auditors: @bsclifton
Test plan:
npm run test -- --grep="add funds welcome screen"
npm run test -- --grep="add funds wizard screen"
@NejcZdovc NejcZdovc force-pushed the bat-integration branch 3 times, most recently from 5ea2529 to 32230b0 Compare October 6, 2017 23:44
@bsclifton bsclifton changed the title Bat integration BAT integration (BAT Mercury) Oct 6, 2017
bsclifton and others added 2 commits October 7, 2017 01:51
- transition is called for all wallets
- sync is now done before transition
- added logic after transition (state updated via onLedgerCallback)

Auditors: @mrose17

Set wallet to v1 if v1 properties are found
(it should be transitioned on launch)

In the roundtrip callback, add `response` to param list when calling during an error

changes default debug mode
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

We verified a $0 wallet and my personal wallet (which had $80). Both transitioned correctly

@NejcZdovc NejcZdovc merged commit ca35372 into master Oct 6, 2017
NejcZdovc added a commit that referenced this pull request Oct 7, 2017
NejcZdovc added a commit that referenced this pull request Oct 7, 2017
NejcZdovc added a commit that referenced this pull request Oct 7, 2017
NejcZdovc added a commit that referenced this pull request Oct 7, 2017
@cezaraugusto cezaraugusto deleted the bat-integration branch October 14, 2017 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants