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

Etherspot account, actions and client #282

Merged
merged 15 commits into from
Dec 12, 2024
Merged
5 changes: 5 additions & 0 deletions .changeset/ninety-forks-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Added support for Etherspot Smart Account
2 changes: 1 addition & 1 deletion .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name": "permissionless (esm)",
"path": "./packages/permissionless/_esm/index.js",
"limit": "50 kB",
"limit": "55 kB",
"import": "*"
},
{
Expand Down
12 changes: 12 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/constants.ts

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions packages/permissionless-test/mock-aa-infra/alto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import {
ENTRY_POINT_V06_CREATECALL,
ENTRY_POINT_V07_CREATECALL,
ERC_7579_TEST_MODULE_CREATECALL,
ETHERSPOT_BOOTSTRAP_CREATECALL,
ETHERSPOT_IMPLEMENTATION,
ETHERSPOT_MULTIPLE_OWNER_ECDSA_VALIDATOR_CREATECALL,
ETHERSPOT_WALLET_FACTORY_CREATECALL,
KERNEL_V06_ACCOUNT_V2_1_LOGIC_CREATECALL,
KERNEL_V06_ACCOUNT_V2_2_LOGIC_CREATECALL,
KERNEL_V06_ACCOUNT_V2_3_LOGIC_CREATECALL,
Expand Down Expand Up @@ -385,6 +389,30 @@ export const setupContracts = async (rpc: string) => {
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: ETHERSPOT_WALLET_FACTORY_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: ETHERSPOT_IMPLEMENTATION,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: ETHERSPOT_BOOTSTRAP_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: DETERMINISTIC_DEPLOYER,
data: ETHERSPOT_MULTIPLE_OWNER_ECDSA_VALIDATOR_CREATECALL,
gas: 15_000_000n,
nonce: nonce++
}),
walletClient.sendTransaction({
to: SAFE_SINGLETON_FACTORY,
data: SAFE_7579_MODULE_CREATECALL,
Expand Down Expand Up @@ -640,6 +668,10 @@ export const setupContracts = async (rpc: string) => {
"0x3143E1C0Af0Cdc153423863923Cf4e3818e34Daa", // Trust TokenReceiverFacet
"0xCe36b85d12D81cd619C745c7717f3396E184Ac7C", // Trust DiamondLoupeFacet
"0x2e7f1dAe1F3799d20f5c31bEFdc7A620f664728D", // Trust DefaultFallbackHandler
"0x93FB56A4a0B7160fbf8903d251Cc7A3fb9bA0933", // Etherspot Factory
"0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066", // Etherspot Bootstrap
"0x7aCEE15c9FFc1e8f287C26E0f4C8244A0729F557", // Etherspot Multiple Owner ECDSA Validator
"0x202A5598bDba2cE62bFfA13EcccB04969719Fad9", // Etherspot implementation
"0x4Fd8d57b94966982B62e9588C27B4171B55E8354", // ERC7579 Test Module
"0x85e23b94e7F5E9cC1fF78BCe78cfb15B81f0DF00", // Thirdweb factory 0.6
"0x4be0ddfebca9a5a4a617dee4dece99e7c862dceb", // Thirdweb factory 0.7
Expand Down
29 changes: 29 additions & 0 deletions packages/permissionless-test/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
toThirdwebSmartAccount
} from "../../permissionless/accounts"
import { toBiconomySmartAccount } from "../../permissionless/accounts/biconomy/toBiconomySmartAccount"
import { toEtherspotSmartAccount } from "../../permissionless/accounts/etherspot/toEtherspotSmartAccount"
import {
type LightAccountVersion,
toLightSmartAccount
Expand Down Expand Up @@ -395,6 +396,21 @@ export const getThirdwebClient = async <
})
}

export const getEtherspotClient = async <
entryPointVersion extends "0.6" | "0.7"
>({
anvilRpc
}: AAParamType<entryPointVersion>) => {
return toEtherspotSmartAccount({
client: getPublicClient(anvilRpc),
owners: [privateKeyToAccount(generatePrivateKey())],
entryPoint: {
address: entryPoint07Address,
version: "0.7"
}
})
}

export const getCoreSmartAccounts = () => [
{
name: "Trust",
Expand Down Expand Up @@ -645,6 +661,19 @@ export const getCoreSmartAccounts = () => [
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Etherspot",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
conf: AAParamType<entryPointVersion>
) =>
getBundlerClient({
account: await getEtherspotClient(conf),
...conf
}),
supportsEntryPointV06: false,
supportsEntryPointV07: true,
isEip1271Compliant: true
},
{
name: "Thirdweb",
getSmartAccountClient: async <entryPointVersion extends "0.6" | "0.7">(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export const EtherspotBootstrapAbi = [
{
inputs: [
{
components: [
{
internalType: "address",
name: "module",
type: "address"
},
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
internalType: "struct BootstrapConfig[]",
name: "$valdiators",
type: "tuple[]"
},
{
components: [
{
internalType: "address",
name: "module",
type: "address"
},
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
internalType: "struct BootstrapConfig[]",
name: "$executors",
type: "tuple[]"
},
{
components: [
{
internalType: "address",
name: "module",
type: "address"
},
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
internalType: "struct BootstrapConfig",
name: "_hook",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "module",
type: "address"
},
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
internalType: "struct BootstrapConfig[]",
name: "_fallbacks",
type: "tuple[]"
}
],
name: "initMSA",
outputs: [],
stateMutability: "nonpayable",
type: "function"
}
]

export const EtherspotOnInstallAbi = [
{
inputs: [
{
internalType: "bytes",
name: "data",
type: "bytes"
}
],
name: "onInstall",
outputs: [],
stateMutability: "nonpayable",
type: "function"
}
] as const
27 changes: 27 additions & 0 deletions packages/permissionless/accounts/etherspot/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { Address } from "viem"

export const DUMMY_ECDSA_SIGNATURE =
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c"

export const VALIDATOR_TYPE = {
ROOT: "0x00",
VALIDATOR: "0x01",
PERMISSION: "0x02"
} as const

export enum VALIDATOR_MODE {
DEFAULT = "0x00",
ENABLE = "0x01"
}

export type NetworkAddresses = {
metaFactoryAddress: Address
bootstrapAddress: Address
validatorAddress: Address
}

export const DEFAULT_CONTRACT_ADDRESS: NetworkAddresses = {
metaFactoryAddress: "0x93FB56A4a0B7160fbf8903d251Cc7A3fb9bA0933", // modularEtherspotWalletFactory
bootstrapAddress: "0x1baCB2F1ef4fD02f02e32cCF70888D9Caeb5f066",
validatorAddress: "0x7aCEE15c9FFc1e8f287C26E0f4C8244A0729F557" // multipleOwnerECDSAValidator
}
Loading
Loading