Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions async_substrate_interface/async_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,14 @@ async def process_events(self):
has_transaction_fee_paid_event = True

# Process other events
possible_success = False
for event in await self.triggered_events:
# Check events
if (
event["event"]["module_id"] == "System"
and event["event"]["event_id"] == "ExtrinsicSuccess"
):
if self.__error_message is None:
self.__is_success = True
self.__error_message = None
possible_success = True

if "dispatch_info" in event["event"]["attributes"]:
self.__weight = event["event"]["attributes"]["dispatch_info"][
Expand All @@ -299,6 +298,7 @@ async def process_events(self):
event["event"]["module_id"] == "MevShield"
and event["event"]["event_id"] == "DecryptedRejected"
):
possible_success = False
self.__is_success = False

if event["event"]["module_id"] == "System":
Expand All @@ -307,9 +307,13 @@ async def process_events(self):
self.__weight = dispatch_info["weight"]
else:
# MEV shield extrinsics
dispatch_info = event["event"]["attributes"]["reason"]["post_info"]
dispatch_info = event["event"]["attributes"]["reason"][
"post_info"
]
dispatch_error = event["event"]["attributes"]["reason"]["error"]
self.__weight = event["event"]["attributes"]["reason"]["post_info"]["actual_weight"]
self.__weight = event["event"]["attributes"]["reason"][
"post_info"
]["actual_weight"]

if "Module" in dispatch_error:
if isinstance(dispatch_error["Module"], tuple):
Expand Down Expand Up @@ -375,6 +379,10 @@ async def process_events(self):
and event["event"]["event_id"] == "Deposit"
):
self.__total_fee_amount += event.value["attributes"]["amount"]
if possible_success is True and self.__error_message is None:
# we delay the positive setting of the __is_success flag until we have finished iteration of the
# events and have ensured nothing has set an error message
self.__is_success = True

@property
async def is_success(self) -> bool:
Expand Down
29 changes: 23 additions & 6 deletions async_substrate_interface/sync_substrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,14 @@ def process_events(self):
has_transaction_fee_paid_event = True

# Process other events
possible_success = False
for event in self.triggered_events:
# Check events
if (
event["event"]["module_id"] == "System"
and event["event"]["event_id"] == "ExtrinsicSuccess"
):
self.__is_success = True
self.__error_message = None
possible_success = True

if "dispatch_info" in event["event"]["attributes"]:
self.__weight = event["event"]["attributes"]["dispatch_info"][
Expand All @@ -255,13 +255,26 @@ def process_events(self):
elif (
event["event"]["module_id"] == "System"
and event["event"]["event_id"] == "ExtrinsicFailed"
) or (
event["event"]["module_id"] == "MevShield"
and event["event"]["event_id"] == "DecryptedRejected"
):
possible_success = False
self.__is_success = False

dispatch_info = event["event"]["attributes"]["dispatch_info"]
dispatch_error = event["event"]["attributes"]["dispatch_error"]

self.__weight = dispatch_info["weight"]
if event["event"]["module_id"] == "System":
dispatch_info = event["event"]["attributes"]["dispatch_info"]
dispatch_error = event["event"]["attributes"]["dispatch_error"]
self.__weight = dispatch_info["weight"]
else:
# MEV shield extrinsics
dispatch_info = event["event"]["attributes"]["reason"][
"post_info"
]
dispatch_error = event["event"]["attributes"]["reason"]["error"]
self.__weight = event["event"]["attributes"]["reason"][
"post_info"
]["actual_weight"]

if "Module" in dispatch_error:
if isinstance(dispatch_error["Module"], tuple):
Expand Down Expand Up @@ -319,6 +332,10 @@ def process_events(self):
and event["event"]["event_id"] == "Deposit"
):
self.__total_fee_amount += event.value["attributes"]["amount"]
if possible_success is True and self.__error_message is None:
# we delay the positive setting of the __is_success flag until we have finished iteration of the
# events and have ensured nothing has set an error message
self.__is_success = True

@property
def is_success(self) -> bool:
Expand Down
Loading