@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
|
@@ -19,8 +19,8 @@ import type { SendUserOperationParameters, UserOperationContext } from "./types.
|
|
|
19
19
|
* });
|
|
20
20
|
* ```
|
|
21
21
|
*
|
|
22
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
22
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for RPC requests
|
|
23
23
|
* @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client
|
|
24
24
|
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation
|
|
25
25
|
*/
|
|
26
|
-
export declare function sendUserOperation<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>>(
|
|
26
|
+
export declare function sendUserOperation<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<SendUserOperationResult<TEntryPointVersion>>;
|
|
@@ -3,6 +3,7 @@ import { AccountNotFoundError } from "../../errors/account.js";
|
|
|
3
3
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
4
4
|
import { buildUserOperation } from "./buildUserOperation.js";
|
|
5
5
|
import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
6
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
6
7
|
/**
|
|
7
8
|
* Sends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.
|
|
8
9
|
*
|
|
@@ -20,11 +21,12 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
20
21
|
* });
|
|
21
22
|
* ```
|
|
22
23
|
*
|
|
23
|
-
* @param {Client<TTransport, TChain, TAccount>}
|
|
24
|
+
* @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for RPC requests
|
|
24
25
|
* @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client
|
|
25
26
|
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation
|
|
26
27
|
*/
|
|
27
|
-
export async function sendUserOperation(
|
|
28
|
+
export async function sendUserOperation(client_, args) {
|
|
29
|
+
const client = clientHeaderTrack(client_, "sendUserOperation");
|
|
28
30
|
const { account = client.account, context, overrides } = args;
|
|
29
31
|
if (!account) {
|
|
30
32
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendUserOperation.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;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/sendUserOperation.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;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAKrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAWrC,OAA6C,EAC7C,IAAqD;IAErD,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IAC/D,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,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,mBAAmB,EACnB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,EAAE;QAChD,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO;QACP,OAAO;QACP,SAAS;KACV,CAAC,CAAC;IAEH,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,OAAO;QACP,QAAQ;QACR,OAAO;QACP,SAAS;KACV,CAAC,CAAC;AACL,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 type { SendUserOperationResult } from \"../../client/types.js\";\nimport { AccountNotFoundError } from \"../../errors/account.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { buildUserOperation } from \"./buildUserOperation.js\";\nimport { _sendUserOperation } from \"./internal/sendUserOperation.js\";\nimport type {\n SendUserOperationParameters,\n UserOperationContext,\n} from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Sends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n *\n * const account = await toSmartContractAccount(...);\n * const result = await createSmartAccountClient(...).sendUserOperation({\n * uo: {\n * target: \"0x...\",\n * data: \"0x...\", // or \"0x\",\n * value: 0n, // optional\n * }\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, TAccount>} client_ the smart account client to use for RPC requests\n * @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client\n * @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation\n */\nexport async function sendUserOperation<\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<SendUserOperationResult<TEntryPointVersion>> {\n const client = clientHeaderTrack(client_, \"sendUserOperation\");\n const { account = client.account, context, overrides } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"sendUserOperation\",\n client\n );\n }\n\n const uoStruct = await buildUserOperation(client, {\n uo: args.uo,\n account,\n context,\n overrides,\n });\n\n return _sendUserOperation(client, {\n account,\n uoStruct,\n context,\n overrides,\n });\n}\n"]}
|
|
@@ -3,7 +3,9 @@ import { AccountNotFoundError } from "../../errors/account.js";
|
|
|
3
3
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
4
4
|
import { sendUserOperation } from "./sendUserOperation.js";
|
|
5
5
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
6
|
-
|
|
6
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
7
|
+
export const upgradeAccount = async (client_, args) => {
|
|
8
|
+
const client = clientHeaderTrack(client_, "upgradeAccount");
|
|
7
9
|
const { account = client.account, upgradeTo, overrides, waitForTx, context, } = args;
|
|
8
10
|
if (!account) {
|
|
9
11
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgradeAccount.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/upgradeAccount.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,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"upgradeAccount.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/upgradeAccount.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,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,CAAC,MAAM,cAAc,GAYN,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAC5D,MAAM,EACJ,OAAO,GAAG,MAAM,CAAC,OAAO,EACxB,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,GACR,GAAG,IAAI,CAAC;IAET,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,gBAAgB,EAChB,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAC;IAE1E,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,sBAAsB,CAAC;QAC7D,gBAAgB,EAAE,kBAAkB;QACpC,iBAAiB,EAAE,kBAAkB;KACtC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,EAAE;QAC7C,EAAE,EAAE;YACF,MAAM,EAAE,OAAO,CAAC,OAAO;YACvB,IAAI,EAAE,iBAAiB;SACxB;QACD,OAAO;QACP,SAAS;QACT,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACvB,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,GAAG,MAAM,+BAA+B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hash, 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 { sendUserOperation } from \"./sendUserOperation.js\";\nimport type { UpgradeAccountParams, UserOperationContext } from \"./types.js\";\nimport { waitForUserOperationTransaction } from \"./waitForUserOperationTransacation.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\nexport const upgradeAccount: <\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: UpgradeAccountParams<TAccount, TContext>\n) => Promise<Hash> = async (client_, args) => {\n const client = clientHeaderTrack(client_, \"upgradeAccount\");\n const {\n account = client.account,\n upgradeTo,\n overrides,\n waitForTx,\n context,\n } = args;\n\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"upgradeAccount\",\n client\n );\n }\n\n const { implAddress: accountImplAddress, initializationData } = upgradeTo;\n\n const encodeUpgradeData = await account.encodeUpgradeToAndCall({\n upgradeToAddress: accountImplAddress,\n upgradeToInitData: initializationData,\n });\n\n const result = await sendUserOperation(client, {\n uo: {\n target: account.address,\n data: encodeUpgradeData,\n },\n account,\n overrides,\n context,\n });\n\n let hash = result.hash;\n if (waitForTx) {\n hash = await waitForUserOperationTransaction(client, result);\n }\n\n return hash;\n};\n"]}
|
|
@@ -15,7 +15,7 @@ import type { WaitForUserOperationTxParameters } from "./types.js";
|
|
|
15
15
|
* });
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
|
-
* @param {Client<TTransport, TChain, any>}
|
|
18
|
+
* @param {Client<TTransport, TChain, any>} client_ The client instance used to interact with the blockchain
|
|
19
19
|
* @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for
|
|
20
20
|
* @param {Hex} args.hash The transaction hash to wait for
|
|
21
21
|
* @param {WaitForUserOperationTxParameters["retries"]} [args.retries] Optional retry parameters
|
|
@@ -2,6 +2,7 @@ import { isBaseSmartAccountClient } from "../../client/isSmartAccountClient.js";
|
|
|
2
2
|
import { IncompatibleClientError } from "../../errors/client.js";
|
|
3
3
|
import { FailedToFindTransactionError } from "../../errors/transaction.js";
|
|
4
4
|
import { Logger } from "../../logger.js";
|
|
5
|
+
import { clientHeaderTrack } from "../../index.js";
|
|
5
6
|
/**
|
|
6
7
|
* Waits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.
|
|
7
8
|
*
|
|
@@ -17,7 +18,7 @@ import { Logger } from "../../logger.js";
|
|
|
17
18
|
* });
|
|
18
19
|
* ```
|
|
19
20
|
*
|
|
20
|
-
* @param {Client<TTransport, TChain, any>}
|
|
21
|
+
* @param {Client<TTransport, TChain, any>} client_ The client instance used to interact with the blockchain
|
|
21
22
|
* @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for
|
|
22
23
|
* @param {Hex} args.hash The transaction hash to wait for
|
|
23
24
|
* @param {WaitForUserOperationTxParameters["retries"]} [args.retries] Optional retry parameters
|
|
@@ -26,7 +27,8 @@ import { Logger } from "../../logger.js";
|
|
|
26
27
|
* @param {number} [args.retries.multiplier] The multiplier for the interval between retries
|
|
27
28
|
* @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed
|
|
28
29
|
*/
|
|
29
|
-
export const waitForUserOperationTransaction = async (
|
|
30
|
+
export const waitForUserOperationTransaction = async (client_, args) => {
|
|
31
|
+
const client = clientHeaderTrack(client_, "waitForUserOperationTransaction");
|
|
30
32
|
if (!isBaseSmartAccountClient(client)) {
|
|
31
33
|
throw new IncompatibleClientError("BaseSmartAccountClient", "waitForUserOperationTransaction", client);
|
|
32
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"waitForUserOperationTransacation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/waitForUserOperationTransacation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"waitForUserOperationTransacation.js","sourceRoot":"","sources":["../../../../src/actions/smartAccount/waitForUserOperationTransacation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAMxB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC1C,MAAM,MAAM,GAAG,iBAAiB,CAAC,OAAO,EAAE,iCAAiC,CAAC,CAAC;IAC7E,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,uBAAuB,CAC/B,wBAAwB,EACxB,iCAAiC,EACjC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,MAAM,EACJ,IAAI,EACJ,OAAO,GAAG;QACR,UAAU,EAAE,MAAM,CAAC,YAAY;QAC/B,UAAU,EAAE,MAAM,CAAC,iBAAiB;QACpC,UAAU,EAAE,MAAM,CAAC,iBAAiB;KACrC,GACF,GAAG,IAAI,CAAC;IAET,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,2BAA2B,GAC/B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;QAEtB,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,UAAU,CAAC,OAAO,EAAE,2BAA2B,CAAC,CACjD,CAAC;QAEF,MAAM,OAAO,GAAG,MAAM,MAAM;aACzB,uBAAuB,CAAC,IAAqB,CAAC;aAC9C,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,MAAM,CAAC,KAAK,CACV,qFAAqF,IAAI,KAAK,CAAC,EAAE,CAClG,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,MAAM,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC,CAAC","sourcesContent":["import type { Chain, Client, Hex, Transport } from \"viem\";\nimport { isBaseSmartAccountClient } from \"../../client/isSmartAccountClient.js\";\nimport { IncompatibleClientError } from \"../../errors/client.js\";\nimport { FailedToFindTransactionError } from \"../../errors/transaction.js\";\nimport { Logger } from \"../../logger.js\";\nimport type { WaitForUserOperationTxParameters } from \"./types.js\";\nimport { clientHeaderTrack } from \"../../index.js\";\n\n/**\n * Waits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * // smart account client is already extended with waitForUserOperationTransaction\n * const client = createSmartAccountClient(...);\n * const result = await client.waitForUserOperationTransaction({\n * hash: \"0x...\",\n * retries: {...} // optional param to configure the retry amounts\n * });\n * ```\n *\n * @param {Client<TTransport, TChain, any>} client_ The client instance used to interact with the blockchain\n * @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for\n * @param {Hex} args.hash The transaction hash to wait for\n * @param {WaitForUserOperationTxParameters[\"retries\"]} [args.retries] Optional retry parameters\n * @param {number} [args.retries.maxRetries] The maximum number of retry attempts\n * @param {number} [args.retries.intervalMs] The interval in milliseconds between retries\n * @param {number} [args.retries.multiplier] The multiplier for the interval between retries\n * @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed\n */\nexport const waitForUserOperationTransaction: <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined\n>(\n client: Client<TTransport, TChain, any>,\n args: WaitForUserOperationTxParameters\n) => Promise<Hex> = async (client_, args) => {\n const client = clientHeaderTrack(client_, \"waitForUserOperationTransaction\");\n if (!isBaseSmartAccountClient(client)) {\n throw new IncompatibleClientError(\n \"BaseSmartAccountClient\",\n \"waitForUserOperationTransaction\",\n client\n );\n }\n\n const {\n hash,\n retries = {\n maxRetries: client.txMaxRetries,\n intervalMs: client.txRetryIntervalMs,\n multiplier: client.txRetryMultiplier,\n },\n } = args;\n\n for (let i = 0; i < retries.maxRetries; i++) {\n const txRetryIntervalWithJitterMs =\n retries.intervalMs * Math.pow(retries.multiplier, i) +\n Math.random() * 100;\n\n await new Promise((resolve) =>\n setTimeout(resolve, txRetryIntervalWithJitterMs)\n );\n\n const receipt = await client\n .getUserOperationReceipt(hash as `0x${string}`)\n .catch((e) => {\n Logger.error(\n `[SmartAccountProvider] waitForUserOperationTransaction error fetching receipt for ${hash}: ${e}`\n );\n });\n\n if (receipt) {\n return receipt?.receipt.transactionHash;\n }\n }\n\n throw new FailedToFindTransactionError(hash);\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The symbol that is used to add a breadcrumb to the headers. Is an optional
|
|
3
|
+
* function that is used to add a breadcrumb to the headers.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ADD_BREADCRUMB: unique symbol;
|
|
6
|
+
/**
|
|
7
|
+
* Add a crumb to the breadcrumb.
|
|
8
|
+
*
|
|
9
|
+
* @param {X} client Clients are somethings like viem, that we are adding breadcrumbs to, and could be owning the transport. Usually a alchemy client.
|
|
10
|
+
* @param {string} crumb The crumb to add to the breadcrumb
|
|
11
|
+
* @returns {Function} A function that updates the headers
|
|
12
|
+
*/
|
|
13
|
+
export declare function clientHeaderTrack<X extends {}>(client: X, crumb: string): X;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The symbol that is used to add a breadcrumb to the headers. Is an optional
|
|
3
|
+
* function that is used to add a breadcrumb to the headers.
|
|
4
|
+
*/
|
|
5
|
+
export const ADD_BREADCRUMB = Symbol("addBreadcrumb");
|
|
6
|
+
function hasAddBreadcrumb(a) {
|
|
7
|
+
return ADD_BREADCRUMB in a;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Add a crumb to the breadcrumb.
|
|
11
|
+
*
|
|
12
|
+
* @param {X} client Clients are somethings like viem, that we are adding breadcrumbs to, and could be owning the transport. Usually a alchemy client.
|
|
13
|
+
* @param {string} crumb The crumb to add to the breadcrumb
|
|
14
|
+
* @returns {Function} A function that updates the headers
|
|
15
|
+
*/
|
|
16
|
+
export function clientHeaderTrack(client, crumb) {
|
|
17
|
+
if (hasAddBreadcrumb(client)) {
|
|
18
|
+
return client[ADD_BREADCRUMB](crumb);
|
|
19
|
+
}
|
|
20
|
+
return client;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=addBreadcrumb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addBreadcrumb.js","sourceRoot":"","sources":["../../../src/client/addBreadcrumb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAEtD,SAAS,gBAAgB,CACvB,CAAI;IAEJ,OAAO,cAAc,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAe,MAAS,EAAE,KAAa;IACtE,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * The symbol that is used to add a breadcrumb to the headers. Is an optional\n * function that is used to add a breadcrumb to the headers.\n */\nexport const ADD_BREADCRUMB = Symbol(\"addBreadcrumb\");\n\nfunction hasAddBreadcrumb<A extends {}>(\n a: A\n): a is A & { [ADD_BREADCRUMB]: (breadcrumb: string) => A } {\n return ADD_BREADCRUMB in a;\n}\n\n/**\n * Add a crumb to the breadcrumb.\n *\n * @param {X} client Clients are somethings like viem, that we are adding breadcrumbs to, and could be owning the transport. Usually a alchemy client.\n * @param {string} crumb The crumb to add to the breadcrumb\n * @returns {Function} A function that updates the headers\n */\nexport function clientHeaderTrack<X extends {}>(client: X, crumb: string): X {\n if (hasAddBreadcrumb(client)) {\n return client[ADD_BREADCRUMB](crumb);\n }\n return client;\n}\n"]}
|
|
@@ -13,6 +13,15 @@ type SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;
|
|
|
13
13
|
export type SmartAccountClientConfig<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<Pick<ClientConfig<transport, chain, account>, "cacheTime" | "chain" | "key" | "name" | "pollingInterval" | "transport" | "type"> & {
|
|
14
14
|
account?: account;
|
|
15
15
|
opts?: z.input<typeof SmartAccountClientOptsSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* A function that adds a breadcrumb to the current context
|
|
18
|
+
* Note, most implementations will override the client with the default alchemy transport and this
|
|
19
|
+
* leads to the fact that a transport could be overwritten and not known until later.
|
|
20
|
+
*
|
|
21
|
+
* @param crumb A crumb, or span is telling that we are in a next step part of a multi step action
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
addBreadCrumb?: <T>(crumb: string) => T;
|
|
16
25
|
} & ClientMiddlewareConfig<context>>;
|
|
17
26
|
export type SmartAccountClientRpcSchema = [
|
|
18
27
|
...BundlerRpcSchema,
|
|
@@ -7,6 +7,7 @@ import { createBundlerClient } from "./bundlerClient.js";
|
|
|
7
7
|
import {} from "./decorators/bundlerClient.js";
|
|
8
8
|
import { smartAccountClientActions, } from "./decorators/smartAccountClient.js";
|
|
9
9
|
import { SmartAccountClientOptsSchema } from "./schema.js";
|
|
10
|
+
import { ADD_BREADCRUMB } from "./addBreadcrumb.js";
|
|
10
11
|
/**
|
|
11
12
|
* Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.
|
|
12
13
|
*
|
|
@@ -28,7 +29,7 @@ import { SmartAccountClientOptsSchema } from "./schema.js";
|
|
|
28
29
|
* @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account
|
|
29
30
|
*/
|
|
30
31
|
export function createSmartAccountClient(config) {
|
|
31
|
-
const { key = "account", name = "account provider", transport, type = "SmartAccountClient", ...params } = config;
|
|
32
|
+
const { key = "account", name = "account provider", transport, type = "SmartAccountClient", addBreadCrumb, ...params } = config;
|
|
32
33
|
const client = createBundlerClient({
|
|
33
34
|
...params,
|
|
34
35
|
key,
|
|
@@ -41,6 +42,7 @@ export function createSmartAccountClient(config) {
|
|
|
41
42
|
transport: (opts) => {
|
|
42
43
|
const rpcTransport = transport(opts);
|
|
43
44
|
return custom({
|
|
45
|
+
name: "SmartAccountClientTransport",
|
|
44
46
|
async request({ method, params }) {
|
|
45
47
|
switch (method) {
|
|
46
48
|
case "eth_accounts": {
|
|
@@ -111,9 +113,17 @@ export function createSmartAccountClient(config) {
|
|
|
111
113
|
})(opts);
|
|
112
114
|
},
|
|
113
115
|
})
|
|
114
|
-
.extend(() =>
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
.extend(() => {
|
|
117
|
+
const addBreadCrumbs = addBreadCrumb
|
|
118
|
+
? {
|
|
119
|
+
[ADD_BREADCRUMB]: addBreadCrumb,
|
|
120
|
+
}
|
|
121
|
+
: {};
|
|
122
|
+
return {
|
|
123
|
+
...SmartAccountClientOptsSchema.parse(config.opts ?? {}),
|
|
124
|
+
...addBreadCrumbs,
|
|
125
|
+
};
|
|
126
|
+
})
|
|
117
127
|
.extend(middlewareActions(config))
|
|
118
128
|
.extend(smartAccountClientActions);
|
|
119
129
|
return { ...client, type };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAUP,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAGN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,GAE1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AA4G3D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAgC;IAEhC,MAAM,EACJ,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,kBAAkB,EACzB,SAAS,EACT,IAAI,GAAG,oBAAoB,EAC3B,GAAG,MAAM,EACV,GAAG,MAAM,CAAC;IAEX,MAAM,MAAM,GAAuB,mBAAmB,CAAC;QACrD,GAAG,MAAM;QACT,GAAG;QACH,IAAI;QACJ,2EAA2E;QAC3E,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AC,EAAE,CAAC;wBACvB;4BACE,uGAAuG;4BACvG,2CAA2C;4BAC3C,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;oBACpD,CAAC;gBACH,CAAC;aACF,CAAC,CAAC,IAAI,CAAC,CAAC;QACX,CAAC;KACF,CAAC;SACC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;QACb,GAAG,4BAA4B,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;KACzD,CAAC,CAAC;SACF,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;SACjC,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAErC,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAgCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,oCAAoC,CAClD,MAEC;IAED,OAAO,wBAAwB,CAAC;QAC9B,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n custom,\n type Chain,\n type Client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n// [!region SmartAccountClientActions]\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n// [!endregion SmartAccountClientActions]\n\n// [!region SmartAccountClient]\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n// [!endregion SmartAccountClient]\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\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 config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\n/**\n * Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * // optionally hoist the account\n * account: toSmartContractAccount(...),\n * });\n * ```\n *\n * @param {SmartAccountClientConfig} config The configuration for creating the smart account client\n * @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account\n */\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n async request({ method, params }) {\n switch (method) {\n case \"eth_accounts\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n return [client.account.address];\n }\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage({\n message: data,\n account: client.account,\n });\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage({\n message: data,\n account: client.account,\n });\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => ({\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n }))\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\n/**\n * Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.\n *\n * @example\n * ```ts\n * import {\n * createBundlerClient,\n * createSmartAccountClientFromExisting,\n * toSmartContractAccount\n * } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n * const client = createSmartAccountClientFromExisting({\n * client,\n * account: toSmartContractAccount(...),\n * })\n * ```\n *\n * @param {Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {client: BundlerClient}} config the configuration object which includes the client\n * @returns {SmartAccountClient} A smart account client created from the existing BundlerClient\n */\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,GAUP,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAGN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,G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AAC;QAC9B,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK;QAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KACjC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n custom,\n type Chain,\n type Client,\n type ClientConfig,\n type CustomTransport,\n type FormattedTransactionRequest,\n type PublicActions,\n type PublicRpcSchema,\n type RpcSchema,\n type Transport,\n} from \"viem\";\nimport { z } from \"zod\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types.js\";\nimport { AccountNotFoundError } from \"../errors/account.js\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport { middlewareActions } from \"../middleware/actions.js\";\nimport type { ClientMiddleware } from \"../middleware/types.js\";\nimport type { Prettify } from \"../utils/index.js\";\nimport { createBundlerClient, type BundlerClient } from \"./bundlerClient.js\";\nimport {\n type BundlerActions,\n type BundlerRpcSchema,\n} from \"./decorators/bundlerClient.js\";\nimport {\n smartAccountClientActions,\n type BaseSmartAccountClientActions,\n} from \"./decorators/smartAccountClient.js\";\nimport { SmartAccountClientOptsSchema } from \"./schema.js\";\nimport type { ClientMiddlewareConfig } from \"./types.js\";\nimport { ADD_BREADCRUMB } from \"./addBreadcrumb.js\";\n\ntype SmartAccountClientOpts = z.output<typeof SmartAccountClientOptsSchema>;\n\nexport type SmartAccountClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Pick<\n ClientConfig<transport, chain, account>,\n | \"cacheTime\"\n | \"chain\"\n | \"key\"\n | \"name\"\n | \"pollingInterval\"\n | \"transport\"\n | \"type\"\n > & {\n account?: account;\n opts?: z.input<typeof SmartAccountClientOptsSchema>;\n /**\n * A function that adds a breadcrumb to the current context\n * Note, most implementations will override the client with the default alchemy transport and this\n * leads to the fact that a transport could be overwritten and not known until later.\n *\n * @param crumb A crumb, or span is telling that we are in a next step part of a multi step action\n * @returns\n */\n addBreadCrumb?: <T>(crumb: string) => T;\n } & ClientMiddlewareConfig<context>\n>;\n\nexport type SmartAccountClientRpcSchema = [\n ...BundlerRpcSchema,\n ...PublicRpcSchema\n];\n\n// [!region SmartAccountClientActions]\nexport type SmartAccountClientActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = BaseSmartAccountClientActions<chain, account, context> &\n BundlerActions &\n PublicActions;\n// [!endregion SmartAccountClientActions]\n\n// [!region SmartAccountClient]\nexport type SmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n rpcSchema extends RpcSchema = SmartAccountClientRpcSchema,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n rpcSchema,\n actions & SmartAccountClientActions<chain, account, context>\n >\n>;\n// [!endregion SmartAccountClient]\n\nexport type BaseSmartAccountClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n Client<\n transport,\n chain,\n account,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n {\n middleware: ClientMiddleware<context>;\n } & SmartAccountClientOpts &\n BundlerActions &\n PublicActions\n >\n>;\n\nexport function createSmartAccountClient<\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 config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>\n): SmartAccountClient<TTransport, TChain, TAccount>;\n\n/**\n * Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, toSmartContractAccount } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * chain: sepolia,\n * transport: http(\"RPC_URL\"),\n * // optionally hoist the account\n * account: toSmartContractAccount(...),\n * });\n * ```\n *\n * @param {SmartAccountClientConfig} config The configuration for creating the smart account client\n * @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account\n */\nexport function createSmartAccountClient(\n config: SmartAccountClientConfig\n): SmartAccountClient {\n const {\n key = \"account\",\n name = \"account provider\",\n transport,\n type = \"SmartAccountClient\",\n addBreadCrumb,\n ...params\n } = config;\n\n const client: SmartAccountClient = createBundlerClient({\n ...params,\n key,\n name,\n // we start out with this because the base methods for a SmartAccountClient\n // require a smart account client, but once we have completed building everything\n // we want to override this value with the one passed in by the extender\n type: \"SmartAccountClient\",\n // TODO: this needs to be tested\n transport: (opts) => {\n const rpcTransport = transport(opts);\n\n return custom({\n name: \"SmartAccountClientTransport\",\n async request({ method, params }) {\n switch (method) {\n case \"eth_accounts\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n\n return [client.account.address];\n }\n case \"eth_sendTransaction\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n const [tx] = params as [FormattedTransactionRequest];\n return client.sendTransaction({\n ...tx,\n account: client.account,\n chain: client.chain,\n });\n case \"eth_sign\":\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, data] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage({\n message: data,\n account: client.account,\n });\n case \"personal_sign\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [data, address] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signMessage({\n message: data,\n account: client.account,\n });\n }\n case \"eth_signTypedData_v4\": {\n if (!client.account) {\n throw new AccountNotFoundError();\n }\n const [address, dataParams] = params!;\n if (\n address?.toLowerCase() !== client.account.address.toLowerCase()\n ) {\n throw new Error(\n \"cannot sign for address that is not the current account\"\n );\n }\n return client.signTypedData(dataParams);\n }\n case \"eth_chainId\":\n if (!opts.chain) {\n throw new ChainNotFoundError();\n }\n\n return opts.chain.id;\n default:\n // TODO: there's probably a number of methods we just don't support, will need to test most of them out\n // first let's get something working though\n return rpcTransport.request({ method, params });\n }\n },\n })(opts);\n },\n })\n .extend(() => {\n const addBreadCrumbs = addBreadCrumb\n ? {\n [ADD_BREADCRUMB]: addBreadCrumb,\n }\n : {};\n return {\n ...SmartAccountClientOptsSchema.parse(config.opts ?? {}),\n ...addBreadCrumbs,\n };\n })\n .extend(middlewareActions(config))\n .extend(smartAccountClientActions);\n\n return { ...client, type };\n}\n\nexport function createSmartAccountClientFromExisting<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TClient extends BundlerClient<TTransport> = BundlerClient<TTransport>,\n TActions extends SmartAccountClientActions<\n TChain,\n TAccount,\n TContext\n > = SmartAccountClientActions<TChain, TAccount>,\n TRpcSchema extends SmartAccountClientRpcSchema = SmartAccountClientRpcSchema,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n config: Omit<\n SmartAccountClientConfig<Transport, TChain, TAccount, TContext>,\n \"transport\" | \"chain\"\n > & { client: TClient }\n): SmartAccountClient<\n CustomTransport,\n TChain,\n TAccount,\n TActions,\n TRpcSchema,\n TContext\n>;\n\n/**\n * Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.\n *\n * @example\n * ```ts\n * import {\n * createBundlerClient,\n * createSmartAccountClientFromExisting,\n * toSmartContractAccount\n * } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n * const client = createSmartAccountClientFromExisting({\n * client,\n * account: toSmartContractAccount(...),\n * })\n * ```\n *\n * @param {Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {client: BundlerClient}} config the configuration object which includes the client\n * @returns {SmartAccountClient} A smart account client created from the existing BundlerClient\n */\nexport function createSmartAccountClientFromExisting(\n config: Omit<SmartAccountClientConfig, \"transport\" | \"chain\"> & {\n client: BundlerClient;\n }\n): SmartAccountClient {\n return createSmartAccountClient({\n ...config,\n chain: config.client.chain,\n transport: custom(config.client),\n });\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export { EntryPointNotFoundError, InvalidEntryPointError, } from "./errors/entry
|
|
|
38
38
|
export { InvalidSignerTypeError } from "./errors/signer.js";
|
|
39
39
|
export { FailedToFindTransactionError, TransactionMissingToParamError, } from "./errors/transaction.js";
|
|
40
40
|
export { InvalidUserOperationError, WaitForUserOperationError, } from "./errors/useroperation.js";
|
|
41
|
+
export * from "./client/addBreadcrumb.js";
|
|
41
42
|
export { LogLevel, Logger } from "./logger.js";
|
|
42
43
|
export { middlewareActions } from "./middleware/actions.js";
|
|
43
44
|
export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
|
|
@@ -58,4 +59,5 @@ export { WalletClientSigner } from "./signer/wallet-client.js";
|
|
|
58
59
|
export { split, type SplitTransportParams } from "./transport/split.js";
|
|
59
60
|
export type * from "./types.js";
|
|
60
61
|
export type * from "./utils/index.js";
|
|
62
|
+
export { TraceHeader } from "./utils/traceHeader.js";
|
|
61
63
|
export { BigNumberishRangeSchema, BigNumberishSchema, ChainSchema, HexSchema, MultiplierSchema, allEqual, applyUserOpFeeOption, applyUserOpOverride, applyUserOpOverrideOrFeeOption, asyncPipe, bigIntMax, bigIntMultiply, bypassPaymasterAndData, bypassPaymasterAndDataEmptyHex, concatPaymasterAndData, deepHexlify, filterUndefined, getDefaultUserOperationFeeOptions, isBigNumberish, isMultiplier, isValidRequest, parsePaymasterAndData, pick, resolveProperties, takeBytes, toRecord, } from "./utils/index.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { EntryPointNotFoundError, InvalidEntryPointError, } from "./errors/entry
|
|
|
28
28
|
export { InvalidSignerTypeError } from "./errors/signer.js";
|
|
29
29
|
export { FailedToFindTransactionError, TransactionMissingToParamError, } from "./errors/transaction.js";
|
|
30
30
|
export { InvalidUserOperationError, WaitForUserOperationError, } from "./errors/useroperation.js";
|
|
31
|
+
export * from "./client/addBreadcrumb.js";
|
|
31
32
|
export { LogLevel, Logger } from "./logger.js";
|
|
32
33
|
export { middlewareActions } from "./middleware/actions.js";
|
|
33
34
|
export { default7702UserOpSigner } from "./middleware/defaults/7702signer.js";
|
|
@@ -43,5 +44,6 @@ export { SignerSchema, isSigner } from "./signer/schema.js";
|
|
|
43
44
|
export { wrapSignatureWith6492 } from "./signer/utils.js";
|
|
44
45
|
export { WalletClientSigner } from "./signer/wallet-client.js";
|
|
45
46
|
export { split } from "./transport/split.js";
|
|
47
|
+
export { TraceHeader } from "./utils/traceHeader.js";
|
|
46
48
|
export { BigNumberishRangeSchema, BigNumberishSchema, ChainSchema, HexSchema, MultiplierSchema, allEqual, applyUserOpFeeOption, applyUserOpOverride, applyUserOpOverrideOrFeeOption, asyncPipe, bigIntMax, bigIntMultiply, bypassPaymasterAndData, bypassPaymasterAndDataEmptyHex, concatPaymasterAndData, deepHexlify, filterUndefined, getDefaultUserOperationFeeOptions, isBigNumberish, isMultiplier, isValidRequest, parsePaymasterAndData, pick, resolveProperties, takeBytes, toRecord, } from "./utils/index.js";
|
|
47
49
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @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EAAE,MAAM,2CAA2C,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAA6B,MAAM,sBAAsB,CAAC;AAGxE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC9B,SAAS,EACT,SAAS,EACT,cAAc,EACd,sBAAsB,EACtB,8BAA8B,EAC9B,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,iCAAiC,EACjC,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,iBAAiB,EACjB,SAAS,EACT,QAAQ,GACT,MAAM,kBAAkB,CAAC","sourcesContent":["export type { Abi } from \"abitype\";\nexport type { Address, HttpTransport } from \"viem\";\n\nexport { EntryPointAbi_v6 } from \"./abis/EntryPointAbi_v6.js\";\nexport { EntryPointAbi_v7 } from \"./abis/EntryPointAbi_v7.js\";\nexport { SimpleAccountAbi_v6 } from \"./abis/SimpleAccountAbi_v6.js\";\nexport { SimpleAccountAbi_v7 } from \"./abis/SimpleAccountAbi_v7.js\";\nexport { SimpleAccountFactoryAbi } from \"./abis/SimpleAccountFactoryAbi.js\";\nexport type * from \"./account/smartContractAccount.js\";\nexport {\n getAccountAddress,\n isSmartAccountWithSigner,\n parseFactoryAddressFromAccountInitCode,\n toSmartContractAccount,\n} from \"./account/smartContractAccount.js\";\nexport { buildUserOperation } from \"./actions/smartAccount/buildUserOperation.js\";\nexport { buildUserOperationFromTx } from \"./actions/smartAccount/buildUserOperationFromTx.js\";\nexport { buildUserOperationFromTxs } from \"./actions/smartAccount/buildUserOperationFromTxs.js\";\nexport { checkGasSponsorshipEligibility } from \"./actions/smartAccount/checkGasSponsorshipEligibility.js\";\nexport { dropAndReplaceUserOperation } from \"./actions/smartAccount/dropAndReplaceUserOperation.js\";\nexport { sendTransaction } from \"./actions/smartAccount/sendTransaction.js\";\nexport { sendTransactions } from \"./actions/smartAccount/sendTransactions.js\";\nexport { sendUserOperation } from \"./actions/smartAccount/sendUserOperation.js\";\nexport type * from \"./actions/smartAccount/types.js\";\nexport { waitForUserOperationTransaction } from \"./actions/smartAccount/waitForUserOperationTransacation.js\";\nexport type * from \"./client/bundlerClient.js\";\nexport {\n createBundlerClient,\n createBundlerClientFromExisting,\n} from \"./client/bundlerClient.js\";\nexport type * from \"./client/decorators/bundlerClient.js\";\nexport { bundlerActions } from \"./client/decorators/bundlerClient.js\";\nexport type * from \"./client/decorators/smartAccountClient.js\";\nexport { smartAccountClientActions } from \"./client/decorators/smartAccountClient.js\";\nexport { isSmartAccountClient } from \"./client/isSmartAccountClient.js\";\nexport {\n ConnectionConfigSchema,\n SmartAccountClientOptsSchema,\n} from \"./client/schema.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport {\n createSmartAccountClient,\n createSmartAccountClientFromExisting,\n} from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport {\n convertChainIdToCoinType,\n convertCoinTypeToChain,\n convertCoinTypeToChainId,\n} from \"./ens/utils.js\";\nexport {\n defaultEntryPointVersion,\n entryPointRegistry,\n getEntryPoint,\n isEntryPointVersion,\n} from \"./entrypoint/index.js\";\nexport type * from \"./entrypoint/types.js\";\nexport {\n AccountNotFoundError,\n AccountRequiresOwnerError,\n BatchExecutionNotSupportedError,\n DefaultFactoryNotDefinedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n IncorrectAccountType,\n SignTransactionNotSupportedError,\n SmartAccountWithSignerRequiredError,\n UpgradeToAndCallNotSupportedError,\n UpgradesNotSupportedError,\n} from \"./errors/account.js\";\nexport { BaseError } from \"./errors/base.js\";\nexport {\n ChainNotFoundError,\n IncompatibleClientError,\n InvalidRpcUrlError,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n} from \"./errors/client.js\";\nexport {\n EntryPointNotFoundError,\n InvalidEntryPointError,\n} from \"./errors/entrypoint.js\";\nexport { InvalidSignerTypeError } from \"./errors/signer.js\";\nexport {\n FailedToFindTransactionError,\n TransactionMissingToParamError,\n} from \"./errors/transaction.js\";\nexport {\n InvalidUserOperationError,\n WaitForUserOperationError,\n} from \"./errors/useroperation.js\";\nexport { LogLevel, Logger } from \"./logger.js\";\nexport { middlewareActions } from \"./middleware/actions.js\";\nexport { default7702UserOpSigner } from \"./middleware/defaults/7702signer.js\";\nexport { default7702GasEstimator } from \"./middleware/defaults/7702gasEstimator.js\";\nexport { defaultFeeEstimator } from \"./middleware/defaults/feeEstimator.js\";\nexport { defaultGasEstimator } from \"./middleware/defaults/gasEstimator.js\";\nexport { defaultPaymasterAndData } from \"./middleware/defaults/paymasterAndData.js\";\nexport { defaultUserOpSigner } from \"./middleware/defaults/userOpSigner.js\";\nexport type * from \"./middleware/erc7677middleware.js\";\nexport { erc7677Middleware } from \"./middleware/erc7677middleware.js\";\nexport { noopMiddleware } from \"./middleware/noopMiddleware.js\";\nexport type * from \"./middleware/types.js\";\nexport { LocalAccountSigner } from \"./signer/local-account.js\";\nexport { SignerSchema, isSigner } from \"./signer/schema.js\";\nexport type {\n SmartAccountAuthenticator,\n SmartAccountSigner,\n} from \"./signer/types.js\";\nexport { wrapSignatureWith6492 } from \"./signer/utils.js\";\nexport { WalletClientSigner } from \"./signer/wallet-client.js\";\nexport { split, type SplitTransportParams } from \"./transport/split.js\";\nexport type * from \"./types.js\";\nexport type * from \"./utils/index.js\";\nexport {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n ChainSchema,\n HexSchema,\n MultiplierSchema,\n allEqual,\n applyUserOpFeeOption,\n applyUserOpOverride,\n applyUserOpOverrideOrFeeOption,\n asyncPipe,\n bigIntMax,\n bigIntMultiply,\n bypassPaymasterAndData,\n bypassPaymasterAndDataEmptyHex,\n concatPaymasterAndData,\n deepHexlify,\n filterUndefined,\n getDefaultUserOperationFeeOptions,\n isBigNumberish,\n isMultiplier,\n isValidRequest,\n parsePaymasterAndData,\n pick,\n resolveProperties,\n takeBytes,\n toRecord,\n} from \"./utils/index.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,sCAAsC,EACtC,sBAAsB,GACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,EAAE,8BAA8B,EAAE,MAAM,0DAA0D,CAAC;AAC1G,OAAO,EAAE,2BAA2B,EAAE,MAAM,uDAAuD,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,M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jC,cAAc,EACd,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,iBAAiB,EACjB,SAAS,EACT,QAAQ,GACT,MAAM,kBAAkB,CAAC","sourcesContent":["export type { Abi } from \"abitype\";\nexport type { Address, HttpTransport } from \"viem\";\n\nexport { EntryPointAbi_v6 } from \"./abis/EntryPointAbi_v6.js\";\nexport { EntryPointAbi_v7 } from \"./abis/EntryPointAbi_v7.js\";\nexport { SimpleAccountAbi_v6 } from \"./abis/SimpleAccountAbi_v6.js\";\nexport { SimpleAccountAbi_v7 } from \"./abis/SimpleAccountAbi_v7.js\";\nexport { SimpleAccountFactoryAbi } from \"./abis/SimpleAccountFactoryAbi.js\";\nexport type * from \"./account/smartContractAccount.js\";\nexport {\n getAccountAddress,\n isSmartAccountWithSigner,\n parseFactoryAddressFromAccountInitCode,\n toSmartContractAccount,\n} from \"./account/smartContractAccount.js\";\nexport { buildUserOperation } from \"./actions/smartAccount/buildUserOperation.js\";\nexport { buildUserOperationFromTx } from \"./actions/smartAccount/buildUserOperationFromTx.js\";\nexport { buildUserOperationFromTxs } from \"./actions/smartAccount/buildUserOperationFromTxs.js\";\nexport { checkGasSponsorshipEligibility } from \"./actions/smartAccount/checkGasSponsorshipEligibility.js\";\nexport { dropAndReplaceUserOperation } from \"./actions/smartAccount/dropAndReplaceUserOperation.js\";\nexport { sendTransaction } from \"./actions/smartAccount/sendTransaction.js\";\nexport { sendTransactions } from \"./actions/smartAccount/sendTransactions.js\";\nexport { sendUserOperation } from \"./actions/smartAccount/sendUserOperation.js\";\nexport type * from \"./actions/smartAccount/types.js\";\nexport { waitForUserOperationTransaction } from \"./actions/smartAccount/waitForUserOperationTransacation.js\";\nexport type * from \"./client/bundlerClient.js\";\nexport {\n createBundlerClient,\n createBundlerClientFromExisting,\n} from \"./client/bundlerClient.js\";\nexport type * from \"./client/decorators/bundlerClient.js\";\nexport { bundlerActions } from \"./client/decorators/bundlerClient.js\";\nexport type * from \"./client/decorators/smartAccountClient.js\";\nexport { smartAccountClientActions } from \"./client/decorators/smartAccountClient.js\";\nexport { isSmartAccountClient } from \"./client/isSmartAccountClient.js\";\nexport {\n ConnectionConfigSchema,\n SmartAccountClientOptsSchema,\n} from \"./client/schema.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport {\n createSmartAccountClient,\n createSmartAccountClientFromExisting,\n} from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport {\n convertChainIdToCoinType,\n convertCoinTypeToChain,\n convertCoinTypeToChainId,\n} from \"./ens/utils.js\";\nexport {\n defaultEntryPointVersion,\n entryPointRegistry,\n getEntryPoint,\n isEntryPointVersion,\n} from \"./entrypoint/index.js\";\nexport type * from \"./entrypoint/types.js\";\nexport {\n AccountNotFoundError,\n AccountRequiresOwnerError,\n BatchExecutionNotSupportedError,\n DefaultFactoryNotDefinedError,\n FailedToGetStorageSlotError,\n GetCounterFactualAddressError,\n IncorrectAccountType,\n SignTransactionNotSupportedError,\n SmartAccountWithSignerRequiredError,\n UpgradeToAndCallNotSupportedError,\n UpgradesNotSupportedError,\n} from \"./errors/account.js\";\nexport { BaseError } from \"./errors/base.js\";\nexport {\n ChainNotFoundError,\n IncompatibleClientError,\n InvalidRpcUrlError,\n InvalidEntityIdError,\n InvalidNonceKeyError,\n EntityIdOverrideError,\n InvalidModularAccountV2Mode,\n} from \"./errors/client.js\";\nexport {\n EntryPointNotFoundError,\n InvalidEntryPointError,\n} from \"./errors/entrypoint.js\";\nexport { InvalidSignerTypeError } from \"./errors/signer.js\";\nexport {\n FailedToFindTransactionError,\n TransactionMissingToParamError,\n} from \"./errors/transaction.js\";\nexport {\n InvalidUserOperationError,\n WaitForUserOperationError,\n} from \"./errors/useroperation.js\";\nexport * from \"./client/addBreadcrumb.js\";\nexport { LogLevel, Logger } from \"./logger.js\";\nexport { middlewareActions } from \"./middleware/actions.js\";\nexport { default7702UserOpSigner } from \"./middleware/defaults/7702signer.js\";\nexport { default7702GasEstimator } from \"./middleware/defaults/7702gasEstimator.js\";\nexport { defaultFeeEstimator } from \"./middleware/defaults/feeEstimator.js\";\nexport { defaultGasEstimator } from \"./middleware/defaults/gasEstimator.js\";\nexport { defaultPaymasterAndData } from \"./middleware/defaults/paymasterAndData.js\";\nexport { defaultUserOpSigner } from \"./middleware/defaults/userOpSigner.js\";\nexport type * from \"./middleware/erc7677middleware.js\";\nexport { erc7677Middleware } from \"./middleware/erc7677middleware.js\";\nexport { noopMiddleware } from \"./middleware/noopMiddleware.js\";\nexport type * from \"./middleware/types.js\";\nexport { LocalAccountSigner } from \"./signer/local-account.js\";\nexport { SignerSchema, isSigner } from \"./signer/schema.js\";\nexport type {\n SmartAccountAuthenticator,\n SmartAccountSigner,\n} from \"./signer/types.js\";\nexport { wrapSignatureWith6492 } from \"./signer/utils.js\";\nexport { WalletClientSigner } from \"./signer/wallet-client.js\";\nexport { split, type SplitTransportParams } from \"./transport/split.js\";\nexport type * from \"./types.js\";\nexport type * from \"./utils/index.js\";\nexport { TraceHeader } from \"./utils/traceHeader.js\";\nexport {\n BigNumberishRangeSchema,\n BigNumberishSchema,\n ChainSchema,\n HexSchema,\n MultiplierSchema,\n allEqual,\n applyUserOpFeeOption,\n applyUserOpOverride,\n applyUserOpOverrideOrFeeOption,\n asyncPipe,\n bigIntMax,\n bigIntMultiply,\n bypassPaymasterAndData,\n bypassPaymasterAndDataEmptyHex,\n concatPaymasterAndData,\n deepHexlify,\n filterUndefined,\n getDefaultUserOperationFeeOptions,\n isBigNumberish,\n isMultiplier,\n isValidRequest,\n parsePaymasterAndData,\n pick,\n resolveProperties,\n takeBytes,\n toRecord,\n} from \"./utils/index.js\";\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Some tools that are useful when dealing with the values
|
|
3
|
+
* of the trace header. Follows the W3C trace context standard.
|
|
4
|
+
*
|
|
5
|
+
* @see https://www.w3.org/TR/trace-context/
|
|
6
|
+
*/
|
|
7
|
+
export declare class TraceHeader {
|
|
8
|
+
readonly traceId: string;
|
|
9
|
+
readonly parentId: string;
|
|
10
|
+
readonly traceFlags: string;
|
|
11
|
+
readonly traceState: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Initializes a new instance with the provided trace identifiers and state information.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} traceId The unique identifier for the trace
|
|
16
|
+
* @param {string} parentId The identifier of the parent trace
|
|
17
|
+
* @param {string} traceFlags Flags containing trace-related options
|
|
18
|
+
* @param {TraceHeader["traceState"]} traceState The trace state information for additional trace context
|
|
19
|
+
*/
|
|
20
|
+
constructor(traceId: string, parentId: string, traceFlags: string, traceState: TraceHeader["traceState"]);
|
|
21
|
+
/**
|
|
22
|
+
* Creating a default trace id that is a random setup for both trace id and parent id
|
|
23
|
+
*
|
|
24
|
+
* @example ```ts
|
|
25
|
+
* const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @returns {TraceHeader} A default trace header
|
|
29
|
+
*/
|
|
30
|
+
static default(): TraceHeader;
|
|
31
|
+
/**
|
|
32
|
+
* Should be able to consume a trace header from the headers of an http request
|
|
33
|
+
*
|
|
34
|
+
* @example ```ts
|
|
35
|
+
* const traceHeader = TraceHeader.fromTraceHeader(headers);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @param {Record<string,string>} headers The headers from the http request
|
|
39
|
+
* @returns {TraceHeader | undefined} The trace header object, or nothing if not found
|
|
40
|
+
*/
|
|
41
|
+
static fromTraceHeader(headers: Record<string, string>): TraceHeader | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Should be able to convert the trace header to the format that is used in the headers of an http request
|
|
44
|
+
*
|
|
45
|
+
* @example ```ts
|
|
46
|
+
* const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default();
|
|
47
|
+
* const headers = traceHeader.toTraceHeader();
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @returns {{stracheader: string, tracestate: string}} The trace header in the format of a record, used in our http client
|
|
51
|
+
*/
|
|
52
|
+
toTraceHeader(): {
|
|
53
|
+
readonly traceheader: `00-${string}-${string}-${string}`;
|
|
54
|
+
readonly tracestate: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Should be able to create a new trace header with a new event in the trace state,
|
|
58
|
+
* as the key of the eventName as breadcrumbs appending onto previous breadcrumbs with the - infix if exists. And the
|
|
59
|
+
* trace parent gets updated as according to the docs
|
|
60
|
+
*
|
|
61
|
+
* @example ```ts
|
|
62
|
+
* const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default();
|
|
63
|
+
* const newTraceHeader = traceHeader.withEvent("newEvent");
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param {string} eventName The key of the new event
|
|
67
|
+
* @returns {TraceHeader} The new trace header
|
|
68
|
+
*/
|
|
69
|
+
withEvent(eventName: string): TraceHeader;
|
|
70
|
+
}
|