Skip to content

Commit e95e209

Browse files
[SDK] Optimize 4337 signature performance
1 parent 8260af3 commit e95e209

File tree

2 files changed

+11
-35
lines changed

2 files changed

+11
-35
lines changed

.changeset/thirty-eels-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Optimize 4337 signature performance

packages/thirdweb/src/wallets/smart/lib/signing.ts

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type * as ox__TypedData from "ox/TypedData";
22
import { serializeErc6492Signature } from "../../../auth/serialize-erc6492-signature.js";
3-
import {
4-
verifyEip1271Signature,
5-
verifyHash,
6-
} from "../../../auth/verify-hash.js";
3+
import { verifyEip1271Signature } from "../../../auth/verify-hash.js";
74
import type { Chain } from "../../../chains/types.js";
85
import type { ThirdwebClient } from "../../../client/client.js";
96
import {
@@ -50,7 +47,7 @@ export async function smartAccountSignMessage({
5047
if (is712Factory) {
5148
const wrappedMessageHash = encodeAbiParameters(
5249
[{ type: "bytes32" }],
53-
[originalMsgHash],
50+
[originalMsgHash]
5451
);
5552

5653
sig = await options.personalAccount.signTypedData({
@@ -96,19 +93,7 @@ export async function smartAccountSignMessage({
9693
signature: sig,
9794
});
9895

99-
// check if the signature is valid
100-
const isValid = await verifyHash({
101-
address: accountContract.address,
102-
chain: accountContract.chain,
103-
client: accountContract.client,
104-
hash: originalMsgHash,
105-
signature: erc6492Sig,
106-
});
107-
108-
if (isValid) {
109-
return erc6492Sig;
110-
}
111-
throw new Error("Unable to verify ERC-6492 signature after signing.");
96+
return erc6492Sig;
11297
}
11398
}
11499

@@ -149,7 +134,7 @@ export async function smartAccountSignTypedData<
149134
if (is712Factory) {
150135
const wrappedMessageHash = encodeAbiParameters(
151136
[{ type: "bytes32" }],
152-
[originalMsgHash],
137+
[originalMsgHash]
153138
);
154139
sig = await options.personalAccount.signTypedData({
155140
domain: {
@@ -194,21 +179,7 @@ export async function smartAccountSignTypedData<
194179
signature: sig,
195180
});
196181

197-
// check if the signature is valid
198-
const isValid = await verifyHash({
199-
address: accountContract.address,
200-
chain: accountContract.chain,
201-
client: accountContract.client,
202-
hash: originalMsgHash,
203-
signature: erc6492Sig,
204-
});
205-
206-
if (isValid) {
207-
return erc6492Sig;
208-
}
209-
throw new Error(
210-
"Unable to verify signature on smart account, please make sure the admin wallet has permissions and the signature is valid.",
211-
);
182+
return erc6492Sig;
212183
}
213184
}
214185

@@ -225,7 +196,7 @@ export async function confirmContractDeployment(args: {
225196
while (!isDeployed) {
226197
if (Date.now() - startTime > timeout) {
227198
throw new Error(
228-
"Timeout: Smart account deployment not confirmed after 1 minute",
199+
"Timeout: Smart account deployment not confirmed after 1 minute"
229200
);
230201
}
231202
await new Promise((resolve) => setTimeout(resolve, 500));

0 commit comments

Comments
 (0)