33import base58
44import time
55from logged_groups import logged_group
6+ from solana .system_program import SYS_PROGRAM_ID
67
78try :
89 from indexer_base import IndexerBase
910 from indexer_db import IndexerDB
1011 from utils import SolanaIxSignInfo , NeonTxResultInfo , NeonTxInfo , Canceller , str_fmt_object
11- from utils import get_accounts_from_storage
12+ from utils import get_accounts_from_storage , check_error
1213except ImportError :
1314 from .indexer_base import IndexerBase
1415 from .indexer_db import IndexerDB
1516 from .utils import SolanaIxSignInfo , NeonTxResultInfo , NeonTxInfo , Canceller , str_fmt_object
16- from .utils import get_accounts_from_storage
17+ from .utils import get_accounts_from_storage , check_error
1718
1819from ..environment import EVM_LOADER_ID , FINALIZED , CANCEL_TIMEOUT , SOLANA_URL
1920
@@ -252,6 +253,9 @@ def iter_txs(self):
252253 for tx in self ._tx_table .values ():
253254 yield tx
254255
256+ def add_account_to_db (self , neon_account : str , pda_account : str , code_account : str , slot : int ):
257+ self ._db .fill_account_info_by_indexer (neon_account , pda_account , code_account , slot )
258+
255259
256260@logged_group ("neon.Indexer" )
257261class DummyIxDecoder :
@@ -451,6 +455,50 @@ def _decode_datachunck(self, ix_info: SolanaIxInfo) -> WriteIxDecoder._DataChunk
451455 )
452456
453457
458+ class CreateAccountIxDecoder (DummyIxDecoder ):
459+ def __init__ (self , state : ReceiptsParserState ):
460+ DummyIxDecoder .__init__ (self , 'CreateAccount' , state )
461+
462+ def execute (self ) -> bool :
463+ self ._decoding_start ()
464+
465+ if check_error (self .ix .tx ):
466+ return self ._decoding_skip ("Ignore failed create account" )
467+
468+ if len (self .ix .ix_data ) < 41 :
469+ return self ._decoding_skip (f'not enough data to get the Neon account { len (self .ix .ix_data )} ' )
470+
471+ neon_account = "0x" + self .ix .ix_data [8 + 8 + 4 :][:20 ].hex ()
472+ pda_account = self .ix .get_account (1 )
473+ code_account = self .ix .get_account (3 )
474+ if code_account == str (SYS_PROGRAM_ID ) or code_account == '' :
475+ code_account = None
476+
477+ self .debug (f"neon_account({ neon_account } ), pda_account({ pda_account } ), code_account({ code_account } ), slot({ self .ix .sign .slot } )" )
478+
479+ self .state .add_account_to_db (neon_account , pda_account , code_account , self .ix .sign .slot )
480+ return True
481+
482+
483+ class ResizeStorageAccountIxDecoder (DummyIxDecoder ):
484+ def __init__ (self , state : ReceiptsParserState ):
485+ DummyIxDecoder .__init__ (self , 'ResizeStorageAccount' , state )
486+
487+ def execute (self ) -> bool :
488+ self ._decoding_start ()
489+
490+ if check_error (self .ix .tx ):
491+ return self ._decoding_skip ("Ignore failed resize account" )
492+
493+ pda_account = self .ix .get_account (0 )
494+ code_account = self .ix .get_account (2 )
495+
496+ self .debug (f"pda_account({ pda_account } ), code_account({ code_account } ), slot({ self .ix .sign .slot } )" )
497+
498+ self .state .add_account_to_db (None , pda_account , code_account , self .ix .sign .slot )
499+ return True
500+
501+
454502class CallFromRawIxDecoder (DummyIxDecoder ):
455503 def __init__ (self , state : ReceiptsParserState ):
456504 DummyIxDecoder .__init__ (self , 'CallFromRaw' , state )
@@ -635,7 +683,7 @@ def __init__(self, solana_url, evm_loader_id):
635683 self .ix_decoder_map = {
636684 0x00 : WriteIxDecoder (self .state ),
637685 0x01 : DummyIxDecoder ('Finalize' , self .state ),
638- 0x02 : DummyIxDecoder ( 'CreateAccount' , self .state ),
686+ 0x02 : CreateAccountIxDecoder ( self .state ),
639687 0x03 : DummyIxDecoder ('Call' , self .state ),
640688 0x04 : DummyIxDecoder ('CreateAccountWithSeed' , self .state ),
641689 0x05 : CallFromRawIxDecoder (self .state ),
@@ -647,6 +695,7 @@ def __init__(self, solana_url, evm_loader_id):
647695 0x0c : CancelIxDecoder (self .state ),
648696 0x0d : PartialCallOrContinueIxDecoder (self .state ),
649697 0x0e : ExecuteOrContinueIxParser (self .state ),
698+ 0x11 : ResizeStorageAccountIxDecoder (self .state ),
650699 0x12 : WriteWithHolderIxDecoder (self .state ),
651700 0x13 : PartialCallV02IxDecoder (self .state ),
652701 0x14 : ContinueV02IxDecoder (self .state ),
0 commit comments