@aa-sdk/core 4.20.1 → 4.22.0
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/dist/esm/actions/smartAccount/buildUserOperation.d.ts +3 -3
- package/dist/esm/actions/smartAccount/buildUserOperation.js +7 -3
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.d.ts +2 -2
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js +4 -2
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.d.ts +2 -2
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js +4 -2
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +2 -2
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js +4 -2
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.d.ts +2 -2
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js +4 -2
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.d.ts +2 -2
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js +4 -2
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.d.ts +2 -2
- package/dist/esm/actions/smartAccount/sendTransaction.js +4 -2
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.d.ts +2 -2
- package/dist/esm/actions/smartAccount/sendTransactions.js +4 -2
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.d.ts +2 -2
- package/dist/esm/actions/smartAccount/sendUserOperation.js +4 -2
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/upgradeAccount.js +3 -1
- package/dist/esm/actions/smartAccount/upgradeAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.d.ts +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js +4 -2
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/addBreadcrumb.d.ts +13 -0
- package/dist/esm/client/addBreadcrumb.js +22 -0
- package/dist/esm/client/addBreadcrumb.js.map +1 -0
- package/dist/esm/client/smartAccountClient.d.ts +9 -0
- package/dist/esm/client/smartAccountClient.js +14 -4
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/traceHeader.d.ts +70 -0
- package/dist/esm/utils/traceHeader.js +133 -0
- package/dist/esm/utils/traceHeader.js.map +1 -0
- package/dist/esm/utils/userop.js +4 -4
- package/dist/esm/utils/userop.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts +3 -3
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +2 -2
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +2 -2
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +2 -2
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +2 -2
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +2 -2
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts +2 -2
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransactions.d.ts +2 -2
- package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts +2 -2
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/upgradeAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +1 -1
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
- package/dist/types/client/addBreadcrumb.d.ts +14 -0
- package/dist/types/client/addBreadcrumb.d.ts.map +1 -0
- package/dist/types/client/smartAccountClient.d.ts +9 -0
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/traceHeader.d.ts +71 -0
- package/dist/types/utils/traceHeader.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/actions/smartAccount/buildUserOperation.ts +7 -4
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +4 -2
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +4 -2
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +4 -2
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +4 -2
- package/src/actions/smartAccount/estimateUserOperationGas.ts +4 -2
- package/src/actions/smartAccount/sendTransaction.ts +4 -2
- package/src/actions/smartAccount/sendTransactions.ts +4 -2
- package/src/actions/smartAccount/sendUserOperation.ts +4 -2
- package/src/actions/smartAccount/upgradeAccount.ts +3 -1
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +4 -2
- package/src/client/addBreadcrumb.ts +25 -0
- package/src/client/smartAccountClient.ts +23 -3
- package/src/index.ts +2 -0
- package/src/utils/traceHeader.ts +133 -0
- package/src/utils/userop.ts +4 -4
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Chain, type Client, type Transport } from "viem";
|
|
2
2
|
import { type GetEntryPointFromAccount, type SmartContractAccount } from "../../account/smartContractAccount.js";
|
|
3
3
|
import type { UserOperationStruct } from "../../types.js";
|
|
4
4
|
import type { BuildUserOperationParameters, UserOperationContext } from "./types";
|
|
@@ -21,8 +21,8 @@ import type { BuildUserOperationParameters, UserOperationContext } from "./types
|
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
23
23
|
*
|
|
24
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
24
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the client instance used to build the user operation
|
|
25
25
|
* @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context
|
|
26
26
|
* @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details
|
|
27
27
|
*/
|
|
28
|
-
export declare function buildUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(
|
|
28
|
+
export declare function buildUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client_: Client<TTransport, TChain, TAccount>, args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>): Promise<UserOperationStruct<TEntryPointVersion>>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import {} from "viem";
|
|
1
2
|
import {} from "../../account/smartContractAccount.js";
|
|
2
3
|
import { isBaseSmartAccountClient } from "../../client/isSmartAccountClient.js";
|
|
3
4
|
import { AccountNotFoundError } from "../../errors/account.js";
|
|
4
5
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
5
6
|
import { _initUserOperation } from "./internal/initUserOperation.js";
|
|
6
7
|
import { _runMiddlewareStack } from "./internal/runMiddlewareStack.js";
|
|
8
|
+
import { clientHeaderTrack } from "../../client/addBreadcrumb.js";
|
|
9
|
+
const USER_OPERATION_METHOD = "buildUserOperation";
|
|
7
10
|
/**
|
|
8
11
|
* Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.
|
|
9
12
|
*
|
|
@@ -23,17 +26,18 @@ import { _runMiddlewareStack } from "./internal/runMiddlewareStack.js";
|
|
|
23
26
|
* });
|
|
24
27
|
* ```
|
|
25
28
|
*
|
|
26
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
29
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the client instance used to build the user operation
|
|
27
30
|
* @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context
|
|
28
31
|
* @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details
|
|
29
32
|
*/
|
|
30
|
-
export async function buildUserOperation(
|
|
33
|
+
export async function buildUserOperation(client_, args) {
|
|
34
|
+
const client = clientHeaderTrack(client_, USER_OPERATION_METHOD);
|
|
31
35
|
const { account = client.account, overrides, context } = args;
|
|
32
36
|
if (!account) {
|
|
33
37
|
throw new AccountNotFoundError();
|
|
34
38
|
}
|
|
35
39
|
if (!isBaseSmartAccountClient(client)) {
|
|
36
|
-
throw new IncompatibleClientError("BaseSmartAccountClient",
|
|
40
|
+
throw new IncompatibleClientError("BaseSmartAccountClient", USER_OPERATION_METHOD, client);
|
|
37
41
|
}
|
|
38
42
|
return _initUserOperation(client, args).then((_uo) => _runMiddlewareStack(client, {
|
|
39
43
|
uo: _uo,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,MAAM,MAAM,CAAC;AAC/D,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AACnD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAWtC,OAA6C,EAC7C,IAA0E;IAE1E,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;IACjE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,qBAAqB,EACrB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnD,mBAAmB,CAAC,MAAM,EAAE;QAC1B,EAAE,EAAE,GAAG;QACP,SAAS;QACT,OAAO;QACP,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { type Chain, type Client, type Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport type {\n BuildUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../client/addBreadcrumb.js\";\n\nconst USER_OPERATION_METHOD = \"buildUserOperation\";\n/**\n * Builds a user operation using the provided client and operation parameters. Ensures that the account exists and the client is compatible.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with buildUserOperation\n * const client = createSmartAccountClient(...);\n * const result = await client.buildUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * },\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the client instance used to build the user operation\n * @param {BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>} args the parameters required to build the user operation, including account, overrides, and context\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a promise that resolves to a `UserOperationStruct` object containing the built user operation details\n */\nexport async function buildUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildUserOperationParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, USER_OPERATION_METHOD);\n const { account = client.account, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n USER_OPERATION_METHOD,\n client\n );\n }\n\n return _initUserOperation(client, args).then((_uo) =>\n _runMiddlewareStack(client, {\n uo: _uo,\n overrides,\n account,\n context,\n })\n );\n}\n"]}
|
|
@@ -35,10 +35,10 @@ import type { UserOperationContext } from "./types.js";
|
|
|
35
35
|
* const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
|
|
36
36
|
* ```
|
|
37
37
|
*
|
|
38
|
-
* @param {Client<Transport, TChain, TAccount>}
|
|
38
|
+
* @param {Client<Transport, TChain, TAccount>} client_ the smart account client to use for RPC requests
|
|
39
39
|
* @param {SendTransactionParameters} args the send tx parameters
|
|
40
40
|
* @param {UserOperationOverrides} overrides optional overrides to use for any of the fields
|
|
41
41
|
* @param {TContext} context if the smart account client requires additinoal context for building UOs
|
|
42
42
|
* @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation
|
|
43
43
|
*/
|
|
44
|
-
export declare function buildUserOperationFromTx<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(
|
|
44
|
+
export declare function buildUserOperationFromTx<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client_: Client<Transport, TChain, TAccount>, args: SendTransactionParameters<TChain, TAccount, TChainOverride>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext): Promise<UserOperationStruct<TEntryPointVersion>>;
|
|
@@ -4,6 +4,7 @@ import { AccountNotFoundError } from "../../errors/account.js";
|
|
|
4
4
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
5
5
|
import { TransactionMissingToParamError } from "../../errors/transaction.js";
|
|
6
6
|
import { buildUserOperation } from "./buildUserOperation.js";
|
|
7
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured `ClientMiddlewares` on the `SmartAccountClient`
|
|
9
10
|
*
|
|
@@ -37,13 +38,14 @@ import { buildUserOperation } from "./buildUserOperation.js";
|
|
|
37
38
|
* const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });
|
|
38
39
|
* ```
|
|
39
40
|
*
|
|
40
|
-
* @param {Client<Transport, TChain, TAccount>}
|
|
41
|
+
* @param {Client<Transport, TChain, TAccount>} client_ the smart account client to use for RPC requests
|
|
41
42
|
* @param {SendTransactionParameters} args the send tx parameters
|
|
42
43
|
* @param {UserOperationOverrides} overrides optional overrides to use for any of the fields
|
|
43
44
|
* @param {TContext} context if the smart account client requires additinoal context for building UOs
|
|
44
45
|
* @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation
|
|
45
46
|
*/
|
|
46
|
-
export async function buildUserOperationFromTx(
|
|
47
|
+
export async function buildUserOperationFromTx(client_, args, overrides, context) {
|
|
48
|
+
const client = clientHeaderTrack(client_, "buildUserOperationFromTx");
|
|
47
49
|
const { account = client.account, ...request } = args;
|
|
48
50
|
if (!account || typeof account === "string") {
|
|
49
51
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"buildUserOperationFromTx.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,MAAM,CAAC;AAKd,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAK7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;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sourcesContent":["import {\n type Chain,\n type Client,\n type SendTransactionParameters,\n type Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type {\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single, yet to be signed `UserOperation` (UO) struct. The output user operation struct will be filled with all gas fields (and paymaster data if a paymaster is used) based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`, `maxPriorityFeePerGas`) computed using the configured `ClientMiddlewares` on the `SmartAccountClient`\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * // buildUserOperationFromTx converts a traditional Ethereum transaction and returns\n * // the unsigned user operation struct after constructing the user operation struct\n * // through the middleware pipeline\n * const tx: RpcTransactionRequest = {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * };\n * const uoStruct = await smartAccountClient.buildUserOperationFromTx(tx);\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({ request, entryPoint: entryPointAddress });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ the smart account client to use for RPC requests\n * @param {SendTransactionParameters} args the send tx parameters\n * @param {UserOperationOverrides} overrides optional overrides to use for any of the fields\n * @param {TContext} context if the smart account client requires additinoal context for building UOs\n * @returns {Promise<UserOperationStruct<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTx<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<UserOperationStruct<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTx\");\n const { account = client.account, ...request } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTx\",\n client\n );\n }\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: request.maxFeePerGas ? request.maxFeePerGas : undefined,\n maxPriorityFeePerGas: request.maxPriorityFeePerGas\n ? request.maxPriorityFeePerGas\n : undefined,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n return buildUserOperation(client, {\n uo: {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? request.value : 0n,\n },\n account: account as SmartContractAccount,\n context,\n overrides: _overrides,\n });\n}\n"]}
|
|
@@ -51,8 +51,8 @@ import type { BuildTransactionParameters, BuildUserOperationFromTransactionsResu
|
|
|
51
51
|
* });
|
|
52
52
|
* ```
|
|
53
53
|
*
|
|
54
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
54
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use to make RPC calls
|
|
55
55
|
* @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware
|
|
56
56
|
* @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
|
|
57
57
|
*/
|
|
58
|
-
export declare function buildUserOperationFromTxs<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(
|
|
58
|
+
export declare function buildUserOperationFromTxs<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client_: Client<TTransport, TChain, TAccount>, args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>;
|
|
@@ -5,6 +5,7 @@ import { IncompatibleClientError } from "../../errors/client.js";
|
|
|
5
5
|
import { TransactionMissingToParamError } from "../../errors/transaction.js";
|
|
6
6
|
import { bigIntMax } from "../../utils/index.js";
|
|
7
7
|
import { buildUserOperation } from "./buildUserOperation.js";
|
|
8
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
8
9
|
/**
|
|
9
10
|
* Performs `buildUserOperationFromTx` in batch and builds into a single,
|
|
10
11
|
* yet to be signed `UserOperation` (UO) struct. The output user operation struct
|
|
@@ -55,11 +56,12 @@ import { buildUserOperation } from "./buildUserOperation.js";
|
|
|
55
56
|
* });
|
|
56
57
|
* ```
|
|
57
58
|
*
|
|
58
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
59
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use to make RPC calls
|
|
59
60
|
* @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware
|
|
60
61
|
* @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation
|
|
61
62
|
*/
|
|
62
|
-
export async function buildUserOperationFromTxs(
|
|
63
|
+
export async function buildUserOperationFromTxs(client_, args) {
|
|
64
|
+
const client = clientHeaderTrack(client_, "buildUserOperationFromTxs");
|
|
63
65
|
const { account = client.account, requests, overrides, context } = args;
|
|
64
66
|
if (!account) {
|
|
65
67
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,MAAM,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"buildUserOperationFromTxs.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/buildUserOperationFromTxs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA2C,MAAM,MAAM,CAAC;AAKxE,OAAO,EAAE,wBAAwB,EAAE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P,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,oFAAoF;QACpF,KAAK;QACL,SAAS,EAAE,UAAU;KACtB,CAAC;AACJ,CAAC","sourcesContent":["import { fromHex, type Chain, type Client, type Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport type { UserOperationOverrides } from \"../../types\";\nimport { bigIntMax } from \"../../utils/index.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n BuildTransactionParameters,\n BuildUserOperationFromTransactionsResult,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Performs `buildUserOperationFromTx` in batch and builds into a single,\n * yet to be signed `UserOperation` (UO) struct. The output user operation struct\n * will be filled with all gas fields (and paymaster data if a paymaster is used)\n * based on the transactions data (`to`, `data`, `value`, `maxFeePerGas`,\n * `maxPriorityFeePerGas`) computed using the configured ClientMiddlewares on the SmartAccountClient.\n *\n * @example\n * ```ts\n * import type { RpcTransactionRequest } from \"viem\";\n * import { smartAccountClient } from \"./smartAccountClient\";\n *\n * const requests: RpcTransactionRequest[] = [\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * {\n * from, // ignored\n * to,\n * data: encodeFunctionData({\n * abi: ContractABI.abi,\n * functionName: \"func\",\n * args: [arg1, arg2, ...],\n * }),\n * },\n * ];\n * const uoStruct = await smartAccountClient.buildUserOperationFromTxs({\n * requests,\n * });\n *\n * // signUserOperation signs the above unsigned user operation struct built\n * // using the account connected to the smart account client\n * const request = await smartAccountClient.signUserOperation({ uoStruct });\n *\n * // You can use the BundlerAction `sendRawUserOperation` (packages/core/src/actions/bundler/sendRawUserOperation.ts)\n * // to send the signed user operation request to the bundler, requesting the bundler to send the signed uo to the\n * // EntryPoint contract pointed at by the entryPoint address parameter\n * const entryPointAddress = client.account.getEntryPoint().address;\n * const uoHash = await smartAccountClient.sendRawUserOperation({\n * request,\n * entryPoint: entryPointAddress,\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use to make RPC calls\n * @param {BuildTransactionParameters} args an object containing the requests to build as well as, the account if not hoisted, the context, the overrides, and optionally a flag to enable signing of the UO via the underlying middleware\n * @returns {Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>>} a Promise containing the built user operation\n */\nexport async function buildUserOperationFromTxs<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: BuildTransactionParameters<TAccount, TContext, TEntryPointVersion>\n): Promise<BuildUserOperationFromTransactionsResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"buildUserOperationFromTxs\");\n const { account = client.account, requests, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"buildUserOperationFromTxs\",\n client\n );\n }\n\n const batch = requests.map((request) => {\n if (!request.to) {\n throw new TransactionMissingToParamError();\n }\n\n return {\n target: request.to,\n data: request.data ?? \"0x\",\n value: request.value ? fromHex(request.value, \"bigint\") : 0n,\n };\n });\n\n const mfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxFeePerGas != null)\n .map((x) => fromHex(x.maxFeePerGas!, \"bigint\"));\n const maxFeePerGas =\n overrides?.maxFeePerGas != null\n ? overrides?.maxFeePerGas\n : mfpgOverridesInTx().length > 0\n ? bigIntMax(...mfpgOverridesInTx())\n : undefined;\n\n const mpfpgOverridesInTx = () =>\n requests\n .filter((x) => x.maxPriorityFeePerGas != null)\n .map((x) => fromHex(x.maxPriorityFeePerGas!, \"bigint\"));\n const maxPriorityFeePerGas =\n overrides?.maxPriorityFeePerGas != null\n ? overrides?.maxPriorityFeePerGas\n : mpfpgOverridesInTx().length > 0\n ? bigIntMax(...mpfpgOverridesInTx())\n : undefined;\n\n const _overrides = {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoStruct = await buildUserOperation(client, {\n uo: batch,\n account,\n context,\n overrides: _overrides,\n });\n\n return {\n uoStruct,\n // TODO: in v4 major version update, remove these as below parameters are not needed\n batch,\n overrides: _overrides,\n };\n}\n"]}
|
|
@@ -30,8 +30,8 @@ export type CheckGasSponsorshipEligibilityResult<TAccount extends SmartContractA
|
|
|
30
30
|
* );
|
|
31
31
|
* ```
|
|
32
32
|
*
|
|
33
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
33
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for making RPC calls
|
|
34
34
|
* @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
|
|
35
35
|
* @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO
|
|
36
36
|
*/
|
|
37
|
-
export declare function checkGasSponsorshipEligibility<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(
|
|
37
|
+
export declare function checkGasSponsorshipEligibility<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined>(client_: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<CheckGasSponsorshipEligibilityResult<TAccount>>;
|
|
@@ -2,6 +2,7 @@ import { isBaseSmartAccountClient } from "../../client/isSmartAccountClient.js";
|
|
|
2
2
|
import { AccountNotFoundError } from "../../errors/account.js";
|
|
3
3
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
4
4
|
import { buildUserOperation } from "./buildUserOperation.js";
|
|
5
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
5
6
|
/**
|
|
6
7
|
* This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.
|
|
7
8
|
* Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.
|
|
@@ -26,11 +27,12 @@ import { buildUserOperation } from "./buildUserOperation.js";
|
|
|
26
27
|
* );
|
|
27
28
|
* ```
|
|
28
29
|
*
|
|
29
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
30
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for making RPC calls
|
|
30
31
|
* @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides
|
|
31
32
|
* @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO
|
|
32
33
|
*/
|
|
33
|
-
export function checkGasSponsorshipEligibility(
|
|
34
|
+
export function checkGasSponsorshipEligibility(client_, args) {
|
|
35
|
+
const client = clientHeaderTrack(client_, "checkGasSponsorshipEligibility");
|
|
34
36
|
const { account = client.account, overrides, context } = args;
|
|
35
37
|
if (!account) {
|
|
36
38
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"checkGasSponsorshipEligibility.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/checkGasSponsorshipEligibility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAYnD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,8BAA8B,CAU5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;IAC5E,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAE9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,gCAAgC,EAChC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC;SACC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC9B,QAAQ,EACN,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,KAAK,OAAO;YACzC,CAAC,CAAE,mBAAoD;iBAClD,gBAAgB,KAAK,IAAI;gBAC3B,mBAAoD;qBAClD,gBAAgB,KAAK,IAAI;YAC9B,CAAC,CAAE,mBAAoD;iBAClD,aAAa,KAAK,IAAI;gBACxB,mBAAoD;qBAClD,aAAa,KAAK,IAAI;QAC/B,OAAO,EAAE,mBAAmB;KAC7B,CAAC,CAAC;SACF,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC;QACZ,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC,CAAC;AACR,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationStruct } from \"../../types.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\nexport type CheckGasSponsorshipEligibilityResult<\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n eligible: boolean;\n request?: UserOperationStruct<TEntryPointVersion>;\n};\n\n/**\n * This function verifies the eligibility of the connected account for gas sponsorship concerning the upcoming `UserOperation` (UO) that is intended to be sent.\n * Internally, this method invokes `buildUserOperation`, which navigates through the middleware pipeline, including the `PaymasterMiddleware`. Its purpose is to construct the UO struct meant for transmission to the bundler. Following the construction of the UO struct, this function verifies if the resulting structure contains a non-empty `paymasterAndData` field.\n * You can utilize this method before sending the user operation to confirm its eligibility for gas sponsorship. Depending on the outcome, it allows you to tailor the user experience accordingly, based on eligibility.\n *\n * @example\n * ```ts\n * import { smartAccountClient } from \"./smartAccountClient\";\n * // [!code focus:99]\n * const { eligible } = await smartAccountClient.checkGasSponsorshipEligibility({\n * uo: {\n * data: \"0xCalldata\",\n * target: \"0xTarget\",\n * value: 0n,\n * },\n * });\n *\n * console.log(\n * `User Operation is ${\n * eligible ? \"eligible\" : \"ineligible\"\n * } for gas sponsorship.`\n * );\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for making RPC calls\n * @param {SendUserOperationParameters} args containing the user operation, account, context, and overrides\n * @returns {Promise<CheckGasSponsorshipEligibilityResult<TAccount>>} a Promise containing a boolean indicating if the account is elgibile for sponsorship and the sponsored UO\n */\nexport function checkGasSponsorshipEligibility<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<CheckGasSponsorshipEligibilityResult<TAccount>> {\n const client = clientHeaderTrack(client_, \"checkGasSponsorshipEligibility\");\n const { account = client.account, overrides, context } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"checkGasSponsorshipEligibility\",\n client\n );\n }\n\n return buildUserOperation(client, {\n uo: args.uo,\n account,\n overrides,\n context,\n })\n .then((userOperationStruct) => ({\n eligible:\n account.getEntryPoint().version === \"0.6.0\"\n ? (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.6.0\">)\n .paymasterAndData !== null\n : (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== \"0x\" &&\n (userOperationStruct as UserOperationStruct<\"0.7.0\">)\n .paymasterData !== null,\n request: userOperationStruct,\n }))\n .catch(() => ({\n eligible: false,\n }));\n}\n"]}
|
|
@@ -20,8 +20,8 @@ import type { DropAndReplaceUserOperationParameters, UserOperationContext } from
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
23
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ The client instance with the transport, chain, and account information
|
|
24
24
|
* @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
|
|
25
25
|
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
|
|
26
26
|
*/
|
|
27
|
-
export declare function dropAndReplaceUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(
|
|
27
|
+
export declare function dropAndReplaceUserOperation<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client_: Client<TTransport, TChain, TAccount>, args: DropAndReplaceUserOperationParameters<TAccount, TContext>): Promise<SendUserOperationResult<TEntryPointVersion>>;
|
|
@@ -4,6 +4,7 @@ import { IncompatibleClientError } from "../../errors/client.js";
|
|
|
4
4
|
import { bigIntMax, bigIntMultiply, resolveProperties, } from "../../utils/index.js";
|
|
5
5
|
import { _runMiddlewareStack } from "./internal/runMiddlewareStack.js";
|
|
6
6
|
import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
7
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.
|
|
9
10
|
*
|
|
@@ -22,11 +23,12 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
22
23
|
* });
|
|
23
24
|
* ```
|
|
24
25
|
*
|
|
25
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
26
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ The client instance with the transport, chain, and account information
|
|
26
27
|
* @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context
|
|
27
28
|
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation
|
|
28
29
|
*/
|
|
29
|
-
export async function dropAndReplaceUserOperation(
|
|
30
|
+
export async function dropAndReplaceUserOperation(client_, args) {
|
|
31
|
+
const client = clientHeaderTrack(client_, "dropAndReplaceUserOperation");
|
|
30
32
|
const { account = client.account, uoToDrop, overrides, context } = args;
|
|
31
33
|
if (!account) {
|
|
32
34
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"dropAndReplaceUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/dropAndReplaceUserOperation.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAMjE,OAAO,EACL,SAAS,EACT,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAW/C,OAA6C,EAC7C,IAA+D;IAE/D,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;IACzE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,6BAA6B,EAC7B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3C,MAAM,UAAU,GAAG,CACjB,UAAU,CAAC,OAAO,KAAK,OAAO;QAC5B,CAAC,CAAC;YACE,QAAQ,EAAG,QAA0C,CAAC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,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,QAAQ,EAAE,QAAQ;QAClB,OAAO;QACP,OAAO;QACP,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport type { SendUserOperationResult } from \"../../client/types\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type {\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../../types\";\nimport {\n bigIntMax,\n bigIntMultiply,\n resolveProperties,\n} from \"../../utils/index.js\";\nimport { _runMiddlewareStack } from \"./internal/runMiddlewareStack.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n DropAndReplaceUserOperationParameters,\n UserOperationContext,\n} from \"./types\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Drops an existing user operation and replaces it with a new one while ensuring the appropriate fees and overrides are applied.\n *\n * @example\n * ```ts\n * import {\n * createSmartAccountClient,\n * } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with dropAndReplaceUserOperation\n * const client = createSmartAccountClient(...);\n * const { request } = await client.sendUserOperation(...);\n * const result = await client.dropAndReplaceUserOperation({\n * uoToDrop: request,\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client instance with the transport, chain, and account information\n * @param {DropAndReplaceUserOperationParameters<TAccount, TContext>} args The parameters required for dropping and replacing the user operation including the account, operation to drop, overrides, and context\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} A promise that resolves to the result of sending the new user operation\n */\nexport async function dropAndReplaceUserOperation<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: DropAndReplaceUserOperationParameters<TAccount, TContext>\n): Promise<SendUserOperationResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"dropAndReplaceUserOperation\");\n const { account = client.account, uoToDrop, overrides, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"dropAndReplaceUserOperation\",\n client\n );\n }\n\n const entryPoint = account.getEntryPoint();\n\n const uoToSubmit = (\n entryPoint.version === \"0.6.0\"\n ? {\n initCode: (uoToDrop as UserOperationRequest<\"0.6.0\">).initCode,\n sender: (uoToDrop as UserOperationRequest<\"0.6.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.6.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.6.0\">).callData,\n signature: await account.getDummySignature(),\n }\n : {\n ...((uoToDrop as UserOperationRequest<\"0.7.0\">).factory &&\n (uoToDrop as UserOperationRequest<\"0.7.0\">).factoryData\n ? {\n factory: (uoToDrop as UserOperationRequest<\"0.7.0\">).factory,\n factoryData: (uoToDrop as UserOperationRequest<\"0.7.0\">)\n .factoryData,\n }\n : {}),\n sender: (uoToDrop as UserOperationRequest<\"0.7.0\">).sender,\n nonce: (uoToDrop as UserOperationRequest<\"0.7.0\">).nonce,\n callData: (uoToDrop as UserOperationRequest<\"0.7.0\">).callData,\n signature: await account.getDummySignature(),\n }\n ) as UserOperationStruct<TEntryPointVersion>;\n\n // If the fee estimator is not the one estimating fees, then this won't work\n // however, we have migrated to using erc7677middleware for alchemy paymaster flows\n // and most of the other paymasters we've seen don't do fee estimation\n const { maxFeePerGas, maxPriorityFeePerGas } = await resolveProperties(\n await client.middleware.feeEstimator(uoToSubmit, { account, client })\n );\n\n const _overrides = {\n ...overrides,\n maxFeePerGas: bigIntMax(\n BigInt(maxFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxFeePerGas, 1.1)\n ),\n maxPriorityFeePerGas: bigIntMax(\n BigInt(maxPriorityFeePerGas ?? 0n),\n bigIntMultiply(uoToDrop.maxPriorityFeePerGas, 1.1)\n ),\n } as UserOperationOverrides<TEntryPointVersion>;\n\n const uoToSend = await _runMiddlewareStack(client, {\n uo: uoToSubmit,\n overrides: _overrides,\n account,\n });\n\n return _sendUserOperation(client, {\n uoStruct: uoToSend,\n account,\n context,\n overrides: _overrides,\n });\n}\n"]}
|
|
@@ -11,8 +11,8 @@ import type { SendUserOperationParameters, UserOperationContext } from "./types.
|
|
|
11
11
|
* @template {SmartContractAccount | undefined} TAccount
|
|
12
12
|
* @template {UserOperationContext | undefined} TContext
|
|
13
13
|
* @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion
|
|
14
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
14
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ smart account client
|
|
15
15
|
* @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters
|
|
16
16
|
* @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response
|
|
17
17
|
*/
|
|
18
|
-
export declare function estimateUserOperationGas<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(
|
|
18
|
+
export declare function estimateUserOperationGas<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client_: Client<TTransport, TChain, TAccount>, args: SendUserOperationParameters<TAccount, TContext>): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>;
|
|
@@ -4,6 +4,7 @@ import { AccountNotFoundError } from "../../errors/account.js";
|
|
|
4
4
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
5
5
|
import { deepHexlify, resolveProperties } from "../../utils/index.js";
|
|
6
6
|
import { _initUserOperation } from "./internal/initUserOperation.js";
|
|
7
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
7
8
|
/**
|
|
8
9
|
* Description SmartAccountClientAction for estimating the gas cost of a user operation
|
|
9
10
|
*
|
|
@@ -13,11 +14,12 @@ import { _initUserOperation } from "./internal/initUserOperation.js";
|
|
|
13
14
|
* @template {SmartContractAccount | undefined} TAccount
|
|
14
15
|
* @template {UserOperationContext | undefined} TContext
|
|
15
16
|
* @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion
|
|
16
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
17
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ smart account client
|
|
17
18
|
* @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters
|
|
18
19
|
* @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response
|
|
19
20
|
*/
|
|
20
|
-
export async function estimateUserOperationGas(
|
|
21
|
+
export async function estimateUserOperationGas(client_, args) {
|
|
22
|
+
const client = clientHeaderTrack(client_, "estimateUserOperationGas");
|
|
21
23
|
const { account = client.account, overrides } = args;
|
|
22
24
|
if (!account) {
|
|
23
25
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"estimateUserOperationGas.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/estimateUserOperationGas.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAW5C,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IACrD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,0BAA0B,EAC1B,MAAM,CACP,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7D,OAAO,MAAM,CAAC,wBAAwB,CACpC,OAAO,EACP,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,EAC/B,SAAS,EAAE,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Transport } from \"viem\";\nimport {\n type GetEntryPointFromAccount,\n type SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport type { UserOperationEstimateGasResponse } from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { _initUserOperation } from \"./internal/initUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Description SmartAccountClientAction for estimating the gas cost of a user operation\n *\n * @async\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n * @template {UserOperationContext | undefined} TContext\n * @template {GetEntryPointFromAccount<TAccount>} TEntryPointVersion\n * @param {Client<TTransport, TChain, TAccount>} client_ smart account client\n * @param {SendUserOperationParameters<TAccount, TContext>} args send user operation parameters\n * @returns {Promise<UserOperationEstimateGasResponse<TEntryPointVersion>>}user operation gas estimate response\n */\nexport async function estimateUserOperationGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendUserOperationParameters<TAccount, TContext>\n): Promise<UserOperationEstimateGasResponse<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account, overrides } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"estimateUserOperationGas\",\n client\n );\n }\n\n return _initUserOperation(client, args).then(async (struct) => {\n const request = deepHexlify(await resolveProperties(struct));\n return client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n });\n}\n"]}
|
|
@@ -20,10 +20,10 @@ import type { UserOperationContext } from "./types.js";
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @param {Client<Transport, TChain, TAccount>}
|
|
23
|
+
* @param {Client<Transport, TChain, TAccount>} client_ The client to send the transaction through
|
|
24
24
|
* @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction
|
|
25
25
|
* @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation
|
|
26
26
|
* @param {UserOperationContext} [context] Optional context for the user operation
|
|
27
27
|
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash
|
|
28
28
|
*/
|
|
29
|
-
export declare function sendTransaction<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(
|
|
29
|
+
export declare function sendTransaction<TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TChainOverride extends Chain | undefined = Chain | undefined, TContext extends UserOperationContext | undefined = UserOperationContext | undefined, TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>>(client_: Client<Transport, TChain, TAccount>, args: SendTransactionParameters<TChain, TAccount, TChainOverride>, overrides?: UserOperationOverrides<TEntryPointVersion>, context?: TContext): Promise<Hex>;
|
|
@@ -6,6 +6,7 @@ import { WaitForUserOperationError } from "../../errors/useroperation.js";
|
|
|
6
6
|
import { buildUserOperationFromTx } from "./buildUserOperationFromTx.js";
|
|
7
7
|
import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
8
8
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
9
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
9
10
|
/**
|
|
10
11
|
* Sends a transaction using the provided client, arguments, optional overrides, and context.
|
|
11
12
|
* This sends a UO and then waits for it to be mined
|
|
@@ -24,13 +25,14 @@ import { waitForUserOperationTransaction } from "./waitForUserOperationTransacat
|
|
|
24
25
|
* });
|
|
25
26
|
* ```
|
|
26
27
|
*
|
|
27
|
-
* @param {Client<Transport, TChain, TAccount>}
|
|
28
|
+
* @param {Client<Transport, TChain, TAccount>} client_ The client to send the transaction through
|
|
28
29
|
* @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction
|
|
29
30
|
* @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation
|
|
30
31
|
* @param {UserOperationContext} [context] Optional context for the user operation
|
|
31
32
|
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash
|
|
32
33
|
*/
|
|
33
|
-
export async function sendTransaction(
|
|
34
|
+
export async function sendTransaction(client_, args, overrides, context) {
|
|
35
|
+
const client = clientHeaderTrack(client_, "estimateUserOperationGas");
|
|
34
36
|
const { account = client.account } = args;
|
|
35
37
|
if (!account || typeof account === "string") {
|
|
36
38
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"sendTransaction.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransaction.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,8BAA8B,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAWnC,OAA4C,EAC5C,IAAiE,EACjE,SAAsD,EACtD,OAAkB;IAElB,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;IACtE,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC1C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACb,MAAM,IAAI,8BAA8B,EAAE,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAC7C,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,CACR,CAAC;IAEF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QACzD,OAAO,EAAE,OAA+B;QACxC,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,+BAA+B,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n Chain,\n Client,\n Hex,\n SendTransactionParameters,\n Transport,\n} from \"viem\";\nimport type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { TransactionMissingToParamError } from \"../../errors/transaction.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport type { UserOperationOverrides } from \"../../types.js\";\nimport { buildUserOperationFromTx } from \"./buildUserOperationFromTx.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { UserOperationContext } from \"./types.js\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends a transaction using the provided client, arguments, optional overrides, and context.\n * This sends a UO and then waits for it to be mined\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransaction\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransaction({\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<Transport, TChain, TAccount>} client_ The client to send the transaction through\n * @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction\n * @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation\n * @param {UserOperationContext} [context] Optional context for the user operation\n * @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash\n */\nexport async function sendTransaction<\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TChainOverride extends Chain | undefined = Chain | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n client_: Client<Transport, TChain, TAccount>,\n args: SendTransactionParameters<TChain, TAccount, TChainOverride>,\n overrides?: UserOperationOverrides<TEntryPointVersion>,\n context?: TContext\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { account = client.account } = args;\n if (!account || typeof account === \"string\") {\n throw new AccountNotFoundError();\n }\n\n if (!args.to) {\n throw new TransactionMissingToParamError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransaction\",\n client\n );\n }\n\n const uoStruct = await buildUserOperationFromTx(\n client,\n args,\n overrides,\n context\n );\n\n const { hash, request } = await _sendUserOperation(client, {\n account: account as SmartContractAccount,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}
|
|
@@ -20,8 +20,8 @@ import type { SendTransactionsParameters, UserOperationContext } from "./types";
|
|
|
20
20
|
* });
|
|
21
21
|
* ```
|
|
22
22
|
*
|
|
23
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
23
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ The client used to send the transactions
|
|
24
24
|
* @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context
|
|
25
25
|
* @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions
|
|
26
26
|
*/
|
|
27
|
-
export declare function sendTransactions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext>(
|
|
27
|
+
export declare function sendTransactions<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined, TContext extends UserOperationContext | undefined = UserOperationContext>(client_: Client<TTransport, TChain, TAccount>, args: SendTransactionsParameters<TAccount, TContext>): Promise<Hex>;
|
|
@@ -5,6 +5,7 @@ import { WaitForUserOperationError } from "../../errors/useroperation.js";
|
|
|
5
5
|
import { buildUserOperationFromTxs } from "./buildUserOperationFromTxs.js";
|
|
6
6
|
import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
7
7
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
8
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
8
9
|
/**
|
|
9
10
|
* Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.
|
|
10
11
|
*
|
|
@@ -24,11 +25,12 @@ import { waitForUserOperationTransaction } from "./waitForUserOperationTransacat
|
|
|
24
25
|
* });
|
|
25
26
|
* ```
|
|
26
27
|
*
|
|
27
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
28
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ The client used to send the transactions
|
|
28
29
|
* @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context
|
|
29
30
|
* @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions
|
|
30
31
|
*/
|
|
31
|
-
export async function sendTransactions(
|
|
32
|
+
export async function sendTransactions(client_, args) {
|
|
33
|
+
const client = clientHeaderTrack(client_, "estimateUserOperationGas");
|
|
32
34
|
const { requests, overrides, account = client.account, context } = args;
|
|
33
35
|
if (!account) {
|
|
34
36
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTransactions.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"sendTransactions.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendTransactions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,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E,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,IAAI,yBAAyB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport type { SmartContractAccount } from \"../../account/smartContractAccount.js\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { WaitForUserOperationError } from \"../../errors/useroperation.js\";\nimport { buildUserOperationFromTxs } from \"./buildUserOperationFromTxs.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type { SendTransactionsParameters, UserOperationContext } from \"./types\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with sendTransactions\n * const client = createSmartAccountClient(...);\n * const result = await client.sendTransactions({\n * requests: [{\n * to: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * }],\n * account, // only required if the client above is not connected to an account\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ The client used to send the transactions\n * @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions\n */\nexport async function sendTransactions<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined = UserOperationContext\n>(\n client_: Client<TTransport, TChain, TAccount>,\n args: SendTransactionsParameters<TAccount, TContext>\n): Promise<Hex> {\n const client = clientHeaderTrack(client_, \"estimateUserOperationGas\");\n const { requests, overrides, account = client.account, context } = args;\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendTransactions\",\n client\n );\n }\n\n const { uoStruct } = await buildUserOperationFromTxs(client, {\n requests,\n overrides,\n account,\n context,\n });\n\n const { hash, request } = await _sendUserOperation(client, {\n account,\n uoStruct,\n context,\n overrides,\n });\n\n return waitForUserOperationTransaction(client, { hash }).catch((e) => {\n throw new WaitForUserOperationError(request, e);\n });\n}\n"]}
|