Skip to content

Commit c1072ee

Browse files
authored
Fix decryptor nonce computation (#1062)
* 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.
1 parent 67513b2 commit c1072ee

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

aquarius/events/decryptor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#
55
import json
66
import logging
7+
import time
8+
from _decimal import Decimal
79
from datetime import datetime, timezone
810
from hashlib import sha256
911

@@ -17,18 +19,18 @@
1719

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

2224
signature = get_signature_bytes(
23-
f"{txid}{aquarius_account.address}{chain_id}{nonce}"
25+
f"{txid}{aquarius_account.address}{chain_id}{str(nonce)}"
2426
)
2527
payload = {
2628
"transactionId": txid,
2729
"chainId": chain_id,
2830
"decrypterAddress": aquarius_account.address,
2931
"dataNftAddress": contract_address,
3032
"signature": signature,
31-
"nonce": nonce,
33+
"nonce": str(nonce),
3234
}
3335

3436
try:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"elasticsearch==8.9.0",
3030
"PyYAML==6.0.1",
3131
"pytz==2023.3",
32-
"ocean-contracts==1.1.14",
32+
"ocean-contracts==1.1.15",
3333
"web3==6.7.0",
3434
"gevent",
3535
"python-dateutil==2.8.2",

tests/test_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def test_token_uri_update(client, base_ddo_url, events_object):
440440
web3.eth.default_account = test_account1.address
441441
txn_hash = nft_contract.functions.setTokenURI(
442442
1, "http://something-else.com"
443-
).transact()
443+
).transact({"from": test_account1.address})
444444
_ = web3.eth.wait_for_transaction_receipt(txn_hash)
445445

446446
events_object.process_current_blocks()

0 commit comments

Comments
 (0)