From b6a5373a3d9603f5184befc2853a5f00758e749c Mon Sep 17 00:00:00 2001 From: K Date: Tue, 17 Oct 2023 14:49:45 +0000 Subject: [PATCH] Update README --- README.md | 30 +++++++++++++++++++++++++++++- src/index.ts | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b5e6837..aa9d2f0 100644 --- a/README.md +++ b/README.md @@ -1 +1,29 @@ -# warp-contracts-plugin-zod \ No newline at end of file +# 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; +``` diff --git a/src/index.ts b/src/index.ts index 106ab1b..ca484aa 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { WarpPlugin, WarpPluginType } from 'warp-contracts'; import zod from 'zod'; -export class ZodPlugin implements WarpPlugin { +export class ZodExtension implements WarpPlugin { process(input: any): void { input.zod = zod; }