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

Adds clear/delete payments options #14116

Closed
wants to merge 1 commit into from

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented May 14, 2018

Resolves #8537

New options

Clear publishers option on shutdown
image

Manually clearing publishers and payment history
image

While contribution is in progress
image

Delete wallet
image

Delete wallet confirmation
image

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.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

  1. make sure that synopsis is not reset when only clear Browsing history is selected when reseting browser
  2. make sure that ledger table is cleared, but not payment history when Brave Payments attention data is selected when restarting browser
  3. make sure that ledger table is not cleared when contribution is in progress
  4. make sure that ledger table is cleared when clearing data manually Brave Payments attention data
  5. make sure that payment history is cleared when clearing data manually Brave Payments statements
  6. make sure that payment options are disabled when contribution is in progress when you are clearing data manually

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

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

@NejcZdovc NejcZdovc self-assigned this May 14, 2018
@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch 2 times, most recently from a780279 to 0a4c415 Compare May 14, 2018 08:53
@NejcZdovc NejcZdovc changed the title Adds clear payments options Adds clear/delete payments options May 14, 2018
@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch from 0a4c415 to bb8c7af Compare May 14, 2018 11:24
@bradleyrichter
Copy link
Contributor

bradleyrichter commented May 15, 2018

@NejcZdovc please change "Usage data for Brave Payments" to:

"Brave Payments attention data" in both instances.

Change "Payment history" to:

"Brave Payments statements"

@NejcZdovc
Copy link
Contributor Author

@bradleyrichter text updated, screenshots updated

@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch 2 times, most recently from 7be8e2e to 2eae85d Compare May 15, 2018 07:49
@NejcZdovc NejcZdovc added this to the 0.22.x Release 5 milestone May 22, 2018
@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch 6 times, most recently from a3a77d6 to 44bca51 Compare May 28, 2018 08:44
@NejcZdovc NejcZdovc requested review from bsclifton, jasonrsadler, kjozwiak and ryanml and removed request for bsclifton May 28, 2018 09:00
@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch 3 times, most recently from 1a0c652 to 38a27a5 Compare May 28, 2018 13:20
@@ -3123,6 +3126,53 @@ const activityRoundTrip = (err, response, body) => {
updater.checkForUpdate(false, true)
}

const deleteWallet = (state) => {
state = ledgerState.deleteSynopsis(state)
state = state.setIn(['settings', settings.PAYMENTS_ENABLED], false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make sure the file is deleted successfully before disabling payments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that this is needed, because we will delete all data related to the payments in the state, so when you run it again it should override this file if still exists

}

onToggleSetting (setting, e) {
appActions.onToggleBrowsingData(setting, e.target.value)
}

onClear () {
onClear (check) {
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this conditional to a separate function so it's clearer what's happening?

@jasonrsadler
Copy link
Contributor

Can you add steps to test plan to be able to trigger contribution without hitting the 30 minute wall?

const clearPaymentHistory = (state) => {
state = ledgerState.setInfoProp(state, 'transactions', Immutable.List())
state = ledgerState.setInfoProp(state, 'ballots', Immutable.List())
state = ledgerState.setInfoProp(state, 'batch', Immutable.List())
Copy link
Contributor

@ryanml ryanml May 28, 2018

Choose a reason for hiding this comment

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

batch should be set to Immutable.Map() here, it is of type object in bat-client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if (data) {
data.transactions = []
data.ballots = []
data.batch = []
Copy link
Contributor

Choose a reason for hiding this comment

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

See above, should be data.batch = {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

fs.accessSync(path, fs.constants.W_OK)
let data = fs.readFileSync(path)
data = JSON.parse(data)
if (data) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be helpful to set data.memos = [] in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would like to keep memos, because we use them for debugging if needed

@NejcZdovc
Copy link
Contributor Author

NejcZdovc commented May 29, 2018

@jasonrsadler this is what I normally use when debugging contributions LEDGER_ENVIRONMENT=staging LEDGER_VERBOSE=true LEDGER_NO_FUZZING=true LEDGER_NO_DELAY=true npm run start

@NejcZdovc NejcZdovc force-pushed the feature/#8537-clear branch 3 times, most recently from 3a0c827 to e681429 Compare May 29, 2018 07:11
Resolves brave#8537

Auditors:

Test Plan:
Copy link
Contributor

@ryanml ryanml left a comment

Choose a reason for hiding this comment

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

Works well, thanks for the updates 👍

NejcZdovc added a commit that referenced this pull request May 29, 2018
NejcZdovc added a commit that referenced this pull request May 29, 2018
@NejcZdovc
Copy link
Contributor Author

master 141893c
0.23 65ad358
0.22 4463ecc

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.

4 participants