Skip to content

Commit

Permalink
Add removed attributes by mistake
Browse files Browse the repository at this point in the history
- #795 changes were removed by mistake
  • Loading branch information
Uxio0 committed Mar 8, 2024
1 parent a04f96d commit f90a39c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gnosis/eth/account_abstraction/user_operation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import dataclasses
from functools import cached_property
from typing import Any, Dict, List, Optional, TypedDict, Union

from eth_abi import encode as abi_encode
from eth_typing import ChecksumAddress, HexStr
from hexbytes import HexBytes
from web3 import Web3

from gnosis.eth.utils import fast_keccak

Expand Down Expand Up @@ -68,6 +70,16 @@ def from_bundler_response(
def __str__(self):
return f"User Operation sender={self.sender} nonce={self.nonce} hash={self.user_operation_hash.hex()}"

@cached_property
def paymaster(self) -> Optional[ChecksumAddress]:
if self.paymaster_and_data and len(self.paymaster_and_data) >= 20:
return Web3.to_checksum_address(self.paymaster_and_data[:20])
return None

@cached_property
def paymaster_data(self) -> bytes:
return self.paymaster_and_data[:20]

def calculate_user_operation_hash(self, chain_id: int) -> bytes:
hash_init_code = fast_keccak(self.init_code)
hash_call_data = fast_keccak(self.call_data)
Expand Down

0 comments on commit f90a39c

Please sign in to comment.