Skip to content

Commit

Permalink
Merge pull request #15 from vaariance/fix/default-gas-values
Browse files Browse the repository at this point in the history
fix: devault gas values and missing eth_call param.
  • Loading branch information
code-z2 authored Jan 15, 2024
2 parents 17ebfae + 6c0382e commit c9b9794
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 7 additions & 7 deletions lib/src/4337/userop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class UserOperation implements UserOperationBase {
/// - `sender`: The Ethereum address of the sender. Defaults to the smartwallet address.
/// - `nonce`: The nonce value. Defaults to [BigInt.zero].
/// - `initCode`: The initialization code as a [Uint8List]. Defaults to an empty [Uint8List].
/// - `callGasLimit`: The call gas limit as a [BigInt]. Defaults to [BigInt.from(10000000)].
/// - `verificationGasLimit`: The verification gas limit as a [BigInt]. Defaults to [BigInt.from(10000000)].
/// - `preVerificationGas`: The pre-verification gas as a [BigInt]. Defaults to [BigInt.from(21000)].
/// - `callGasLimit`: The call gas limit as a [BigInt]. Defaults to [BigInt.from(250000)].
/// - `verificationGasLimit`: The verification gas limit as a [BigInt]. Defaults to [BigInt.from(750000)].
/// - `preVerificationGas`: The pre-verification gas as a [BigInt]. Defaults to [BigInt.from(51000)].
/// - `maxFeePerGas`: The maximum fee per gas as a [BigInt]. Defaults to [BigInt.one].
/// - `maxPriorityFeePerGas`: The maximum priority fee per gas as a [BigInt]. Defaults to [BigInt.one].
///
Expand Down Expand Up @@ -106,9 +106,9 @@ class UserOperation implements UserOperationBase {
nonce: nonce ?? BigInt.zero,
initCode: initCode ?? Uint8List(0),
callData: callData,
callGasLimit: callGasLimit ?? BigInt.from(10000000),
verificationGasLimit: verificationGasLimit ?? BigInt.from(10000000),
preVerificationGas: preVerificationGas ?? BigInt.from(21000),
callGasLimit: callGasLimit ?? BigInt.from(250000),
verificationGasLimit: verificationGasLimit ?? BigInt.from(750000),
preVerificationGas: preVerificationGas ?? BigInt.from(51000),
maxFeePerGas: maxFeePerGas ?? BigInt.one,
maxPriorityFeePerGas: maxPriorityFeePerGas ?? BigInt.one,
signature: "0x",
Expand Down Expand Up @@ -148,7 +148,7 @@ class UserOperation implements UserOperationBase {
map['verificationGasLimit'] =
'0x${opGas.verificationGasLimit.toRadixString(16)}';
map['preVerificationGas'] =
'0x${(opGas.preVerificationGas + BigInt.from(35000)).toRadixString(16)}';
'0x${BigInt.from(opGas.preVerificationGas.toDouble() * 1.2).toRadixString(16)}';
}

if (sender != null) map['sender'] = sender.hex;
Expand Down
6 changes: 4 additions & 2 deletions lib/src/common/contract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ class Contract {
: "0x",
if (sender != null) 'from': sender.hex,
};
return _provider.send<String>('eth_call', [calldata]).then(
(value) => function.decodeReturnValues(value));
return _provider.send<String>('eth_call', [
calldata,
BlockNum.current().toBlockParam()
]).then((value) => function.decodeReturnValues(value));
}

/// Asynchronously checks whether a smart contract is deployed at the specified address.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ dev_dependencies:
topics:
- wallets
- ethereum
- "4337"
- web3
- account-abstraction

0 comments on commit c9b9794

Please sign in to comment.