@account-kit/infra 4.12.1-alpha.0 → 4.13.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.
Files changed (36) hide show
  1. package/dist/esm/actions/types.d.ts +2 -14
  2. package/dist/esm/actions/types.js.map +1 -1
  3. package/dist/esm/alchemyTransport.js +0 -1
  4. package/dist/esm/alchemyTransport.js.map +1 -1
  5. package/dist/esm/client/smartAccountClient.js +4 -10
  6. package/dist/esm/client/smartAccountClient.js.map +1 -1
  7. package/dist/esm/client/types.d.ts +2 -11
  8. package/dist/esm/client/types.js.map +1 -1
  9. package/dist/esm/index.d.ts +1 -1
  10. package/dist/esm/index.js +1 -1
  11. package/dist/esm/index.js.map +1 -1
  12. package/dist/esm/middleware/gasManager.d.ts +0 -20
  13. package/dist/esm/middleware/gasManager.js +1 -121
  14. package/dist/esm/middleware/gasManager.js.map +1 -1
  15. package/dist/esm/version.d.ts +1 -1
  16. package/dist/esm/version.js +1 -1
  17. package/dist/esm/version.js.map +1 -1
  18. package/dist/types/actions/types.d.ts +2 -14
  19. package/dist/types/actions/types.d.ts.map +1 -1
  20. package/dist/types/alchemyTransport.d.ts.map +1 -1
  21. package/dist/types/client/types.d.ts +2 -11
  22. package/dist/types/client/types.d.ts.map +1 -1
  23. package/dist/types/index.d.ts +1 -1
  24. package/dist/types/index.d.ts.map +1 -1
  25. package/dist/types/middleware/gasManager.d.ts +0 -20
  26. package/dist/types/middleware/gasManager.d.ts.map +1 -1
  27. package/dist/types/version.d.ts +1 -1
  28. package/dist/types/version.d.ts.map +1 -1
  29. package/package.json +5 -5
  30. package/src/actions/types.ts +2 -41
  31. package/src/alchemyTransport.ts +0 -1
  32. package/src/client/smartAccountClient.ts +4 -14
  33. package/src/client/types.ts +1 -13
  34. package/src/index.ts +1 -4
  35. package/src/middleware/gasManager.ts +2 -204
  36. package/src/version.ts +1 -1
@@ -1,5 +1,5 @@
1
- import type { UserOperationStruct, UserOperationRequest, UserOperationOverrides, EntryPointVersion } from "@aa-sdk/core";
2
- import type { Address, Hash, Hex } from "viem";
1
+ import type { UserOperationStruct } from "@aa-sdk/core";
2
+ import type { Address, Hash } from "viem";
3
3
  export declare enum SimulateAssetType {
4
4
  NATIVE = "NATIVE",
5
5
  ERC20 = "ERC20",
@@ -41,15 +41,3 @@ export interface SimulateAssetChange {
41
41
  name?: string;
42
42
  logo?: string;
43
43
  }
44
- export type RequestGasAndPaymasterAndDataRequest = [
45
- {
46
- policyId: string;
47
- entryPoint: Address;
48
- dummySignature: Hex;
49
- userOperation: UserOperationRequest;
50
- overrides?: UserOperationOverrides;
51
- }
52
- ];
53
- export type RequestGasAndPaymasterAndDataResponse<TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = Pick<UserOperationRequest, "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "maxFeePerGas" | "maxPriorityFeePerGas"> & (TEntryPointVersion extends "0.6.0" ? {
54
- paymasterAndData: UserOperationRequest<"0.6.0">["paymasterAndData"];
55
- } : TEntryPointVersion extends "0.7.0" ? Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData" | "paymasterVerificationGasLimit" | "paymasterPostOpGasLimit"> : never);
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAQA,MAAM,CAAN,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,oCAAe,CAAA;IACf,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB;;;OAGG;IACH,gDAA2B,CAAA;AAC7B,CAAC,EAVW,iBAAiB,KAAjB,iBAAiB,QAU5B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B","sourcesContent":["import type {\n UserOperationStruct,\n UserOperationRequest,\n UserOperationOverrides,\n EntryPointVersion,\n} from \"@aa-sdk/core\";\nimport type { Address, Hash, Hex } from \"viem\";\n\nexport enum SimulateAssetType {\n NATIVE = \"NATIVE\",\n ERC20 = \"ERC20\",\n ERC721 = \"ERC721\",\n ERC1155 = \"ERC1155\",\n /**\n * Special contracts that don't follow ERC 721/1155. Currently limited to\n * CryptoKitties and CryptoPunks.\n */\n SPECIAL_NFT = \"SPECIAL_NFT\",\n}\n\nexport enum SimulateChangeType {\n APPROVE = \"APPROVE\",\n TRANSFER = \"TRANSFER\",\n}\n\nexport type SimulateUserOperationAssetChangesRequest = [\n UserOperationStruct,\n entryPoint: Address,\n blockNumber?: Hash\n];\n\nexport type SimulateUserOperationAssetChangesResponse = {\n changes: SimulateAssetChange[];\n error?: SimulateAssetChangesError;\n};\n\nexport interface SimulateAssetChangesError extends Record<string, any> {\n message: string;\n}\n\nexport interface SimulateAssetChange {\n assetType: SimulateAssetType;\n changeType: SimulateChangeType;\n from: Address;\n to: Address;\n rawAmount?: string;\n amount?: string;\n contactAddress: Address;\n tokenId?: string;\n decimals: number;\n symbol: string;\n name?: string;\n logo?: string;\n}\n\nexport type RequestGasAndPaymasterAndDataRequest = [\n {\n policyId: string;\n entryPoint: Address;\n dummySignature: Hex;\n userOperation: UserOperationRequest;\n overrides?: UserOperationOverrides;\n }\n];\n\nexport type RequestGasAndPaymasterAndDataResponse<\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n> = Pick<\n UserOperationRequest,\n | \"callGasLimit\"\n | \"preVerificationGas\"\n | \"verificationGasLimit\"\n | \"maxFeePerGas\"\n | \"maxPriorityFeePerGas\"\n> &\n (TEntryPointVersion extends \"0.6.0\"\n ? {\n paymasterAndData: UserOperationRequest<\"0.6.0\">[\"paymasterAndData\"];\n }\n : TEntryPointVersion extends \"0.7.0\"\n ? Pick<\n UserOperationRequest<\"0.7.0\">,\n | \"paymaster\"\n | \"paymasterData\"\n | \"paymasterVerificationGasLimit\"\n | \"paymasterPostOpGasLimit\"\n >\n : never);\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,iBAUX;AAVD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,oCAAe,CAAA;IACf,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB;;;OAGG;IACH,gDAA2B,CAAA;AAC7B,CAAC,EAVW,iBAAiB,KAAjB,iBAAiB,QAU5B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B","sourcesContent":["import type { UserOperationStruct } from \"@aa-sdk/core\";\nimport type { Address, Hash } from \"viem\";\n\nexport enum SimulateAssetType {\n NATIVE = \"NATIVE\",\n ERC20 = \"ERC20\",\n ERC721 = \"ERC721\",\n ERC1155 = \"ERC1155\",\n /**\n * Special contracts that don't follow ERC 721/1155. Currently limited to\n * CryptoKitties and CryptoPunks.\n */\n SPECIAL_NFT = \"SPECIAL_NFT\",\n}\n\nexport enum SimulateChangeType {\n APPROVE = \"APPROVE\",\n TRANSFER = \"TRANSFER\",\n}\n\nexport type SimulateUserOperationAssetChangesRequest = [\n UserOperationStruct,\n entryPoint: Address,\n blockNumber?: Hash\n];\n\nexport type SimulateUserOperationAssetChangesResponse = {\n changes: SimulateAssetChange[];\n error?: SimulateAssetChangesError;\n};\n\nexport interface SimulateAssetChangesError extends Record<string, any> {\n message: string;\n}\n\nexport interface SimulateAssetChange {\n assetType: SimulateAssetType;\n changeType: SimulateChangeType;\n from: Address;\n to: Address;\n rawAmount?: string;\n amount?: string;\n contactAddress: Address;\n tokenId?: string;\n decimals: number;\n symbol: string;\n name?: string;\n logo?: string;\n}\n"]}
@@ -11,7 +11,6 @@ const alchemyMethods = [
11
11
  "rundler_maxPriorityFeePerGas",
12
12
  "pm_getPaymasterData",
13
13
  "pm_getPaymasterStubData",
14
- "alchemy_requestGasAndPaymasterAndData",
15
14
  ];
16
15
  /**
17
16
  * A type guard for the transport to determine if it is an Alchemy transport.
@@ -1 +1 @@
1
- {"version":3,"file":"alchemyTransport.js","sourceRoot":"","sources":["../../src/alchemyTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,GAGN,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,IAAI,GAOL,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAavC,MAAM,cAAc,GAAG;IACrB,uBAAuB;IACvB,8BAA8B;IAC9B,6BAA6B;IAC7B,4BAA4B;IAC5B,0BAA0B;IAC1B,8BAA8B;IAC9B,qBAAqB;IACrB,yBAAyB;IACzB,uCAAuC;CACxC,CAAC;AA2BF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAoB,EACpB,KAAY;IAEZ,OAAO,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,OAAO,CAAC,MAA8B;IACpD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1C,uEAAuE;IACvE,0DAA0D;IAC1D,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAEhD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,KAAK,CACnD,MAAM,CAAC,iBAAiB,IAAI,MAAM,CACnC,CAAC;IAEF,MAAM,eAAe,GAAG,sBAAsB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAErE,sHAAsH;IACtH,YAAY,CAAC,O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CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n ConnectionConfigSchema,\n split,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport {\n createTransport,\n http,\n type Chain,\n type EIP1193RequestFn,\n type HttpTransportConfig,\n type PublicRpcSchema,\n type Transport,\n type TransportConfig,\n} from \"viem\";\nimport type { AlchemyRpcSchema } from \"./client/types.js\";\nimport { AlchemyChainSchema } from \"./schema.js\";\nimport { VERSION } from \"./version.js\";\n\ntype Never<T> = T extends object\n ? {\n [K in keyof T]?: never;\n }\n : never;\n\ntype SplitTransportConfig = {\n alchemyConnection: ConnectionConfig;\n nodeRpcUrl: string;\n};\n\nconst alchemyMethods = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"rundler_maxPriorityFeePerGas\",\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n \"alchemy_requestGasAndPaymasterAndData\",\n];\n\nexport type AlchemyTransportConfig = (\n | (ConnectionConfig & Never<SplitTransportConfig>)\n | (SplitTransportConfig & Never<ConnectionConfig>)\n) & {\n /** The max number of times to retry. */\n retryCount?: TransportConfig[\"retryCount\"] | undefined;\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig[\"retryDelay\"] | undefined;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n};\n\ntype AlchemyTransportBase = Transport<\n \"alchemy\",\n {\n alchemyRpcUrl: string;\n fetchOptions?: AlchemyTransportConfig[\"fetchOptions\"];\n },\n EIP1193RequestFn<[...PublicRpcSchema, ...AlchemyRpcSchema]>\n>;\n\nexport type AlchemyTransport = AlchemyTransportBase & {\n updateHeaders(newHeaders: HeadersInit): void;\n config: AlchemyTransportConfig;\n};\n\n/**\n * A type guard for the transport to determine if it is an Alchemy transport.\n * Used in cases where we would like to do switching depending on the transport, where there used\n * to be two clients for a alchemy and a non alchemy, and with this switch we don't need the two seperate clients. *\n *\n * @param {Transport} transport The transport to check\n * @param {Chain} chain Chain for the transport to run its function to return the transport config\n * @returns {boolean} `true` if the transport is an Alchemy transport, otherwise `false`\n */\nexport function isAlchemyTransport(\n transport: Transport,\n chain: Chain\n): transport is AlchemyTransport {\n return transport({ chain }).config.type === \"alchemy\";\n}\n\n/**\n * Creates an Alchemy transport with the specified configuration options.\n * When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.\n * If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.\n *\n * @example\n * ### Basic Example\n * If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * ### AA Only Chains\n * For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only\n * handles the Bundler and Paymaster RPCs for these chains.\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * alchemyConnection: {\n * apiKey: \"your-api-key\",\n * },\n * nodeRpcUrl: \"https://zora.rpc.url\",\n * });\n * ```\n *\n * @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.\n * @param {number} config.retryDelay Optional The delay between retries, in milliseconds.\n * @param {number} config.retryCount Optional The number of retry attempts.\n * @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).\n * @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.\n * @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).\n * @param {string} [config.rpcUrl] Optional RPC URL.\n * @param {string} [config.apiKey] Optional API key for Alchemy.\n * @param {string} [config.jwt] Optional JSON Web Token for authorization.\n * @returns {AlchemyTransport} The configured Alchemy transport object.\n */\nexport function alchemy(config: AlchemyTransportConfig): AlchemyTransport {\n const { retryDelay, retryCount } = config;\n // we create a copy here in case we create a split transport down below\n // we don't want to add alchemy headers to 3rd party nodes\n const fetchOptions = { ...config.fetchOptions };\n\n const connectionConfig = ConnectionConfigSchema.parse(\n config.alchemyConnection ?? config\n );\n\n const headersAsObject = convertHeadersToObject(fetchOptions.headers);\n\n // TODO: we probably should just log these headers during telemetry logging instead of doing this mutable header stuff\n fetchOptions.headers = {\n ...headersAsObject,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n const transport: AlchemyTransportBase = (opts) => {\n const { chain: chain_ } = opts;\n if (!chain_) {\n throw new ChainNotFoundError();\n }\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n const innerTransport = (() => {\n if (config.alchemyConnection && config.nodeRpcUrl) {\n return split({\n overrides: [\n {\n methods: alchemyMethods,\n transport: http(rpcUrl, { fetchOptions }),\n },\n ],\n fallback: http(config.nodeRpcUrl, {\n fetchOptions: config.fetchOptions,\n }),\n });\n }\n\n return http(rpcUrl, { fetchOptions });\n })();\n\n return createTransport(\n {\n key: \"alchemy\",\n name: \"Alchemy Transport\",\n request: innerTransport(opts).request,\n retryCount: retryCount ?? opts?.retryCount,\n retryDelay,\n type: \"alchemy\",\n },\n { alchemyRpcUrl: rpcUrl, fetchOptions }\n );\n };\n\n return Object.assign(transport, {\n updateHeaders(newHeaders_: HeadersInit) {\n const newHeaders = convertHeadersToObject(newHeaders_);\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n config,\n });\n}\n\nconst convertHeadersToObject = (\n headers?: HeadersInit\n): Record<string, string> => {\n if (!headers) {\n return {};\n }\n\n if (headers instanceof Headers) {\n const headersObject = {} as Record<string, string>;\n headers.forEach((value, key) => {\n headersObject[key] = value;\n });\n return headersObject;\n }\n\n if (Array.isArray(headers)) {\n return headers.reduce((acc, header) => {\n acc[header[0]] = header[1];\n return acc;\n }, {} as Record<string, string>);\n }\n\n return headers;\n};\n"]}
1
+ {"version":3,"file":"alchemyTransport.js","sourceRoot":"","sources":["../../src/alchemyTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,KAAK,GAGN,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,eAAe,EACf,IAAI,GAOL,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAavC,MAAM,cAAc,GAAG;IACrB,uBAAuB;IACvB,8BAA8B;IAC9B,6BAA6B;IAC7B,4BAA4B;IAC5B,0BAA0B;IAC1B,8BAA8B;IAC9B,qBAAqB;IACrB,yBAAyB;CAC1B,CAAC;AA2BF;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAChC,SAAoB,EACpB,KAAY;IAEZ,OAAO,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACxD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,OAAO,CAAC,MAA8B;IACpD,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAC1C,uEAAuE;IACvE,0DAA0D;IAC1D,MAAM,YAAY,GAAG,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;IAEhD,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,KAAK,CACnD,MAAM,CAA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AE;YACpC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3B,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAA4B,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n ConnectionConfigSchema,\n split,\n type ConnectionConfig,\n type NoUndefined,\n} from \"@aa-sdk/core\";\nimport {\n createTransport,\n http,\n type Chain,\n type EIP1193RequestFn,\n type HttpTransportConfig,\n type PublicRpcSchema,\n type Transport,\n type TransportConfig,\n} from \"viem\";\nimport type { AlchemyRpcSchema } from \"./client/types.js\";\nimport { AlchemyChainSchema } from \"./schema.js\";\nimport { VERSION } from \"./version.js\";\n\ntype Never<T> = T extends object\n ? {\n [K in keyof T]?: never;\n }\n : never;\n\ntype SplitTransportConfig = {\n alchemyConnection: ConnectionConfig;\n nodeRpcUrl: string;\n};\n\nconst alchemyMethods = [\n \"eth_sendUserOperation\",\n \"eth_estimateUserOperationGas\",\n \"eth_getUserOperationReceipt\",\n \"eth_getUserOperationByHash\",\n \"eth_supportedEntryPoints\",\n \"rundler_maxPriorityFeePerGas\",\n \"pm_getPaymasterData\",\n \"pm_getPaymasterStubData\",\n];\n\nexport type AlchemyTransportConfig = (\n | (ConnectionConfig & Never<SplitTransportConfig>)\n | (SplitTransportConfig & Never<ConnectionConfig>)\n) & {\n /** The max number of times to retry. */\n retryCount?: TransportConfig[\"retryCount\"] | undefined;\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig[\"retryDelay\"] | undefined;\n fetchOptions?: NoUndefined<HttpTransportConfig[\"fetchOptions\"]>;\n};\n\ntype AlchemyTransportBase = Transport<\n \"alchemy\",\n {\n alchemyRpcUrl: string;\n fetchOptions?: AlchemyTransportConfig[\"fetchOptions\"];\n },\n EIP1193RequestFn<[...PublicRpcSchema, ...AlchemyRpcSchema]>\n>;\n\nexport type AlchemyTransport = AlchemyTransportBase & {\n updateHeaders(newHeaders: HeadersInit): void;\n config: AlchemyTransportConfig;\n};\n\n/**\n * A type guard for the transport to determine if it is an Alchemy transport.\n * Used in cases where we would like to do switching depending on the transport, where there used\n * to be two clients for a alchemy and a non alchemy, and with this switch we don't need the two seperate clients. *\n *\n * @param {Transport} transport The transport to check\n * @param {Chain} chain Chain for the transport to run its function to return the transport config\n * @returns {boolean} `true` if the transport is an Alchemy transport, otherwise `false`\n */\nexport function isAlchemyTransport(\n transport: Transport,\n chain: Chain\n): transport is AlchemyTransport {\n return transport({ chain }).config.type === \"alchemy\";\n}\n\n/**\n * Creates an Alchemy transport with the specified configuration options.\n * When sending all traffic to Alchemy, you must pass in one of rpcUrl, apiKey, or jwt.\n * If you want to send Bundler and Paymaster traffic to Alchemy and Node traffic to a different RPC, you must pass in alchemyConnection and nodeRpcUrl.\n *\n * @example\n * ### Basic Example\n * If the chain you're using is supported for both Bundler and Node RPCs, then you can do the following:\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * // NOTE: you can also pass in an rpcUrl or jwt here or rpcUrl and jwt\n * apiKey: \"your-api-key\",\n * });\n * ```\n *\n * ### AA Only Chains\n * For AA-only chains, you need to specify the alchemyConnection and nodeRpcUrl since Alchemy only\n * handles the Bundler and Paymaster RPCs for these chains.\n * ```ts\n * import { alchemy } from \"@account-kit/infra\";\n *\n * const transport = alchemy({\n * alchemyConnection: {\n * apiKey: \"your-api-key\",\n * },\n * nodeRpcUrl: \"https://zora.rpc.url\",\n * });\n * ```\n *\n * @param {AlchemyTransportConfig} config The configuration object for the Alchemy transport.\n * @param {number} config.retryDelay Optional The delay between retries, in milliseconds.\n * @param {number} config.retryCount Optional The number of retry attempts.\n * @param {string} [config.alchemyConnection] Optional Alchemy connection configuration (if this is passed in, nodeRpcUrl is required).\n * @param {string} [config.fetchOptions] Optional fetch options for HTTP requests.\n * @param {string} [config.nodeRpcUrl] Optional RPC URL for node (if this is passed in, alchemyConnection is required).\n * @param {string} [config.rpcUrl] Optional RPC URL.\n * @param {string} [config.apiKey] Optional API key for Alchemy.\n * @param {string} [config.jwt] Optional JSON Web Token for authorization.\n * @returns {AlchemyTransport} The configured Alchemy transport object.\n */\nexport function alchemy(config: AlchemyTransportConfig): AlchemyTransport {\n const { retryDelay, retryCount } = config;\n // we create a copy here in case we create a split transport down below\n // we don't want to add alchemy headers to 3rd party nodes\n const fetchOptions = { ...config.fetchOptions };\n\n const connectionConfig = ConnectionConfigSchema.parse(\n config.alchemyConnection ?? config\n );\n\n const headersAsObject = convertHeadersToObject(fetchOptions.headers);\n\n // TODO: we probably should just log these headers during telemetry logging instead of doing this mutable header stuff\n fetchOptions.headers = {\n ...headersAsObject,\n \"Alchemy-AA-Sdk-Version\": VERSION,\n };\n\n if (connectionConfig.jwt != null) {\n fetchOptions.headers = {\n ...fetchOptions.headers,\n Authorization: `Bearer ${connectionConfig.jwt}`,\n };\n }\n\n const transport: AlchemyTransportBase = (opts) => {\n const { chain: chain_ } = opts;\n if (!chain_) {\n throw new ChainNotFoundError();\n }\n const chain = AlchemyChainSchema.parse(chain_);\n\n const rpcUrl =\n connectionConfig.rpcUrl == null\n ? `${chain.rpcUrls.alchemy.http[0]}/${connectionConfig.apiKey ?? \"\"}`\n : connectionConfig.rpcUrl;\n\n const innerTransport = (() => {\n if (config.alchemyConnection && config.nodeRpcUrl) {\n return split({\n overrides: [\n {\n methods: alchemyMethods,\n transport: http(rpcUrl, { fetchOptions }),\n },\n ],\n fallback: http(config.nodeRpcUrl, {\n fetchOptions: config.fetchOptions,\n }),\n });\n }\n\n return http(rpcUrl, { fetchOptions });\n })();\n\n return createTransport(\n {\n key: \"alchemy\",\n name: \"Alchemy Transport\",\n request: innerTransport(opts).request,\n retryCount: retryCount ?? opts?.retryCount,\n retryDelay,\n type: \"alchemy\",\n },\n { alchemyRpcUrl: rpcUrl, fetchOptions }\n );\n };\n\n return Object.assign(transport, {\n updateHeaders(newHeaders_: HeadersInit) {\n const newHeaders = convertHeadersToObject(newHeaders_);\n\n fetchOptions.headers = {\n ...fetchOptions.headers,\n ...newHeaders,\n };\n },\n config,\n });\n}\n\nconst convertHeadersToObject = (\n headers?: HeadersInit\n): Record<string, string> => {\n if (!headers) {\n return {};\n }\n\n if (headers instanceof Headers) {\n const headersObject = {} as Record<string, string>;\n headers.forEach((value, key) => {\n headersObject[key] = value;\n });\n return headersObject;\n }\n\n if (Array.isArray(headers)) {\n return headers.reduce((acc, header) => {\n acc[header[0]] = header[1];\n return acc;\n }, {} as Record<string, string>);\n }\n\n return headers;\n};\n"]}
@@ -2,7 +2,7 @@ import { ChainNotFoundError, createSmartAccountClient, isSmartAccountWithSigner,
2
2
  import {} from "viem";
3
3
  import { getDefaultUserOperationFeeOptions } from "../defaults.js";
4
4
  import { alchemyFeeEstimator } from "../middleware/feeEstimator.js";
5
- import { alchemyGasAndPaymasterAndDataMiddleware } from "../middleware/gasManager.js";
5
+ import { alchemyGasManagerMiddleware } from "../middleware/gasManager.js";
6
6
  import { alchemyUserOperationSimulator } from "../middleware/userOperationSimulator.js";
7
7
  import { alchemyActions, } from "./decorators/smartAccount.js";
8
8
  export function getSignerTypeHeader(account) {
@@ -30,9 +30,6 @@ export function createAlchemySmartAccountClient({ account, policyId, useSimulati
30
30
  throw new ChainNotFoundError();
31
31
  }
32
32
  const feeOptions = opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);
33
- const gasAndPaymasterAndDataMiddleware = policyId
34
- ? alchemyGasAndPaymasterAndDataMiddleware(policyId)
35
- : undefined;
36
33
  const scaClient = createSmartAccountClient({
37
34
  account,
38
35
  transport,
@@ -42,21 +39,18 @@ export function createAlchemySmartAccountClient({ account, policyId, useSimulati
42
39
  ...opts,
43
40
  feeOptions,
44
41
  },
45
- dummyPaymasterAndData: gasAndPaymasterAndDataMiddleware?.dummyPaymasterAndData,
46
- feeEstimator: feeEstimator ??
47
- gasAndPaymasterAndDataMiddleware?.feeEstimator ??
48
- alchemyFeeEstimator(transport),
49
- gasEstimator: gasEstimator ?? gasAndPaymasterAndDataMiddleware?.gasEstimator,
50
42
  customMiddleware: async (struct, args) => {
51
43
  if (isSmartAccountWithSigner(args.account)) {
52
44
  transport.updateHeaders(getSignerTypeHeader(args.account));
53
45
  }
54
46
  return customMiddleware ? customMiddleware(struct, args) : struct;
55
47
  },
56
- paymasterAndData: gasAndPaymasterAndDataMiddleware?.paymasterAndData,
48
+ feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),
57
49
  userOperationSimulator: useSimulation
58
50
  ? alchemyUserOperationSimulator(transport)
59
51
  : undefined,
52
+ gasEstimator,
53
+ ...(policyId && alchemyGasManagerMiddleware(policyId)),
60
54
  signUserOperation,
61
55
  }).extend(alchemyActions);
62
56
  if (account && isSmartAccountWithSigner(account)) {
@@ -1 +1 @@
1
- {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GASzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,uCAAuC,EAAE,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EACL,cAAc,GAEf,MAAM,8BAA8B,CAAC;AAGtC,MAAM,UAAU,mBAAmB,CAEjC,OAAiB;IACjB,OAAO,EAAE,uBAAuB,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,UAAU,EAAE,CAAC;AACrE,CAAC;AAiFD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,+BAA+B,CAAC,EAC9C,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,gBAA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I,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n createSmartAccountClient,\n isSmartAccountWithSigner,\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain } from \"viem\";\nimport type { AlchemyTransport } from \"../alchemyTransport.js\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { alchemyFeeEstimator } from \"../middleware/feeEstimator.js\";\nimport { alchemyGasAndPaymasterAndDataMiddleware } from \"../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../middleware/userOperationSimulator.js\";\nimport {\n alchemyActions,\n type AlchemySmartAccountClientActions,\n} from \"./decorators/smartAccount.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n account?: account;\n useSimulation?: boolean;\n policyId?: string;\n} & Pick<\n SmartAccountClientConfig<AlchemyTransport, chain, account, context>,\n | \"customMiddleware\"\n | \"feeEstimator\"\n | \"gasEstimator\"\n | \"signUserOperation\"\n | \"transport\"\n | \"chain\"\n | \"opts\"\n>;\n// #endregion AlchemySmartAccountClientConfig\n\nexport type BaseAlchemyActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = SmartAccountClientActions<chain, account, context> &\n AlchemySmartAccountClientActions<account, context>;\n\nexport type AlchemySmartAccountClient_Base<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n SmartAccountClient<\n AlchemyTransport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<AlchemySmartAccountClient_Base<chain, account, actions, context>>;\n\nexport function createAlchemySmartAccountClient<\n TChain extends Chain = Chain,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n params: AlchemySmartAccountClientConfig<TChain, TAccount, TContext>\n): AlchemySmartAccountClient<TChain, TAccount, Record<string, never>, TContext>;\n\n/**\n * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClient, alchemy } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chain\";\n *\n * const client = createAlchemySmartAccountClient({\n * chain: sepolia,\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * });\n * ```\n *\n * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client\n * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options\n */\nexport function createAlchemySmartAccountClient({\n account,\n policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n transport,\n chain,\n opts,\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n if (!chain) {\n throw new ChainNotFoundError();\n }\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n const gasAndPaymasterAndDataMiddleware = policyId\n ? alchemyGasAndPaymasterAndDataMiddleware(policyId)\n : undefined;\n\n const scaClient = createSmartAccountClient({\n account,\n transport,\n chain,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n dummyPaymasterAndData:\n gasAndPaymasterAndDataMiddleware?.dummyPaymasterAndData,\n feeEstimator:\n feeEstimator ??\n gasAndPaymasterAndDataMiddleware?.feeEstimator ??\n alchemyFeeEstimator(transport),\n gasEstimator:\n gasEstimator ?? gasAndPaymasterAndDataMiddleware?.gasEstimator,\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n transport.updateHeaders(getSignerTypeHeader(args.account));\n }\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n paymasterAndData: gasAndPaymasterAndDataMiddleware?.paymasterAndData,\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(transport)\n : undefined,\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n transport.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
1
+ {"version":3,"file":"smartAccountClient.js","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GASzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAA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AC,SAAS,CAAC;YAC1C,CAAC,CAAC,SAAS;QACb,YAAY;QACZ,GAAG,CAAC,QAAQ,IAAI,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QACtD,iBAAiB;KAClB,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAE1B,IAAI,OAAO,IAAI,wBAAwB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n ChainNotFoundError,\n createSmartAccountClient,\n isSmartAccountWithSigner,\n type Prettify,\n type SmartAccountClient,\n type SmartAccountClientActions,\n type SmartAccountClientConfig,\n type SmartAccountClientRpcSchema,\n type SmartContractAccount,\n type SmartContractAccountWithSigner,\n type UserOperationContext,\n} from \"@aa-sdk/core\";\nimport { type Chain } from \"viem\";\nimport type { AlchemyTransport } from \"../alchemyTransport.js\";\nimport { getDefaultUserOperationFeeOptions } from \"../defaults.js\";\nimport { alchemyFeeEstimator } from \"../middleware/feeEstimator.js\";\nimport { alchemyGasManagerMiddleware } from \"../middleware/gasManager.js\";\nimport { alchemyUserOperationSimulator } from \"../middleware/userOperationSimulator.js\";\nimport {\n alchemyActions,\n type AlchemySmartAccountClientActions,\n} from \"./decorators/smartAccount.js\";\nimport type { AlchemyRpcSchema } from \"./types.js\";\n\nexport function getSignerTypeHeader<\n TAccount extends SmartContractAccountWithSigner\n>(account: TAccount) {\n return { \"Alchemy-Aa-Sdk-Signer\": account.getSigner().signerType };\n}\n\n// #region AlchemySmartAccountClientConfig\nexport type AlchemySmartAccountClientConfig<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = {\n account?: account;\n useSimulation?: boolean;\n policyId?: string;\n} & Pick<\n SmartAccountClientConfig<AlchemyTransport, chain, account, context>,\n | \"customMiddleware\"\n | \"feeEstimator\"\n | \"gasEstimator\"\n | \"signUserOperation\"\n | \"transport\"\n | \"chain\"\n | \"opts\"\n>;\n// #endregion AlchemySmartAccountClientConfig\n\nexport type BaseAlchemyActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = SmartAccountClientActions<chain, account, context> &\n AlchemySmartAccountClientActions<account, context>;\n\nexport type AlchemySmartAccountClient_Base<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<\n SmartAccountClient<\n AlchemyTransport,\n chain,\n account,\n actions & BaseAlchemyActions<chain, account, context>,\n [...SmartAccountClientRpcSchema, ...AlchemyRpcSchema],\n context\n >\n>;\n\nexport type AlchemySmartAccountClient<\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n actions extends Record<string, unknown> = Record<string, unknown>,\n context extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n> = Prettify<AlchemySmartAccountClient_Base<chain, account, actions, context>>;\n\nexport function createAlchemySmartAccountClient<\n TChain extends Chain = Chain,\n TAccount extends SmartContractAccount | undefined =\n | SmartContractAccount\n | undefined,\n TContext extends UserOperationContext | undefined =\n | UserOperationContext\n | undefined\n>(\n params: AlchemySmartAccountClientConfig<TChain, TAccount, TContext>\n): AlchemySmartAccountClient<TChain, TAccount, Record<string, never>, TContext>;\n\n/**\n * Creates an Alchemy smart account client using the provided configuration options, including account details, gas manager configuration, and custom middleware.\n *\n * @example\n * ```ts\n * import { createAlchemySmartAccountClient, alchemy } from \"@account-kit/infra\";\n * import { sepolia } from \"@account-kit/infra/chain\";\n *\n * const client = createAlchemySmartAccountClient({\n * chain: sepolia,\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * });\n * ```\n *\n * @param {AlchemySmartAccountClientConfig} config The configuration for creating the Alchemy smart account client\n * @returns {AlchemySmartAccountClient} An instance of `AlchemySmartAccountClient` configured based on the provided options\n */\nexport function createAlchemySmartAccountClient({\n account,\n policyId,\n useSimulation,\n feeEstimator,\n customMiddleware,\n gasEstimator,\n signUserOperation,\n transport,\n chain,\n opts,\n}: AlchemySmartAccountClientConfig): AlchemySmartAccountClient {\n if (!chain) {\n throw new ChainNotFoundError();\n }\n\n const feeOptions =\n opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);\n\n const scaClient = createSmartAccountClient({\n account,\n transport,\n chain,\n type: \"AlchemySmartAccountClient\",\n opts: {\n ...opts,\n feeOptions,\n },\n customMiddleware: async (struct, args) => {\n if (isSmartAccountWithSigner(args.account)) {\n transport.updateHeaders(getSignerTypeHeader(args.account));\n }\n return customMiddleware ? customMiddleware(struct, args) : struct;\n },\n feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),\n userOperationSimulator: useSimulation\n ? alchemyUserOperationSimulator(transport)\n : undefined,\n gasEstimator,\n ...(policyId && alchemyGasManagerMiddleware(policyId)),\n signUserOperation,\n }).extend(alchemyActions);\n\n if (account && isSmartAccountWithSigner(account)) {\n transport.updateHeaders(getSignerTypeHeader(account));\n }\n\n return scaClient;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type BundlerClient, type Erc7677RpcSchema, type UserOperationRequest } from "@aa-sdk/core";
2
- import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse, RequestGasAndPaymasterAndDataRequest, RequestGasAndPaymasterAndDataResponse } from "../actions/types";
2
+ import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse } from "../actions/types";
3
3
  import type { AlchemyTransport } from "../alchemyTransport";
4
4
  export type AlchemyRpcSchema = [
5
5
  {
@@ -14,12 +14,7 @@ export type AlchemyRpcSchema = [
14
14
  },
15
15
  ...Erc7677RpcSchema<{
16
16
  policyId: string;
17
- }>,
18
- {
19
- Method: "alchemy_requestGasAndPaymasterAndData";
20
- Parameters: RequestGasAndPaymasterAndDataRequest;
21
- ReturnType: RequestGasAndPaymasterAndDataResponse;
22
- }
17
+ }>
23
18
  ];
24
19
  export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
25
20
  request: BundlerClient<AlchemyTransport>["request"] & {
@@ -31,9 +26,5 @@ export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
31
26
  method: "rundler_maxPriorityFeePerGas";
32
27
  params: [];
33
28
  }): Promise<UserOperationRequest["maxPriorityFeePerGas"]>;
34
- request(args: {
35
- method: "alchemy_requestGasAndPaymasterAndData";
36
- params: RequestGasAndPaymasterAndDataRequest;
37
- }): Promise<RequestGasAndPaymasterAndDataResponse>;
38
29
  }["request"];
39
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,cAAc,CAAC","sourcesContent":["import {\n type BundlerClient,\n type Erc7677RpcSchema,\n type UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport type {\n SimulateUserOperationAssetChangesRequest,\n SimulateUserOperationAssetChangesResponse,\n RequestGasAndPaymasterAndDataRequest,\n RequestGasAndPaymasterAndDataResponse,\n} from \"../actions/types\";\nimport type { AlchemyTransport } from \"../alchemyTransport\";\n\nexport type AlchemyRpcSchema = [\n {\n Method: \"alchemy_simulateUserOperationAssetChanges\";\n Parameters: SimulateUserOperationAssetChangesRequest;\n ReturnType: SimulateUserOperationAssetChangesResponse;\n },\n {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: UserOperationRequest[\"maxPriorityFeePerGas\"];\n },\n ...Erc7677RpcSchema<{ policyId: string }>,\n {\n Method: \"alchemy_requestGasAndPaymasterAndData\";\n Parameters: RequestGasAndPaymasterAndDataRequest;\n ReturnType: RequestGasAndPaymasterAndDataResponse;\n }\n];\n\nexport type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {\n request: BundlerClient<AlchemyTransport>[\"request\"] &\n {\n request(args: {\n method: \"alchemy_simulateUserOperationAssetChanges\";\n params: SimulateUserOperationAssetChangesRequest;\n }): Promise<SimulateUserOperationAssetChangesResponse>;\n\n request(args: {\n method: \"rundler_maxPriorityFeePerGas\";\n params: [];\n }): Promise<UserOperationRequest[\"maxPriorityFeePerGas\"]>;\n\n request(args: {\n method: \"alchemy_requestGasAndPaymasterAndData\";\n params: RequestGasAndPaymasterAndDataRequest;\n }): Promise<RequestGasAndPaymasterAndDataResponse>;\n }[\"request\"];\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,MAAM,cAAc,CAAC","sourcesContent":["import {\n type BundlerClient,\n type Erc7677RpcSchema,\n type UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport type {\n SimulateUserOperationAssetChangesRequest,\n SimulateUserOperationAssetChangesResponse,\n} from \"../actions/types\";\nimport type { AlchemyTransport } from \"../alchemyTransport\";\n\nexport type AlchemyRpcSchema = [\n {\n Method: \"alchemy_simulateUserOperationAssetChanges\";\n Parameters: SimulateUserOperationAssetChangesRequest;\n ReturnType: SimulateUserOperationAssetChangesResponse;\n },\n {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: UserOperationRequest[\"maxPriorityFeePerGas\"];\n },\n ...Erc7677RpcSchema<{ policyId: string }>\n];\n\nexport type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {\n request: BundlerClient<AlchemyTransport>[\"request\"] &\n {\n request(args: {\n method: \"alchemy_simulateUserOperationAssetChanges\";\n params: SimulateUserOperationAssetChangesRequest;\n }): Promise<SimulateUserOperationAssetChangesResponse>;\n\n request(args: {\n method: \"rundler_maxPriorityFeePerGas\";\n params: [];\n }): Promise<UserOperationRequest[\"maxPriorityFeePerGas\"]>;\n }[\"request\"];\n};\n"]}
@@ -19,6 +19,6 @@ export { getDefaultUserOperationFeeOptions } from "./defaults.js";
19
19
  export { getAlchemyPaymasterAddress } from "./gas-manager.js";
20
20
  export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
21
21
  export type * from "./middleware/gasManager.js";
22
- export { alchemyGasManagerMiddleware, alchemyGasAndPaymasterAndDataMiddleware, } from "./middleware/gasManager.js";
22
+ export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
23
23
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
24
24
  export type * from "./schema.js";
package/dist/esm/index.js CHANGED
@@ -9,6 +9,6 @@ export { createAlchemySmartAccountClient } from "./client/smartAccountClient.js"
9
9
  export { getDefaultUserOperationFeeOptions } from "./defaults.js";
10
10
  export { getAlchemyPaymasterAddress } from "./gas-manager.js";
11
11
  export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
12
- export { alchemyGasManagerMiddleware, alchemyGasAndPaymasterAndDataMiddleware, } from "./middleware/gasManager.js";
12
+ export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
13
13
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EACL,2BAA2B,EAC3B,uCAAuC,GACxC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./alchemyTransport.js\";\nexport { alchemy, isAlchemyTransport } from \"./alchemyTransport.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumNova,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n shape,\n shapeSepolia,\n worldChain,\n worldChainSepolia,\n zora,\n zoraSepolia,\n beraChainBartio,\n opbnbMainnet,\n opbnbTestnet,\n soneiumMinato,\n soneiumMainnet,\n unichainMainnet,\n unichainSepolia,\n inkMainnet,\n inkSepolia,\n mekong,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport {\n alchemyGasManagerMiddleware,\n alchemyGasAndPaymasterAndDataMiddleware,\n} from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AAGzF,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export type * from \"./actions/simulateUserOperationChanges.js\";\nexport { simulateUserOperationChanges } from \"./actions/simulateUserOperationChanges.js\";\nexport type * from \"./actions/types.js\";\nexport type * from \"./alchemyTransport.js\";\nexport { alchemy, isAlchemyTransport } from \"./alchemyTransport.js\";\nexport type * from \"./chains.js\";\nexport {\n arbitrum,\n arbitrumGoerli,\n arbitrumNova,\n arbitrumSepolia,\n base,\n baseGoerli,\n baseSepolia,\n defineAlchemyChain,\n fraxtal,\n fraxtalSepolia,\n goerli,\n mainnet,\n optimism,\n optimismGoerli,\n optimismSepolia,\n polygon,\n polygonAmoy,\n polygonMumbai,\n sepolia,\n shape,\n shapeSepolia,\n worldChain,\n worldChainSepolia,\n zora,\n zoraSepolia,\n beraChainBartio,\n opbnbMainnet,\n opbnbTestnet,\n soneiumMinato,\n soneiumMainnet,\n unichainMainnet,\n unichainSepolia,\n inkMainnet,\n inkSepolia,\n mekong,\n} from \"./chains.js\";\nexport type * from \"./client/decorators/alchemyEnhancedApis.js\";\nexport { alchemyEnhancedApiActions } from \"./client/decorators/alchemyEnhancedApis.js\";\nexport type * from \"./client/decorators/smartAccount.js\";\nexport { alchemyActions } from \"./client/decorators/smartAccount.js\";\nexport { isAlchemySmartAccountClient } from \"./client/isAlchemySmartAccountClient.js\";\nexport type * from \"./client/rpcClient.js\";\nexport { createAlchemyPublicRpcClient } from \"./client/rpcClient.js\";\nexport type * from \"./client/smartAccountClient.js\";\nexport { createAlchemySmartAccountClient } from \"./client/smartAccountClient.js\";\nexport type * from \"./client/types.js\";\nexport { getDefaultUserOperationFeeOptions } from \"./defaults.js\";\nexport { getAlchemyPaymasterAddress } from \"./gas-manager.js\";\nexport { alchemyFeeEstimator } from \"./middleware/feeEstimator.js\";\nexport type * from \"./middleware/gasManager.js\";\nexport { alchemyGasManagerMiddleware } from \"./middleware/gasManager.js\";\nexport { alchemyUserOperationSimulator } from \"./middleware/userOperationSimulator.js\";\nexport type * from \"./schema.js\";\n"]}
@@ -18,23 +18,3 @@ import type { ClientMiddlewareConfig } from "@aa-sdk/core";
18
18
  * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
19
19
  */
20
20
  export declare function alchemyGasManagerMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
21
- /**
22
- * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions using
23
- * the `alchemy_requestGasAndPaymasterAndData` method instead of standard ERC-7677 methods.
24
- *
25
- * @example
26
- * ```ts
27
- * import { sepolia, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
28
- * import { http } from "viem";
29
- *
30
- * const client = createSmartAccountClient({
31
- * transport: http("rpc-url"),
32
- * chain: sepolia,
33
- * ...alchemyGasAndPaymasterAndDataMiddleware("policyId")
34
- * });
35
- * ```
36
- *
37
- * @param {string} policyId the policyId for Alchemy's gas manager
38
- * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
39
- */
40
- export declare function alchemyGasAndPaymasterAndDataMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData">;
@@ -1,6 +1,4 @@
1
- import { bypassPaymasterAndData, ChainNotFoundError, deepHexlify, defaultFeeEstimator, defaultGasEstimator, erc7677Middleware, filterUndefined, isBigNumberish, isMultiplier, noopMiddleware, resolveProperties, } from "@aa-sdk/core";
2
- import { getAlchemyPaymasterAddress } from "../gas-manager.js";
3
- import { fromHex, isHex } from "viem";
1
+ import { erc7677Middleware } from "@aa-sdk/core";
4
2
  /**
5
3
  * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.
6
4
  *
@@ -24,122 +22,4 @@ export function alchemyGasManagerMiddleware(policyId) {
24
22
  context: { policyId: policyId },
25
23
  });
26
24
  }
27
- /**
28
- * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions using
29
- * the `alchemy_requestGasAndPaymasterAndData` method instead of standard ERC-7677 methods.
30
- *
31
- * @example
32
- * ```ts
33
- * import { sepolia, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
34
- * import { http } from "viem";
35
- *
36
- * const client = createSmartAccountClient({
37
- * transport: http("rpc-url"),
38
- * chain: sepolia,
39
- * ...alchemyGasAndPaymasterAndDataMiddleware("policyId")
40
- * });
41
- * ```
42
- *
43
- * @param {string} policyId the policyId for Alchemy's gas manager
44
- * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
45
- */
46
- export function alchemyGasAndPaymasterAndDataMiddleware(policyId) {
47
- return {
48
- dummyPaymasterAndData: async (uo, { client, account }) => {
49
- if (!client.chain) {
50
- throw new ChainNotFoundError();
51
- }
52
- const paymaster = getAlchemyPaymasterAddress(client.chain);
53
- const paymasterData = await account.getDummySignature();
54
- return {
55
- ...uo,
56
- dummyPaymasterAndData: {
57
- paymaster,
58
- paymasterData,
59
- },
60
- };
61
- },
62
- feeEstimator: (uo, args) => {
63
- return bypassPaymasterAndData(args.overrides)
64
- ? defaultFeeEstimator(args.client)(uo, args)
65
- : noopMiddleware(uo, args);
66
- },
67
- gasEstimator: (uo, args) => {
68
- return bypassPaymasterAndData(args.overrides)
69
- ? defaultGasEstimator(args.client)(uo, args)
70
- : noopMiddleware(uo, args);
71
- },
72
- paymasterAndData: async (uo, { account, client, feeOptions, overrides: overrides_ }) => {
73
- if (!client.chain) {
74
- throw new ChainNotFoundError();
75
- }
76
- const userOp = deepHexlify(await resolveProperties(uo));
77
- const overrides = filterUndefined({
78
- maxFeePerGas: overrideField("maxFeePerGas", overrides_, feeOptions, userOp),
79
- maxPriorityFeePerGas: overrideField("maxPriorityFeePerGas", overrides_, feeOptions, userOp),
80
- callGasLimit: overrideField("callGasLimit", overrides_, feeOptions, userOp),
81
- verificationGasLimit: overrideField("verificationGasLimit", overrides_, feeOptions, userOp),
82
- preVerificationGas: overrideField("preVerificationGas", overrides_, feeOptions, userOp),
83
- ...(account.getEntryPoint().version === "0.7.0"
84
- ? {
85
- paymasterVerificationGasLimit: overrideField("paymasterVerificationGasLimit", overrides_, feeOptions, userOp),
86
- paymasterPostOpGasLimit: overrideField("paymasterPostOpGasLimit", overrides_, feeOptions, userOp),
87
- }
88
- : {}),
89
- });
90
- const result = await client.request({
91
- method: "alchemy_requestGasAndPaymasterAndData",
92
- params: [
93
- {
94
- policyId,
95
- entryPoint: account.getEntryPoint().address,
96
- userOperation: userOp,
97
- dummySignature: await account.getDummySignature(),
98
- overrides,
99
- },
100
- ],
101
- });
102
- return {
103
- ...uo,
104
- ...result,
105
- };
106
- },
107
- };
108
- }
109
- /**
110
- * Utility function to override a field in the user operation request with the overrides or fee options
111
- *
112
- * @template {EntryPointVersion} TEntryPointVersion
113
- * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override
114
- * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object
115
- * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client
116
- * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request
117
- * @returns {Hex | Multiplier | undefined} the overridden field value
118
- */
119
- const overrideField = (field, overrides, feeOptions, userOperation) => {
120
- let _field = field;
121
- if (overrides?.[_field] != null) {
122
- // one-off absolute override
123
- if (isBigNumberish(overrides[_field])) {
124
- return deepHexlify(overrides[_field]);
125
- }
126
- // one-off multiplier overrides
127
- else {
128
- return {
129
- multiplier: Number(overrides[_field].multiplier),
130
- };
131
- }
132
- }
133
- // provider level fee options with multiplier
134
- if (isMultiplier(feeOptions?.[field])) {
135
- return {
136
- multiplier: Number(feeOptions[field].multiplier),
137
- };
138
- }
139
- const userOpField = userOperation[field];
140
- if (isHex(userOpField) && fromHex(userOpField, "bigint") > 0n) {
141
- return userOpField;
142
- }
143
- return undefined;
144
- };
145
25
  //# sourceMappingURL=gasManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,MAAM,CAAC;AAGhD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAgB;IAEhB,OAAO,iBAAiB,CAAuB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YAEH,OAAO;gBACL,GAAG,EAAE;gBACL,GAAG,MAAM;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,CAGpB,KAAwD,EACxD,SAAiE,EACjE,UAAmE,EACnE,aAAuD,EACzB,EAAE;IAChC,IAAI,MAAM,GAAG,KAAyD,CAAC;IAEvE,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QAChC,4BAA4B;QAC5B,IAAI,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACxC,CAAC;QACD,+BAA+B;aAC1B,CAAC;YACJ,OAAO;gBACL,UAAU,EAAE,MAAM,CAAE,SAAS,CAAC,MAAM,CAAgB,CAAC,UAAU,CAAC;aACjE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,6CAA6C;IAC7C,IAAI,YAAY,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACtC,OAAO;YACL,UAAU,EAAE,MAAM,CAAE,UAAW,CAAC,KAAK,CAAgB,CAAC,UAAU,CAAC;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GACf,aAAa,CAAC,KAAuD,CAAC,CAAC;IACzE,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,WAAkB,EAAE,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC;QACrE,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import type {\n ClientMiddlewareConfig,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndData,\n ChainNotFoundError,\n deepHexlify,\n defaultFeeEstimator,\n defaultGasEstimator,\n erc7677Middleware,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n noopMiddleware,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { getAlchemyPaymasterAddress } from \"../gas-manager.js\";\nimport { fromHex, isHex, type Hex } from \"viem\";\nimport type { AlchemySmartAccountClient } from \"../client/smartAccountClient.js\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.\n *\n * @example\n * ```ts\n * import { sepolia, alchemyGasManagerMiddleware } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * ...alchemyGasManagerMiddleware(\"policyId\")\n * });\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasManagerMiddleware(\n policyId: string\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string }>({\n context: { policyId: policyId },\n });\n}\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions using\n * the `alchemy_requestGasAndPaymasterAndData` method instead of standard ERC-7677 methods.\n *\n * @example\n * ```ts\n * import { sepolia, alchemyGasAndPaymasterAndDataMiddleware } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * ...alchemyGasAndPaymasterAndDataMiddleware(\"policyId\")\n * });\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasAndPaymasterAndDataMiddleware(\n policyId: string\n): Pick<\n ClientMiddlewareConfig,\n \"dummyPaymasterAndData\" | \"feeEstimator\" | \"gasEstimator\" | \"paymasterAndData\"\n> {\n return {\n dummyPaymasterAndData: async (uo, { client, account }) => {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const paymaster = getAlchemyPaymasterAddress(client.chain);\n const paymasterData = await account.getDummySignature();\n\n return {\n ...uo,\n dummyPaymasterAndData: {\n paymaster,\n paymasterData,\n },\n };\n },\n feeEstimator: (uo, args) => {\n return bypassPaymasterAndData(args.overrides)\n ? defaultFeeEstimator(args.client)(uo, args)\n : noopMiddleware(uo, args);\n },\n gasEstimator: (uo, args) => {\n return bypassPaymasterAndData(args.overrides)\n ? defaultGasEstimator(args.client)(uo, args)\n : noopMiddleware(uo, args);\n },\n paymasterAndData: async (\n uo,\n { account, client, feeOptions, overrides: overrides_ }\n ) => {\n if (!client.chain) {\n throw new ChainNotFoundError();\n }\n\n const userOp = deepHexlify(await resolveProperties(uo));\n\n const overrides: UserOperationOverrides = filterUndefined({\n maxFeePerGas: overrideField(\n \"maxFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOp\n ),\n maxPriorityFeePerGas: overrideField(\n \"maxPriorityFeePerGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOp\n ),\n callGasLimit: overrideField(\n \"callGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOp\n ),\n verificationGasLimit: overrideField(\n \"verificationGasLimit\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOp\n ),\n preVerificationGas: overrideField(\n \"preVerificationGas\",\n overrides_ as UserOperationOverrides,\n feeOptions,\n userOp\n ),\n ...(account.getEntryPoint().version === \"0.7.0\"\n ? {\n paymasterVerificationGasLimit: overrideField<\"0.7.0\">(\n \"paymasterVerificationGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOp\n ),\n paymasterPostOpGasLimit: overrideField<\"0.7.0\">(\n \"paymasterPostOpGasLimit\",\n overrides_ as UserOperationOverrides<\"0.7.0\">,\n feeOptions,\n userOp\n ),\n }\n : {}),\n });\n\n const result = await (client as AlchemySmartAccountClient).request({\n method: \"alchemy_requestGasAndPaymasterAndData\",\n params: [\n {\n policyId,\n entryPoint: account.getEntryPoint().address,\n userOperation: userOp,\n dummySignature: await account.getDummySignature(),\n overrides,\n },\n ],\n });\n\n return {\n ...uo,\n ...result,\n };\n },\n };\n}\n\n/**\n * Utility function to override a field in the user operation request with the overrides or fee options\n *\n * @template {EntryPointVersion} TEntryPointVersion\n * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override\n * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object\n * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client\n * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request\n * @returns {Hex | Multiplier | undefined} the overridden field value\n */\nconst overrideField = <\n TEntryPointVersion extends EntryPointVersion = EntryPointVersion\n>(\n field: keyof UserOperationFeeOptions<TEntryPointVersion>,\n overrides: UserOperationOverrides<TEntryPointVersion> | undefined,\n feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,\n userOperation: UserOperationRequest<TEntryPointVersion>\n): Hex | Multiplier | undefined => {\n let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;\n\n if (overrides?.[_field] != null) {\n // one-off absolute override\n if (isBigNumberish(overrides[_field])) {\n return deepHexlify(overrides[_field]);\n }\n // one-off multiplier overrides\n else {\n return {\n multiplier: Number((overrides[_field] as Multiplier).multiplier),\n };\n }\n }\n\n // provider level fee options with multiplier\n if (isMultiplier(feeOptions?.[field])) {\n return {\n multiplier: Number((feeOptions![field] as Multiplier).multiplier),\n };\n }\n\n const userOpField =\n userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];\n if (isHex(userOpField) && fromHex(userOpField as Hex, \"bigint\") > 0n) {\n return userOpField;\n }\n return undefined;\n};\n"]}
1
+ {"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAgB;IAEhB,OAAO,iBAAiB,CAAuB;QAC7C,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { ClientMiddlewareConfig } from \"@aa-sdk/core\";\nimport { erc7677Middleware } from \"@aa-sdk/core\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.\n *\n * @example\n * ```ts\n * import { sepolia, alchemyGasManagerMiddleware } from \"@account-kit/infra\";\n * import { http } from \"viem\";\n *\n * const client = createSmartAccountClient({\n * transport: http(\"rpc-url\"),\n * chain: sepolia,\n * ...alchemyGasManagerMiddleware(\"policyId\")\n * });\n * ```\n *\n * @param {string} policyId the policyId for Alchemy's gas manager\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasManagerMiddleware(\n policyId: string\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string }>({\n context: { policyId: policyId },\n });\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "4.12.1-alpha.0";
1
+ export declare const VERSION = "4.13.0";
@@ -1,4 +1,4 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.12.1-alpha.0";
3
+ export const VERSION = "4.13.0";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.12.1-alpha.0\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"4.13.0\";\n"]}
@@ -1,5 +1,5 @@
1
- import type { UserOperationStruct, UserOperationRequest, UserOperationOverrides, EntryPointVersion } from "@aa-sdk/core";
2
- import type { Address, Hash, Hex } from "viem";
1
+ import type { UserOperationStruct } from "@aa-sdk/core";
2
+ import type { Address, Hash } from "viem";
3
3
  export declare enum SimulateAssetType {
4
4
  NATIVE = "NATIVE",
5
5
  ERC20 = "ERC20",
@@ -41,16 +41,4 @@ export interface SimulateAssetChange {
41
41
  name?: string;
42
42
  logo?: string;
43
43
  }
44
- export type RequestGasAndPaymasterAndDataRequest = [
45
- {
46
- policyId: string;
47
- entryPoint: Address;
48
- dummySignature: Hex;
49
- userOperation: UserOperationRequest;
50
- overrides?: UserOperationOverrides;
51
- }
52
- ];
53
- export type RequestGasAndPaymasterAndDataResponse<TEntryPointVersion extends EntryPointVersion = EntryPointVersion> = Pick<UserOperationRequest, "callGasLimit" | "preVerificationGas" | "verificationGasLimit" | "maxFeePerGas" | "maxPriorityFeePerGas"> & (TEntryPointVersion extends "0.6.0" ? {
54
- paymasterAndData: UserOperationRequest<"0.6.0">["paymasterAndData"];
55
- } : TEntryPointVersion extends "0.7.0" ? Pick<UserOperationRequest<"0.7.0">, "paymaster" | "paymasterData" | "paymasterVerificationGasLimit" | "paymasterPostOpGasLimit"> : never);
56
44
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[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;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,CA+ExE"}
@@ -1,5 +1,5 @@
1
1
  import { type BundlerClient, type Erc7677RpcSchema, type UserOperationRequest } from "@aa-sdk/core";
2
- import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse, RequestGasAndPaymasterAndDataRequest, RequestGasAndPaymasterAndDataResponse } from "../actions/types";
2
+ import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse } from "../actions/types";
3
3
  import type { AlchemyTransport } from "../alchemyTransport";
4
4
  export type AlchemyRpcSchema = [
5
5
  {
@@ -14,12 +14,7 @@ export type AlchemyRpcSchema = [
14
14
  },
15
15
  ...Erc7677RpcSchema<{
16
16
  policyId: string;
17
- }>,
18
- {
19
- Method: "alchemy_requestGasAndPaymasterAndData";
20
- Parameters: RequestGasAndPaymasterAndDataRequest;
21
- ReturnType: RequestGasAndPaymasterAndDataResponse;
22
- }
17
+ }>
23
18
  ];
24
19
  export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
25
20
  request: BundlerClient<AlchemyTransport>["request"] & {
@@ -31,10 +26,6 @@ export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
31
26
  method: "rundler_maxPriorityFeePerGas";
32
27
  params: [];
33
28
  }): Promise<UserOperationRequest["maxPriorityFeePerGas"]>;
34
- request(args: {
35
- method: "alchemy_requestGasAndPaymasterAndData";
36
- params: RequestGasAndPaymasterAndDataRequest;
37
- }): Promise<RequestGasAndPaymasterAndDataResponse>;
38
29
  }["request"];
39
30
  };
40
31
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AAC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1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/client/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,wCAAwC,EACxC,yCAAyC,EAC1C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B;QACE,MAAM,EAAE,2CAA2C,CAAC;QACpD,UAAU,EAAE,wCAAwC,CAAC;QACrD,UAAU,EAAE,yCAAyC,CAAC;KACvD;IACD;QACE,MAAM,EAAE,8BAA8B,CAAC;QACvC,UAAU,EAAE,EAAE,CAAC;QACf,UAAU,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;KAC1D;IACD,GAAG,gBAAgB,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,gBAAgB,CAAC,GAAG;IACvE,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC,SAAS,CAAC,GACjD;QACE,OAAO,CAAC,IAAI,EAAE;YACZ,MAAM,EAAE,2CAA2C,CAAC;YACpD,MAAM,EAAE,wCAAwC,CAAC;SAClD,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;QAEvD,OAAO,CAAC,IAAI,EAAE;YACZ,MAAM,EAAE,8BAA8B,CAAC;YACvC,MAAM,EAAE,EAAE,CAAC;SACZ,GAAG,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,CAAC;KAC3D,CAAC,SAAS,CAAC,CAAC;CAChB,CAAC"}
@@ -19,7 +19,7 @@ export { getDefaultUserOperationFeeOptions } from "./defaults.js";
19
19
  export { getAlchemyPaymasterAddress } from "./gas-manager.js";
20
20
  export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
21
21
  export type * from "./middleware/gasManager.js";
22
- export { alchemyGasManagerMiddleware, alchemyGasAndPaymasterAndDataMiddleware, } from "./middleware/gasManager.js";
22
+ export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
23
23
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
24
24
  export type * from "./schema.js";
25
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,2CAA2C,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,2CAA2C,CAAC;AACzF,mBAAmB,oBAAoB,CAAC;AACxC,mBAAmB,uBAAuB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpE,mBAAmB,aAAa,CAAC;AACjC,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,EACR,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,aAAa,EACb,OAAO,EACP,KAAK,EACL,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,mBAAmB,4CAA4C,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAC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M,GACP,MAAM,aAAa,CAAC;AACrB,mBAAmB,4CAA4C,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,mBAAmB,qCAAqC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,mBAAmB,uBAAuB,CAAC;AAC3C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,mBAAmB,gCAAgC,CAAC;AACpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,mBAAmB,mBAAmB,CAAC;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,mBAAmB,4BAA4B,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,mBAAmB,aAAa,CAAC"}
@@ -18,24 +18,4 @@ import type { ClientMiddlewareConfig } from "@aa-sdk/core";
18
18
  * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
19
19
  */
20
20
  export declare function alchemyGasManagerMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
21
- /**
22
- * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions using
23
- * the `alchemy_requestGasAndPaymasterAndData` method instead of standard ERC-7677 methods.
24
- *
25
- * @example
26
- * ```ts
27
- * import { sepolia, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
28
- * import { http } from "viem";
29
- *
30
- * const client = createSmartAccountClient({
31
- * transport: http("rpc-url"),
32
- * chain: sepolia,
33
- * ...alchemyGasAndPaymasterAndDataMiddleware("policyId")
34
- * });
35
- * ```
36
- *
37
- * @param {string} policyId the policyId for Alchemy's gas manager
38
- * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
39
- */
40
- export declare function alchemyGasAndPaymasterAndDataMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData">;
41
21
  //# sourceMappingURL=gasManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gasManager.d.ts","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EAMvB,MAAM,cAAc,CAAC;AAkBtB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,GACf,IAAI,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,kBAAkB,CAAC,CAI5E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,MAAM,GACf,IAAI,CACL,sBAAsB,EACtB,uBAAuB,GAAG,cAAc,GAAG,cAAc,GAAG,kBAAkB,CAC/E,CA0GA"}
1
+ {"version":3,"file":"gasManager.d.ts","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAG3D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,GACf,IAAI,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,kBAAkB,CAAC,CAI5E"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "4.12.1-alpha.0";
1
+ export declare const VERSION = "4.13.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@account-kit/infra",
3
- "version": "4.12.1-alpha.0",
3
+ "version": "4.13.0",
4
4
  "description": "adapters for @aa-sdk/core for interacting with alchemy services",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -45,13 +45,13 @@
45
45
  "vitest": "^2.0.4"
46
46
  },
47
47
  "dependencies": {
48
- "@aa-sdk/core": "^4.12.1-alpha.0",
49
- "@account-kit/logging": "^4.12.1-alpha.0",
48
+ "@aa-sdk/core": "^4.13.0",
49
+ "@account-kit/logging": "^4.13.0",
50
50
  "eventemitter3": "^5.0.1",
51
51
  "zod": "^3.22.4"
52
52
  },
53
53
  "peerDependencies": {
54
- "viem": "^2.20.0"
54
+ "viem": "^2.22.6"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public",
@@ -65,7 +65,7 @@
65
65
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
66
66
  },
67
67
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
68
- "gitHead": "7835fad48bb913cc0b9adfb82fc98610e5cde0b1",
68
+ "gitHead": "6865bd7b49bc7db064bca7026914e4299febdb34",
69
69
  "optionalDependencies": {
70
70
  "alchemy-sdk": "^3.0.0"
71
71
  }
@@ -1,10 +1,5 @@
1
- import type {
2
- UserOperationStruct,
3
- UserOperationRequest,
4
- UserOperationOverrides,
5
- EntryPointVersion,
6
- } from "@aa-sdk/core";
7
- import type { Address, Hash, Hex } from "viem";
1
+ import type { UserOperationStruct } from "@aa-sdk/core";
2
+ import type { Address, Hash } from "viem";
8
3
 
9
4
  export enum SimulateAssetType {
10
5
  NATIVE = "NATIVE",
@@ -52,37 +47,3 @@ export interface SimulateAssetChange {
52
47
  name?: string;
53
48
  logo?: string;
54
49
  }
55
-
56
- export type RequestGasAndPaymasterAndDataRequest = [
57
- {
58
- policyId: string;
59
- entryPoint: Address;
60
- dummySignature: Hex;
61
- userOperation: UserOperationRequest;
62
- overrides?: UserOperationOverrides;
63
- }
64
- ];
65
-
66
- export type RequestGasAndPaymasterAndDataResponse<
67
- TEntryPointVersion extends EntryPointVersion = EntryPointVersion
68
- > = Pick<
69
- UserOperationRequest,
70
- | "callGasLimit"
71
- | "preVerificationGas"
72
- | "verificationGasLimit"
73
- | "maxFeePerGas"
74
- | "maxPriorityFeePerGas"
75
- > &
76
- (TEntryPointVersion extends "0.6.0"
77
- ? {
78
- paymasterAndData: UserOperationRequest<"0.6.0">["paymasterAndData"];
79
- }
80
- : TEntryPointVersion extends "0.7.0"
81
- ? Pick<
82
- UserOperationRequest<"0.7.0">,
83
- | "paymaster"
84
- | "paymasterData"
85
- | "paymasterVerificationGasLimit"
86
- | "paymasterPostOpGasLimit"
87
- >
88
- : never);
@@ -39,7 +39,6 @@ const alchemyMethods = [
39
39
  "rundler_maxPriorityFeePerGas",
40
40
  "pm_getPaymasterData",
41
41
  "pm_getPaymasterStubData",
42
- "alchemy_requestGasAndPaymasterAndData",
43
42
  ];
44
43
 
45
44
  export type AlchemyTransportConfig = (
@@ -15,7 +15,7 @@ import { type Chain } from "viem";
15
15
  import type { AlchemyTransport } from "../alchemyTransport.js";
16
16
  import { getDefaultUserOperationFeeOptions } from "../defaults.js";
17
17
  import { alchemyFeeEstimator } from "../middleware/feeEstimator.js";
18
- import { alchemyGasAndPaymasterAndDataMiddleware } from "../middleware/gasManager.js";
18
+ import { alchemyGasManagerMiddleware } from "../middleware/gasManager.js";
19
19
  import { alchemyUserOperationSimulator } from "../middleware/userOperationSimulator.js";
20
20
  import {
21
21
  alchemyActions,
@@ -144,10 +144,6 @@ export function createAlchemySmartAccountClient({
144
144
  const feeOptions =
145
145
  opts?.feeOptions ?? getDefaultUserOperationFeeOptions(chain);
146
146
 
147
- const gasAndPaymasterAndDataMiddleware = policyId
148
- ? alchemyGasAndPaymasterAndDataMiddleware(policyId)
149
- : undefined;
150
-
151
147
  const scaClient = createSmartAccountClient({
152
148
  account,
153
149
  transport,
@@ -157,24 +153,18 @@ export function createAlchemySmartAccountClient({
157
153
  ...opts,
158
154
  feeOptions,
159
155
  },
160
- dummyPaymasterAndData:
161
- gasAndPaymasterAndDataMiddleware?.dummyPaymasterAndData,
162
- feeEstimator:
163
- feeEstimator ??
164
- gasAndPaymasterAndDataMiddleware?.feeEstimator ??
165
- alchemyFeeEstimator(transport),
166
- gasEstimator:
167
- gasEstimator ?? gasAndPaymasterAndDataMiddleware?.gasEstimator,
168
156
  customMiddleware: async (struct, args) => {
169
157
  if (isSmartAccountWithSigner(args.account)) {
170
158
  transport.updateHeaders(getSignerTypeHeader(args.account));
171
159
  }
172
160
  return customMiddleware ? customMiddleware(struct, args) : struct;
173
161
  },
174
- paymasterAndData: gasAndPaymasterAndDataMiddleware?.paymasterAndData,
162
+ feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),
175
163
  userOperationSimulator: useSimulation
176
164
  ? alchemyUserOperationSimulator(transport)
177
165
  : undefined,
166
+ gasEstimator,
167
+ ...(policyId && alchemyGasManagerMiddleware(policyId)),
178
168
  signUserOperation,
179
169
  }).extend(alchemyActions);
180
170
 
@@ -6,8 +6,6 @@ import {
6
6
  import type {
7
7
  SimulateUserOperationAssetChangesRequest,
8
8
  SimulateUserOperationAssetChangesResponse,
9
- RequestGasAndPaymasterAndDataRequest,
10
- RequestGasAndPaymasterAndDataResponse,
11
9
  } from "../actions/types";
12
10
  import type { AlchemyTransport } from "../alchemyTransport";
13
11
 
@@ -22,12 +20,7 @@ export type AlchemyRpcSchema = [
22
20
  Parameters: [];
23
21
  ReturnType: UserOperationRequest["maxPriorityFeePerGas"];
24
22
  },
25
- ...Erc7677RpcSchema<{ policyId: string }>,
26
- {
27
- Method: "alchemy_requestGasAndPaymasterAndData";
28
- Parameters: RequestGasAndPaymasterAndDataRequest;
29
- ReturnType: RequestGasAndPaymasterAndDataResponse;
30
- }
23
+ ...Erc7677RpcSchema<{ policyId: string }>
31
24
  ];
32
25
 
33
26
  export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
@@ -42,10 +35,5 @@ export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
42
35
  method: "rundler_maxPriorityFeePerGas";
43
36
  params: [];
44
37
  }): Promise<UserOperationRequest["maxPriorityFeePerGas"]>;
45
-
46
- request(args: {
47
- method: "alchemy_requestGasAndPaymasterAndData";
48
- params: RequestGasAndPaymasterAndDataRequest;
49
- }): Promise<RequestGasAndPaymasterAndDataResponse>;
50
38
  }["request"];
51
39
  };
package/src/index.ts CHANGED
@@ -55,9 +55,6 @@ export { getDefaultUserOperationFeeOptions } from "./defaults.js";
55
55
  export { getAlchemyPaymasterAddress } from "./gas-manager.js";
56
56
  export { alchemyFeeEstimator } from "./middleware/feeEstimator.js";
57
57
  export type * from "./middleware/gasManager.js";
58
- export {
59
- alchemyGasManagerMiddleware,
60
- alchemyGasAndPaymasterAndDataMiddleware,
61
- } from "./middleware/gasManager.js";
58
+ export { alchemyGasManagerMiddleware } from "./middleware/gasManager.js";
62
59
  export { alchemyUserOperationSimulator } from "./middleware/userOperationSimulator.js";
63
60
  export type * from "./schema.js";
@@ -1,27 +1,5 @@
1
- import type {
2
- ClientMiddlewareConfig,
3
- EntryPointVersion,
4
- Multiplier,
5
- UserOperationFeeOptions,
6
- UserOperationOverrides,
7
- UserOperationRequest,
8
- } from "@aa-sdk/core";
9
- import {
10
- bypassPaymasterAndData,
11
- ChainNotFoundError,
12
- deepHexlify,
13
- defaultFeeEstimator,
14
- defaultGasEstimator,
15
- erc7677Middleware,
16
- filterUndefined,
17
- isBigNumberish,
18
- isMultiplier,
19
- noopMiddleware,
20
- resolveProperties,
21
- } from "@aa-sdk/core";
22
- import { getAlchemyPaymasterAddress } from "../gas-manager.js";
23
- import { fromHex, isHex, type Hex } from "viem";
24
- import type { AlchemySmartAccountClient } from "../client/smartAccountClient.js";
1
+ import type { ClientMiddlewareConfig } from "@aa-sdk/core";
2
+ import { erc7677Middleware } from "@aa-sdk/core";
25
3
 
26
4
  /**
27
5
  * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions.
@@ -48,183 +26,3 @@ export function alchemyGasManagerMiddleware(
48
26
  context: { policyId: policyId },
49
27
  });
50
28
  }
51
-
52
- /**
53
- * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring transactions using
54
- * the `alchemy_requestGasAndPaymasterAndData` method instead of standard ERC-7677 methods.
55
- *
56
- * @example
57
- * ```ts
58
- * import { sepolia, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
59
- * import { http } from "viem";
60
- *
61
- * const client = createSmartAccountClient({
62
- * transport: http("rpc-url"),
63
- * chain: sepolia,
64
- * ...alchemyGasAndPaymasterAndDataMiddleware("policyId")
65
- * });
66
- * ```
67
- *
68
- * @param {string} policyId the policyId for Alchemy's gas manager
69
- * @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
70
- */
71
- export function alchemyGasAndPaymasterAndDataMiddleware(
72
- policyId: string
73
- ): Pick<
74
- ClientMiddlewareConfig,
75
- "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData"
76
- > {
77
- return {
78
- dummyPaymasterAndData: async (uo, { client, account }) => {
79
- if (!client.chain) {
80
- throw new ChainNotFoundError();
81
- }
82
-
83
- const paymaster = getAlchemyPaymasterAddress(client.chain);
84
- const paymasterData = await account.getDummySignature();
85
-
86
- return {
87
- ...uo,
88
- dummyPaymasterAndData: {
89
- paymaster,
90
- paymasterData,
91
- },
92
- };
93
- },
94
- feeEstimator: (uo, args) => {
95
- return bypassPaymasterAndData(args.overrides)
96
- ? defaultFeeEstimator(args.client)(uo, args)
97
- : noopMiddleware(uo, args);
98
- },
99
- gasEstimator: (uo, args) => {
100
- return bypassPaymasterAndData(args.overrides)
101
- ? defaultGasEstimator(args.client)(uo, args)
102
- : noopMiddleware(uo, args);
103
- },
104
- paymasterAndData: async (
105
- uo,
106
- { account, client, feeOptions, overrides: overrides_ }
107
- ) => {
108
- if (!client.chain) {
109
- throw new ChainNotFoundError();
110
- }
111
-
112
- const userOp = deepHexlify(await resolveProperties(uo));
113
-
114
- const overrides: UserOperationOverrides = filterUndefined({
115
- maxFeePerGas: overrideField(
116
- "maxFeePerGas",
117
- overrides_ as UserOperationOverrides,
118
- feeOptions,
119
- userOp
120
- ),
121
- maxPriorityFeePerGas: overrideField(
122
- "maxPriorityFeePerGas",
123
- overrides_ as UserOperationOverrides,
124
- feeOptions,
125
- userOp
126
- ),
127
- callGasLimit: overrideField(
128
- "callGasLimit",
129
- overrides_ as UserOperationOverrides,
130
- feeOptions,
131
- userOp
132
- ),
133
- verificationGasLimit: overrideField(
134
- "verificationGasLimit",
135
- overrides_ as UserOperationOverrides,
136
- feeOptions,
137
- userOp
138
- ),
139
- preVerificationGas: overrideField(
140
- "preVerificationGas",
141
- overrides_ as UserOperationOverrides,
142
- feeOptions,
143
- userOp
144
- ),
145
- ...(account.getEntryPoint().version === "0.7.0"
146
- ? {
147
- paymasterVerificationGasLimit: overrideField<"0.7.0">(
148
- "paymasterVerificationGasLimit",
149
- overrides_ as UserOperationOverrides<"0.7.0">,
150
- feeOptions,
151
- userOp
152
- ),
153
- paymasterPostOpGasLimit: overrideField<"0.7.0">(
154
- "paymasterPostOpGasLimit",
155
- overrides_ as UserOperationOverrides<"0.7.0">,
156
- feeOptions,
157
- userOp
158
- ),
159
- }
160
- : {}),
161
- });
162
-
163
- const result = await (client as AlchemySmartAccountClient).request({
164
- method: "alchemy_requestGasAndPaymasterAndData",
165
- params: [
166
- {
167
- policyId,
168
- entryPoint: account.getEntryPoint().address,
169
- userOperation: userOp,
170
- dummySignature: await account.getDummySignature(),
171
- overrides,
172
- },
173
- ],
174
- });
175
-
176
- return {
177
- ...uo,
178
- ...result,
179
- };
180
- },
181
- };
182
- }
183
-
184
- /**
185
- * Utility function to override a field in the user operation request with the overrides or fee options
186
- *
187
- * @template {EntryPointVersion} TEntryPointVersion
188
- * @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override
189
- * @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object
190
- * @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client
191
- * @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request
192
- * @returns {Hex | Multiplier | undefined} the overridden field value
193
- */
194
- const overrideField = <
195
- TEntryPointVersion extends EntryPointVersion = EntryPointVersion
196
- >(
197
- field: keyof UserOperationFeeOptions<TEntryPointVersion>,
198
- overrides: UserOperationOverrides<TEntryPointVersion> | undefined,
199
- feeOptions: UserOperationFeeOptions<TEntryPointVersion> | undefined,
200
- userOperation: UserOperationRequest<TEntryPointVersion>
201
- ): Hex | Multiplier | undefined => {
202
- let _field = field as keyof UserOperationOverrides<TEntryPointVersion>;
203
-
204
- if (overrides?.[_field] != null) {
205
- // one-off absolute override
206
- if (isBigNumberish(overrides[_field])) {
207
- return deepHexlify(overrides[_field]);
208
- }
209
- // one-off multiplier overrides
210
- else {
211
- return {
212
- multiplier: Number((overrides[_field] as Multiplier).multiplier),
213
- };
214
- }
215
- }
216
-
217
- // provider level fee options with multiplier
218
- if (isMultiplier(feeOptions?.[field])) {
219
- return {
220
- multiplier: Number((feeOptions![field] as Multiplier).multiplier),
221
- };
222
- }
223
-
224
- const userOpField =
225
- userOperation[field as keyof UserOperationRequest<TEntryPointVersion>];
226
- if (isHex(userOpField) && fromHex(userOpField as Hex, "bigint") > 0n) {
227
- return userOpField;
228
- }
229
- return undefined;
230
- };
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is autogenerated by inject-version.ts. Any changes will be
2
2
  // overwritten on commit!
3
- export const VERSION = "4.12.0";
3
+ export const VERSION = "4.13.0";