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

NFT pinning improvements #17983

Merged
merged 7 commits into from
Apr 14, 2023
Merged

NFT pinning improvements #17983

merged 7 commits into from
Apr 14, 2023

Conversation

cypt4
Copy link
Collaborator

@cypt4 cypt4 commented Apr 10, 2023

Update wallet NFT pinning state if setting changes
Resolves brave/brave-browser#29354

Don't show pinning status if autopin is disabled
Resolves brave/brave-browser#29553

Improve NFT pinning queue
Resolves brave/brave-browser#29551

Fixes pinning after wallet reset
brave/brave-browser#29207

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
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • 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 wiki
    • npm run lint, npm run presubmit wiki, 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:

  1. Switch autopin setting on the settings page - check that feature status is changed on the wallet page ( Disabling Automatically pin NFTs settings doesn't update the IPFS banner on portfolio/nft page brave-browser#29354)
  2. Check that pinning statuses are hidden when setting is off ( Clearing pinned NFT still shows NFT data is being pinned to your local IPFS node on NFT details screen brave-browser#29553)
  3. Check case described in Adding NFT from the same collection doesn't show the pinning state until browser restart brave-browser#29551
  4. Check case described in NFT pinning not started after wallet reset until browser is restarted brave-browser#29207

@cypt4 cypt4 requested review from a team as code owners April 10, 2023 20:45
@github-actions github-actions bot added CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet feature/web3/wallet/core labels Apr 10, 2023
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Contributor

@muliswilliam muliswilliam left a comment

Choose a reason for hiding this comment

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

LGTM

pref_change_registrar_ = std::make_unique<PrefChangeRegistrar>();
pref_change_registrar_->Init(pref_service_);
pref_change_registrar_->Add(
kAutoPinEnabled,
base::BindRepeating(&BraveWalletAutoPinService::OnAutoPinStatusChanged,
weak_ptr_factory_.GetWeakPtr()));
base::Unretained(this)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs another weak_ptr_factory for invalidating in OnAutoPinStatusChanged

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 102 to 104
auto intent =
std::make_unique<IntentData>(token, Operation::kAdd, absl::nullopt);
AddOrExecute(std::move(intent));
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need in temp variable here and below

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 232 to 239
if (v->token == data->token && v->service == data->service &&
v->operation == data->operation) {
return;
}
}
if (current_ && current_->token == data->token &&
current_->service == data->service) {
current_->service == data->service &&
current_->operation == data->operation) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Duplicated equality check algorithm

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


if (data->operation == Operation::kAdd ||
data->operation == Operation::kValidate) {
if (tokens_.find(data->token) == tokens_.end()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

base::Contains

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

if (isNftAsset && selectedAsset && nftPinnable) {
return getNftPinningStatus(selectedAsset)
}
return undefined
}, [nftPinnable, isNftAsset, selectedAsset, nftPinningStatus])
}, [nftPinnable, isNftAsset, selectedAsset, nftPinningStatus, isAutoPinEnabled])
Copy link
Collaborator

Choose a reason for hiding this comment

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

nftPinningStatus is not referenced in useMemo body, need it here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

getNftPinningStatus is dependent on nftPinningStatus i guess

Copy link
Collaborator

@supermassive supermassive left a comment

Choose a reason for hiding this comment

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

LGTM with minor issues to fix

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

@linhkikuchi linhkikuchi merged commit 0f56b39 into master Apr 14, 2023
@linhkikuchi linhkikuchi deleted the brave_29493_1 branch April 14, 2023 08:56
@github-actions github-actions bot added this to the 1.52.x - Nightly milestone Apr 14, 2023
brave-builds added a commit that referenced this pull request Apr 14, 2023
@srirambv
Copy link
Contributor

Verification passed on

Brave 1.52.47 Chromium: 112.0.5615.121 (Official Build) nightly (64-bit)
Revision 39cc4e45904ae9f1741c4fbaa866e629c96f2268-refs/branch-heads/5615_51@{#8}
OS Windows 11 Version 22H2 (Build 22621.1555)
  • Verified the following issues
https://github.com/brave/brave-browser/issues/29354 - Passed
  • Verified disabling Automatically pin NFTs setting auto-updates the IPFS banner on Portfolio/NFT page
17983-1.mp4
https://github.com/brave/brave-browser/issues/29553 - Passed
  • Verified clearing pinned NFT doesn't show any pin status on the NFT
17983-2.mp4
https://github.com/brave/brave-browser/issues/29551 - Passed
  • Verified adding an NFT from the same collection automatically shows the pinning status and doesn't require browser restart
17983-3.mp4
https://github.com/brave/brave-browser/issues/29207 - Passed
  • Verified after resetting wallet newly added NFT in new wallet automatically starts pinning if the auto pin nft setting is enabled.
17983-4.mp4

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