viem 2.17.10 → 2.18.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +16 -2
- package/README.md +6 -0
- package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js +6 -0
- package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -0
- package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +688 -0
- package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -0
- package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js +704 -0
- package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -0
- package/_cjs/account-abstraction/accounts/toSmartAccount.js +93 -0
- package/_cjs/account-abstraction/accounts/toSmartAccount.js.map +1 -0
- package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js +24 -0
- package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -0
- package/_cjs/account-abstraction/accounts/types.js +3 -0
- package/_cjs/account-abstraction/accounts/types.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +37 -0
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/getSupportedEntryPoints.js +7 -0
- package/_cjs/account-abstraction/actions/bundler/getSupportedEntryPoints.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/getUserOperation.js +22 -0
- package/_cjs/account-abstraction/actions/bundler/getUserOperation.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/getUserOperationReceipt.js +15 -0
- package/_cjs/account-abstraction/actions/bundler/getUserOperationReceipt.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js +239 -0
- package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js +36 -0
- package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -0
- package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +48 -0
- package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js +34 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js +34 -0
- package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -0
- package/_cjs/account-abstraction/clients/createBundlerClient.js +18 -0
- package/_cjs/account-abstraction/clients/createBundlerClient.js.map +1 -0
- package/_cjs/account-abstraction/clients/createPaymasterClient.js +17 -0
- package/_cjs/account-abstraction/clients/createPaymasterClient.js.map +1 -0
- package/_cjs/account-abstraction/clients/decorators/bundler.js +24 -0
- package/_cjs/account-abstraction/clients/decorators/bundler.js.map +1 -0
- package/_cjs/account-abstraction/clients/decorators/paymaster.js +12 -0
- package/_cjs/account-abstraction/clients/decorators/paymaster.js.map +1 -0
- package/_cjs/account-abstraction/constants/abis.js +1318 -0
- package/_cjs/account-abstraction/constants/abis.js.map +1 -0
- package/_cjs/account-abstraction/constants/address.js +6 -0
- package/_cjs/account-abstraction/constants/address.js.map +1 -0
- package/_cjs/account-abstraction/errors/bundler.js +813 -0
- package/_cjs/account-abstraction/errors/bundler.js.map +1 -0
- package/_cjs/account-abstraction/errors/userOperation.js +91 -0
- package/_cjs/account-abstraction/errors/userOperation.js.map +1 -0
- package/_cjs/account-abstraction/index.js +90 -0
- package/_cjs/account-abstraction/index.js.map +1 -0
- package/_cjs/account-abstraction/types/account.js +3 -0
- package/_cjs/account-abstraction/types/account.js.map +1 -0
- package/_cjs/account-abstraction/types/entryPointVersion.js +3 -0
- package/_cjs/account-abstraction/types/entryPointVersion.js.map +1 -0
- package/_cjs/account-abstraction/types/rpc.js +3 -0
- package/_cjs/account-abstraction/types/rpc.js.map +1 -0
- package/_cjs/account-abstraction/types/userOperation.js +3 -0
- package/_cjs/account-abstraction/types/userOperation.js.map +1 -0
- package/_cjs/account-abstraction/utils/errors/getBundlerError.js +186 -0
- package/_cjs/account-abstraction/utils/errors/getBundlerError.js.map +1 -0
- package/_cjs/account-abstraction/utils/errors/getUserOperationError.js +87 -0
- package/_cjs/account-abstraction/utils/errors/getUserOperationError.js.map +1 -0
- package/_cjs/account-abstraction/utils/formatters/userOperation.js +24 -0
- package/_cjs/account-abstraction/utils/formatters/userOperation.js.map +1 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationGas.js +18 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationGas.js.map +1 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationReceipt.js +18 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationReceipt.js.map +1 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +43 -0
- package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -0
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js +88 -0
- package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -0
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +44 -0
- package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -0
- package/_cjs/accounts/index.js +1 -3
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/privateKeyToAccount.js +4 -0
- package/_cjs/accounts/privateKeyToAccount.js.map +1 -1
- package/_cjs/accounts/toAccount.js +1 -0
- package/_cjs/accounts/toAccount.js.map +1 -1
- package/_cjs/accounts/utils/parseAccount.js.map +1 -1
- package/_cjs/accounts/utils/sign.js +8 -2
- package/_cjs/accounts/utils/sign.js.map +1 -1
- package/_cjs/accounts/utils/signMessage.js +1 -3
- package/_cjs/accounts/utils/signMessage.js.map +1 -1
- package/_cjs/accounts/utils/signTypedData.js +2 -3
- package/_cjs/accounts/utils/signTypedData.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +35 -22
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/signMessage.js +1 -1
- package/_cjs/actions/wallet/signMessage.js.map +1 -1
- package/_cjs/actions/wallet/signTransaction.js +1 -2
- package/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/_cjs/actions/wallet/signTypedData.js +1 -1
- package/_cjs/actions/wallet/signTypedData.js.map +1 -1
- package/_cjs/chains/definitions/bobaSepolia.js +23 -0
- package/_cjs/chains/definitions/bobaSepolia.js.map +1 -0
- package/_cjs/chains/index.js +9 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/constants/abis.js +0 -3
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/constants/address.js +3 -1
- package/_cjs/constants/address.js.map +1 -1
- package/_cjs/errors/account.js +17 -2
- package/_cjs/errors/account.js.map +1 -1
- package/_cjs/errors/contract.js +1 -1
- package/_cjs/errors/contract.js.map +1 -1
- package/_cjs/errors/rpc.js +6 -6
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/index.js +5 -3
- package/_cjs/index.js.map +1 -1
- package/_cjs/types/eip1193.js.map +1 -1
- package/_cjs/utils/buildRequest.js +4 -2
- package/_cjs/utils/buildRequest.js.map +1 -1
- package/_cjs/utils/errors/getNodeError.js +1 -2
- package/_cjs/utils/errors/getNodeError.js.map +1 -1
- package/_cjs/utils/index.js +3 -1
- package/_cjs/utils/index.js.map +1 -1
- package/_cjs/utils/signature/serializeErc6492Signature.js +6 -2
- package/_cjs/utils/signature/serializeErc6492Signature.js.map +1 -1
- package/_cjs/utils/signature/serializeSignature.js +6 -2
- package/_cjs/utils/signature/serializeSignature.js.map +1 -1
- package/_cjs/utils/signature/verifyHash.js +10 -0
- package/_cjs/utils/signature/verifyHash.js.map +1 -0
- package/_esm/account-abstraction/accounts/createWebAuthnCredential.js +3 -0
- package/_esm/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -0
- package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +709 -0
- package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -0
- package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js +718 -0
- package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -0
- package/_esm/account-abstraction/accounts/toSmartAccount.js +96 -0
- package/_esm/account-abstraction/accounts/toSmartAccount.js.map +1 -0
- package/_esm/account-abstraction/accounts/toWebAuthnAccount.js +26 -0
- package/_esm/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -0
- package/_esm/account-abstraction/accounts/types.js +2 -0
- package/_esm/account-abstraction/accounts/types.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +61 -0
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/getSupportedEntryPoints.js +25 -0
- package/_esm/account-abstraction/actions/bundler/getSupportedEntryPoints.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/getUserOperation.js +42 -0
- package/_esm/account-abstraction/actions/bundler/getUserOperation.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/getUserOperationReceipt.js +35 -0
- package/_esm/account-abstraction/actions/bundler/getUserOperationReceipt.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js +323 -0
- package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/sendUserOperation.js +60 -0
- package/_esm/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -0
- package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +68 -0
- package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +56 -0
- package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -0
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +56 -0
- package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -0
- package/_esm/account-abstraction/clients/createBundlerClient.js +15 -0
- package/_esm/account-abstraction/clients/createBundlerClient.js.map +1 -0
- package/_esm/account-abstraction/clients/createPaymasterClient.js +14 -0
- package/_esm/account-abstraction/clients/createPaymasterClient.js.map +1 -0
- package/_esm/account-abstraction/clients/decorators/bundler.js +21 -0
- package/_esm/account-abstraction/clients/decorators/bundler.js.map +1 -0
- package/_esm/account-abstraction/clients/decorators/paymaster.js +9 -0
- package/_esm/account-abstraction/clients/decorators/paymaster.js.map +1 -0
- package/_esm/account-abstraction/constants/abis.js +1315 -0
- package/_esm/account-abstraction/constants/abis.js.map +1 -0
- package/_esm/account-abstraction/constants/address.js +3 -0
- package/_esm/account-abstraction/constants/address.js.map +1 -0
- package/_esm/account-abstraction/errors/bundler.js +774 -0
- package/_esm/account-abstraction/errors/bundler.js.map +1 -0
- package/_esm/account-abstraction/errors/userOperation.js +84 -0
- package/_esm/account-abstraction/errors/userOperation.js.map +1 -0
- package/_esm/account-abstraction/index.js +31 -0
- package/_esm/account-abstraction/index.js.map +1 -0
- package/_esm/account-abstraction/types/account.js +2 -0
- package/_esm/account-abstraction/types/account.js.map +1 -0
- package/_esm/account-abstraction/types/entryPointVersion.js +2 -0
- package/_esm/account-abstraction/types/entryPointVersion.js.map +1 -0
- package/_esm/account-abstraction/types/rpc.js +2 -0
- package/_esm/account-abstraction/types/rpc.js.map +1 -0
- package/_esm/account-abstraction/types/userOperation.js +2 -0
- package/_esm/account-abstraction/types/userOperation.js.map +1 -0
- package/_esm/account-abstraction/utils/errors/getBundlerError.js +183 -0
- package/_esm/account-abstraction/utils/errors/getBundlerError.js.map +1 -0
- package/_esm/account-abstraction/utils/errors/getUserOperationError.js +85 -0
- package/_esm/account-abstraction/utils/errors/getUserOperationError.js.map +1 -0
- package/_esm/account-abstraction/utils/formatters/userOperation.js +21 -0
- package/_esm/account-abstraction/utils/formatters/userOperation.js.map +1 -0
- package/_esm/account-abstraction/utils/formatters/userOperationGas.js +15 -0
- package/_esm/account-abstraction/utils/formatters/userOperationGas.js.map +1 -0
- package/_esm/account-abstraction/utils/formatters/userOperationReceipt.js +15 -0
- package/_esm/account-abstraction/utils/formatters/userOperationReceipt.js.map +1 -0
- package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +40 -0
- package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -0
- package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js +85 -0
- package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -0
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +41 -0
- package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -0
- package/_esm/accounts/index.js +0 -1
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/privateKeyToAccount.js +4 -0
- package/_esm/accounts/privateKeyToAccount.js.map +1 -1
- package/_esm/accounts/toAccount.js +2 -0
- package/_esm/accounts/toAccount.js.map +1 -1
- package/_esm/accounts/utils/parseAccount.js.map +1 -1
- package/_esm/accounts/utils/sign.js +9 -3
- package/_esm/accounts/utils/sign.js.map +1 -1
- package/_esm/accounts/utils/signMessage.js +1 -3
- package/_esm/accounts/utils/signMessage.js.map +1 -1
- package/_esm/accounts/utils/signTypedData.js +2 -3
- package/_esm/accounts/utils/signTypedData.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +37 -24
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/signMessage.js +1 -1
- package/_esm/actions/wallet/signMessage.js.map +1 -1
- package/_esm/actions/wallet/signTransaction.js +1 -2
- package/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/_esm/actions/wallet/signTypedData.js +1 -1
- package/_esm/actions/wallet/signTypedData.js.map +1 -1
- package/_esm/chains/definitions/bobaSepolia.js +20 -0
- package/_esm/chains/definitions/bobaSepolia.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/constants/abis.js +0 -3
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/constants/address.js +2 -0
- package/_esm/constants/address.js.map +1 -1
- package/_esm/errors/account.js +15 -1
- package/_esm/errors/account.js.map +1 -1
- package/_esm/errors/contract.js +1 -1
- package/_esm/errors/contract.js.map +1 -1
- package/_esm/errors/rpc.js +6 -6
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/index.js +1 -0
- package/_esm/index.js.map +1 -1
- package/_esm/types/eip1193.js.map +1 -1
- package/_esm/utils/buildRequest.js +4 -2
- package/_esm/utils/buildRequest.js.map +1 -1
- package/_esm/utils/errors/getNodeError.js +1 -2
- package/_esm/utils/errors/getNodeError.js.map +1 -1
- package/_esm/utils/index.js +1 -0
- package/_esm/utils/index.js.map +1 -1
- package/_esm/utils/signature/serializeErc6492Signature.js +6 -2
- package/_esm/utils/signature/serializeErc6492Signature.js.map +1 -1
- package/_esm/utils/signature/serializeSignature.js +6 -2
- package/_esm/utils/signature/serializeSignature.js.map +1 -1
- package/_esm/utils/signature/verifyHash.js +19 -0
- package/_esm/utils/signature/verifyHash.js.map +1 -0
- package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts +2 -0
- package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts.map +1 -0
- package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts +648 -0
- package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts.map +1 -0
- package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts +464 -0
- package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts.map +1 -0
- package/_types/account-abstraction/accounts/toSmartAccount.d.ts +14 -0
- package/_types/account-abstraction/accounts/toSmartAccount.d.ts.map +1 -0
- package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts +32 -0
- package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts.map +1 -0
- package/_types/account-abstraction/accounts/types.d.ts +174 -0
- package/_types/account-abstraction/accounts/types.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts +62 -0
- package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/getSupportedEntryPoints.d.ts +30 -0
- package/_types/account-abstraction/actions/bundler/getSupportedEntryPoints.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/getUserOperation.d.ts +57 -0
- package/_types/account-abstraction/actions/bundler/getUserOperation.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/getUserOperationReceipt.d.ts +39 -0
- package/_types/account-abstraction/actions/bundler/getUserOperationReceipt.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts +106 -0
- package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts +60 -0
- package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts.map +1 -0
- package/_types/account-abstraction/actions/bundler/waitForUserOperationReceipt.d.ts +52 -0
- package/_types/account-abstraction/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -0
- package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts +49 -0
- package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -0
- package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts +55 -0
- package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -0
- package/_types/account-abstraction/clients/createBundlerClient.d.ts +66 -0
- package/_types/account-abstraction/clients/createBundlerClient.d.ts.map +1 -0
- package/_types/account-abstraction/clients/createPaymasterClient.d.ts +27 -0
- package/_types/account-abstraction/clients/createPaymasterClient.d.ts.map +1 -0
- package/_types/account-abstraction/clients/decorators/bundler.d.ts +206 -0
- package/_types/account-abstraction/clients/decorators/bundler.d.ts.map +1 -0
- package/_types/account-abstraction/clients/decorators/paymaster.d.ts +60 -0
- package/_types/account-abstraction/clients/decorators/paymaster.d.ts.map +1 -0
- package/_types/account-abstraction/constants/abis.d.ts +1468 -0
- package/_types/account-abstraction/constants/abis.d.ts.map +1 -0
- package/_types/account-abstraction/constants/address.d.ts +3 -0
- package/_types/account-abstraction/constants/address.d.ts.map +1 -0
- package/_types/account-abstraction/errors/bundler.d.ts +391 -0
- package/_types/account-abstraction/errors/bundler.d.ts.map +1 -0
- package/_types/account-abstraction/errors/userOperation.d.ts +41 -0
- package/_types/account-abstraction/errors/userOperation.d.ts.map +1 -0
- package/_types/account-abstraction/index.d.ts +34 -0
- package/_types/account-abstraction/index.d.ts.map +1 -0
- package/_types/account-abstraction/types/account.d.ts +11 -0
- package/_types/account-abstraction/types/account.d.ts.map +1 -0
- package/_types/account-abstraction/types/entryPointVersion.d.ts +9 -0
- package/_types/account-abstraction/types/entryPointVersion.d.ts.map +1 -0
- package/_types/account-abstraction/types/rpc.d.ts +9 -0
- package/_types/account-abstraction/types/rpc.d.ts.map +1 -0
- package/_types/account-abstraction/types/userOperation.d.ts +157 -0
- package/_types/account-abstraction/types/userOperation.d.ts.map +1 -0
- package/_types/account-abstraction/utils/errors/getBundlerError.d.ts +8 -0
- package/_types/account-abstraction/utils/errors/getBundlerError.d.ts.map +1 -0
- package/_types/account-abstraction/utils/errors/getUserOperationError.d.ts +15 -0
- package/_types/account-abstraction/utils/errors/getUserOperationError.d.ts.map +1 -0
- package/_types/account-abstraction/utils/formatters/userOperation.d.ts +6 -0
- package/_types/account-abstraction/utils/formatters/userOperation.d.ts.map +1 -0
- package/_types/account-abstraction/utils/formatters/userOperationGas.d.ts +6 -0
- package/_types/account-abstraction/utils/formatters/userOperationGas.d.ts.map +1 -0
- package/_types/account-abstraction/utils/formatters/userOperationReceipt.d.ts +6 -0
- package/_types/account-abstraction/utils/formatters/userOperationReceipt.d.ts.map +1 -0
- package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts +7 -0
- package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts.map +1 -0
- package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts +13 -0
- package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts.map +1 -0
- package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts +3 -0
- package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -0
- package/_types/accounts/index.d.ts +0 -1
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/privateKeyToAccount.d.ts +2 -1
- package/_types/accounts/privateKeyToAccount.d.ts.map +1 -1
- package/_types/accounts/toAccount.d.ts.map +1 -1
- package/_types/accounts/types.d.ts +14 -7
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/accounts/utils/parseAccount.d.ts +1 -1
- package/_types/accounts/utils/parseAccount.d.ts.map +1 -1
- package/_types/accounts/utils/sign.d.ts +9 -6
- package/_types/accounts/utils/sign.d.ts.map +1 -1
- package/_types/accounts/utils/signMessage.d.ts +1 -2
- package/_types/accounts/utils/signMessage.d.ts.map +1 -1
- package/_types/accounts/utils/signTypedData.d.ts +1 -2
- package/_types/accounts/utils/signTypedData.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +2 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/signMessage.d.ts.map +1 -1
- package/_types/actions/wallet/signTransaction.d.ts.map +1 -1
- package/_types/chains/definitions/bobaSepolia.d.ts +35 -0
- package/_types/chains/definitions/bobaSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/lisk.d.ts +2 -2
- package/_types/chains/definitions/playfiAlbireo.d.ts +2 -2
- package/_types/chains/definitions/zkSync.d.ts +2 -2
- package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +2 -2
- package/_types/chains/definitions/zkSyncLocalNode.d.ts +2 -2
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +2 -2
- package/_types/chains/definitions/zkSyncTestnet.d.ts +2 -2
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +2 -2
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/decorators/wallet.d.ts +1 -1
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/constants/abis.d.ts +0 -3
- package/_types/constants/abis.d.ts.map +1 -1
- package/_types/constants/address.d.ts +2 -0
- package/_types/constants/address.d.ts.map +1 -1
- package/_types/errors/account.d.ts +11 -0
- package/_types/errors/account.d.ts.map +1 -1
- package/_types/errors/rpc.d.ts +9 -3
- package/_types/errors/rpc.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/index.d.ts +5 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +239 -2
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/types/multicall.d.ts +1 -1
- package/_types/types/multicall.d.ts.map +1 -1
- package/_types/types/utils.d.ts +2 -2
- package/_types/types/utils.d.ts.map +1 -1
- package/_types/utils/buildRequest.d.ts.map +1 -1
- package/_types/utils/errors/getNodeError.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +1 -1
- package/_types/utils/index.d.ts +1 -0
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/signature/hashTypedData.d.ts +2 -2
- package/_types/utils/signature/hashTypedData.d.ts.map +1 -1
- package/_types/utils/signature/serializeErc6492Signature.d.ts +7 -4
- package/_types/utils/signature/serializeErc6492Signature.d.ts.map +1 -1
- package/_types/utils/signature/serializeSignature.d.ts +8 -2
- package/_types/utils/signature/serializeSignature.d.ts.map +1 -1
- package/_types/utils/signature/verifyHash.d.ts +30 -0
- package/_types/utils/signature/verifyHash.d.ts.map +1 -0
- package/_types/zksync/chainConfig.d.ts +2 -2
- package/_types/zksync/formatters.d.ts +2 -2
- package/account-abstraction/accounts/createWebAuthnCredential.ts +7 -0
- package/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts +817 -0
- package/account-abstraction/accounts/implementations/toSoladySmartAccount.ts +794 -0
- package/account-abstraction/accounts/toSmartAccount.ts +126 -0
- package/account-abstraction/accounts/toWebAuthnAccount.ts +56 -0
- package/account-abstraction/accounts/types.ts +208 -0
- package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +170 -0
- package/account-abstraction/actions/bundler/getSupportedEntryPoints.ts +33 -0
- package/account-abstraction/actions/bundler/getUserOperation.ts +85 -0
- package/account-abstraction/actions/bundler/getUserOperationReceipt.ts +64 -0
- package/account-abstraction/actions/bundler/prepareUserOperation.ts +637 -0
- package/account-abstraction/actions/bundler/sendUserOperation.ts +149 -0
- package/account-abstraction/actions/bundler/waitForUserOperationReceipt.ts +139 -0
- package/account-abstraction/actions/paymaster/getPaymasterData.ts +135 -0
- package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +138 -0
- package/account-abstraction/clients/createBundlerClient.ts +155 -0
- package/account-abstraction/clients/createPaymasterClient.ts +78 -0
- package/account-abstraction/clients/decorators/bundler.ts +296 -0
- package/account-abstraction/clients/decorators/paymaster.ts +81 -0
- package/account-abstraction/constants/abis.ts +1404 -0
- package/account-abstraction/constants/address.ts +4 -0
- package/account-abstraction/errors/bundler.ts +781 -0
- package/account-abstraction/errors/userOperation.ts +111 -0
- package/account-abstraction/index.ts +228 -0
- package/account-abstraction/package.json +6 -0
- package/account-abstraction/types/account.ts +21 -0
- package/account-abstraction/types/entryPointVersion.ts +24 -0
- package/account-abstraction/types/rpc.ts +29 -0
- package/account-abstraction/types/userOperation.ts +262 -0
- package/account-abstraction/utils/errors/getBundlerError.ts +309 -0
- package/account-abstraction/utils/errors/getUserOperationError.ts +153 -0
- package/account-abstraction/utils/formatters/userOperation.ts +31 -0
- package/account-abstraction/utils/formatters/userOperationGas.ts +26 -0
- package/account-abstraction/utils/formatters/userOperationReceipt.ts +24 -0
- package/account-abstraction/utils/formatters/userOperationRequest.ts +53 -0
- package/account-abstraction/utils/userOperation/getUserOperationHash.ts +138 -0
- package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +64 -0
- package/accounts/index.ts +1 -1
- package/accounts/privateKeyToAccount.ts +5 -0
- package/accounts/toAccount.ts +3 -0
- package/accounts/types.ts +34 -12
- package/accounts/utils/parseAccount.ts +6 -3
- package/accounts/utils/sign.ts +24 -8
- package/accounts/utils/signMessage.ts +1 -7
- package/accounts/utils/signTypedData.ts +2 -7
- package/actions/wallet/sendTransaction.ts +48 -27
- package/actions/wallet/signMessage.ts +2 -1
- package/actions/wallet/signTransaction.ts +1 -2
- package/actions/wallet/signTypedData.ts +1 -1
- package/chains/definitions/bobaSepolia.ts +20 -0
- package/chains/index.ts +1 -0
- package/clients/decorators/public.ts +2 -3
- package/clients/decorators/wallet.ts +1 -2
- package/constants/abis.ts +0 -3
- package/constants/address.ts +4 -0
- package/errors/account.ts +22 -1
- package/errors/contract.ts +1 -1
- package/errors/rpc.ts +6 -6
- package/errors/version.ts +1 -1
- package/index.ts +20 -3
- package/package.json +7 -1
- package/types/eip1193.ts +314 -2
- package/types/multicall.ts +1 -1
- package/types/utils.ts +6 -5
- package/utils/buildRequest.ts +4 -2
- package/utils/errors/getNodeError.ts +1 -2
- package/utils/index.ts +6 -0
- package/utils/signature/hashTypedData.ts +6 -6
- package/utils/signature/serializeErc6492Signature.ts +17 -8
- package/utils/signature/serializeSignature.ts +24 -4
- package/utils/signature/verifyHash.ts +54 -0
@@ -0,0 +1,637 @@
|
|
1
|
+
import type { Address, Narrow } from 'abitype'
|
2
|
+
import {
|
3
|
+
type ParseAccountErrorType,
|
4
|
+
parseAccount,
|
5
|
+
} from '../../../accounts/utils/parseAccount.js'
|
6
|
+
import {
|
7
|
+
type EstimateFeesPerGasErrorType,
|
8
|
+
estimateFeesPerGas,
|
9
|
+
} from '../../../actions/public/estimateFeesPerGas.js'
|
10
|
+
import type { Client } from '../../../clients/createClient.js'
|
11
|
+
import type { Transport } from '../../../clients/transports/createTransport.js'
|
12
|
+
import { AccountNotFoundError } from '../../../errors/account.js'
|
13
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
14
|
+
import type { Chain } from '../../../types/chain.js'
|
15
|
+
import type { ContractFunctionParameters } from '../../../types/contract.js'
|
16
|
+
import type { Hex } from '../../../types/misc.js'
|
17
|
+
import type {
|
18
|
+
Assign,
|
19
|
+
OneOf,
|
20
|
+
Prettify,
|
21
|
+
UnionOmit,
|
22
|
+
} from '../../../types/utils.js'
|
23
|
+
import {
|
24
|
+
type EncodeFunctionDataErrorType,
|
25
|
+
encodeFunctionData,
|
26
|
+
} from '../../../utils/abi/encodeFunctionData.js'
|
27
|
+
import { type ConcatErrorType, concat } from '../../../utils/data/concat.js'
|
28
|
+
import { getAction } from '../../../utils/getAction.js'
|
29
|
+
import { parseGwei } from '../../../utils/unit/parseGwei.js'
|
30
|
+
import type { SmartAccount } from '../../accounts/types.js'
|
31
|
+
import type { BundlerClient } from '../../clients/createBundlerClient.js'
|
32
|
+
import type { PaymasterActions } from '../../clients/decorators/paymaster.js'
|
33
|
+
import type {
|
34
|
+
DeriveSmartAccount,
|
35
|
+
GetSmartAccountParameter,
|
36
|
+
} from '../../types/account.js'
|
37
|
+
import type {
|
38
|
+
DeriveEntryPointVersion,
|
39
|
+
EntryPointVersion,
|
40
|
+
} from '../../types/entryPointVersion.js'
|
41
|
+
import type {
|
42
|
+
UserOperation,
|
43
|
+
UserOperationCall,
|
44
|
+
UserOperationCalls,
|
45
|
+
UserOperationRequest,
|
46
|
+
} from '../../types/userOperation.js'
|
47
|
+
import {
|
48
|
+
type GetPaymasterDataErrorType,
|
49
|
+
getPaymasterData as getPaymasterData_,
|
50
|
+
} from '../paymaster/getPaymasterData.js'
|
51
|
+
import {
|
52
|
+
type GetPaymasterStubDataErrorType,
|
53
|
+
getPaymasterStubData as getPaymasterStubData_,
|
54
|
+
} from '../paymaster/getPaymasterStubData.js'
|
55
|
+
import {
|
56
|
+
type EstimateUserOperationGasParameters,
|
57
|
+
estimateUserOperationGas,
|
58
|
+
} from './estimateUserOperationGas.js'
|
59
|
+
|
60
|
+
const defaultParameters = [
|
61
|
+
'factory',
|
62
|
+
'fees',
|
63
|
+
'gas',
|
64
|
+
'paymaster',
|
65
|
+
'nonce',
|
66
|
+
'signature',
|
67
|
+
] as const
|
68
|
+
|
69
|
+
export type PrepareUserOperationParameterType =
|
70
|
+
| 'factory'
|
71
|
+
| 'fees'
|
72
|
+
| 'gas'
|
73
|
+
| 'paymaster'
|
74
|
+
| 'nonce'
|
75
|
+
| 'signature'
|
76
|
+
|
77
|
+
type FactoryProperties<
|
78
|
+
entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
79
|
+
> =
|
80
|
+
| (entryPointVersion extends '0.7'
|
81
|
+
? {
|
82
|
+
factory: UserOperation['factory']
|
83
|
+
factoryData: UserOperation['factoryData']
|
84
|
+
}
|
85
|
+
: never)
|
86
|
+
| (entryPointVersion extends '0.6'
|
87
|
+
? {
|
88
|
+
initCode: UserOperation['initCode']
|
89
|
+
}
|
90
|
+
: never)
|
91
|
+
|
92
|
+
type GasProperties<
|
93
|
+
entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
94
|
+
> =
|
95
|
+
| (entryPointVersion extends '0.7'
|
96
|
+
? {
|
97
|
+
callGasLimit: UserOperation['callGasLimit']
|
98
|
+
preVerificationGas: UserOperation['preVerificationGas']
|
99
|
+
verificationGasLimit: UserOperation['verificationGasLimit']
|
100
|
+
paymasterPostOpGasLimit: UserOperation['paymasterPostOpGasLimit']
|
101
|
+
paymasterVerificationGasLimit: UserOperation['paymasterVerificationGasLimit']
|
102
|
+
}
|
103
|
+
: never)
|
104
|
+
| (entryPointVersion extends '0.6'
|
105
|
+
? {
|
106
|
+
callGasLimit: UserOperation['callGasLimit']
|
107
|
+
preVerificationGas: UserOperation['preVerificationGas']
|
108
|
+
verificationGasLimit: UserOperation['verificationGasLimit']
|
109
|
+
}
|
110
|
+
: never)
|
111
|
+
|
112
|
+
type FeeProperties = {
|
113
|
+
maxFeePerGas: UserOperation['maxFeePerGas']
|
114
|
+
maxPriorityFeePerGas: UserOperation['maxPriorityFeePerGas']
|
115
|
+
}
|
116
|
+
|
117
|
+
type NonceProperties = {
|
118
|
+
nonce: UserOperation['nonce']
|
119
|
+
}
|
120
|
+
|
121
|
+
type PaymasterProperties<
|
122
|
+
entryPointVersion extends EntryPointVersion = EntryPointVersion,
|
123
|
+
> =
|
124
|
+
| (entryPointVersion extends '0.7'
|
125
|
+
? {
|
126
|
+
paymaster: UserOperation['paymaster']
|
127
|
+
paymasterData: UserOperation['paymasterData']
|
128
|
+
paymasterPostOpGasLimit: UserOperation['paymasterPostOpGasLimit']
|
129
|
+
paymasterVerificationGasLimit: UserOperation['paymasterVerificationGasLimit']
|
130
|
+
}
|
131
|
+
: never)
|
132
|
+
| (entryPointVersion extends '0.6'
|
133
|
+
? {
|
134
|
+
paymasterAndData: UserOperation['paymasterAndData']
|
135
|
+
}
|
136
|
+
: never)
|
137
|
+
|
138
|
+
type SignatureProperties = {
|
139
|
+
signature: UserOperation['signature']
|
140
|
+
}
|
141
|
+
|
142
|
+
export type PrepareUserOperationRequest<
|
143
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
144
|
+
accountOverride extends SmartAccount | undefined = SmartAccount | undefined,
|
145
|
+
calls extends readonly unknown[] = readonly unknown[],
|
146
|
+
//
|
147
|
+
_derivedAccount extends SmartAccount | undefined = DeriveSmartAccount<
|
148
|
+
account,
|
149
|
+
accountOverride
|
150
|
+
>,
|
151
|
+
_derivedVersion extends
|
152
|
+
EntryPointVersion = DeriveEntryPointVersion<_derivedAccount>,
|
153
|
+
> = Assign<
|
154
|
+
UserOperationRequest<_derivedVersion>,
|
155
|
+
OneOf<{ calls: UserOperationCalls<Narrow<calls>> } | { callData: Hex }> & {
|
156
|
+
parameters?: readonly PrepareUserOperationParameterType[] | undefined
|
157
|
+
paymaster?:
|
158
|
+
| Address
|
159
|
+
| true
|
160
|
+
| {
|
161
|
+
/** Retrieves paymaster-related User Operation properties to be used for sending the User Operation. */
|
162
|
+
getPaymasterData?: PaymasterActions['getPaymasterData'] | undefined
|
163
|
+
/** Retrieves paymaster-related User Operation properties to be used for gas estimation. */
|
164
|
+
getPaymasterStubData?:
|
165
|
+
| PaymasterActions['getPaymasterStubData']
|
166
|
+
| undefined
|
167
|
+
}
|
168
|
+
| undefined
|
169
|
+
/** Paymaster context to pass to `getPaymasterData` and `getPaymasterStubData` calls. */
|
170
|
+
paymasterContext?: unknown | undefined
|
171
|
+
}
|
172
|
+
>
|
173
|
+
|
174
|
+
export type PrepareUserOperationParameters<
|
175
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
176
|
+
accountOverride extends SmartAccount | undefined = SmartAccount | undefined,
|
177
|
+
calls extends readonly unknown[] = readonly unknown[],
|
178
|
+
request extends PrepareUserOperationRequest<
|
179
|
+
account,
|
180
|
+
accountOverride,
|
181
|
+
calls
|
182
|
+
> = PrepareUserOperationRequest<account, accountOverride, calls>,
|
183
|
+
> = request & GetSmartAccountParameter<account, accountOverride>
|
184
|
+
|
185
|
+
export type PrepareUserOperationReturnType<
|
186
|
+
account extends SmartAccount | undefined = SmartAccount | undefined,
|
187
|
+
accountOverride extends SmartAccount | undefined = SmartAccount | undefined,
|
188
|
+
calls extends readonly unknown[] = readonly unknown[],
|
189
|
+
request extends PrepareUserOperationRequest<
|
190
|
+
account,
|
191
|
+
accountOverride,
|
192
|
+
calls
|
193
|
+
> = PrepareUserOperationRequest<account, accountOverride, calls>,
|
194
|
+
//
|
195
|
+
_parameters extends
|
196
|
+
PrepareUserOperationParameterType = request['parameters'] extends readonly PrepareUserOperationParameterType[]
|
197
|
+
? request['parameters'][number]
|
198
|
+
: (typeof defaultParameters)[number],
|
199
|
+
_derivedAccount extends SmartAccount | undefined = DeriveSmartAccount<
|
200
|
+
account,
|
201
|
+
accountOverride
|
202
|
+
>,
|
203
|
+
_derivedVersion extends
|
204
|
+
EntryPointVersion = DeriveEntryPointVersion<_derivedAccount>,
|
205
|
+
> = Prettify<
|
206
|
+
UnionOmit<request, 'calls' | 'parameters'> & {
|
207
|
+
callData: Hex
|
208
|
+
paymasterAndData: _derivedVersion extends '0.6' ? Hex : undefined
|
209
|
+
sender: UserOperation['sender']
|
210
|
+
} & (Extract<_parameters, 'factory'> extends never
|
211
|
+
? {}
|
212
|
+
: FactoryProperties<_derivedVersion>) &
|
213
|
+
(Extract<_parameters, 'nonce'> extends never ? {} : NonceProperties) &
|
214
|
+
(Extract<_parameters, 'fees'> extends never ? {} : FeeProperties) &
|
215
|
+
(Extract<_parameters, 'gas'> extends never
|
216
|
+
? {}
|
217
|
+
: GasProperties<_derivedVersion>) &
|
218
|
+
(Extract<_parameters, 'paymaster'> extends never
|
219
|
+
? {}
|
220
|
+
: PaymasterProperties<_derivedVersion>) &
|
221
|
+
(Extract<_parameters, 'signature'> extends never ? {} : SignatureProperties)
|
222
|
+
>
|
223
|
+
|
224
|
+
export type PrepareUserOperationErrorType =
|
225
|
+
| ParseAccountErrorType
|
226
|
+
| GetPaymasterStubDataErrorType
|
227
|
+
| GetPaymasterDataErrorType
|
228
|
+
| EncodeFunctionDataErrorType
|
229
|
+
| ConcatErrorType
|
230
|
+
| EstimateFeesPerGasErrorType
|
231
|
+
| ErrorType
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Prepares a User Operation and fills in missing properties.
|
235
|
+
*
|
236
|
+
* - Docs: https://viem.sh/actions/bundler/prepareUserOperation
|
237
|
+
*
|
238
|
+
* @param args - {@link PrepareUserOperationParameters}
|
239
|
+
* @returns The User Operation. {@link PrepareUserOperationReturnType}
|
240
|
+
*
|
241
|
+
* @example
|
242
|
+
* import { createBundlerClient, http } from 'viem'
|
243
|
+
* import { toSmartAccount } from 'viem/accounts'
|
244
|
+
* import { mainnet } from 'viem/chains'
|
245
|
+
* import { prepareUserOperation } from 'viem/actions'
|
246
|
+
*
|
247
|
+
* const account = await toSmartAccount({ ... })
|
248
|
+
*
|
249
|
+
* const client = createBundlerClient({
|
250
|
+
* chain: mainnet,
|
251
|
+
* transport: http(),
|
252
|
+
* })
|
253
|
+
*
|
254
|
+
* const request = await prepareUserOperation(client, {
|
255
|
+
* account,
|
256
|
+
* calls: [{ to: '0x...', value: parseEther('1') }],
|
257
|
+
* })
|
258
|
+
*/
|
259
|
+
export async function prepareUserOperation<
|
260
|
+
account extends SmartAccount | undefined,
|
261
|
+
const calls extends readonly unknown[],
|
262
|
+
const request extends PrepareUserOperationRequest<
|
263
|
+
account,
|
264
|
+
accountOverride,
|
265
|
+
calls
|
266
|
+
>,
|
267
|
+
accountOverride extends SmartAccount | undefined = undefined,
|
268
|
+
>(
|
269
|
+
client: Client<Transport, Chain | undefined, account>,
|
270
|
+
parameters_: PrepareUserOperationParameters<
|
271
|
+
account,
|
272
|
+
accountOverride,
|
273
|
+
calls,
|
274
|
+
request
|
275
|
+
>,
|
276
|
+
): Promise<
|
277
|
+
PrepareUserOperationReturnType<account, accountOverride, calls, request>
|
278
|
+
> {
|
279
|
+
const parameters = parameters_ as PrepareUserOperationParameters
|
280
|
+
const {
|
281
|
+
account: account_ = client.account,
|
282
|
+
parameters: properties = defaultParameters,
|
283
|
+
} = parameters
|
284
|
+
|
285
|
+
////////////////////////////////////////////////////////////////////////////////
|
286
|
+
// Assert that an Account is defined.
|
287
|
+
////////////////////////////////////////////////////////////////////////////////
|
288
|
+
|
289
|
+
if (!account_) throw new AccountNotFoundError()
|
290
|
+
const account = parseAccount(account_)
|
291
|
+
|
292
|
+
////////////////////////////////////////////////////////////////////////////////
|
293
|
+
// Declare typed Bundler Client.
|
294
|
+
////////////////////////////////////////////////////////////////////////////////
|
295
|
+
|
296
|
+
const bundlerClient = client as unknown as BundlerClient
|
297
|
+
|
298
|
+
////////////////////////////////////////////////////////////////////////////////
|
299
|
+
// Declare Paymaster properties.
|
300
|
+
////////////////////////////////////////////////////////////////////////////////
|
301
|
+
|
302
|
+
const paymaster = parameters.paymaster ?? bundlerClient?.paymaster
|
303
|
+
const paymasterAddress = typeof paymaster === 'string' ? paymaster : undefined
|
304
|
+
const { getPaymasterStubData, getPaymasterData } = (() => {
|
305
|
+
// If `paymaster: true`, we will assume the Bundler Client supports Paymaster Actions.
|
306
|
+
if (paymaster === true)
|
307
|
+
return {
|
308
|
+
getPaymasterStubData: (parameters: any) =>
|
309
|
+
getAction(
|
310
|
+
bundlerClient,
|
311
|
+
getPaymasterStubData_,
|
312
|
+
'getPaymasterStubData',
|
313
|
+
)(parameters),
|
314
|
+
getPaymasterData: (parameters: any) =>
|
315
|
+
getAction(
|
316
|
+
bundlerClient,
|
317
|
+
getPaymasterData_,
|
318
|
+
'getPaymasterData',
|
319
|
+
)(parameters),
|
320
|
+
}
|
321
|
+
|
322
|
+
// If Actions are passed to `paymaster` (via Paymaster Client or directly), we will use them.
|
323
|
+
if (typeof paymaster === 'object') {
|
324
|
+
const { getPaymasterStubData, getPaymasterData } = paymaster
|
325
|
+
return {
|
326
|
+
getPaymasterStubData: (getPaymasterData && getPaymasterStubData
|
327
|
+
? getPaymasterStubData
|
328
|
+
: getPaymasterData) as typeof getPaymasterStubData,
|
329
|
+
getPaymasterData:
|
330
|
+
getPaymasterData && getPaymasterStubData
|
331
|
+
? getPaymasterData
|
332
|
+
: undefined,
|
333
|
+
}
|
334
|
+
}
|
335
|
+
|
336
|
+
// No Paymaster functions.
|
337
|
+
return {
|
338
|
+
getPaymasterStubData: undefined,
|
339
|
+
getPaymasterData: undefined,
|
340
|
+
}
|
341
|
+
})()
|
342
|
+
const paymasterContext = parameters.paymasterContext
|
343
|
+
? parameters.paymasterContext
|
344
|
+
: bundlerClient?.paymasterContext
|
345
|
+
|
346
|
+
////////////////////////////////////////////////////////////////////////////////
|
347
|
+
// Set up the User Operation request.
|
348
|
+
////////////////////////////////////////////////////////////////////////////////
|
349
|
+
|
350
|
+
let request = {
|
351
|
+
...parameters,
|
352
|
+
paymaster: paymasterAddress,
|
353
|
+
sender: account.address,
|
354
|
+
} as PrepareUserOperationRequest
|
355
|
+
|
356
|
+
////////////////////////////////////////////////////////////////////////////////
|
357
|
+
// Concurrently prepare properties required to fill the User Operation.
|
358
|
+
////////////////////////////////////////////////////////////////////////////////
|
359
|
+
|
360
|
+
const [callData, factory, fees, nonce, signature] = await Promise.all([
|
361
|
+
(async () => {
|
362
|
+
if (parameters.calls)
|
363
|
+
return account.encodeCalls(
|
364
|
+
parameters.calls.map((call_) => {
|
365
|
+
const call = call_ as
|
366
|
+
| UserOperationCall
|
367
|
+
| (ContractFunctionParameters & { to: Address; value: bigint })
|
368
|
+
if ('abi' in call)
|
369
|
+
return {
|
370
|
+
data: encodeFunctionData(call),
|
371
|
+
to: call.to,
|
372
|
+
value: call.value,
|
373
|
+
} as UserOperationCall
|
374
|
+
return call as UserOperationCall
|
375
|
+
}),
|
376
|
+
)
|
377
|
+
return parameters.callData
|
378
|
+
})(),
|
379
|
+
(async () => {
|
380
|
+
if (!properties.includes('factory')) return undefined
|
381
|
+
if (parameters.initCode) return { initCode: parameters.initCode }
|
382
|
+
if (parameters.factory && parameters.factoryData) {
|
383
|
+
return {
|
384
|
+
factory: parameters.factory,
|
385
|
+
factoryData: parameters.factoryData,
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
const { factory, factoryData } = await account.getFactoryArgs()
|
390
|
+
|
391
|
+
if (account.entryPoint.version === '0.6')
|
392
|
+
return {
|
393
|
+
initCode:
|
394
|
+
factory && factoryData ? concat([factory, factoryData]) : undefined,
|
395
|
+
}
|
396
|
+
return {
|
397
|
+
factory,
|
398
|
+
factoryData,
|
399
|
+
}
|
400
|
+
})(),
|
401
|
+
(async () => {
|
402
|
+
if (!properties.includes('fees')) return undefined
|
403
|
+
|
404
|
+
// If the Bundler Client has a `estimateFeesPerGas` hook, run it.
|
405
|
+
if (bundlerClient?.userOperation?.estimateFeesPerGas) {
|
406
|
+
const fees = await bundlerClient.userOperation.estimateFeesPerGas({
|
407
|
+
account,
|
408
|
+
bundlerClient,
|
409
|
+
userOperation: request as UserOperation,
|
410
|
+
})
|
411
|
+
request = {
|
412
|
+
...request,
|
413
|
+
...fees,
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
// If we have sufficient properties for fees, return them.
|
418
|
+
if (
|
419
|
+
typeof parameters.maxFeePerGas === 'bigint' &&
|
420
|
+
typeof parameters.maxPriorityFeePerGas === 'bigint'
|
421
|
+
)
|
422
|
+
return request
|
423
|
+
|
424
|
+
// Otherwise, we will need to estimate the fees to fill the fee properties.
|
425
|
+
try {
|
426
|
+
const client_ = 'client' in client ? (client.client as Client) : client
|
427
|
+
const fees = await getAction(
|
428
|
+
client_,
|
429
|
+
estimateFeesPerGas,
|
430
|
+
'estimateFeesPerGas',
|
431
|
+
)({
|
432
|
+
chain: client_.chain,
|
433
|
+
type: 'eip1559',
|
434
|
+
})
|
435
|
+
return {
|
436
|
+
maxFeePerGas:
|
437
|
+
typeof parameters.maxFeePerGas === 'bigint'
|
438
|
+
? parameters.maxFeePerGas
|
439
|
+
: BigInt(
|
440
|
+
// Bundlers unfortunately have strict rules on fee prechecks – we will need to set a generous buffer.
|
441
|
+
Math.max(
|
442
|
+
Number(2n * fees.maxFeePerGas),
|
443
|
+
Number(parseGwei('3')),
|
444
|
+
),
|
445
|
+
),
|
446
|
+
maxPriorityFeePerGas:
|
447
|
+
typeof parameters.maxPriorityFeePerGas === 'bigint'
|
448
|
+
? parameters.maxPriorityFeePerGas
|
449
|
+
: BigInt(
|
450
|
+
// Bundlers unfortunately have strict rules on fee prechecks – we will need to set a generous buffer.
|
451
|
+
Math.max(
|
452
|
+
Number(2n * fees.maxPriorityFeePerGas),
|
453
|
+
Number(parseGwei('1')),
|
454
|
+
),
|
455
|
+
),
|
456
|
+
}
|
457
|
+
} catch {
|
458
|
+
return undefined
|
459
|
+
}
|
460
|
+
})(),
|
461
|
+
(async () => {
|
462
|
+
if (!properties.includes('nonce')) return undefined
|
463
|
+
if (typeof parameters.nonce === 'bigint') return parameters.nonce
|
464
|
+
return account.getNonce()
|
465
|
+
})(),
|
466
|
+
(async () => {
|
467
|
+
if (!properties.includes('signature')) return undefined
|
468
|
+
return account.getStubSignature()
|
469
|
+
})(),
|
470
|
+
])
|
471
|
+
|
472
|
+
////////////////////////////////////////////////////////////////////////////////
|
473
|
+
// Fill User Operation with the prepared properties from above.
|
474
|
+
////////////////////////////////////////////////////////////////////////////////
|
475
|
+
|
476
|
+
if (typeof callData !== 'undefined') request.callData = callData
|
477
|
+
if (typeof factory !== 'undefined')
|
478
|
+
request = { ...request, ...(factory as any) }
|
479
|
+
if (typeof fees !== 'undefined') request = { ...request, ...(fees as any) }
|
480
|
+
if (typeof nonce !== 'undefined') request.nonce = nonce
|
481
|
+
if (typeof signature !== 'undefined') request.signature = signature
|
482
|
+
|
483
|
+
////////////////////////////////////////////////////////////////////////////////
|
484
|
+
// `initCode` is required to be filled with EntryPoint 0.6.
|
485
|
+
////////////////////////////////////////////////////////////////////////////////
|
486
|
+
|
487
|
+
// If no `initCode` is provided, we use an empty bytes string.
|
488
|
+
if (account.entryPoint.version === '0.6' && !request.initCode)
|
489
|
+
request.initCode = '0x'
|
490
|
+
|
491
|
+
////////////////////////////////////////////////////////////////////////////////
|
492
|
+
// Fill User Operation with paymaster-related properties for **gas estimation**.
|
493
|
+
////////////////////////////////////////////////////////////////////////////////
|
494
|
+
|
495
|
+
// console.log('wat')
|
496
|
+
|
497
|
+
// If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
|
498
|
+
// User Operation properties required to estimate the User Operation gas.
|
499
|
+
let isPaymasterPopulated = false
|
500
|
+
if (
|
501
|
+
properties.includes('paymaster') &&
|
502
|
+
getPaymasterStubData &&
|
503
|
+
!paymasterAddress &&
|
504
|
+
!parameters.paymasterAndData
|
505
|
+
) {
|
506
|
+
const {
|
507
|
+
isFinal = false,
|
508
|
+
sponsor,
|
509
|
+
...paymasterArgs
|
510
|
+
} = await getPaymasterStubData({
|
511
|
+
chainId: client.chain!.id!,
|
512
|
+
entryPointAddress: account.entryPoint.address,
|
513
|
+
context: paymasterContext,
|
514
|
+
...(request as UserOperation),
|
515
|
+
})
|
516
|
+
isPaymasterPopulated = isFinal
|
517
|
+
request = {
|
518
|
+
...request,
|
519
|
+
...paymasterArgs,
|
520
|
+
} as PrepareUserOperationRequest
|
521
|
+
}
|
522
|
+
|
523
|
+
////////////////////////////////////////////////////////////////////////////////
|
524
|
+
// `paymasterAndData` is required to be filled with EntryPoint 0.6.
|
525
|
+
////////////////////////////////////////////////////////////////////////////////
|
526
|
+
|
527
|
+
// If no `paymasterAndData` is provided, we use an empty bytes string.
|
528
|
+
if (account.entryPoint.version === '0.6' && !request.paymasterAndData)
|
529
|
+
request.paymasterAndData = '0x'
|
530
|
+
|
531
|
+
////////////////////////////////////////////////////////////////////////////////
|
532
|
+
// Fill User Operation with gas-related properties.
|
533
|
+
////////////////////////////////////////////////////////////////////////////////
|
534
|
+
|
535
|
+
if (properties.includes('gas')) {
|
536
|
+
// If the Account has opinionated gas estimation logic, run the `estimateGas` hook and
|
537
|
+
// fill the request with the prepared gas properties.
|
538
|
+
if (account.userOperation?.estimateGas) {
|
539
|
+
const gas = await account.userOperation.estimateGas(
|
540
|
+
request as UserOperation,
|
541
|
+
)
|
542
|
+
request = {
|
543
|
+
...request,
|
544
|
+
...gas,
|
545
|
+
} as PrepareUserOperationRequest
|
546
|
+
}
|
547
|
+
|
548
|
+
// If not all the gas properties are already populated, we will need to estimate the gas
|
549
|
+
// to fill the gas properties.
|
550
|
+
if (
|
551
|
+
typeof request.callGasLimit === 'undefined' ||
|
552
|
+
typeof request.preVerificationGas === 'undefined' ||
|
553
|
+
typeof request.verificationGasLimit === 'undefined' ||
|
554
|
+
(request.paymaster &&
|
555
|
+
typeof request.paymasterPostOpGasLimit === 'undefined') ||
|
556
|
+
(request.paymaster &&
|
557
|
+
typeof request.paymasterVerificationGasLimit === 'undefined')
|
558
|
+
) {
|
559
|
+
const gas = await getAction(
|
560
|
+
client,
|
561
|
+
estimateUserOperationGas,
|
562
|
+
'estimateUserOperationGas',
|
563
|
+
)({
|
564
|
+
account,
|
565
|
+
// Some Bundlers fail if nullish gas values are provided for gas estimation :') –
|
566
|
+
// so we will need to set a default zeroish value.
|
567
|
+
callGasLimit: 0n,
|
568
|
+
preVerificationGas: 0n,
|
569
|
+
verificationGasLimit: 0n,
|
570
|
+
...(request.paymaster
|
571
|
+
? {
|
572
|
+
paymasterPostOpGasLimit: 0n,
|
573
|
+
paymasterVerificationGasLimit: 0n,
|
574
|
+
}
|
575
|
+
: {}),
|
576
|
+
...request,
|
577
|
+
} as EstimateUserOperationGasParameters)
|
578
|
+
request = {
|
579
|
+
...request,
|
580
|
+
callGasLimit: request.callGasLimit ?? gas.callGasLimit,
|
581
|
+
preVerificationGas:
|
582
|
+
request.preVerificationGas ?? gas.preVerificationGas,
|
583
|
+
verificationGasLimit:
|
584
|
+
request.verificationGasLimit ?? gas.verificationGasLimit,
|
585
|
+
paymasterPostOpGasLimit:
|
586
|
+
request.paymasterPostOpGasLimit ?? gas.paymasterPostOpGasLimit,
|
587
|
+
paymasterVerificationGasLimit:
|
588
|
+
request.paymasterVerificationGasLimit ??
|
589
|
+
gas.paymasterVerificationGasLimit,
|
590
|
+
} as PrepareUserOperationRequest
|
591
|
+
}
|
592
|
+
}
|
593
|
+
|
594
|
+
////////////////////////////////////////////////////////////////////////////////
|
595
|
+
// Fill User Operation with paymaster-related properties for **sending** the User Operation.
|
596
|
+
////////////////////////////////////////////////////////////////////////////////
|
597
|
+
|
598
|
+
// If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
|
599
|
+
// User Operation properties required to send the User Operation.
|
600
|
+
if (
|
601
|
+
properties.includes('paymaster') &&
|
602
|
+
getPaymasterData &&
|
603
|
+
!paymasterAddress &&
|
604
|
+
!parameters.paymasterAndData &&
|
605
|
+
!isPaymasterPopulated
|
606
|
+
) {
|
607
|
+
// Retrieve paymaster-related User Operation properties to be used for **sending** the User Operation.
|
608
|
+
const paymaster = await getPaymasterData({
|
609
|
+
chainId: client.chain!.id!,
|
610
|
+
entryPointAddress: account.entryPoint.address,
|
611
|
+
context: paymasterContext,
|
612
|
+
...(request as UserOperation),
|
613
|
+
})
|
614
|
+
request = {
|
615
|
+
...request,
|
616
|
+
...paymaster,
|
617
|
+
} as PrepareUserOperationRequest
|
618
|
+
}
|
619
|
+
|
620
|
+
////////////////////////////////////////////////////////////////////////////////
|
621
|
+
// Remove redundant properties that do not conform to the User Operation schema.
|
622
|
+
////////////////////////////////////////////////////////////////////////////////
|
623
|
+
|
624
|
+
delete request.calls
|
625
|
+
delete request.parameters
|
626
|
+
delete request.paymasterContext
|
627
|
+
if (typeof request.paymaster !== 'string') delete request.paymaster
|
628
|
+
|
629
|
+
////////////////////////////////////////////////////////////////////////////////
|
630
|
+
|
631
|
+
return request as unknown as PrepareUserOperationReturnType<
|
632
|
+
account,
|
633
|
+
accountOverride,
|
634
|
+
calls,
|
635
|
+
request
|
636
|
+
>
|
637
|
+
}
|