@@ -34,8 +34,8 @@ type BaseRedelegatePermissionContextParameters = {
3434 environment : SmartAccountsEnvironment ;
3535 /** The permission context to redelegate from (i.e., from ERC-7715 response) */
3636 permissionContext : PermissionContext ;
37- /** The chain ID for the signature */
38- chainId : number ;
37+ /** The chain ID for the signature (falls back to `client.chain.id`) */
38+ chainId ? : number ;
3939 /** Optional scope - if not provided, inherits from parent */
4040 scope ?: ScopeConfig ;
4141 /** Additional caveats to apply to the redelegation */
@@ -181,7 +181,8 @@ function resolveRedelegationArgs<
181181 * 4. Prepends it to the delegation chain
182182 * 5. Returns the encoded permission context
183183 *
184- * Use {@link redelegatePermissionContextOpen} to create an open redelegation
184+ * Use {@link redelegatePermissionContextOpenAction} to create an open
185+ * redelegation
185186 * (delegate set to `ANY_BENEFICIARY`).
186187 *
187188 * @param client - Wallet client with signing capability.
@@ -190,7 +191,7 @@ function resolveRedelegationArgs<
190191 *
191192 * @example
192193 * ```ts
193- * const result = await redelegatePermissionContext (walletClient, {
194+ * const result = await redelegatePermissionContextAction (walletClient, {
194195 * environment,
195196 * permissionContext: erc7715Response.context,
196197 * chainId: 11155111,
@@ -208,14 +209,15 @@ function resolveRedelegationArgs<
208209 * });
209210 * ```
210211 */
211- export async function redelegatePermissionContext <
212+ export async function redelegatePermissionContextAction <
212213 TChain extends Chain | undefined ,
213214 TAccount extends Account | undefined ,
214215> (
215216 client : SigningClient < TChain , TAccount > ,
216217 parameters : RedelegatePermissionContextParameters ,
217218) : Promise < RedelegatePermissionContextReturnType > {
218- const { environment, chainId, scope, caveats, salt, to } = parameters ;
219+ const { environment, scope, caveats, salt, to } = parameters ;
220+ const chainId = resolveChainId ( client , parameters . chainId ) ;
219221
220222 const { account, delegations, parentDelegation, from } =
221223 resolveRedelegationArgs ( client , parameters ) ;
@@ -250,7 +252,7 @@ export async function redelegatePermissionContext<
250252 * existing permission context and returns both the signed delegation and the
251253 * updated permission context.
252254 *
253- * Use {@link redelegatePermissionContext } when you want to delegate to a
255+ * Use {@link redelegatePermissionContextAction } when you want to delegate to a
254256 * specific address.
255257 *
256258 * @param client - Wallet client with signing capability.
@@ -259,22 +261,23 @@ export async function redelegatePermissionContext<
259261 *
260262 * @example
261263 * ```ts
262- * const result = await redelegatePermissionContextOpen (walletClient, {
264+ * const result = await redelegatePermissionContextOpenAction (walletClient, {
263265 * environment,
264266 * permissionContext: erc7715Response.context,
265267 * chainId: 11155111,
266268 * caveats: [limitedCallsCaveat],
267269 * });
268270 * ```
269271 */
270- export async function redelegatePermissionContextOpen <
272+ export async function redelegatePermissionContextOpenAction <
271273 TChain extends Chain | undefined ,
272274 TAccount extends Account | undefined ,
273275> (
274276 client : SigningClient < TChain , TAccount > ,
275277 parameters : RedelegatePermissionContextOpenParameters ,
276278) : Promise < RedelegatePermissionContextReturnType > {
277- const { environment, chainId, scope, caveats, salt } = parameters ;
279+ const { environment, scope, caveats, salt } = parameters ;
280+ const chainId = resolveChainId ( client , parameters . chainId ) ;
278281
279282 const { account, delegations, parentDelegation, from } =
280283 resolveRedelegationArgs ( client , parameters ) ;
@@ -325,61 +328,3 @@ function resolveChainId(
325328 }
326329 return client . chain . id ;
327330}
328-
329- /**
330- * Creates redelegation actions that can be used to extend a wallet client.
331- *
332- * Adds two actions:
333- * - `redelegatePermissionContext` for redelegating to a specific delegate.
334- * - `redelegatePermissionContextOpen` for creating an open redelegation.
335- *
336- * @returns A function that can be used with the wallet client `extend` method.
337- *
338- * @example
339- * ```ts
340- * const walletClient = createWalletClient({
341- * chain: sepolia,
342- * transport: http(),
343- * }).extend(redelegatePermissionContextActions());
344- *
345- * // Specific redelegation
346- * const specific = await walletClient.redelegatePermissionContext({
347- * environment,
348- * permissionContext: erc7715Response.context,
349- * to: charlie.address,
350- * });
351- *
352- * // Open redelegation
353- * const open = await walletClient.redelegatePermissionContextOpen({
354- * environment,
355- * permissionContext: erc7715Response.context,
356- * });
357- * ```
358- */
359- export function redelegatePermissionContextActions ( ) {
360- return <
361- TChain extends Chain | undefined ,
362- TAccount extends Account | undefined ,
363- > (
364- client : SigningClient < TChain , TAccount > ,
365- ) => ( {
366- redelegatePermissionContext : async (
367- parameters : Omit < RedelegatePermissionContextParameters , 'chainId' > & {
368- chainId ?: number ;
369- } ,
370- ) =>
371- redelegatePermissionContext ( client , {
372- ...parameters ,
373- chainId : resolveChainId ( client , parameters . chainId ) ,
374- } ) ,
375- redelegatePermissionContextOpen : async (
376- parameters : Omit < RedelegatePermissionContextOpenParameters , 'chainId' > & {
377- chainId ?: number ;
378- } ,
379- ) =>
380- redelegatePermissionContextOpen ( client , {
381- ...parameters ,
382- chainId : resolveChainId ( client , parameters . chainId ) ,
383- } ) ,
384- } ) ;
385- }
0 commit comments