Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept zero address as to when posting transactions #1855

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions safe_transaction_service/history/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def save(self, **kwargs):


class SafeMultisigTransactionSerializer(SafeMultisigTxSerializerV1):
to = EthereumAddressField(allow_zero_address=True, allow_sentinel_address=True)
contract_transaction_hash = Sha3HashField()
sender = EthereumAddressField()
# TODO Make signature mandatory
Expand Down
48 changes: 48 additions & 0 deletions safe_transaction_service/history/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,54 @@ def test_post_multisig_transactions(self):
)
self.assertEqual(response.status_code, status.HTTP_422_UNPROCESSABLE_ENTITY)

def test_post_multisig_transaction_with_zero_to(self):
safe_owner_1 = Account.create()
safe = self.deploy_test_safe(owners=[safe_owner_1.address])
safe_address = safe.address

response = self.client.get(
reverse("v1:history:multisig-transactions", args=(safe_address,)),
format="json",
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["count"], 0)

data = {
"to": NULL_ADDRESS,
"value": 100000000000000000,
"data": None,
"operation": 0,
"nonce": 0,
"safeTxGas": 0,
"baseGas": 0,
"gasPrice": 0,
"gasToken": "0x0000000000000000000000000000000000000000",
"refundReceiver": "0x0000000000000000000000000000000000000000",
# "contractTransactionHash": "0x1c2c77b29086701ccdda7836c399112a9b715c6a153f6c8f75c84da4297f60d3",
"sender": safe_owner_1.address,
}
safe_tx = safe.build_multisig_tx(
data["to"],
data["value"],
data["data"],
data["operation"],
data["safeTxGas"],
data["baseGas"],
data["gasPrice"],
data["gasToken"],
data["refundReceiver"],
safe_nonce=data["nonce"],
)
data["contractTransactionHash"] = safe_tx.safe_tx_hash.hex()
response = self.client.post(
reverse("v1:history:multisig-transactions", args=(safe_address,)),
format="json",
data=data,
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
multisig_transaction_db = MultisigTransaction.objects.first()
self.assertFalse(multisig_transaction_db.trusted)

def test_post_multisig_transaction_with_1271_signature(self):
account = Account.create()
safe_owner = self.deploy_test_safe(owners=[account.address])
Expand Down
Loading