@@ -3,8 +3,7 @@ import { permitTypedData } from '@aave/client-next/actions';
33import {
44 sendTransactionAndWait ,
55 signERC20PermitWith ,
6- signSwapByIntentWith ,
7- signSwapCancelWith ,
6+ signSwapTypedDataWith ,
87} from '@aave/client-next/viem' ;
98import type {
109 CancelSwapTypedData ,
@@ -94,62 +93,30 @@ export function useERC20Permit(
9493export type SignSwapError = SigningError | UnexpectedError ;
9594
9695/**
97- * A hook that provides a way to sign swap by intent using a viem WalletClient instance.
96+ * A hook that provides a way to sign swap typed data using a viem WalletClient instance.
9897 *
9998 * ```ts
10099 * const { data: wallet } = useWalletClient(); // wagmi hook
101- * const [signSwapByIntent , { loading, error, data }] = useSignSwapByIntentWith (wallet);
100+ * const [signSwapTypedData , { loading, error, data }] = useSignSwapTypedDataWith (wallet);
102101 *
103102 * const run = async () => {
104- * const result = await signSwapByIntent(swapByIntentTypedData );
103+ * const result = await signSwapTypedData(swapTypedData );
105104 *
106105 * if (result.isErr()) {
107106 * console.error(result.error);
108107 * return;
109108 * }
110109 *
111- * console.log('Swap by intent signed:', result.value);
110+ * console.log('Swap typed data signed:', result.value);
112111 * };
113112 * ```
114113 */
115- export function useSignSwapByIntentWith (
114+ export function useSignSwapTypedDataWith (
116115 walletClient : WalletClient | undefined ,
117116) : UseAsyncTask < SwapByIntentTypedData , ERC712Signature , SignSwapError > {
118117 return useAsyncTask ( ( typedData : SwapByIntentTypedData ) => {
119- invariant ( walletClient , 'Expected a WalletClient to sign swap by intent ' ) ;
118+ invariant ( walletClient , 'Expected a WalletClient to sign swap typed data ' ) ;
120119
121- return signSwapByIntentWith ( walletClient ) ( typedData ) ;
122- } ) ;
123- }
124-
125- /**
126- * A hook that provides a way to sign swap cancellation using a viem WalletClient instance.
127- *
128- * ```ts
129- * const { data: wallet } = useWalletClient(); // wagmi hook
130- * const [signSwapCancel, { loading, error, data }] = useSignSwapCancelWith(wallet);
131- *
132- * const run = async () => {
133- * const result = await signSwapCancel(cancelSwapTypedData);
134- *
135- * if (result.isErr()) {
136- * console.error(result.error);
137- * return;
138- * }
139- *
140- * console.log('Swap cancellation signed:', result.value);
141- * };
142- * ```
143- */
144- export function useSignSwapCancelWith (
145- walletClient : WalletClient | undefined ,
146- ) : UseAsyncTask < CancelSwapTypedData , ERC712Signature , SignSwapError > {
147- return useAsyncTask ( ( typedData : CancelSwapTypedData ) => {
148- invariant (
149- walletClient ,
150- 'Expected a WalletClient to sign swap cancellation' ,
151- ) ;
152-
153- return signSwapCancelWith ( walletClient ) ( typedData ) ;
120+ return signSwapTypedDataWith ( walletClient ) ( typedData ) ;
154121 } ) ;
155122}
0 commit comments