Skip to content

Commit 88b8cc0

Browse files
committed
Fixing transaction error handling
1 parent f0f81ff commit 88b8cc0

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

aries_cloudagent/anoncreds/default/did_besu/registry.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from base58 import alphabet
1010
from web3 import Web3
11+
from web3.exceptions import ContractCustomError
1112
from web3.middleware import geth_poa_middleware
1213
from web3.types import TxReceipt
1314

@@ -255,6 +256,10 @@ async def send_transaction_tx(self, call_function) -> TxReceipt:
255256
# Wait for transaction receipt
256257
tx_receipt = self.web3.eth.wait_for_transaction_receipt(send_tx)
257258

259+
if tx_receipt["status"] == 0:
260+
LOGGER.debug("Receipt of the reverted transaction: %s", tx_receipt)
261+
raise AnonCredsRegistrationError(f"Transaction reverted: %s", send_tx)
262+
258263
return tx_receipt
259264

260265
async def register_revocation(
@@ -621,7 +626,10 @@ async def register_revocation_registry_definition(
621626
# receipt = contract.functions.createSchema(indy_schema).transact({"from": self.ACCOUNT})
622627
LOGGER.debug("Receipt: %s", tx_receipt)
623628
# Was it realy created?
624-
result = contract.functions.resolveRevocation(rev_reg_def_id).call()
629+
try:
630+
contract.functions.resolveRevocation(rev_reg_def_id).call()
631+
except ContractCustomError as e:
632+
raise AnonCredsRegistrationError("Error searching for newly created revocation") from e
625633

626634
seq_no = self.REVOCATION_ADDRESS
627635
except LedgerError as err:

aries_cloudagent/ledger/besu_vdr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ async def fetch_schema_by_id(self, schema_id: str) -> dict:
144144
)
145145

146146
except ContractCustomError as ex:
147-
LOGGER.error(f"Could not retrieve schema {schema_id} {ex.message}")
147+
LOGGER.debug(f"Could not retrieve schema {schema_id} {ex.message}")
148148
return schema
149149

150150
async def fetch_schema_by_seq_no(self, seq_no: int) -> dict:
@@ -367,7 +367,7 @@ async def send_credential_definition_anoncreds(
367367
tx_receipt = self._send_signed_transaction(call_function, False)
368368
LOGGER.debug("Receipt: %s", tx_receipt)
369369

370-
result = self.fetch_credential_definition(cred_def_id)
370+
result = await self.fetch_credential_definition(cred_def_id)
371371
if not result:
372372
raise LedgerError("Failed to register credef")
373373

aries_cloudagent/messaging/valid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ class IndyRevRegId(Regexp):
489489
rf"([{B58}]{{21,22}}):3:"
490490
rf"CL:(([1-9][0-9]*)|([{B58}]{{21,22}}:2:.+:[0-9.]+))(:.+)?:"
491491
rf"CL_ACCUM:(.+$)|^((did:indy2)?:.+:[{B58}]{{21,22}})" # issuer DID
492-
f"/anoncreds/v0/REV_REG_DEF/" # cred def id marker
492+
f"\/anoncreds\/v0\/REV_REG_DEF\/" # cred def id marker
493493
rf"((did:indy2)?:.+:[{B58}]{{21,22}})" # issuer DID
494-
f"/anoncreds/v0/CLAIM_DEF/" # cred def id marker
494+
f"\/anoncreds\/v0\/CLAIM_DEF\/" # cred def id marker
495495
# f":CL" # sig alg
496-
rf"((did:indy2)?:.+:[{B58}]{{21,22}}/anoncreds/v0/SCHEMA/.+/[0-9.]+)" # schema txn / id
497-
f"/(.+)?(:|/)CL_ACCUM(:|/).+$"
496+
rf"((did:indy2)?:.+:[{B58}]{{21,22}}\/anoncreds\/v0\/SCHEMA\/.+\/[0-9.]+)" # schema txn / id
497+
f"\/(.+)?(:|\/)CL_ACCUM(:|\/).+$"
498498
)
499499

500500
def __init__(self):

0 commit comments

Comments
 (0)