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

[Flask] RNTar Android native module for snaps installation #6300

Merged
merged 7 commits into from
May 9, 2023

Conversation

owencraston
Copy link
Contributor

@owencraston owencraston commented Apr 28, 2023

Development & PR Process

  1. Follow MetaMask Mobile Coding Standards
  2. Add release-xx label to identify the PR slated for a upcoming release (will be used in release discussion)
  3. Add needs-dev-review label when work is completed
  4. Add needs-qa label when dev review is completed
  5. Add QA Passed label when QA has signed off

Description

  • This change is being merged into the flask branch and will have failing tests. This is expected for now and we will address the failing tests (that also exist in the flask branch) as we get closer to a stable release.

1. What is the reason for the change?

  • this PR enables the installation of snaps from NPM/Dapps

2. What is the improvement/solution?

  • similar to the work done in this PR, I have created a android native module that reads a .tgz file (the type of file we get from NPM) and extracts its content to the device. We then pass the location of that extracted content to the snaps code and it reads it into the SnapsController.
  • I also write some basic tests for this native module that required adding some new dependacies
  • To extract the tgz content, I needed to install/use the Apache commons compress library into the Android project.

Screenshots/Recordings

working.on.android.2.mov

Issue

Progresses https://github.com/MetaMask/mobile-planning/issues/731

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@owencraston owencraston force-pushed the snaps/android-npm-install branch from 7358076 to 604744e Compare April 28, 2023 19:42
@owencraston owencraston changed the title RNTar native module [Flask] RNTar Android native module Apr 28, 2023
@owencraston owencraston force-pushed the snaps/android-npm-install branch from 604744e to c93da4d Compare April 28, 2023 19:53
@owencraston owencraston force-pushed the snaps/android-npm-install branch from 469e3cf to 0a95a9d Compare May 4, 2023 00:06
@owencraston owencraston marked this pull request as ready for review May 4, 2023 00:09
@owencraston owencraston requested a review from a team as a code owner May 4, 2023 00:09
@owencraston owencraston changed the title [Flask] RNTar Android native module [Flask] RNTar Android native module for snaps installation May 4, 2023
* @param errorMessage - The error message to throw if validation fails.
*/
function validateSnapShasum(manifest, sourceCode, errorMessage = 'Invalid Snap manifest: manifest shasum does not match computed shasum.') {
- if (manifest.source.shasum !== getSnapSourceShasum(sourceCode)) {
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 was unable to make this implementation work with the Shasum validation (the results are different on Android) so I am disabling it for now and will try to get it working in a future change. The issue to track this work can be found here.

@owencraston owencraston added the No QA Needed Apply this label when your PR does not need any QA effort. label May 4, 2023
Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

I only had a look at the java part.
It looks good overall, mostly comments with just one memory leak risk on the resource not closing: not sure there's reasons for leak to actually happen, but better using a try/finally or try with resource in case, who knows.

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Nice work! Java part looks safer. Making the code ready for when we will upgrade min sdk is great! (will ease work later)

@owencraston owencraston merged commit 9eee3b9 into flask May 9, 2023
@owencraston owencraston deleted the snaps/android-npm-install branch May 9, 2023 17:48
@github-actions github-actions bot locked and limited conversation to collaborators May 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
No QA Needed Apply this label when your PR does not need any QA effort.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants