Skip to content

Commit 0b03514

Browse files
committed
Fix jsdoc comments in getCaveatAvailableAmount.ts
1 parent 246694e commit 0b03514

3 files changed

Lines changed: 36 additions & 9 deletions

File tree

packages/delegation-toolkit/src/actions/getCaveatAvailableAmount.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
9699
function 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+
}

packages/delegation-toolkit/test/actions/caveatEnforcerClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { type PublicClient, createPublicClient, http, type Hex } from 'viem';
22
import { sepolia } from 'viem/chains';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

5-
import { randomAddress, randomBytes } from '../utils';
65
import {
76
createCaveatEnforcerClient,
87
type CaveatEnforcerClient,
@@ -24,6 +23,7 @@ import {
2423
} from '../../src/contracts';
2524
import { getDelegationHashOffchain } from '../../src/delegation';
2625
import type { DeleGatorEnvironment } from '../../src/types';
26+
import { randomAddress, randomBytes } from '../utils';
2727

2828
// Helper function to generate random bytes32
2929
const randomBytes32 = (): Hex => randomBytes(32);

packages/delegation-toolkit/test/caveatUtils.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import { sepolia } from 'viem/chains';
33
import { beforeEach, describe, expect, it, vi } from 'vitest';
44

55
import { randomAddress, randomBytes } from './utils';
6+
import {
7+
createCaveatEnforcerClient,
8+
type CaveatEnforcerClient,
9+
} from '../src/actions/caveatEnforcerClient';
610
import {
711
getErc20PeriodTransferEnforcerAvailableAmount,
812
getErc20StreamingEnforcerAvailableAmount,
@@ -11,10 +15,6 @@ import {
1115
getNativeTokenStreamingEnforcerAvailableAmount,
1216
type CaveatEnforcerParams,
1317
} from '../src/actions/getCaveatAvailableAmount';
14-
import {
15-
createCaveatEnforcerClient,
16-
type CaveatEnforcerClient,
17-
} from '../src/actions/caveatEnforcerClient';
1818
import {
1919
ERC20PeriodTransferEnforcer,
2020
MultiTokenPeriodEnforcer,

0 commit comments

Comments
 (0)