abitype icon indicating copy to clipboard operation
abitype copied to clipboard

fix: normalize `AbiFallback.inputs` type between `abitype` and `zod`

Open matbour opened this issue 1 year ago • 8 comments

Description

This PR aligns the following AbiFallback.inputs type between Zod schema and abitype

type Left = AbiFallback['inputs']; // readonly []
type Right = z.infer<typeof AbiFallbackSchema>['inputs']; // never[]

After:

type Left = AbiFallback['inputs']; // readonly never[]
type Right = z.infer<typeof AbiFallbackSchema>['inputs']; readonly never[]

Additional Information

Before submitting this issue, please make sure you do the following.

  • [X] Read the contributing guide
  • [X] Added documentation related to the changes made.
  • [X] Added or updated tests (and snapshots) related to the changes made.

PR-Codex overview

Focus of the PR:

This PR focuses on normalizing the AbiFallback.inputs type and zod.

Detailed summary:

  • Normalize AbiFallback.inputs type and zod
  • Update packages/abitype/src/abi.ts to use readonly never[] instead of readonly [] for AbiFallback.inputs
  • Update packages/abitype/src/zod.ts to use z.tuple([]).readonly().optional() for AbiFallback.inputs
  • Add AbiFallback and AbiFunction to packages/abitype/src/zod.test-d.ts
  • Update imports in packages/abitype/src/zod.test-d.ts
  • Add tests for AbiFunction and AbiFallback in packages/abitype/src/zod.test-d.ts

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

matbour avatar Oct 14 '23 08:10 matbour

🦋 Changeset detected

Latest commit: d5dadf7135838c998d35099adb7f31670fca4470

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

This PR includes changesets to release 1 package
Name Type
abitype Patch

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

changeset-bot[bot] avatar Oct 14 '23 08:10 changeset-bot[bot]

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 14, 2023 8:26am

vercel[bot] avatar Oct 14 '23 08:10 vercel[bot]

Bug Fixes

  • normalize AbiFallback.inputs type and zod (d5dadf7)

Contributors

mathieu-bour

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

commit-lint[bot] avatar Oct 14 '23 08:10 commit-lint[bot]

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (32cf12d) 99.83% compared to head (d5dadf7) 99.83%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #203   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files          26       26           
  Lines        6082     6082           
  Branches      195      195           
=======================================
  Hits         6072     6072           
  Misses          8        8           
  Partials        2        2           
Files Coverage Δ
packages/abitype/src/zod.ts 100.00% <100.00%> (ø)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 14 '23 08:10 codecov[bot]

I've tested the ABI output of the fallback function on every major solidity compiler and the ABI JSON output does not have the inputs property. I think instead of normalizing the type between TS and Zod we should remove this property all together. I also believe that Vyper doesn't support fallback functions.

Raiden1411 avatar Oct 17 '23 22:10 Raiden1411

So you mean completely removing AbiFallback['input']?

matbour avatar Oct 18 '23 07:10 matbour

If @tmm agrees I would say so

Raiden1411 avatar Oct 18 '23 09:10 Raiden1411

@Raiden1411 @tmm just wanted to know your opinion about removing fallback from fallback function

matbour avatar Jan 22 '24 13:01 matbour

@Raiden1411's comment is spot on! Wasn't able to push to this PR for some reason so created a new one here https://github.com/wevm/abitype/pull/248

tmm avatar Aug 06 '24 15:08 tmm