diff --git a/packages/taco/src/conditions/schemas/contract.ts b/packages/taco/src/conditions/schemas/contract.ts index 59e1f831..6f0c9ac1 100644 --- a/packages/taco/src/conditions/schemas/contract.ts +++ b/packages/taco/src/conditions/schemas/contract.ts @@ -5,6 +5,7 @@ import { AbiParameter } from 'abitype/zod'; import { paramOrContextParamSchema } from './context'; import { rpcConditionSchema } from './rpc'; +import { parseAbi, parseAbiItem } from 'abitype'; const functionAbiSchema = z .object({ @@ -49,6 +50,23 @@ const functionAbiSchema = z export type FunctionAbiProps = z.infer; +export const humanReadableAbiSchema = z + .string().startsWith("function ") + .refine( + (abi) => { + try { + parseAbiItem(abi); + return true; + } catch (e) { + return false; + } + }, + { + message: 'Invalid Human-Readable ABI format', + }, + ) + .transform(parseAbiItem); + export const ContractConditionType = 'contract'; export const contractConditionSchema = rpcConditionSchema .extend({