abitype
abitype copied to clipboard
feat(human-readable): parse EIP712 human-readable type signatures
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
- [x] I read the contributing guide
- [x] I added documentation related to the changes made.
- [x] 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 detected
Latest commit: e917c51786901b40463c80f11ea640ebb7e34ccc
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
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 |
Features
- parse human readable EIP-712 typed data (021bff1)
Chore
- lint (e975d9a)
- JSDocs (1de58b8)
- changeset (c8c4ea4)
- update types to better represent runtime behaviour (8a3f268)
- comments (df7bde8)
- lint (3ef4f85)
- add examples and types reorganization (b4823c2)
- merge main (7bdd7a8)
Documentation
- add
parseTypedData
to docs. (cc59705)
Bug Fixes
- failing typecheck (4365d01)
Contributors
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
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 |
Codecov Report
All modified lines are covered by tests :white_check_mark:
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%> (ΓΈ) |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@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?
@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.