forked from neonevm/neon-tests
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a function for debug failed neon trx (#515)
- Loading branch information
1 parent
4fad317
commit 6d8cbcb
Showing
4 changed files
with
38 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import base64 | ||
|
||
from solana.rpc.commitment import Confirmed | ||
from solders.signature import Signature | ||
|
||
from utils.web3client import Web3Client | ||
|
||
|
||
def decode_logs(log_messages: list) -> str: | ||
decoded_logs = "" | ||
|
||
for log in log_messages: | ||
if "Program data:" in log: | ||
decoded_logs += "Program data: " | ||
encoded_part = log.replace("Program data: ", "") | ||
for item in encoded_part.split(" "): | ||
decoded_logs += " " + str(base64.b64decode(item)) | ||
else: | ||
decoded_logs += log | ||
decoded_logs += " " | ||
return decoded_logs | ||
|
||
|
||
def get_all_solana_logs_for_neon_trx(web3_client: Web3Client, solana_client, trx_hash): | ||
sol_trxs = web3_client.get_solana_trx_by_neon(trx_hash)["result"] | ||
logs = [] | ||
for trx in sol_trxs: | ||
encoded_log = solana_client.get_transaction( | ||
Signature.from_string(trx), commitment=Confirmed | ||
).value.transaction.meta.log_messages | ||
logs.append(decode_logs(encoded_log)) | ||
|
||
return logs |