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

Support sign raw in the Policy Engine #220

Merged
merged 5 commits into from
Apr 5, 2024
Merged

Conversation

wcalderipe
Copy link
Collaborator

@wcalderipe wcalderipe commented Apr 4, 2024

This PR adds support for signRaw action in the policy engine. It also refactors some of the existing plain types to use Zod schemas.

Finally, it adds a top-level test recipe in the makefile to test a very single project. This is useful when you have cross project changes, and you want to make sure everything is working as expected.

Zod records with custom types

In Zod, when you define a record with primitives like z.record(z.string(), z.string()), the inferred type is indeed Record<string, string>, which aligns with expectations. However, if you define a record with a z.custom, such as z.record(z.custom<`0x${string}`>(), z.string()), instead of getting Record<`0x${string}`, string>, you actually end up with Record<`0x${string}`, string | undefined>.

You can test it with the snippet below:

const R1 = z.record(z.string(), z.string())
export type A1 = z.infer<typeof R1>

const R2 = z.record(z.custom<`0x${string}`>(), z.string())
export type A2 = z.infer<typeof R2>

@wcalderipe wcalderipe self-assigned this Apr 4, 2024
@wcalderipe wcalderipe merged commit 344b672 into main Apr 5, 2024
3 checks passed
@wcalderipe wcalderipe deleted the feature/support-sign-raw branch May 27, 2024 09:17
mattschoch pushed a commit that referenced this pull request Jun 19, 2024
* Refactor toInput to use individual mapping functions

* Support sign raw action

Refactor Evaluation Request to use a Zod schema

* Refactor types to use Zod schema

* Add top-level test recipies

* Update README
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.

1 participant