Skip to content

Commit

Permalink
Merge pull request #122 from pimlicolabs/feat/introduce-middleware
Browse files Browse the repository at this point in the history
change providerToSmartAccountSigner positional args to keyword args
  • Loading branch information
plusminushalf authored Feb 25, 2024
2 parents 7e87bf2 + f860a3a commit 2ba4c25
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-rocks-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": minor
---

providerToSmartAccountSigner accepts keyword args
Original file line number Diff line number Diff line change
Expand Up @@ -244,20 +244,14 @@ describe("Simple Account from walletClient", () => {
const publicClient = await getPublicClient()

const bundlerClient = getBundlerClient()
const pimlicoPaymaster = getPimlicoPaymasterClient()

const smartAccountClient = await getSmartAccountClient({
account: await getSignerToSimpleSmartAccount({
signer: await getCustomSignerToSimpleSmartAccount()
}),
sponsorUserOperation: async ({
entryPoint: _entryPoint,
userOperation
}) => {
const pimlicoPaymaster = getPimlicoPaymasterClient()
return pimlicoPaymaster.sponsorUserOperation({
userOperation,
entryPoint: getEntryPoint()
})
middleware: {
sponsorUserOperation: pimlicoPaymaster.sponsorUserOperation
}
})

Expand Down Expand Up @@ -304,20 +298,14 @@ describe("Simple Account from walletClient", () => {
const publicClient = await getPublicClient()

const bundlerClient = getBundlerClient()
const pimlicoPaymaster = getPimlicoPaymasterClient()

const smartAccountClient = await getSmartAccountClient({
account: await getSignerToSimpleSmartAccount({
signer: await getCustomSignerToSimpleSmartAccount()
}),
sponsorUserOperation: async ({
entryPoint: _entryPoint,
userOperation
}) => {
const pimlicoPaymaster = getPimlicoPaymasterClient()
return pimlicoPaymaster.sponsorUserOperation({
userOperation,
entryPoint: getEntryPoint()
})
middleware: {
sponsorUserOperation: pimlicoPaymaster.sponsorUserOperation
}
})

Expand Down
9 changes: 6 additions & 3 deletions packages/permissionless/utils/providerToSmartAccountSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import {
} from "viem"
import { walletClientToSmartAccountSigner } from "./walletClientToSmartAccountSigner"

export const providerToSmartAccountSigner = async (
provider: EIP1193Provider,
export const providerToSmartAccountSigner = async ({
provider,
signerAddress
}: {
provider: EIP1193Provider
signerAddress?: Hex
) => {
}) => {
let account: Hex
if (!signerAddress) {
;[account] = await provider.request({ method: "eth_requestAccounts" })
Expand Down

0 comments on commit 2ba4c25

Please sign in to comment.