Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/safe onchain identifier #370

Merged
merged 4 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/grumpy-readers-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Deprecated toSafeSmartAccount's setupTransactions field
5 changes: 5 additions & 0 deletions .changeset/old-apples-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added onchainIdentier param for toSafeSmartAccount
21 changes: 19 additions & 2 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
http,
type Account,
type Hex,
createPublicClient,
createWalletClient
} from "viem"
import {
type SmartAccount,
createBundlerClient,
createPaymasterClient,
entryPoint06Address,
entryPoint07Address
Expand Down Expand Up @@ -349,17 +349,20 @@ export const getSafeClient = async <entryPointVersion extends "0.6" | "0.7">({
anvilRpc,
erc7579,
privateKey,
owners
owners,
onchainIdentifier
}: {
erc7579?: boolean
owners?: Account[]
onchainIdentifier?: Hex
} & AAParamType<entryPointVersion>): Promise<
ToSafeSmartAccountReturnType<entryPointVersion>
> => {
const publicClient = getPublicClient(anvilRpc)

return toSafeSmartAccount({
client: publicClient,
onchainIdentifier,
entryPoint: {
address:
entryPoint.version === "0.6"
Expand Down Expand Up @@ -716,6 +719,20 @@ export const getCoreSmartAccounts = () => [
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Safe (with onchain identifier)",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
conf: AAParamType<entryPointVersion>
) =>
getBundlerClient({
account: await getSafeClient(conf),
...conf
}),
onchainIdentifier: "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
supportsEntryPointV06: true,
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Safe multiple owners",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
Expand Down
13 changes: 11 additions & 2 deletions packages/permissionless/accounts/safe/toSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@
safeModuleSetupAddress?: Address
multiSendAddress?: Address
multiSendCallOnlyAddress?: Address
// @deprecated This field is deprecated. It is recommended to make any setup transactions in the userOperation's calldata.
setupTransactions?: {
to: Address
data: Address
Expand Down Expand Up @@ -975,6 +976,7 @@
paymentToken?: Address
payment?: bigint
paymentReceiver?: Address
onchainIdentifier?: Hex
} & GetErc7579Params<TErc7579>

function isErc7579Args<entryPointVersion extends "0.6" | "0.7" = "0.7">(
Expand Down Expand Up @@ -1149,7 +1151,8 @@
nonceKey,
paymentToken,
payment,
paymentReceiver
paymentReceiver,
onchainIdentifier
} = parameters

const owners = await Promise.all(
Expand Down Expand Up @@ -1421,11 +1424,17 @@
value = call.value ?? 0n
}

return encodeFunctionData({
const calldata = encodeFunctionData({
abi: executeUserOpWithErrorStringAbi,
functionName: "executeUserOpWithErrorString",
args: [to, value, data, operationType]
})

if (onchainIdentifier) {
return concat([calldata, onchainIdentifier])

Check warning on line 1434 in packages/permissionless/accounts/safe/toSafeSmartAccount.ts

View check run for this annotation

Codecov / codecov/patch

packages/permissionless/accounts/safe/toSafeSmartAccount.ts#L1434

Added line #L1434 was not covered by tests
}

return calldata
},
async decodeCalls(callData) {
try {
Expand Down
Loading