@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
|
@@ -9,10 +9,34 @@ import {
|
|
|
9
9
|
import { InvalidSignerTypeError } from "../errors/signer.js";
|
|
10
10
|
import type { SmartAccountSigner } from "./types";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Represents a wallet client signer for smart accounts, providing methods to get the address, sign messages, and sign typed data.
|
|
14
|
+
*/
|
|
12
15
|
export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
13
16
|
signerType: string;
|
|
14
17
|
inner: WalletClient;
|
|
15
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Initializes a signer with a given wallet client and signer type.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
25
|
+
* import { createWalletClient, custom } from 'viem'
|
|
26
|
+
* import { mainnet } from 'viem/chains'
|
|
27
|
+
*
|
|
28
|
+
* const client = createWalletClient({
|
|
29
|
+
* chain: mainnet,
|
|
30
|
+
* transport: custom(window.ethereum!)
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param {WalletClient} client The wallet client to interact with
|
|
37
|
+
* @param {string} signerType The type of signer; must be a valid signer type, otherwise an error will be thrown
|
|
38
|
+
* @throws {InvalidSignerTypeError} If the signer type is invalid
|
|
39
|
+
*/
|
|
16
40
|
constructor(client: WalletClient, signerType: string) {
|
|
17
41
|
this.inner = client;
|
|
18
42
|
if (!signerType) {
|
|
@@ -21,11 +45,52 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
|
21
45
|
this.signerType = signerType;
|
|
22
46
|
}
|
|
23
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Asynchronously retrieves addresses from the inner object and returns the first address after applying the `getAddress` function.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
54
|
+
* import { createWalletClient, custom } from 'viem'
|
|
55
|
+
* import { mainnet } from 'viem/chains'
|
|
56
|
+
*
|
|
57
|
+
* const client = createWalletClient({
|
|
58
|
+
* chain: mainnet,
|
|
59
|
+
* transport: custom(window.ethereum!)
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
63
|
+
* console.log(await signer.getAddress());
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @returns {Promise<string>} A promise that resolves to the first address after being processed by the `getAddress` function.
|
|
67
|
+
*/
|
|
24
68
|
getAddress: () => Promise<`0x${string}`> = async () => {
|
|
25
69
|
let addresses = await this.inner.getAddresses();
|
|
26
70
|
return getAddress(addresses[0]);
|
|
27
71
|
};
|
|
28
72
|
|
|
73
|
+
/**
|
|
74
|
+
* Signs a message using the account's signing method.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
79
|
+
* import { createWalletClient, custom } from 'viem'
|
|
80
|
+
* import { mainnet } from 'viem/chains'
|
|
81
|
+
*
|
|
82
|
+
* const client = createWalletClient({
|
|
83
|
+
* chain: mainnet,
|
|
84
|
+
* transport: custom(window.ethereum!)
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
88
|
+
* console.log(await signer.signMessage("hello"));
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param {string} message the message string that needs to be signed
|
|
92
|
+
* @returns {Promise<string>} a promise that resolves to the signed message
|
|
93
|
+
*/
|
|
29
94
|
readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`> =
|
|
30
95
|
async (message) => {
|
|
31
96
|
const account = this.inner.account ?? (await this.getAddress());
|
|
@@ -33,6 +98,33 @@ export class WalletClientSigner implements SmartAccountSigner<WalletClient> {
|
|
|
33
98
|
return this.inner.signMessage({ message, account });
|
|
34
99
|
};
|
|
35
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Signs the provided typed data using the account's private key.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* import { WalletClientSigner } from "@aa-sdk/core";
|
|
107
|
+
* import { createWalletClient, custom } from 'viem'
|
|
108
|
+
* import { mainnet } from 'viem/chains'
|
|
109
|
+
*
|
|
110
|
+
* const client = createWalletClient({
|
|
111
|
+
* chain: mainnet,
|
|
112
|
+
* transport: custom(window.ethereum!)
|
|
113
|
+
* });
|
|
114
|
+
*
|
|
115
|
+
* const signer = new WalletClientSigner(client, 'wallet');
|
|
116
|
+
* console.log(await signer.signTypedData({
|
|
117
|
+
* types: {
|
|
118
|
+
* "Message": [{ name: "content", type: "string" }]
|
|
119
|
+
* },
|
|
120
|
+
* primaryType: "Message",
|
|
121
|
+
* message: { content: "Hello" },
|
|
122
|
+
* }));
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} typedData The typed data to be signed
|
|
126
|
+
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the signed data
|
|
127
|
+
*/
|
|
36
128
|
signTypedData = async <
|
|
37
129
|
const TTypedData extends TypedData | { [key: string]: unknown },
|
|
38
130
|
TPrimaryType extends string = string
|
package/src/transport/split.ts
CHANGED
|
@@ -37,8 +37,8 @@ export interface SplitTransportParams {
|
|
|
37
37
|
* });
|
|
38
38
|
* ```
|
|
39
39
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @returns
|
|
40
|
+
* @param {SplitTransportParams} params split transport configuration containing the methods overrides and fallback transport
|
|
41
|
+
* @returns {CustomTransport} a viem Transport that splits traffic
|
|
42
42
|
*/
|
|
43
43
|
export const split = (params: SplitTransportParams): CustomTransport => {
|
|
44
44
|
const overrideMap = params.overrides.reduce((accum, curr) => {
|
package/src/utils/bigint.ts
CHANGED
|
@@ -5,8 +5,8 @@ import { isMultiplier } from "./schema.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns the max bigint in a list of bigints
|
|
7
7
|
*
|
|
8
|
-
* @param args a list of bigints to get the max of
|
|
9
|
-
* @returns the max bigint in the list
|
|
8
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
9
|
+
* @returns {bigint} the max bigint in the list
|
|
10
10
|
*/
|
|
11
11
|
export const bigIntMax = (...args: bigint[]): bigint => {
|
|
12
12
|
if (!args.length) {
|
|
@@ -19,8 +19,8 @@ export const bigIntMax = (...args: bigint[]): bigint => {
|
|
|
19
19
|
/**
|
|
20
20
|
* Returns the min bigint in a list of bigints
|
|
21
21
|
*
|
|
22
|
-
* @param args a list of bigints to get the max of
|
|
23
|
-
* @returns the min bigint in the list
|
|
22
|
+
* @param {bigint[]} args a list of bigints to get the max of
|
|
23
|
+
* @returns {bigint} the min bigint in the list
|
|
24
24
|
*/
|
|
25
25
|
export const bigIntMin = (...args: bigint[]): bigint => {
|
|
26
26
|
if (!args.length) {
|
|
@@ -33,16 +33,16 @@ export const bigIntMin = (...args: bigint[]): bigint => {
|
|
|
33
33
|
/**
|
|
34
34
|
* Given a bigint and a min-max range, returns the min-max clamped bigint value
|
|
35
35
|
*
|
|
36
|
-
* @param value a bigint value to clamp
|
|
37
|
-
* @param lower lower bound min max tuple value
|
|
38
|
-
* @param upper upper bound min max tuple value
|
|
39
|
-
* @returns the clamped bigint value per given range
|
|
36
|
+
* @param {BigNumberish} value a bigint value to clamp
|
|
37
|
+
* @param {BigNumberish | undefined} lower lower bound min max tuple value
|
|
38
|
+
* @param {BigNumberish | undefined} upper upper bound min max tuple value
|
|
39
|
+
* @returns {bigint} the clamped bigint value per given range
|
|
40
40
|
*/
|
|
41
41
|
export const bigIntClamp = (
|
|
42
42
|
value: BigNumberish,
|
|
43
43
|
lower: BigNumberish | null | undefined,
|
|
44
44
|
upper: BigNumberish | null | undefined
|
|
45
|
-
) => {
|
|
45
|
+
): bigint => {
|
|
46
46
|
lower = lower != null ? BigInt(lower) : null;
|
|
47
47
|
upper = upper != null ? BigInt(upper) : null;
|
|
48
48
|
|
|
@@ -71,10 +71,10 @@ export enum RoundingMode {
|
|
|
71
71
|
* Given a bigint and a number (which can be a float), returns the bigint value.
|
|
72
72
|
* Note: this function has loss and will round down to the nearest integer.
|
|
73
73
|
*
|
|
74
|
-
* @param base - the number to be multiplied
|
|
75
|
-
* @param multiplier - the amount to multiply by
|
|
76
|
-
* @param roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP
|
|
77
|
-
* @returns the bigint value of the multiplication with the number rounded by the rounding mode
|
|
74
|
+
* @param {BigNumberish} base - the number to be multiplied
|
|
75
|
+
* @param {number} multiplier - the amount to multiply by
|
|
76
|
+
* @param {RoundingMode} roundingMode - the rounding mode to use when calculating the percent. defaults to ROUND_UP
|
|
77
|
+
* @returns {bigint} the bigint value of the multiplication with the number rounded by the rounding mode
|
|
78
78
|
*/
|
|
79
79
|
export const bigIntMultiply = (
|
|
80
80
|
base: BigNumberish,
|
|
@@ -111,8 +111,8 @@ export const bigIntMultiply = (
|
|
|
111
111
|
* });
|
|
112
112
|
* ```
|
|
113
113
|
*
|
|
114
|
-
* @param phrase -- any string value.
|
|
115
|
-
* @returns the bigint value of the hashed string
|
|
114
|
+
* @param {string} phrase -- any string value.
|
|
115
|
+
* @returns {bigint} the bigint value of the hashed string
|
|
116
116
|
*/
|
|
117
117
|
export const stringToIndex = (phrase: string): bigint =>
|
|
118
118
|
BigInt(keccak256(toHex(phrase)));
|
package/src/utils/bytes.ts
CHANGED
|
@@ -8,11 +8,11 @@ type TakeBytesOpts = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Given a bytes string, returns a slice of the bytes
|
|
10
10
|
*
|
|
11
|
-
* @param bytes - the hex string representing bytes
|
|
12
|
-
* @param opts - optional parameters for slicing the bytes
|
|
13
|
-
* @param opts.offset - the offset in bytes to start slicing from
|
|
14
|
-
* @param opts.count - the number of bytes to slice
|
|
15
|
-
* @returns the sliced bytes
|
|
11
|
+
* @param {Hex} bytes - the hex string representing bytes
|
|
12
|
+
* @param {TakeBytesOpts} opts - optional parameters for slicing the bytes
|
|
13
|
+
* @param {number} opts.offset - the offset in bytes to start slicing from
|
|
14
|
+
* @param {number} opts.count - the number of bytes to slice
|
|
15
|
+
* @returns {Hex} the sliced bytes
|
|
16
16
|
*/
|
|
17
17
|
export const takeBytes = (bytes: Hex, opts: TakeBytesOpts = {}): Hex => {
|
|
18
18
|
const { offset, count } = opts;
|
package/src/utils/defaults.ts
CHANGED
|
@@ -1,79 +1,6 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
arbitrumGoerli,
|
|
5
|
-
arbitrumSepolia,
|
|
6
|
-
base,
|
|
7
|
-
baseGoerli,
|
|
8
|
-
baseSepolia,
|
|
9
|
-
fraxtal,
|
|
10
|
-
fraxtalSepolia,
|
|
11
|
-
goerli,
|
|
12
|
-
mainnet,
|
|
13
|
-
optimism,
|
|
14
|
-
optimismGoerli,
|
|
15
|
-
optimismSepolia,
|
|
16
|
-
polygon,
|
|
17
|
-
polygonAmoy,
|
|
18
|
-
polygonMumbai,
|
|
19
|
-
sepolia,
|
|
20
|
-
zora,
|
|
21
|
-
zoraSepolia,
|
|
22
|
-
} from "../chains/index.js";
|
|
23
|
-
import { defaultEntryPointVersion } from "../entrypoint/index.js";
|
|
24
|
-
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
25
|
-
import { DefaultFactoryNotDefinedError } from "../errors/account.js";
|
|
26
|
-
import type { UserOperationFeeOptions } from "../types";
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Utility method returning the default simple account factory address given a {@link Chain} object
|
|
30
|
-
*
|
|
31
|
-
* @param chain - a {@link Chain} object
|
|
32
|
-
* @param version - {@link EntryPointVersion} value that defaults to `defaultEntryPointVersion`
|
|
33
|
-
* @returns a {@link abi.Address} for the given chain
|
|
34
|
-
* @throws if the chain doesn't have an address currently deployed
|
|
35
|
-
*/
|
|
36
|
-
export const getDefaultSimpleAccountFactoryAddress = (
|
|
37
|
-
chain: Chain,
|
|
38
|
-
version: EntryPointVersion = defaultEntryPointVersion
|
|
39
|
-
): Address => {
|
|
40
|
-
switch (version) {
|
|
41
|
-
case "0.6.0":
|
|
42
|
-
switch (chain.id) {
|
|
43
|
-
case mainnet.id:
|
|
44
|
-
case polygon.id:
|
|
45
|
-
case polygonAmoy.id:
|
|
46
|
-
case optimism.id:
|
|
47
|
-
case optimismSepolia.id:
|
|
48
|
-
case arbitrum.id:
|
|
49
|
-
case arbitrumSepolia.id:
|
|
50
|
-
case base.id:
|
|
51
|
-
case baseGoerli.id:
|
|
52
|
-
case baseSepolia.id:
|
|
53
|
-
case fraxtal.id:
|
|
54
|
-
case fraxtalSepolia.id:
|
|
55
|
-
case zora.id:
|
|
56
|
-
case zoraSepolia.id:
|
|
57
|
-
return "0x15Ba39375ee2Ab563E8873C8390be6f2E2F50232";
|
|
58
|
-
case sepolia.id:
|
|
59
|
-
case goerli.id:
|
|
60
|
-
case polygonMumbai.id:
|
|
61
|
-
case optimismGoerli.id:
|
|
62
|
-
case arbitrumGoerli.id:
|
|
63
|
-
return "0x9406Cc6185a346906296840746125a0E44976454";
|
|
64
|
-
default:
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
case "0.7.0":
|
|
69
|
-
switch (chain.id) {
|
|
70
|
-
default:
|
|
71
|
-
return "0x91E60e0613810449d098b0b5Ec8b51A0FE8c8985";
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
throw new DefaultFactoryNotDefinedError("SimpleAccount", chain, version);
|
|
76
|
-
};
|
|
1
|
+
import { type Chain } from "viem";
|
|
2
|
+
import { arbitrum, arbitrumGoerli, arbitrumSepolia } from "viem/chains";
|
|
3
|
+
import type { UserOperationFeeOptions } from "../types.js";
|
|
77
4
|
|
|
78
5
|
export const minPriorityFeePerBidDefaults = new Map<number, bigint>([
|
|
79
6
|
[arbitrum.id, 10_000_000n],
|
package/src/utils/index.ts
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
|
-
import type { Chain } from "viem";
|
|
2
1
|
import { toHex } from "viem";
|
|
3
|
-
import * as chains from "viem/chains";
|
|
4
|
-
import * as alchemyChains from "../chains/index.js";
|
|
5
2
|
import type { PromiseOrValue } from "../types.js";
|
|
6
3
|
import type { RecordableKeys } from "./types.js";
|
|
7
4
|
|
|
8
|
-
export const AlchemyChainMap = new Map<number, Chain>(
|
|
9
|
-
Object.values(alchemyChains).map((c) => [c.id, c])
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Utility method for converting a chainId to a {@link Chain} object
|
|
14
|
-
*
|
|
15
|
-
* @param chainId - the chainId to convert
|
|
16
|
-
* @returns a {@link Chain} object for the given chainId
|
|
17
|
-
* @throws if the chainId is not found
|
|
18
|
-
*/
|
|
19
|
-
export const getChain = (chainId: number): Chain => {
|
|
20
|
-
for (const chain of Object.values(chains)) {
|
|
21
|
-
if (chain.id === chainId) {
|
|
22
|
-
return AlchemyChainMap.get(chain.id) ?? chain;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
throw new Error("could not find chain");
|
|
26
|
-
};
|
|
27
|
-
|
|
28
5
|
/**
|
|
29
6
|
* Utility function that allows for piping a series of async functions together
|
|
30
7
|
*
|
|
31
|
-
* @param fns - functions to pipe
|
|
32
|
-
* @returns result of the pipe
|
|
8
|
+
* @param {((s: S, o?: O, f?: F) => Promise<S>)[]} fns - functions to pipe
|
|
9
|
+
* @returns {S} result of the pipe
|
|
33
10
|
*/
|
|
34
11
|
export const asyncPipe =
|
|
35
12
|
<S, O, F>(...fns: ((s: S, o?: O, f?: F) => Promise<S>)[]) =>
|
|
@@ -47,10 +24,10 @@ export type Deferrable<T> = {
|
|
|
47
24
|
};
|
|
48
25
|
|
|
49
26
|
/**
|
|
50
|
-
* Await all of the properties of a
|
|
27
|
+
* Await all of the properties of a Deferrable object
|
|
51
28
|
*
|
|
52
|
-
* @param object - a
|
|
53
|
-
* @returns the object with its properties resolved
|
|
29
|
+
* @param {Deferrable<T>} object - a Deferrable object
|
|
30
|
+
* @returns {Promise<T>} the object with its properties resolved
|
|
54
31
|
*/
|
|
55
32
|
export async function resolveProperties<T>(object: Deferrable<T>): Promise<T> {
|
|
56
33
|
const promises = Object.keys(object).map((key) => {
|
|
@@ -71,8 +48,8 @@ export async function resolveProperties<T>(object: Deferrable<T>): Promise<T> {
|
|
|
71
48
|
/**
|
|
72
49
|
* Recursively converts all values in an object to hex strings
|
|
73
50
|
*
|
|
74
|
-
* @param obj - obj to deep hexlify
|
|
75
|
-
* @returns object with all of its values hexlified
|
|
51
|
+
* @param {any} obj - obj to deep hexlify
|
|
52
|
+
* @returns {any} object with all of its values hexlified
|
|
76
53
|
*/
|
|
77
54
|
export function deepHexlify(obj: any): any {
|
|
78
55
|
if (typeof obj === "function") {
|
|
@@ -97,19 +74,23 @@ export function deepHexlify(obj: any): any {
|
|
|
97
74
|
);
|
|
98
75
|
}
|
|
99
76
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Filters out properties with undefined or null values from the provided object.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* import { filterUndefined } from "@aa-sdk/core";
|
|
83
|
+
*
|
|
84
|
+
* const result = filterUndefined({
|
|
85
|
+
* foo: undefined,
|
|
86
|
+
* bar: null,
|
|
87
|
+
* baz: "baz",
|
|
88
|
+
* }); // { baz: "baz" }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param {T} obj the object from which to remove properties with undefined or null values
|
|
92
|
+
* @returns {T} the object with undefined or null properties removed
|
|
93
|
+
*/
|
|
113
94
|
export function filterUndefined<T>(obj: T): T {
|
|
114
95
|
for (const key in obj) {
|
|
115
96
|
if (obj[key] == null) {
|
|
@@ -119,6 +100,23 @@ export function filterUndefined<T>(obj: T): T {
|
|
|
119
100
|
return obj as T;
|
|
120
101
|
}
|
|
121
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Picks the specified keys from an object and returns a new object containing only those key-value pairs.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* import { pick } from "@aa-sdk/core";
|
|
109
|
+
*
|
|
110
|
+
* const picked = pick({
|
|
111
|
+
* foo: "foo",
|
|
112
|
+
* bar: "bar",
|
|
113
|
+
* }, ["foo"]); // { foo: "foo" }
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @param {Record<string, unknown>} obj The object from which to pick keys
|
|
117
|
+
* @param {string|string[]} keys A single key or an array of keys to pick from the object
|
|
118
|
+
* @returns {Record<string, unknown>} A new object containing only the picked key-value pairs
|
|
119
|
+
*/
|
|
122
120
|
export function pick(obj: Record<string, unknown>, keys: string | string[]) {
|
|
123
121
|
return Object.keys(obj)
|
|
124
122
|
.filter((k) => keys.includes(k))
|
|
@@ -128,8 +126,8 @@ export function pick(obj: Record<string, unknown>, keys: string | string[]) {
|
|
|
128
126
|
/**
|
|
129
127
|
* Utility method for checking if the passed in values are all equal (strictly)
|
|
130
128
|
*
|
|
131
|
-
* @param params - values to check
|
|
132
|
-
* @returns a boolean indicating if all values are the same
|
|
129
|
+
* @param {...any[]} params - values to check
|
|
130
|
+
* @returns {boolean} a boolean indicating if all values are the same
|
|
133
131
|
* @throws if no values are passed in
|
|
134
132
|
*/
|
|
135
133
|
export const allEqual = (...params: any[]): boolean => {
|
|
@@ -142,15 +140,35 @@ export const allEqual = (...params: any[]): boolean => {
|
|
|
142
140
|
/**
|
|
143
141
|
* Utility method for checking the condition and return the value if condition holds true, undefined if not.
|
|
144
142
|
*
|
|
145
|
-
* @param condition - condition to check
|
|
146
|
-
* @param value - value to return when condition holds true
|
|
147
|
-
* @returns the value if condition holds true, undefined if not
|
|
143
|
+
* @param {Promise<boolean>} condition - condition to check
|
|
144
|
+
* @param {() => Promise<T>} value - value to return when condition holds true
|
|
145
|
+
* @returns {Promise<T | undefined>} the value if condition holds true, undefined if not
|
|
148
146
|
*/
|
|
149
147
|
export const conditionalReturn = <T>(
|
|
150
148
|
condition: Promise<boolean>,
|
|
151
149
|
value: () => Promise<T>
|
|
152
150
|
): Promise<T | undefined> => condition.then((t) => (t ? value() : undefined));
|
|
153
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Converts an array of objects into a record (object) where each key is determined by the specified selector and the value is determined by the provided function.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { toRecord } from "@aa-sdk/core";
|
|
158
|
+
* import { sepolia, mainnet } from "viem/chains";
|
|
159
|
+
*
|
|
160
|
+
* const addressesByChain = toRecord(
|
|
161
|
+
* [sepolia, mainnet],
|
|
162
|
+
* "id",
|
|
163
|
+
* () => "0x..."
|
|
164
|
+
* ); // { [sepolia.id]: "0x...", [mainnet.id]: "0x..." }
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @param {T[]} array The array of objects to convert to a record
|
|
168
|
+
* @param {K} selector The key used to select the property that will become the record's key
|
|
169
|
+
* @param {(item: T) => V} fn The function that transforms each item in the array into the record's value
|
|
170
|
+
* @returns {Record<T[K], V>} The resulting record object
|
|
171
|
+
*/
|
|
154
172
|
export const toRecord = <
|
|
155
173
|
T extends { [K in RecordableKeys<T>]: string | number | symbol },
|
|
156
174
|
K extends RecordableKeys<T>,
|
package/src/utils/types.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export type NoUndefined<T> = T extends undefined ? never : T;
|
|
11
11
|
// borrowed from viem
|
|
12
12
|
/**
|
|
13
|
-
* @description Checks if
|
|
13
|
+
* @description Checks if T is `undefined`
|
|
14
14
|
* @param T - Type to check
|
|
15
15
|
* @example
|
|
16
16
|
* type Result = IsUndefined<undefined>
|
|
@@ -27,7 +27,7 @@ export type RequiredBy<TType, TKeys extends keyof TType> = Required<
|
|
|
27
27
|
/**
|
|
28
28
|
* @description Combines members of an intersection into a readable type.
|
|
29
29
|
*
|
|
30
|
-
* @see
|
|
30
|
+
* @see https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
|
|
31
31
|
* @example
|
|
32
32
|
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
33
33
|
* => { a: string, b: string, c: number, d: bigint }
|
package/src/utils/userop.ts
CHANGED
|
@@ -14,10 +14,10 @@ import { bigIntClamp, bigIntMultiply } from "./bigint.js";
|
|
|
14
14
|
import { allEqual, isBigNumberish } from "./index.js";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Utility method for asserting a
|
|
17
|
+
* Utility method for asserting a UserOperationStruct has valid fields for the given entry point version
|
|
18
18
|
*
|
|
19
|
-
* @param request a
|
|
20
|
-
* @returns a type guard that asserts the
|
|
19
|
+
* @param {UserOperationStruct} request a UserOperationStruct to validate
|
|
20
|
+
* @returns {boolean} a type guard that asserts the UserOperationRequest is valid
|
|
21
21
|
*/
|
|
22
22
|
export function isValidRequest<
|
|
23
23
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -37,10 +37,10 @@ export function isValidRequest<
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* Utility method for asserting a
|
|
40
|
+
* Utility method for asserting a UserOperationRequest has valid fields for the paymaster data
|
|
41
41
|
*
|
|
42
|
-
* @param request a
|
|
43
|
-
* @returns a type guard that asserts the
|
|
42
|
+
* @param {UserOperationRequest} request a UserOperationRequest to validate
|
|
43
|
+
* @returns {boolean} a type guard that asserts the UserOperationRequest is a UserOperationRequest
|
|
44
44
|
*/
|
|
45
45
|
export function isValidPaymasterAndData<
|
|
46
46
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -59,10 +59,10 @@ export function isValidPaymasterAndData<
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
* Utility method for asserting a
|
|
62
|
+
* Utility method for asserting a UserOperationStruct has valid fields for the paymaster data
|
|
63
63
|
*
|
|
64
|
-
* @param request a
|
|
65
|
-
* @returns a type guard that asserts the
|
|
64
|
+
* @param {UserOperationRequest} request a UserOperationRequest to validate
|
|
65
|
+
* @returns {boolean} a type guard that asserts the UserOperationStruct is a UserOperationRequest
|
|
66
66
|
*/
|
|
67
67
|
export function isValidFactoryAndData<
|
|
68
68
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -80,12 +80,12 @@ export function isValidFactoryAndData<
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Utility method for applying a
|
|
83
|
+
* Utility method for applying a UserOperationOverrides field value
|
|
84
84
|
* over the current value set for the field
|
|
85
85
|
*
|
|
86
|
-
* @param value the current value of the field
|
|
87
|
-
* @param override the override value to apply
|
|
88
|
-
* @returns the new value of the field after applying the override
|
|
86
|
+
* @param {BigNumberish} value the current value of the field
|
|
87
|
+
* @param {BigNumberish | Multiplier} override the override value to apply
|
|
88
|
+
* @returns {BigNumberish} the new value of the field after applying the override
|
|
89
89
|
*/
|
|
90
90
|
export function applyUserOpOverride<TValue extends BigNumberish | undefined>(
|
|
91
91
|
value: TValue,
|
|
@@ -106,12 +106,12 @@ export function applyUserOpOverride<TValue extends BigNumberish | undefined>(
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* Utility method for applying a
|
|
109
|
+
* Utility method for applying a UserOperationFeeOptionsField value
|
|
110
110
|
* over the current value set for the field
|
|
111
111
|
*
|
|
112
|
-
* @param value the current value of the field
|
|
113
|
-
* @param feeOption the
|
|
114
|
-
* @returns the new value of the field after applying the
|
|
112
|
+
* @param {BigNumberish} value the current value of the field
|
|
113
|
+
* @param {UserOperationFeeOptionsField} feeOption the override value to apply
|
|
114
|
+
* @returns {BigNumberish} the new value of the field after applying the override
|
|
115
115
|
*/
|
|
116
116
|
export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
|
|
117
117
|
value: TValue,
|
|
@@ -133,14 +133,14 @@ export function applyUserOpFeeOption<TValue extends BigNumberish | undefined>(
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/**
|
|
136
|
-
* Utility method for applying a
|
|
137
|
-
* a
|
|
136
|
+
* Utility method for applying a UserOperationOverrides field value and
|
|
137
|
+
* a UserOperationFeeOptionsField value over the current value set for the field,
|
|
138
138
|
* with the override taking precedence over the fee option
|
|
139
139
|
*
|
|
140
|
-
* @param value the current value of the field
|
|
141
|
-
* @param [override] the override value to apply
|
|
142
|
-
* @param [feeOption] the fee option field value to apply
|
|
143
|
-
* @returns the new value of the field after applying the override or fee option
|
|
140
|
+
* @param {BigNumberish} value the current value of the field
|
|
141
|
+
* @param {BigNumberish | Multiplier} [override] the override value to apply
|
|
142
|
+
* @param {UserOperationFeeOptionsField} [feeOption] the fee option field value to apply
|
|
143
|
+
* @returns {BigNumberish} the new value of the field after applying the override or fee option
|
|
144
144
|
*/
|
|
145
145
|
export function applyUserOpOverrideOrFeeOption<
|
|
146
146
|
TValue extends BigNumberish | undefined
|
|
@@ -160,8 +160,8 @@ export function applyUserOpOverrideOrFeeOption<
|
|
|
160
160
|
* either because the UserOp is paying for its own gas, or passing a specific paymaster
|
|
161
161
|
*
|
|
162
162
|
* @template EntryPointVersion TEntryPointVersion
|
|
163
|
-
* @param overrides the user operation overrides to check
|
|
164
|
-
* @returns whether the paymaster middleware should be bypassed
|
|
163
|
+
* @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the user operation overrides to check
|
|
164
|
+
* @returns {boolean} whether the paymaster middleware should be bypassed
|
|
165
165
|
*/
|
|
166
166
|
export const bypassPaymasterAndData = <
|
|
167
167
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -177,8 +177,8 @@ export const bypassPaymasterAndData = <
|
|
|
177
177
|
* pay for its own gas
|
|
178
178
|
*
|
|
179
179
|
* @template EntryPointVersion TEntryPointVersion
|
|
180
|
-
* @param overrides the user operation overrides to check
|
|
181
|
-
* @returns whether the paymaster middleware should be bypassed
|
|
180
|
+
* @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the user operation overrides to check
|
|
181
|
+
* @returns {boolean} whether the paymaster middleware should be bypassed
|
|
182
182
|
*/
|
|
183
183
|
export const bypassPaymasterAndDataEmptyHex = <
|
|
184
184
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -192,9 +192,9 @@ export const bypassPaymasterAndDataEmptyHex = <
|
|
|
192
192
|
/**
|
|
193
193
|
* Utility method for parsing the paymaster address and paymasterData from the paymasterAndData hex string
|
|
194
194
|
*
|
|
195
|
-
* @param paymasterAndData the paymaster and data hex string to parse.
|
|
195
|
+
* @param {Hex} paymasterAndData the paymaster and data hex string to parse.
|
|
196
196
|
* The hex string refers to the paymasterAndData field of entrypoint v0.6 user operation request
|
|
197
|
-
* @returns the parsed paymaster and paymasterData fields of entrypoint v0.7 user operation request paymaster and paymasterData field
|
|
197
|
+
* @returns {{ paymaster: Hex; paymasterData: Hex}} the parsed paymaster and paymasterData fields of entrypoint v0.7 user operation request paymaster and paymasterData field
|
|
198
198
|
*/
|
|
199
199
|
export const parsePaymasterAndData = (
|
|
200
200
|
paymasterAndData: Hex
|
|
@@ -207,11 +207,11 @@ export const parsePaymasterAndData = (
|
|
|
207
207
|
* Utility method for converting the object containing the paymaster address and paymaster data
|
|
208
208
|
* to the paymaster and data concatenated hex string
|
|
209
209
|
*
|
|
210
|
-
* @param paymasterAndData the object containing the picked paymaster and paymasterData fields of
|
|
210
|
+
* @param {{ paymaster: Hex; paymasterData: Hex}} paymasterAndData the object containing the picked paymaster and paymasterData fields of
|
|
211
211
|
* entrypoint v0.7 user operation request
|
|
212
|
-
* @param paymasterAndData.paymaster the paymaster address
|
|
213
|
-
* @param paymasterAndData.paymasterData the paymaster data
|
|
214
|
-
* @returns the paymasterAndData hex value of entrypoint v0.6 user operation request paymasterAndData field
|
|
212
|
+
* @param {Hex} paymasterAndData.paymaster the paymaster address
|
|
213
|
+
* @param {Hex} paymasterAndData.paymasterData the paymaster data
|
|
214
|
+
* @returns {Hex} the paymasterAndData hex value of entrypoint v0.6 user operation request paymasterAndData field
|
|
215
215
|
*/
|
|
216
216
|
export const concatPaymasterAndData = ({
|
|
217
217
|
paymaster = "0x",
|
package/src/version.ts
CHANGED