@aa-sdk/core 4.0.0-alpha.9 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/abis/EntryPointAbi_v7.js +1 -0
- package/dist/esm/abis/EntryPointAbi_v7.js.map +1 -1
- package/dist/esm/account/smartContractAccount.d.ts +50 -1
- package/dist/esm/account/smartContractAccount.js +111 -2
- package/dist/esm/account/smartContractAccount.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperation.d.ts +23 -0
- package/dist/esm/actions/smartAccount/buildUserOperation.js +23 -0
- package/dist/esm/actions/smartAccount/buildUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.d.ts +39 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js +39 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTx.js.map +1 -1
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.d.ts +54 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js +55 -0
- package/dist/esm/actions/smartAccount/buildUserOperationFromTxs.js.map +1 -1
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +28 -0
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js +28 -0
- package/dist/esm/actions/smartAccount/checkGasSponsorshipEligibility.js.map +1 -1
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.d.ts +22 -0
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js +27 -6
- package/dist/esm/actions/smartAccount/dropAndReplaceUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.d.ts +13 -0
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js +13 -0
- package/dist/esm/actions/smartAccount/estimateUserOperationGas.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.d.ts +13 -0
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js +14 -1
- package/dist/esm/actions/smartAccount/internal/initUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js +2 -1
- package/dist/esm/actions/smartAccount/internal/runMiddlewareStack.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransaction.d.ts +24 -0
- package/dist/esm/actions/smartAccount/sendTransaction.js +24 -0
- package/dist/esm/actions/smartAccount/sendTransaction.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendTransactions.d.ts +23 -0
- package/dist/esm/actions/smartAccount/sendTransactions.js +23 -0
- package/dist/esm/actions/smartAccount/sendTransactions.js.map +1 -1
- package/dist/esm/actions/smartAccount/sendUserOperation.d.ts +21 -0
- package/dist/esm/actions/smartAccount/sendUserOperation.js +21 -0
- package/dist/esm/actions/smartAccount/sendUserOperation.js.map +1 -1
- package/dist/esm/actions/smartAccount/types.d.ts +14 -0
- package/dist/esm/actions/smartAccount/types.js +1 -0
- package/dist/esm/actions/smartAccount/types.js.map +1 -1
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.d.ts +24 -0
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js +24 -0
- package/dist/esm/actions/smartAccount/waitForUserOperationTransacation.js.map +1 -1
- package/dist/esm/client/bundlerClient.d.ts +21 -0
- package/dist/esm/client/bundlerClient.js +32 -0
- package/dist/esm/client/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/bundlerClient.d.ts +41 -0
- package/dist/esm/client/decorators/bundlerClient.js +10 -0
- package/dist/esm/client/decorators/bundlerClient.js.map +1 -1
- package/dist/esm/client/decorators/smartAccountClient.d.ts +8 -0
- package/dist/esm/client/decorators/smartAccountClient.js +12 -1
- package/dist/esm/client/decorators/smartAccountClient.js.map +1 -1
- package/dist/esm/client/isSmartAccountClient.d.ts +16 -0
- package/dist/esm/client/isSmartAccountClient.js +16 -0
- package/dist/esm/client/isSmartAccountClient.js.map +1 -1
- package/dist/esm/client/schema.d.ts +12 -0
- package/dist/esm/client/schema.js +14 -0
- package/dist/esm/client/schema.js.map +1 -1
- package/dist/esm/client/smartAccountClient.js +53 -0
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.js +1 -0
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/ens/utils.d.ts +45 -0
- package/dist/esm/ens/utils.js +49 -0
- package/dist/esm/ens/utils.js.map +1 -1
- package/dist/esm/entrypoint/index.d.ts +14 -0
- package/dist/esm/entrypoint/index.js +30 -0
- package/dist/esm/entrypoint/index.js.map +1 -1
- package/dist/esm/entrypoint/types.d.ts +17 -0
- package/dist/esm/errors/account.d.ts +87 -4
- package/dist/esm/errors/account.js +88 -4
- package/dist/esm/errors/account.js.map +1 -1
- package/dist/esm/errors/base.d.ts +5 -0
- package/dist/esm/errors/base.js +5 -0
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/client.d.ts +24 -0
- package/dist/esm/errors/client.js +24 -0
- package/dist/esm/errors/client.js.map +1 -1
- package/dist/esm/errors/entrypoint.d.ts +18 -0
- package/dist/esm/errors/entrypoint.js +18 -0
- package/dist/esm/errors/entrypoint.js.map +1 -1
- package/dist/esm/errors/signer.d.ts +8 -0
- package/dist/esm/errors/signer.js +8 -0
- package/dist/esm/errors/signer.js.map +1 -1
- package/dist/esm/errors/transaction.d.ts +14 -1
- package/dist/esm/errors/transaction.js +14 -1
- package/dist/esm/errors/transaction.js.map +1 -1
- package/dist/esm/errors/useroperation.d.ts +25 -0
- package/dist/esm/errors/useroperation.js +26 -0
- package/dist/esm/errors/useroperation.js.map +1 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logger.d.ts +91 -0
- package/dist/esm/logger.js +91 -0
- package/dist/esm/logger.js.map +1 -1
- package/dist/esm/middleware/actions.d.ts +14 -0
- package/dist/esm/middleware/actions.js +7 -0
- package/dist/esm/middleware/actions.js.map +1 -1
- package/dist/esm/middleware/defaults/feeEstimator.d.ts +20 -0
- package/dist/esm/middleware/defaults/feeEstimator.js +28 -0
- package/dist/esm/middleware/defaults/feeEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/gasEstimator.d.ts +8 -0
- package/dist/esm/middleware/defaults/gasEstimator.js +8 -0
- package/dist/esm/middleware/defaults/gasEstimator.js.map +1 -1
- package/dist/esm/middleware/defaults/paymasterAndData.d.ts +8 -0
- package/dist/esm/middleware/defaults/paymasterAndData.js +8 -0
- package/dist/esm/middleware/defaults/paymasterAndData.js.map +1 -1
- package/dist/esm/middleware/defaults/userOpSigner.d.ts +10 -0
- package/dist/esm/middleware/defaults/userOpSigner.js +10 -0
- package/dist/esm/middleware/defaults/userOpSigner.js.map +1 -1
- package/dist/esm/middleware/erc7677middleware.d.ts +21 -0
- package/dist/esm/middleware/erc7677middleware.js +23 -0
- package/dist/esm/middleware/erc7677middleware.js.map +1 -1
- package/dist/esm/middleware/noopMiddleware.d.ts +6 -0
- package/dist/esm/middleware/noopMiddleware.js +6 -0
- package/dist/esm/middleware/noopMiddleware.js.map +1 -1
- package/dist/esm/middleware/types.js +1 -0
- package/dist/esm/middleware/types.js.map +1 -1
- package/dist/esm/signer/local-account.d.ts +96 -1
- package/dist/esm/signer/local-account.js +97 -2
- package/dist/esm/signer/local-account.js.map +1 -1
- package/dist/esm/signer/schema.d.ts +14 -0
- package/dist/esm/signer/schema.js +14 -0
- package/dist/esm/signer/schema.js.map +1 -1
- package/dist/esm/signer/types.d.ts +12 -0
- package/dist/esm/signer/types.js +1 -0
- package/dist/esm/signer/types.js.map +1 -1
- package/dist/esm/signer/utils.d.ts +20 -0
- package/dist/esm/signer/utils.js +27 -0
- package/dist/esm/signer/utils.js.map +1 -1
- package/dist/esm/signer/wallet-client.d.ts +92 -0
- package/dist/esm/signer/wallet-client.js +92 -0
- package/dist/esm/signer/wallet-client.js.map +1 -1
- package/dist/esm/transport/split.d.ts +32 -0
- package/dist/esm/transport/split.js +32 -0
- package/dist/esm/transport/split.js.map +1 -1
- package/dist/esm/types.d.ts +17 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/bigint.d.ts +45 -0
- package/dist/esm/utils/bigint.js +46 -0
- package/dist/esm/utils/bigint.js.map +1 -1
- package/dist/esm/utils/bytes.d.ts +9 -0
- package/dist/esm/utils/bytes.js +10 -1
- package/dist/esm/utils/bytes.js.map +1 -1
- package/dist/esm/utils/index.d.ts +86 -0
- package/dist/esm/utils/index.js +86 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/schema.d.ts +3 -0
- package/dist/esm/utils/schema.js +9 -0
- package/dist/esm/utils/schema.js.map +1 -1
- package/dist/esm/utils/stateOverride.js +2 -0
- package/dist/esm/utils/stateOverride.js.map +1 -1
- package/dist/esm/utils/types.d.ts +22 -0
- package/dist/esm/utils/types.js +1 -0
- package/dist/esm/utils/types.js.map +1 -1
- package/dist/esm/utils/userop.d.ts +79 -0
- package/dist/esm/utils/userop.js +83 -0
- package/dist/esm/utils/userop.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +3 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/account/smartContractAccount.d.ts +1 -1
- package/dist/types/account/smartContractAccount.d.ts.map +1 -1
- package/dist/types/actions/smartAccount/dropAndReplaceUserOperation.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/transport/split.d.ts +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +10 -11
- package/src/account/smartContractAccount.ts +3 -3
- package/src/actions/smartAccount/dropAndReplaceUserOperation.ts +10 -10
- package/src/actions/smartAccount/internal/initUserOperation.ts +1 -1
- package/src/client/smartAccountClient.ts +7 -0
- package/src/index.ts +0 -1
- package/src/transport/split.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/cjs/abis/EntryPointAbi_v6.d.ts +0 -1018
- package/dist/cjs/abis/EntryPointAbi_v6.js +0 -1313
- package/dist/cjs/abis/EntryPointAbi_v6.js.map +0 -1
- package/dist/cjs/abis/EntryPointAbi_v7.d.ts +0 -775
- package/dist/cjs/abis/EntryPointAbi_v7.js +0 -661
- package/dist/cjs/abis/EntryPointAbi_v7.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountAbi_v6.d.ts +0 -405
- package/dist/cjs/abis/SimpleAccountAbi_v6.js +0 -528
- package/dist/cjs/abis/SimpleAccountAbi_v6.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountAbi_v7.d.ts +0 -410
- package/dist/cjs/abis/SimpleAccountAbi_v7.js +0 -538
- package/dist/cjs/abis/SimpleAccountAbi_v7.js.map +0 -1
- package/dist/cjs/abis/SimpleAccountFactoryAbi.d.ts +0 -55
- package/dist/cjs/abis/SimpleAccountFactoryAbi.js +0 -78
- package/dist/cjs/abis/SimpleAccountFactoryAbi.js.map +0 -1
- package/dist/cjs/account/smartContractAccount.d.ts +0 -74
- package/dist/cjs/account/smartContractAccount.js +0 -180
- package/dist/cjs/account/smartContractAccount.js.map +0 -1
- package/dist/cjs/actions/bundler/estimateUserOperationGas.d.ts +0 -8
- package/dist/cjs/actions/bundler/estimateUserOperationGas.js +0 -18
- package/dist/cjs/actions/bundler/estimateUserOperationGas.js.map +0 -1
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.d.ts +0 -3
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.js +0 -11
- package/dist/cjs/actions/bundler/getSupportedEntryPoints.js.map +0 -1
- package/dist/cjs/actions/bundler/getUserOperationByHash.d.ts +0 -6
- package/dist/cjs/actions/bundler/getUserOperationByHash.js +0 -11
- package/dist/cjs/actions/bundler/getUserOperationByHash.js.map +0 -1
- package/dist/cjs/actions/bundler/getUserOperationReceipt.d.ts +0 -6
- package/dist/cjs/actions/bundler/getUserOperationReceipt.js +0 -11
- package/dist/cjs/actions/bundler/getUserOperationReceipt.js.map +0 -1
- package/dist/cjs/actions/bundler/sendRawUserOperation.d.ts +0 -7
- package/dist/cjs/actions/bundler/sendRawUserOperation.js +0 -11
- package/dist/cjs/actions/bundler/sendRawUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/buildUserOperation.js +0 -25
- package/dist/cjs/actions/smartAccount/buildUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js +0 -39
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTx.js.map +0 -1
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js +0 -62
- package/dist/cjs/actions/smartAccount/buildUserOperationFromTxs.js.map +0 -1
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js +0 -34
- package/dist/cjs/actions/smartAccount/checkGasSponsorshipEligibility.js.map +0 -1
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js +0 -64
- package/dist/cjs/actions/smartAccount/dropAndReplaceUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js +0 -23
- package/dist/cjs/actions/smartAccount/estimateUserOperationGas.js.map +0 -1
- package/dist/cjs/actions/smartAccount/getAddress.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/getAddress.js +0 -13
- package/dist/cjs/actions/smartAccount/getAddress.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.d.ts +0 -7
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js +0 -42
- package/dist/cjs/actions/smartAccount/internal/initUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js +0 -47
- package/dist/cjs/actions/smartAccount/internal/runMiddlewareStack.js.map +0 -1
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js +0 -28
- package/dist/cjs/actions/smartAccount/internal/sendUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendTransaction.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/sendTransaction.js +0 -35
- package/dist/cjs/actions/smartAccount/sendTransaction.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendTransactions.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/sendTransactions.js +0 -36
- package/dist/cjs/actions/smartAccount/sendTransactions.js.map +0 -1
- package/dist/cjs/actions/smartAccount/sendUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/sendUserOperation.js +0 -31
- package/dist/cjs/actions/smartAccount/sendUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signMessage.d.ts +0 -6
- package/dist/cjs/actions/smartAccount/signMessage.js +0 -12
- package/dist/cjs/actions/smartAccount/signMessage.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signMessageWith6492.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/signMessageWith6492.js +0 -12
- package/dist/cjs/actions/smartAccount/signMessageWith6492.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signTypedData.d.ts +0 -10
- package/dist/cjs/actions/smartAccount/signTypedData.js +0 -12
- package/dist/cjs/actions/smartAccount/signTypedData.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.d.ts +0 -6
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js +0 -12
- package/dist/cjs/actions/smartAccount/signTypedDataWith6492.js.map +0 -1
- package/dist/cjs/actions/smartAccount/signUserOperation.d.ts +0 -5
- package/dist/cjs/actions/smartAccount/signUserOperation.js +0 -30
- package/dist/cjs/actions/smartAccount/signUserOperation.js.map +0 -1
- package/dist/cjs/actions/smartAccount/types.d.ts +0 -42
- package/dist/cjs/actions/smartAccount/types.js +0 -3
- package/dist/cjs/actions/smartAccount/types.js.map +0 -1
- package/dist/cjs/actions/smartAccount/upgradeAccount.d.ts +0 -4
- package/dist/cjs/actions/smartAccount/upgradeAccount.js +0 -38
- package/dist/cjs/actions/smartAccount/upgradeAccount.js.map +0 -1
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.d.ts +0 -3
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js +0 -36
- package/dist/cjs/actions/smartAccount/waitForUserOperationTransacation.js.map +0 -1
- package/dist/cjs/client/bundlerClient.d.ts +0 -10
- package/dist/cjs/client/bundlerClient.js +0 -51
- package/dist/cjs/client/bundlerClient.js.map +0 -1
- package/dist/cjs/client/decorators/bundlerClient.d.ts +0 -41
- package/dist/cjs/client/decorators/bundlerClient.js +0 -17
- package/dist/cjs/client/decorators/bundlerClient.js.map +0 -1
- package/dist/cjs/client/decorators/smartAccountClient.d.ts +0 -35
- package/dist/cjs/client/decorators/smartAccountClient.js +0 -43
- package/dist/cjs/client/decorators/smartAccountClient.js.map +0 -1
- package/dist/cjs/client/isSmartAccountClient.d.ts +0 -5
- package/dist/cjs/client/isSmartAccountClient.js +0 -18
- package/dist/cjs/client/isSmartAccountClient.js.map +0 -1
- package/dist/cjs/client/schema.d.ts +0 -767
- package/dist/cjs/client/schema.js +0 -63
- package/dist/cjs/client/schema.js.map +0 -1
- package/dist/cjs/client/smartAccountClient.d.ts +0 -33
- package/dist/cjs/client/smartAccountClient.js +0 -93
- package/dist/cjs/client/smartAccountClient.js.map +0 -1
- package/dist/cjs/client/types.d.ts +0 -21
- package/dist/cjs/client/types.js +0 -3
- package/dist/cjs/client/types.js.map +0 -1
- package/dist/cjs/ens/utils.d.ts +0 -6
- package/dist/cjs/ens/utils.js +0 -53
- package/dist/cjs/ens/utils.js.map +0 -1
- package/dist/cjs/entrypoint/0.6.d.ts +0 -1029
- package/dist/cjs/entrypoint/0.6.js +0 -49
- package/dist/cjs/entrypoint/0.6.js.map +0 -1
- package/dist/cjs/entrypoint/0.7.d.ts +0 -792
- package/dist/cjs/entrypoint/0.7.js +0 -88
- package/dist/cjs/entrypoint/0.7.js.map +0 -1
- package/dist/cjs/entrypoint/index.d.ts +0 -8
- package/dist/cjs/entrypoint/index.js +0 -53
- package/dist/cjs/entrypoint/index.js.map +0 -1
- package/dist/cjs/entrypoint/types.d.ts +0 -46
- package/dist/cjs/entrypoint/types.js +0 -3
- package/dist/cjs/entrypoint/types.js.map +0 -1
- package/dist/cjs/errors/account.d.ts +0 -47
- package/dist/cjs/errors/account.js +0 -140
- package/dist/cjs/errors/account.js.map +0 -1
- package/dist/cjs/errors/base.d.ts +0 -18
- package/dist/cjs/errors/base.js +0 -39
- package/dist/cjs/errors/base.js.map +0 -1
- package/dist/cjs/errors/client.d.ts +0 -14
- package/dist/cjs/errors/client.js +0 -44
- package/dist/cjs/errors/client.js.map +0 -1
- package/dist/cjs/errors/entrypoint.d.ts +0 -10
- package/dist/cjs/errors/entrypoint.js +0 -32
- package/dist/cjs/errors/entrypoint.js.map +0 -1
- package/dist/cjs/errors/signer.d.ts +0 -5
- package/dist/cjs/errors/signer.js +0 -20
- package/dist/cjs/errors/signer.js.map +0 -1
- package/dist/cjs/errors/transaction.d.ts +0 -10
- package/dist/cjs/errors/transaction.js +0 -29
- package/dist/cjs/errors/transaction.js.map +0 -1
- package/dist/cjs/errors/useroperation.d.ts +0 -10
- package/dist/cjs/errors/useroperation.js +0 -34
- package/dist/cjs/errors/useroperation.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -60
- package/dist/cjs/index.js +0 -170
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/logger.d.ts +0 -20
- package/dist/cjs/logger.js +0 -60
- package/dist/cjs/logger.js.map +0 -1
- package/dist/cjs/middleware/actions.d.ts +0 -12
- package/dist/cjs/middleware/actions.js +0 -21
- package/dist/cjs/middleware/actions.js.map +0 -1
- package/dist/cjs/middleware/defaults/feeEstimator.d.ts +0 -3
- package/dist/cjs/middleware/defaults/feeEstimator.js +0 -23
- package/dist/cjs/middleware/defaults/feeEstimator.js.map +0 -1
- package/dist/cjs/middleware/defaults/gasEstimator.d.ts +0 -3
- package/dist/cjs/middleware/defaults/gasEstimator.js +0 -28
- package/dist/cjs/middleware/defaults/gasEstimator.js.map +0 -1
- package/dist/cjs/middleware/defaults/paymasterAndData.d.ts +0 -2
- package/dist/cjs/middleware/defaults/paymasterAndData.js +0 -12
- package/dist/cjs/middleware/defaults/paymasterAndData.js.map +0 -1
- package/dist/cjs/middleware/defaults/userOpSigner.d.ts +0 -2
- package/dist/cjs/middleware/defaults/userOpSigner.js +0 -26
- package/dist/cjs/middleware/defaults/userOpSigner.js.map +0 -1
- package/dist/cjs/middleware/erc7677middleware.d.ts +0 -40
- package/dist/cjs/middleware/erc7677middleware.js +0 -77
- package/dist/cjs/middleware/erc7677middleware.js.map +0 -1
- package/dist/cjs/middleware/noopMiddleware.d.ts +0 -3
- package/dist/cjs/middleware/noopMiddleware.js +0 -8
- package/dist/cjs/middleware/noopMiddleware.js.map +0 -1
- package/dist/cjs/middleware/types.d.ts +0 -22
- package/dist/cjs/middleware/types.js +0 -3
- package/dist/cjs/middleware/types.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/signer/local-account.d.ts +0 -219
- package/dist/cjs/signer/local-account.js +0 -56
- package/dist/cjs/signer/local-account.js.map +0 -1
- package/dist/cjs/signer/schema.d.ts +0 -4
- package/dist/cjs/signer/schema.js +0 -16
- package/dist/cjs/signer/schema.js.map +0 -1
- package/dist/cjs/signer/types.d.ts +0 -15
- package/dist/cjs/signer/types.js +0 -3
- package/dist/cjs/signer/types.js.map +0 -1
- package/dist/cjs/signer/utils.d.ts +0 -7
- package/dist/cjs/signer/utils.js +0 -16
- package/dist/cjs/signer/utils.js.map +0 -1
- package/dist/cjs/signer/wallet-client.d.ts +0 -217
- package/dist/cjs/signer/wallet-client.js +0 -58
- package/dist/cjs/signer/wallet-client.js.map +0 -1
- package/dist/cjs/transport/split.d.ts +0 -9
- package/dist/cjs/transport/split.js +0 -26
- package/dist/cjs/transport/split.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -158
- package/dist/cjs/types.js +0 -3
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/utils/bigint.d.ts +0 -10
- package/dist/cjs/utils/bigint.js +0 -55
- package/dist/cjs/utils/bigint.js.map +0 -1
- package/dist/cjs/utils/bytes.d.ts +0 -7
- package/dist/cjs/utils/bytes.js +0 -11
- package/dist/cjs/utils/bytes.js.map +0 -1
- package/dist/cjs/utils/defaults.d.ts +0 -4
- package/dist/cjs/utils/defaults.js +0 -19
- package/dist/cjs/utils/defaults.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -19
- package/dist/cjs/utils/index.js +0 -95
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/schema.d.ts +0 -25
- package/dist/cjs/utils/schema.js +0 -35
- package/dist/cjs/utils/schema.js.map +0 -1
- package/dist/cjs/utils/stateOverride.d.ts +0 -4
- package/dist/cjs/utils/stateOverride.js +0 -52
- package/dist/cjs/utils/stateOverride.js.map +0 -1
- package/dist/cjs/utils/testUtils.d.ts +0 -6
- package/dist/cjs/utils/testUtils.js +0 -33
- package/dist/cjs/utils/testUtils.js.map +0 -1
- package/dist/cjs/utils/types.d.ts +0 -16
- package/dist/cjs/utils/types.js +0 -3
- package/dist/cjs/utils/types.js.map +0 -1
- package/dist/cjs/utils/userop.d.ts +0 -49
- package/dist/cjs/utils/userop.js +0 -75
- package/dist/cjs/utils/userop.js.map +0 -1
- package/dist/cjs/version.d.ts +0 -1
- package/dist/cjs/version.js +0 -5
- package/dist/cjs/version.js.map +0 -1
- package/dist/esm/package.json +0 -1
package/dist/esm/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,uCAAQ,CAAA;AACV,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;IACT,uCAAQ,CAAA;AACV,CAAC,EAPW,QAAQ,KAAR,QAAQ,QAOnB;AAED;;GAEG;AACH,MAAM,OAAO,MAAM;IAIjB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAAC,QAAkB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,YAAY,CAAC,OAAe;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,KAAK,CAAC,GAAW,EAAE,GAAG,IAAW;QACtC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO;QAEjD,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,IAAI,CAAC,GAAW,EAAE,GAAG,IAAW;QACrC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC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= 4,\n INFO = 3,\n WARN = 2,\n ERROR = 1,\n NONE = 0,\n}\n\n/**\n * Logger class provides static methods for logging at different levels such as error, warn, debug, info, and verbose. This class allows setting log levels and log filters to control the logging behavior.\n */\nexport class Logger {\n static logLevel: LogLevel = LogLevel.INFO;\n static logFilter?: string;\n\n /**\n * Sets the log level for logging purposes.\n *\n * @example\n * ```ts\n * import { Logger, LogLevel } from \"@aa-sdk/core\";\n * Logger.setLogLevel(LogLevel.DEBUG);\n * ```\n *\n * @param {LogLevel} logLevel The desired log level\n */\n static setLogLevel(logLevel: LogLevel) {\n this.logLevel = logLevel;\n }\n\n /**\n * Sets the log filter pattern.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.setLogFilter(\"error\");\n * ```\n *\n * @param {string} pattern The pattern to set as the log filter\n */\n static setLogFilter(pattern: string) {\n this.logFilter = pattern;\n }\n\n /**\n * Logs an error message to the console if the logging condition is met.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.error(\"An error occurred while processing the request\");\n * ```\n *\n * @param {string} msg The primary error message to be logged\n * @param {...any[]} args Additional arguments to be logged along with the error message\n */\n static error(msg: string, ...args: any[]) {\n if (!this.shouldLog(msg, LogLevel.ERROR)) return;\n\n console.error(msg, ...args);\n }\n\n /**\n * Logs a warning message if the logging conditions are met.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.warn(\"Careful...\");\n * ```\n *\n * @param {string} msg The message to log as a warning\n * @param {...any[]} args Additional parameters to log along with the message\n */\n static warn(msg: string, ...args: any[]) {\n if (!this.shouldLog(msg, LogLevel.WARN)) return;\n\n console.warn(msg, ...args);\n }\n\n /**\n * Logs a debug message to the console if the log level allows it.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.debug(\"Something is happening\");\n * ```\n *\n * @param {string} msg The message to log\n * @param {...any[]} args Additional arguments to pass to the console.debug method\n */\n static debug(msg: string, ...args: any[]) {\n if (!this.shouldLog(msg, LogLevel.DEBUG)) return;\n\n console.debug(msg, ...args);\n }\n\n /**\n * Logs an informational message to the console if the logging level is set to INFO.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.info(\"Something is happening\");\n * ```\n *\n * @param {string} msg the message to log\n * @param {...any[]} args additional arguments to log alongside the message\n */\n static info(msg: string, ...args: any[]) {\n if (!this.shouldLog(msg, LogLevel.INFO)) return;\n\n console.info(msg, ...args);\n }\n\n /**\n * Logs a message with additional arguments if the logging level permits it.\n *\n * @example\n * ```ts\n * import { Logger } from \"@aa-sdk/core\";\n *\n * Logger.verbose(\"Something is happening\");\n * ```\n *\n * @param {string} msg The message to log\n * @param {...any[]} args Additional arguments to be logged\n */\n static verbose(msg: string, ...args: any[]) {\n if (!this.shouldLog(msg, LogLevel.VERBOSE)) return;\n\n console.log(msg, ...args);\n }\n\n private static shouldLog(msg: string, level: LogLevel) {\n if (this.logLevel < level) return false;\n if (this.logFilter && !msg.includes(this.logFilter)) return false;\n\n return true;\n }\n}\n"]}
|
|
@@ -3,10 +3,24 @@ import type { SmartContractAccount } from "../account/smartContractAccount.js";
|
|
|
3
3
|
import type { BundlerActions, BundlerRpcSchema } from "../client/decorators/bundlerClient.js";
|
|
4
4
|
import type { ClientMiddlewareConfig } from "../client/types.js";
|
|
5
5
|
import type { ClientMiddleware } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Middleware client type
|
|
8
|
+
*
|
|
9
|
+
* @template {Transport} TTransport
|
|
10
|
+
* @template {Chain | undefined} TChain
|
|
11
|
+
* @template {SmartContractAccount | undefined} TAccount
|
|
12
|
+
*/
|
|
6
13
|
export type MiddlewareClient<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined> = Client<TTransport, TChain, TAccount, [
|
|
7
14
|
...BundlerRpcSchema,
|
|
8
15
|
...PublicRpcSchema
|
|
9
16
|
], PublicActions & BundlerActions>;
|
|
17
|
+
/**
|
|
18
|
+
* function that takes in ClientMiddlewareConfig used during client initiation
|
|
19
|
+
* and returns the middleware actions object that the smart account client extends with
|
|
20
|
+
*
|
|
21
|
+
* @param {ClientMiddlewareConfig} overrides config used during client initiation for overriding default middlewares
|
|
22
|
+
* @returns {(client: MiddlewareClient<TTransport, TChain, TAccount>) => { middleware: ClientMiddleware }} middleware actions object
|
|
23
|
+
*/
|
|
10
24
|
export declare const middlewareActions: (overrides: ClientMiddlewareConfig) => <TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartContractAccount | undefined = SmartContractAccount | undefined>(client: MiddlewareClient<TTransport, TChain, TAccount>) => {
|
|
11
25
|
middleware: ClientMiddleware;
|
|
12
26
|
};
|
|
@@ -4,6 +4,13 @@ import { defaultGasEstimator } from "./defaults/gasEstimator.js";
|
|
|
4
4
|
import { defaultPaymasterAndData } from "./defaults/paymasterAndData.js";
|
|
5
5
|
import { defaultUserOpSigner } from "./defaults/userOpSigner.js";
|
|
6
6
|
import { noopMiddleware } from "./noopMiddleware.js";
|
|
7
|
+
/**
|
|
8
|
+
* function that takes in ClientMiddlewareConfig used during client initiation
|
|
9
|
+
* and returns the middleware actions object that the smart account client extends with
|
|
10
|
+
*
|
|
11
|
+
* @param {ClientMiddlewareConfig} overrides config used during client initiation for overriding default middlewares
|
|
12
|
+
* @returns {(client: MiddlewareClient<TTransport, TChain, TAccount>) => { middleware: ClientMiddleware }} middleware actions object
|
|
13
|
+
*/
|
|
7
14
|
export const middlewareActions = (overrides) => (client) => ({
|
|
8
15
|
middleware: {
|
|
9
16
|
customMiddleware: overrides.customMiddleware ?? noopMiddleware,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/middleware/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,MAAM,CAAC;AAOd,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/middleware/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAMN,MAAM,MAAM,CAAC;AAOd,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAwBrD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,CAAC,SAAiC,EAAE,EAAE,CACtC,CAOE,MAAsD,EACpB,EAAE,CAAC,CAAC;IACtC,UAAU,EAAE;QACV,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,IAAI,cAAc;QAC9D,qBAAqB,EACnB,SAAS,CAAC,qBAAqB,IAAI,uBAAuB;QAC5D,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC;QACnE,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,mBAAmB,CAAC,MAAM,CAAC;QACnE,gBAAgB,EAAE,SAAS,CAAC,gBAAgB,IAAI,uBAAuB;QACvE,sBAAsB,EACpB,SAAS,CAAC,sBAAsB,IAAI,cAAc;QACpD,iBAAiB,EAAE,SAAS,CAAC,iBAAiB,IAAI,mBAAmB;KACtE;CACF,CAAC,CAAC","sourcesContent":["import {\n type Chain,\n type Client,\n type PublicActions,\n type PublicRpcSchema,\n type Transport,\n} from \"viem\";\nimport type { SmartContractAccount } from \"../account/smartContractAccount.js\";\nimport type {\n BundlerActions,\n BundlerRpcSchema,\n} from \"../client/decorators/bundlerClient.js\";\nimport type { ClientMiddlewareConfig } from \"../client/types.js\";\nimport { defaultFeeEstimator } from \"./defaults/feeEstimator.js\";\nimport { defaultGasEstimator } from \"./defaults/gasEstimator.js\";\nimport { defaultPaymasterAndData } from \"./defaults/paymasterAndData.js\";\nimport { defaultUserOpSigner } from \"./defaults/userOpSigner.js\";\nimport { noopMiddleware } from \"./noopMiddleware.js\";\nimport type { ClientMiddleware } from \"./types.js\";\n\n/**\n * Middleware client type\n *\n * @template {Transport} TTransport\n * @template {Chain | undefined} TChain\n * @template {SmartContractAccount | undefined} TAccount\n */\nexport type MiddlewareClient<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n> = Client<\n TTransport,\n TChain,\n TAccount,\n [...BundlerRpcSchema, ...PublicRpcSchema],\n PublicActions & BundlerActions\n>;\n\n/**\n * function that takes in ClientMiddlewareConfig used during client initiation\n * and returns the middleware actions object that the smart account client extends with\n *\n * @param {ClientMiddlewareConfig} overrides config used during client initiation for overriding default middlewares\n * @returns {(client: MiddlewareClient<TTransport, TChain, TAccount>) => { middleware: ClientMiddleware }} middleware actions object\n */\nexport const middlewareActions =\n (overrides: ClientMiddlewareConfig) =>\n <\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined\n >(\n client: MiddlewareClient<TTransport, TChain, TAccount>\n ): { middleware: ClientMiddleware } => ({\n middleware: {\n customMiddleware: overrides.customMiddleware ?? noopMiddleware,\n dummyPaymasterAndData:\n overrides.dummyPaymasterAndData ?? defaultPaymasterAndData,\n feeEstimator: overrides.feeEstimator ?? defaultFeeEstimator(client),\n gasEstimator: overrides.gasEstimator ?? defaultGasEstimator(client),\n paymasterAndData: overrides.paymasterAndData ?? defaultPaymasterAndData,\n userOperationSimulator:\n overrides.userOperationSimulator ?? noopMiddleware,\n signUserOperation: overrides.signUserOperation ?? defaultUserOpSigner,\n },\n });\n"]}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
1
|
import type { MiddlewareClient } from "../actions";
|
|
2
2
|
import type { ClientMiddlewareFn } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Default fee estimator middleware function that estimates the maximum fee per gas and maximum priority fee per gas for a given client and applies the necessary overrides and fee options.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { createSmartAccountClient, defaultFeeEstimator, createBundlerClient } from "@aa-sdk/core";
|
|
9
|
+
*
|
|
10
|
+
* const bundlerClient = createBundlerClient(...);
|
|
11
|
+
*
|
|
12
|
+
* // NOTE: this is already provided by the smart account client
|
|
13
|
+
* const client = createSmartAccountClient({
|
|
14
|
+
* feeEstimator: defaultFeeEstimator(bundlerClient),
|
|
15
|
+
* ...otherParams
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @template {MiddlewareClient} C The type of the client
|
|
20
|
+
* @param {C} client The client to perform the fee estimation
|
|
21
|
+
* @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees
|
|
22
|
+
*/
|
|
3
23
|
export declare function defaultFeeEstimator<C extends MiddlewareClient>(client: C): ClientMiddlewareFn;
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import { applyUserOpOverrideOrFeeOption } from "../../utils/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default fee estimator middleware function that estimates the maximum fee per gas and maximum priority fee per gas for a given client and applies the necessary overrides and fee options.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { createSmartAccountClient, defaultFeeEstimator, createBundlerClient } from "@aa-sdk/core";
|
|
8
|
+
*
|
|
9
|
+
* const bundlerClient = createBundlerClient(...);
|
|
10
|
+
*
|
|
11
|
+
* // NOTE: this is already provided by the smart account client
|
|
12
|
+
* const client = createSmartAccountClient({
|
|
13
|
+
* feeEstimator: defaultFeeEstimator(bundlerClient),
|
|
14
|
+
* ...otherParams
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @template {MiddlewareClient} C The type of the client
|
|
19
|
+
* @param {C} client The client to perform the fee estimation
|
|
20
|
+
* @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees
|
|
21
|
+
*/
|
|
2
22
|
export function defaultFeeEstimator(client) {
|
|
3
23
|
return async (struct, { overrides, feeOptions }) => {
|
|
24
|
+
// maxFeePerGas must be at least the sum of maxPriorityFeePerGas and baseFee
|
|
25
|
+
// so we need to accommodate for the fee option applied maxPriorityFeePerGas for the maxFeePerGas
|
|
26
|
+
//
|
|
27
|
+
// Note that if maxFeePerGas is not at least the sum of maxPriorityFeePerGas and required baseFee
|
|
28
|
+
// after applying the fee options, then the transaction will fail
|
|
29
|
+
//
|
|
30
|
+
// Refer to https://docs.alchemy.com/docs/maxpriorityfeepergas-vs-maxfeepergas
|
|
31
|
+
// for more information about maxFeePerGas and maxPriorityFeePerGas
|
|
4
32
|
const feeData = await client.estimateFeesPerGas();
|
|
5
33
|
if (!feeData.maxFeePerGas || feeData.maxPriorityFeePerGas == null) {
|
|
6
34
|
throw new Error("feeData is missing maxFeePerGas or maxPriorityFeePerGas");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/feeEstimator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"feeEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/feeEstimator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAS;IAET,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,EAAE;QACjD,4EAA4E;QAC5E,iGAAiG;QACjG,EAAE;QACF,iGAAiG;QACjG,iEAAiE;QACjE,EAAE;QACF,8EAA8E;QAC9E,mEAAmE;QAEnE,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAClD,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,oBAAoB,IAAI,IAAI,EAAE,CAAC;YAClE,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,oBAAoB,GACtB,MAAM,MAAM,CAAC,4BAA4B,EAAE,CAAC;QAE9C,oBAAoB,GAAG,8BAA8B,CACnD,oBAAoB,EACpB,SAAS,EAAE,oBAAoB,EAC/B,UAAU,EAAE,oBAAoB,CACjC,CAAC;QAEF,IAAI,YAAY,GACd,OAAO,CAAC,YAAY;YACpB,OAAO,CAAC,oBAAoB;YAC5B,MAAM,CAAC,oBAAoB,CAAC,CAAC;QAE/B,YAAY,GAAG,8BAA8B,CAC3C,YAAY,EACZ,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,YAAY,CACzB,CAAC;QAEF,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;QACnC,MAAM,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACnD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { BigNumberish } from \"../../types\";\nimport { applyUserOpOverrideOrFeeOption } from \"../../utils/index.js\";\nimport type { MiddlewareClient } from \"../actions\";\nimport type { ClientMiddlewareFn } from \"../types\";\n\n/**\n * Default fee estimator middleware function that estimates the maximum fee per gas and maximum priority fee per gas for a given client and applies the necessary overrides and fee options.\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, defaultFeeEstimator, createBundlerClient } from \"@aa-sdk/core\";\n *\n * const bundlerClient = createBundlerClient(...);\n *\n * // NOTE: this is already provided by the smart account client\n * const client = createSmartAccountClient({\n * feeEstimator: defaultFeeEstimator(bundlerClient),\n * ...otherParams\n * });\n * ```\n *\n * @template {MiddlewareClient} C The type of the client\n * @param {C} client The client to perform the fee estimation\n * @returns {ClientMiddlewareFn} A middleware function that takes in the struct and options, estimates the fees, and updates the struct with the estimated fees\n */\nexport function defaultFeeEstimator<C extends MiddlewareClient>(\n client: C\n): ClientMiddlewareFn {\n return async (struct, { overrides, feeOptions }) => {\n // maxFeePerGas must be at least the sum of maxPriorityFeePerGas and baseFee\n // so we need to accommodate for the fee option applied maxPriorityFeePerGas for the maxFeePerGas\n //\n // Note that if maxFeePerGas is not at least the sum of maxPriorityFeePerGas and required baseFee\n // after applying the fee options, then the transaction will fail\n //\n // Refer to https://docs.alchemy.com/docs/maxpriorityfeepergas-vs-maxfeepergas\n // for more information about maxFeePerGas and maxPriorityFeePerGas\n\n const feeData = await client.estimateFeesPerGas();\n if (!feeData.maxFeePerGas || feeData.maxPriorityFeePerGas == null) {\n throw new Error(\n \"feeData is missing maxFeePerGas or maxPriorityFeePerGas\"\n );\n }\n\n let maxPriorityFeePerGas: BigNumberish =\n await client.estimateMaxPriorityFeePerGas();\n\n maxPriorityFeePerGas = applyUserOpOverrideOrFeeOption(\n maxPriorityFeePerGas,\n overrides?.maxPriorityFeePerGas,\n feeOptions?.maxPriorityFeePerGas\n );\n\n let maxFeePerGas: BigNumberish =\n feeData.maxFeePerGas -\n feeData.maxPriorityFeePerGas +\n BigInt(maxPriorityFeePerGas);\n\n maxFeePerGas = applyUserOpOverrideOrFeeOption(\n maxFeePerGas,\n overrides?.maxFeePerGas,\n feeOptions?.maxFeePerGas\n );\n\n struct.maxFeePerGas = maxFeePerGas;\n struct.maxPriorityFeePerGas = maxPriorityFeePerGas;\n return struct;\n };\n}\n"]}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { MiddlewareClient } from "../actions.js";
|
|
2
2
|
import type { ClientMiddlewareFn } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Description default gas estimator middleware for `SmartAccountClient`
|
|
5
|
+
* You can override this middleware with your custom gas estimator middleware
|
|
6
|
+
* by passing it to the client constructor
|
|
7
|
+
*
|
|
8
|
+
* @param {MiddlewareClient} client smart account client instance to apply the middleware to
|
|
9
|
+
* @returns {ClientMiddlewareFn} middleware execution function used to estimate gas for user operations
|
|
10
|
+
*/
|
|
3
11
|
export declare const defaultGasEstimator: <C extends MiddlewareClient>(client: C) => ClientMiddlewareFn;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { deepHexlify, resolveProperties } from "../../utils/index.js";
|
|
2
2
|
import { applyUserOpOverrideOrFeeOption } from "../../utils/userop.js";
|
|
3
|
+
/**
|
|
4
|
+
* Description default gas estimator middleware for `SmartAccountClient`
|
|
5
|
+
* You can override this middleware with your custom gas estimator middleware
|
|
6
|
+
* by passing it to the client constructor
|
|
7
|
+
*
|
|
8
|
+
* @param {MiddlewareClient} client smart account client instance to apply the middleware to
|
|
9
|
+
* @returns {ClientMiddlewareFn} middleware execution function used to estimate gas for user operations
|
|
10
|
+
*/
|
|
3
11
|
export const defaultGasEstimator = (client) => async (struct, { account, overrides, feeOptions }) => {
|
|
4
12
|
const request = deepHexlify(await resolveProperties(struct));
|
|
5
13
|
const estimates = await client.estimateUserOperationGas(request, account.getEntryPoint().address, overrides?.stateOverride);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gasEstimator.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/gasEstimator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;
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AM,6BAA6B,GAAG,8BAA8B,CAClE,SAAS,CAAC,6BAA6B,EACtC,SAA6C;YAC5C,EAAE,6BAA6B,EAChC,UAA+C;YAC9C,EAAE,6BAA6B,CAClC,CAAC;QACF,MAAM,KAAK,GAAG,MAAsC,CAAC;QAErD,KAAK,CAAC,6BAA6B,GAAG,6BAA6B,CAAC;QAEpE,KAAK,CAAC,uBAAuB;YAC3B,KAAK,CAAC,uBAAuB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../../types.js\";\nimport { deepHexlify, resolveProperties } from \"../../utils/index.js\";\nimport { applyUserOpOverrideOrFeeOption } from \"../../utils/userop.js\";\nimport type { MiddlewareClient } from \"../actions.js\";\nimport type { ClientMiddlewareFn } from \"../types.js\";\n\n/**\n * Description default gas estimator middleware for `SmartAccountClient`\n * You can override this middleware with your custom gas estimator middleware\n * by passing it to the client constructor\n *\n * @param {MiddlewareClient} client smart account client instance to apply the middleware to\n * @returns {ClientMiddlewareFn} middleware execution function used to estimate gas for user operations\n */\nexport const defaultGasEstimator: <C extends MiddlewareClient>(\n client: C\n) => ClientMiddlewareFn =\n (client: MiddlewareClient): ClientMiddlewareFn =>\n async (struct, { account, overrides, feeOptions }) => {\n const request = deepHexlify(await resolveProperties(struct));\n\n const estimates = await client.estimateUserOperationGas(\n request,\n account.getEntryPoint().address,\n overrides?.stateOverride\n );\n\n const callGasLimit = applyUserOpOverrideOrFeeOption(\n estimates.callGasLimit,\n overrides?.callGasLimit,\n feeOptions?.callGasLimit\n );\n const verificationGasLimit = applyUserOpOverrideOrFeeOption(\n estimates.verificationGasLimit,\n overrides?.verificationGasLimit,\n feeOptions?.verificationGasLimit\n );\n const preVerificationGas = applyUserOpOverrideOrFeeOption(\n estimates.preVerificationGas,\n overrides?.preVerificationGas,\n feeOptions?.preVerificationGas\n );\n\n struct.callGasLimit = callGasLimit;\n struct.verificationGasLimit = verificationGasLimit;\n struct.preVerificationGas = preVerificationGas;\n\n const entryPoint = account.getEntryPoint();\n if (entryPoint.version === \"0.7.0\") {\n const paymasterVerificationGasLimit = applyUserOpOverrideOrFeeOption(\n estimates.paymasterVerificationGasLimit,\n (overrides as UserOperationOverrides<\"0.7.0\">)\n ?.paymasterVerificationGasLimit,\n (feeOptions as UserOperationFeeOptions<\"0.7.0\">)\n ?.paymasterVerificationGasLimit\n );\n const uo_v7 = struct as UserOperationStruct<\"0.7.0\">;\n\n uo_v7.paymasterVerificationGasLimit = paymasterVerificationGasLimit;\n\n uo_v7.paymasterPostOpGasLimit =\n uo_v7.paymasterPostOpGasLimit ?? (uo_v7.paymaster ? \"0x0\" : undefined);\n }\n\n return struct;\n };\n"]}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { ClientMiddlewareFn } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Middleware function that sets the `paymasterAndData` field in the given struct based on the entry point version of the account.
|
|
4
|
+
* This is the default used by `createSmartAccountClient` and is not necessary to be used directly.
|
|
5
|
+
*
|
|
6
|
+
* @param {UserOperationStruct} struct the user operation structure to be modified
|
|
7
|
+
* @param {{ account: Account }} context an object containing the account information
|
|
8
|
+
* @returns {Promise<UserOperationStruct>} a promise that resolves to the modified user operation structure
|
|
9
|
+
*/
|
|
2
10
|
export declare const defaultPaymasterAndData: ClientMiddlewareFn;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware function that sets the `paymasterAndData` field in the given struct based on the entry point version of the account.
|
|
3
|
+
* This is the default used by `createSmartAccountClient` and is not necessary to be used directly.
|
|
4
|
+
*
|
|
5
|
+
* @param {UserOperationStruct} struct the user operation structure to be modified
|
|
6
|
+
* @param {{ account: Account }} context an object containing the account information
|
|
7
|
+
* @returns {Promise<UserOperationStruct>} a promise that resolves to the modified user operation structure
|
|
8
|
+
*/
|
|
1
9
|
export const defaultPaymasterAndData = async (struct, { account }) => {
|
|
2
10
|
const entryPoint = account.getEntryPoint();
|
|
3
11
|
if (entryPoint.version === "0.6.0") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paymasterAndData.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/paymasterAndData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paymasterAndData.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/paymasterAndData.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAuB,KAAK,EAC9D,MAAM,EACN,EAAE,OAAO,EAAE,EACX,EAAE;IACF,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAC3C,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAClC,MAAuC,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { UserOperationStruct } from \"../../types\";\nimport type { ClientMiddlewareFn } from \"../types\";\n\n/**\n * Middleware function that sets the `paymasterAndData` field in the given struct based on the entry point version of the account.\n * This is the default used by `createSmartAccountClient` and is not necessary to be used directly.\n *\n * @param {UserOperationStruct} struct the user operation structure to be modified\n * @param {{ account: Account }} context an object containing the account information\n * @returns {Promise<UserOperationStruct>} a promise that resolves to the modified user operation structure\n */\nexport const defaultPaymasterAndData: ClientMiddlewareFn = async (\n struct,\n { account }\n) => {\n const entryPoint = account.getEntryPoint();\n if (entryPoint.version === \"0.6.0\") {\n (struct as UserOperationStruct<\"0.6.0\">).paymasterAndData = \"0x\";\n }\n return struct;\n};\n"]}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { ClientMiddlewareFn } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Provides a default middleware function for signing user operations with a client account. This function validates the request and adds the signature to it.
|
|
4
|
+
* This is already included in the client returned from `createSmartAccountClient`
|
|
5
|
+
*
|
|
6
|
+
* @param {UserOperationStruct} struct The user operation structure to be signed
|
|
7
|
+
* @param {*} context The middleware context containing the client and account information
|
|
8
|
+
* @param {Client} context.client The client object, which should include account and chain information
|
|
9
|
+
* @param {Account} [context.account] Optional, the account used for signing, defaults to the client's account if not provided
|
|
10
|
+
* @returns {Promise<UserOperationStruct>} A promise that resolves to the signed user operation structure
|
|
11
|
+
*/
|
|
2
12
|
export declare const defaultUserOpSigner: ClientMiddlewareFn;
|
|
@@ -2,6 +2,16 @@ import { AccountNotFoundError } from "../../errors/account.js";
|
|
|
2
2
|
import { ChainNotFoundError } from "../../errors/client.js";
|
|
3
3
|
import { InvalidUserOperationError } from "../../errors/useroperation.js";
|
|
4
4
|
import { deepHexlify, isValidRequest, resolveProperties, } from "../../utils/index.js";
|
|
5
|
+
/**
|
|
6
|
+
* Provides a default middleware function for signing user operations with a client account. This function validates the request and adds the signature to it.
|
|
7
|
+
* This is already included in the client returned from `createSmartAccountClient`
|
|
8
|
+
*
|
|
9
|
+
* @param {UserOperationStruct} struct The user operation structure to be signed
|
|
10
|
+
* @param {*} context The middleware context containing the client and account information
|
|
11
|
+
* @param {Client} context.client The client object, which should include account and chain information
|
|
12
|
+
* @param {Account} [context.account] Optional, the account used for signing, defaults to the client's account if not provided
|
|
13
|
+
* @returns {Promise<UserOperationStruct>} A promise that resolves to the signed user operation structure
|
|
14
|
+
*/
|
|
5
15
|
export const defaultUserOpSigner = async (struct, { client, account = client.account }) => {
|
|
6
16
|
if (!account) {
|
|
7
17
|
throw new AccountNotFoundError();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userOpSigner.js","sourceRoot":"","sources":["../../../../src/middleware/defaults/userOpSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D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,CAAC,CAAC","sourcesContent":["import { AccountNotFoundError } from \"../../errors/account.js\";\nimport { ChainNotFoundError } from \"../../errors/client.js\";\nimport { InvalidUserOperationError } from \"../../errors/useroperation.js\";\nimport {\n deepHexlify,\n isValidRequest,\n resolveProperties,\n} from \"../../utils/index.js\";\nimport type { ClientMiddlewareFn } from \"../types\";\n\n/**\n * Provides a default middleware function for signing user operations with a client account. This function validates the request and adds the signature to it.\n * This is already included in the client returned from `createSmartAccountClient`\n *\n * @param {UserOperationStruct} struct The user operation structure to be signed\n * @param {*} context The middleware context containing the client and account information\n * @param {Client} context.client The client object, which should include account and chain information\n * @param {Account} [context.account] Optional, the account used for signing, defaults to the client's account if not provided\n * @returns {Promise<UserOperationStruct>} A promise that resolves to the signed user operation structure\n */\nexport const defaultUserOpSigner: ClientMiddlewareFn = async (\n struct,\n { client, account = client.account }\n) => {\n if (!account) {\n throw new AccountNotFoundError();\n }\n\n if (!client?.chain) {\n throw new ChainNotFoundError();\n }\n\n const resolvedStruct = await resolveProperties(struct);\n const request = deepHexlify(resolvedStruct);\n if (!isValidRequest(request)) {\n throw new InvalidUserOperationError(resolvedStruct);\n }\n\n return {\n ...resolvedStruct,\n signature: await account.signUserOperationHash(\n account.getEntryPoint().getUserOperationHash(request)\n ),\n };\n};\n"]}
|
|
@@ -37,4 +37,25 @@ export type Erc7677MiddlewareParams<TContext extends Record<string, any> | undef
|
|
|
37
37
|
feeOptions?: UserOperationFeeOptions;
|
|
38
38
|
}) => Promise<TContext>) | TContext;
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations.
|
|
42
|
+
* This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { createSmartAccountClient, erc7677Middleware } from "@aa-sdk/core";
|
|
47
|
+
* import { http } from "viem";
|
|
48
|
+
* import { sepolia } from "viem/chains";
|
|
49
|
+
*
|
|
50
|
+
* const client = createSmartAccountClient({
|
|
51
|
+
* transport: http("rpc-url"),
|
|
52
|
+
* chain: sepolia,
|
|
53
|
+
* // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context
|
|
54
|
+
* ...erc7677Middleware(),
|
|
55
|
+
* })
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param {Erc7677MiddlewareParams<TContext>} params Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op
|
|
59
|
+
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} An object containing middleware functions `dummyPaymasterAndData` and `paymasterAndData` for processing user operations with the paymaster data
|
|
60
|
+
*/
|
|
40
61
|
export declare function erc7677Middleware<TContext extends Record<string, any> | undefined = Record<string, any> | undefined>(params?: Erc7677MiddlewareParams<TContext>): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
|
|
@@ -1,9 +1,31 @@
|
|
|
1
1
|
import { toHex, } from "viem";
|
|
2
2
|
import { ChainNotFoundError } from "../errors/client.js";
|
|
3
3
|
import { deepHexlify, resolveProperties, } from "../utils/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations.
|
|
6
|
+
* This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { createSmartAccountClient, erc7677Middleware } from "@aa-sdk/core";
|
|
11
|
+
* import { http } from "viem";
|
|
12
|
+
* import { sepolia } from "viem/chains";
|
|
13
|
+
*
|
|
14
|
+
* const client = createSmartAccountClient({
|
|
15
|
+
* transport: http("rpc-url"),
|
|
16
|
+
* chain: sepolia,
|
|
17
|
+
* // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context
|
|
18
|
+
* ...erc7677Middleware(),
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {Erc7677MiddlewareParams<TContext>} params Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op
|
|
23
|
+
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} An object containing middleware functions `dummyPaymasterAndData` and `paymasterAndData` for processing user operations with the paymaster data
|
|
24
|
+
*/
|
|
4
25
|
export function erc7677Middleware(params) {
|
|
5
26
|
const dummyPaymasterAndData = async (uo, { client, account, feeOptions, overrides }) => {
|
|
6
27
|
const userOp = deepHexlify(await resolveProperties(uo));
|
|
28
|
+
// Those values will be set after fee estimation.
|
|
7
29
|
userOp.maxFeePerGas = "0x0";
|
|
8
30
|
userOp.maxPriorityFeePerGas = "0x0";
|
|
9
31
|
userOp.callGasLimit = "0x0";
|
|
@@ -21,6 +43,7 @@ export function erc7677Middleware(params) {
|
|
|
21
43
|
throw new ChainNotFoundError();
|
|
22
44
|
}
|
|
23
45
|
const erc7677client = client;
|
|
46
|
+
// TODO: probably need to handle the sponsor and isFinal fields
|
|
24
47
|
const { paymaster, paymasterAndData, paymasterData, paymasterPostOpGasLimit, paymasterVerificationGasLimit, } = await erc7677client.request({
|
|
25
48
|
method: "pm_getPaymasterStubData",
|
|
26
49
|
params: [userOp, entrypoint.address, toHex(client.chain.id), context],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc7677middleware.js","sourceRoot":"","sources":["../../../src/middleware/erc7677middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAMN,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAOzD,OAAO,EACL,WAAW,EACX,iBAAiB,GAElB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"erc7677middleware.js","sourceRoot":"","sources":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E,gBAAgB,EAAE,aAAa,EAAE,GAClD,MAAM,aAAa,CAAC,OAAO,CAAC;YAC1B,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC;SACtE,CAAC,CAAC;QAEL,IAAI,UAAU,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;YACnC,OAAO;gBACL,GAAG,EAAE;gBACL,gBAAgB;aACjB,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,EAAE;YACL,SAAS;YACT,aAAa;SACd,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,qBAAqB;QACrB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import {\n toHex,\n type Address,\n type Chain,\n type Client,\n type Hex,\n type Transport,\n} from \"viem\";\nimport type { ClientMiddlewareConfig } from \"../client/types\";\nimport type { EntryPointVersion } from \"../entrypoint/types\";\nimport { ChainNotFoundError } from \"../errors/client.js\";\nimport type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n UserOperationStruct,\n} from \"../types\";\nimport {\n deepHexlify,\n resolveProperties,\n type Deferrable,\n} from \"../utils/index.js\";\nimport type { ClientMiddlewareFn } from \"./types\";\n\nexport type Erc7677RpcSchema = [\n {\n Method: \"pm_getPaymasterStubData\";\n Parameters: [UserOperationRequest, Address, Hex, Record<string, any>];\n ReturnType: {\n sponsor?: { name: string; icon?: string }; // Sponsor info\n paymaster?: Address; // Paymaster address (entrypoint v0.7)\n paymasterData?: Hex; // Paymaster data (entrypoint v0.7)\n paymasterVerificationGasLimit?: Hex; // Paymaster validation gas (entrypoint v0.7)\n paymasterPostOpGasLimit?: Hex; // Paymaster post-op gas (entrypoint v0.7)\n paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)\n isFinal?: boolean; // Indicates that the caller does not need to call pm_getPaymasterData\n };\n },\n {\n Method: \"pm_getPaymasterData\";\n Parameters: [UserOperationRequest, Address, Hex, Record<string, any>];\n ReturnType: {\n paymaster?: Address; // Paymaster address (entrypoint v0.7)\n paymasterData?: Hex; // Paymaster data (entrypoint v0.7)\n paymasterAndData?: Hex; // Paymaster and data (entrypoint v0.6)\n };\n }\n];\n\nexport type Erc7677Client<T extends Transport = Transport> = Client<\n T,\n Chain,\n undefined,\n Erc7677RpcSchema\n>;\n\nexport type Erc7677MiddlewareParams<\n TContext extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined,\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = {\n context?:\n | ((\n struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,\n args: {\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n feeOptions?: UserOperationFeeOptions;\n }\n ) => Promise<TContext>)\n | TContext;\n};\n\n/**\n * Middleware function for interacting with ERC-7677 enabled clients. It supports resolving paymaster and data fields for user operations.\n * This middleware assumes that your RPC provider supports the ERC-7677 methods (pm_getPaymasterStubData and pm_getPaymasterData).\n *\n * @example\n * ```ts\n * import { createSmartAccountClient, erc7677Middleware } from \"@aa-sdk/core\";\n * import { http } from \"viem\";\n * import { sepolia } from \"viem/chains\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * // this assumes that your RPC provider supports the ERC-7677 methods AND takes no context\n * ...erc7677Middleware(),\n * })\n * ```\n *\n * @param {Erc7677MiddlewareParams<TContext>} params Middleware parameters including context function or object. Context can be resolved dynamically by passing in a function which takes in the context at the time of sending a user op\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} An object containing middleware functions `dummyPaymasterAndData` and `paymasterAndData` for processing user operations with the paymaster data\n */\nexport function erc7677Middleware<\n TContext extends Record<string, any> | undefined =\n | Record<string, any>\n | undefined\n>(\n params?: Erc7677MiddlewareParams<TContext>\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n const dummyPaymasterAndData: ClientMiddlewareFn = async (\n uo,\n { client, account, feeOptions, overrides }\n ) => {\n const userOp = deepHexlify(await resolveProperties(uo));\n\n // Those values will be set after fee estimation.\n userOp.maxFeePerGas = \"0x0\";\n userOp.maxPriorityFeePerGas = \"0x0\";\n userOp.callGasLimit = \"0x0\";\n userOp.verificationGasLimit = \"0x0\";\n userOp.preVerificationGas = \"0x0\";\n\n const entrypoint = account.getEntryPoint();\n\n if (entrypoint.version === \"0.7.0\") {\n userOp.paymasterVerificationGasLimit = \"0x0\";\n userOp.paymasterPostOpGasLimit = \"0x0\";\n }\n\n const context =\n (typeof params?.context === \"function\"\n ? await params?.context(userOp, { overrides, feeOptions })\n : params?.context) ?? {};\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const erc7677client = client as Erc7677Client;\n // TODO: probably need to handle the sponsor and isFinal fields\n const {\n paymaster,\n paymasterAndData,\n paymasterData,\n paymasterPostOpGasLimit,\n paymasterVerificationGasLimit,\n } = await erc7677client.request({\n method: \"pm_getPaymasterStubData\",\n params: [userOp, entrypoint.address, toHex(client.chain.id), context],\n });\n\n if (entrypoint.version === \"0.6.0\") {\n return {\n ...uo,\n paymasterAndData,\n };\n }\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n paymasterPostOpGasLimit,\n paymasterVerificationGasLimit,\n };\n };\n\n const paymasterAndData: ClientMiddlewareFn = async (\n uo,\n { client, account, feeOptions, overrides }\n ) => {\n const userOp = deepHexlify(await resolveProperties(uo));\n const context =\n (typeof params?.context === \"function\"\n ? await params?.context(userOp, { overrides, feeOptions })\n : params?.context) ?? {};\n\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const erc7677client = client as Erc7677Client;\n\n const entrypoint = account.getEntryPoint();\n const { paymaster, paymasterAndData, paymasterData } =\n await erc7677client.request({\n method: \"pm_getPaymasterData\",\n params: [userOp, entrypoint.address, toHex(client.chain.id), context],\n });\n\n if (entrypoint.version === \"0.6.0\") {\n return {\n ...uo,\n paymasterAndData,\n };\n }\n\n return {\n ...uo,\n paymaster,\n paymasterData,\n };\n };\n\n return {\n dummyPaymasterAndData,\n paymasterAndData,\n };\n}\n"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { UserOperationContext } from "../actions/smartAccount/types";
|
|
2
2
|
import type { ClientMiddlewareFn } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Noop middleware that does nothing and passes the arguments through
|
|
5
|
+
*
|
|
6
|
+
* @param {Deferrable<UserOperationStruct<TEntryPointVersion>>} args the client middleware arguments passed to the middleware
|
|
7
|
+
* @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} the arguments passed to the middleware and returned as is without modification
|
|
8
|
+
*/
|
|
3
9
|
export declare const noopMiddleware: ClientMiddlewareFn<UserOperationContext | undefined>;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Noop middleware that does nothing and passes the arguments through
|
|
3
|
+
*
|
|
4
|
+
* @param {Deferrable<UserOperationStruct<TEntryPointVersion>>} args the client middleware arguments passed to the middleware
|
|
5
|
+
* @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} the arguments passed to the middleware and returned as is without modification
|
|
6
|
+
*/
|
|
1
7
|
export const noopMiddleware = async (args) => {
|
|
2
8
|
return args;
|
|
3
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noopMiddleware.js","sourceRoot":"","sources":["../../../src/middleware/noopMiddleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noopMiddleware.js","sourceRoot":"","sources":["../../../src/middleware/noopMiddleware.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAEvB,KAAK,EAAE,IAAI,EAAE,EAAE;IACjB,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["import type { UserOperationContext } from \"../actions/smartAccount/types\";\nimport type { ClientMiddlewareFn } from \"./types\";\n\n/**\n * Noop middleware that does nothing and passes the arguments through\n *\n * @param {Deferrable<UserOperationStruct<TEntryPointVersion>>} args the client middleware arguments passed to the middleware\n * @returns {Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>} the arguments passed to the middleware and returned as is without modification\n */\nexport const noopMiddleware: ClientMiddlewareFn<\n UserOperationContext | undefined\n> = async (args) => {\n return args;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/middleware/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../account/smartContractAccount\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types\";\nimport type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../types\";\nimport type { Deferrable } from \"../utils\";\nimport type { MiddlewareClient } from \"./actions\";\n\nexport type ClientMiddlewareArgs<\n TAccount extends SmartContractAccount,\n C extends MiddlewareClient,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n context?: TContext;\n feeOptions?: UserOperationFeeOptions;\n account: TAccount;\n client: C;\n};\n\n// [!region ClientMiddlewareFn]\nexport type ClientMiddlewareFn<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = <\n TAccount extends SmartContractAccount,\n C extends MiddlewareClient,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,\n args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>\n) => Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>;\n// [!endregion ClientMiddlewareFn]\n\n// [!region ClientMiddleware]\nexport type ClientMiddleware<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n dummyPaymasterAndData: ClientMiddlewareFn<TContext>;\n feeEstimator: ClientMiddlewareFn<TContext>;\n gasEstimator: ClientMiddlewareFn<TContext>;\n customMiddleware: ClientMiddlewareFn<TContext>;\n paymasterAndData: ClientMiddlewareFn<TContext>;\n userOperationSimulator: ClientMiddlewareFn<TContext>;\n signUserOperation: ClientMiddlewareFn<TContext>;\n};\n// [!endregion ClientMiddleware]\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/middleware/types.ts"],"names":[],"mappings":";AAyDA,gCAAgC","sourcesContent":["import type {\n GetEntryPointFromAccount,\n SmartContractAccount,\n} from \"../account/smartContractAccount\";\nimport type { UserOperationContext } from \"../actions/smartAccount/types\";\nimport type {\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationStruct,\n} from \"../types\";\nimport type { Deferrable } from \"../utils\";\nimport type { MiddlewareClient } from \"./actions\";\n\nexport type ClientMiddlewareArgs<\n TAccount extends SmartContractAccount,\n C extends MiddlewareClient,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n> = {\n overrides?: UserOperationOverrides<TEntryPointVersion>;\n context?: TContext;\n feeOptions?: UserOperationFeeOptions;\n account: TAccount;\n client: C;\n};\n\n// [!region ClientMiddlewareFn]\nexport type ClientMiddlewareFn<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = <\n TAccount extends SmartContractAccount,\n C extends MiddlewareClient,\n TEntryPointVersion extends GetEntryPointFromAccount<TAccount> = GetEntryPointFromAccount<TAccount>\n>(\n struct: Deferrable<UserOperationStruct<TEntryPointVersion>>,\n args: ClientMiddlewareArgs<TAccount, C, TContext, TEntryPointVersion>\n) => Promise<Deferrable<UserOperationStruct<TEntryPointVersion>>>;\n// [!endregion ClientMiddlewareFn]\n\n// [!region ClientMiddleware]\nexport type ClientMiddleware<\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n dummyPaymasterAndData: ClientMiddlewareFn<TContext>;\n feeEstimator: ClientMiddlewareFn<TContext>;\n gasEstimator: ClientMiddlewareFn<TContext>;\n customMiddleware: ClientMiddlewareFn<TContext>;\n paymasterAndData: ClientMiddlewareFn<TContext>;\n userOperationSimulator: ClientMiddlewareFn<TContext>;\n signUserOperation: ClientMiddlewareFn<TContext>;\n};\n// [!endregion ClientMiddleware]\n"]}
|
|
@@ -1,10 +1,63 @@
|
|
|
1
1
|
import { type HDAccount, type HDOptions, type Hex, type LocalAccount, type PrivateKeyAccount, type SignableMessage, type TypedDataDefinition } from "viem";
|
|
2
2
|
import type { SmartAccountSigner } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Represents a local account signer and provides methods to sign messages and transactions, as well as static methods to create the signer from mnemonic or private key.
|
|
5
|
+
*/
|
|
3
6
|
export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount | LocalAccount> implements SmartAccountSigner<T> {
|
|
4
7
|
inner: T;
|
|
5
8
|
signerType: string;
|
|
9
|
+
/**
|
|
10
|
+
* A function to initialize an object with an inner parameter and derive a signerType from it.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
15
|
+
* import { privateKeyToAccount, generatePrivateKey } from "viem";
|
|
16
|
+
*
|
|
17
|
+
* const signer = new LocalAccountSigner(
|
|
18
|
+
* privateKeyToAccount(generatePrivateKey()),
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param {T} inner The inner parameter containing the necessary data
|
|
23
|
+
*/
|
|
6
24
|
constructor(inner: T);
|
|
25
|
+
/**
|
|
26
|
+
* Signs the provided message using the inner signMessage function.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
31
|
+
* import { generatePrivateKey } from "viem";
|
|
32
|
+
*
|
|
33
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
34
|
+
* const signature = await signer.signMessage("Hello, world!");
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @param {string} message The message to be signed
|
|
38
|
+
* @returns {Promise<any>} A promise that resolves to the signed message
|
|
39
|
+
*/
|
|
7
40
|
readonly signMessage: (message: SignableMessage) => Promise<`0x${string}`>;
|
|
41
|
+
/**
|
|
42
|
+
* Signs typed data using the given parameters.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
47
|
+
* import { generatePrivateKey } from "viem";
|
|
48
|
+
*
|
|
49
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
50
|
+
* const signature = await signer.signTypedData({
|
|
51
|
+
* domain: {},
|
|
52
|
+
* types: {},
|
|
53
|
+
* primaryType: "",
|
|
54
|
+
* message: {},
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param {TypedDataDefinition<TTypedData, TPrimaryType>} params The parameters defining the typed data and primary type
|
|
59
|
+
* @returns {Promise<Hex>} A promise that resolves to the signed data in hexadecimal format
|
|
60
|
+
*/
|
|
8
61
|
readonly signTypedData: <const TTypedData extends {
|
|
9
62
|
[x: string]: readonly import("viem").TypedDataParameter[];
|
|
10
63
|
[x: `string[${string}]`]: undefined;
|
|
@@ -213,7 +266,49 @@ export declare class LocalAccountSigner<T extends HDAccount | PrivateKeyAccount
|
|
|
213
266
|
} | {
|
|
214
267
|
[key: string]: unknown;
|
|
215
268
|
}, TPrimaryType extends string = string>(params: TypedDataDefinition<TTypedData, TPrimaryType>) => Promise<Hex>;
|
|
269
|
+
/**
|
|
270
|
+
* Returns the address of the inner object in a specific hexadecimal format.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts
|
|
274
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
275
|
+
* import { generatePrivateKey } from "viem";
|
|
276
|
+
*
|
|
277
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
278
|
+
* const address = await signer.getAddress();
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @returns {Promise<Hex>} A promise that resolves to the address in the format `0x{string}`
|
|
282
|
+
*/
|
|
216
283
|
readonly getAddress: () => Promise<`0x${string}`>;
|
|
284
|
+
/**
|
|
285
|
+
* Creates a LocalAccountSigner using the provided mnemonic key and optional HD options.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
290
|
+
* import { generateMnemonic } from "viem";
|
|
291
|
+
*
|
|
292
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generateMnemonic());
|
|
293
|
+
* ```
|
|
294
|
+
*
|
|
295
|
+
* @param {string} key The mnemonic key to derive the account from.
|
|
296
|
+
* @param {HDOptions} [opts] Optional HD options for deriving the account.
|
|
297
|
+
* @returns {LocalAccountSigner<HDAccount>} A LocalAccountSigner object for the derived account.
|
|
298
|
+
*/
|
|
217
299
|
static mnemonicToAccountSigner(key: string, opts?: HDOptions): LocalAccountSigner<HDAccount>;
|
|
218
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Creates a `LocalAccountSigner` instance using the provided private key.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```ts
|
|
305
|
+
* import { LocalAccountSigner } from "@aa-sdk/core";
|
|
306
|
+
* import { generatePrivateKey } from "viem";
|
|
307
|
+
*
|
|
308
|
+
* const signer = LocalAccountSigner.mnemonicToAccountSigner(generatePrivateKey());
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* @param {Hex} key The private key in hexadecimal format
|
|
312
|
+
* @returns {LocalAccountSigner<PrivateKeyAccount>} An instance of `LocalAccountSigner` initialized with the provided private key
|
|
313
|
+
*/ static privateKeyToAccountSigner(key: Hex): LocalAccountSigner<PrivateKeyAccount>;
|
|
219
314
|
}
|