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

fix: Convert BN to hexadecimal when balance from chain is defined #3933

Closed
wants to merge 1 commit into from

Conversation

tommasini
Copy link
Contributor

Explanation

Currently, we are trying to convert to hexadecimal a balance that is undefined because ethQuery is not initialized yet and we are not able to fetch the balance.

References

Changelog

@metamask/assets-controllers

  • : Added condition on refresh function to only convert to hexadecimal if balance is defined

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@tommasini tommasini requested a review from a team as a code owner February 19, 2024 21:49
@tommasini
Copy link
Contributor Author

Wondering if we could expose a loading statement from this controller, for the client know when ethQuery is defined

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Ah... this bug would have been caught if BNToHex did not take any as its argument. This is being addressed via #3717.

In any case, would you mind adding a test for this?

@mcmire
Copy link
Contributor

mcmire commented Feb 26, 2024

Wondering if we could expose a loading statement from this controller, for the client know when ethQuery is defined

With regard to your question here, I think the proper pattern we should look into adopting is that controllers should not be initialized until a provider (and thus an ethQuery instance) is available. This way provider or ethQuery can never be undefined. But, perhaps that is not possible in every case.

tommasini added a commit to MetaMask/metamask-mobile that referenced this pull request Feb 27, 2024
## **Description**
We were experiencing `undefined is not an object (evaluating
'inputBn.toString')` this warning multiple times when opening the app,
because `this.ethQuery` it was not defined yet at the
`AccountTrackerController` when .

It was added a condition to only update the balance if it was possible
to get balance from chain.


Core PR: MetaMask/core#3933

## **Related issues**

Fixes:

## **Manual testing steps**

1. Open the app
2. Shouldn't have the warning `undefined is not an object (evaluating
'inputBn.toString')`
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

e

Smoke E2E test builds:
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a075edf7-676e-4d24-8b0d-014890863b6d

Regression E2E test builds:
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/30f56c4e-3811-432c-83f0-139ea5b16ff5


## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [x] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
@cryptodev-2s
Copy link
Contributor

this fix will be addressed in #3975.

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.

3 participants