@toruslabs/ethereum-controllers 7.1.1 → 7.1.3
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/ethereumControllers.cjs.js +27 -13
- package/dist/ethereumControllers.esm.js +28 -14
- package/dist/ethereumControllers.umd.min.js +1 -1
- package/dist/lib.cjs/AccountAbstraction/AccountAbstractionController.js +27 -13
- package/dist/lib.esm/AccountAbstraction/AccountAbstractionController.js +28 -14
- package/dist/types/utils/interfaces.d.ts +8 -0
- package/package.json +2 -2
|
@@ -11912,25 +11912,39 @@ class src_AccountAbstractionController extends src_base_controllers_namespaceObj
|
|
|
11912
11912
|
value: txParams.value ? BigInt(txParams.value) : undefined,
|
|
11913
11913
|
data: txParams.data
|
|
11914
11914
|
}];
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
11918
|
-
// if maxFeePerGas and maxPriorityFeePerGas are not provided, prepareUserOperation will estimate them
|
|
11919
|
-
const userOp = await this.bundlerClient.prepareUserOperation({
|
|
11920
|
-
account: this.smartAccount,
|
|
11921
|
-
calls
|
|
11922
|
-
});
|
|
11923
|
-
maxFeePerGas = userOp === null || userOp === void 0 ? void 0 : userOp.maxFeePerGas;
|
|
11924
|
-
maxPriorityFeePerGas = userOp === null || userOp === void 0 ? void 0 : userOp.maxPriorityFeePerGas;
|
|
11925
|
-
}
|
|
11915
|
+
const maxFeePerGas = txParams.maxFeePerGas ? BigInt(txParams.maxFeePerGas) : undefined;
|
|
11916
|
+
const maxPriorityFeePerGas = txParams.maxPriorityFeePerGas ? BigInt(txParams.maxPriorityFeePerGas) : undefined;
|
|
11926
11917
|
|
|
11927
|
-
// estimate gas: maxFeePerGas and maxPriorityFeePerGas are required
|
|
11918
|
+
// estimate gas: maxFeePerGas and maxPriorityFeePerGas are not required
|
|
11928
11919
|
const estimateGasParams = {
|
|
11929
11920
|
account: this.smartAccount,
|
|
11930
11921
|
calls,
|
|
11931
11922
|
maxFeePerGas,
|
|
11932
|
-
maxPriorityFeePerGas
|
|
11923
|
+
maxPriorityFeePerGas,
|
|
11924
|
+
stateOverride: [
|
|
11925
|
+
// override state to estimate gas for an ERC-20 transfer without causing a RPC error due to insufficient funds
|
|
11926
|
+
// ref: https://docs.cometh.io/connect-4337/bundler/bundler-api/eth_estimateuseroperationgas#optional-state-override-set
|
|
11927
|
+
{
|
|
11928
|
+
address: this.smartAccount.address,
|
|
11929
|
+
balance: (0,src_external_viem_namespaceObject.parseEther)("1")
|
|
11930
|
+
}]
|
|
11933
11931
|
};
|
|
11932
|
+
|
|
11933
|
+
// bundler only support factoryArgs for estimate user operation gas in entryPoint v0.7
|
|
11934
|
+
let factoryArgs;
|
|
11935
|
+
if (this.smartAccount.entryPoint.version !== "0.6") {
|
|
11936
|
+
factoryArgs = await this.smartAccount.getFactoryArgs(); // will return undefined if smart account already deployed
|
|
11937
|
+
}
|
|
11938
|
+
if (factoryArgs) {
|
|
11939
|
+
// using object spread here will cause type error because of viem's excessively deep types
|
|
11940
|
+
// TODO: currently using single property assignment, check again when viem types are updated
|
|
11941
|
+
if (factoryArgs.factory) {
|
|
11942
|
+
estimateGasParams.factory = factoryArgs.factory;
|
|
11943
|
+
}
|
|
11944
|
+
if (factoryArgs.factoryData) {
|
|
11945
|
+
estimateGasParams.factoryData = factoryArgs.factoryData;
|
|
11946
|
+
}
|
|
11947
|
+
}
|
|
11934
11948
|
const result = await this.bundlerClient.estimateUserOperationGas(estimateGasParams);
|
|
11935
11949
|
const gasData = {
|
|
11936
11950
|
callGasLimit: (0,src_external_viem_namespaceObject.toHex)(result.callGasLimit),
|
|
@@ -6,7 +6,7 @@ import { BrowserProvider, toQuantity, Contract, isHexString, SigningKey, hashMes
|
|
|
6
6
|
import log from 'loglevel';
|
|
7
7
|
import { addHexPrefix, stripHexPrefix, isHexString as isHexString$1, bytesToHex, privateToPublic, toChecksumAddress, privateToAddress, ecsign, bigIntToBytes, isValidAddress } from '@ethereumjs/util';
|
|
8
8
|
import { JRPCEngine, providerFromEngine, createAsyncMiddleware, mergeMiddleware, createScaffoldMiddleware, providerFromMiddleware, rpcErrors, SafeEventEmitter, providerErrors } from '@web3auth/auth';
|
|
9
|
-
import { defineChain, createPublicClient, http, createWalletClient, toHex } from 'viem';
|
|
9
|
+
import { defineChain, createPublicClient, http, createWalletClient, parseEther, toHex } from 'viem';
|
|
10
10
|
import { createPaymasterClient, createBundlerClient, entryPoint06Address, entryPoint07Address } from 'viem/account-abstraction';
|
|
11
11
|
import { get } from '@toruslabs/http-helpers';
|
|
12
12
|
import BigNumber from 'bignumber.js';
|
|
@@ -1177,25 +1177,39 @@ class AccountAbstractionController extends BaseController {
|
|
|
1177
1177
|
value: txParams.value ? BigInt(txParams.value) : undefined,
|
|
1178
1178
|
data: txParams.data
|
|
1179
1179
|
}];
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if (!maxFeePerGas || !maxPriorityFeePerGas) {
|
|
1183
|
-
// if maxFeePerGas and maxPriorityFeePerGas are not provided, prepareUserOperation will estimate them
|
|
1184
|
-
const userOp = await this.bundlerClient.prepareUserOperation({
|
|
1185
|
-
account: this.smartAccount,
|
|
1186
|
-
calls
|
|
1187
|
-
});
|
|
1188
|
-
maxFeePerGas = userOp === null || userOp === void 0 ? void 0 : userOp.maxFeePerGas;
|
|
1189
|
-
maxPriorityFeePerGas = userOp === null || userOp === void 0 ? void 0 : userOp.maxPriorityFeePerGas;
|
|
1190
|
-
}
|
|
1180
|
+
const maxFeePerGas = txParams.maxFeePerGas ? BigInt(txParams.maxFeePerGas) : undefined;
|
|
1181
|
+
const maxPriorityFeePerGas = txParams.maxPriorityFeePerGas ? BigInt(txParams.maxPriorityFeePerGas) : undefined;
|
|
1191
1182
|
|
|
1192
|
-
// estimate gas: maxFeePerGas and maxPriorityFeePerGas are required
|
|
1183
|
+
// estimate gas: maxFeePerGas and maxPriorityFeePerGas are not required
|
|
1193
1184
|
const estimateGasParams = {
|
|
1194
1185
|
account: this.smartAccount,
|
|
1195
1186
|
calls,
|
|
1196
1187
|
maxFeePerGas,
|
|
1197
|
-
maxPriorityFeePerGas
|
|
1188
|
+
maxPriorityFeePerGas,
|
|
1189
|
+
stateOverride: [
|
|
1190
|
+
// override state to estimate gas for an ERC-20 transfer without causing a RPC error due to insufficient funds
|
|
1191
|
+
// ref: https://docs.cometh.io/connect-4337/bundler/bundler-api/eth_estimateuseroperationgas#optional-state-override-set
|
|
1192
|
+
{
|
|
1193
|
+
address: this.smartAccount.address,
|
|
1194
|
+
balance: parseEther("1")
|
|
1195
|
+
}]
|
|
1198
1196
|
};
|
|
1197
|
+
|
|
1198
|
+
// bundler only support factoryArgs for estimate user operation gas in entryPoint v0.7
|
|
1199
|
+
let factoryArgs;
|
|
1200
|
+
if (this.smartAccount.entryPoint.version !== "0.6") {
|
|
1201
|
+
factoryArgs = await this.smartAccount.getFactoryArgs(); // will return undefined if smart account already deployed
|
|
1202
|
+
}
|
|
1203
|
+
if (factoryArgs) {
|
|
1204
|
+
// using object spread here will cause type error because of viem's excessively deep types
|
|
1205
|
+
// TODO: currently using single property assignment, check again when viem types are updated
|
|
1206
|
+
if (factoryArgs.factory) {
|
|
1207
|
+
estimateGasParams.factory = factoryArgs.factory;
|
|
1208
|
+
}
|
|
1209
|
+
if (factoryArgs.factoryData) {
|
|
1210
|
+
estimateGasParams.factoryData = factoryArgs.factoryData;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1199
1213
|
const result = await this.bundlerClient.estimateUserOperationGas(estimateGasParams);
|
|
1200
1214
|
const gasData = {
|
|
1201
1215
|
callGasLimit: toHex(result.callGasLimit),
|