Skip to content

Commit

Permalink
fix(zod): allow empty string on name property in AbiParameter (#185)
Browse files Browse the repository at this point in the history
* fix: allow empty name in AbiParameter

* chore: update changeset

---------

Co-authored-by: 0xRaiden <[email protected]>
  • Loading branch information
StanleyDing and Raiden1411 authored Aug 17, 2023
1 parent b03440c commit f5b27a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/large-pugs-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"abitype": patch
---

Fixed a bug where an empty string on the `name` property in AbiParameter wasn't allowed.
2 changes: 2 additions & 0 deletions src/zod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,12 @@ describe('AbiParameter', () => {
it('returns valid schema', () => {
expect(
AbiParameter.parse({
name: '',
type: 'address',
}),
).toMatchInlineSnapshot(`
{
"name": "",
"type": "address",
}
`)
Expand Down
2 changes: 1 addition & 1 deletion src/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const SolidityArray = z.union([
export const AbiParameter: z.ZodType<AbiParameterType> = z.lazy(() =>
z.intersection(
z.object({
name: Identifier.optional(),
name: z.union([Identifier.optional(), z.literal('')]),
/** Representation used by Solidity compiler */
internalType: z.string().optional(),
}),
Expand Down

1 comment on commit f5b27a8

@vercel
Copy link

@vercel vercel bot commented on f5b27a8 Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

abitype – ./

abitype.dev
abitype-wagmi-dev.vercel.app
abitype.vercel.app
abitype-git-main-wagmi-dev.vercel.app

Please sign in to comment.