Skip to content

Commit

Permalink
Fix decryptor nonce computation (#1062)
Browse files Browse the repository at this point in the history
* Fix nonce computation on decrypt.

* Changed default value.

* Rebuild query params.

* tweak.

* Convert from Decimal to str.

* Added sleep in test.

* Added from param to transact function.

* Update contracts version.

* Changed default to 1. Remove condition.

* Changed to nanoseconds format.
  • Loading branch information
mariacarmina authored Sep 25, 2023
1 parent 67513b2 commit c1072ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions aquarius/events/decryptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
import json
import logging
import time
from _decimal import Decimal
from datetime import datetime, timezone
from hashlib import sha256

Expand All @@ -17,18 +19,18 @@

def decrypt_ddo(w3, provider_url, contract_address, chain_id, txid, hash, es_instance):
aquarius_account = get_aquarius_wallet()
nonce = str(int(datetime.now(timezone.utc).timestamp()))
nonce = Decimal(time.time_ns())

signature = get_signature_bytes(
f"{txid}{aquarius_account.address}{chain_id}{nonce}"
f"{txid}{aquarius_account.address}{chain_id}{str(nonce)}"
)
payload = {
"transactionId": txid,
"chainId": chain_id,
"decrypterAddress": aquarius_account.address,
"dataNftAddress": contract_address,
"signature": signature,
"nonce": nonce,
"nonce": str(nonce),
}

try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"elasticsearch==8.9.0",
"PyYAML==6.0.1",
"pytz==2023.3",
"ocean-contracts==1.1.14",
"ocean-contracts==1.1.15",
"web3==6.7.0",
"gevent",
"python-dateutil==2.8.2",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def test_token_uri_update(client, base_ddo_url, events_object):
web3.eth.default_account = test_account1.address
txn_hash = nft_contract.functions.setTokenURI(
1, "http://something-else.com"
).transact()
).transact({"from": test_account1.address})
_ = web3.eth.wait_for_transaction_receipt(txn_hash)

events_object.process_current_blocks()
Expand Down

0 comments on commit c1072ee

Please sign in to comment.