Skip to content

Commit

Permalink
Update Uint256 field API response to string (#2367)
Browse files Browse the repository at this point in the history
  • Loading branch information
falvaradorodriguez authored Dec 19, 2024
1 parent f3a0030 commit 6e30184
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 39 deletions.
12 changes: 6 additions & 6 deletions safe_transaction_service/account_abstraction/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@ class UserOperationResponseSerializer(serializers.Serializer):

sender = eth_serializers.EthereumAddressField()
user_operation_hash = eth_serializers.HexadecimalField(source="hash")
nonce = serializers.IntegerField(min_value=0)
nonce = serializers.CharField()
init_code = eth_serializers.HexadecimalField(allow_null=True)
call_data = eth_serializers.HexadecimalField(allow_null=True)
call_gas_limit = serializers.IntegerField(min_value=0)
verification_gas_limit = serializers.IntegerField(min_value=0)
pre_verification_gas = serializers.IntegerField(min_value=0)
max_fee_per_gas = serializers.IntegerField(min_value=0)
max_priority_fee_per_gas = serializers.IntegerField(min_value=0)
call_gas_limit = serializers.CharField()
verification_gas_limit = serializers.CharField()
pre_verification_gas = serializers.CharField()
max_fee_per_gas = serializers.CharField()
max_priority_fee_per_gas = serializers.CharField()
paymaster = eth_serializers.EthereumAddressField(allow_null=True)
paymaster_data = eth_serializers.HexadecimalField(allow_null=True)
signature = eth_serializers.HexadecimalField()
Expand Down
75 changes: 50 additions & 25 deletions safe_transaction_service/account_abstraction/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,22 @@ def test_safe_operation_view(self):
"safeOperationHash": safe_operation.hash,
"userOperation": {
"sender": safe_operation.user_operation.sender,
"nonce": safe_operation.user_operation.nonce,
"nonce": str(safe_operation.user_operation.nonce),
"userOperationHash": safe_operation.user_operation.hash,
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
"initCode": "0x",
"callData": "0x",
"callGasLimit": safe_operation.user_operation.call_gas_limit,
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
"verificationGasLimit": str(
safe_operation.user_operation.verification_gas_limit
),
"preVerificationGas": str(
safe_operation.user_operation.pre_verification_gas
),
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
"maxPriorityFeePerGas": str(
safe_operation.user_operation.max_priority_fee_per_gas
),
"paymaster": NULL_ADDRESS,
"paymasterData": "0x",
"entryPoint": safe_operation.user_operation.entry_point,
Expand Down Expand Up @@ -149,16 +155,22 @@ def test_safe_operations_view(self):
"safeOperationHash": safe_operation.hash,
"userOperation": {
"sender": safe_operation.user_operation.sender,
"nonce": safe_operation.user_operation.nonce,
"nonce": str(safe_operation.user_operation.nonce),
"userOperationHash": safe_operation.user_operation.hash,
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
"initCode": "0x",
"callData": "0x",
"callGasLimit": safe_operation.user_operation.call_gas_limit,
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
"verificationGasLimit": str(
safe_operation.user_operation.verification_gas_limit
),
"preVerificationGas": str(
safe_operation.user_operation.pre_verification_gas
),
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
"maxPriorityFeePerGas": str(
safe_operation.user_operation.max_priority_fee_per_gas
),
"paymaster": NULL_ADDRESS,
"paymasterData": "0x",
"signature": "0x" + "0" * 24,
Expand Down Expand Up @@ -890,16 +902,22 @@ def test_user_operation_view(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected = {
"sender": safe_operation.user_operation.sender,
"nonce": safe_operation.user_operation.nonce,
"nonce": str(safe_operation.user_operation.nonce),
"userOperationHash": safe_operation.user_operation.hash,
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
"initCode": "0x",
"callData": "0x",
"callGasLimit": safe_operation.user_operation.call_gas_limit,
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
"verificationGasLimit": str(
safe_operation.user_operation.verification_gas_limit
),
"preVerificationGas": str(
safe_operation.user_operation.pre_verification_gas
),
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
"maxPriorityFeePerGas": str(
safe_operation.user_operation.max_priority_fee_per_gas
),
"paymaster": NULL_ADDRESS,
"paymasterData": "0x",
"signature": "0x" + "0" * 24,
Expand Down Expand Up @@ -935,24 +953,31 @@ def test_user_operations_view(self):
response.json(), {"count": 0, "next": None, "previous": None, "results": []}
)
safe_operation = factories.SafeOperationFactory(
user_operation__sender=safe_address
user_operation__sender=safe_address,
user_operation__nonce=131872201376309576872419307987365003264,
)
response = self.client.get(
reverse("v1:account_abstraction:user-operations", args=(safe_address,))
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected = {
"sender": safe_operation.user_operation.sender,
"nonce": safe_operation.user_operation.nonce,
"nonce": str(safe_operation.user_operation.nonce),
"userOperationHash": safe_operation.user_operation.hash,
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
"initCode": "0x",
"callData": "0x",
"callGasLimit": safe_operation.user_operation.call_gas_limit,
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
"verificationGasLimit": str(
safe_operation.user_operation.verification_gas_limit
),
"preVerificationGas": str(
safe_operation.user_operation.pre_verification_gas
),
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
"maxPriorityFeePerGas": str(
safe_operation.user_operation.max_priority_fee_per_gas
),
"paymaster": NULL_ADDRESS,
"paymasterData": "0x",
"signature": "0x" + "0" * 24,
Expand Down
2 changes: 1 addition & 1 deletion safe_transaction_service/history/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ def get_data_decoded(self, obj: SafeCreationInfo) -> Dict[str, Any]:

class SafeInfoResponseSerializer(serializers.Serializer):
address = EthereumAddressField()
nonce = serializers.IntegerField()
nonce = serializers.CharField()
threshold = serializers.IntegerField()
owners = serializers.ListField(child=EthereumAddressField())
master_copy = EthereumAddressField()
Expand Down
20 changes: 13 additions & 7 deletions safe_transaction_service/history/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3379,16 +3379,22 @@ def test_safe_creation_view(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected["user_operation"] = {
"sender": safe_operation.user_operation.sender,
"nonce": safe_operation.user_operation.nonce,
"nonce": str(safe_operation.user_operation.nonce),
"user_operation_hash": safe_operation.user_operation.hash,
"ethereum_tx_hash": internal_tx.ethereum_tx_id,
"init_code": "0x1234",
"call_data": "0x",
"call_gas_limit": safe_operation.user_operation.call_gas_limit,
"verification_gas_limit": safe_operation.user_operation.verification_gas_limit,
"pre_verification_gas": safe_operation.user_operation.pre_verification_gas,
"max_fee_per_gas": safe_operation.user_operation.max_fee_per_gas,
"max_priority_fee_per_gas": safe_operation.user_operation.max_priority_fee_per_gas,
"call_gas_limit": str(safe_operation.user_operation.call_gas_limit),
"verification_gas_limit": str(
safe_operation.user_operation.verification_gas_limit
),
"pre_verification_gas": str(
safe_operation.user_operation.pre_verification_gas
),
"max_fee_per_gas": str(safe_operation.user_operation.max_fee_per_gas),
"max_priority_fee_per_gas": str(
safe_operation.user_operation.max_priority_fee_per_gas
),
"paymaster": safe_operation.user_operation.paymaster,
"paymaster_data": "0x",
"signature": "0x" + safe_operation.user_operation.signature.hex(),
Expand Down Expand Up @@ -3518,7 +3524,7 @@ def test_safe_info_view(self):
response.data,
{
"address": blockchain_safe.address,
"nonce": 0,
"nonce": "0",
"threshold": blockchain_safe.retrieve_threshold(),
"owners": blockchain_safe.retrieve_owners(),
"master_copy": blockchain_safe.retrieve_master_copy_address(),
Expand Down

0 comments on commit 6e30184

Please sign in to comment.