@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
|
@@ -20,6 +20,30 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
20
20
|
import type { UserOperationContext } from "./types.js";
|
|
21
21
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Sends a transaction using the provided client, arguments, optional overrides, and context.
|
|
25
|
+
* This sends a UO and then waits for it to be mined
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
30
|
+
*
|
|
31
|
+
* // smart account client is already extended with sendTransaction
|
|
32
|
+
* const client = createSmartAccountClient(...);
|
|
33
|
+
* const result = await client.sendTransaction({
|
|
34
|
+
* to: "0x...",
|
|
35
|
+
* data: "0x...", // or "0x",
|
|
36
|
+
* value: 0n, // optional
|
|
37
|
+
* account, // only required if the client above is not connected to an account
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param {Client<Transport, TChain, TAccount>} client The client to send the transaction through
|
|
42
|
+
* @param {SendTransactionParameters<TChain, TAccount, TChainOverride>} args The parameters required to send the transaction
|
|
43
|
+
* @param {UserOperationOverrides<TEntryPointVersion>} [overrides] Optional overrides for the user operation
|
|
44
|
+
* @param {UserOperationContext} [context] Optional context for the user operation
|
|
45
|
+
* @returns {Promise<Hex>} A promise that resolves to a hex string representing the transaction hash
|
|
46
|
+
*/
|
|
23
47
|
export async function sendTransaction<
|
|
24
48
|
TChain extends Chain | undefined = Chain | undefined,
|
|
25
49
|
TAccount extends SmartContractAccount | undefined =
|
|
@@ -9,6 +9,29 @@ import { _sendUserOperation } from "./internal/sendUserOperation.js";
|
|
|
9
9
|
import type { SendTransactionsParameters, UserOperationContext } from "./types";
|
|
10
10
|
import { waitForUserOperationTransaction } from "./waitForUserOperationTransacation.js";
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Sends transactions using the provided client and transaction parameters. This function builds user operations from the transactions, sends them, and waits for the transaction to be mined.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
18
|
+
*
|
|
19
|
+
* // smart account client is already extended with sendTransactions
|
|
20
|
+
* const client = createSmartAccountClient(...);
|
|
21
|
+
* const result = await client.sendTransactions({
|
|
22
|
+
* requests: [{
|
|
23
|
+
* to: "0x...",
|
|
24
|
+
* data: "0x...", // or "0x",
|
|
25
|
+
* value: 0n, // optional
|
|
26
|
+
* }],
|
|
27
|
+
* account, // only required if the client above is not connected to an account
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client used to send the transactions
|
|
32
|
+
* @param {SendTransactionsParameters<TAccount, TContext>} args The parameters for sending the transactions, including requests, overrides, account, and context
|
|
33
|
+
* @returns {Promise<Hex>} A promise that resolves to the transaction hash of the sent transactions
|
|
34
|
+
*/
|
|
12
35
|
export async function sendTransactions<
|
|
13
36
|
TTransport extends Transport = Transport,
|
|
14
37
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -17,9 +17,23 @@ import type {
|
|
|
17
17
|
/**
|
|
18
18
|
* Sends a user operation or batch of user operations using the connected account. Before executing, sendUserOperation will run the user operation through the middleware pipeline.
|
|
19
19
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { createSmartAccountClient, toSmartContractAccount } from "@aa-sdk/core";
|
|
23
|
+
*
|
|
24
|
+
* const account = await toSmartContractAccount(...);
|
|
25
|
+
* const result = await createSmartAccountClient(...).sendUserOperation({
|
|
26
|
+
* uo: {
|
|
27
|
+
* target: "0x...",
|
|
28
|
+
* data: "0x...", // or "0x",
|
|
29
|
+
* value: 0n, // optional
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param {Client<TTransport, TChain, TAccount>} client the smart account client to use for RPC requests
|
|
35
|
+
* @param {SendUserOperationParameters<TAccount, TContext>} args contains the UO or batch to send, context, overrides, and account if not hoisted on the client
|
|
36
|
+
* @returns {Promise<SendUserOperationResult<TEntryPointVersion>>} a Promise containing the result of the user operation
|
|
23
37
|
*/
|
|
24
38
|
export async function sendUserOperation<
|
|
25
39
|
TTransport extends Transport = Transport,
|
|
@@ -6,6 +6,30 @@ import { FailedToFindTransactionError } from "../../errors/transaction.js";
|
|
|
6
6
|
import { Logger } from "../../logger.js";
|
|
7
7
|
import type { WaitForUserOperationTxParameters } from "./types.js";
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Waits for a user operation transaction to be confirmed by checking the receipt periodically until it is found or a maximum number of retries is reached.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
15
|
+
*
|
|
16
|
+
* // smart account client is already extended with waitForUserOperationTransaction
|
|
17
|
+
* const client = createSmartAccountClient(...);
|
|
18
|
+
* const result = await client.waitForUserOperationTransaction({
|
|
19
|
+
* hash: "0x...",
|
|
20
|
+
* retries: {...} // optional param to configure the retry amounts
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param {Client<TTransport, TChain, any>} client The client instance used to interact with the blockchain
|
|
25
|
+
* @param {WaitForUserOperationTxParameters} args The parameters for the transaction to wait for
|
|
26
|
+
* @param {Hex} args.hash The transaction hash to wait for
|
|
27
|
+
* @param {WaitForUserOperationTxParameters["retries"]} [args.retries] Optional retry parameters
|
|
28
|
+
* @param {number} [args.retries.maxRetries] The maximum number of retry attempts
|
|
29
|
+
* @param {number} [args.retries.intervalMs] The interval in milliseconds between retries
|
|
30
|
+
* @param {number} [args.retries.multiplier] The multiplier for the interval between retries
|
|
31
|
+
* @returns {Promise<Hex>} A promise that resolves to the transaction hash when the transaction is confirmed
|
|
32
|
+
*/
|
|
9
33
|
export const waitForUserOperationTransaction: <
|
|
10
34
|
TTransport extends Transport = Transport,
|
|
11
35
|
TChain extends Chain | undefined = Chain | undefined
|
|
@@ -29,6 +29,21 @@ export type BundlerClient<T extends Transport = Transport> = Client<
|
|
|
29
29
|
PublicActions<T, Chain> & BundlerActions
|
|
30
30
|
>;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Creates a bundler client from an existing public client with the provided transport and chain.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { createPublicClient } from "viem";
|
|
38
|
+
* import { createBundlerClientFromExisting } from "@aa-sdk/core";
|
|
39
|
+
*
|
|
40
|
+
* const publicClient = createPublicClient(...);
|
|
41
|
+
* const bundlerClient = createBundlerClientFromExisting(publicClient);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param {PublicClient<T, Chain>} client The existing public client to be extended with bundler actions
|
|
45
|
+
* @returns {BundlerClient<T>} A bundler client that extends the functionality of the provided public client
|
|
46
|
+
*/
|
|
32
47
|
export const createBundlerClientFromExisting: <
|
|
33
48
|
T extends Transport | FallbackTransport = Transport
|
|
34
49
|
>(
|
|
@@ -43,13 +58,30 @@ export const createBundlerClientFromExisting: <
|
|
|
43
58
|
/**
|
|
44
59
|
* Creates a PublicClient with methods for calling Bundler RPC methods
|
|
45
60
|
*
|
|
46
|
-
* @param args - configuration for the client
|
|
47
|
-
* @returns a PublicClient with methods for calling Bundler RPC methods
|
|
61
|
+
* @param {PublicClientConfig<TTransport, Chain> & { type?: string }} args - configuration for the client
|
|
62
|
+
* @returns {BundlerClient<TTransport>} a PublicClient with methods for calling Bundler RPC methods
|
|
48
63
|
*/
|
|
49
64
|
export function createBundlerClient<TTransport extends Transport>(
|
|
50
65
|
args: PublicClientConfig<TTransport, Chain> & { type?: string }
|
|
51
66
|
): BundlerClient<TTransport>;
|
|
52
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Creates a Bundler Client using the provided configuration parameters, including chain and optional type.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* import { createBundlerClient } from "@aa-sdk/core";
|
|
74
|
+
* import { sepolia } from "viem/chains";
|
|
75
|
+
*
|
|
76
|
+
* const client = createBundlerClient({
|
|
77
|
+
* chain: sepolia,
|
|
78
|
+
* transport: http("RPC_URL"),
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @param {PublicClientConfig & { type?: string }} args Configuration for creating the Bundler Client, including parameters for the chain, transport, and optional type
|
|
83
|
+
* @returns {BundlerClient} The created Bundler Client with extended public and bundler actions
|
|
84
|
+
*/
|
|
53
85
|
export function createBundlerClient(
|
|
54
86
|
args: PublicClientConfig & { type?: string }
|
|
55
87
|
): BundlerClient {
|
|
@@ -55,10 +55,10 @@ export type BundlerActions = {
|
|
|
55
55
|
/**
|
|
56
56
|
* calls `eth_estimateUserOperationGas` and returns the result
|
|
57
57
|
*
|
|
58
|
-
* @param request - the
|
|
58
|
+
* @param request - the UserOperationRequest to estimate gas for
|
|
59
59
|
* @param entryPoint - the entry point address the op will be sent to
|
|
60
60
|
* @param stateOverride - the state override to use for the estimation
|
|
61
|
-
* @returns the gas estimates for the given response
|
|
61
|
+
* @returns the gas estimates for the given response
|
|
62
62
|
*/
|
|
63
63
|
estimateUserOperationGas<
|
|
64
64
|
TEntryPointVersion extends EntryPointVersion = EntryPointVersion
|
|
@@ -71,7 +71,7 @@ export type BundlerActions = {
|
|
|
71
71
|
/**
|
|
72
72
|
* calls `eth_sendUserOperation` and returns the hash of the sent UserOperation
|
|
73
73
|
*
|
|
74
|
-
* @param request - the
|
|
74
|
+
* @param request - the UserOperationRequest to send
|
|
75
75
|
* @param entryPoint - the entry point address the op will be sent to
|
|
76
76
|
* @returns the hash of the sent UserOperation
|
|
77
77
|
*/
|
|
@@ -83,30 +83,39 @@ export type BundlerActions = {
|
|
|
83
83
|
): Promise<Hash>;
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* calls `eth_getUserOperationByHash` and returns the
|
|
86
|
+
* calls `eth_getUserOperationByHash` and returns the UserOperationResponse
|
|
87
87
|
*
|
|
88
88
|
* @param hash - the hash of the UserOperation to fetch
|
|
89
|
-
* @returns -
|
|
89
|
+
* @returns - the user operation if found or null
|
|
90
90
|
*/
|
|
91
91
|
getUserOperationByHash(hash: Hash): Promise<UserOperationResponse | null>;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
* calls `eth_getUserOperationReceipt` and returns the
|
|
94
|
+
* calls `eth_getUserOperationReceipt` and returns the UserOperationReceipt
|
|
95
95
|
*
|
|
96
96
|
* @param hash - the hash of the UserOperation to get the receipt for
|
|
97
|
-
* @returns -
|
|
97
|
+
* @returns - a user operation receipt or null if not found
|
|
98
98
|
*/
|
|
99
99
|
getUserOperationReceipt(hash: Hash): Promise<UserOperationReceipt | null>;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* calls `eth_supportedEntryPoints` and returns the entry points the RPC supports
|
|
103
103
|
*
|
|
104
|
-
* @returns -
|
|
104
|
+
* @returns - an array of the entrypoint addresses supported
|
|
105
105
|
*/
|
|
106
106
|
getSupportedEntryPoints(): Promise<Address[]>;
|
|
107
107
|
};
|
|
108
108
|
// [!endregion BundlerActions]
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A viem client decorator that provides Bundler specific actions.
|
|
112
|
+
* These actions include estimating gas for user operations, sending raw user operations, retrieving user operations by hash, getting supported entry points, and getting user operation receipts.
|
|
113
|
+
*
|
|
114
|
+
* NOTE: this is already added to the client returned from `createBundlerClient`
|
|
115
|
+
*
|
|
116
|
+
* @param {TClient} client The client instance that will be used to perform bundler actions
|
|
117
|
+
* @returns {BundlerActions} An object containing various bundler-related actions that can be executed using the provided client
|
|
118
|
+
*/
|
|
110
119
|
export const bundlerActions: <
|
|
111
120
|
TClient extends Client<
|
|
112
121
|
Transport,
|
|
@@ -133,6 +133,14 @@ export type BaseSmartAccountClientActions<
|
|
|
133
133
|
});
|
|
134
134
|
// #endregion SmartAccountClientActions
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Provides a set of smart account client actions to decorate the provided client. These actions include building and signing user operations, sending transactions, and more.
|
|
138
|
+
*
|
|
139
|
+
* NOTE: this is already added to clients returned from `createSmartAccountClient`
|
|
140
|
+
*
|
|
141
|
+
* @param {Client<TTransport, TChain, TAccount>} client The client to bind the smart account actions to
|
|
142
|
+
* @returns {BaseSmartAccountClientActions<TChain, TAccount, TContext>} An object containing various smart account client actions
|
|
143
|
+
*/
|
|
136
144
|
export const smartAccountClientActions: <
|
|
137
145
|
TTransport extends Transport = Transport,
|
|
138
146
|
TChain extends Chain | undefined = Chain | undefined,
|
|
@@ -11,8 +11,8 @@ import type {
|
|
|
11
11
|
* Useful for narrowing the type of the client down when used within the
|
|
12
12
|
* smart account client decorators
|
|
13
13
|
*
|
|
14
|
-
* @param client a viem client
|
|
15
|
-
* @returns true if the client is a SmartAccountClient
|
|
14
|
+
* @param {Client<TTransport, TChain, TAccount>} client a viem client
|
|
15
|
+
* @returns {boolean} true if the client is a SmartAccountClient
|
|
16
16
|
*/
|
|
17
17
|
export function isSmartAccountClient<
|
|
18
18
|
TTransport extends Transport = Transport,
|
|
@@ -37,8 +37,8 @@ export function isSmartAccountClient<
|
|
|
37
37
|
* Useful for narrowing the type of the client down when used within the
|
|
38
38
|
* smart account action decorators
|
|
39
39
|
*
|
|
40
|
-
* @param client a viem client
|
|
41
|
-
* @returns true if the account is a BaseSmartAccountClient
|
|
40
|
+
* @param {Client<TTransport, TChain, TAccount>} client a viem client
|
|
41
|
+
* @returns {boolean} true if the account is a BaseSmartAccountClient
|
|
42
42
|
*/
|
|
43
43
|
export function isBaseSmartAccountClient<
|
|
44
44
|
TTransport extends Transport = Transport,
|
|
@@ -135,6 +135,26 @@ export function createSmartAccountClient<
|
|
|
135
135
|
config: SmartAccountClientConfig<TTransport, TChain, TAccount, TContext>
|
|
136
136
|
): SmartAccountClient<TTransport, TChain, TAccount>;
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Creates a smart account client using the provided configuration. This client handles various Ethereum transactions and message signing operations.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* import { createSmartAccountClient, toSmartContractAccount } from "@aa-sdk/core";
|
|
144
|
+
* import { http } from "viem";
|
|
145
|
+
* import { sepolia } from "viem/chains";
|
|
146
|
+
*
|
|
147
|
+
* const client = createSmartAccountClient({
|
|
148
|
+
* chain: sepolia,
|
|
149
|
+
* transport: http("RPC_URL"),
|
|
150
|
+
* // optionally hoist the account
|
|
151
|
+
* account: toSmartContractAccount(...),
|
|
152
|
+
* });
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @param {SmartAccountClientConfig} config The configuration for creating the smart account client
|
|
156
|
+
* @returns {SmartAccountClient} A smart account client capable of handling transactions, message signing, and other operations on a smart account
|
|
157
|
+
*/
|
|
138
158
|
export function createSmartAccountClient(
|
|
139
159
|
config: SmartAccountClientConfig
|
|
140
160
|
): SmartAccountClient {
|
|
@@ -263,6 +283,27 @@ export function createSmartAccountClientFromExisting<
|
|
|
263
283
|
TContext
|
|
264
284
|
>;
|
|
265
285
|
|
|
286
|
+
/**
|
|
287
|
+
* Creates a smart account client using an existing client and specific configuration. This function can be used to reuse a pre-existing BundlerClient while customizing other aspects of the smart account.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```ts
|
|
291
|
+
* import {
|
|
292
|
+
* createBundlerClient,
|
|
293
|
+
* createSmartAccountClientFromExisting,
|
|
294
|
+
* toSmartContractAccount
|
|
295
|
+
* } from "@aa-sdk/core";
|
|
296
|
+
*
|
|
297
|
+
* const bundlerClient = createBundlerClient(...);
|
|
298
|
+
* const client = createSmartAccountClientFromExisting({
|
|
299
|
+
* client,
|
|
300
|
+
* account: toSmartContractAccount(...),
|
|
301
|
+
* })
|
|
302
|
+
* ```
|
|
303
|
+
*
|
|
304
|
+
* @param {Omit<SmartAccountClientConfig, "transport" | "chain"> & {client: BundlerClient}} config the configuration object which includes the client
|
|
305
|
+
* @returns {SmartAccountClient} A smart account client created from the existing BundlerClient
|
|
306
|
+
*/
|
|
266
307
|
export function createSmartAccountClientFromExisting(
|
|
267
308
|
config: Omit<SmartAccountClientConfig, "transport" | "chain"> & {
|
|
268
309
|
client: BundlerClient;
|
package/src/client/types.ts
CHANGED
|
@@ -3,10 +3,7 @@ import type { Hash, Hex } from "viem";
|
|
|
3
3
|
import type { z } from "zod";
|
|
4
4
|
import type { UserOperationContext } from "../actions/smartAccount/types.js";
|
|
5
5
|
import type { EntryPointVersion } from "../entrypoint/types.js";
|
|
6
|
-
import type {
|
|
7
|
-
ClientMiddleware,
|
|
8
|
-
ClientMiddlewareFn,
|
|
9
|
-
} from "../middleware/types.js";
|
|
6
|
+
import type { ClientMiddleware } from "../middleware/types.js";
|
|
10
7
|
import type { UserOperationRequest } from "../types.js";
|
|
11
8
|
import type { ConnectionConfigSchema } from "./schema.js";
|
|
12
9
|
|
|
@@ -37,15 +34,5 @@ export type ClientMiddlewareConfig<
|
|
|
37
34
|
TContext extends UserOperationContext | undefined =
|
|
38
35
|
| UserOperationContext
|
|
39
36
|
| undefined
|
|
40
|
-
> =
|
|
41
|
-
Partial<ClientMiddleware<TContext>>,
|
|
42
|
-
"dummyPaymasterAndData" | "paymasterAndData"
|
|
43
|
-
> & {
|
|
44
|
-
paymasterAndData?: {
|
|
45
|
-
dummyPaymasterAndData: () =>
|
|
46
|
-
| UserOperationRequest<"0.6.0">["paymasterAndData"]
|
|
47
|
-
| Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData">;
|
|
48
|
-
paymasterAndData: ClientMiddlewareFn<TContext>;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
37
|
+
> = Partial<ClientMiddleware<TContext>>;
|
|
51
38
|
// [!endregion ClientMiddlewareConfig]
|
package/src/ens/utils.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import type { Chain } from "viem/chains";
|
|
2
1
|
import * as chains from "viem/chains";
|
|
3
|
-
import { mainnet } from "
|
|
2
|
+
import { mainnet, type Chain } from "viem/chains";
|
|
4
3
|
|
|
5
4
|
export const ChainsById: Map<number, chains.Chain> = new Map(
|
|
6
5
|
Object.values(chains).map((x) => [x.id, x])
|
|
7
6
|
);
|
|
8
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Converts a given chain ID to a coin type, following specific standards for mainnet and non-mainnet chains.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { convertChainIdToCoinType } from "@aa-sdk/core";
|
|
14
|
+
* import { sepolia } from "viem/chains";
|
|
15
|
+
*
|
|
16
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param {number} chainId the blockchain chain ID that you want to convert to a coin type
|
|
20
|
+
* @returns {number} the corresponding coin type for the given chain ID
|
|
21
|
+
*/
|
|
9
22
|
export const convertChainIdToCoinType = (chainId: number): number => {
|
|
10
23
|
if (chainId === mainnet.id) {
|
|
11
24
|
// this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)
|
|
@@ -16,6 +29,21 @@ export const convertChainIdToCoinType = (chainId: number): number => {
|
|
|
16
29
|
return (0x80000000 | chainId) >>> 0;
|
|
17
30
|
};
|
|
18
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Converts a coin type to a chain ID based on predefined mappings. This function follows ENSIP-9 for coin type 60 and ENSIP-11 for other coin types.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { convertChainIdToCoinType, convertCoinTypeToChainId } from "@aa-sdk/core";
|
|
38
|
+
* import { sepolia } from "viem/chains";
|
|
39
|
+
*
|
|
40
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
41
|
+
* const chainId = convertCoinTypeToChainId(coinType);
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param {number} coinType the coin type to be converted to a chain ID
|
|
45
|
+
* @returns {number} the corresponding chain ID
|
|
46
|
+
*/
|
|
19
47
|
export const convertCoinTypeToChainId = (coinType: number): number => {
|
|
20
48
|
if (coinType === 60) {
|
|
21
49
|
// this comes from [ensip-9](https://docs.ens.domains/ens-improvement-proposals/ensip-9-multichain-address-resolution)
|
|
@@ -26,6 +54,22 @@ export const convertCoinTypeToChainId = (coinType: number): number => {
|
|
|
26
54
|
return (0x7fffffff & coinType) >> 0;
|
|
27
55
|
};
|
|
28
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Converts a coin type to its corresponding blockchain chain based on a predefined mapping.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { convertChainIdToCoinType, convertCoinTypeToChain } from "@aa-sdk/core";
|
|
63
|
+
* import { sepolia } from "viem/chains";
|
|
64
|
+
*
|
|
65
|
+
* const coinType = convertChainIdToCoinType(sepolia.id);
|
|
66
|
+
* const chain = convertCoinTypeToChain(coinType);
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param {number} coinType The numerical identifier for the coin type
|
|
70
|
+
* @returns {Chain} The corresponding blockchain chain
|
|
71
|
+
* @throws {Error} If the coin type does not map to a supported chain
|
|
72
|
+
*/
|
|
29
73
|
export const convertCoinTypeToChain = (coinType: number): Chain => {
|
|
30
74
|
const chainId = convertCoinTypeToChainId(coinType);
|
|
31
75
|
const chain = ChainsById.get(chainId);
|
package/src/entrypoint/index.ts
CHANGED
|
@@ -17,6 +17,20 @@ export const entryPointRegistry: EntryPointRegistry = {
|
|
|
17
17
|
"0.7.0": EntryPoint_v7,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the given value is a valid key of the EntryPointRegistry.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { isEntryPointVersion } from "@aa-sdk/core";
|
|
26
|
+
*
|
|
27
|
+
* const valid = isEntryPointVersion("0.6.0");
|
|
28
|
+
* const invalid = isEntryPointVersion("0.8.0");
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param {*} value The value to be checked
|
|
32
|
+
* @returns {boolean} true if the value is a valid key of EntryPointRegistry, false otherwise
|
|
33
|
+
*/
|
|
20
34
|
export const isEntryPointVersion = (
|
|
21
35
|
value: any
|
|
22
36
|
): value is keyof EntryPointRegistry => {
|
|
@@ -44,6 +58,22 @@ export function getEntryPoint<TChain extends Chain = Chain>(
|
|
|
44
58
|
options?: GetEntryPointOptions<DefaultEntryPointVersion>
|
|
45
59
|
): EntryPointDefRegistry<TChain>[DefaultEntryPointVersion];
|
|
46
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the entry point definition for the specified chain and version, falling back to the default version if not provided. Throws an error if the entry point address cannot be found.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { getEntryPoint } from "@aa-sdk/core";
|
|
67
|
+
* import { sepolia } from "viem/chains";
|
|
68
|
+
*
|
|
69
|
+
* const entryPoint060 = getEntryPoint(sepolia);
|
|
70
|
+
* const entryPoint070 = getEntryPoint(sepolia, { version: "0.7.0" });
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @param {Chain} chain The chain for which the entry point is being retrieved
|
|
74
|
+
* @param {GetEntryPointOptions<TEntryPointVersion>} options Options containing the version and address overrides for the entry point
|
|
75
|
+
* @returns {EntryPointDefRegistry<TChain>[EntryPointVersion]} The entry point definition for the specified chain and version
|
|
76
|
+
*/
|
|
47
77
|
export function getEntryPoint<
|
|
48
78
|
TEntryPointVersion extends EntryPointVersion,
|
|
49
79
|
TChain extends Chain = Chain
|
|
@@ -88,65 +118,3 @@ export function getEntryPoint<
|
|
|
88
118
|
|
|
89
119
|
throw new EntryPointNotFoundError(chain, version);
|
|
90
120
|
}
|
|
91
|
-
|
|
92
|
-
// // =================================================================================
|
|
93
|
-
// // TODO: Add tests for the following cases
|
|
94
|
-
|
|
95
|
-
// const chain: Chain = mainnet;
|
|
96
|
-
|
|
97
|
-
// // 1. left and right hand side version type should match, as well as the param
|
|
98
|
-
|
|
99
|
-
// // === Error ===
|
|
100
|
-
// const ep1_a: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
101
|
-
// version: "0.7.0",
|
|
102
|
-
// }); // error
|
|
103
|
-
// const ep1_b: EntryPointDef<"0.7.0"> = getEntryPoint(chain); // error
|
|
104
|
-
// const ep1_c: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
105
|
-
// version: "0.7.0",
|
|
106
|
-
// }); // error
|
|
107
|
-
// const ep1_d: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
108
|
-
// version: "0.7.0",
|
|
109
|
-
// }); // error
|
|
110
|
-
|
|
111
|
-
// // === Valid ===
|
|
112
|
-
// const ep1a: EntryPointDef<"0.6.0"> = getEntryPoint(chain);
|
|
113
|
-
// const ep1b: EntryPointDef<"0.6.0"> = getEntryPoint(chain, { version: "0.6.0" });
|
|
114
|
-
// const ep1c: EntryPointDef<"0.7.0"> = getEntryPoint(chain, { version: "0.7.0" });
|
|
115
|
-
// const ep1d: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
116
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
117
|
-
// });
|
|
118
|
-
// const ep1e: EntryPointDef<"0.6.0"> = getEntryPoint(chain, {
|
|
119
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
120
|
-
// version: "0.6.0",
|
|
121
|
-
// });
|
|
122
|
-
// const ep1f: EntryPointDef<"0.7.0"> = getEntryPoint(chain, {
|
|
123
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
124
|
-
// version: "0.7.0",
|
|
125
|
-
// });
|
|
126
|
-
|
|
127
|
-
// // 2. If non-default type is specified, version option param of the type is required
|
|
128
|
-
|
|
129
|
-
// // === Error ===
|
|
130
|
-
// const ep2_a: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain); // error
|
|
131
|
-
// const ep2_b: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
132
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
133
|
-
// });
|
|
134
|
-
|
|
135
|
-
// // === Valid ===
|
|
136
|
-
// const ep2a: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
137
|
-
// version: "0.7.0",
|
|
138
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
139
|
-
// });
|
|
140
|
-
// const ep2b: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
141
|
-
// version: "0.6.0",
|
|
142
|
-
// });
|
|
143
|
-
// const ep2c: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain);
|
|
144
|
-
// const ep2d: EntryPointDef<"0.6.0"> = getEntryPoint<"0.6.0">(chain, {
|
|
145
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
146
|
-
// });
|
|
147
|
-
// const ep2e: EntryPointDef<"0.7.0"> = getEntryPoint<"0.7.0">(chain, {
|
|
148
|
-
// version: "0.7.0",
|
|
149
|
-
// addressOverride: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
150
|
-
// });
|
|
151
|
-
|
|
152
|
-
// // =================================================================================
|