Skip to content

Commit 6e30184

Browse files
Update Uint256 field API response to string (#2367)
1 parent f3a0030 commit 6e30184

File tree

4 files changed

+70
-39
lines changed

4 files changed

+70
-39
lines changed

safe_transaction_service/account_abstraction/serializers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,14 @@ class UserOperationResponseSerializer(serializers.Serializer):
411411

412412
sender = eth_serializers.EthereumAddressField()
413413
user_operation_hash = eth_serializers.HexadecimalField(source="hash")
414-
nonce = serializers.IntegerField(min_value=0)
414+
nonce = serializers.CharField()
415415
init_code = eth_serializers.HexadecimalField(allow_null=True)
416416
call_data = eth_serializers.HexadecimalField(allow_null=True)
417-
call_gas_limit = serializers.IntegerField(min_value=0)
418-
verification_gas_limit = serializers.IntegerField(min_value=0)
419-
pre_verification_gas = serializers.IntegerField(min_value=0)
420-
max_fee_per_gas = serializers.IntegerField(min_value=0)
421-
max_priority_fee_per_gas = serializers.IntegerField(min_value=0)
417+
call_gas_limit = serializers.CharField()
418+
verification_gas_limit = serializers.CharField()
419+
pre_verification_gas = serializers.CharField()
420+
max_fee_per_gas = serializers.CharField()
421+
max_priority_fee_per_gas = serializers.CharField()
422422
paymaster = eth_serializers.EthereumAddressField(allow_null=True)
423423
paymaster_data = eth_serializers.HexadecimalField(allow_null=True)
424424
signature = eth_serializers.HexadecimalField()

safe_transaction_service/account_abstraction/tests/test_views.py

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,22 @@ def test_safe_operation_view(self):
6969
"safeOperationHash": safe_operation.hash,
7070
"userOperation": {
7171
"sender": safe_operation.user_operation.sender,
72-
"nonce": safe_operation.user_operation.nonce,
72+
"nonce": str(safe_operation.user_operation.nonce),
7373
"userOperationHash": safe_operation.user_operation.hash,
7474
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
7575
"initCode": "0x",
7676
"callData": "0x",
77-
"callGasLimit": safe_operation.user_operation.call_gas_limit,
78-
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
79-
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
80-
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
81-
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
77+
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
78+
"verificationGasLimit": str(
79+
safe_operation.user_operation.verification_gas_limit
80+
),
81+
"preVerificationGas": str(
82+
safe_operation.user_operation.pre_verification_gas
83+
),
84+
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
85+
"maxPriorityFeePerGas": str(
86+
safe_operation.user_operation.max_priority_fee_per_gas
87+
),
8288
"paymaster": NULL_ADDRESS,
8389
"paymasterData": "0x",
8490
"entryPoint": safe_operation.user_operation.entry_point,
@@ -149,16 +155,22 @@ def test_safe_operations_view(self):
149155
"safeOperationHash": safe_operation.hash,
150156
"userOperation": {
151157
"sender": safe_operation.user_operation.sender,
152-
"nonce": safe_operation.user_operation.nonce,
158+
"nonce": str(safe_operation.user_operation.nonce),
153159
"userOperationHash": safe_operation.user_operation.hash,
154160
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
155161
"initCode": "0x",
156162
"callData": "0x",
157-
"callGasLimit": safe_operation.user_operation.call_gas_limit,
158-
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
159-
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
160-
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
161-
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
163+
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
164+
"verificationGasLimit": str(
165+
safe_operation.user_operation.verification_gas_limit
166+
),
167+
"preVerificationGas": str(
168+
safe_operation.user_operation.pre_verification_gas
169+
),
170+
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
171+
"maxPriorityFeePerGas": str(
172+
safe_operation.user_operation.max_priority_fee_per_gas
173+
),
162174
"paymaster": NULL_ADDRESS,
163175
"paymasterData": "0x",
164176
"signature": "0x" + "0" * 24,
@@ -890,16 +902,22 @@ def test_user_operation_view(self):
890902
self.assertEqual(response.status_code, status.HTTP_200_OK)
891903
expected = {
892904
"sender": safe_operation.user_operation.sender,
893-
"nonce": safe_operation.user_operation.nonce,
905+
"nonce": str(safe_operation.user_operation.nonce),
894906
"userOperationHash": safe_operation.user_operation.hash,
895907
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
896908
"initCode": "0x",
897909
"callData": "0x",
898-
"callGasLimit": safe_operation.user_operation.call_gas_limit,
899-
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
900-
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
901-
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
902-
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
910+
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
911+
"verificationGasLimit": str(
912+
safe_operation.user_operation.verification_gas_limit
913+
),
914+
"preVerificationGas": str(
915+
safe_operation.user_operation.pre_verification_gas
916+
),
917+
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
918+
"maxPriorityFeePerGas": str(
919+
safe_operation.user_operation.max_priority_fee_per_gas
920+
),
903921
"paymaster": NULL_ADDRESS,
904922
"paymasterData": "0x",
905923
"signature": "0x" + "0" * 24,
@@ -935,24 +953,31 @@ def test_user_operations_view(self):
935953
response.json(), {"count": 0, "next": None, "previous": None, "results": []}
936954
)
937955
safe_operation = factories.SafeOperationFactory(
938-
user_operation__sender=safe_address
956+
user_operation__sender=safe_address,
957+
user_operation__nonce=131872201376309576872419307987365003264,
939958
)
940959
response = self.client.get(
941960
reverse("v1:account_abstraction:user-operations", args=(safe_address,))
942961
)
943962
self.assertEqual(response.status_code, status.HTTP_200_OK)
944963
expected = {
945964
"sender": safe_operation.user_operation.sender,
946-
"nonce": safe_operation.user_operation.nonce,
965+
"nonce": str(safe_operation.user_operation.nonce),
947966
"userOperationHash": safe_operation.user_operation.hash,
948967
"ethereumTxHash": safe_operation.user_operation.ethereum_tx_id,
949968
"initCode": "0x",
950969
"callData": "0x",
951-
"callGasLimit": safe_operation.user_operation.call_gas_limit,
952-
"verificationGasLimit": safe_operation.user_operation.verification_gas_limit,
953-
"preVerificationGas": safe_operation.user_operation.pre_verification_gas,
954-
"maxFeePerGas": safe_operation.user_operation.max_fee_per_gas,
955-
"maxPriorityFeePerGas": safe_operation.user_operation.max_priority_fee_per_gas,
970+
"callGasLimit": str(safe_operation.user_operation.call_gas_limit),
971+
"verificationGasLimit": str(
972+
safe_operation.user_operation.verification_gas_limit
973+
),
974+
"preVerificationGas": str(
975+
safe_operation.user_operation.pre_verification_gas
976+
),
977+
"maxFeePerGas": str(safe_operation.user_operation.max_fee_per_gas),
978+
"maxPriorityFeePerGas": str(
979+
safe_operation.user_operation.max_priority_fee_per_gas
980+
),
956981
"paymaster": NULL_ADDRESS,
957982
"paymasterData": "0x",
958983
"signature": "0x" + "0" * 24,

safe_transaction_service/history/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def get_data_decoded(self, obj: SafeCreationInfo) -> Dict[str, Any]:
809809

810810
class SafeInfoResponseSerializer(serializers.Serializer):
811811
address = EthereumAddressField()
812-
nonce = serializers.IntegerField()
812+
nonce = serializers.CharField()
813813
threshold = serializers.IntegerField()
814814
owners = serializers.ListField(child=EthereumAddressField())
815815
master_copy = EthereumAddressField()

safe_transaction_service/history/tests/test_views.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3379,16 +3379,22 @@ def test_safe_creation_view(self):
33793379
self.assertEqual(response.status_code, status.HTTP_200_OK)
33803380
expected["user_operation"] = {
33813381
"sender": safe_operation.user_operation.sender,
3382-
"nonce": safe_operation.user_operation.nonce,
3382+
"nonce": str(safe_operation.user_operation.nonce),
33833383
"user_operation_hash": safe_operation.user_operation.hash,
33843384
"ethereum_tx_hash": internal_tx.ethereum_tx_id,
33853385
"init_code": "0x1234",
33863386
"call_data": "0x",
3387-
"call_gas_limit": safe_operation.user_operation.call_gas_limit,
3388-
"verification_gas_limit": safe_operation.user_operation.verification_gas_limit,
3389-
"pre_verification_gas": safe_operation.user_operation.pre_verification_gas,
3390-
"max_fee_per_gas": safe_operation.user_operation.max_fee_per_gas,
3391-
"max_priority_fee_per_gas": safe_operation.user_operation.max_priority_fee_per_gas,
3387+
"call_gas_limit": str(safe_operation.user_operation.call_gas_limit),
3388+
"verification_gas_limit": str(
3389+
safe_operation.user_operation.verification_gas_limit
3390+
),
3391+
"pre_verification_gas": str(
3392+
safe_operation.user_operation.pre_verification_gas
3393+
),
3394+
"max_fee_per_gas": str(safe_operation.user_operation.max_fee_per_gas),
3395+
"max_priority_fee_per_gas": str(
3396+
safe_operation.user_operation.max_priority_fee_per_gas
3397+
),
33923398
"paymaster": safe_operation.user_operation.paymaster,
33933399
"paymaster_data": "0x",
33943400
"signature": "0x" + safe_operation.user_operation.signature.hex(),
@@ -3518,7 +3524,7 @@ def test_safe_info_view(self):
35183524
response.data,
35193525
{
35203526
"address": blockchain_safe.address,
3521-
"nonce": 0,
3527+
"nonce": "0",
35223528
"threshold": blockchain_safe.retrieve_threshold(),
35233529
"owners": blockchain_safe.retrieve_owners(),
35243530
"master_copy": blockchain_safe.retrieve_master_copy_address(),

0 commit comments

Comments
 (0)