Skip to content

Remove public actions requirement and loose smart account type #264

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import type {
Chain,
Client,
Hex,
PublicActions,
PublicRpcSchema,
Transport
} from "viem"
import type { Account, Chain, Client, Hex, Transport } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import type { ENTRYPOINT_ADDRESS_V06_TYPE, Prettify } from "../../types"
import {
Expand All @@ -30,15 +23,10 @@ export type PrivateKeyToBiconomySmartAccountParameters<
export async function privateKeyToBiconomySmartAccount<
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{
privateKey,
...rest
Expand All @@ -49,6 +37,7 @@ export async function privateKeyToBiconomySmartAccount<
entryPoint,
TTransport,
TChain,
TClientAccount,
"privateKey"
>(client, {
signer: privateKeyAccount,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PublicActions, PublicRpcSchema, TypedData } from "viem"
import type { Account, TypedData } from "viem"
import {
type Address,
type Chain,
Expand Down Expand Up @@ -212,16 +212,11 @@ export async function signerToBiconomySmartAccount<
entryPoint extends ENTRYPOINT_ADDRESS_V06_TYPE,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined,
TSource extends string = string,
TAddress extends Address = Address
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{
signer,
address,
Expand Down Expand Up @@ -311,7 +306,7 @@ export async function signerToBiconomySmartAccount<
TTypedData,
TPrimaryType,
TChain,
undefined
TClientAccount
>(client, {
account: viemSigner,
...typedData
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PublicActions, PublicRpcSchema, TypedData } from "viem"
import type { Account, TypedData } from "viem"
import {
type Address,
type Chain,
Expand Down Expand Up @@ -316,14 +316,15 @@ const getAccountInitCode = async <entryPoint extends EntryPoint>({
const getAccountAddress = async <
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>({
client,
entryPoint: entryPointAddress,
factory,
factoryData
}: {
client: Client<TTransport, TChain>
client: Client<TTransport, TChain, TClientAccount>
entryPoint: entryPoint
factory: Address
factoryData: Hex
Expand Down Expand Up @@ -373,16 +374,11 @@ export async function signerToEcdsaKernelSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined,
TSource extends string = string,
TAddress extends Address = Address
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{
signer,
address,
Expand Down Expand Up @@ -435,7 +431,7 @@ export async function signerToEcdsaKernelSmartAccount<
// Fetch account address and chain id
const [accountAddress, chainId] = await Promise.all([
address ??
getAccountAddress<entryPoint, TTransport, TChain>({
getAccountAddress({
client,
factory:
entryPointVersion === "v0.6"
Expand Down Expand Up @@ -487,7 +483,7 @@ export async function signerToEcdsaKernelSmartAccount<
TTypedData,
TPrimaryType,
TChain,
undefined
TClientAccount
>(client, {
account: viemSigner,
...typedData,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import type {
Chain,
Client,
Hex,
PublicActions,
PublicRpcSchema,
Transport
} from "viem"
import type { Account, Chain, Client, Hex, Transport } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import type { Prettify } from "../../types"
import type { EntryPoint } from "../../types"
Expand All @@ -31,15 +24,10 @@ export type PrivateKeyToLightSmartAccountParameters<
export async function privateKeyToLightSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{ privateKey, ...rest }: PrivateKeyToLightSmartAccountParameters<entryPoint>
): Promise<LightSmartAccount<entryPoint, TTransport, TChain>> {
const privateKeyAccount = privateKeyToAccount(privateKey)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {
type Account,
type Address,
type Chain,
type Client,
type Hex,
type LocalAccount,
type PublicActions,
type PublicRpcSchema,
type Transport,
type TypedData,
type TypedDataDefinition,
Expand Down Expand Up @@ -80,15 +79,16 @@ const getAccountInitCode = async (
const getAccountAddress = async <
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>({
client,
factoryAddress,
entryPoint: entryPointAddress,
owner,
index = BigInt(0)
}: {
client: Client<TTransport, TChain>
client: Client<TTransport, TChain, TClientAccount>
factoryAddress: Address
owner: Address
entryPoint: entryPoint
Expand Down Expand Up @@ -191,16 +191,11 @@ export async function signerToLightSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined,
TSource extends string = string,
TAddress extends Address = Address
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{
signer,
address,
Expand Down Expand Up @@ -230,7 +225,7 @@ export async function signerToLightSmartAccount<

const [accountAddress, chainId] = await Promise.all([
address ??
getAccountAddress<entryPoint, TTransport, TChain>({
getAccountAddress({
client,
factoryAddress,
entryPoint: entryPointAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import type {
Chain,
Client,
Hex,
PublicActions,
PublicRpcSchema,
Transport
} from "viem"
import type { Account, Chain, Client, Hex, Transport } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import type { EntryPoint, Prettify } from "../../types"
import {
Expand All @@ -30,15 +23,10 @@ export type PrivateKeyToSafeSmartAccountParameters<
export async function privateKeyToSafeSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{ privateKey, ...rest }: PrivateKeyToSafeSmartAccountParameters<entryPoint>
): Promise<SafeSmartAccount<entryPoint, TTransport, TChain>> {
const privateKeyAccount = privateKeyToAccount(privateKey)
Expand Down
19 changes: 7 additions & 12 deletions packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {
type Account,
type Address,
type Chain,
type Client,
type Hex,
type LocalAccount,
type PublicActions,
type PublicRpcSchema,
type SignableMessage,
type Transport,
type TypedData,
Expand Down Expand Up @@ -864,7 +863,8 @@ const getAccountInitCode = async ({

const getAccountAddress = async <
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>({
client,
owner,
Expand All @@ -884,7 +884,7 @@ const getAccountAddress = async <
attesters = [],
attestersThreshold = 0
}: {
client: Client<TTransport, TChain>
client: Client<TTransport, TChain, TClientAccount>
owner: Address
safeModuleSetupAddress: Address
safe4337ModuleAddress: Address
Expand Down Expand Up @@ -1087,17 +1087,12 @@ export async function signerToSafeSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined,
TSource extends string = string,
TAddress extends Address = Address,
TErc7579 extends Address | undefined = undefined
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
args: SignerToSafeSmartAccountParameters<
entryPoint,
TSource,
Expand Down Expand Up @@ -1180,7 +1175,7 @@ export async function signerToSafeSmartAccount<

const accountAddress =
address ??
(await getAccountAddress<TTransport, TChain>({
(await getAccountAddress({
client,
owner: viemSigner.address,
safeModuleSetupAddress,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import type {
Address,
Chain,
Client,
Hex,
PublicActions,
PublicRpcSchema,
Transport
} from "viem"
import type { Account, Address, Chain, Client, Hex, Transport } from "viem"
import { privateKeyToAccount } from "viem/accounts"
import type { EntryPoint, Prettify } from "../../types"
import {
Expand All @@ -31,15 +23,10 @@ export type PrivateKeyToSimpleSmartAccountParameters<
export async function privateKeyToSimpleSmartAccount<
entryPoint extends EntryPoint,
TTransport extends Transport = Transport,
TChain extends Chain | undefined = Chain | undefined
TChain extends Chain | undefined = Chain | undefined,
TClientAccount extends Account | undefined = undefined
>(
client: Client<
TTransport,
TChain,
undefined,
PublicRpcSchema,
PublicActions<TTransport, TChain>
>,
client: Client<TTransport, TChain, TClientAccount>,
{
privateKey,
...rest
Expand All @@ -51,6 +38,7 @@ export async function privateKeyToSimpleSmartAccount<
entryPoint,
TTransport,
TChain,
TClientAccount,
"privateKey",
Address
>(client, {
Expand Down
Loading
Loading