-
Notifications
You must be signed in to change notification settings - Fork 920
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) Implement NFT asset details screen #16671
Conversation
android/java/org/chromium/chrome/browser/crypto_wallet/activities/NftDetailActivity.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/activities/NftDetailActivity.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check lint, but ++ otherwise
Is there a security review for this? Particularly SVG support. CC @kdenhartog |
@diracdeltas, requested a security review: https://github.com/brave/security/issues/1168. |
android/java/org/chromium/chrome/browser/crypto_wallet/activities/NftDetailActivity.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/activities/NftDetailActivity.java
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/activities/NftDetailActivity.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/fragments/PortfolioFragment.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/fragments/PortfolioFragment.java
Outdated
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/util/AndroidUtils.java
Show resolved
Hide resolved
android/java/org/chromium/chrome/browser/crypto_wallet/util/Utils.java
Outdated
Show resolved
Hide resolved
We haven't added SVG support with any new lib yet so no security review is needed for now. |
android/java/org/chromium/chrome/browser/crypto_wallet/fragments/PortfolioFragment.java
Outdated
Show resolved
Hide resolved
71f4d1c
to
1b4c20c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One non blocker from me and I see you've addressed the concern about arbitrary URL file types by limiting this to Network and Data URLs only. LGTM
String networkName = defaultNetwork.chainName; | ||
mNetworkNameView.setText(networkName); | ||
String blockExplorerUrl = defaultNetwork.blockExplorerUrls.length > 0 | ||
? defaultNetwork.blockExplorerUrls[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non blocking: is there a reason this needs to be an array if we're just grabbing the first index here always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a Mojom
generated NetworkInfo
class to get response data of network as an object from backend so it cannot be changed as it's being used across platforms and since there can be 0,1 or 1+ values so array is the ideal type for this kind of data. Changing this would require changes across platforms, backend and there could be a use case where more than the first url is being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good question!
The blockExplorerUrls
is an array because some tokens may have multiple blockchain explorer endpoints, this could be useful in case one endpoint is down. Of course, we should add the required logic on top where we check if an endpoint is down and process the next one if present. (It could be an improvement to implement in the future).
Another constraint to consider is about our current configuration as well: NetworkInfo.java
(defaultNetwork
) is a Java class generated by the mojo binding generator. So the original type is a struct
defined in brave_wallet.mojom
here.
Not savvy enough to know how much room we have to modify these mojom
files. I'm sure @SergeyZhukovsky could tell us more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spotted one blocker to make sure we're disabling support for http. Also one other non blocker for resolving IPFS content which we could do via a gateway if we don't have support for nodes in Android (which I'm pretty sure is the case)
@@ -51,6 +45,6 @@ public static boolean isSvg(String url) { | |||
} | |||
|
|||
private static boolean isValidImgUrl(String url) { | |||
return !TextUtils.isEmpty(url); | |||
return URLUtil.isDataUrl(url) || URLUtil.isNetworkUrl(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocker: Just double checked brave-core and noticed that we support only HTTPS here, so going to block to make sure we're not supporting http URLs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case http
, we should
- Not load the URL
- Try replacing it with
https
before loading?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm going to replace URLUtil.isNetworkUrl(url)
with URLUtil.isHttpsUrl(url)
. Doing so, only HTTPS will be allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in this commit 👉 66efe7e
(#16671)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
android/java/org/chromium/chrome/browser/crypto_wallet/util/ImageLoader.java
Outdated
Show resolved
Hide resolved
@kdenhartog security feedback addressed. Re-requesting your review, thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. All security concerns have been addressed
Improve performance and (more importantly) fix serialization as inner classes hold a reference to their outer class when non-static.
Makes sure the URL is a data URL that starts with `data:`, or a network URL that starts with `http` or `https`.
66efe7e
to
b97dc59
Compare
Implements new NFT asset detail screen supporting GIF, BMP, PNG and JPG images. (cherry picked from commit 15fd2dc)
Verification passed on Oppo Reno 5 with Android 13 running 1.49.75 x64 Nighty build
16671.mp4 |
Resolves brave/brave-browser#27276
Implements new NFT asset detail screen supporting GIF, BMP, PNG and JPG images.
demo.mov
Security Review
Requested security review: https://github.com/brave/security/issues/1168.
Related Issues
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
(E.g
0x59468516a8259058bad1ca5f8f4bff190d30e066
, id183
- Invisible Friends)