@@ -10,16 +10,14 @@ import {
1010 type PermitBatch ,
1111} from "@uniswap/permit2-sdk" ;
1212import type { BatchPermitOptions } from "@uniswap/v4-sdk" ;
13- import type { TypedDataDomain , TypedDataField } from "ethers" ;
14- import { zeroAddress } from "viem" ;
15- import type { Hex } from "viem/_types/types/misc" ;
16-
17- /**
13+ import type { TypedDataField } from "ethers" ;
14+ import type { Hex } from "viem" ;
15+ import { zeroAddress } from "viem" ; /**
1816 * Prepares the permit2 batch data for multiple tokens
1917 *
2018 * This function creates a batch permit that allows a spender to use multiple tokens
2119 * on behalf of the user. It fetches current allowance details for each token and
22- * prepares the data needed for signing.
20+ * prepares the data needed for signing. You can use with viem or ethers.
2321 *
2422 * The complete flow to use this function is:
2523 * 1. Prepare the permit data:
@@ -33,10 +31,14 @@ import type { Hex } from "viem/_types/types/misc";
3331 *
3432 * 2. Sign the permit data using your signer:
3533 * ```typescript
34+ * // viem
35+ * const signature = await signer._signTypedData(permitData.toSign)
36+ *
37+ * // ethers
3638 * const signature = await signer.signTypedData(
3739 * permitData.toSign.domain,
3840 * permitData.toSign.types,
39- * permitData.toSign.values
41+ * permitData.toSign.values,
4042 * )
4143 * ```
4244 *
@@ -135,7 +137,7 @@ export async function preparePermit2BatchData(
135137 PERMIT2_ADDRESS ,
136138 chainId ,
137139 ) as {
138- domain : TypedDataDomain ;
140+ domain : PreparePermit2BatchDataResult [ "toSign" ] [ "domain" ] ;
139141 types : Record < string , TypedDataField [ ] > ;
140142 values : PermitBatch ;
141143 } ;
@@ -158,6 +160,8 @@ export async function preparePermit2BatchData(
158160 domain,
159161 types,
160162 values,
163+ primaryType : "PermitBatch" ,
164+ message : values as unknown as Record < string , unknown > ,
161165 } ,
162166 } ;
163167}
0 commit comments