Skip to content

Commit e210686

Browse files
committed
feat: force either code or ipfsId passed to executeJs but not both
1 parent 1f67314 commit e210686

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/schemas/src/lib/schemas.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,11 +561,11 @@ export const JsonExecutionSdkParamsSchema = LitActionSdkParamsSchema.pick({
561561
/**
562562
* JS code to run on the nodes
563563
*/
564-
code: z.string().optional(), // TODO one or the other
564+
code: z.string().optional(),
565565
/**
566566
* The IPFS ID of some JS code to run on the nodes
567567
*/
568-
ipfsId: z.string().optional(), // TODO one or the other
568+
ipfsId: z.string().optional(),
569569
/**
570570
* the session signatures to use to authorize the user with the nodes
571571
*/
@@ -574,7 +574,13 @@ export const JsonExecutionSdkParamsSchema = LitActionSdkParamsSchema.pick({
574574
* auth methods to resolve
575575
*/
576576
authMethods: z.array(AuthMethodSchema).optional(),
577-
});
577+
})
578+
.refine(
579+
(data) => (data.code && !data.ipfsId) || (!data.code && data.ipfsId),
580+
{
581+
message: 'Either `code` or `ipfsId` must be provided, but not both.',
582+
}
583+
);
578584

579585
export const SigResponseSchema = z.object({
580586
r: z.string(),

0 commit comments

Comments
 (0)