Skip to content

Commit 2d63e10

Browse files
committed
fix(wallet-client): handle permits in sendCalls action, add clarifying docs
1 parent 4714a52 commit 2d63e10

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

account-kit/react/src/experimental/hooks/useSendCalls.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export type UseSendCallsResult<
6363
* or fall back to regular EOA transactions when connected to an EOA wallet. It handles the complete
6464
* flow of preparing, signing, and sending calls.
6565
*
66+
* <Note>
67+
* If using this hook with an ERC-20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
68+
* from the user. It is recommended to use the `usePrepareCalls` hook instead to manually handle the permit signature.
69+
* </Note>
70+
*
6671
* @template TEntryPointVersion - The entry point version to use for user operations (defaults to EntryPointVersion)
6772
*
6873
* @param {UseSendCallsParams} params - Configuration parameters for the hook

account-kit/wallet-client/src/client/actions/sendCalls.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import type { InnerWalletApiClient } from "../../types.js";
33
import { prepareCalls, type PrepareCallsParams } from "./prepareCalls.js";
44
import { metrics } from "../../metrics.js";
55
import { signPreparedCalls } from "./signPreparedCalls.js";
6-
import type { SmartAccountSigner } from "@aa-sdk/core";
6+
import { type SmartAccountSigner } from "@aa-sdk/core";
77
import {
88
sendPreparedCalls,
99
type SendPreparedCallsResult,
1010
} from "./sendPreparedCalls.js";
11+
import { signSignatureRequest } from "./signSignatureRequest.js";
1112

1213
export type SendCallsParams<
1314
TAccount extends Address | undefined = Address | undefined,
@@ -18,6 +19,11 @@ export type SendCallsResult = SendPreparedCallsResult;
1819
/**
1920
* Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
2021
*
22+
* <Note>
23+
* If using this action with an ERC20 paymaster in pre-operation mode with `autoPermit`, the contents of the permit will be hidden
24+
* from the user. It is recommended to use the `prepareCalls` action instead to manually handle the permit signature.
25+
* </Note>
26+
*
2127
* @param {InnerWalletApiClient} client - The wallet API client to use for the request
2228
* @param {SmartAccountSigner} signer - The signer to use
2329
* @param {PrepareCallsParams<TAccount>} params - Parameters for sending calls
@@ -54,7 +60,23 @@ export async function sendCalls<
5460
name: "send_calls",
5561
});
5662

57-
const calls = await prepareCalls(client, params);
63+
let calls = await prepareCalls(client, params);
64+
65+
if (calls.type === "paymaster-permit") {
66+
const signature = await signSignatureRequest(
67+
signer,
68+
calls.signatureRequest,
69+
);
70+
71+
const secondCallParams = {
72+
from: calls.modifiedRequest.from,
73+
calls: calls.modifiedRequest.calls,
74+
capabilities: calls.modifiedRequest.capabilities,
75+
paymasterPermitSignature: signature,
76+
};
77+
78+
calls = await prepareCalls(client, secondCallParams);
79+
}
5880

5981
const signedCalls = await signPreparedCalls(signer, calls);
6082

docs/pages/reference/account-kit/wallet-client/functions/sendCalls.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ slug: wallets/reference/account-kit/wallet-client/functions/sendCalls
77

88
Prepares, signs, and submits calls. This function internally calls `prepareCalls`, `signPreparedCalls`, and `sendPreparedCalls`.
99

10+
<Note>
11+
If using this action with an ERC-20 paymaster in pre-operation mode with
12+
`autoPermit`, the contents of the permit will be hidden from the user. It is
13+
recommended to use the `prepareCalls` action instead to manually handle the
14+
permit signature.
15+
</Note>
16+
1017
## Import
1118

1219
```ts

0 commit comments

Comments
 (0)