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

Add nexus account #318

Merged
merged 5 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 15 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/constants.ts

Large diffs are not rendered by default.

43 changes: 41 additions & 2 deletions packages/permissionless-test/mock-aa-infra/alto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import {
KERNEL_V07_V3_1_FACTORY_CREATECALL,
LIGHT_ACCOUNT_FACTORY_V110_CREATECALL,
LIGHT_ACCOUNT_FACTORY_V200_CREATECALL,
NEXUS_ACCOUNT_BOOTSTRAPPER_CREATECALL,
NEXUS_ACCOUNT_IMPLEMENTATION_CREATECALL,
NEXUS_BOOTSTRAP_LIB_CREATECALL,
NEXUS_K1_VALIDATOR_CREATECALL,
NEXUS_K1_VALIDATOR_FACTORY_CREATECALL,
SAFE_7579_LAUNCHPAD_CREATECALL,
SAFE_7579_MODULE_CREATECALL,
SAFE_7579_REGISTRY_CREATECALL,
Expand Down Expand Up @@ -302,6 +307,12 @@ export const setupContracts = async (rpc: string) => {
data: THIRDWEB_FACTORY_V07_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: NEXUS_BOOTSTRAP_LIB_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
})
])

Expand Down Expand Up @@ -363,12 +374,35 @@ export const setupContracts = async (rpc: string) => {
gas: 15_000_000n,
nonce: nonce++
}),

walletClient.sendTransaction({
to: BICONOMY_SINGLETON_FACTORY,
data: BICONOMY_DEFAULT_FALLBACK_HANDLER_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: BICONOMY_SINGLETON_FACTORY,
data: NEXUS_K1_VALIDATOR_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: BICONOMY_SINGLETON_FACTORY,
data: NEXUS_K1_VALIDATOR_FACTORY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: BICONOMY_SINGLETON_FACTORY,
data: NEXUS_ACCOUNT_IMPLEMENTATION_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: BICONOMY_SINGLETON_FACTORY,
data: NEXUS_ACCOUNT_BOOTSTRAPPER_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
})
])

Expand Down Expand Up @@ -483,6 +517,11 @@ export const setupContracts = async (rpc: string) => {
"0x2e7f1dAe1F3799d20f5c31bEFdc7A620f664728D", // Trust DefaultFallbackHandler
"0xc98B026383885F41d9a995f85FC480E9bb8bB891", // ERC7579 Test Module
"0x85e23b94e7F5E9cC1fF78BCe78cfb15B81f0DF00", // Thirdweb factory 0.6
"0x4be0ddfebca9a5a4a617dee4dece99e7c862dceb" // Thirdweb factory 0.7
"0x4be0ddfebca9a5a4a617dee4dece99e7c862dceb", // Thirdweb factory 0.7
"0x00000bb19a3579F4D779215dEf97AFbd0e30DB55", // Nexus K1 Validator Factory
"0x00000004171351c442B202678c48D8AB5B321E8f", // Nexus K1 Validator
"0x000000039dfcAd030719B07296710F045F0558f7", // Nexus Account Implementation
"0x00000008c901d8871b6F6942De0B5D9cCf3873d3", // Nexus Account Bootstrapper
"0x6c77ddf87a1717465d29f8f16f44711eb0c839c0" // Nexus BootstrapLib
])
}
40 changes: 37 additions & 3 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
type LightAccountVersion,
toLightSmartAccount
} from "../../permissionless/accounts/light/toLightSmartAccount"
import { toNexusSmartAccount } from "../../permissionless/accounts/nexus/toNexusSmartAccount"
import { toSafeSmartAccount } from "../../permissionless/accounts/safe/toSafeSmartAccount"
import {
type ToSimpleSmartAccountReturnType,
Expand Down Expand Up @@ -190,9 +191,9 @@ export const getPimlicoClient = <entryPointVersion extends "0.6" | "0.7">({

export const getPublicClient = (anvilRpc: string) => {
const transport = http(anvilRpc, {
//onFetchRequest: async (req) => {
// console.log(await req.json(), "request")
//},
// onFetchRequest: async (req) => {
// console.log(await req.json(), "request")
// }
//onFetchResponse: async (response) => {
// console.log(await response.clone().json(), "response")
//}
Expand Down Expand Up @@ -287,6 +288,17 @@ export const getBiconomyClient = async <
})
}

export const getNexusClient = async <entryPointVersion extends "0.6" | "0.7">({
anvilRpc,
privateKey
}: AAParamType<entryPointVersion>) => {
return toNexusSmartAccount({
client: getPublicClient(anvilRpc),
owners: [privateKeyToAccount(privateKey ?? generatePrivateKey())],
nexusVersion: "1.0.0"
})
}

export const getKernelEcdsaClient = async <
entryPointVersion extends "0.6" | "0.7"
>({
Expand Down Expand Up @@ -518,6 +530,28 @@ export const getCoreSmartAccounts = () => [
supportsEntryPointV07: false,
isEip1271Compliant: true
},
{
name: "Nexus",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
conf: AAParamType<entryPointVersion>
) =>
getBundlerClient({
account: await getNexusClient(conf),
...conf
}),
getErc7579SmartAccountClient: async <
entryPointVersion extends "0.6" | "0.7"
>(
conf: AAParamType<entryPointVersion>
) =>
getSmartAccountClient({
account: await getNexusClient(conf),
...conf
}),
supportsEntryPointV06: false,
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Safe",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
Expand Down
11 changes: 11 additions & 0 deletions packages/permissionless/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ import {
toBiconomySmartAccount
} from "./biconomy/toBiconomySmartAccount"

import {
type NexusSmartAccountImplementation,
type ToNexusSmartAccountParameters,
type ToNexusSmartAccountReturnType,
toNexusSmartAccount
} from "./nexus/toNexusSmartAccount"

import {
type ThirdwebSmartAccountImplementation,
type ToThirdwebSmartAccountParameters,
Expand Down Expand Up @@ -74,6 +81,10 @@ export {
type SafeVersion,
type KernelVersion,
toEcdsaKernelSmartAccount,
type NexusSmartAccountImplementation,
type ToNexusSmartAccountParameters,
type ToNexusSmartAccountReturnType,
toNexusSmartAccount,
type ToBiconomySmartAccountReturnType,
type ToBiconomySmartAccountParameters,
type BiconomySmartAccountImplementation,
Expand Down
Loading
Loading