diff --git a/packages/providers/src/validation.ts b/packages/providers/src/validation.ts index c7bca01..7d7c679 100644 --- a/packages/providers/src/validation.ts +++ b/packages/providers/src/validation.ts @@ -27,75 +27,78 @@ export const AddChainRequestParams = z .strict(); // Params -export const AccountsRequestParamsSchema = z - .object({ +export const RequestWithContext = z.object({ + context: z.record(z.any()).default({}).optional() +}).strict() +export const AccountsRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_accounts"), }) .strict(); -export const RequestAccountsRequestParamsSchema = z - .object({ +export const RequestAccountsRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_requestAccounts"), }) .strict(); -export const ChainIdRequestParamsSchema = z - .object({ method: z.literal("mina_chainId") }) +export const ChainIdRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_chainId") }) .strict(); -export const ChainInformationRequestParamsSchema = z - .object({ method: z.literal("mina_chainInformation") }) +export const ChainInformationRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_chainInformation") }) .strict(); -export const GetBalanceRequestParamsSchema = z - .object({ method: z.literal("mina_getBalance") }) +export const GetBalanceRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_getBalance") }) .strict(); -export const SignRequestParamsSchema = z - .object({ +export const SignRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_sign"), params: z.array(z.string()), }) .strict(); -export const SignFieldsRequestParamsSchema = z - .object({ +export const SignFieldsRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_signFields"), params: z.array(z.array(FieldSchema)), }) .strict(); -export const SignTransactionRequestParamsSchema = z - .object({ +export const SignTransactionRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_signTransaction"), params: z.array(z.union([TransactionPayload, ZkAppCommandPayload])), }) .strict(); -export const SendTransactionRequestParamsSchema = z - .object({ +export const SendTransactionRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_sendTransaction"), params: z.array(SignedTransactionSchema), }) .strict(); -export const CreateNullifierRequestParamsSchema = z - .object({ +export const CreateNullifierRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_createNullifier"), params: z.array(z.array(FieldSchema)), }) .strict(); -export const SwitchChainRequestParamsSchema = z - .object({ +export const SwitchChainRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_switchChain"), params: z.array(z.string()), }) .strict(); -export const AddChainRequestParamsSchema = z - .object({ +export const AddChainRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_addChain"), params: z.array(AddChainRequestParams), }) .strict(); -export const SetStateRequestParamsSchema = z - .object({ +export const SetStateRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_setState"), params: z.array(JsonSchema), }) .strict(); -export const GetStateRequestParamsSchema = z - .object({ +export const GetStateRequestParamsSchema = RequestWithContext + .extend({ method: z.literal("mina_getState"), params: z.array(z.string()), })