Skip to content

Enable re-linking when a user connects an Uphold wallet #8180

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

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

zenparsing
Copy link
Collaborator

Resolves brave/brave-browser#14573

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

With an Uphold-connected profile:

  • Start the browser
  • Navigate to brave://rewards and disconnect the Uphold account.
  • Clear logs.
  • Navigate to brave://rewards and connect an Uphold wallet.
  • View logs.
    • Verify that a call was made to /v3/wallet/uphold/{payment_id}/claim and a 200 response was returned.

@zenparsing zenparsing self-assigned this Mar 8, 2021
@zenparsing zenparsing requested review from a team, bsclifton, deeppandya and emerick and removed request for a team March 9, 2021 17:58
Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM

@zenparsing zenparsing merged commit dfe20f4 into master Mar 9, 2021
@zenparsing zenparsing deleted the ksmith-uphold-relinking branch March 9, 2021 18:01
@zenparsing zenparsing added this to the 1.23.x - Nightly milestone Mar 9, 2021
brave-builds pushed a commit that referenced this pull request Mar 10, 2021
@LaurenWags
Copy link
Member

LaurenWags commented Mar 16, 2021

Verified using

Brave	1.23.41 Chromium: 89.0.4389.90 (Official Build) nightly (x86_64)
Revision	62eb262cdaae9ef819aadd778193781455ec7a49-refs/branch-heads/4389@{#1534}
OS	macOS Version 10.15.7 (Build 19H524)
Verified test plan from PR description

After disconnecting the wallet, I saw the below in my logs:

[Mar 16, 2021, 4:13:31.9 PM:INFO:uphold.cc(196)] Disconnecting wallet

Confirmed UI showed wallet as disconnected:

brave://rewards brave://rewards-internals panel
testplan-rewards testplan-internals testplan-panel

Reconnected Uphold wallet on brave://rewards:

brave://rewards brave://rewards-internals panel
1 2 3

Confirmed I see linking request in the logs:

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/c.............5/claim
> Method: UrlMethod::POST
> Content: {"signedLinkingRequest":"ey.............
> Content Type: application/json; charset=utf-8
[Mar 16, 2021, 4:17:46.1 PM:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/c...............5/claim
> Result: Success
> HTTP Code: 200
> Body: null

Checked able to reconnect/relink from panel as well:

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/c..........5/claim
> Method: UrlMethod::POST
> Content: {"signedLinkingRequest":"ey............
> Content Type: application/json; charset=utf-8
[Mar 16, 2021, 4:21:07.7 PM:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/c...........5/claim
> Result: Success
> HTTP Code: 200
> Body: null
Confirmed Ad grants claimed while wallet is not linked on server get sent to Uphold after re-linking occurs
  1. Clean profile, join staging rewards, connect a KYC'd Uphold account
initial-linking
  1. Asked Ben H to remove my wallet link on the server (make it so my paymentId was not linked to my Uphold wallet)
  2. Once step 2 is completed, asked Chris to send me a staging Ad grant to my paymentId
  3. After ~10 min, the ad grant showed up in the browser and I claimed it using captcha
  4. Confirm Ad grant BAT not sent to Uphold
brave://rewards brave://rewards-internals
panel-adgrant internals-adgrant

Confirmed in Uphold Transactions list that the ad grant is not ported to Uphold.

Browser tries to send claimed ad grant to uphold, but it fails:

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v1/suggestions/claim
> Method: UrlMethod::POST
> Content: {"credentials":[{"publicKey":"cvdPwa.....................
> Content Type: application/json; charset=utf-8
> Header digest: SHA-256=YVW4MDeDoU0ppgBp6n1VgHvs94TkIgDAPV1+sSX6kfk=
> Header signature: keyId="b0.........................
> Header accept: application/json
[43663:775:0316/153530.101920:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v1/suggestions/claim
> Result: Failure
> HTTP Code: 400
> Body: {"message":"Error draining: Wallet is not verified","code":400}
[43663:775:0316/153530.102054:INFO:post_suggestions_claim.cc(60)] Invalid request
[43663:775:0316/153530.102107:INFO:credentials_promotion.cc(489)] Failed to parse redeem tokens response
[43663:775:0316/153530.102155:INFO:wallet.cc(149)] Claiming tokens failed
  1. Click on "Wallet Verified" and disconnect from Uphold
brave://rewards brave://rewards-internals
rewards-disconnected internals-disconnected
[43663:775:0316/153929.793941:VERBOSE1:uphold.cc(196)] Disconnecting wallet
  1. Click on "Disconnected" to reconnect to Uphold and confirm re-link made.
brave://rewards brave://rewards-internals Uphold Transactions List
rewards-reconnect internals-reconnect Uphold-txn
[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/b..............7/claim
> Method: UrlMethod::POST
> Content: {"signedLinkingRequest":"eyJ........................
> Content Type: application/json; charset=utf-8
[43663:775:0316/154100.106195:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/b................7/claim
> Result: Success
> HTTP Code: 200
> Body: null

Confirmed ad grant ported to Uphold

[ REQUEST ]
> URL: https://grant.rewards.bravesoftware.com/v1/suggestions/claim
> Method: UrlMethod::POST
> Content: {"credentials":[{"publicKey":"cvd....................
> Content Type: application/json; charset=utf-8
> Header digest: SHA-256=YVW4MDeDoU0ppgBp6n1VgHvs94TkIgDAPV1+sSX6kfk=
> Header signature: keyId="b0............................
> Header accept: application/json
[43663:775:0316/154100.695098:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.bravesoftware.com/v1/suggestions/claim
> Result: Success
> HTTP Code: 200
> Body: 
Confirm not disconnected from Uphold on upgrade

Installed 1.21.77 on staging and connected KYC'd uphold account.

Close 1.21.x and rename profile to Nightly.

Launch with 1.23.41, confirm you are not disconnected from Uphold and can still tip a KYC'd publisher.

1.21.77 1.23.41 Tip to KYC'd publisher Tip shown in Uphold Transactions
Screen Shot 2021-03-16 at 4 33 54 PM Screen Shot 2021-03-16 at 4 36 01 PM Screen Shot 2021-03-16 at 4 39 15 PM Screen Shot 2021-03-16 at 4 39 05 PM

@srirambv
Copy link
Contributor

srirambv commented Mar 18, 2021

  • Verified disconnecting an existing wallet work
2021-03-18 05:00:29.023 26676-26676/? V/chromium: [VERBOSE1:uphold.cc(196)] Disconnecting wallet
  • Verified after connecting the wallet again got the confirmation of existing wallet
2021-03-18 08:12:20.631 26676-26676/? V/chromium: [VERBOSE1:wallet_create.cc(35)] Wallet already exists
2021-03-18 08:12:20.637 26676-26676/? V/chromium: [VERBOSE5:ledger_impl.cc(139)] 
    [ REQUEST ]
    > URL: https://api-sandbox.uphold.com/oauth2/token
    > Method: UrlMethod::POST
    > Content: code=2a...................................0&grant_type=authorization_code
    > Content Type: application/x-www-form-urlencoded
2021-03-18 08:12:24.645 26676-26676/? V/chromium: [VERBOSE5:ledger_impl.cc(139)] 
    [ REQUEST ]
    > URL: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/a0.../claim
    > Method: UrlMethod::POST
    > Content: {"signedLinkingRequest":"eyJ....."}
    > Content Type: application/json; charset=utf-8
  • Verified able to reconnect/relink from panel as well
2021-03-18 08:12:25.895 26676-26676/? V/chromium: [VERBOSE6:logging_util.cc(136)] 
    [ RESPONSE - OnRequest ]
    > Url: https://grant.rewards.bravesoftware.com/v3/wallet/uphold/a0.../claim
    > Result: Success
    > HTTP Code: 200
    > Body: null
Disconnected Connected
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempt Uphold wallet relinking more often
4 participants