Skip to content

Commit 85bde21

Browse files
[SDK] Handle 7702 accounts in verifyTypedData (#8141)
1 parent 2c84ac4 commit 85bde21

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.changeset/cyan-windows-reply.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+
Handle 7702 accounts in verifyTypedData

packages/thirdweb/src/auth/verify-typed-data.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type * as ox__Signature from "ox/Signature";
1+
import * as ox__Secp256k1 from "ox/Secp256k1";
2+
import * as ox__Signature from "ox/Signature";
23
import * as ox__TypedData from "ox/TypedData";
34
import type { Chain } from "../chains/types.js";
45
import type { ThirdwebClient } from "../client/client.js";
5-
import type { Hex } from "../utils/encoding/hex.js";
6+
import { type Hex, isHex } from "../utils/encoding/hex.js";
67
import type { HashTypedDataParams } from "../utils/hashing/hashTypedData.js";
78
import { type VerifyHashParams, verifyHash } from "./verify-hash.js";
89

@@ -101,6 +102,23 @@ export async function verifyTypedData<
101102
primaryType,
102103
types,
103104
} as HashTypedDataParams);
105+
106+
if (!isHex(signature)) {
107+
return false;
108+
}
109+
110+
try {
111+
const recoveredAddress = ox__Secp256k1.recoverAddress({
112+
payload: messageHash,
113+
signature: ox__Signature.fromHex(signature),
114+
});
115+
116+
if (recoveredAddress.toLowerCase() === address.toLowerCase()) {
117+
return true;
118+
}
119+
} catch {
120+
// no-op, we skip to contract signature check
121+
}
104122
return verifyHash({
105123
accountFactory,
106124
address,

0 commit comments

Comments
 (0)