-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add low level support for 7702
- Loading branch information
Showing
13 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { AccountNotFoundError } from "../../errors/account.js"; | ||
import type { ClientMiddlewareFn } from "../types"; | ||
import { defaultUserOpSigner } from "./userOpSigner.js"; | ||
|
||
/** | ||
* Provides a default middleware function for signing user operations with a client account when using ERC-7702 to upgrade local accounts to smart accounts. | ||
* If the SmartAccount doesn't support `signAuthorization`, then this just runs the default UserOpSigner middleware | ||
* | ||
* @param {UserOperationStruct} struct The user operation structure to be signed | ||
* @param {*} params The middleware context containing the client and account information | ||
* @param {Client} params.client The client object, which should include account and chain information | ||
* @param {Account} [params.account] Optional, the account used for signing, defaults to the client's account if not provided | ||
* @returns {Promise<UserOperationStruct>} A promise that resolves to the signed user operation structure | ||
*/ | ||
export const default7702UserOpSigner: ClientMiddlewareFn = async ( | ||
struct, | ||
params | ||
) => { | ||
const uo = await defaultUserOpSigner(struct, params); | ||
const account = params.account ?? params.client.account; | ||
if (!account) { | ||
throw new AccountNotFoundError(); | ||
} | ||
|
||
if (!account.signAuthorization) { | ||
return uo; | ||
} | ||
|
||
const code = | ||
(await params.client.getCode({ address: account.address })) ?? "0x"; | ||
// TODO: this isn't the cleanest because now the account implementation HAS to know that it needs to return an impl address | ||
// even if the account is not deployed | ||
const implAddress = await account.getImplementationAddress(); | ||
if ( | ||
code === | ||
"0x00000000000000000000000000000000000000000000000001ff00" + | ||
implAddress.slice(2) | ||
) { | ||
return uo; | ||
} | ||
|
||
return { | ||
...uo, | ||
// TODO: put this in a constant | ||
signature: | ||
"0x00000000000000000000000000000000000000000000000001ff00" + | ||
(await uo.signature).slice(2), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// This file is autogenerated by inject-version.ts. Any changes will be | ||
// overwritten on commit! | ||
export const VERSION = "4.5.1"; | ||
export const VERSION = "4.6.0"; |
43 changes: 43 additions & 0 deletions
43
site/pages/reference/aa-sdk/core/functions/default7702UserOpSigner.mdx
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.