Skip to content

Commit

Permalink
Initial code to allow human readable function abi.
Browse files Browse the repository at this point in the history
  • Loading branch information
derekpierre committed Oct 11, 2024
1 parent 152d37c commit c404a96
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/taco/src/conditions/schemas/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -49,6 +50,23 @@ const functionAbiSchema = z

export type FunctionAbiProps = z.infer<typeof functionAbiSchema>;

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({
Expand Down

0 comments on commit c404a96

Please sign in to comment.