@alchemy/aa-infra 5.0.0-beta.2 → 5.0.0-beta.20

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.
@@ -3,13 +3,10 @@ import type { UserOperationRequest, SmartAccount, BundlerClient } from "viem/acc
3
3
  import type { RundlerRpcSchema } from "./schema.js";
4
4
  export type RundlerClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartAccount | undefined = SmartAccount | undefined> = BundlerClient<transport, chain, account, Client | undefined, RundlerRpcSchema>;
5
5
  /**
6
- * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_maxPriorityFeePerGas` for priority fee estimation.
6
+ * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_getUserOperationGasPrice` for fee estimation.
7
7
  *
8
- * It fetches:
9
- * 1. `baseFeePerGas` from the latest block.
10
- * 2. `maxPriorityFeePerGas` via `rundler_maxPriorityFeePerGas`.
11
- *
12
- * It then returns `maxFeePerGas = baseFee * 1.5 + priority` (aligns with viem default).
8
+ * It fetches gas price via `rundler_getUserOperationGasPrice` and returns the
9
+ * `suggested.maxFeePerGas` and `suggested.maxPriorityFeePerGas` values directly.
13
10
  *
14
11
  * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.
15
12
  * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.
@@ -1,15 +1,9 @@
1
- import { getBlock } from "viem/actions";
2
- import { isHex, hexToBigInt, } from "viem";
3
- import { BaseError, bigIntMultiply } from "@alchemy/common";
4
- import { InvalidHexValueError } from "./errors.js";
1
+ import { hexToBigInt, } from "viem";
5
2
  /**
6
- * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_maxPriorityFeePerGas` for priority fee estimation.
3
+ * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_getUserOperationGasPrice` for fee estimation.
7
4
  *
8
- * It fetches:
9
- * 1. `baseFeePerGas` from the latest block.
10
- * 2. `maxPriorityFeePerGas` via `rundler_maxPriorityFeePerGas`.
11
- *
12
- * It then returns `maxFeePerGas = baseFee * 1.5 + priority` (aligns with viem default).
5
+ * It fetches gas price via `rundler_getUserOperationGasPrice` and returns the
6
+ * `suggested.maxFeePerGas` and `suggested.maxPriorityFeePerGas` values directly.
13
7
  *
14
8
  * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.
15
9
  * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.
@@ -33,31 +27,13 @@ export async function estimateFeesPerGas({ bundlerClient, account: _account, use
33
27
  // to access bundler-specific properties from a base Client type.
34
28
  // See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355
35
29
  const rundlerClient = bundlerClient;
36
- const [block, maxPriorityFeePerGasHex] = await Promise.all([
37
- // If the node rpc url is different from the bundler url, the public
38
- // client should be passed in when creating the bundler client, which
39
- // we can access here for public actions.
40
- getBlock(rundlerClient.client ?? rundlerClient, { blockTag: "latest" }),
41
- rundlerClient.request({
42
- method: "rundler_maxPriorityFeePerGas",
43
- params: [],
44
- }),
45
- ]);
46
- const baseFeePerGas = block.baseFeePerGas;
47
- if (baseFeePerGas == null) {
48
- throw new BaseError("baseFeePerGas is null");
49
- }
50
- if (maxPriorityFeePerGasHex == null) {
51
- throw new BaseError("rundler_maxPriorityFeePerGas returned null or undefined");
52
- }
53
- if (!isHex(maxPriorityFeePerGasHex)) {
54
- throw new InvalidHexValueError(maxPriorityFeePerGasHex);
55
- }
56
- const maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGasHex);
57
- const bufferedMaxPriorityFeePerGas = bigIntMultiply(maxPriorityFeePerGas, 1.5);
30
+ const { suggested } = await rundlerClient.request({
31
+ method: "rundler_getUserOperationGasPrice",
32
+ params: [],
33
+ });
58
34
  return {
59
- maxPriorityFeePerGas: bufferedMaxPriorityFeePerGas,
60
- maxFeePerGas: bigIntMultiply(baseFeePerGas, 1.5) + bufferedMaxPriorityFeePerGas,
35
+ maxPriorityFeePerGas: hexToBigInt(suggested.maxPriorityFeePerGas),
36
+ maxFeePerGas: hexToBigInt(suggested.maxFeePerGas),
61
37
  };
62
38
  }
63
39
  //# sourceMappingURL=estimateFeesPerGas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"estimateFeesPerGas.js","sourceRoot":"","sources":["../../src/estimateFeesPerGas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAEL,KAAK,EAGL,WAAW,GAEZ,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAenD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAOtC,EACA,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAK9B;IAIC,6FAA6F;IAC7F,8GAA8G;IAC9G,iEAAiE;IACjE,uHAAuH;IACvH,MAAM,aAAa,GAAG,aAAyC,CAAC;IAEhE,MAAM,CAAC,KAAK,EAAE,uBAAuB,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,oEAAoE;QACpE,qEAAqE;QACrE,yCAAyC;QACzC,QAAQ,CAAC,aAAa,CAAC,MAAM,IAAI,aAAa,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACvE,aAAa,CAAC,OAAO,CAAC;YACpB,MAAM,EAAE,8BAA8B;YACtC,MAAM,EAAE,EAAE;SACX,CAAC;KACH,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;IAC1C,IAAI,aAAa,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,SAAS,CAAC,uBAAuB,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,uBAAuB,IAAI,IAAI,EAAE,CAAC;QACpC,MAAM,IAAI,SAAS,CACjB,yDAAyD,CAC1D,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,oBAAoB,GAAG,WAAW,CAAC,uBAAuB,CAAC,CAAC;IAElE,MAAM,4BAA4B,GAAG,cAAc,CACjD,oBAAoB,EACpB,GAAG,CACJ,CAAC;IAEF,OAAO;QACL,oBAAoB,EAAE,4BAA4B;QAClD,YAAY,EACV,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG,4BAA4B;KACpE,CAAC;AACJ,CAAC","sourcesContent":["import { getBlock } from \"viem/actions\";\nimport {\n type Client,\n isHex,\n type Transport,\n type Chain,\n hexToBigInt,\n type Account,\n} from \"viem\";\nimport type {\n UserOperationRequest,\n SmartAccount,\n BundlerClient,\n} from \"viem/account-abstraction\";\nimport { BaseError, bigIntMultiply } from \"@alchemy/common\";\nimport type { RundlerRpcSchema } from \"./schema.js\";\nimport { InvalidHexValueError } from \"./errors.js\";\n\n// Extend client with Rundler rpc schema.\nexport type RundlerClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<\n transport,\n chain,\n account,\n Client | undefined,\n RundlerRpcSchema\n>;\n\n/**\n * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_maxPriorityFeePerGas` for priority fee estimation.\n *\n * It fetches:\n * 1. `baseFeePerGas` from the latest block.\n * 2. `maxPriorityFeePerGas` via `rundler_maxPriorityFeePerGas`.\n *\n * It then returns `maxFeePerGas = baseFee * 1.5 + priority` (aligns with viem default).\n *\n * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.\n * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.\n *\n * @example\n * ```ts\n * import { createBundlerClient } from \"viem/account-abstraction\";\n * import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from \"@alchemy/aa-infra\";\n *\n * const bundler = createBundlerClient({\n * transport: http(\"<rundler-url>\"),\n * userOperation: {\n * estimateFeesPerGas: alchemyEstimateFeesPerGas,\n * },\n * });\n * ```\n */\nexport async function estimateFeesPerGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | Account | undefined =\n | SmartAccount\n | Account\n | undefined,\n>({\n bundlerClient,\n account: _account,\n userOperation: _userOperation,\n}: {\n bundlerClient: Client<TTransport, TChain, TAccount>;\n account?: SmartAccount;\n userOperation?: UserOperationRequest;\n}): Promise<{\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n}> {\n // Cast to RundlerClient to access rundler-specific RPC methods and BundlerClient properties.\n // This mirrors viem's pattern in prepareUserOperation.ts where they cast `client as unknown as BundlerClient`\n // to access bundler-specific properties from a base Client type.\n // See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355\n const rundlerClient = bundlerClient as unknown as RundlerClient;\n\n const [block, maxPriorityFeePerGasHex] = await Promise.all([\n // If the node rpc url is different from the bundler url, the public\n // client should be passed in when creating the bundler client, which\n // we can access here for public actions.\n getBlock(rundlerClient.client ?? rundlerClient, { blockTag: \"latest\" }),\n rundlerClient.request({\n method: \"rundler_maxPriorityFeePerGas\",\n params: [],\n }),\n ]);\n\n const baseFeePerGas = block.baseFeePerGas;\n if (baseFeePerGas == null) {\n throw new BaseError(\"baseFeePerGas is null\");\n }\n if (maxPriorityFeePerGasHex == null) {\n throw new BaseError(\n \"rundler_maxPriorityFeePerGas returned null or undefined\",\n );\n }\n if (!isHex(maxPriorityFeePerGasHex)) {\n throw new InvalidHexValueError(maxPriorityFeePerGasHex);\n }\n const maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGasHex);\n\n const bufferedMaxPriorityFeePerGas = bigIntMultiply(\n maxPriorityFeePerGas,\n 1.5,\n );\n\n return {\n maxPriorityFeePerGas: bufferedMaxPriorityFeePerGas,\n maxFeePerGas:\n bigIntMultiply(baseFeePerGas, 1.5) + bufferedMaxPriorityFeePerGas,\n };\n}\n"]}
1
+ {"version":3,"file":"estimateFeesPerGas.js","sourceRoot":"","sources":["../../src/estimateFeesPerGas.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,GAEZ,MAAM,MAAM,CAAC;AAqBd;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAOtC,EACA,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAK9B;IAIC,6FAA6F;IAC7F,8GAA8G;IAC9G,iEAAiE;IACjE,uHAAuH;IACvH,MAAM,aAAa,GAAG,aAAyC,CAAC;IAEhE,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC;QAChD,MAAM,EAAE,kCAAkC;QAC1C,MAAM,EAAE,EAAE;KACX,CAAC,CAAC;IAEH,OAAO;QACL,oBAAoB,EAAE,WAAW,CAAC,SAAS,CAAC,oBAAoB,CAAC;QACjE,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC,YAAY,CAAC;KAClD,CAAC;AACJ,CAAC","sourcesContent":["import {\n type Client,\n type Transport,\n type Chain,\n hexToBigInt,\n type Account,\n} from \"viem\";\nimport type {\n UserOperationRequest,\n SmartAccount,\n BundlerClient,\n} from \"viem/account-abstraction\";\nimport type { RundlerRpcSchema } from \"./schema.js\";\n\n// Extend client with Rundler rpc schema.\nexport type RundlerClient<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends SmartAccount | undefined = SmartAccount | undefined,\n> = BundlerClient<\n transport,\n chain,\n account,\n Client | undefined,\n RundlerRpcSchema\n>;\n\n/**\n * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_getUserOperationGasPrice` for fee estimation.\n *\n * It fetches gas price via `rundler_getUserOperationGasPrice` and returns the\n * `suggested.maxFeePerGas` and `suggested.maxPriorityFeePerGas` values directly.\n *\n * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.\n * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.\n *\n * @example\n * ```ts\n * import { createBundlerClient } from \"viem/account-abstraction\";\n * import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from \"@alchemy/aa-infra\";\n *\n * const bundler = createBundlerClient({\n * transport: http(\"<rundler-url>\"),\n * userOperation: {\n * estimateFeesPerGas: alchemyEstimateFeesPerGas,\n * },\n * });\n * ```\n */\nexport async function estimateFeesPerGas<\n TTransport extends Transport = Transport,\n TChain extends Chain | undefined = Chain | undefined,\n TAccount extends SmartAccount | Account | undefined =\n | SmartAccount\n | Account\n | undefined,\n>({\n bundlerClient,\n account: _account,\n userOperation: _userOperation,\n}: {\n bundlerClient: Client<TTransport, TChain, TAccount>;\n account?: SmartAccount;\n userOperation?: UserOperationRequest;\n}): Promise<{\n maxFeePerGas: bigint;\n maxPriorityFeePerGas: bigint;\n}> {\n // Cast to RundlerClient to access rundler-specific RPC methods and BundlerClient properties.\n // This mirrors viem's pattern in prepareUserOperation.ts where they cast `client as unknown as BundlerClient`\n // to access bundler-specific properties from a base Client type.\n // See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355\n const rundlerClient = bundlerClient as unknown as RundlerClient;\n\n const { suggested } = await rundlerClient.request({\n method: \"rundler_getUserOperationGasPrice\",\n params: [],\n });\n\n return {\n maxPriorityFeePerGas: hexToBigInt(suggested.maxPriorityFeePerGas),\n maxFeePerGas: hexToBigInt(suggested.maxFeePerGas),\n };\n}\n"]}
@@ -4,5 +4,21 @@ type RundlerMaxPriorityFeePerGasSchema = {
4
4
  Parameters: [];
5
5
  ReturnType: Hex;
6
6
  };
7
- export type RundlerRpcSchema = [RundlerMaxPriorityFeePerGasSchema];
7
+ type RundlerGetUserOperationGasPriceSchema = {
8
+ Method: "rundler_getUserOperationGasPrice";
9
+ Parameters: [];
10
+ ReturnType: {
11
+ priorityFee: Hex;
12
+ baseFee: Hex;
13
+ blockNumber: Hex;
14
+ suggested: {
15
+ maxPriorityFeePerGas: Hex;
16
+ maxFeePerGas: Hex;
17
+ };
18
+ };
19
+ };
20
+ export type RundlerRpcSchema = [
21
+ RundlerMaxPriorityFeePerGasSchema,
22
+ RundlerGetUserOperationGasPriceSchema
23
+ ];
8
24
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from \"viem\";\n\ntype RundlerMaxPriorityFeePerGasSchema = {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: Hex;\n};\n\nexport type RundlerRpcSchema = [RundlerMaxPriorityFeePerGasSchema];\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"","sourcesContent":["import type { Hex } from \"viem\";\n\ntype RundlerMaxPriorityFeePerGasSchema = {\n Method: \"rundler_maxPriorityFeePerGas\";\n Parameters: [];\n ReturnType: Hex;\n};\n\ntype RundlerGetUserOperationGasPriceSchema = {\n Method: \"rundler_getUserOperationGasPrice\";\n Parameters: [];\n ReturnType: {\n priorityFee: Hex;\n baseFee: Hex;\n blockNumber: Hex;\n suggested: {\n maxPriorityFeePerGas: Hex;\n maxFeePerGas: Hex;\n };\n };\n};\n\nexport type RundlerRpcSchema = [\n RundlerMaxPriorityFeePerGasSchema,\n RundlerGetUserOperationGasPriceSchema,\n];\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "5.0.0-beta.1";
1
+ export declare const VERSION = "5.0.0-beta.19";
@@ -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 = "5.0.0-beta.1";
3
+ export const VERSION = "5.0.0-beta.19";
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,cAAc,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.1\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,yBAAyB;AACzB,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["// This file is autogenerated by inject-version.ts. Any changes will be\n// overwritten on commit!\nexport const VERSION = \"5.0.0-beta.19\";\n"]}
@@ -3,13 +3,10 @@ import type { UserOperationRequest, SmartAccount, BundlerClient } from "viem/acc
3
3
  import type { RundlerRpcSchema } from "./schema.js";
4
4
  export type RundlerClient<transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, account extends SmartAccount | undefined = SmartAccount | undefined> = BundlerClient<transport, chain, account, Client | undefined, RundlerRpcSchema>;
5
5
  /**
6
- * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_maxPriorityFeePerGas` for priority fee estimation.
6
+ * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_getUserOperationGasPrice` for fee estimation.
7
7
  *
8
- * It fetches:
9
- * 1. `baseFeePerGas` from the latest block.
10
- * 2. `maxPriorityFeePerGas` via `rundler_maxPriorityFeePerGas`.
11
- *
12
- * It then returns `maxFeePerGas = baseFee * 1.5 + priority` (aligns with viem default).
8
+ * It fetches gas price via `rundler_getUserOperationGasPrice` and returns the
9
+ * `suggested.maxFeePerGas` and `suggested.maxPriorityFeePerGas` values directly.
13
10
  *
14
11
  * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.
15
12
  * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.
@@ -1 +1 @@
1
- {"version":3,"file":"estimateFeesPerGas.d.ts","sourceRoot":"","sources":["../../src/estimateFeesPerGas.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,MAAM,EAEX,KAAK,SAAS,EACd,KAAK,KAAK,EAEV,KAAK,OAAO,EACb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAIpD,MAAM,MAAM,aAAa,CACvB,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IACjE,aAAa,CACf,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,GAAG,SAAS,EAClB,gBAAgB,CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,OAAO,GAAG,SAAS,GAC/C,YAAY,GACZ,OAAO,GACP,SAAS,EACb,EACA,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAC9B,EAAE;IACD,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC,CA0CD"}
1
+ {"version":3,"file":"estimateFeesPerGas.d.ts","sourceRoot":"","sources":["../../src/estimateFeesPerGas.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,KAAK,EAEV,KAAK,OAAO,EACb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,MAAM,MAAM,aAAa,CACvB,SAAS,SAAS,SAAS,GAAG,SAAS,EACvC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,IACjE,aAAa,CACf,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,GAAG,SAAS,EAClB,gBAAgB,CACjB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,SAAS,SAAS,GAAG,SAAS,EACxC,MAAM,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACpD,QAAQ,SAAS,YAAY,GAAG,OAAO,GAAG,SAAS,GAC/C,YAAY,GACZ,OAAO,GACP,SAAS,EACb,EACA,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAC9B,EAAE;IACD,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC,CAgBD"}
@@ -4,6 +4,22 @@ type RundlerMaxPriorityFeePerGasSchema = {
4
4
  Parameters: [];
5
5
  ReturnType: Hex;
6
6
  };
7
- export type RundlerRpcSchema = [RundlerMaxPriorityFeePerGasSchema];
7
+ type RundlerGetUserOperationGasPriceSchema = {
8
+ Method: "rundler_getUserOperationGasPrice";
9
+ Parameters: [];
10
+ ReturnType: {
11
+ priorityFee: Hex;
12
+ baseFee: Hex;
13
+ blockNumber: Hex;
14
+ suggested: {
15
+ maxPriorityFeePerGas: Hex;
16
+ maxFeePerGas: Hex;
17
+ };
18
+ };
19
+ };
20
+ export type RundlerRpcSchema = [
21
+ RundlerMaxPriorityFeePerGasSchema,
22
+ RundlerGetUserOperationGasPriceSchema
23
+ ];
8
24
  export {};
9
25
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,KAAK,iCAAiC,GAAG;IACvC,MAAM,EAAE,8BAA8B,CAAC;IACvC,UAAU,EAAE,EAAE,CAAC;IACf,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,iCAAiC,CAAC,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,KAAK,iCAAiC,GAAG;IACvC,MAAM,EAAE,8BAA8B,CAAC;IACvC,UAAU,EAAE,EAAE,CAAC;IACf,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAEF,KAAK,qCAAqC,GAAG;IAC3C,MAAM,EAAE,kCAAkC,CAAC;IAC3C,UAAU,EAAE,EAAE,CAAC;IACf,UAAU,EAAE;QACV,WAAW,EAAE,GAAG,CAAC;QACjB,OAAO,EAAE,GAAG,CAAC;QACb,WAAW,EAAE,GAAG,CAAC;QACjB,SAAS,EAAE;YACT,oBAAoB,EAAE,GAAG,CAAC;YAC1B,YAAY,EAAE,GAAG,CAAC;SACnB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,iCAAiC;IACjC,qCAAqC;CACtC,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "5.0.0-beta.1";
1
+ export declare const VERSION = "5.0.0-beta.19";
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,iBAAiB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alchemy/aa-infra",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.20",
4
4
  "description": "Alchemy Account Abstraction Infrastructure",
5
5
  "author": "Alchemy",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "scripts": {
33
33
  "prebuild": "tsx ./inject-version.ts",
34
- "build": "yarn clean && yarn build:esm && yarn build:types",
34
+ "build": "pnpm run clean && pnpm run build:esm && pnpm run build:types",
35
35
  "build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm",
36
36
  "build:types": "tsc --project tsconfig.build.json --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
37
37
  "clean": "rm -rf ./dist",
@@ -39,11 +39,11 @@
39
39
  "test:run": "vitest run"
40
40
  },
41
41
  "devDependencies": {
42
- "typescript-template": "*",
42
+ "typescript-template": "workspace:*",
43
43
  "viem": "^2.45.0"
44
44
  },
45
45
  "dependencies": {
46
- "@alchemy/common": "^5.0.0-beta.2"
46
+ "@alchemy/common": "5.0.0-beta.20"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "viem": "^2.45.0"
@@ -60,5 +60,5 @@
60
60
  "url": "https://github.com/alchemyplatform/aa-sdk/issues"
61
61
  },
62
62
  "homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
63
- "gitHead": "9042002b7414ac2ae8a6251ee4cf96555b091eca"
63
+ "gitHead": "e8b35b489e1f129877c618752b35b4fb05149a55"
64
64
  }
@@ -1,7 +1,5 @@
1
- import { getBlock } from "viem/actions";
2
1
  import {
3
2
  type Client,
4
- isHex,
5
3
  type Transport,
6
4
  type Chain,
7
5
  hexToBigInt,
@@ -12,9 +10,7 @@ import type {
12
10
  SmartAccount,
13
11
  BundlerClient,
14
12
  } from "viem/account-abstraction";
15
- import { BaseError, bigIntMultiply } from "@alchemy/common";
16
13
  import type { RundlerRpcSchema } from "./schema.js";
17
- import { InvalidHexValueError } from "./errors.js";
18
14
 
19
15
  // Extend client with Rundler rpc schema.
20
16
  export type RundlerClient<
@@ -30,13 +26,10 @@ export type RundlerClient<
30
26
  >;
31
27
 
32
28
  /**
33
- * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_maxPriorityFeePerGas` for priority fee estimation.
29
+ * A custom `estimateFeesPerGas` function for viem bundler clients to use `rundler_getUserOperationGasPrice` for fee estimation.
34
30
  *
35
- * It fetches:
36
- * 1. `baseFeePerGas` from the latest block.
37
- * 2. `maxPriorityFeePerGas` via `rundler_maxPriorityFeePerGas`.
38
- *
39
- * It then returns `maxFeePerGas = baseFee * 1.5 + priority` (aligns with viem default).
31
+ * It fetches gas price via `rundler_getUserOperationGasPrice` and returns the
32
+ * `suggested.maxFeePerGas` and `suggested.maxPriorityFeePerGas` values directly.
40
33
  *
41
34
  * @param {RundlerClient} bundlerClient Bundler client with the rundler RPC method.
42
35
  * @returns {Promise<{maxFeePerGas: bigint, maxPriorityFeePerGas: bigint}>} Estimated fee values.
@@ -79,39 +72,13 @@ export async function estimateFeesPerGas<
79
72
  // See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355
80
73
  const rundlerClient = bundlerClient as unknown as RundlerClient;
81
74
 
82
- const [block, maxPriorityFeePerGasHex] = await Promise.all([
83
- // If the node rpc url is different from the bundler url, the public
84
- // client should be passed in when creating the bundler client, which
85
- // we can access here for public actions.
86
- getBlock(rundlerClient.client ?? rundlerClient, { blockTag: "latest" }),
87
- rundlerClient.request({
88
- method: "rundler_maxPriorityFeePerGas",
89
- params: [],
90
- }),
91
- ]);
92
-
93
- const baseFeePerGas = block.baseFeePerGas;
94
- if (baseFeePerGas == null) {
95
- throw new BaseError("baseFeePerGas is null");
96
- }
97
- if (maxPriorityFeePerGasHex == null) {
98
- throw new BaseError(
99
- "rundler_maxPriorityFeePerGas returned null or undefined",
100
- );
101
- }
102
- if (!isHex(maxPriorityFeePerGasHex)) {
103
- throw new InvalidHexValueError(maxPriorityFeePerGasHex);
104
- }
105
- const maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGasHex);
106
-
107
- const bufferedMaxPriorityFeePerGas = bigIntMultiply(
108
- maxPriorityFeePerGas,
109
- 1.5,
110
- );
75
+ const { suggested } = await rundlerClient.request({
76
+ method: "rundler_getUserOperationGasPrice",
77
+ params: [],
78
+ });
111
79
 
112
80
  return {
113
- maxPriorityFeePerGas: bufferedMaxPriorityFeePerGas,
114
- maxFeePerGas:
115
- bigIntMultiply(baseFeePerGas, 1.5) + bufferedMaxPriorityFeePerGas,
81
+ maxPriorityFeePerGas: hexToBigInt(suggested.maxPriorityFeePerGas),
82
+ maxFeePerGas: hexToBigInt(suggested.maxFeePerGas),
116
83
  };
117
84
  }
package/src/schema.ts CHANGED
@@ -6,4 +6,21 @@ type RundlerMaxPriorityFeePerGasSchema = {
6
6
  ReturnType: Hex;
7
7
  };
8
8
 
9
- export type RundlerRpcSchema = [RundlerMaxPriorityFeePerGasSchema];
9
+ type RundlerGetUserOperationGasPriceSchema = {
10
+ Method: "rundler_getUserOperationGasPrice";
11
+ Parameters: [];
12
+ ReturnType: {
13
+ priorityFee: Hex;
14
+ baseFee: Hex;
15
+ blockNumber: Hex;
16
+ suggested: {
17
+ maxPriorityFeePerGas: Hex;
18
+ maxFeePerGas: Hex;
19
+ };
20
+ };
21
+ };
22
+
23
+ export type RundlerRpcSchema = [
24
+ RundlerMaxPriorityFeePerGasSchema,
25
+ RundlerGetUserOperationGasPriceSchema,
26
+ ];
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 = "5.0.0-beta.2";
3
+ export const VERSION = "5.0.0-beta.20";