diff --git a/packages/alchemy/e2e-tests/simple-account.test.ts b/packages/alchemy/e2e-tests/simple-account.test.ts index e710362e38..651d770cb9 100644 --- a/packages/alchemy/e2e-tests/simple-account.test.ts +++ b/packages/alchemy/e2e-tests/simple-account.test.ts @@ -1,7 +1,4 @@ -import type { - PublicErc4337Client, - UserOperationOverrides, -} from "@alchemy/aa-core"; +import type { UserOperationOverrides } from "@alchemy/aa-core"; import { LogLevel, Logger, @@ -20,7 +17,6 @@ import { } from "viem"; import { mnemonicToAccount } from "viem/accounts"; import { sepolia } from "viem/chains"; -import type { SimulateUserOperationAssetChangesResponse } from "../src/middleware/types/index.js"; import { AlchemyProvider } from "../src/provider.js"; import { API_KEY, OWNER_MNEMONIC, PAYMASTER_POLICY_ID } from "./constants.js"; @@ -254,7 +250,7 @@ describe("Simple Account Tests", () => { chain, }); - const simulatedAssetChanges: SimulateUserOperationAssetChangesResponse = + const simulatedAssetChanges = await provider.simulateUserOperationAssetChanges({ target: provider.getEntryPointAddress(), data: "0x", @@ -326,7 +322,7 @@ const givenConnectedProvider = ({ }, }, }).connect( - (provider: PublicErc4337Client) => + (provider) => new SimpleSmartContractAccount({ chain, owner, diff --git a/packages/alchemy/src/middleware/gas-manager.ts b/packages/alchemy/src/middleware/gas-manager.ts index eae2c1b151..9ac692e613 100644 --- a/packages/alchemy/src/middleware/gas-manager.ts +++ b/packages/alchemy/src/middleware/gas-manager.ts @@ -54,7 +54,7 @@ export const withAlchemyGasManager =

( .withGasEstimator(async (struct, overrides, feeOptions) => { // but if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override), // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called - if (overrides?.paymasterAndData != null) { + if (overrides?.paymasterAndData === "0x") { const result = await fallbackGasEstimator( struct, overrides, @@ -80,7 +80,7 @@ export const withAlchemyGasManager =

( // but if user is bypassing paymaster to fallback to having the account to pay the gas (one-off override), // we cannot delegate gas estimation to the bundler because paymaster middleware will not be called - if (overrides?.paymasterAndData != null) { + if (overrides?.paymasterAndData === "0x") { const result = await fallbackFeeDataGetter( struct, overrides, @@ -160,7 +160,7 @@ const withAlchemyPaymasterAndDataMiddleware =

( const withAlchemyGasAndPaymasterAndDataMiddleware =

( provider: P, config: AlchemyGasManagerConfig -): Parameters["0"] => ({ +): Parameters["0"] => ({ paymasterDataMiddleware: async (struct, overrides, feeOptions) => { const userOperation: UserOperationRequest = deepHexlify( await resolveProperties(struct) diff --git a/packages/core/src/provider/base.ts b/packages/core/src/provider/base.ts index c3e0fe4d22..4465be42bf 100644 --- a/packages/core/src/provider/base.ts +++ b/packages/core/src/provider/base.ts @@ -399,11 +399,6 @@ export class SmartAccountProvider< signature: uoToDrop.signature, } as UserOperationStruct; - Logger.debug( - "[SmartAccountProvider] dropAndReplaceUserOperation uoToSubmit", - uoToSubmit - ); - // Run once to get the fee estimates // This can happen at any part of the middleware stack, so we want to run it all const { maxFeePerGas, maxPriorityFeePerGas } = @@ -530,9 +525,9 @@ export class SmartAccountProvider< overrides ?? {}; if ( - callGasLimit === undefined || - verificationGasLimit === undefined || - preVerificationGas === undefined + callGasLimit == null || + verificationGasLimit == null || + preVerificationGas == null ) { const request = deepHexlify(await resolveProperties(struct)); const estimates = await this.rpcClient.estimateUserOperationGas( diff --git a/packages/core/src/provider/types.ts b/packages/core/src/provider/types.ts index 78ef21eda8..1efdde77a6 100644 --- a/packages/core/src/provider/types.ts +++ b/packages/core/src/provider/types.ts @@ -329,7 +329,7 @@ export interface ISmartAccountProvider< * Overrides the feeDataGetter middleware which is used for setting the fee fields on the UserOperation * prior to execution. * - * @param override - a function for overriding the default feeDataGetter middleware + * @param override - a function for overriding the default feeDataGetter middleware * @param feeOptions - optional FeeDataFeeOptions to set at the global level of the provider. * @returns */ diff --git a/packages/core/src/utils/bigint.ts b/packages/core/src/utils/bigint.ts index ee9518a5fc..5242abdd8e 100644 --- a/packages/core/src/utils/bigint.ts +++ b/packages/core/src/utils/bigint.ts @@ -6,9 +6,9 @@ import type { BigNumberish } from "../types"; * @param args a list of bigints to get the max of * @returns the max bigint in the list */ -export const bigIntMax = (...args: bigint[]) => { +export const bigIntMax = (...args: bigint[]): bigint => { if (!args.length) { - return undefined; + throw new Error("bigIntMax requires at least one argument"); } return args.reduce((m, c) => (m > c ? m : c)); @@ -20,9 +20,9 @@ export const bigIntMax = (...args: bigint[]) => { * @param args a list of bigints to get the max of * @returns the min bigint in the list */ -export const bigIntMin = (...args: bigint[]) => { +export const bigIntMin = (...args: bigint[]): bigint => { if (!args.length) { - return undefined; + throw new Error("bigIntMin requires at least one argument"); } return args.reduce((m, c) => (m < c ? m : c));