@alchemy/aa-infra 0.0.0-alpha.14 → 0.0.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/estimateFeesPerGas.d.ts +2 -2
- package/dist/esm/estimateFeesPerGas.js +7 -2
- package/dist/esm/estimateFeesPerGas.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/types/estimateFeesPerGas.d.ts +2 -2
- package/dist/types/estimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/estimateFeesPerGas.ts +10 -8
- package/src/version.ts +1 -1
|
@@ -27,8 +27,8 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function estimateFeesPerGas
|
|
31
|
-
bundlerClient:
|
|
30
|
+
export declare function estimateFeesPerGas({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
+
bundlerClient: Client;
|
|
32
32
|
account?: SmartAccount;
|
|
33
33
|
userOperation?: UserOperationRequest;
|
|
34
34
|
}): Promise<{
|
|
@@ -28,12 +28,17 @@ import { InvalidHexValueError } from "./errors.js";
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export async function estimateFeesPerGas({ bundlerClient, account: _account, userOperation: _userOperation, }) {
|
|
31
|
+
// Cast to RundlerClient to access rundler-specific RPC methods and BundlerClient properties.
|
|
32
|
+
// This mirrors viem's pattern in prepareUserOperation.ts where they cast `client as unknown as BundlerClient`
|
|
33
|
+
// to access bundler-specific properties from a base Client type.
|
|
34
|
+
// See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355
|
|
35
|
+
const rundlerClient = bundlerClient;
|
|
31
36
|
const [block, maxPriorityFeePerGasHex] = await Promise.all([
|
|
32
37
|
// If the node rpc url is different from the bundler url, the public
|
|
33
38
|
// client should be passed in when creating the bundler client, which
|
|
34
39
|
// we can access here for public actions.
|
|
35
|
-
getBlock(
|
|
36
|
-
|
|
40
|
+
getBlock(rundlerClient.client ?? rundlerClient, { blockTag: "latest" }),
|
|
41
|
+
rundlerClient.request({
|
|
37
42
|
method: "rundler_maxPriorityFeePerGas",
|
|
38
43
|
params: [],
|
|
39
44
|
}),
|
|
@@ -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,GACZ,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAenD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,
|
|
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,GACZ,MAAM,MAAM,CAAC;AAMd,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAenD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAK9B;IAIC,6FAA6F;IAC7F,8GAA8G;IAC9G,iEAAiE;IACjE,uHAAuH;IACvH,MAAM,aAAa,GAAG,aAA8B,CAAC;IAErD,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,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,uBAAuB,IAAI,IAAI,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,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,OAAO;QACL,oBAAoB;QACpB,YAAY,EAAE,cAAc,CAAC,aAAa,EAAE,GAAG,CAAC,GAAG,oBAAoB;KACxE,CAAC;AACJ,CAAC","sourcesContent":["import { getBlock } from \"viem/actions\";\nimport {\n type Client,\n isHex,\n type Transport,\n type Chain,\n hexToBigInt,\n} from \"viem\";\nimport type {\n UserOperationRequest,\n SmartAccount,\n BundlerClient,\n} from \"viem/account-abstraction\";\nimport { 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 { 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 bundlerClient,\n account: _account,\n userOperation: _userOperation,\n}: {\n bundlerClient: Client;\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 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 Error(\"baseFeePerGas is null\");\n }\n if (maxPriorityFeePerGasHex == null) {\n throw new Error(\"rundler_maxPriorityFeePerGas returned null or undefined\");\n }\n if (!isHex(maxPriorityFeePerGasHex)) {\n throw new InvalidHexValueError(maxPriorityFeePerGasHex);\n }\n const maxPriorityFeePerGas = hexToBigInt(maxPriorityFeePerGasHex);\n\n return {\n maxPriorityFeePerGas,\n maxFeePerGas: bigIntMultiply(baseFeePerGas, 1.5) + maxPriorityFeePerGas,\n };\n}\n"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.0.0-alpha.14";
|
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -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 = \"0.0.0-alpha.
|
|
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 = \"0.0.0-alpha.14\";\n"]}
|
|
@@ -27,8 +27,8 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function estimateFeesPerGas
|
|
31
|
-
bundlerClient:
|
|
30
|
+
export declare function estimateFeesPerGas({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
+
bundlerClient: Client;
|
|
32
32
|
account?: SmartAccount;
|
|
33
33
|
userOperation?: UserOperationRequest;
|
|
34
34
|
}): Promise<{
|
|
@@ -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,EAEX,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,
|
|
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,EAEX,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,CAAC,EACvC,aAAa,EACb,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,GAC9B,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,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,CAkCD"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.0.0-alpha.14";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alchemy/aa-infra",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.15",
|
|
4
4
|
"description": "Alchemy Account Abstraction Infrastructure",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typescript-template": "*"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@alchemy/common": "^0.0.0-alpha.
|
|
46
|
+
"@alchemy/common": "^0.0.0-alpha.15",
|
|
47
47
|
"viem": "^2.32.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"url": "https://github.com/alchemyplatform/aa-sdk/issues"
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/alchemyplatform/aa-sdk#readme",
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "fec14e3da5a8ecc65394749d00759a0474d27083"
|
|
62
62
|
}
|
|
@@ -53,28 +53,30 @@ export type RundlerClient<
|
|
|
53
53
|
* });
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export async function estimateFeesPerGas
|
|
57
|
-
TTransport extends Transport = Transport,
|
|
58
|
-
TChain extends Chain | undefined = Chain | undefined,
|
|
59
|
-
TAccount extends SmartAccount | undefined = SmartAccount | undefined,
|
|
60
|
-
>({
|
|
56
|
+
export async function estimateFeesPerGas({
|
|
61
57
|
bundlerClient,
|
|
62
58
|
account: _account,
|
|
63
59
|
userOperation: _userOperation,
|
|
64
60
|
}: {
|
|
65
|
-
bundlerClient:
|
|
61
|
+
bundlerClient: Client;
|
|
66
62
|
account?: SmartAccount;
|
|
67
63
|
userOperation?: UserOperationRequest;
|
|
68
64
|
}): Promise<{
|
|
69
65
|
maxFeePerGas: bigint;
|
|
70
66
|
maxPriorityFeePerGas: bigint;
|
|
71
67
|
}> {
|
|
68
|
+
// Cast to RundlerClient to access rundler-specific RPC methods and BundlerClient properties.
|
|
69
|
+
// This mirrors viem's pattern in prepareUserOperation.ts where they cast `client as unknown as BundlerClient`
|
|
70
|
+
// to access bundler-specific properties from a base Client type.
|
|
71
|
+
// See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355
|
|
72
|
+
const rundlerClient = bundlerClient as RundlerClient;
|
|
73
|
+
|
|
72
74
|
const [block, maxPriorityFeePerGasHex] = await Promise.all([
|
|
73
75
|
// If the node rpc url is different from the bundler url, the public
|
|
74
76
|
// client should be passed in when creating the bundler client, which
|
|
75
77
|
// we can access here for public actions.
|
|
76
|
-
getBlock(
|
|
77
|
-
|
|
78
|
+
getBlock(rundlerClient.client ?? rundlerClient, { blockTag: "latest" }),
|
|
79
|
+
rundlerClient.request({
|
|
78
80
|
method: "rundler_maxPriorityFeePerGas",
|
|
79
81
|
params: [],
|
|
80
82
|
}),
|
package/src/version.ts
CHANGED