permissionless 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/_cjs/actions/bundler/estimateUserOperationGas.js +2 -2
- package/_cjs/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/actions/bundler/getUserOperationReceipt.js +2 -2
- package/_cjs/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_cjs/actions/bundler/sendUserOperation.js +2 -2
- package/_cjs/actions/bundler/sendUserOperation.js.map +1 -1
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js +46 -0
- package/_cjs/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_cjs/actions/index.js +5 -1
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/pimlico/sponsorUserOperation.js +2 -2
- package/_cjs/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_cjs/actions/stackup/sponsorUserOperation.js +2 -2
- package/_cjs/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_cjs/clients/bundler.js.map +1 -1
- package/_cjs/clients/decorators/bundler.js +3 -1
- package/_cjs/clients/decorators/bundler.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/{actions/utils.js → utils/deepHexlify.js} +1 -1
- package/_cjs/utils/deepHexlify.js.map +1 -0
- package/_cjs/utils/observe.js +39 -0
- package/_cjs/utils/observe.js.map +1 -0
- package/_esm/actions/bundler/estimateUserOperationGas.js +1 -1
- package/_esm/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js +1 -1
- package/_esm/actions/bundler/getUserOperationReceipt.js.map +1 -1
- package/_esm/actions/bundler/sendUserOperation.js +1 -1
- package/_esm/actions/bundler/sendUserOperation.js.map +1 -1
- package/_esm/actions/bundler/waitForUserOperationReceipt.js +63 -0
- package/_esm/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_esm/actions/index.js +3 -1
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js +1 -1
- package/_esm/actions/pimlico/sponsorUserOperation.js.map +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js +1 -1
- package/_esm/actions/stackup/sponsorUserOperation.js.map +1 -1
- package/_esm/clients/bundler.js.map +1 -1
- package/_esm/clients/decorators/bundler.js +3 -1
- package/_esm/clients/decorators/bundler.js.map +1 -1
- package/_esm/index.js +3 -1
- package/_esm/index.js.map +1 -1
- package/_esm/{actions/utils.js → utils/deepHexlify.js} +1 -1
- package/_esm/utils/deepHexlify.js.map +1 -0
- package/_esm/utils/observe.js +42 -0
- package/_esm/utils/observe.js.map +1 -0
- package/_types/actions/bundler/getUserOperationReceipt.d.ts +2 -33
- package/_types/actions/bundler/getUserOperationReceipt.d.ts.map +1 -1
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts +43 -0
- package/_types/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -0
- package/_types/actions/index.d.ts +4 -2
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/clients/bundler.d.ts +1 -1
- package/_types/clients/bundler.d.ts.map +1 -1
- package/_types/clients/decorators/bundler.d.ts +24 -1
- package/_types/clients/decorators/bundler.d.ts.map +1 -1
- package/_types/index.d.ts +4 -2
- package/_types/index.d.ts.map +1 -1
- package/_types/{actions/utils.d.ts → utils/deepHexlify.d.ts} +1 -1
- package/_types/utils/deepHexlify.d.ts.map +1 -0
- package/_types/utils/observe.d.ts +17 -0
- package/_types/utils/observe.d.ts.map +1 -0
- package/actions/bundler/estimateUserOperationGas.ts +1 -1
- package/actions/bundler/getUserOperationReceipt.ts +6 -3
- package/actions/bundler/sendUserOperation.ts +1 -1
- package/actions/bundler/waitForUserOperationReceipt.ts +80 -0
- package/actions/index.ts +10 -2
- package/actions/pimlico/sponsorUserOperation.ts +1 -1
- package/actions/stackup/sponsorUserOperation.ts +1 -1
- package/clients/bundler.ts +7 -1
- package/clients/decorators/bundler.ts +35 -2
- package/index.ts +10 -2
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/observe.ts +61 -0
- package/_cjs/actions/utils.js.map +0 -1
- package/_esm/actions/utils.js.map +0 -1
- package/_types/actions/utils.d.ts.map +0 -1
- /package/{actions/utils.ts → utils/deepHexlify.ts} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const listenersCache = /*#__PURE__*/ new Map();
|
|
2
|
+
export const cleanupCache = /*#__PURE__*/ new Map();
|
|
3
|
+
let callbackCount = 0;
|
|
4
|
+
/**
|
|
5
|
+
* @description Sets up an observer for a given function. If another function
|
|
6
|
+
* is set up under the same observer id, the function will only be called once
|
|
7
|
+
* for both instances of the observer.
|
|
8
|
+
*/
|
|
9
|
+
export function observe(observerId, callbacks, fn) {
|
|
10
|
+
const callbackId = ++callbackCount;
|
|
11
|
+
const getListeners = () => listenersCache.get(observerId) || [];
|
|
12
|
+
const unsubscribe = () => {
|
|
13
|
+
const listeners = getListeners();
|
|
14
|
+
listenersCache.set(observerId,
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: it's a recursive function, so it's hard to type
|
|
16
|
+
listeners.filter((cb) => cb.id !== callbackId));
|
|
17
|
+
};
|
|
18
|
+
const unwatch = () => {
|
|
19
|
+
const cleanup = cleanupCache.get(observerId);
|
|
20
|
+
if (getListeners().length === 1 && cleanup)
|
|
21
|
+
cleanup();
|
|
22
|
+
unsubscribe();
|
|
23
|
+
};
|
|
24
|
+
const listeners = getListeners();
|
|
25
|
+
listenersCache.set(observerId, [...listeners, { id: callbackId, fns: callbacks }]);
|
|
26
|
+
if (listeners && listeners.length > 0)
|
|
27
|
+
return unwatch;
|
|
28
|
+
const emit = {};
|
|
29
|
+
for (const key in callbacks) {
|
|
30
|
+
emit[key] = ((...args) => {
|
|
31
|
+
const listeners = getListeners();
|
|
32
|
+
if (listeners.length === 0)
|
|
33
|
+
return;
|
|
34
|
+
listeners.forEach((listener) => listener.fns[key]?.(...args));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const cleanup = fn(emit);
|
|
38
|
+
if (typeof cleanup === "function")
|
|
39
|
+
cleanupCache.set(observerId, cleanup);
|
|
40
|
+
return unwatch;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=observe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../utils/observe.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,GAAG,EAA4C,CAAA;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,GAAG,EAAsB,CAAA;AAIvE,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACnB,UAAkB,EAClB,SAAqB,EACrB,EAA4B;IAE5B,MAAM,UAAU,GAAG,EAAE,aAAa,CAAA;IAElC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;IAE/D,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;QAChC,cAAc,CAAC,GAAG,CACd,UAAU;QACV,8FAA8F;QAC9F,SAAS,CAAC,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,CACtD,CAAA;IACL,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACjB,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC5C,IAAI,YAAY,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO;YAAE,OAAO,EAAE,CAAA;QACrD,WAAW,EAAE,CAAA;IACjB,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,GAAG,SAAS,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IAElF,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAA;IAErD,MAAM,IAAI,GAAe,EAAgB,CAAA;IACzC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE;QACzB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAA2D,EAAE,EAAE;YAC5E,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;YAChC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAM;YAClC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;QACjE,CAAC,CAAkD,CAAA;KACtD;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAExE,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -35,7 +35,7 @@ export type GetUserOperationReceiptReturnType = {
|
|
|
35
35
|
address: Address;
|
|
36
36
|
topics: Hex[];
|
|
37
37
|
}[];
|
|
38
|
-
}
|
|
38
|
+
};
|
|
39
39
|
/**
|
|
40
40
|
* Returns the user operation receipt from userOpHash
|
|
41
41
|
*
|
|
@@ -58,36 +58,5 @@ export type GetUserOperationReceiptReturnType = {
|
|
|
58
58
|
* getUserOperationReceipt(bundlerClient, {hash: userOpHash})
|
|
59
59
|
*
|
|
60
60
|
*/
|
|
61
|
-
export declare const getUserOperationReceipt: (client: BundlerClient, { hash }: GetUserOperationReceiptParameters) => Promise<
|
|
62
|
-
userOpHash: Hash;
|
|
63
|
-
sender: Address;
|
|
64
|
-
nonce: bigint;
|
|
65
|
-
actualGasUsed: bigint;
|
|
66
|
-
actualGasCost: bigint;
|
|
67
|
-
success: boolean;
|
|
68
|
-
receipt: {
|
|
69
|
-
transactionHash: Hex;
|
|
70
|
-
transactionIndex: bigint;
|
|
71
|
-
blockHash: Hash;
|
|
72
|
-
blockNumber: bigint;
|
|
73
|
-
from: Address;
|
|
74
|
-
to: Address | null;
|
|
75
|
-
cumulativeGasUsed: bigint;
|
|
76
|
-
status: TStatus;
|
|
77
|
-
gasUsed: bigint;
|
|
78
|
-
contractAddress: Address | null;
|
|
79
|
-
logsBloom: Hex;
|
|
80
|
-
effectiveGasPrice: bigint;
|
|
81
|
-
};
|
|
82
|
-
logs: {
|
|
83
|
-
data: Hex;
|
|
84
|
-
blockNumber: bigint;
|
|
85
|
-
blockHash: Hash;
|
|
86
|
-
transactionHash: Hash;
|
|
87
|
-
logIndex: bigint;
|
|
88
|
-
transactionIndex: bigint;
|
|
89
|
-
address: Address;
|
|
90
|
-
topics: Hex[];
|
|
91
|
-
}[];
|
|
92
|
-
} | null>;
|
|
61
|
+
export declare const getUserOperationReceipt: (client: BundlerClient, { hash }: GetUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType | null>;
|
|
93
62
|
//# sourceMappingURL=getUserOperationReceipt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getUserOperationReceipt.d.ts","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA;AAG3D,MAAM,MAAM,iCAAiC,GAAG;IAC5C,IAAI,EAAE,IAAI,CAAA;CACb,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC5C,UAAU,EAAE,IAAI,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE;QACL,eAAe,EAAE,GAAG,CAAA;QACpB,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,IAAI,CAAA;QACf,WAAW,EAAE,MAAM,CAAA;QACnB,IAAI,EAAE,OAAO,CAAA;QACb,EAAE,EAAE,OAAO,GAAG,IAAI,CAAA;QAClB,iBAAiB,EAAE,MAAM,CAAA;QACzB,MAAM,EAAE,OAAO,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,eAAe,EAAE,OAAO,GAAG,IAAI,CAAA;QAC/B,SAAS,EAAE,GAAG,CAAA;QACd,iBAAiB,EAAE,MAAM,CAAA;KAC5B,CAAA;IACD,IAAI,EAAE;QACF,IAAI,EAAE,GAAG,CAAA;QACT,WAAW,EAAE,MAAM,CAAA;QACnB,SAAS,EAAE,IAAI,CAAA;QACf,eAAe,EAAE,IAAI,CAAA;QACrB,QAAQ,EAAE,MAAM,CAAA;QAChB,gBAAgB,EAAE,MAAM,CAAA;QACxB,OAAO,EAAE,OAAO,CAAA;QAChB,MAAM,EAAE,GAAG,EAAE,CAAA;KAChB,EAAE,CAAA;CACN,
|
|
1
|
+
{"version":3,"file":"getUserOperationReceipt.d.ts","sourceRoot":"","sources":["../../../actions/bundler/getUserOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,KAAK,EAAE,O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|
|
2
|
+
import { type BundlerClient } from "../../clients/bundler";
|
|
3
|
+
import { type GetUserOperationReceiptReturnType } from "./getUserOperationReceipt";
|
|
4
|
+
export declare class WaitForUserOperationReceiptTimeoutError extends BaseError {
|
|
5
|
+
name: string;
|
|
6
|
+
constructor({ hash }: {
|
|
7
|
+
hash: Hash;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export type WaitForUserOperationReceiptParameters = {
|
|
11
|
+
/** The hash of the transaction. */
|
|
12
|
+
hash: Hash;
|
|
13
|
+
/**
|
|
14
|
+
* Polling frequency (in ms). Defaults to the client's pollingInterval config.
|
|
15
|
+
* @default client.pollingInterval
|
|
16
|
+
*/
|
|
17
|
+
pollingInterval?: number;
|
|
18
|
+
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
|
19
|
+
timeout?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms.html#block) (one confirmation), and then returns the [User Operation Receipt](https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt).
|
|
23
|
+
*
|
|
24
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/waitForUserOperationReceipt
|
|
25
|
+
*
|
|
26
|
+
* @param client - Bundler Client to use
|
|
27
|
+
* @param parameters - {@link WaitForUserOperationReceiptParameters}
|
|
28
|
+
* @returns The transaction receipt. {@link GetUserOperationReceiptReturnType}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* import { createBundlerClient, waitForUserOperationReceipt, http } from 'viem'
|
|
32
|
+
* import { mainnet } from 'viem/chains'
|
|
33
|
+
*
|
|
34
|
+
* const client = createBundlerClient({
|
|
35
|
+
* chain: mainnet,
|
|
36
|
+
* transport: http(),
|
|
37
|
+
* })
|
|
38
|
+
* const userOperationReceipt = await waitForUserOperationReceipt(client, {
|
|
39
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
40
|
+
* })
|
|
41
|
+
*/
|
|
42
|
+
export declare const waitForUserOperationReceipt: <TChain extends Chain | undefined>(bundlerClient: BundlerClient<TChain>, { hash, pollingInterval, timeout }: WaitForUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType>;
|
|
43
|
+
//# sourceMappingURL=waitForUserOperationReceipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitForUserOperationReceipt.d.ts","sourceRoot":"","sources":["../../../actions/bundler/waitForUserOperationReceipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,KAAK,IAAI,EAAa,MAAM,MAAM,CAAA;AAClE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,OAAO,EAAE,KAAK,iCAAiC,EAA2B,MAAM,2BAA2B,CAAA;AAE3G,qBAAa,uCAAwC,SAAQ,SAAS;IACzD,IAAI,SAA4C;gBAC7C,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;CAGvC;AAED,MAAM,MAAM,qCAAqC,GAAG;IAChD,mCAAmC;IACnC,IAAI,EAAE,IAAI,CAAA;IACV;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,2BAA2B,+GAEgC,qCAAqC,KAC1G,QAAQ,iCAAiC,CA+B3C,CAAA"}
|
|
@@ -11,8 +11,10 @@ import { getUserOperationByHash } from "./bundler/getUserOperationByHash.js";
|
|
|
11
11
|
import { getUserOperationReceipt } from "./bundler/getUserOperationReceipt.js";
|
|
12
12
|
import { sendUserOperation } from "./bundler/sendUserOperation.js";
|
|
13
13
|
import { supportedEntryPoints } from "./bundler/supportedEntryPoints.js";
|
|
14
|
+
import { waitForUserOperationReceipt } from "./bundler/waitForUserOperationReceipt.js";
|
|
15
|
+
import { type WaitForUserOperationReceiptParameters, WaitForUserOperationReceiptTimeoutError } from "./bundler/waitForUserOperationReceipt.js";
|
|
14
16
|
import type { GetAccountNonceParams } from "./public/getAccountNonce.js";
|
|
15
17
|
import { getAccountNonce } from "./public/getAccountNonce.js";
|
|
16
|
-
export type { SendUserOperationParameters, EstimateUserOperationGasParameters, EstimateUserOperationGasReturnType, GetUserOperationByHashParameters, GetUserOperationByHashReturnType, GetUserOperationReceiptParameters, GetUserOperationReceiptReturnType, GetSenderAddressParams, GetAccountNonceParams };
|
|
17
|
-
export { sendUserOperation, estimateUserOperationGas, supportedEntryPoints, chainId, getUserOperationByHash, getUserOperationReceipt, getSenderAddress, getAccountNonce, InvalidEntryPointError };
|
|
18
|
+
export type { SendUserOperationParameters, EstimateUserOperationGasParameters, EstimateUserOperationGasReturnType, GetUserOperationByHashParameters, GetUserOperationByHashReturnType, GetUserOperationReceiptParameters, GetUserOperationReceiptReturnType, GetSenderAddressParams, GetAccountNonceParams, WaitForUserOperationReceiptParameters };
|
|
19
|
+
export { sendUserOperation, estimateUserOperationGas, supportedEntryPoints, chainId, getUserOperationByHash, getUserOperationReceipt, getSenderAddress, getAccountNonce, InvalidEntryPointError, waitForUserOperationReceipt, WaitForUserOperationReceiptTimeoutError };
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kCAAkC,EAClC,kCAAkC,EACrC,MAAM,uCAAuC,CAAA;AAC9C,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAA;AAC3F,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qCAAqC,CAAA;AAC3F,OAAO,KAAK,EACR,iCAAiC,EACjC,iCAAiC,EACpC,MAAM,sCAAs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AAC1E,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAEvF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAA;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0CAA0C,CAAA;AACtF,OAAO,EACH,KAAK,qCAAqC,EAC1C,uCAAuC,EAC1C,MAAM,0CAA0C,CAAA;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAE7D,YAAY,EACR,2BAA2B,EAC3B,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,EACtB,qBAAqB,EACrB,qCAAqC,EACxC,CAAA;AAED,OAAO,EACH,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,2BAA2B,EAC3B,uCAAuC,EAC1C,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Account, Chain, Client, PublicClientConfig, Transport } from "viem";
|
|
2
2
|
import type { BundlerRpcSchema } from "../types/bundler.js";
|
|
3
3
|
import { type BundlerActions } from "./decorators/bundler.js";
|
|
4
|
-
export type BundlerClient =
|
|
4
|
+
export type BundlerClient<TChain extends Chain | undefined = Chain | undefined> = Client<Transport, TChain, Account | undefined, BundlerRpcSchema, BundlerActions>;
|
|
5
5
|
/**
|
|
6
6
|
* Creates a EIP-4337 compliant Bundler Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../clients/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,yBAAyB,CAAA;AAE7E,MAAM,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../clients/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AAEjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,yBAAyB,CAAA;AAE7E,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,IAAI,MAAM,CACpF,SAAS,EACT,MAAM,EACN,OAAO,GAAG,SAAS,EACnB,gBAAgB,EAChB,cAAc,CACjB,CAAA;AACD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;MAE7B,aASF,CAAA"}
|
|
@@ -4,6 +4,7 @@ import { type EstimateUserOperationGasParameters, type EstimateUserOperationGasR
|
|
|
4
4
|
import { type GetUserOperationByHashParameters, type GetUserOperationByHashReturnType } from "../../actions/bundler/getUserOperationByHash.js";
|
|
5
5
|
import { type GetUserOperationReceiptParameters, type GetUserOperationReceiptReturnType } from "../../actions/bundler/getUserOperationReceipt.js";
|
|
6
6
|
import { type SendUserOperationParameters } from "../../actions/bundler/sendUserOperation.js";
|
|
7
|
+
import { type WaitForUserOperationReceiptParameters } from "../../actions/bundler/waitForUserOperationReceipt.js";
|
|
7
8
|
export type BundlerActions = {
|
|
8
9
|
/**
|
|
9
10
|
*
|
|
@@ -143,7 +144,29 @@ export type BundlerActions = {
|
|
|
143
144
|
* await bundlerClient.getUserOperationReceipt({hash: userOpHash})
|
|
144
145
|
*
|
|
145
146
|
*/
|
|
146
|
-
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType>;
|
|
147
|
+
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType | null>;
|
|
148
|
+
/**
|
|
149
|
+
* Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms.html#block) (one confirmation), and then returns the [User Operation Receipt](https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt).
|
|
150
|
+
*
|
|
151
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/waitForUserOperationReceipt
|
|
152
|
+
*
|
|
153
|
+
* @param client - Bundler Client to use
|
|
154
|
+
* @param parameters - {@link WaitForUserOperationReceiptParameters}
|
|
155
|
+
* @returns The transaction receipt. {@link GetUserOperationReceiptReturnType}
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* import { createBundlerClient, waitForUserOperationReceipt, http } from 'viem'
|
|
159
|
+
* import { mainnet } from 'viem/chains'
|
|
160
|
+
*
|
|
161
|
+
* const bundlerClient = createBundlerClient({
|
|
162
|
+
* chain: mainnet,
|
|
163
|
+
* transport: http(),
|
|
164
|
+
* })
|
|
165
|
+
* const userOperationReceipt = await bundlerClient.waitForUserOperationReceipt({
|
|
166
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
167
|
+
* })
|
|
168
|
+
*/
|
|
169
|
+
waitForUserOperationReceipt: (args: WaitForUserOperationReceiptParameters) => Promise<GetUserOperationReceiptReturnType>;
|
|
147
170
|
};
|
|
148
171
|
declare const bundlerActions: (client: Client) => BundlerActions;
|
|
149
172
|
export { bundlerActions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../clients/decorators/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,EACH,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EAE1C,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EACH,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EAExC,MAAM,iDAAiD,CAAA;AACxD,OAAO,EACH,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EAEzC,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,KAAK,2BAA2B,EAAqB,MAAM,4CAA4C,CAAA;
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../../clients/decorators/bundler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAExC,OAAO,EACH,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EAE1C,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EACH,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,EAExC,MAAM,iDAAiD,CAAA;AACxD,OAAO,EACH,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EAEzC,MAAM,kDAAkD,CAAA;AACzD,OAAO,EAAE,KAAK,2BAA2B,EAAqB,MAAM,4CAA4C,CAAA;AAEhH,OAAO,EACH,KAAK,qCAAqC,EAE7C,MAAM,sDAAsD,CAAA;AAG7D,MAAM,MAAM,cAAc,GAAG;IACzB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,2BAA2B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACvE;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,wBAAwB,EAAE,CAAC,IAAI,EAAE,kCAAkC,KAAK,OAAO,CAAC,kCAAkC,CAAC,CAAA;IACnH;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9C;;;;;;;;;;;;;;;;;;;OAmBG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IAC9B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,sBAAsB,EAAE,CAAC,IAAI,EAAE,gCAAgC,KAAK,OAAO,CAAC,gCAAgC,CAAC,CAAA;IAC7G;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,uBAAuB,EAAE,CACrB,IAAI,EAAE,iCAAiC,KACtC,OAAO,CAAC,iCAAiC,GAAG,IAAI,CAAC,CAAA;IAEtD;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,2BAA2B,EAAE,CACzB,IAAI,EAAE,qCAAqC,KAC1C,OAAO,CAAC,iCAAiC,CAAC,CAAA;CAClD,CAAA;AAED,QAAA,MAAM,cAAc,WAAY,MAAM,KAAG,cAavC,CAAA;AAEF,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
package/_types/index.d.ts
CHANGED
|
@@ -11,13 +11,15 @@ import { getUserOperationByHash } from "./actions/bundler/getUserOperationByHash
|
|
|
11
11
|
import { getUserOperationReceipt } from "./actions/bundler/getUserOperationReceipt.js";
|
|
12
12
|
import { sendUserOperation } from "./actions/bundler/sendUserOperation.js";
|
|
13
13
|
import { supportedEntryPoints } from "./actions/bundler/supportedEntryPoints.js";
|
|
14
|
+
import { waitForUserOperationReceipt } from "./actions/bundler/waitForUserOperationReceipt.js";
|
|
15
|
+
import { type WaitForUserOperationReceiptParameters, WaitForUserOperationReceiptTimeoutError } from "./actions/bundler/waitForUserOperationReceipt.js";
|
|
14
16
|
import type { GetAccountNonceParams } from "./actions/public/getAccountNonce.js";
|
|
15
17
|
import { getAccountNonce } from "./actions/public/getAccountNonce.js";
|
|
16
18
|
import { type BundlerClient, createBundlerClient } from "./clients/bundler.js";
|
|
17
19
|
import type { BundlerActions } from "./clients/decorators/bundler.js";
|
|
18
20
|
import { bundlerActions } from "./clients/decorators/bundler.js";
|
|
19
|
-
export type { SendUserOperationParameters, EstimateUserOperationGasParameters, EstimateUserOperationGasReturnType, GetUserOperationByHashParameters, GetUserOperationByHashReturnType, GetUserOperationReceiptParameters, GetUserOperationReceiptReturnType, GetSenderAddressParams, GetAccountNonceParams, BundlerClient, BundlerActions };
|
|
20
|
-
export { sendUserOperation, estimateUserOperationGas, supportedEntryPoints, chainId, getUserOperationByHash, getUserOperationReceipt, getSenderAddress, getAccountNonce, createBundlerClient, bundlerActions };
|
|
21
|
+
export type { SendUserOperationParameters, EstimateUserOperationGasParameters, EstimateUserOperationGasReturnType, GetUserOperationByHashParameters, GetUserOperationByHashReturnType, GetUserOperationReceiptParameters, GetUserOperationReceiptReturnType, GetSenderAddressParams, GetAccountNonceParams, BundlerClient, BundlerActions, WaitForUserOperationReceiptParameters };
|
|
22
|
+
export { sendUserOperation, estimateUserOperationGas, supportedEntryPoints, chainId, getUserOperationByHash, getUserOperationReceipt, getSenderAddress, getAccountNonce, waitForUserOperationReceipt, createBundlerClient, bundlerActions, WaitForUserOperationReceiptTimeoutError };
|
|
21
23
|
import type { UserOperation } from "./types/userOperation.js";
|
|
22
24
|
export { type UserOperation };
|
|
23
25
|
import type { GetUserOperationHashParams } from "./utils/getUserOperationHash.js";
|
package/_types/index.d.ts.map
CHANGED
|
@@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M,iCAAiC,CAAA;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AAEhE,YAAY,EACR,2BAA2B,EAC3B,kCAAkC,EAClC,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,EAChC,iCAAiC,EACjC,iCAAiC,EACjC,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,qCAAqC,EACxC,CAAA;AAED,OAAO,EACH,iBAAiB,EACjB,wBAAwB,EACxB,oBAAoB,EACpB,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,mBAAmB,EACnB,cAAc,EACd,uCAAuC,EAC1C,CAAA;AACD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,EAAE,KAAK,aAAa,EAAE,CAAA;AAE7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAA;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AAEtE,OAAO,EAAE,oBAAoB,EAAE,KAAK,0BAA0B,EAAE,CAAA;AAChE,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepHexlify.d.ts","sourceRoot":"","sources":["../../utils/deepHexlify.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB;;;CAG3B,CAAA;AAGV,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAqBzC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MaybePromise } from "viem/types/utils";
|
|
2
|
+
type Callback = ((...args: any[]) => any) | undefined;
|
|
3
|
+
type Callbacks = Record<string, Callback>;
|
|
4
|
+
export declare const listenersCache: Map<string, {
|
|
5
|
+
id: number;
|
|
6
|
+
fns: Callbacks;
|
|
7
|
+
}[]>;
|
|
8
|
+
export declare const cleanupCache: Map<string, () => void>;
|
|
9
|
+
type EmitFunction<TCallbacks extends Callbacks> = (emit: TCallbacks) => MaybePromise<void | (() => void)>;
|
|
10
|
+
/**
|
|
11
|
+
* @description Sets up an observer for a given function. If another function
|
|
12
|
+
* is set up under the same observer id, the function will only be called once
|
|
13
|
+
* for both instances of the observer.
|
|
14
|
+
*/
|
|
15
|
+
export declare function observe<TCallbacks extends Callbacks>(observerId: string, callbacks: TCallbacks, fn: EmitFunction<TCallbacks>): () => void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../utils/observe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAGpD,KAAK,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,SAAS,CAAA;AACrD,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAEzC,eAAO,MAAM,cAAc;QAAuC,MAAM;SAAO,SAAS;IAAO,CAAA;AAC/F,eAAO,MAAM,YAAY,oBAAuC,IAAI,CAAG,CAAA;AAEvE,KAAK,YAAY,CAAC,UAAU,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE,UAAU,KAAK,YAAY,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAA;AAIzG;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,UAAU,SAAS,SAAS,EAChD,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,UAAU,EACrB,EAAE,EAAE,YAAY,CAAC,UAAU,CAAC,cAuC/B"}
|
|
@@ -3,7 +3,7 @@ import type { PartialBy } from "viem/types/utils"
|
|
|
3
3
|
import type { BundlerClient } from "../../clients/bundler.js"
|
|
4
4
|
import type { UserOperation } from "../../types/userOperation.js"
|
|
5
5
|
import type { UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
6
|
-
import { deepHexlify } from "
|
|
6
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
7
7
|
|
|
8
8
|
export type EstimateUserOperationGasParameters = {
|
|
9
9
|
userOperation: PartialBy<UserOperation, "callGasLimit" | "preVerificationGas" | "verificationGasLimit">
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, Hash, Hex } from "viem"
|
|
2
2
|
import type { BundlerClient } from "../../clients/bundler.js"
|
|
3
3
|
import type { TStatus } from "../../types/userOperation.js"
|
|
4
|
-
import { transactionReceiptStatus } from "
|
|
4
|
+
import { transactionReceiptStatus } from "../../utils/deepHexlify.js"
|
|
5
5
|
|
|
6
6
|
export type GetUserOperationReceiptParameters = {
|
|
7
7
|
hash: Hash
|
|
@@ -38,7 +38,7 @@ export type GetUserOperationReceiptReturnType = {
|
|
|
38
38
|
address: Address
|
|
39
39
|
topics: Hex[]
|
|
40
40
|
}[]
|
|
41
|
-
}
|
|
41
|
+
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Returns the user operation receipt from userOpHash
|
|
@@ -62,7 +62,10 @@ export type GetUserOperationReceiptReturnType = {
|
|
|
62
62
|
* getUserOperationReceipt(bundlerClient, {hash: userOpHash})
|
|
63
63
|
*
|
|
64
64
|
*/
|
|
65
|
-
export const getUserOperationReceipt = async (
|
|
65
|
+
export const getUserOperationReceipt = async (
|
|
66
|
+
client: BundlerClient,
|
|
67
|
+
{ hash }: GetUserOperationReceiptParameters
|
|
68
|
+
): Promise<GetUserOperationReceiptReturnType | null> => {
|
|
66
69
|
const params: [Hash] = [hash]
|
|
67
70
|
|
|
68
71
|
const response = await client.request({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Address, Hash } from "viem"
|
|
2
2
|
import type { BundlerClient } from "../../clients/bundler.js"
|
|
3
3
|
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
4
|
-
import { deepHexlify } from "
|
|
4
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
5
5
|
|
|
6
6
|
export type SendUserOperationParameters = {
|
|
7
7
|
userOperation: UserOperation
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { BaseError, type Chain, type Hash, stringify } from "viem"
|
|
2
|
+
import { type BundlerClient } from "../../clients/bundler"
|
|
3
|
+
import { observe } from "../../utils/observe"
|
|
4
|
+
import { type GetUserOperationReceiptReturnType, getUserOperationReceipt } from "./getUserOperationReceipt"
|
|
5
|
+
|
|
6
|
+
export class WaitForUserOperationReceiptTimeoutError extends BaseError {
|
|
7
|
+
override name = "WaitForUserOperationReceiptTimeoutError"
|
|
8
|
+
constructor({ hash }: { hash: Hash }) {
|
|
9
|
+
super(`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type WaitForUserOperationReceiptParameters = {
|
|
14
|
+
/** The hash of the transaction. */
|
|
15
|
+
hash: Hash
|
|
16
|
+
/**
|
|
17
|
+
* Polling frequency (in ms). Defaults to the client's pollingInterval config.
|
|
18
|
+
* @default client.pollingInterval
|
|
19
|
+
*/
|
|
20
|
+
pollingInterval?: number
|
|
21
|
+
/** Optional timeout (in milliseconds) to wait before stopping polling. */
|
|
22
|
+
timeout?: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms.html#block) (one confirmation), and then returns the [User Operation Receipt](https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt).
|
|
27
|
+
*
|
|
28
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/waitForUserOperationReceipt
|
|
29
|
+
*
|
|
30
|
+
* @param client - Bundler Client to use
|
|
31
|
+
* @param parameters - {@link WaitForUserOperationReceiptParameters}
|
|
32
|
+
* @returns The transaction receipt. {@link GetUserOperationReceiptReturnType}
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* import { createBundlerClient, waitForUserOperationReceipt, http } from 'viem'
|
|
36
|
+
* import { mainnet } from 'viem/chains'
|
|
37
|
+
*
|
|
38
|
+
* const client = createBundlerClient({
|
|
39
|
+
* chain: mainnet,
|
|
40
|
+
* transport: http(),
|
|
41
|
+
* })
|
|
42
|
+
* const userOperationReceipt = await waitForUserOperationReceipt(client, {
|
|
43
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
44
|
+
* })
|
|
45
|
+
*/
|
|
46
|
+
export const waitForUserOperationReceipt = <TChain extends Chain | undefined>(
|
|
47
|
+
bundlerClient: BundlerClient<TChain>,
|
|
48
|
+
{ hash, pollingInterval = bundlerClient.pollingInterval, timeout }: WaitForUserOperationReceiptParameters
|
|
49
|
+
): Promise<GetUserOperationReceiptReturnType> => {
|
|
50
|
+
const observerId = stringify(["waitForUserOperationReceipt", bundlerClient.uid, hash])
|
|
51
|
+
|
|
52
|
+
let userOperationReceipt: GetUserOperationReceiptReturnType
|
|
53
|
+
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
if (timeout) {
|
|
56
|
+
setTimeout(() => reject(new WaitForUserOperationReceiptTimeoutError({ hash })), timeout)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const _unobserve = observe(observerId, { resolve, reject }, async (emit) => {
|
|
60
|
+
const _removeInterval = setInterval(async () => {
|
|
61
|
+
const done = (fn: () => void) => {
|
|
62
|
+
clearInterval(_removeInterval)
|
|
63
|
+
fn()
|
|
64
|
+
_unobserve()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const _userOperationReceipt = await getUserOperationReceipt(bundlerClient, { hash })
|
|
68
|
+
|
|
69
|
+
if (_userOperationReceipt !== null) {
|
|
70
|
+
userOperationReceipt = _userOperationReceipt
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (userOperationReceipt) {
|
|
74
|
+
done(() => emit.resolve(userOperationReceipt))
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
}, pollingInterval)
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}
|
package/actions/index.ts
CHANGED
|
@@ -19,6 +19,11 @@ import { getUserOperationByHash } from "./bundler/getUserOperationByHash.js"
|
|
|
19
19
|
import { getUserOperationReceipt } from "./bundler/getUserOperationReceipt.js"
|
|
20
20
|
import { sendUserOperation } from "./bundler/sendUserOperation.js"
|
|
21
21
|
import { supportedEntryPoints } from "./bundler/supportedEntryPoints.js"
|
|
22
|
+
import { waitForUserOperationReceipt } from "./bundler/waitForUserOperationReceipt.js"
|
|
23
|
+
import {
|
|
24
|
+
type WaitForUserOperationReceiptParameters,
|
|
25
|
+
WaitForUserOperationReceiptTimeoutError
|
|
26
|
+
} from "./bundler/waitForUserOperationReceipt.js"
|
|
22
27
|
import type { GetAccountNonceParams } from "./public/getAccountNonce.js"
|
|
23
28
|
import { getAccountNonce } from "./public/getAccountNonce.js"
|
|
24
29
|
|
|
@@ -31,7 +36,8 @@ export type {
|
|
|
31
36
|
GetUserOperationReceiptParameters,
|
|
32
37
|
GetUserOperationReceiptReturnType,
|
|
33
38
|
GetSenderAddressParams,
|
|
34
|
-
GetAccountNonceParams
|
|
39
|
+
GetAccountNonceParams,
|
|
40
|
+
WaitForUserOperationReceiptParameters
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export {
|
|
@@ -43,5 +49,7 @@ export {
|
|
|
43
49
|
getUserOperationReceipt,
|
|
44
50
|
getSenderAddress,
|
|
45
51
|
getAccountNonce,
|
|
46
|
-
InvalidEntryPointError
|
|
52
|
+
InvalidEntryPointError,
|
|
53
|
+
waitForUserOperationReceipt,
|
|
54
|
+
WaitForUserOperationReceiptTimeoutError
|
|
47
55
|
}
|
|
@@ -2,7 +2,7 @@ import type { Address, Hex } from "viem"
|
|
|
2
2
|
import type { PartialBy } from "viem/types/utils"
|
|
3
3
|
import type { PimlicoPaymasterClient } from "../../clients/pimlico.js"
|
|
4
4
|
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
5
|
-
import { deepHexlify } from "
|
|
5
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
6
6
|
|
|
7
7
|
export type SponsorUserOperationParameters = {
|
|
8
8
|
userOperation: PartialBy<
|
|
@@ -3,7 +3,7 @@ import type { PartialBy } from "viem/types/utils"
|
|
|
3
3
|
import { type StackupPaymasterClient } from "../../clients/stackup.js"
|
|
4
4
|
import type { StackupPaymasterContext } from "../../types/stackup.js"
|
|
5
5
|
import type { UserOperation, UserOperationWithBigIntAsHex } from "../../types/userOperation.js"
|
|
6
|
-
import { deepHexlify } from "
|
|
6
|
+
import { deepHexlify } from "../../utils/deepHexlify.js"
|
|
7
7
|
|
|
8
8
|
export type SponsorUserOperationParameters = {
|
|
9
9
|
userOperation: PartialBy<
|
package/clients/bundler.ts
CHANGED
|
@@ -3,7 +3,13 @@ import { createClient } from "viem"
|
|
|
3
3
|
import type { BundlerRpcSchema } from "../types/bundler.js"
|
|
4
4
|
import { type BundlerActions, bundlerActions } from "./decorators/bundler.js"
|
|
5
5
|
|
|
6
|
-
export type BundlerClient
|
|
6
|
+
export type BundlerClient<TChain extends Chain | undefined = Chain | undefined> = Client<
|
|
7
|
+
Transport,
|
|
8
|
+
TChain,
|
|
9
|
+
Account | undefined,
|
|
10
|
+
BundlerRpcSchema,
|
|
11
|
+
BundlerActions
|
|
12
|
+
>
|
|
7
13
|
/**
|
|
8
14
|
* Creates a EIP-4337 compliant Bundler Client with a given [Transport](https://viem.sh/docs/clients/intro.html) configured for a [Chain](https://viem.sh/docs/clients/chains.html).
|
|
9
15
|
*
|
|
@@ -18,6 +18,10 @@ import {
|
|
|
18
18
|
} from "../../actions/bundler/getUserOperationReceipt.js"
|
|
19
19
|
import { type SendUserOperationParameters, sendUserOperation } from "../../actions/bundler/sendUserOperation.js"
|
|
20
20
|
import { supportedEntryPoints } from "../../actions/bundler/supportedEntryPoints.js"
|
|
21
|
+
import {
|
|
22
|
+
type WaitForUserOperationReceiptParameters,
|
|
23
|
+
waitForUserOperationReceipt
|
|
24
|
+
} from "../../actions/bundler/waitForUserOperationReceipt.js"
|
|
21
25
|
import type { BundlerClient } from "../bundler.js"
|
|
22
26
|
|
|
23
27
|
export type BundlerActions = {
|
|
@@ -159,7 +163,34 @@ export type BundlerActions = {
|
|
|
159
163
|
* await bundlerClient.getUserOperationReceipt({hash: userOpHash})
|
|
160
164
|
*
|
|
161
165
|
*/
|
|
162
|
-
getUserOperationReceipt: (
|
|
166
|
+
getUserOperationReceipt: (
|
|
167
|
+
args: GetUserOperationReceiptParameters
|
|
168
|
+
) => Promise<GetUserOperationReceiptReturnType | null>
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms.html#block) (one confirmation), and then returns the [User Operation Receipt](https://docs.pimlico.io/permissionless/reference/bundler-actions/getUserOperationReceipt).
|
|
172
|
+
*
|
|
173
|
+
* - Docs: https://docs.pimlico.io/permissionless/reference/bundler-actions/waitForUserOperationReceipt
|
|
174
|
+
*
|
|
175
|
+
* @param client - Bundler Client to use
|
|
176
|
+
* @param parameters - {@link WaitForUserOperationReceiptParameters}
|
|
177
|
+
* @returns The transaction receipt. {@link GetUserOperationReceiptReturnType}
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* import { createBundlerClient, waitForUserOperationReceipt, http } from 'viem'
|
|
181
|
+
* import { mainnet } from 'viem/chains'
|
|
182
|
+
*
|
|
183
|
+
* const bundlerClient = createBundlerClient({
|
|
184
|
+
* chain: mainnet,
|
|
185
|
+
* transport: http(),
|
|
186
|
+
* })
|
|
187
|
+
* const userOperationReceipt = await bundlerClient.waitForUserOperationReceipt({
|
|
188
|
+
* hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
|
|
189
|
+
* })
|
|
190
|
+
*/
|
|
191
|
+
waitForUserOperationReceipt: (
|
|
192
|
+
args: WaitForUserOperationReceiptParameters
|
|
193
|
+
) => Promise<GetUserOperationReceiptReturnType>
|
|
163
194
|
}
|
|
164
195
|
|
|
165
196
|
const bundlerActions = (client: Client): BundlerActions => ({
|
|
@@ -172,7 +203,9 @@ const bundlerActions = (client: Client): BundlerActions => ({
|
|
|
172
203
|
getUserOperationByHash: (args: GetUserOperationByHashParameters) =>
|
|
173
204
|
getUserOperationByHash(client as BundlerClient, args),
|
|
174
205
|
getUserOperationReceipt: (args: GetUserOperationReceiptParameters) =>
|
|
175
|
-
getUserOperationReceipt(client as BundlerClient, args)
|
|
206
|
+
getUserOperationReceipt(client as BundlerClient, args),
|
|
207
|
+
waitForUserOperationReceipt: (args: WaitForUserOperationReceiptParameters) =>
|
|
208
|
+
waitForUserOperationReceipt(client as BundlerClient, args)
|
|
176
209
|
})
|
|
177
210
|
|
|
178
211
|
export { bundlerActions }
|
package/index.ts
CHANGED
|
@@ -19,6 +19,11 @@ import { getUserOperationByHash } from "./actions/bundler/getUserOperationByHash
|
|
|
19
19
|
import { getUserOperationReceipt } from "./actions/bundler/getUserOperationReceipt.js"
|
|
20
20
|
import { sendUserOperation } from "./actions/bundler/sendUserOperation.js"
|
|
21
21
|
import { supportedEntryPoints } from "./actions/bundler/supportedEntryPoints.js"
|
|
22
|
+
import { waitForUserOperationReceipt } from "./actions/bundler/waitForUserOperationReceipt.js"
|
|
23
|
+
import {
|
|
24
|
+
type WaitForUserOperationReceiptParameters,
|
|
25
|
+
WaitForUserOperationReceiptTimeoutError
|
|
26
|
+
} from "./actions/bundler/waitForUserOperationReceipt.js"
|
|
22
27
|
import type { GetAccountNonceParams } from "./actions/public/getAccountNonce.js"
|
|
23
28
|
import { getAccountNonce } from "./actions/public/getAccountNonce.js"
|
|
24
29
|
import { type BundlerClient, createBundlerClient } from "./clients/bundler.js"
|
|
@@ -36,7 +41,8 @@ export type {
|
|
|
36
41
|
GetSenderAddressParams,
|
|
37
42
|
GetAccountNonceParams,
|
|
38
43
|
BundlerClient,
|
|
39
|
-
BundlerActions
|
|
44
|
+
BundlerActions,
|
|
45
|
+
WaitForUserOperationReceiptParameters
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
export {
|
|
@@ -48,8 +54,10 @@ export {
|
|
|
48
54
|
getUserOperationReceipt,
|
|
49
55
|
getSenderAddress,
|
|
50
56
|
getAccountNonce,
|
|
57
|
+
waitForUserOperationReceipt,
|
|
51
58
|
createBundlerClient,
|
|
52
|
-
bundlerActions
|
|
59
|
+
bundlerActions,
|
|
60
|
+
WaitForUserOperationReceiptTimeoutError
|
|
53
61
|
}
|
|
54
62
|
import type { UserOperation } from "./types/userOperation.js"
|
|
55
63
|
|