Skip to content

Commit

Permalink
Allow TypedDataUtils to be called unbound
Browse files Browse the repository at this point in the history
Previously the functions exposed as `TypedDataUtils` could only be
called from the `TypedDataUtils` object. If they were called unbound,
they would throw errors because of the use of `this`.

They have all been updated to no longer rely upon `this`, so they now
work the same way regardless how they are bound when called.

They are still exported as the `TypedDataUtils` object, so this should
not change the API. This was done to simplify the code, specifically to
make it easier for functions outside of `TypedDataUtils` to reuse code
inside of `TypedDataUtils`.

Some types required adjustments, as type mistakes were brought to light
that TypeScript for some reason wasn't aware of when these were
declared as properties of the `TypedDataUtils` object. These were fixed
by adding two type assertions, and by making the `types` parameter to
`hashStruct` more strict. The type assertions (warranted or not)
preserve the types used previously. We can replace them later with
validation.
  • Loading branch information
Gudahtt committed Jul 14, 2021
1 parent c48e15c commit 910deeb
Show file tree
Hide file tree
Showing 2 changed files with 357 additions and 219 deletions.
Loading

0 comments on commit 910deeb

Please sign in to comment.