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

feat(human-readable): parse EIP712 human-readable type signatures #166

Closed
wants to merge 18 commits into from

Conversation

Raiden1411
Copy link
Collaborator

@Raiden1411 Raiden1411 commented Jul 12, 2023

Description

This PR adds support for EIP712 typed data signatures.

Essentially the typed data human readable signature is represented as a struct signature. This however differs from Abi structs, since this will follow the specifications introduced in EIP712.

The new parseTypedData function parses in two contexts. Either if you want to create and resolve the typed data or simply want to create it (the latter is the default behavior).

This also introduces a couple of new types for consumers to use. ParseTypedData, ResolveTypedData, ResolvedTypedData and ResolvedTypedDataToPrimativeTypes.

Examples were created to demonstrate this new pattern and the documentation also reflects these changes.

Additional Information

  • I read the contributing guide
  • I added documentation related to the changes made.
  • I added or updated tests related to the changes made.

Your ENS/address:


PR-Codex overview

This PR adds human-readable EIP-712 parsing utilities and resolves typed data into corresponding Solidity primitive types.

Detailed summary

  • Added parseTypedData function to parse human-readable typed data into EIP-712 typed data.
  • Added MissingNamedParameter error class for missing named parameters in EIP-712 typed data.
  • Updated typings and dependencies.

The following files were skipped due to too many changes: src/utils.ts, src/human-readable/parseTypedData.ts, src/human-readable/runtime/structs.ts, src/human-readable/parseTypedData.test.ts, examples/signTypedData.test-d.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@changeset-bot
Copy link

changeset-bot bot commented Jul 12, 2023

🦋 Changeset detected

Latest commit: e917c51

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jul 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
abitype ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 8, 2023 8:56am

@commit-lint
Copy link

commit-lint bot commented Jul 12, 2023

Features

  • parse human readable EIP-712 typed data (021bff1)

Chore

Documentation

  • add parseTypedData to docs. (cc59705)

Bug Fixes

Contributors

Raiden1411

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 12, 2023

Size Change: +1.5 kB (+3%)

Total Size: 49.9 kB

Filename Size Change
dist/cjs/human-readable/errors/struct.js 423 B +85 B (+25%) 🚨
dist/cjs/human-readable/runtime/structs.js 1.35 kB +319 B (+31%) 🚨
dist/cjs/index.js 792 B +49 B (+7%) 🔍
dist/esm/human-readable/errors/struct.js 355 B +73 B (+26%) 🚨
dist/esm/human-readable/runtime/structs.js 1.25 kB +298 B (+31%) 🚨
dist/esm/index.js 369 B +24 B (+7%) 🔍
dist/cjs/human-readable/parseTypedData.js 357 B +357 B (new file) 🆕
dist/esm/human-readable/parseTypedData.js 296 B +296 B (new file) 🆕
ℹ️ View Unchanged
Filename Size
dist/cjs/abi.js 123 B
dist/cjs/config.js 126 B
dist/cjs/errors.js 577 B
dist/cjs/human-readable/errors/abiItem.js 537 B
dist/cjs/human-readable/errors/abiParameter.js 804 B
dist/cjs/human-readable/errors/signature.js 420 B
dist/cjs/human-readable/errors/splitParameters.js 404 B
dist/cjs/human-readable/formatAbi.js 294 B
dist/cjs/human-readable/formatAbiItem.js 420 B
dist/cjs/human-readable/formatAbiParameter.js 487 B
dist/cjs/human-readable/formatAbiParameters.js 313 B
dist/cjs/human-readable/parseAbi.js 348 B
dist/cjs/human-readable/parseAbiItem.js 439 B
dist/cjs/human-readable/parseAbiParameter.js 470 B
dist/cjs/human-readable/parseAbiParameters.js 527 B
dist/cjs/human-readable/runtime/cache.js 616 B
dist/cjs/human-readable/runtime/signatures.js 782 B
dist/cjs/human-readable/runtime/utils.js 2.13 kB
dist/cjs/human-readable/types/signatures-test-d.js 440 B
dist/cjs/human-readable/types/signatures.js 127 B
dist/cjs/human-readable/types/structs.js 127 B
dist/cjs/human-readable/types/utils.js 124 B
dist/cjs/narrow.js 169 B
dist/cjs/regex.js 362 B
dist/cjs/test.js 597 B
dist/cjs/test/abis.js 5.93 kB
dist/cjs/test/human-readable.js 3.6 kB
dist/cjs/types.js 124 B
dist/cjs/utils.js 124 B
dist/cjs/version.js 148 B
dist/cjs/zod.js 2.08 kB
dist/esm/abi.js 62 B
dist/esm/config.js 65 B
dist/esm/errors.js 524 B
dist/esm/human-readable/errors/abiItem.js 454 B
dist/esm/human-readable/errors/abiParameter.js 674 B
dist/esm/human-readable/errors/signature.js 339 B
dist/esm/human-readable/errors/splitParameters.js 345 B
dist/esm/human-readable/formatAbi.js 214 B
dist/esm/human-readable/formatAbiItem.js 339 B
dist/esm/human-readable/formatAbiParameter.js 405 B
dist/esm/human-readable/formatAbiParameters.js 230 B
dist/esm/human-readable/parseAbi.js 267 B
dist/esm/human-readable/parseAbiItem.js 353 B
dist/esm/human-readable/parseAbiParameter.js 383 B
dist/esm/human-readable/parseAbiParameters.js 436 B
dist/esm/human-readable/runtime/cache.js 554 B
dist/esm/human-readable/runtime/signatures.js 572 B
dist/esm/human-readable/runtime/utils.js 2.04 kB
dist/esm/human-readable/types/signatures-test-d.js 367 B
dist/esm/human-readable/types/signatures.js 69 B
dist/esm/human-readable/types/structs.js 66 B
dist/esm/human-readable/types/utils.js 64 B
dist/esm/narrow.js 97 B
dist/esm/regex.js 284 B
dist/esm/test.js 298 B
dist/esm/test/abis.js 5.8 kB
dist/esm/test/human-readable.js 3.49 kB
dist/esm/types.js 64 B
dist/esm/utils.js 64 B
dist/esm/version.js 82 B
dist/esm/zod.js 1.91 kB

compressed-size-action

@codecov
Copy link

codecov bot commented Jul 12, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (529da5c) 99.90% compared to head (e917c51) 99.91%.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #166    +/-   ##
========================================
  Coverage   99.90%   99.91%            
========================================
  Files          21       22     +1     
  Lines        2055     2281   +226     
  Branches      325      362    +37     
========================================
+ Hits         2053     2279   +226     
  Misses          2        2            
Files Coverage Δ
src/human-readable/errors/struct.ts 100.00% <100.00%> (ø)
src/human-readable/parseTypedData.ts 100.00% <100.00%> (ø)
src/human-readable/runtime/structs.ts 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Raiden1411
Copy link
Collaborator Author

@tmm with the restructure do you want me to re-open this PR or do you think that this doesn't make sense in having for abitype?

@tmm tmm force-pushed the main branch 4 times, most recently from 6b36159 to c706a9a Compare May 23, 2024 21:55
@tmm tmm force-pushed the main branch 3 times, most recently from ffcd744 to 62b32d7 Compare June 25, 2024 00:27
@tmm
Copy link
Member

tmm commented Aug 6, 2024

@Raiden1411 this PR is great work and maybe we'll add it in someday (EIP-712 isn't a burning use-case it seems right now). Going to close out for the time-being.

@tmm tmm closed this Aug 6, 2024
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.

2 participants