-
-
Notifications
You must be signed in to change notification settings - Fork 49
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): parameter validation and strict mode #138
Conversation
🦋 Changeset detectedLatest commit: e90ae65 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 |
FeaturesChore
Bug Fixes
Code Refactoring
ContributorsCommit-Lint commandsYou can trigger Commit-Lint actions by commenting on this PR:
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: +62 B (0%) Total Size: 47.1 kB
ℹ️ View Unchanged
|
|
||
- Type `boolean` | ||
- Default `false` | ||
|
||
```ts twoslash | ||
declare module 'abitype' { | ||
export interface Config { | ||
StrictAbiType: false | ||
Strict: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change it will affect type checking not only on types but also valid modifiers and parameter names. Kept as default so folks can hop in instead of out.
Codecov Report
@@ Coverage Diff @@
## main #138 +/- ##
========================================
Coverage 99.89% 99.90%
========================================
Files 21 21
Lines 1914 2029 +115
Branches 308 308
========================================
+ Hits 1912 2027 +115
Misses 2 2
|
@@ -128,7 +129,7 @@ export type IsName<TName extends string> = TName extends '' | |||
: false | |||
export type ValidateName< | |||
TName extends string, | |||
CheckCharacters extends boolean = false, | |||
CheckCharacters extends boolean = ResolvedConfig['Strict'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now gets enabled once folks enable strict mode instead of always being false.
@@ -1,9 +1,9 @@ | |||
import type { AbiParameter } from '../../abi.js' | |||
import type { InferredAbiParameter } from '../../abi.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to change this to InferredAbiParameter
because while parsing structs with StrictAbiType = true
it would cause some components to be never
.
AllKeys extends keyof T = keyof T, | ||
> = [AllKeys] extends [never] ? true : false | ||
|
||
export type Flatten< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also filters out all never
types. It wasn't playing to well with never
as members since never extends any[]
is true.
@tmm, made some comments on the files. Let me know what you think about this. |
Will close this and break this down into seperate PRs. Currently doing to much on this one |
Description
Adds parameter validation to
parseAbiParameter
andparseAbiParameters
.Changes
StrictAbiType
toStrict
.Additional Information
Your ENS/address:
PR-Codex overview
This PR adds parameter validation and stricter checks to
parseAbiParameter
andparseAbiParameters
. It also renamesStrictAbiType
toStrict
and enforces stricter checks on human-readable ABIs. Notable changes include:parseAbiParameter
andparseAbiParameters
StrictAbiType
toStrict
InferredAbi
instead ofAbi
ExtractAbiParseErrors
,Flatten
,IsEmptyObject
,IsArrayString
,Pop
,IsNever
, andRange