Skip to content

Commit

Permalink
temp update: dev n tell
Browse files Browse the repository at this point in the history
  • Loading branch information
code-z2 committed Jan 5, 2024
1 parent 3e8f940 commit 0c00dbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
15 changes: 10 additions & 5 deletions lib/src/4337/userop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class UserOperation implements UserOperationBase {
@override
String paymasterAndData;

final dummySig =
"0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c";

Uint8List _hash;

UserOperation({
Expand Down Expand Up @@ -117,15 +120,17 @@ class UserOperation implements UserOperationBase {
);

factory UserOperation.update(
Map<String, dynamic> map,
UserOperationGas opGas, {
Map<String, dynamic> map, {
UserOperationGas? opGas,
EthereumAddress? sender,
BigInt? nonce,
String? initCode,
}) {
map['callGasLimit'] = opGas.callGasLimit;
map['verificationGasLimit'] = opGas.verificationGasLimit;
map['preVerificationGas'] = opGas.preVerificationGas;
map['callGasLimit'] = opGas?.callGasLimit ?? map['callGasLimit'];
map['verificationGasLimit'] =
opGas?.verificationGasLimit ?? map['verificationGasLimit'];
map['preVerificationGas'] =
opGas?.preVerificationGas ?? map['preVerificationGas'];

if (sender != null) map['sender'] = sender.hex;
if (nonce != null) map['nonce'] = '0x${nonce.toRadixString(16)}';
Expand Down
26 changes: 13 additions & 13 deletions lib/src/4337/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,21 @@ class SmartWallet with _PluginManager implements SmartWalletBase {
}

Future _updateUserOperation(UserOperation op) async {
final map = op.toMap();
List<dynamic> reponses = await Future.wait([
plugin<BundlerProviderBase>('bundler')
.estimateUserOperationGas(map, _chain.entrypoint),
plugin<RPCProviderBase>('ethRpc').getGasPrice(),
nonce,
deployed
]);
List<dynamic> reponses = await Future.wait(
[plugin<RPCProviderBase>('ethRpc').getGasPrice(), nonce, deployed]);
dev.log("responses from update: $reponses");
op = UserOperation.update(map, reponses[0],
op = UserOperation.update(op.toMap(),
sender: _walletAddress,
nonce: reponses[2].value,
initCode: !(reponses[3]) ? _initCode! : null);
op.maxFeePerGas = reponses[1]["maxFeePerGas"] as BigInt;
op.maxPriorityFeePerGas = reponses[1]["maxPriorityFeePerGas"] as BigInt;
nonce: reponses[1].value,
initCode: !(reponses[2]) ? _initCode! : null);
op.maxFeePerGas = reponses[0]["maxFeePerGas"] as BigInt;
op.maxPriorityFeePerGas = reponses[0]["maxPriorityFeePerGas"] as BigInt;
op.signature = op.dummySig;
dev.log("mock user op = ${op.toMap()}");
UserOperationGas opGas = await plugin<BundlerProviderBase>('bundler')
.estimateUserOperationGas(op.toMap(), _chain.entrypoint);
dev.log("opGas = ${opGas.toString()}");
op = UserOperation.update(op.toMap(), opGas: opGas);
}

Future<void> _validateUserOperation(UserOperation op) async {
Expand Down

0 comments on commit 0c00dbd

Please sign in to comment.