From 0d8f7ebe64f1fbff1ddd2b22cd0f32844ab15415 Mon Sep 17 00:00:00 2001 From: danidfra Date: Thu, 19 Sep 2024 01:13:20 -0300 Subject: [PATCH] Rst --- src/schemas/zap-split.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/schemas/zap-split.ts diff --git a/src/schemas/zap-split.ts b/src/schemas/zap-split.ts new file mode 100644 index 000000000..c2323d773 --- /dev/null +++ b/src/schemas/zap-split.ts @@ -0,0 +1,22 @@ +import { z } from 'zod'; + +import { type Account, accountSchema } from './account'; + +const addMethodsToAccount = (account: Account) => { + return { + ...account, + get: (key: string) => (account as any)[key], + getIn: (path: string[]) => path.reduce((acc, key) => (acc as any)[key], account), + toJS: () => account, + }; +}; + +const baseZapAccountSchema = z.object({ + account: accountSchema.transform(addMethodsToAccount), + message: z.string().catch(''), + weight: z.number().catch(0), +}); + +type ZapSplitData = z.infer; + +export { baseZapAccountSchema, type ZapSplitData }; \ No newline at end of file