Skip to content

Commit

Permalink
feat(sdk): add eagerDeployment option to smart wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
gregfromstl committed Dec 27, 2024
1 parent 81685ff commit 61f9bbc
Show file tree
Hide file tree
Showing 7 changed files with 911 additions and 640 deletions.
15 changes: 15 additions & 0 deletions .changeset/polite-trains-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"thirdweb": minor
---

Feature: Adds eagerDeployment option for smart accounts that need EIP-1271 signatures.

When setting `eagerDeployment` to `true`, smart accounts will use the legacy behavior of deploying prior to signing a message or typed data.

```ts
const wallet = smartWallet({
chain,
gasless: true,
eagerDeployment: true,
});
```
21 changes: 12 additions & 9 deletions packages/thirdweb/src/auth/verify-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ export async function verifyHash({
try {
const result = await eth_call(rpcRequest, verificationData);
return hexToBool(result);
} catch (err) {
console.error("Error verifying ERC-6492 signature", err);
} catch {
// Some chains do not support the eth_call simulation and will fail, so we fall back to regular EIP1271 validation
const validEip1271 = await verifyEip1271Signature({
hash,
Expand All @@ -154,7 +153,7 @@ export async function verifyHash({
}

const EIP_1271_MAGIC_VALUE = "0x1626ba7e";
async function verifyEip1271Signature({
export async function verifyEip1271Signature({
hash,
signature,
contract,
Expand All @@ -163,10 +162,14 @@ async function verifyEip1271Signature({
signature: Hex;
contract: ThirdwebContract;
}): Promise<boolean> {
const result = await isValidSignature({
hash,
signature,
contract,
});
return result === EIP_1271_MAGIC_VALUE;
try {
const result = await isValidSignature({
hash,
signature,
contract,
});
return result === EIP_1271_MAGIC_VALUE;
} catch {
return false;
}
}
Loading

0 comments on commit 61f9bbc

Please sign in to comment.