22import traceback
33from dataclasses import dataclass
44import base58
5+ import base64
56import json
67from typing import Any , Callable , Dict , Iterator , Tuple , TypedDict , Union , List
78from uuid import uuid4
6364from solana .rpc .commitment import Commitment
6465from solana .rpc .async_api import AsyncClient
6566from solana .rpc .types import TxOpts
67+ from solders .transaction import Transaction as SoldersTransaction
6668from solders .pubkey import Pubkey
6769from solders .hash import Hash
6870from solders .signature import Signature
@@ -324,7 +326,10 @@ async def order_subscribe(
324326 "transactionSubscribe" ,
325327 params = [
326328 {
327- "mentions" : [str (market_pubkey )],
329+ "accounts" :
330+ {
331+ "include" : [str (market_pubkey )]
332+ },
328333 "failed" : False ,
329334 "vote" : False ,
330335 },
@@ -385,15 +390,21 @@ async def order_subscribe(
385390 def __process_transaction_event (
386391 self , response , market_pubkey : Pubkey , trader_pubkey : Pubkey
387392 ) -> [OrderSubscribeResponse ]:
388- payload = response ["params" ]["result" ]["value" ]
393+ if "error" in response ["params" ]["result" ]["value" ]:
394+ error = response ["params" ]["result" ]["value" ]["error" ]
395+ print ("Order subscription returned an error %s" , error )
396+ return []
397+
398+ payload = response ["params" ]["result" ]["value" ]["transaction" ]
389399 meta = payload ["meta" ]
390400 loaded_addresses = meta .get ("loadedAddresses" , {"readonly" : [], "writable" : []})
391- tx_message = payload ["transaction" ]["message" ]
392- message = tx_message [- 1 ] if isinstance (tx_message , list ) else tx_message
401+ tx_message = SoldersTransaction .from_bytes (
402+ base64 .b64decode (payload ["transaction" ][0 ])
403+ ).message
393404 base_account_keys = list (
394405 map (
395406 lambda l : Pubkey .from_bytes (bytes (l )),
396- message [ "accountKeys" ][ 1 :] ,
407+ message . account_keys ,
397408 )
398409 )
399410 lookup_table_keys = list (
@@ -417,7 +428,7 @@ def __process_transaction_event(
417428
418429 phoenix_tx = PhoenixTransaction (
419430 instructions ,
420- signature = Signature . from_bytes ( payload [ "transaction" ][ " signatures" ][ 1 ]) ,
431+ signature = tx . signatures [ 0 ] ,
421432 txReceived = True ,
422433 txFailed = False ,
423434 )
0 commit comments