Skip to content

Add try/catch for assetsContract.getBalanceOf - #328

Merged
rickycodes merged 11 commits into
developfrom
bugfix/token-balance-shows-0
Jan 22, 2021
Merged

rickycodes merged 11 commits into
developfrom
bugfix/token-balance-shows-0

Conversation

@rickycodes

@rickycodes rickycodes commented Jan 19, 2021 •

Copy link
Copy Markdown
Contributor

@rickycodes
rickycodes requested a review from a team as a code owner January 19, 2021 22:49
@rickycodes
rickycodes force-pushed the bugfix/token-balance-shows-0 branch from 2f0a413 to 1296469 Compare January 19, 2021 23:19
Comment thread src/assets/TokenBalancesController.ts
@rickycodes
rickycodes force-pushed the bugfix/token-balance-shows-0 branch from af7ad92 to 75ad094 Compare January 21, 2021 04:56
Gudahtt
Gudahtt previously approved these changes Jan 21, 2021

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Comment thread tests/TokenBalancesController.test.ts

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@andrepimenta andrepimenta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! 👍

@rickycodes
rickycodes merged commit 9169e2b into develop Jan 22, 2021
@rickycodes
rickycodes deleted the bugfix/token-balance-shows-0 branch January 22, 2021 16:22
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
* Request validation should not throw if verifyingContract is not defined in typed signature (#328) (#330)

* 14.0.1 (#331)

---------

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
* Request validation should not throw if verifyingContract is not defined in typed signature (#328) (#330)

* 14.0.1 (#331)

* [14.x] fix: support ethermint's EIP712 implementation (#333)

* setting cosmos as allowed string for verifyingContract field

* fixed and linter

* readability

* Update condition to match main branch

* Remove duplicate copy of test

---------

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Version 14.0.2 (#339)

* Version 14.0.2

* Fix typo

Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>

---------

Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>

---------

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Co-authored-by: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com>
Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Sep 13, 2026
Replaces MetaMask#324, which GitHub auto-closed as merged during a stack reorder
when its head briefly became an ancestor of its base. The changes never
reached `main`; this carries the same two commits.

Mirrors
[MetaMask#9976](MetaMask#9976), the
bottom of core's foundational stack.

| | Before | After |
| --- | --- | --- |
| `engines.node` | `^18.18 \|\| ^20.14 \|\| >=22` | `^22.14.0 \|\| ^24`
|
| `@types/node` | `~18.18.14` | `^22.13.14` |
| CI matrix | 18, 20, 22 | 22, 24 |

`constraints.pro` is updated so `yarn constraints` enforces the new
range. Core makes the `@types/node` bump in this same PR rather than
with its TypeScript change, since the types track the supported runtime.

## Position in the stack

This now sits **below** the ESM conversion (MetaMask#323), so everything up to
and including this PR is still a hybrid CJS/ESM build:

```
main → … → MetaMask#322 → this → MetaMask#323 (ESM only) → MetaMask#325 (TypeScript)
```

That matters for testing. A preview build from here still resolves
through `main: ./dist/index.cjs` with the `require` condition intact, so
it can be consumed by `metamask-extension` as-is. Everything below the
ESM cut can therefore be verified against a real downstream consumer
before the breaking change lands.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Semver-breaking runtime requirement may block consumers still on Node
18 or 20; in-repo changes are mostly policy, CI, and test cleanup with
limited logic impact.
> 
> **Overview**
> **Breaking:** supported Node is now `^22.14.0 || ^24` instead of
18/20/22. That is enforced in `package.json`, `constraints.pro`, and
documented under Unreleased in `CHANGELOG.md`.
> 
> CI **prepare**, **test**, and **compatibility-test** jobs now run on
Node **22.x** and **24.x** only (18 and 20 dropped from the matrix). Dev
typings move from `@types/node` ~18 to **^22.13.14**, with matching
`yarn.lock` updates.
> 
> Test and lint tooling align with the new floor: ESLint comments for
`n/no-unsupported-features/node-builtins` reflect that global `crypto`
is expected on 22+, and `hashing.test.ts` drops the Node 18 `webcrypto`
polyfill/`beforeEach` setup—tests assume `globalThis.crypto.subtle`
exists.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
ba81eca2d4fa1d9a00faa1bd7e975d1b5d02fc8d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Sep 13, 2026
Top of stack MetaMask#331, on MetaMask#325. Mirrors
[MetaMask#10019](MetaMask#10019), the
last of core's foundational chain.

| | Before | After |
| --- | --- | --- |
| `target` | `ES2020` | `ES2022` |
| `lib` | `["ES2020", "DOM"]` | `["ES2022", "DOM"]` |

Correctly last in the order: raising the emit target is only defensible
once the Node floor guarantees the runtime supports it, which MetaMask#328
established.

## It is not cosmetic

`wrapError` sets `cause` behind two `@ts-ignore` comments, with this
note in the source:

> Error causes are not supported by our current tsc target (ES2020, we
need ES2022 to make this work)

`Error.cause` is ES2022, so both suppressions are now obsolete and are
removed. The types are genuine rather than ignored.

The evidence came from enabling test type checking: with `lib: ES2020` a
`tsc` pass over the tests reports **11 errors**, nearly all `Property
'cause' does not exist`. With `lib: ES2022` it reports **zero**. That is
why the type checking PR stacks on top of this one rather than below it.

## Verification

Build, tests, tsd, eslint and lint all pass.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Breaking for consumers on older runtimes or TS configs that assumed
ES2020 output; error utilities are widely used but the change is
configuration and type hygiene rather than new logic.
> 
> **Overview**
> **BREAKING:** Raises the TypeScript **`target`** and **`lib`** from
**ES2020** to **ES2022**, so published output expects a modern runtime
or bundler that can consume ES2022. The unreleased changelog documents
this alongside the existing Node/ESM breaking changes.
> 
> In **`wrapError`**, the **`Error(message, { cause })`** path no longer
needs **`@ts-ignore`** or the comment about ES2020 lacking
**`Error.cause`** types—ES2022 **`lib`** makes **`cause`** a first-class
typed option.
> 
> No runtime behavior change in **`wrapError`** beyond what was already
implemented; this is primarily a compile/emit floor and type-checking
cleanup that unblocks stricter test **`tsc`** (e.g. **`cause`** on
errors) in follow-up work.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6242b3e584a89dd8a4adf7a3c06c8439ab6ede4b. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants