@alchemy/aa-infra 0.0.0-alpha.15 → 0.0.0-alpha.16
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 +4 -4
- package/dist/esm/estimateFeesPerGas.js +1 -1
- 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 +4 -4
- package/dist/types/estimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/estimateFeesPerGas.ts +12 -4
- package/src/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Client, type Transport, type Chain } from "viem";
|
|
1
|
+
import { type Client, type Transport, type Chain, type Account } from "viem";
|
|
2
2
|
import type { UserOperationRequest, SmartAccount, BundlerClient } from "viem/account-abstraction";
|
|
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>;
|
|
@@ -17,7 +17,7 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { createBundlerClient } from "viem/account-abstraction";
|
|
20
|
-
* import { alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
20
|
+
* import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
21
21
|
*
|
|
22
22
|
* const bundler = createBundlerClient({
|
|
23
23
|
* transport: http("<rundler-url>"),
|
|
@@ -27,8 +27,8 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function estimateFeesPerGas({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
-
bundlerClient: Client
|
|
30
|
+
export declare function estimateFeesPerGas<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | Account | undefined = SmartAccount | Account | undefined>({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
+
bundlerClient: Client<TTransport, TChain, TAccount>;
|
|
32
32
|
account?: SmartAccount;
|
|
33
33
|
userOperation?: UserOperationRequest;
|
|
34
34
|
}): Promise<{
|
|
@@ -17,7 +17,7 @@ import { InvalidHexValueError } from "./errors.js";
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { createBundlerClient } from "viem/account-abstraction";
|
|
20
|
-
* import { alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
20
|
+
* import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
21
21
|
*
|
|
22
22
|
* const bundler = createBundlerClient({
|
|
23
23
|
* transport: http("<rundler-url>"),
|
|
@@ -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,
|
|
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,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,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,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 type Account,\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 { 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 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.15";
|
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.15\";\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Client, type Transport, type Chain } from "viem";
|
|
1
|
+
import { type Client, type Transport, type Chain, type Account } from "viem";
|
|
2
2
|
import type { UserOperationRequest, SmartAccount, BundlerClient } from "viem/account-abstraction";
|
|
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>;
|
|
@@ -17,7 +17,7 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { createBundlerClient } from "viem/account-abstraction";
|
|
20
|
-
* import { alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
20
|
+
* import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
21
21
|
*
|
|
22
22
|
* const bundler = createBundlerClient({
|
|
23
23
|
* transport: http("<rundler-url>"),
|
|
@@ -27,8 +27,8 @@ export type RundlerClient<transport extends Transport = Transport, chain extends
|
|
|
27
27
|
* });
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
|
-
export declare function estimateFeesPerGas({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
-
bundlerClient: Client
|
|
30
|
+
export declare function estimateFeesPerGas<TTransport extends Transport = Transport, TChain extends Chain | undefined = Chain | undefined, TAccount extends SmartAccount | Account | undefined = SmartAccount | Account | undefined>({ bundlerClient, account: _account, userOperation: _userOperation, }: {
|
|
31
|
+
bundlerClient: Client<TTransport, TChain, TAccount>;
|
|
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,
|
|
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,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.15";
|
|
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.16",
|
|
4
4
|
"description": "Alchemy Account Abstraction Infrastructure",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"typescript-template": "*"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@alchemy/common": "^0.0.0-alpha.
|
|
47
|
-
"viem": "^2.
|
|
46
|
+
"@alchemy/common": "^0.0.0-alpha.16",
|
|
47
|
+
"viem": "^2.44.2"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public",
|
|
@@ -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": "299dbbeffbba1ee90b8cc4f5f0931cad3645add0"
|
|
62
62
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type Transport,
|
|
6
6
|
type Chain,
|
|
7
7
|
hexToBigInt,
|
|
8
|
+
type Account,
|
|
8
9
|
} from "viem";
|
|
9
10
|
import type {
|
|
10
11
|
UserOperationRequest,
|
|
@@ -43,7 +44,7 @@ export type RundlerClient<
|
|
|
43
44
|
* @example
|
|
44
45
|
* ```ts
|
|
45
46
|
* import { createBundlerClient } from "viem/account-abstraction";
|
|
46
|
-
* import { alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
47
|
+
* import { estimateFeesPerGas as alchemyEstimateFeesPerGas } from "@alchemy/aa-infra";
|
|
47
48
|
*
|
|
48
49
|
* const bundler = createBundlerClient({
|
|
49
50
|
* transport: http("<rundler-url>"),
|
|
@@ -53,12 +54,19 @@ export type RundlerClient<
|
|
|
53
54
|
* });
|
|
54
55
|
* ```
|
|
55
56
|
*/
|
|
56
|
-
export async function estimateFeesPerGas
|
|
57
|
+
export async function estimateFeesPerGas<
|
|
58
|
+
TTransport extends Transport = Transport,
|
|
59
|
+
TChain extends Chain | undefined = Chain | undefined,
|
|
60
|
+
TAccount extends SmartAccount | Account | undefined =
|
|
61
|
+
| SmartAccount
|
|
62
|
+
| Account
|
|
63
|
+
| undefined,
|
|
64
|
+
>({
|
|
57
65
|
bundlerClient,
|
|
58
66
|
account: _account,
|
|
59
67
|
userOperation: _userOperation,
|
|
60
68
|
}: {
|
|
61
|
-
bundlerClient: Client
|
|
69
|
+
bundlerClient: Client<TTransport, TChain, TAccount>;
|
|
62
70
|
account?: SmartAccount;
|
|
63
71
|
userOperation?: UserOperationRequest;
|
|
64
72
|
}): Promise<{
|
|
@@ -69,7 +77,7 @@ export async function estimateFeesPerGas({
|
|
|
69
77
|
// This mirrors viem's pattern in prepareUserOperation.ts where they cast `client as unknown as BundlerClient`
|
|
70
78
|
// to access bundler-specific properties from a base Client type.
|
|
71
79
|
// See: https://github.com/wevm/viem/blob/d18b3b27/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L355
|
|
72
|
-
const rundlerClient = bundlerClient as RundlerClient;
|
|
80
|
+
const rundlerClient = bundlerClient as unknown as RundlerClient;
|
|
73
81
|
|
|
74
82
|
const [block, maxPriorityFeePerGasHex] = await Promise.all([
|
|
75
83
|
// If the node rpc url is different from the bundler url, the public
|
package/src/version.ts
CHANGED