@aa-sdk/core 4.0.0-alpha.0 → 4.0.0-alpha.10
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/cjs/account/smartContractAccount.d.ts +9 -3
- package/dist/cjs/account/smartContractAccount.js +13 -7
- package/dist/cjs/account/smartContractAccount.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/cjs/client/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/bundlerClient.js.map +1 -1
- package/dist/cjs/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/isSmartAccountClient.js.map +1 -1
- package/dist/cjs/client/smartAccountClient.js.map +1 -1
- package/dist/cjs/client/types.d.ts +2 -7
- package/dist/cjs/client/types.js.map +1 -1
- package/dist/cjs/ens/utils.d.ts +1 -1
- package/dist/cjs/ens/utils.js +3 -3
- package/dist/cjs/ens/utils.js.map +1 -1
- package/dist/cjs/entrypoint/index.js.map +1 -1
- package/dist/cjs/errors/account.js.map +1 -1
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/client.js.map +1 -1
- package/dist/cjs/errors/entrypoint.js.map +1 -1
- package/dist/cjs/errors/signer.js.map +1 -1
- package/dist/cjs/errors/transaction.js.map +1 -1
- package/dist/cjs/errors/useroperation.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -7
- package/dist/cjs/index.js +38 -66
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger.js.map +1 -1
- package/dist/cjs/middleware/actions.js +2 -18
- package/dist/cjs/middleware/actions.js.map +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/cjs/middleware/defaults/feeEstimator.js +17 -15
- package/dist/cjs/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/cjs/middleware/defaults/gasEstimator.js +4 -2
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/cjs/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/cjs/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +40 -0
- package/dist/cjs/middleware/erc7677middleware.js +77 -0
- package/dist/cjs/middleware/erc7677middleware.js.map +1 -0
- package/dist/cjs/middleware/noopMiddleware.d.ts +2 -1
- package/dist/cjs/middleware/noopMiddleware.js.map +1 -1
- package/dist/cjs/middleware/types.d.ts +3 -2
- package/dist/cjs/middleware/types.js.map +1 -1
- package/dist/cjs/signer/local-account.d.ts +44 -44
- package/dist/cjs/signer/local-account.js.map +1 -1
- package/dist/cjs/signer/schema.js.map +1 -1
- package/dist/cjs/signer/utils.d.ts +1 -9
- package/dist/cjs/signer/utils.js +1 -16
- package/dist/cjs/signer/utils.js.map +1 -1
- package/dist/cjs/signer/wallet-client.d.ts +44 -44
- package/dist/cjs/signer/wallet-client.js.map +1 -1
- package/dist/cjs/transport/split.js.map +1 -1
- package/dist/cjs/utils/bigint.js.map +1 -1
- package/dist/cjs/utils/bytes.js.map +1 -1
- package/dist/cjs/utils/defaults.d.ts +2 -4
- package/dist/cjs/utils/defaults.js +5 -45
- package/dist/cjs/utils/defaults.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -4
- package/dist/cjs/utils/index.js +1 -33
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/types.js.map +1 -1
- package/dist/cjs/utils/userop.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +9 -3
- package/dist/esm/account/smartContractAccount.js +8 -2
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +2 -7
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.d.ts +1 -1
- package/dist/esm/ens/utils.js +1 -1
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +4 -7
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.js +3 -18
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.d.ts +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.js +17 -15
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.js +4 -2
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +40 -0
- package/dist/esm/middleware/erc7677middleware.js +73 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -0
- package/dist/esm/middleware/noopMiddleware.d.ts +2 -1
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.d.ts +3 -2
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +44 -44
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.js.map +1 -1
- package/dist/esm/signer/utils.d.ts +1 -9
- package/dist/esm/signer/utils.js +0 -14
- package/dist/esm/signer/utils.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +44 -44
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/defaults.d.ts +2 -4
- package/dist/esm/utils/defaults.js +1 -40
- package/dist/esm/utils/defaults.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -4
- package/dist/esm/utils/index.js +0 -18
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/types.js.map +1 -1
- 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/account/smartContractAccount.d.ts +58 -3
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts +23 -0
- package/dist/types/actions/smartAccount/buildUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/buildUserOperationFromTx.d.ts +33 -33
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts +43 -59
- package/dist/types/actions/smartAccount/buildUserOperationFromTxs.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +18 -18
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/estimateUserOperationGas.d.ts +3 -3
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts +3 -4
- package/dist/types/actions/smartAccount/internal/initUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -14
- package/dist/types/actions/smartAccount/internal/runMiddlewareStack.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts +0 -7
- package/dist/types/actions/smartAccount/internal/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransaction.d.ts +24 -0
- package/dist/types/actions/smartAccount/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendTransactions.d.ts +23 -0
- package/dist/types/actions/smartAccount/sendTransactions.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts +17 -3
- package/dist/types/actions/smartAccount/sendUserOperation.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
- package/dist/types/actions/smartAccount/waitForUserOperationTransacation.d.ts.map +1 -1
- package/dist/types/client/bundlerClient.d.ts +17 -2
- package/dist/types/client/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/bundlerClient.d.ts +17 -8
- package/dist/types/client/decorators/bundlerClient.d.ts.map +1 -1
- package/dist/types/client/decorators/smartAccountClient.d.ts +8 -0
- package/dist/types/client/decorators/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/isSmartAccountClient.d.ts +4 -4
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +2 -7
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/ens/utils.d.ts +46 -1
- package/dist/types/ens/utils.d.ts.map +1 -1
- package/dist/types/entrypoint/index.d.ts +14 -0
- package/dist/types/entrypoint/index.d.ts.map +1 -1
- package/dist/types/errors/account.d.ts +87 -4
- package/dist/types/errors/account.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +5 -0
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/client.d.ts +24 -0
- package/dist/types/errors/client.d.ts.map +1 -1
- package/dist/types/errors/entrypoint.d.ts +18 -0
- package/dist/types/errors/entrypoint.d.ts.map +1 -1
- package/dist/types/errors/signer.d.ts +8 -0
- package/dist/types/errors/signer.d.ts.map +1 -1
- package/dist/types/errors/transaction.d.ts +14 -1
- package/dist/types/errors/transaction.d.ts.map +1 -1
- package/dist/types/errors/useroperation.d.ts +5 -5
- package/dist/types/errors/useroperation.d.ts.map +1 -1
- package/dist/types/index.d.ts +4 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logger.d.ts +91 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/middleware/actions.d.ts +3 -3
- package/dist/types/middleware/actions.d.ts.map +1 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts +21 -1
- package/dist/types/middleware/defaults/feeEstimator.d.ts.map +1 -1
- package/dist/types/middleware/defaults/gasEstimator.d.ts +2 -2
- package/dist/types/middleware/defaults/gasEstimator.d.ts.map +1 -1
- package/dist/types/middleware/defaults/paymasterAndData.d.ts +8 -0
- package/dist/types/middleware/defaults/paymasterAndData.d.ts.map +1 -1
- package/dist/types/middleware/defaults/userOpSigner.d.ts +10 -0
- package/dist/types/middleware/defaults/userOpSigner.d.ts.map +1 -1
- package/dist/types/middleware/erc7677middleware.d.ts +62 -0
- package/dist/types/middleware/erc7677middleware.d.ts.map +1 -0
- package/dist/types/middleware/noopMiddleware.d.ts +4 -4
- package/dist/types/middleware/noopMiddleware.d.ts.map +1 -1
- package/dist/types/middleware/types.d.ts +3 -2
- package/dist/types/middleware/types.d.ts.map +1 -1
- package/dist/types/signer/local-account.d.ts +140 -45
- package/dist/types/signer/local-account.d.ts.map +1 -1
- package/dist/types/signer/schema.d.ts +14 -0
- package/dist/types/signer/schema.d.ts.map +1 -1
- package/dist/types/signer/utils.d.ts +21 -9
- package/dist/types/signer/utils.d.ts.map +1 -1
- package/dist/types/signer/wallet-client.d.ts +136 -44
- package/dist/types/signer/wallet-client.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +2 -2
- package/dist/types/utils/bigint.d.ts +14 -14
- package/dist/types/utils/bigint.d.ts.map +1 -1
- package/dist/types/utils/bytes.d.ts +5 -5
- package/dist/types/utils/defaults.d.ts +2 -12
- package/dist/types/utils/defaults.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +66 -23
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/types.d.ts +2 -2
- package/dist/types/utils/userop.d.ts +33 -33
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/account/smartContractAccount.ts +134 -23
- package/src/actions/smartAccount/buildUserOperation.ts +23 -0
- package/src/actions/smartAccount/buildUserOperationFromTx.ts +35 -35
- package/src/actions/smartAccount/buildUserOperationFromTxs.ts +44 -60
- package/src/actions/smartAccount/checkGasSponsorshipEligibility.ts +19 -19
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +22 -0
- package/src/actions/smartAccount/estimateUserOperationGas.ts +3 -3
- package/src/actions/smartAccount/internal/initUserOperation.ts +3 -4
- package/src/actions/smartAccount/internal/runMiddlewareStack.ts +0 -22
- package/src/actions/smartAccount/internal/sendUserOperation.ts +0 -7
- package/src/actions/smartAccount/sendTransaction.ts +24 -0
- package/src/actions/smartAccount/sendTransactions.ts +23 -0
- package/src/actions/smartAccount/sendUserOperation.ts +17 -3
- package/src/actions/smartAccount/waitForUserOperationTransacation.ts +24 -0
- package/src/client/bundlerClient.ts +34 -2
- package/src/client/decorators/bundlerClient.ts +17 -8
- package/src/client/decorators/smartAccountClient.ts +8 -0
- package/src/client/isSmartAccountClient.ts +4 -4
- package/src/client/smartAccountClient.ts +41 -0
- package/src/client/types.ts +2 -15
- package/src/ens/utils.ts +46 -2
- package/src/entrypoint/index.ts +30 -62
- package/src/errors/account.ts +98 -4
- package/src/errors/base.ts +5 -2
- package/src/errors/client.ts +27 -0
- package/src/errors/entrypoint.ts +18 -0
- package/src/errors/signer.ts +9 -0
- package/src/errors/transaction.ts +16 -1
- package/src/errors/useroperation.ts +5 -6
- package/src/index.ts +3 -36
- package/src/logger.ts +91 -0
- package/src/middleware/actions.ts +6 -27
- package/src/middleware/defaults/feeEstimator.ts +24 -4
- package/src/middleware/defaults/gasEstimator.ts +9 -5
- package/src/middleware/defaults/paymasterAndData.ts +8 -0
- package/src/middleware/defaults/userOpSigner.ts +10 -0
- package/src/middleware/erc7677middleware.ts +201 -0
- package/src/middleware/noopMiddleware.ts +6 -4
- package/src/middleware/types.ts +16 -7
- package/src/signer/local-account.ts +97 -2
- package/src/signer/schema.ts +14 -0
- package/src/signer/utils.ts +20 -32
- package/src/signer/wallet-client.ts +92 -0
- package/src/transport/split.ts +2 -2
- package/src/utils/bigint.ts +15 -15
- package/src/utils/bytes.ts +5 -5
- package/src/utils/defaults.ts +3 -76
- package/src/utils/index.ts +66 -48
- package/src/utils/types.ts +2 -2
- package/src/utils/userop.ts +33 -33
- package/src/version.ts +1 -1
- package/dist/cjs/account/base.d.ts +0 -49
- package/dist/cjs/account/base.js +0 -257
- package/dist/cjs/account/base.js.map +0 -1
- package/dist/cjs/account/schema.d.ts +0 -100
- package/dist/cjs/account/schema.js +0 -43
- package/dist/cjs/account/schema.js.map +0 -1
- package/dist/cjs/account/simple.d.ts +0 -14
- package/dist/cjs/account/simple.js +0 -119
- package/dist/cjs/account/simple.js.map +0 -1
- package/dist/cjs/account/types.d.ts +0 -30
- package/dist/cjs/account/types.js +0 -3
- package/dist/cjs/account/types.js.map +0 -1
- package/dist/cjs/chains/index.d.ts +0 -20
- package/dist/cjs/chains/index.js +0 -169
- package/dist/cjs/chains/index.js.map +0 -1
- package/dist/esm/account/base.d.ts +0 -49
- package/dist/esm/account/base.js +0 -253
- package/dist/esm/account/base.js.map +0 -1
- package/dist/esm/account/schema.d.ts +0 -100
- package/dist/esm/account/schema.js +0 -35
- package/dist/esm/account/schema.js.map +0 -1
- package/dist/esm/account/simple.d.ts +0 -14
- package/dist/esm/account/simple.js +0 -115
- package/dist/esm/account/simple.js.map +0 -1
- package/dist/esm/account/types.d.ts +0 -30
- package/dist/esm/account/types.js +0 -2
- package/dist/esm/account/types.js.map +0 -1
- package/dist/esm/chains/index.d.ts +0 -20
- package/dist/esm/chains/index.js +0 -166
- package/dist/esm/chains/index.js.map +0 -1
- package/dist/types/account/base.d.ts +0 -128
- package/dist/types/account/base.d.ts.map +0 -1
- package/dist/types/account/schema.d.ts +0 -101
- package/dist/types/account/schema.d.ts.map +0 -1
- package/dist/types/account/simple.d.ts +0 -15
- package/dist/types/account/simple.d.ts.map +0 -1
- package/dist/types/account/types.d.ts +0 -144
- package/dist/types/account/types.d.ts.map +0 -1
- package/dist/types/chains/index.d.ts +0 -21
- package/dist/types/chains/index.d.ts.map +0 -1
- package/src/account/base.ts +0 -415
- package/src/account/schema.ts +0 -51
- package/src/account/simple.ts +0 -215
- package/src/account/types.ts +0 -184
- package/src/chains/index.ts +0 -194
package/src/errors/account.ts
CHANGED
|
@@ -2,17 +2,35 @@ import type { Chain } from "viem";
|
|
|
2
2
|
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
3
3
|
import { BaseError } from "./base.js";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This error is thrown when an account could not be found to execute a specific action. It extends the `BaseError` class.
|
|
7
|
+
*/
|
|
5
8
|
export class AccountNotFoundError extends BaseError {
|
|
6
9
|
override name = "AccountNotFoundError";
|
|
7
10
|
|
|
8
11
|
// TODO: extend this further using docs path as well
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Constructor for initializing an error message indicating that an account could not be found to execute the specified action.
|
|
15
|
+
*/ constructor() {
|
|
10
16
|
super("Could not find an Account to execute with this Action.");
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Represents an error that is thrown when no default factory is defined for a specific account type on a given chain and entry point version.
|
|
22
|
+
* This error suggests providing an override via the `factoryAddress` parameter when creating an account.
|
|
23
|
+
*/
|
|
14
24
|
export class DefaultFactoryNotDefinedError extends BaseError {
|
|
15
25
|
override name = "DefaultFactoryNotDefinedError";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Constructs an error message indicating that no default factory was found for the given account type, chain, and entry point version.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} accountType the type of account
|
|
31
|
+
* @param {Chain} chain the blockchain chain
|
|
32
|
+
* @param {EntryPointVersion} version the entry point version
|
|
33
|
+
*/
|
|
16
34
|
constructor(accountType: string, chain: Chain, version: EntryPointVersion) {
|
|
17
35
|
super(
|
|
18
36
|
[
|
|
@@ -23,65 +41,141 @@ export class DefaultFactoryNotDefinedError extends BaseError {
|
|
|
23
41
|
}
|
|
24
42
|
}
|
|
25
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Custom error class for handling errors when getting a counterfactual address. This extends the `BaseError` class and provides a custom error message and name.
|
|
46
|
+
*/
|
|
26
47
|
export class GetCounterFactualAddressError extends BaseError {
|
|
27
48
|
override name = "GetCounterFactualAddressError";
|
|
28
|
-
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Constructor for initializing an error message indicating the failure of fetching the counter-factual address.
|
|
52
|
+
*/ constructor() {
|
|
29
53
|
super("getCounterFactualAddress failed");
|
|
30
54
|
}
|
|
31
55
|
}
|
|
32
56
|
|
|
57
|
+
/**
|
|
58
|
+
* An error class representing the condition where upgrades are not supported for a specific account type. This error extends the `BaseError` class and provides a custom error message based on the account type.
|
|
59
|
+
*/
|
|
33
60
|
export class UpgradesNotSupportedError extends BaseError {
|
|
34
61
|
override name = "UpgradesNotSupported";
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Error constructor for indicating that upgrades are not supported by the given account type.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} accountType The type of account that does not support upgrades
|
|
67
|
+
*/
|
|
35
68
|
constructor(accountType: string) {
|
|
36
69
|
super(`Upgrades are not supported by ${accountType}`);
|
|
37
70
|
}
|
|
38
71
|
}
|
|
39
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Error thrown when attempting to sign a transaction that is not supported by smart contracts.
|
|
75
|
+
*/
|
|
40
76
|
export class SignTransactionNotSupportedError extends BaseError {
|
|
41
77
|
override name = "SignTransactionNotSupported";
|
|
42
|
-
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Throws an error indicating that signing a transaction is not supported by smart contracts.
|
|
81
|
+
*
|
|
82
|
+
|
|
83
|
+
*/ constructor() {
|
|
43
84
|
super(`SignTransaction is not supported by smart contracts`);
|
|
44
85
|
}
|
|
45
86
|
}
|
|
46
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Custom error class `FailedToGetStorageSlotError` which is used to signal a failure when attempting to retrieve a storage slot. This error includes the slot and slot descriptor in its message and inherits from `BaseError`.
|
|
90
|
+
*/
|
|
47
91
|
export class FailedToGetStorageSlotError extends BaseError {
|
|
48
92
|
override name = "FailedToGetStorageSlotError";
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Custom error message constructor for failing to get a specific storage slot.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} slot The storage slot that failed to be accessed or retrieved
|
|
98
|
+
* @param {string} slotDescriptor A description of the storage slot, for additional context in the error message
|
|
99
|
+
*/
|
|
49
100
|
constructor(slot: string, slotDescriptor: string) {
|
|
50
101
|
super(`Failed to get storage slot ${slot} (${slotDescriptor})`);
|
|
51
102
|
}
|
|
52
103
|
}
|
|
53
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Represents an error indicating that batch execution is not supported for a specific account type.
|
|
107
|
+
*/
|
|
54
108
|
export class BatchExecutionNotSupportedError extends BaseError {
|
|
55
109
|
override name = "BatchExecutionNotSupportedError";
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Constructs an error message indicating that batch execution is not supported by the specified account type.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} accountType the type of account that does not support batch execution
|
|
115
|
+
*/
|
|
56
116
|
constructor(accountType: string) {
|
|
57
117
|
super(`Batch execution is not supported by ${accountType}`);
|
|
58
118
|
}
|
|
59
119
|
}
|
|
60
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Represents an error that occurs when an account requires an owner to execute but none is provided.
|
|
123
|
+
*/
|
|
61
124
|
export class AccountRequiresOwnerError extends BaseError {
|
|
62
125
|
override name = "AccountRequiresOwnerError";
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Constructs an error indicating that an account of the specified type requires an owner to execute.
|
|
129
|
+
*
|
|
130
|
+
* @param {string} accountType The type of account that requires an owner
|
|
131
|
+
*/
|
|
63
132
|
constructor(accountType: string) {
|
|
64
133
|
super(`Account of type ${accountType} requires an owner to execute`);
|
|
65
134
|
}
|
|
66
135
|
}
|
|
67
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Represents an error that occurs when an attempt is made to call `UpgradeToAndCall` on an account type that does not support it. Includes the account type in the error message.
|
|
139
|
+
*/
|
|
68
140
|
export class UpgradeToAndCallNotSupportedError extends BaseError {
|
|
69
141
|
override name = "UpgradeToAndCallNotSupportedError";
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Constructs an error message indicating that `UpgradeToAndCall` is not supported by the specified account type.
|
|
145
|
+
*
|
|
146
|
+
* @param {string} accountType The type of account that does not support `UpgradeToAndCall`
|
|
147
|
+
*/
|
|
70
148
|
constructor(accountType: string) {
|
|
71
149
|
super(`UpgradeToAndCall is not supported by ${accountType}`);
|
|
72
150
|
}
|
|
73
151
|
}
|
|
74
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Represents an error thrown when an account type does not match the expected type.
|
|
155
|
+
*/
|
|
75
156
|
export class IncorrectAccountType extends BaseError {
|
|
76
157
|
override name = "IncorrectAccountTypeError";
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Constructs an error object indicating that the expected account type does not match the actual account type.
|
|
161
|
+
*
|
|
162
|
+
* @param {string} expected the expected account type
|
|
163
|
+
* @param {string} actual the actual account type that was received
|
|
164
|
+
*/
|
|
77
165
|
constructor(expected: string, actual: string) {
|
|
78
166
|
super(`Expected account type ${expected}, got ${actual}`);
|
|
79
167
|
}
|
|
80
168
|
}
|
|
81
169
|
|
|
170
|
+
/**
|
|
171
|
+
* Error class indicating that a smart account operation requires a signer.
|
|
172
|
+
*/
|
|
82
173
|
export class SmartAccountWithSignerRequiredError extends BaseError {
|
|
83
174
|
override name = "SmartAccountWithSignerRequiredError";
|
|
84
|
-
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Initializes a new instance of the error class with a predefined error message indicating that a smart account requires a signer.
|
|
178
|
+
*/ constructor() {
|
|
85
179
|
super("Smart account requires a signer");
|
|
86
180
|
}
|
|
87
181
|
}
|
package/src/errors/base.ts
CHANGED
|
@@ -16,8 +16,11 @@ type BaseErrorParameters = {
|
|
|
16
16
|
}
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* A custom error class that extends from `ViemBaseError`. This class allows for error messages to include links to relevant documentation based on provided `docsPath` and `docsSlug` parameters.
|
|
21
|
+
* This is based on on viem's BaseError type (obviously from the import and extend)
|
|
22
|
+
* we want the errors here to point to our docs if we supply a docsPath though
|
|
23
|
+
*/
|
|
21
24
|
export class BaseError extends ViemBaseError {
|
|
22
25
|
override name = "AASDKError";
|
|
23
26
|
override version = VERSION;
|
package/src/errors/client.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { Client } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents an error thrown when a client is not compatible with the expected client type for a specific method. The error message provides guidance on how to create a compatible client.
|
|
6
|
+
*/
|
|
4
7
|
export class IncompatibleClientError extends BaseError {
|
|
5
8
|
override name = "IncompatibleClientError";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Throws an error when the client type does not match the expected client type.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} expectedClient The expected type of the client.
|
|
14
|
+
* @param {string} method The method that was called.
|
|
15
|
+
* @param {Client} client The client instance.
|
|
16
|
+
*/
|
|
6
17
|
constructor(expectedClient: string, method: string, client: Client) {
|
|
7
18
|
super(
|
|
8
19
|
[
|
|
@@ -13,15 +24,31 @@ export class IncompatibleClientError extends BaseError {
|
|
|
13
24
|
}
|
|
14
25
|
}
|
|
15
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Represents an error that occurs when an invalid RPC URL is provided. This class extends the `BaseError` class and includes the invalid URL in the error message.
|
|
29
|
+
*/
|
|
16
30
|
export class InvalidRpcUrlError extends BaseError {
|
|
17
31
|
override name = "InvalidRpcUrlError";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Creates an instance of an error with a message indicating an invalid RPC URL.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} [rpcUrl] The invalid RPC URL that caused the error
|
|
37
|
+
*/
|
|
18
38
|
constructor(rpcUrl?: string) {
|
|
19
39
|
super(`Invalid RPC URL ${rpcUrl}`);
|
|
20
40
|
}
|
|
21
41
|
}
|
|
22
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Error class representing a "Chain Not Found" error, typically thrown when no chain is supplied to the client.
|
|
45
|
+
*/
|
|
23
46
|
export class ChainNotFoundError extends BaseError {
|
|
24
47
|
override name = "ChainNotFoundError";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Initializes a new instance of the error message with a default message indicating that no chain was supplied to the client.
|
|
51
|
+
*/
|
|
25
52
|
constructor() {
|
|
26
53
|
super("No chain supplied to the client");
|
|
27
54
|
}
|
package/src/errors/entrypoint.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { Chain } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Represents an error thrown when an entry point is not found for a specific chain and entry point version. This error indicates that a default entry point does not exist for the given chain and version, and suggests providing an override.
|
|
6
|
+
*/
|
|
4
7
|
export class EntryPointNotFoundError extends BaseError {
|
|
5
8
|
override name = "EntryPointNotFoundError";
|
|
6
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Constructs an error message indicating that no default entry point exists for the given chain and entry point version.
|
|
12
|
+
*
|
|
13
|
+
* @param {Chain} chain The blockchain network for which the entry point is being queried
|
|
14
|
+
* @param {any} entryPointVersion The version of the entry point for which no default exists
|
|
15
|
+
*/
|
|
7
16
|
constructor(chain: Chain, entryPointVersion: any) {
|
|
8
17
|
super(
|
|
9
18
|
[
|
|
@@ -14,9 +23,18 @@ export class EntryPointNotFoundError extends BaseError {
|
|
|
14
23
|
}
|
|
15
24
|
}
|
|
16
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Represents an error thrown when an invalid entry point version is encountered for a specific chain. This error extends the `BaseError` class.
|
|
28
|
+
*/
|
|
17
29
|
export class InvalidEntryPointError extends BaseError {
|
|
18
30
|
override name = "InvalidEntryPointError";
|
|
19
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Constructs an error indicating an invalid entry point version for a specific chain.
|
|
34
|
+
*
|
|
35
|
+
* @param {Chain} chain The chain object containing information about the blockchain
|
|
36
|
+
* @param {any} entryPointVersion The entry point version that is invalid
|
|
37
|
+
*/
|
|
20
38
|
constructor(chain: Chain, entryPointVersion: any) {
|
|
21
39
|
super(
|
|
22
40
|
`Invalid entry point: unexpected version ${entryPointVersion} for ${chain.name}.`
|
package/src/errors/signer.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { BaseError } from "./base.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Represents an error thrown when an invalid signer type is provided to the SmartAccountSigner.
|
|
5
|
+
*/
|
|
3
6
|
export class InvalidSignerTypeError extends BaseError {
|
|
4
7
|
override name = "InvalidSignerTypeError";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Constructs an error message when an invalid signer type is passed to SmartAccountSigner.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} [signerType] An optional parameter specifying the signer type. If not provided, a default error message will be used.
|
|
13
|
+
*/
|
|
5
14
|
constructor(signerType?: string) {
|
|
6
15
|
super(
|
|
7
16
|
[
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import type { Hex } from "viem";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a transaction is missing the `to` address parameter. This class extends the `BaseError` class.
|
|
6
|
+
*/
|
|
4
7
|
export class TransactionMissingToParamError extends BaseError {
|
|
5
8
|
override name = "TransactionMissingToParamError";
|
|
6
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Throws an error indicating that a transaction is missing the `to` address in the request.
|
|
12
|
+
*/ constructor() {
|
|
7
13
|
super("Transaction is missing `to` address set on request");
|
|
8
14
|
}
|
|
9
15
|
}
|
|
10
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Represents an error that occurs when a transaction cannot be found for a given user operation. This error extends from `BaseError`. The `hash` of the transaction is provided to indicate which transaction could not be found.
|
|
19
|
+
*/
|
|
11
20
|
export class FailedToFindTransactionError extends BaseError {
|
|
12
21
|
override name = "FailedToFindTransactionError";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a new error message indicating a failure to find the transaction for the specified user operation hash.
|
|
25
|
+
*
|
|
26
|
+
* @param {Hex} hash The hexadecimal value representing the user operation hash.
|
|
27
|
+
*/
|
|
13
28
|
constructor(hash: Hex) {
|
|
14
29
|
super(`Failed to find transaction for user operation ${hash}`);
|
|
15
30
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { UserOperationRequest, UserOperationStruct } from "../types.js";
|
|
2
2
|
import { BaseError } from "./base.js";
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4
|
-
import type { dropAndReplaceUserOperation } from "../actions/smartAccount/dropAndReplaceUserOperation.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
* Thrown when a
|
|
6
|
+
* Thrown when a UserOperationStruct is not a valid request
|
|
8
7
|
*
|
|
9
8
|
* extends viem BaseError
|
|
10
9
|
*/
|
|
@@ -18,7 +17,7 @@ export class InvalidUserOperationError extends BaseError {
|
|
|
18
17
|
*
|
|
19
18
|
* InvalidUserOperationError constructor
|
|
20
19
|
*
|
|
21
|
-
* @param uo the invalid user operation struct
|
|
20
|
+
* @param {UserOperationStruct} uo the invalid user operation struct
|
|
22
21
|
*/
|
|
23
22
|
constructor(uo: UserOperationStruct) {
|
|
24
23
|
super(
|
|
@@ -41,12 +40,12 @@ export class InvalidUserOperationError extends BaseError {
|
|
|
41
40
|
* Error thrown when waiting for user operation request to be mined.
|
|
42
41
|
*
|
|
43
42
|
* Includes the internal error as well as the request that failed. This request
|
|
44
|
-
* can then be used with
|
|
43
|
+
* can then be used with dropAndReplaceUserOperation to retry the operation.
|
|
45
44
|
*/
|
|
46
45
|
export class WaitForUserOperationError extends BaseError {
|
|
47
46
|
/**
|
|
48
|
-
* @param request the user operation request that failed
|
|
49
|
-
* @param error the underlying error that caused the failure
|
|
47
|
+
* @param {UserOperationRequest} request the user operation request that failed
|
|
48
|
+
* @param {Error} error the underlying error that caused the failure
|
|
50
49
|
*/
|
|
51
50
|
constructor(public request: UserOperationRequest, error: Error) {
|
|
52
51
|
super(`Failed to find User Operation: ${error.message}`);
|
package/src/index.ts
CHANGED
|
@@ -7,9 +7,6 @@ export { EntryPointAbi_v7 } from "./abis/EntryPointAbi_v7.js";
|
|
|
7
7
|
export { SimpleAccountAbi_v6 } from "./abis/SimpleAccountAbi_v6.js";
|
|
8
8
|
export { SimpleAccountAbi_v7 } from "./abis/SimpleAccountAbi_v7.js";
|
|
9
9
|
export { SimpleAccountFactoryAbi } from "./abis/SimpleAccountFactoryAbi.js";
|
|
10
|
-
export { BaseSmartContractAccount } from "./account/base.js";
|
|
11
|
-
export { createSimpleSmartAccount } from "./account/simple.js";
|
|
12
|
-
export type { SimpleSmartAccount } from "./account/simple.js";
|
|
13
10
|
export type * from "./account/smartContractAccount.js";
|
|
14
11
|
export {
|
|
15
12
|
getAccountAddress,
|
|
@@ -17,10 +14,6 @@ export {
|
|
|
17
14
|
parseFactoryAddressFromAccountInitCode,
|
|
18
15
|
toSmartContractAccount,
|
|
19
16
|
} from "./account/smartContractAccount.js";
|
|
20
|
-
export type {
|
|
21
|
-
BaseSmartAccountParams,
|
|
22
|
-
SignTypedDataParams,
|
|
23
|
-
} from "./account/types.js";
|
|
24
17
|
export { buildUserOperation } from "./actions/smartAccount/buildUserOperation.js";
|
|
25
18
|
export { buildUserOperationFromTx } from "./actions/smartAccount/buildUserOperationFromTx.js";
|
|
26
19
|
export { buildUserOperationFromTxs } from "./actions/smartAccount/buildUserOperationFromTxs.js";
|
|
@@ -31,27 +24,6 @@ export { sendTransactions } from "./actions/smartAccount/sendTransactions.js";
|
|
|
31
24
|
export { sendUserOperation } from "./actions/smartAccount/sendUserOperation.js";
|
|
32
25
|
export type * from "./actions/smartAccount/types.js";
|
|
33
26
|
export { waitForUserOperationTransaction } from "./actions/smartAccount/waitForUserOperationTransacation.js";
|
|
34
|
-
export {
|
|
35
|
-
arbitrum,
|
|
36
|
-
arbitrumGoerli,
|
|
37
|
-
arbitrumSepolia,
|
|
38
|
-
base,
|
|
39
|
-
baseGoerli,
|
|
40
|
-
baseSepolia,
|
|
41
|
-
fraxtal,
|
|
42
|
-
fraxtalSepolia,
|
|
43
|
-
goerli,
|
|
44
|
-
mainnet,
|
|
45
|
-
optimism,
|
|
46
|
-
optimismGoerli,
|
|
47
|
-
optimismSepolia,
|
|
48
|
-
polygon,
|
|
49
|
-
polygonAmoy,
|
|
50
|
-
polygonMumbai,
|
|
51
|
-
sepolia,
|
|
52
|
-
zora,
|
|
53
|
-
zoraSepolia,
|
|
54
|
-
} from "./chains/index.js";
|
|
55
27
|
export type * from "./client/bundlerClient.js";
|
|
56
28
|
export {
|
|
57
29
|
createBundlerClient,
|
|
@@ -122,6 +94,8 @@ export { defaultFeeEstimator } from "./middleware/defaults/feeEstimator.js";
|
|
|
122
94
|
export { defaultGasEstimator } from "./middleware/defaults/gasEstimator.js";
|
|
123
95
|
export { defaultPaymasterAndData } from "./middleware/defaults/paymasterAndData.js";
|
|
124
96
|
export { defaultUserOpSigner } from "./middleware/defaults/userOpSigner.js";
|
|
97
|
+
export type * from "./middleware/erc7677middleware.js";
|
|
98
|
+
export { erc7677Middleware } from "./middleware/erc7677middleware.js";
|
|
125
99
|
export { noopMiddleware } from "./middleware/noopMiddleware.js";
|
|
126
100
|
export type * from "./middleware/types.js";
|
|
127
101
|
export { LocalAccountSigner } from "./signer/local-account.js";
|
|
@@ -130,16 +104,12 @@ export type {
|
|
|
130
104
|
SmartAccountAuthenticator,
|
|
131
105
|
SmartAccountSigner,
|
|
132
106
|
} from "./signer/types.js";
|
|
133
|
-
export {
|
|
134
|
-
verifyEIP6492Signature,
|
|
135
|
-
wrapSignatureWith6492,
|
|
136
|
-
} from "./signer/utils.js";
|
|
107
|
+
export { wrapSignatureWith6492 } from "./signer/utils.js";
|
|
137
108
|
export { WalletClientSigner } from "./signer/wallet-client.js";
|
|
138
109
|
export { split, type SplitTransportParams } from "./transport/split.js";
|
|
139
110
|
export type * from "./types.js";
|
|
140
111
|
export type * from "./utils/index.js";
|
|
141
112
|
export {
|
|
142
|
-
AlchemyChainMap,
|
|
143
113
|
BigNumberishRangeSchema,
|
|
144
114
|
BigNumberishSchema,
|
|
145
115
|
ChainSchema,
|
|
@@ -156,10 +126,7 @@ export {
|
|
|
156
126
|
bypassPaymasterAndDataEmptyHex,
|
|
157
127
|
concatPaymasterAndData,
|
|
158
128
|
deepHexlify,
|
|
159
|
-
defineReadOnly,
|
|
160
129
|
filterUndefined,
|
|
161
|
-
getChain,
|
|
162
|
-
getDefaultSimpleAccountFactoryAddress,
|
|
163
130
|
getDefaultUserOperationFeeOptions,
|
|
164
131
|
isBigNumberish,
|
|
165
132
|
isMultiplier,
|
package/src/logger.ts
CHANGED
|
@@ -7,42 +7,133 @@ export enum LogLevel {
|
|
|
7
7
|
NONE = 0,
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Logger class provides static methods for logging at different levels such as error, warn, debug, info, and verbose. This class allows setting log levels and log filters to control the logging behavior.
|
|
12
|
+
*/
|
|
10
13
|
export class Logger {
|
|
11
14
|
static logLevel: LogLevel = LogLevel.INFO;
|
|
12
15
|
static logFilter?: string;
|
|
13
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Sets the log level for logging purposes.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { Logger, LogLevel } from "@aa-sdk/core";
|
|
23
|
+
* Logger.setLogLevel(LogLevel.DEBUG);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param {LogLevel} logLevel The desired log level
|
|
27
|
+
*/
|
|
14
28
|
static setLogLevel(logLevel: LogLevel) {
|
|
15
29
|
this.logLevel = logLevel;
|
|
16
30
|
}
|
|
17
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Sets the log filter pattern.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { Logger } from "@aa-sdk/core";
|
|
38
|
+
*
|
|
39
|
+
* Logger.setLogFilter("error");
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @param {string} pattern The pattern to set as the log filter
|
|
43
|
+
*/
|
|
18
44
|
static setLogFilter(pattern: string) {
|
|
19
45
|
this.logFilter = pattern;
|
|
20
46
|
}
|
|
21
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Logs an error message to the console if the logging condition is met.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { Logger } from "@aa-sdk/core";
|
|
54
|
+
*
|
|
55
|
+
* Logger.error("An error occurred while processing the request");
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param {string} msg The primary error message to be logged
|
|
59
|
+
* @param {...any[]} args Additional arguments to be logged along with the error message
|
|
60
|
+
*/
|
|
22
61
|
static error(msg: string, ...args: any[]) {
|
|
23
62
|
if (!this.shouldLog(msg, LogLevel.ERROR)) return;
|
|
24
63
|
|
|
25
64
|
console.error(msg, ...args);
|
|
26
65
|
}
|
|
27
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Logs a warning message if the logging conditions are met.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { Logger } from "@aa-sdk/core";
|
|
73
|
+
*
|
|
74
|
+
* Logger.warn("Careful...");
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @param {string} msg The message to log as a warning
|
|
78
|
+
* @param {...any[]} args Additional parameters to log along with the message
|
|
79
|
+
*/
|
|
28
80
|
static warn(msg: string, ...args: any[]) {
|
|
29
81
|
if (!this.shouldLog(msg, LogLevel.WARN)) return;
|
|
30
82
|
|
|
31
83
|
console.warn(msg, ...args);
|
|
32
84
|
}
|
|
33
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Logs a debug message to the console if the log level allows it.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { Logger } from "@aa-sdk/core";
|
|
92
|
+
*
|
|
93
|
+
* Logger.debug("Something is happening");
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param {string} msg The message to log
|
|
97
|
+
* @param {...any[]} args Additional arguments to pass to the console.debug method
|
|
98
|
+
*/
|
|
34
99
|
static debug(msg: string, ...args: any[]) {
|
|
35
100
|
if (!this.shouldLog(msg, LogLevel.DEBUG)) return;
|
|
36
101
|
|
|
37
102
|
console.debug(msg, ...args);
|
|
38
103
|
}
|
|
39
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Logs an informational message to the console if the logging level is set to INFO.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { Logger } from "@aa-sdk/core";
|
|
111
|
+
*
|
|
112
|
+
* Logger.info("Something is happening");
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @param {string} msg the message to log
|
|
116
|
+
* @param {...any[]} args additional arguments to log alongside the message
|
|
117
|
+
*/
|
|
40
118
|
static info(msg: string, ...args: any[]) {
|
|
41
119
|
if (!this.shouldLog(msg, LogLevel.INFO)) return;
|
|
42
120
|
|
|
43
121
|
console.info(msg, ...args);
|
|
44
122
|
}
|
|
45
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Logs a message with additional arguments if the logging level permits it.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* import { Logger } from "@aa-sdk/core";
|
|
130
|
+
*
|
|
131
|
+
* Logger.verbose("Something is happening");
|
|
132
|
+
* ```
|
|
133
|
+
*
|
|
134
|
+
* @param {string} msg The message to log
|
|
135
|
+
* @param {...any[]} args Additional arguments to be logged
|
|
136
|
+
*/
|
|
46
137
|
static verbose(msg: string, ...args: any[]) {
|
|
47
138
|
if (!this.shouldLog(msg, LogLevel.VERBOSE)) return;
|
|
48
139
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
isHex,
|
|
3
2
|
type Chain,
|
|
4
3
|
type Client,
|
|
5
4
|
type PublicActions,
|
|
@@ -12,10 +11,6 @@ import type {
|
|
|
12
11
|
BundlerRpcSchema,
|
|
13
12
|
} from "../client/decorators/bundlerClient.js";
|
|
14
13
|
import type { ClientMiddlewareConfig } from "../client/types.js";
|
|
15
|
-
import {
|
|
16
|
-
concatPaymasterAndData,
|
|
17
|
-
parsePaymasterAndData,
|
|
18
|
-
} from "../utils/userop.js";
|
|
19
14
|
import { defaultFeeEstimator } from "./defaults/feeEstimator.js";
|
|
20
15
|
import { defaultGasEstimator } from "./defaults/gasEstimator.js";
|
|
21
16
|
import { defaultPaymasterAndData } from "./defaults/paymasterAndData.js";
|
|
@@ -45,11 +40,11 @@ export type MiddlewareClient<
|
|
|
45
40
|
>;
|
|
46
41
|
|
|
47
42
|
/**
|
|
48
|
-
*
|
|
43
|
+
* function that takes in ClientMiddlewareConfig used during client initiation
|
|
49
44
|
* and returns the middleware actions object that the smart account client extends with
|
|
50
45
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @returns middleware actions object
|
|
46
|
+
* @param {ClientMiddlewareConfig} overrides config used during client initiation for overriding default middlewares
|
|
47
|
+
* @returns {(client: MiddlewareClient<TTransport, TChain, TAccount>) => { middleware: ClientMiddleware }} middleware actions object
|
|
53
48
|
*/
|
|
54
49
|
export const middlewareActions =
|
|
55
50
|
(overrides: ClientMiddlewareConfig) =>
|
|
@@ -64,27 +59,11 @@ export const middlewareActions =
|
|
|
64
59
|
): { middleware: ClientMiddleware } => ({
|
|
65
60
|
middleware: {
|
|
66
61
|
customMiddleware: overrides.customMiddleware ?? noopMiddleware,
|
|
67
|
-
dummyPaymasterAndData:
|
|
68
|
-
|
|
69
|
-
const data = overrides.paymasterAndData!.dummyPaymasterAndData();
|
|
70
|
-
const paymasterOverrides =
|
|
71
|
-
account.getEntryPoint().version === "0.7.0"
|
|
72
|
-
? isHex(data)
|
|
73
|
-
? parsePaymasterAndData(data)
|
|
74
|
-
: data
|
|
75
|
-
: {
|
|
76
|
-
paymasterAndData: isHex(data)
|
|
77
|
-
? data
|
|
78
|
-
: concatPaymasterAndData(data),
|
|
79
|
-
};
|
|
80
|
-
return { ...struct, ...paymasterOverrides };
|
|
81
|
-
}
|
|
82
|
-
: defaultPaymasterAndData,
|
|
83
|
-
|
|
62
|
+
dummyPaymasterAndData:
|
|
63
|
+
overrides.dummyPaymasterAndData ?? defaultPaymasterAndData,
|
|
84
64
|
feeEstimator: overrides.feeEstimator ?? defaultFeeEstimator(client),
|
|
85
65
|
gasEstimator: overrides.gasEstimator ?? defaultGasEstimator(client),
|
|
86
|
-
paymasterAndData:
|
|
87
|
-
overrides.paymasterAndData?.paymasterAndData ?? defaultPaymasterAndData,
|
|
66
|
+
paymasterAndData: overrides.paymasterAndData ?? defaultPaymasterAndData,
|
|
88
67
|
userOperationSimulator:
|
|
89
68
|
overrides.userOperationSimulator ?? noopMiddleware,
|
|
90
69
|
signUserOperation: overrides.signUserOperation ?? defaultUserOpSigner,
|