Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kay-is committed Oct 17, 2023
1 parent 7040715 commit b6a5373
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# warp-contracts-plugin-zod
# SmartWeave Extension for Zod

A plugin for Warp Contracts that allows using Zod verifications inside a contract.

## Install

$ yarn add warp-contracts-plugin-nlp

## Setup

```ts
import { ZodExtension } from '@kay-is/warp-contracts-plugin-zod';
import { WarpFactory } from 'warp-contracts';

const warp = WarpFactory.forMainnet().use(new ZodExtension());
```

## Usage

```ts
const User = SmartWeave.extensions.zod.object({
username: z.string()
});

User.parse({ username: 'Ludwig' });

// extract the inferred type
type User = SmartWeave.extensions.zod.infer<typeof User>;
```
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WarpPlugin, WarpPluginType } from 'warp-contracts';
import zod from 'zod';

export class ZodPlugin implements WarpPlugin<any, void> {
export class ZodExtension implements WarpPlugin<any, void> {
process(input: any): void {
input.zod = zod;
}
Expand Down

0 comments on commit b6a5373

Please sign in to comment.