Skip to content

Commit

Permalink
Allow empty safe when adding a delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Nov 12, 2021
1 parent a2388f2 commit 7d2cb0e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions safe_transaction_service/history/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def check_delegate_signature(


class DelegateSerializer(DelegateSignatureCheckerMixin, serializers.Serializer):
safe = EthereumAddressField(allow_null=True)
safe = EthereumAddressField(allow_null=True, required=False)
delegate = EthereumAddressField()
delegator = EthereumAddressField()
signature = HexadecimalField(min_length=65)
Expand All @@ -377,7 +377,7 @@ def get_safe_owners(
def validate(self, data):
super().validate(data)

safe_address: Optional[ChecksumAddress] = data["safe"]
safe_address: Optional[ChecksumAddress] = data.get("safe")
if (
safe_address
and not SafeContract.objects.filter(address=safe_address).exists()
Expand Down
1 change: 0 additions & 1 deletion safe_transaction_service/history/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,6 @@ def test_delegates_post(self):
delegator = Account.create()
label = "Saul Goodman"
data = {
"safe": None,
"delegate": delegate.address,
"delegator": delegator.address,
"label": label,
Expand Down
4 changes: 2 additions & 2 deletions safe_transaction_service/history/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def post(self, request, address, **kwargs):
signer will update the label or delegator if different.
For the signature we are using TOTP with `T0=0` and `Tx=3600`. TOTP is calculated by taking the
Unix UTC epoch time (no milliseconds) and dividing by 3600 (natural division, no decimals)
For signature this hash need to be signed: keccak(address + str(int(current_epoch // 3600)))
For signature this hash need to be signed: keccak(checksummed address + str(int(current_epoch // 3600)))
For example:
- We want to add the delegate `0x132512f995866CcE1b0092384A6118EDaF4508Ff` and `epoch=1586779140`.
- `TOTP = epoch // 3600 = 1586779140 // 3600 = 440771`
Expand Down Expand Up @@ -715,7 +715,7 @@ def post(self, request, **kwargs):
signer will update the label or delegator if different.
For the signature we are using TOTP with `T0=0` and `Tx=3600`. TOTP is calculated by taking the
Unix UTC epoch time (no milliseconds) and dividing by 3600 (natural division, no decimals)
For signature this hash need to be signed: keccak(address + str(int(current_epoch // 3600)))
For signature this hash need to be signed: keccak(checksummed address + str(int(current_epoch // 3600)))
For example:
- We want to add the delegate `0x132512f995866CcE1b0092384A6118EDaF4508Ff` and `epoch=1586779140`.
- `TOTP = epoch // 3600 = 1586779140 // 3600 = 440771`
Expand Down

0 comments on commit 7d2cb0e

Please sign in to comment.