Skip to content

Commit

Permalink
Remove function with signer account
Browse files Browse the repository at this point in the history
  • Loading branch information
falvaradorodriguez committed May 28, 2024
1 parent eb6fcc8 commit a7eb692
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
21 changes: 0 additions & 21 deletions gnosis/safe/api/transaction_service_api/transaction_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,27 +285,6 @@ def add_delegate(
return True

def remove_delegate(
self,
safe_address: ChecksumAddress,
delegate_address: ChecksumAddress,
signer_account: LocalAccount,
) -> bool:
hash_to_sign = self.create_delegate_message_hash(delegate_address)
signature = signer_account.signHash(hash_to_sign)
remove_payload = {
"safe": safe_address,
"delegator": signer_account.address,
"signature": signature.signature.hex(),
}
response = self._delete_request(
f"/api/v2/delegates/{delegate_address}/",
remove_payload,
)
if not response.ok:
raise SafeAPIException(f"Cannot remove delegate: {response.content}")
return True

def remove_delegate_signed(
self,
delegator_address: ChecksumAddress,
delegate_address: ChecksumAddress,
Expand Down
25 changes: 2 additions & 23 deletions gnosis/safe/tests/api/test_transaction_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,6 @@ def test_get_safe_transaction(self):
str(context.exception),
)

def test_remove_delegate(self):
with patch.object(
TransactionServiceApi, "_delete_request"
) as mock_delete_request:
delegate_address = Account().create().address
delegator_account = Account().create()
self.transaction_service_api.remove_delegate(
self.safe_address, delegate_address, delegator_account
)
expected_hash = self.transaction_service_api.create_delegate_message_hash(
delegate_address
)
expected_sign = delegator_account.signHash(expected_hash)
expected_url = f"/api/v2/delegates/{delegate_address}/"
expected_payload = {
"safe": self.safe_address,
"delegator": delegator_account.address,
"signature": expected_sign.signature.hex(),
}
mock_delete_request.assert_called_once_with(expected_url, expected_payload)

def test_remove_delegate_signed(self):
with patch.object(
TransactionServiceApi, "_delete_request"
Expand All @@ -216,7 +195,7 @@ def test_remove_delegate_signed(self):
delegate_address
)
signature = delegator_account.signHash(message_hash).signature.hex()
self.transaction_service_api.remove_delegate_signed(
self.transaction_service_api.remove_delegate(
delegator_account.address, delegate_address, signature
)

Expand All @@ -227,7 +206,7 @@ def test_remove_delegate_signed(self):
}
mock_delete_request.assert_called_once_with(expected_url, expected_payload)

self.transaction_service_api.remove_delegate_signed(
self.transaction_service_api.remove_delegate(
delegator_account.address,
delegate_address,
signature,
Expand Down

0 comments on commit a7eb692

Please sign in to comment.