@@ -33,8 +33,10 @@ export type StreamingResult = {
3333
3434/**
3535 * Finds a caveat that matches the specified enforcer address.
36- * @param delegation - The delegation to search.
37- * @param enforcerAddress - The enforcer address to match.
36+ * @param config - The configuration object.
37+ * @param config.delegation - The delegation to search.
38+ * @param config.enforcerAddress - The enforcer address to match.
39+ * @param config.enforcerName - The name of the enforcer.
3840 * @returns The matching caveat.
3941 * @throws Error if no matching caveat is found.
4042 * @throws Error if multiple matching caveats are found.
@@ -89,8 +91,9 @@ function getDelegationManager(environment: DeleGatorEnvironment): Address {
8991/**
9092 * Gets the enforcer address from environment.
9193 *
92- * @param enforcerName - The name of the enforcer.
93- * @param environment - The delegator environment.
94+ * @param config - The configuration object.
95+ * @param config.enforcerName - The name of the enforcer.
96+ * @param config.environment - The delegator environment.
9497 * @returns The enforcer address.
9598 */
9699function getEnforcerAddress ( {
@@ -380,3 +383,27 @@ export const caveatEnforcerActions =
380383 ) ;
381384 } ,
382385 } ) ;
386+
387+ /**
388+ * Type for client extended with caveat enforcer actions.
389+ */
390+ export type CaveatEnforcerClient = PublicClient &
391+ ReturnType < ReturnType < typeof caveatEnforcerActions > > ;
392+
393+ /**
394+ * Create a viem client extended with caveat enforcer actions.
395+ *
396+ * @param params - The parameters object.
397+ * @param params.client - The viem public client.
398+ * @param params.environment - The delegator environment.
399+ * @returns The extended client with caveat enforcer actions.
400+ */
401+ export function createCaveatEnforcerClient ( {
402+ client,
403+ environment,
404+ } : {
405+ client : PublicClient ;
406+ environment : DeleGatorEnvironment ;
407+ } ) : CaveatEnforcerClient {
408+ return client . extend ( caveatEnforcerActions ( { environment } ) ) ;
409+ }
0 commit comments