@account-kit/infra 4.13.1-alpha.0 → 4.15.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.
- package/dist/esm/actions/types.d.ts +14 -2
- package/dist/esm/actions/types.js.map +1 -1
- package/dist/esm/alchemyTransport.js +1 -0
- package/dist/esm/alchemyTransport.js.map +1 -1
- package/dist/esm/chains.d.ts +1 -0
- package/dist/esm/chains.js +17 -0
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/client/smartAccountClient.d.ts +1 -1
- package/dist/esm/client/smartAccountClient.js +11 -4
- package/dist/esm/client/smartAccountClient.js.map +1 -1
- package/dist/esm/client/types.d.ts +11 -2
- package/dist/esm/client/types.js.map +1 -1
- package/dist/esm/gas-manager.d.ts +2 -0
- package/dist/esm/gas-manager.js +2 -0
- package/dist/esm/gas-manager.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/middleware/gasManager.d.ts +43 -4
- package/dist/esm/middleware/gasManager.js +137 -3
- package/dist/esm/middleware/gasManager.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/actions/types.d.ts +14 -2
- package/dist/types/actions/types.d.ts.map +1 -1
- package/dist/types/alchemyTransport.d.ts.map +1 -1
- package/dist/types/chains.d.ts +1 -0
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/client/smartAccountClient.d.ts +1 -1
- package/dist/types/client/smartAccountClient.d.ts.map +1 -1
- package/dist/types/client/types.d.ts +11 -2
- package/dist/types/client/types.d.ts.map +1 -1
- package/dist/types/gas-manager.d.ts +2 -0
- package/dist/types/gas-manager.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/middleware/gasManager.d.ts +43 -4
- package/dist/types/middleware/gasManager.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/version.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/actions/types.ts +41 -2
- package/src/alchemyTransport.ts +1 -0
- package/src/chains.ts +18 -0
- package/src/client/smartAccountClient.ts +12 -5
- package/src/client/types.ts +13 -1
- package/src/gas-manager.ts +2 -0
- package/src/index.ts +5 -1
- package/src/middleware/gasManager.ts +234 -6
- package/src/version.ts +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { erc7677Middleware } from "@aa-sdk/core";
|
|
1
|
+
import { bypassPaymasterAndData, ChainNotFoundError, deepHexlify, defaultGasEstimator, erc7677Middleware, filterUndefined, isBigNumberish, isMultiplier, noopMiddleware, resolveProperties, } from "@aa-sdk/core";
|
|
2
|
+
import { fromHex, isHex } from "viem";
|
|
3
|
+
import { alchemyFeeEstimator } from "./feeEstimator.js";
|
|
2
4
|
/**
|
|
3
|
-
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
5
|
+
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
6
|
+
* transactions. Adheres to the ERC-7677 standardized communication protocol.
|
|
4
7
|
*
|
|
5
8
|
* @example
|
|
6
9
|
* ```ts
|
|
@@ -14,7 +17,7 @@ import { erc7677Middleware } from "@aa-sdk/core";
|
|
|
14
17
|
* });
|
|
15
18
|
* ```
|
|
16
19
|
*
|
|
17
|
-
* @param {string} policyId the policyId for Alchemy's gas manager
|
|
20
|
+
* @param {string | string[]} policyId the policyId (or list of policyIds) for Alchemy's gas manager
|
|
18
21
|
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
|
|
19
22
|
*/
|
|
20
23
|
export function alchemyGasManagerMiddleware(policyId) {
|
|
@@ -22,4 +25,135 @@ export function alchemyGasManagerMiddleware(policyId) {
|
|
|
22
25
|
context: { policyId: policyId },
|
|
23
26
|
});
|
|
24
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
30
|
+
* transactions. Uses Alchemy's custom `alchemy_requestGasAndPaymasterAndData`
|
|
31
|
+
* method instead of conforming to the standard ERC-7677 interface. Note that
|
|
32
|
+
* if you use `createAlchemySmartAccountClient`, this middleware is already
|
|
33
|
+
* used by default and you do not need to manually include it.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts twoslash
|
|
37
|
+
* import { sepolia, alchemy, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
|
|
38
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
39
|
+
*
|
|
40
|
+
* const client = createSmartAccountClient({
|
|
41
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
42
|
+
* chain: sepolia,
|
|
43
|
+
* ...alchemyGasAndPaymasterAndDataMiddleware({
|
|
44
|
+
* policyId: "policyId",
|
|
45
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
46
|
+
* })
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams} params configuration params
|
|
51
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.policyId} params.policyId the policyId for Alchemy's gas manager
|
|
52
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.transport} params.transport fallback transport to use for fee estimation when not using the paymaster
|
|
53
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.gasEstimatorOverride} params.gasEstimatorOverride custom gas estimator middleware
|
|
54
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.feeEstimatorOverride} params.feeEstimatorOverride custom fee estimator middleware
|
|
55
|
+
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
|
|
56
|
+
*/
|
|
57
|
+
export function alchemyGasAndPaymasterAndDataMiddleware(params) {
|
|
58
|
+
const { policyId, transport, gasEstimatorOverride, feeEstimatorOverride } = params;
|
|
59
|
+
return {
|
|
60
|
+
dummyPaymasterAndData: async (uo, args) => {
|
|
61
|
+
if (
|
|
62
|
+
// No reason to generate dummy data if we are bypassing the paymaster.
|
|
63
|
+
bypassPaymasterAndData(args.overrides) ||
|
|
64
|
+
// When using alchemy_requestGasAndPaymasterAndData, there is generally no reason to generate dummy
|
|
65
|
+
// data. However, if the gas/feeEstimator is overriden, then this option should be enabled.
|
|
66
|
+
!(gasEstimatorOverride || feeEstimatorOverride)) {
|
|
67
|
+
return noopMiddleware(uo, args);
|
|
68
|
+
}
|
|
69
|
+
// Fall back to the default 7677 dummyPaymasterAndData middleware.
|
|
70
|
+
return alchemyGasManagerMiddleware(policyId).dummyPaymasterAndData(uo, args);
|
|
71
|
+
},
|
|
72
|
+
feeEstimator: (uo, args) => {
|
|
73
|
+
return feeEstimatorOverride
|
|
74
|
+
? feeEstimatorOverride(uo, args)
|
|
75
|
+
: bypassPaymasterAndData(args.overrides)
|
|
76
|
+
? alchemyFeeEstimator(transport)(uo, args)
|
|
77
|
+
: noopMiddleware(uo, args);
|
|
78
|
+
},
|
|
79
|
+
gasEstimator: (uo, args) => {
|
|
80
|
+
return gasEstimatorOverride
|
|
81
|
+
? gasEstimatorOverride(uo, args)
|
|
82
|
+
: bypassPaymasterAndData(args.overrides)
|
|
83
|
+
? defaultGasEstimator(args.client)(uo, args)
|
|
84
|
+
: noopMiddleware(uo, args);
|
|
85
|
+
},
|
|
86
|
+
paymasterAndData: async (uo, { account, client, feeOptions, overrides: overrides_ }) => {
|
|
87
|
+
if (!client.chain) {
|
|
88
|
+
throw new ChainNotFoundError();
|
|
89
|
+
}
|
|
90
|
+
const userOp = deepHexlify(await resolveProperties(uo));
|
|
91
|
+
const overrides = filterUndefined({
|
|
92
|
+
maxFeePerGas: overrideField("maxFeePerGas", overrides_, feeOptions, userOp),
|
|
93
|
+
maxPriorityFeePerGas: overrideField("maxPriorityFeePerGas", overrides_, feeOptions, userOp),
|
|
94
|
+
callGasLimit: overrideField("callGasLimit", overrides_, feeOptions, userOp),
|
|
95
|
+
verificationGasLimit: overrideField("verificationGasLimit", overrides_, feeOptions, userOp),
|
|
96
|
+
preVerificationGas: overrideField("preVerificationGas", overrides_, feeOptions, userOp),
|
|
97
|
+
...(account.getEntryPoint().version === "0.7.0"
|
|
98
|
+
? {
|
|
99
|
+
paymasterVerificationGasLimit: overrideField("paymasterVerificationGasLimit", overrides_, feeOptions, userOp),
|
|
100
|
+
paymasterPostOpGasLimit: overrideField("paymasterPostOpGasLimit", overrides_, feeOptions, userOp),
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
103
|
+
});
|
|
104
|
+
const result = await client.request({
|
|
105
|
+
method: "alchemy_requestGasAndPaymasterAndData",
|
|
106
|
+
params: [
|
|
107
|
+
{
|
|
108
|
+
policyId,
|
|
109
|
+
entryPoint: account.getEntryPoint().address,
|
|
110
|
+
userOperation: userOp,
|
|
111
|
+
dummySignature: await account.getDummySignature(),
|
|
112
|
+
overrides,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
...uo,
|
|
118
|
+
...result,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Utility function to override a field in the user operation request with the overrides or fee options
|
|
125
|
+
*
|
|
126
|
+
* @template {EntryPointVersion} TEntryPointVersion
|
|
127
|
+
* @param {keyof UserOperationFeeOptions<TEntryPointVersion>} field the field to override
|
|
128
|
+
* @param {UserOperationOverrides<TEntryPointVersion> | undefined} overrides the overrides object
|
|
129
|
+
* @param {UserOperationFeeOptions<TEntryPointVersion> | undefined} feeOptions the fee options object from the client
|
|
130
|
+
* @param {UserOperationRequest<TEntryPointVersion>} userOperation the user operation request
|
|
131
|
+
* @returns {Hex | Multiplier | undefined} the overridden field value
|
|
132
|
+
*/
|
|
133
|
+
const overrideField = (field, overrides, feeOptions, userOperation) => {
|
|
134
|
+
let _field = field;
|
|
135
|
+
if (overrides?.[_field] != null) {
|
|
136
|
+
// one-off absolute override
|
|
137
|
+
if (isBigNumberish(overrides[_field])) {
|
|
138
|
+
return deepHexlify(overrides[_field]);
|
|
139
|
+
}
|
|
140
|
+
// one-off multiplier overrides
|
|
141
|
+
else {
|
|
142
|
+
return {
|
|
143
|
+
multiplier: Number(overrides[_field].multiplier),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// provider level fee options with multiplier
|
|
148
|
+
if (isMultiplier(feeOptions?.[field])) {
|
|
149
|
+
return {
|
|
150
|
+
multiplier: Number(feeOptions[field].multiplier),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const userOpField = userOperation[field];
|
|
154
|
+
if (isHex(userOpField) && fromHex(userOpField, "bigint") > 0n) {
|
|
155
|
+
return userOpField;
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
};
|
|
25
159
|
//# sourceMappingURL=gasManager.js.map
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"version":3,"file":"gasManager.js","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAY,MAAM,MAAM,CAAC;AAGhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAA2B;IAE3B,OAAO,iBAAiB,CAAkC;QACxD,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;KAChC,CAAC,CAAC;AACL,CAAC;AASD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,uCAAuC,CACrD,MAAqD;IAKrD,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,GACvE,MAAM,CAAC;IACT,OAAO;QACL,qBAAqB,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;YACxC;YACE,sEAAsE;YACtE,sBAAsB,C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,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 ClientMiddlewareFn,\n EntryPointVersion,\n Multiplier,\n UserOperationFeeOptions,\n UserOperationOverrides,\n UserOperationRequest,\n} from \"@aa-sdk/core\";\nimport {\n bypassPaymasterAndData,\n ChainNotFoundError,\n deepHexlify,\n defaultGasEstimator,\n erc7677Middleware,\n filterUndefined,\n isBigNumberish,\n isMultiplier,\n noopMiddleware,\n resolveProperties,\n} from \"@aa-sdk/core\";\nimport { fromHex, isHex, type Hex } from \"viem\";\nimport type { AlchemySmartAccountClient } from \"../client/smartAccountClient.js\";\nimport type { AlchemyTransport } from \"../alchemyTransport.js\";\nimport { alchemyFeeEstimator } from \"./feeEstimator.js\";\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring\n * transactions. Adheres to the ERC-7677 standardized communication protocol.\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 | string[]} policyId the policyId (or list of policyIds) 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 | string[]\n): Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\"> {\n return erc7677Middleware<{ policyId: string | string[] }>({\n context: { policyId: policyId },\n });\n}\n\ninterface AlchemyGasAndPaymasterAndDataMiddlewareParams {\n policyId: string | string[];\n transport: AlchemyTransport;\n gasEstimatorOverride?: ClientMiddlewareFn;\n feeEstimatorOverride?: ClientMiddlewareFn;\n}\n\n/**\n * Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring\n * transactions. Uses Alchemy's custom `alchemy_requestGasAndPaymasterAndData`\n * method instead of conforming to the standard ERC-7677 interface. Note that\n * if you use `createAlchemySmartAccountClient`, this middleware is already\n * used by default and you do not need to manually include it.\n *\n * @example\n * ```ts twoslash\n * import { sepolia, alchemy, alchemyGasAndPaymasterAndDataMiddleware } from \"@account-kit/infra\";\n * import { createSmartAccountClient } from \"@aa-sdk/core\";\n *\n * const client = createSmartAccountClient({\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * chain: sepolia,\n * ...alchemyGasAndPaymasterAndDataMiddleware({\n * policyId: \"policyId\",\n * transport: alchemy({ apiKey: \"your-api-key\" }),\n * })\n * });\n * ```\n *\n * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams} params configuration params\n * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.policyId} params.policyId the policyId for Alchemy's gas manager\n * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.transport} params.transport fallback transport to use for fee estimation when not using the paymaster\n * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.gasEstimatorOverride} params.gasEstimatorOverride custom gas estimator middleware\n * @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.feeEstimatorOverride} params.feeEstimatorOverride custom fee estimator middleware\n * @returns {Pick<ClientMiddlewareConfig, \"dummyPaymasterAndData\" | \"paymasterAndData\">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`\n */\nexport function alchemyGasAndPaymasterAndDataMiddleware(\n params: AlchemyGasAndPaymasterAndDataMiddlewareParams\n): Pick<\n ClientMiddlewareConfig,\n \"dummyPaymasterAndData\" | \"feeEstimator\" | \"gasEstimator\" | \"paymasterAndData\"\n> {\n const { policyId, transport, gasEstimatorOverride, feeEstimatorOverride } =\n params;\n return {\n dummyPaymasterAndData: async (uo, args) => {\n if (\n // No reason to generate dummy data if we are bypassing the paymaster.\n bypassPaymasterAndData(args.overrides) ||\n // When using alchemy_requestGasAndPaymasterAndData, there is generally no reason to generate dummy\n // data. However, if the gas/feeEstimator is overriden, then this option should be enabled.\n !(gasEstimatorOverride || feeEstimatorOverride)\n ) {\n return noopMiddleware(uo, args);\n }\n\n // Fall back to the default 7677 dummyPaymasterAndData middleware.\n return alchemyGasManagerMiddleware(policyId).dummyPaymasterAndData!(\n uo,\n args\n );\n },\n feeEstimator: (uo, args) => {\n return feeEstimatorOverride\n ? feeEstimatorOverride(uo, args)\n : bypassPaymasterAndData(args.overrides)\n ? alchemyFeeEstimator(transport)(uo, args)\n : noopMiddleware(uo, args);\n },\n gasEstimator: (uo, args) => {\n return gasEstimatorOverride\n ? gasEstimatorOverride(uo, args)\n : 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"]}
|
package/dist/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.15.0";
|
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,
|
|
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.15.0\";\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UserOperationStruct } from "@aa-sdk/core";
|
|
2
|
-
import type { Address, Hash } from "viem";
|
|
1
|
+
import type { UserOperationStruct, UserOperationRequest, UserOperationOverrides, EntryPointVersion } from "@aa-sdk/core";
|
|
2
|
+
import type { Address, Hash, Hex } from "viem";
|
|
3
3
|
export declare enum SimulateAssetType {
|
|
4
4
|
NATIVE = "NATIVE",
|
|
5
5
|
ERC20 = "ERC20",
|
|
@@ -41,4 +41,16 @@ export interface SimulateAssetChange {
|
|
|
41
41
|
name?: string;
|
|
42
42
|
logo?: string;
|
|
43
43
|
}
|
|
44
|
+
export type RequestGasAndPaymasterAndDataRequest = [
|
|
45
|
+
{
|
|
46
|
+
policyId: string | 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);
|
|
44
56
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAE/C,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB;;;OAGG;IACH,WAAW,gBAAgB;CAC5B;AAED,oBAAY,kBAAkB;IAC5B,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,mBAAmB;IACnB,UAAU,EAAE,OAAO;IACnB,WAAW,CAAC,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,MAAM,yCAAyC,GAAG;IACtD,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,yBAAyB,CAAC;CACnC,CAAC;AAEF,MAAM,WAAW,yBAA0B,SAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACpE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC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EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;CACvD,EACD,gBAAgB,CAAC,CAAC,GAAG,eAAe,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAC5D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAAG;IACpD,aAAa,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7C,MAAM,EAAE,sBAAsB,CAAC;CAChC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,GACX,SAAS,IAAI,gBAAgB,CAE/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,sBAAsB,GAAG,gBAAgB,CA+ExE"}
|
package/dist/types/chains.d.ts
CHANGED
|
@@ -59,5 +59,6 @@ export declare const beraChainBartio: Chain;
|
|
|
59
59
|
export declare const inkMainnet: Chain;
|
|
60
60
|
export declare const inkSepolia: Chain;
|
|
61
61
|
export declare const arbitrumNova: Chain;
|
|
62
|
+
export declare const monadTestnet: Chain;
|
|
62
63
|
export declare const mekong: Chain;
|
|
63
64
|
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAyBlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB;WAItB,KAAK;gBACA,MAAM;MAChB,KAUH,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAQ5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EAAE,KAS3B,CAAC;AAEH,eAAO,MAAM,IAAI,EAAE,KAKlB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAKzB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,KAgB9B,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,KAgBvB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,KAgBzB,CAAC;AAEH,eAAO,MAAM,KAAK,EAAE,KAgBlB,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,KAgB5B,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,KAgB5B,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,KAgB1B,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,KAgB3B,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,KAgBzB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,KAgBzB,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,KAgB5B,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,KAgBvB,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,KAgBvB,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAgBzB,CAAC;AAEH,eAAO,MAAM,MAAM,EAAE,KAgBnB,CAAC"}
|
|
@@ -9,7 +9,7 @@ export declare function getSignerTypeHeader<TAccount extends SmartContractAccoun
|
|
|
9
9
|
export type AlchemySmartAccountClientConfig<chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = {
|
|
10
10
|
account?: account;
|
|
11
11
|
useSimulation?: boolean;
|
|
12
|
-
policyId?: string;
|
|
12
|
+
policyId?: string | string[];
|
|
13
13
|
} & Pick<SmartAccountClientConfig<AlchemyTransport, chain, account, context>, "customMiddleware" | "feeEstimator" | "gasEstimator" | "signUserOperation" | "transport" | "chain" | "opts">;
|
|
14
14
|
export type BaseAlchemyActions<chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, context extends UserOperationContext | undefined = UserOperationContext | undefined> = SmartAccountClientActions<chain, account, context> & AlchemySmartAccountClientActions<account, context>;
|
|
15
15
|
export type AlchemySmartAccountClient_Base<chain extends Chain | undefined = Chain | undefined, account extends SmartContractAccount | undefined = SmartContractAccount | undefined, actions extends Record<string, unknown> = Record<string, unknown>, context extends UserOperationContext | undefined = UserOperationContext | undefined> = Prettify<SmartAccountClient<AlchemyTransport, chain, account, actions & BaseAlchemyActions<chain, account, context>, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartAccountClient.d.ts","sourceRoot":"","sources":["../../../src/client/smartAccountClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,QAAQ,SAAS,8BAA8B,EAC/C,OAAO,EAAE,QAAQ;;EAElB;AAGD,MAAM,MAAM,+BAA+B,CACzC,KAAK,SAAS,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,SAAS,EACnD,OAAO,SAAS,oBAAoB,GAAG,SAAS,GAC5C,oBAAoB,GACpB,SAAS,EACb,OAAO,SAAS,oBAAoB,GAAG,SAAS,GAC5C,oBAAoB,GACpB,SAAS,IACX;IAC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AE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAE/E,wBAAgB,+BAA+B,CAC7C,MAAM,SAAS,KAAK,GAAG,KAAK,EAC5B,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EACb,QAAQ,SAAS,oBAAoB,GAAG,SAAS,GAC7C,oBAAoB,GACpB,SAAS,EAEb,MAAM,EAAE,+BAA+B,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAClE,yBAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BundlerClient, type Erc7677RpcSchema, type UserOperationRequest } from "@aa-sdk/core";
|
|
2
|
-
import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse } from "../actions/types";
|
|
2
|
+
import type { SimulateUserOperationAssetChangesRequest, SimulateUserOperationAssetChangesResponse, RequestGasAndPaymasterAndDataRequest, RequestGasAndPaymasterAndDataResponse } from "../actions/types";
|
|
3
3
|
import type { AlchemyTransport } from "../alchemyTransport";
|
|
4
4
|
export type AlchemyRpcSchema = [
|
|
5
5
|
{
|
|
@@ -14,7 +14,12 @@ export type AlchemyRpcSchema = [
|
|
|
14
14
|
},
|
|
15
15
|
...Erc7677RpcSchema<{
|
|
16
16
|
policyId: string;
|
|
17
|
-
}
|
|
17
|
+
}>,
|
|
18
|
+
{
|
|
19
|
+
Method: "alchemy_requestGasAndPaymasterAndData";
|
|
20
|
+
Parameters: RequestGasAndPaymasterAndDataRequest;
|
|
21
|
+
ReturnType: RequestGasAndPaymasterAndDataResponse;
|
|
22
|
+
}
|
|
18
23
|
];
|
|
19
24
|
export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
|
|
20
25
|
request: BundlerClient<AlchemyTransport>["request"] & {
|
|
@@ -26,6 +31,10 @@ export type ClientWithAlchemyMethods = BundlerClient<AlchemyTransport> & {
|
|
|
26
31
|
method: "rundler_maxPriorityFeePerGas";
|
|
27
32
|
params: [];
|
|
28
33
|
}): Promise<UserOperationRequest["maxPriorityFeePerGas"]>;
|
|
34
|
+
request(args: {
|
|
35
|
+
method: "alchemy_requestGasAndPaymasterAndData";
|
|
36
|
+
params: RequestGasAndPaymasterAndDataRequest;
|
|
37
|
+
}): Promise<RequestGasAndPaymasterAndDataResponse>;
|
|
29
38
|
}["request"];
|
|
30
39
|
};
|
|
31
40
|
//# 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;AACtB,OAAO,KAAK,EACV,wCAAwC,EACxC,yCAAyC,
|
|
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,EACzC,oCAAoC,EACpC,qCAAqC,EACtC,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;IACzC;QACE,MAAM,EAAE,uCAAuC,CAAC;QAChD,UAAU,EAAE,oCAAoC,CAAC;QACjD,UAAU,EAAE,qCAAqC,CAAC;KACnD;CACF,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;QAE1D,OAAO,CAAC,IAAI,EAAE;YACZ,MAAM,EAAE,uCAAuC,CAAC;YAChD,MAAM,EAAE,oCAAoC,CAAC;SAC9C,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;KACpD,CAAC,SAAS,CAAC,CAAC;CAChB,CAAC"}
|
|
@@ -15,6 +15,8 @@ export declare const AlchemyPaymasterAddressV1 = "0xc03aac639bb21233e01393819703
|
|
|
15
15
|
*
|
|
16
16
|
* @param {Chain} chain The chain for which the paymaster address is required
|
|
17
17
|
* @returns {Address} The Alchemy paymaster address corresponding to the specified chain
|
|
18
|
+
*
|
|
19
|
+
* @deprecated This chain list in this function is no longer maintained since the ERC-7677 middleware is typically used to resolve the paymaster address
|
|
18
20
|
*/
|
|
19
21
|
export declare const getAlchemyPaymasterAddress: (chain: Chain) => Address;
|
|
20
22
|
//# sourceMappingURL=gas-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-manager.d.ts","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAmB3C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,0BAA0B,+CACO,CAAC;AAC/C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"gas-manager.d.ts","sourceRoot":"","sources":["../../src/gas-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAmB3C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAC/C,eAAO,MAAM,0BAA0B,+CACO,CAAC;AAC/C,eAAO,MAAM,yBAAyB,+CACQ,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,UAAW,KAAK,KAAG,OAwBzD,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type * from "./actions/types.js";
|
|
|
4
4
|
export type * from "./alchemyTransport.js";
|
|
5
5
|
export { alchemy, isAlchemyTransport } from "./alchemyTransport.js";
|
|
6
6
|
export type * from "./chains.js";
|
|
7
|
-
export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, beraChainBartio, opbnbMainnet, opbnbTestnet, soneiumMinato, soneiumMainnet, unichainMainnet, unichainSepolia, inkMainnet, inkSepolia, mekong, } from "./chains.js";
|
|
7
|
+
export { arbitrum, arbitrumGoerli, arbitrumNova, arbitrumSepolia, base, baseGoerli, baseSepolia, defineAlchemyChain, fraxtal, fraxtalSepolia, goerli, mainnet, optimism, optimismGoerli, optimismSepolia, polygon, polygonAmoy, polygonMumbai, sepolia, shape, shapeSepolia, worldChain, worldChainSepolia, zora, zoraSepolia, beraChainBartio, opbnbMainnet, opbnbTestnet, soneiumMinato, soneiumMainnet, unichainMainnet, unichainSepolia, inkMainnet, inkSepolia, mekong, monadTestnet, } from "./chains.js";
|
|
8
8
|
export type * from "./client/decorators/alchemyEnhancedApis.js";
|
|
9
9
|
export { alchemyEnhancedApiActions } from "./client/decorators/alchemyEnhancedApis.js";
|
|
10
10
|
export type * from "./client/decorators/smartAccount.js";
|
|
@@ -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 } from "./middleware/gasManager.js";
|
|
22
|
+
export { alchemyGasManagerMiddleware, alchemyGasAndPaymasterAndDataMiddleware, } 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,
|
|
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,EACN,YAAY,GACb,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,EACL,2BAA2B,EAC3B,uCAAuC,GACxC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,mBAAmB,aAAa,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ClientMiddlewareConfig } from "@aa-sdk/core";
|
|
1
|
+
import type { ClientMiddlewareConfig, ClientMiddlewareFn } from "@aa-sdk/core";
|
|
2
|
+
import type { AlchemyTransport } from "../alchemyTransport.js";
|
|
2
3
|
/**
|
|
3
|
-
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
4
|
+
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
5
|
+
* transactions. Adheres to the ERC-7677 standardized communication protocol.
|
|
4
6
|
*
|
|
5
7
|
* @example
|
|
6
8
|
* ```ts
|
|
@@ -14,8 +16,45 @@ import type { ClientMiddlewareConfig } from "@aa-sdk/core";
|
|
|
14
16
|
* });
|
|
15
17
|
* ```
|
|
16
18
|
*
|
|
17
|
-
* @param {string} policyId the policyId for Alchemy's gas manager
|
|
19
|
+
* @param {string | string[]} policyId the policyId (or list of policyIds) for Alchemy's gas manager
|
|
18
20
|
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
|
|
19
21
|
*/
|
|
20
|
-
export declare function alchemyGasManagerMiddleware(policyId: string): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
|
|
22
|
+
export declare function alchemyGasManagerMiddleware(policyId: string | string[]): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">;
|
|
23
|
+
interface AlchemyGasAndPaymasterAndDataMiddlewareParams {
|
|
24
|
+
policyId: string | string[];
|
|
25
|
+
transport: AlchemyTransport;
|
|
26
|
+
gasEstimatorOverride?: ClientMiddlewareFn;
|
|
27
|
+
feeEstimatorOverride?: ClientMiddlewareFn;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Paymaster middleware factory that uses Alchemy's Gas Manager for sponsoring
|
|
31
|
+
* transactions. Uses Alchemy's custom `alchemy_requestGasAndPaymasterAndData`
|
|
32
|
+
* method instead of conforming to the standard ERC-7677 interface. Note that
|
|
33
|
+
* if you use `createAlchemySmartAccountClient`, this middleware is already
|
|
34
|
+
* used by default and you do not need to manually include it.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts twoslash
|
|
38
|
+
* import { sepolia, alchemy, alchemyGasAndPaymasterAndDataMiddleware } from "@account-kit/infra";
|
|
39
|
+
* import { createSmartAccountClient } from "@aa-sdk/core";
|
|
40
|
+
*
|
|
41
|
+
* const client = createSmartAccountClient({
|
|
42
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
43
|
+
* chain: sepolia,
|
|
44
|
+
* ...alchemyGasAndPaymasterAndDataMiddleware({
|
|
45
|
+
* policyId: "policyId",
|
|
46
|
+
* transport: alchemy({ apiKey: "your-api-key" }),
|
|
47
|
+
* })
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams} params configuration params
|
|
52
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.policyId} params.policyId the policyId for Alchemy's gas manager
|
|
53
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.transport} params.transport fallback transport to use for fee estimation when not using the paymaster
|
|
54
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.gasEstimatorOverride} params.gasEstimatorOverride custom gas estimator middleware
|
|
55
|
+
* @param {AlchemyGasAndPaymasterAndDataMiddlewareParams.feeEstimatorOverride} params.feeEstimatorOverride custom fee estimator middleware
|
|
56
|
+
* @returns {Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "paymasterAndData">} partial client middleware configuration containing `dummyPaymasterAndData` and `paymasterAndData`
|
|
57
|
+
*/
|
|
58
|
+
export declare function alchemyGasAndPaymasterAndDataMiddleware(params: AlchemyGasAndPaymasterAndDataMiddlewareParams): Pick<ClientMiddlewareConfig, "dummyPaymasterAndData" | "feeEstimator" | "gasEstimator" | "paymasterAndData">;
|
|
59
|
+
export {};
|
|
21
60
|
//# 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,
|
|
1
|
+
{"version":3,"file":"gasManager.d.ts","sourceRoot":"","sources":["../../../src/middleware/gasManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAMnB,MAAM,cAAc,CAAC;AAetB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAC1B,IAAI,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,kBAAkB,CAAC,CAI5E;AAED,UAAU,6CAA6C;IACrD,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;IAC1C,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,uCAAuC,CACrD,MAAM,EAAE,6CAA6C,GACpD,IAAI,CACL,sBAAsB,EACtB,uBAAuB,GAAG,cAAc,GAAG,cAAc,GAAG,kBAAkB,CAC/E,CAiHA"}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.15.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,
|
|
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.
|
|
3
|
+
"version": "4.15.0",
|
|
4
4
|
"description": "adapters for @aa-sdk/core for interacting with alchemy services",
|
|
5
5
|
"author": "Alchemy",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vitest": "^2.0.4"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@aa-sdk/core": "^4.
|
|
49
|
-
"@account-kit/logging": "^4.
|
|
48
|
+
"@aa-sdk/core": "^4.15.0",
|
|
49
|
+
"@account-kit/logging": "^4.15.0",
|
|
50
50
|
"eventemitter3": "^5.0.1",
|
|
51
51
|
"zod": "^3.22.4"
|
|
52
52
|
},
|
|
@@ -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": "
|
|
68
|
+
"gitHead": "9561e51d921c231e51e2f859b3f5c93f47b6ffd0",
|
|
69
69
|
"optionalDependencies": {
|
|
70
70
|
"alchemy-sdk": "^3.0.0"
|
|
71
71
|
}
|
package/src/actions/types.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
UserOperationStruct,
|
|
3
|
+
UserOperationRequest,
|
|
4
|
+
UserOperationOverrides,
|
|
5
|
+
EntryPointVersion,
|
|
6
|
+
} from "@aa-sdk/core";
|
|
7
|
+
import type { Address, Hash, Hex } from "viem";
|
|
3
8
|
|
|
4
9
|
export enum SimulateAssetType {
|
|
5
10
|
NATIVE = "NATIVE",
|
|
@@ -47,3 +52,37 @@ export interface SimulateAssetChange {
|
|
|
47
52
|
name?: string;
|
|
48
53
|
logo?: string;
|
|
49
54
|
}
|
|
55
|
+
|
|
56
|
+
export type RequestGasAndPaymasterAndDataRequest = [
|
|
57
|
+
{
|
|
58
|
+
policyId: string | 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);
|
package/src/alchemyTransport.ts
CHANGED
package/src/chains.ts
CHANGED
|
@@ -479,6 +479,24 @@ export const arbitrumNova: Chain = {
|
|
|
479
479
|
},
|
|
480
480
|
};
|
|
481
481
|
|
|
482
|
+
export const monadTestnet: Chain = defineChain({
|
|
483
|
+
id: 10143,
|
|
484
|
+
name: "Monad Testnet",
|
|
485
|
+
nativeCurrency: { name: "Monad", symbol: "MON", decimals: 18 },
|
|
486
|
+
rpcUrls: {
|
|
487
|
+
default: {
|
|
488
|
+
http: ["https://monad-testnet.g.alchemy.com/v2"],
|
|
489
|
+
},
|
|
490
|
+
public: {
|
|
491
|
+
http: ["https://monad-testnet.g.alchemy.com/v2"],
|
|
492
|
+
},
|
|
493
|
+
alchemy: {
|
|
494
|
+
http: ["https://monad-testnet.g.alchemy.com/v2"],
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
testnet: true,
|
|
498
|
+
});
|
|
499
|
+
|
|
482
500
|
export const mekong: Chain = defineChain({
|
|
483
501
|
id: 7078815900,
|
|
484
502
|
name: "Mekong Pectra Devnet",
|
|
@@ -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 {
|
|
18
|
+
import { alchemyGasAndPaymasterAndDataMiddleware } from "../middleware/gasManager.js";
|
|
19
19
|
import { alchemyUserOperationSimulator } from "../middleware/userOperationSimulator.js";
|
|
20
20
|
import {
|
|
21
21
|
alchemyActions,
|
|
@@ -41,7 +41,7 @@ export type AlchemySmartAccountClientConfig<
|
|
|
41
41
|
> = {
|
|
42
42
|
account?: account;
|
|
43
43
|
useSimulation?: boolean;
|
|
44
|
-
policyId?: string;
|
|
44
|
+
policyId?: string | string[];
|
|
45
45
|
} & Pick<
|
|
46
46
|
SmartAccountClientConfig<AlchemyTransport, chain, account, context>,
|
|
47
47
|
| "customMiddleware"
|
|
@@ -153,18 +153,25 @@ export function createAlchemySmartAccountClient({
|
|
|
153
153
|
...opts,
|
|
154
154
|
feeOptions,
|
|
155
155
|
},
|
|
156
|
+
feeEstimator: feeEstimator ?? alchemyFeeEstimator(transport),
|
|
157
|
+
gasEstimator,
|
|
156
158
|
customMiddleware: async (struct, args) => {
|
|
157
159
|
if (isSmartAccountWithSigner(args.account)) {
|
|
158
160
|
transport.updateHeaders(getSignerTypeHeader(args.account));
|
|
159
161
|
}
|
|
160
162
|
return customMiddleware ? customMiddleware(struct, args) : struct;
|
|
161
163
|
},
|
|
162
|
-
|
|
164
|
+
...(policyId
|
|
165
|
+
? alchemyGasAndPaymasterAndDataMiddleware({
|
|
166
|
+
policyId,
|
|
167
|
+
transport,
|
|
168
|
+
gasEstimatorOverride: gasEstimator,
|
|
169
|
+
feeEstimatorOverride: feeEstimator,
|
|
170
|
+
})
|
|
171
|
+
: {}),
|
|
163
172
|
userOperationSimulator: useSimulation
|
|
164
173
|
? alchemyUserOperationSimulator(transport)
|
|
165
174
|
: undefined,
|
|
166
|
-
gasEstimator,
|
|
167
|
-
...(policyId && alchemyGasManagerMiddleware(policyId)),
|
|
168
175
|
signUserOperation,
|
|
169
176
|
}).extend(alchemyActions);
|
|
170
177
|
|