-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from pimlicolabs/feat/sendCompressedUserOperation
sendCompressedUserOperation
- Loading branch information
Showing
8 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"permissionless": patch | ||
--- | ||
|
||
Added support for sendCompressedUserOperation Pimlico bundler action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "create-permissionless-app", | ||
"version": "0.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/permissionless/actions/pimlico/sendCompressedUserOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { | ||
Account, | ||
Address, | ||
Chain, | ||
Client, | ||
Hash, | ||
Hex, | ||
Transport | ||
} from "viem" | ||
import type { Prettify } from "../../types/index.js" | ||
import { type PimlicoBundlerRpcSchema } from "../../types/pimlico.js" | ||
|
||
export type SendCompressedUserOperationParameters = { | ||
compressedUserOperation: Hex | ||
inflatorAddress: Address | ||
entryPoint: Address | ||
} | ||
|
||
/** | ||
* Sends a compressed user operation to the bundler | ||
* | ||
* - Docs: https://docs.pimlico.io/permissionless/reference/pimlico-bundler-actions/sendCompressedUserOperation | ||
* | ||
* @param client {@link PimlicoBundlerClient} that you created using viem's createClient whose transport url is pointing to the Pimlico's bundler. | ||
* @param args {@link SendCompressedUserOperationParameters}. | ||
* @returns UserOpHash that you can use to track user operation as {@link Hash}. | ||
* | ||
* @example | ||
* import { pimlicoBundlerActions, sendCompressedUserOperation } from 'permissionless/actions/pimlico' | ||
* import { createClient } from "viem" | ||
* | ||
* const bundlerClient = createClient({ | ||
* chain: goerli, | ||
* transport: http("https://api.pimlico.io/v2/goerli/rpc?apikey=YOUR_API_KEY_HERE") | ||
* }).extend(pimlicoBundlerActions) | ||
* | ||
* const userOpHash = await sendCompressedUserOperation(bundlerClient, { | ||
* compressedUserOperation, | ||
* inflatorAddress, | ||
* entryPoint | ||
* }) | ||
* // Return '0xe9fad2cd67f9ca1d0b7a6513b2a42066784c8df938518da2b51bb8cc9a89ea34' | ||
*/ | ||
export const sendCompressedUserOperation = async < | ||
TTransport extends Transport = Transport, | ||
TChain extends Chain | undefined = Chain | undefined, | ||
TAccount extends Account | undefined = Account | undefined | ||
>( | ||
client: Client<TTransport, TChain, TAccount, PimlicoBundlerRpcSchema>, | ||
args: Prettify<SendCompressedUserOperationParameters> | ||
): Promise<Hash> => { | ||
const { compressedUserOperation, inflatorAddress, entryPoint } = args | ||
|
||
return client.request({ | ||
method: "pimlico_sendCompressedUserOperation", | ||
params: [ | ||
compressedUserOperation as Hex, | ||
inflatorAddress as Address, | ||
entryPoint as Address | ||
] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters