Skip to content

Fix 359 #360

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

Merged
merged 7 commits into from
Feb 5, 2025
Merged
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
5 changes: 5 additions & 0 deletions .changeset/wise-paws-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Fixed support viem>=2.21.59
4 changes: 2 additions & 2 deletions packages/permissionless/accounts/safe/toSafeSmartAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,8 @@ export async function toSafeSmartAccount<
let _multiSendCallOnlyAddress: Address | undefined = undefined
let safeModules: Address[] | undefined = undefined
let setupTransactions: {
to: `0x${string}`
data: `0x${string}`
to: Address
data: Hex
value: bigint
}[] = []
let validators: { address: Address; context: Address }[] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { encodeFunctionData } from "viem"
import { type Address, type Hex, encodeFunctionData } from "viem"

export const encodeCallData = async (
calls: readonly {
to: `0x${string}`
to: Address
value?: bigint | undefined
data?: `0x${string}` | undefined
data?: Hex | undefined
}[]
) => {
if (calls.length > 1) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { encodeFunctionData } from "viem"
import { type Address, type Hex, encodeFunctionData } from "viem"

export const encodeCallData = async (
calls: readonly {
to: `0x${string}`
to: Address
value?: bigint | undefined
data?: `0x${string}` | undefined
data?: Hex | undefined
}[]
) => {
if (calls.length > 1) {
Expand Down
16 changes: 8 additions & 8 deletions packages/permissionless/actions/erc7579.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export type Erc7579Actions<TSmartAccount extends SmartAccount | undefined> = {
accountId: (
args?: GetSmartAccountParameter<TSmartAccount>
) => Promise<string>
installModule: <callsType extends readonly unknown[]>(
args: InstallModuleParameters<TSmartAccount, callsType>
installModule: (
args: InstallModuleParameters<TSmartAccount>
) => Promise<Hash>
installModules: <callsType extends readonly unknown[]>(
args: InstallModulesParameters<TSmartAccount, callsType>
installModules: (
args: InstallModulesParameters<TSmartAccount>
) => Promise<Hash>
isModuleInstalled: (
args: IsModuleInstalledParameters<TSmartAccount>
Expand All @@ -57,11 +57,11 @@ export type Erc7579Actions<TSmartAccount extends SmartAccount | undefined> = {
supportsModule: (
args: SupportsModuleParameters<TSmartAccount>
) => Promise<boolean>
uninstallModule: <callsType extends readonly unknown[]>(
args: UninstallModuleParameters<TSmartAccount, callsType>
uninstallModule: (
args: UninstallModuleParameters<TSmartAccount>
) => Promise<Hash>
uninstallModules: <callsType extends readonly unknown[]>(
args: UninstallModulesParameters<TSmartAccount, callsType>
uninstallModules: (
args: UninstallModulesParameters<TSmartAccount>
) => Promise<Hash>
}

Expand Down
25 changes: 10 additions & 15 deletions packages/permissionless/actions/erc7579/installModule.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { Address, Client, Hex, Narrow, OneOf } from "viem"
import type { Address, Client, Hex, OneOf } from "viem"
import {
type GetSmartAccountParameter,
type PaymasterActions,
type SmartAccount,
type UserOperationCalls,
sendUserOperation
} from "viem/account-abstraction"
import { getAction, parseAccount } from "viem/utils"
Expand All @@ -12,15 +11,18 @@ import { encodeInstallModule } from "../../utils/encodeInstallModule.js"
import type { ModuleType } from "./supportsModule.js"

export type InstallModuleParameters<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
> = GetSmartAccountParameter<TSmartAccount> & {
type: ModuleType
address: Address
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
nonce?: bigint
calls?: UserOperationCalls<Narrow<calls>>
calls?: readonly {
to: Address
value?: bigint | undefined
data?: Hex | undefined
}[]
paymaster?:
| Address
| true
Expand All @@ -46,12 +48,9 @@ export type InstallModuleParameters<
}
>

export async function installModule<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
>(
export function installModule<TSmartAccount extends SmartAccount | undefined>(
client: Client,
parameters: InstallModuleParameters<TSmartAccount, calls>
parameters: InstallModuleParameters<TSmartAccount>
): Promise<Hex> {
const {
account: account_ = client.account,
Expand Down Expand Up @@ -85,11 +84,7 @@ export async function installModule<
account,
modules: [{ address, context: context ?? initData, type }]
}),
...((calls ?? []) as readonly {
to: `0x${string}`
value: bigint
data: `0x${string}`
}[])
...(calls ?? [])
],
paymaster,
paymasterContext,
Expand Down
23 changes: 10 additions & 13 deletions packages/permissionless/actions/erc7579/installModules.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Address, Chain, Client, Hex, Narrow, Transport } from "viem"
import type { Address, Chain, Client, Hex, Transport } from "viem"
import {
type PaymasterActions,
type SmartAccount,
type UserOperationCalls,
sendUserOperation
} from "viem/account-abstraction"
import { getAction, parseAccount } from "viem/utils"
Expand All @@ -13,13 +12,16 @@ import {
} from "../../utils/encodeInstallModule.js"

export type InstallModulesParameters<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
> = EncodeInstallModuleParameters<TSmartAccount> & {
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
nonce?: bigint
calls?: UserOperationCalls<Narrow<calls>>
calls?: readonly {
to: Address
value?: bigint | undefined
data?: Hex | undefined
}[]
paymaster?:
| Address
| true
Expand All @@ -39,11 +41,10 @@ export type InstallModulesParameters<
}

export async function installModules<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
>(
client: Client<Transport, Chain | undefined, TSmartAccount>,
parameters: InstallModulesParameters<TSmartAccount, calls>
parameters: InstallModulesParameters<TSmartAccount>
): Promise<Hex> {
const {
account: account_ = client.account,
Expand Down Expand Up @@ -73,11 +74,7 @@ export async function installModules<
account,
modules
}),
...((calls ?? []) as readonly {
to: `0x${string}`
value: bigint
data: `0x${string}`
}[])
...(calls ?? [])
],
paymaster,
paymasterContext,
Expand Down
31 changes: 10 additions & 21 deletions packages/permissionless/actions/erc7579/uninstallModule.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import type {
Address,
Chain,
Client,
Hex,
Narrow,
OneOf,
Transport
} from "viem"
import type { Address, Chain, Client, Hex, OneOf, Transport } from "viem"
import {
type GetSmartAccountParameter,
type PaymasterActions,
type SmartAccount,
type UserOperationCalls,
sendUserOperation
} from "viem/account-abstraction"
import { getAction } from "viem/utils"
Expand All @@ -21,15 +12,18 @@ import { encodeUninstallModule } from "../../utils/encodeUninstallModule.js"
import type { ModuleType } from "./supportsModule.js"

export type UninstallModuleParameters<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
> = GetSmartAccountParameter<TSmartAccount> & {
type: ModuleType
address: Address
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
nonce?: bigint
calls?: UserOperationCalls<Narrow<calls>>
calls?: readonly {
to: Address
value?: bigint | undefined
data?: Hex | undefined
}[]
paymaster?:
| Address
| true
Expand All @@ -56,11 +50,10 @@ export type UninstallModuleParameters<
>

export async function uninstallModule<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
>(
client: Client<Transport, Chain | undefined, TSmartAccount>,
parameters: UninstallModuleParameters<TSmartAccount, calls>
parameters: UninstallModuleParameters<TSmartAccount>
): Promise<Hex> {
const {
account: account_ = client.account,
Expand Down Expand Up @@ -94,11 +87,7 @@ export async function uninstallModule<
account,
modules: [{ type, address, context: context ?? deInitData }]
}),
...((calls ?? []) as readonly {
to: `0x${string}`
value: bigint
data: `0x${string}`
}[])
...(calls ?? [])
],
paymaster,
paymasterContext,
Expand Down
23 changes: 10 additions & 13 deletions packages/permissionless/actions/erc7579/uninstallModules.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Address, Chain, Client, Hex, Narrow, Transport } from "viem"
import type { Address, Chain, Client, Hex, Transport } from "viem"
import {
type PaymasterActions,
type SmartAccount,
type UserOperationCalls,
sendUserOperation
} from "viem/account-abstraction"
import { getAction } from "viem/utils"
Expand All @@ -14,13 +13,16 @@ import {
} from "../../utils/encodeUninstallModule.js"

export type UninstallModulesParameters<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
> = EncodeUninstallModuleParameters<TSmartAccount> & {
maxFeePerGas?: bigint
maxPriorityFeePerGas?: bigint
nonce?: bigint
calls?: UserOperationCalls<Narrow<calls>>
calls?: readonly {
to: Address
value?: bigint | undefined
data?: Hex | undefined
}[]
paymaster?:
| Address
| true
Expand All @@ -40,11 +42,10 @@ export type UninstallModulesParameters<
}

export async function uninstallModules<
TSmartAccount extends SmartAccount | undefined,
calls extends readonly unknown[]
TSmartAccount extends SmartAccount | undefined
>(
client: Client<Transport, Chain | undefined, TSmartAccount>,
parameters: UninstallModulesParameters<TSmartAccount, calls>
parameters: UninstallModulesParameters<TSmartAccount>
): Promise<Hex> {
const {
account: account_ = client.account,
Expand Down Expand Up @@ -75,11 +76,7 @@ export async function uninstallModules<
account,
modules
}),
...((calls ?? []) as readonly {
to: `0x${string}`
value: bigint
data: `0x${string}`
}[])
...(calls ?? [])
],
paymaster,
paymasterContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type Chain,
type Client,
type ContractFunctionParameters,
type Hex,
RpcError,
type Transport,
encodeFunctionData,
Expand All @@ -19,7 +20,6 @@ import {
type PrepareUserOperationReturnType,
type SmartAccount,
type UserOperation,
type UserOperationCall,
getPaymasterData as getPaymasterData_,
prepareUserOperation
} from "viem/account-abstraction"
Expand Down Expand Up @@ -279,7 +279,11 @@ export const prepareUserOperationForErc20Paymaster =
userOperation.callData = await account.encodeCalls(
finalCalls.map((call_) => {
const call = call_ as
| UserOperationCall
| {
to: Address
value: bigint
data: Hex
}
| (ContractFunctionParameters & {
to: Address
value: bigint
Expand All @@ -289,8 +293,8 @@ export const prepareUserOperationForErc20Paymaster =
data: encodeFunctionData(call),
to: call.to,
value: call.value
} as UserOperationCall
return call as UserOperationCall
}
return call
})
)
parameters.calls = finalCalls
Expand Down