abstract-solana 0.0.0.16__py3-none-any.whl → 0.0.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of abstract-solana might be problematic. Click here for more details.

@@ -30,15 +30,35 @@ def get_end_log_index(txnData,index):
30
30
  if 'invoke' in log.lower():
31
31
  return index+1+i
32
32
  return len(allLogs)
33
- def get_for_program_ids_info(txnData):
33
+ def get_stack_height_from_logs(logs):
34
+ for log in make_list(logs):
35
+ if 'invoke' in log.lower():
36
+ return int(log.split(' ')[-1][1:-1])
37
+ def get_program_id_from_log(logs):
38
+ for log in make_list(logs):
39
+ if 'invoke' in log.lower():
40
+ return log.split(' ')[1]
41
+
42
+ def get_all_logs(txnData):
43
+ logits = []
34
44
  allLogs = get_log_messages_from_txn(txnData)
35
- return [{"programId":get_program_id_from_log(allLogs[i]),
36
- "start":i,
37
- "end":get_end_log_index(txnData,i),
38
- 'stackHeight':get_stack_height_from_logs(allLogs[i]),
39
- 'events':[event.split(':')[0] for event in get_log_events(get_logs_from_index(txnData,index=i))],
40
- 'logs':get_logs_from_index(txnData,index=i)
41
- } for i in range(len(allLogs)) if 'invoke' in allLogs[i].lower()]
45
+ for i,log in enumerate(allLogs):
46
+ if 'invoke' in log.lower():
47
+ logits.append([])
48
+ logits[-1].append(log)
49
+ start = 0
50
+ for i,log in enumerate(logits):
51
+ length = len(log)
52
+ end = start+length
53
+ logits[i]={"programId":get_program_id_from_log(log[0]),
54
+ "start":start,
55
+ "end":end-1,
56
+ 'stackHeight':get_stack_height_from_logs(log[0]) or 1,
57
+ 'events':[event.split(':')[-1] or 'unknown' for event in get_log_events(log)],
58
+ 'vars':[event.split(':')[1:] or 'unknown' for event in get_log_events(log)],
59
+ 'logs':log}
60
+ start = end
61
+ return logits
42
62
  def split_log_for_instruction(log):
43
63
  return log.split('log:')[-1].split('Instruction:')[-1]
44
64
  def clean_split_string(string,delim=' '):
@@ -88,3 +108,47 @@ def findKeyValueIdInCatalog(key,value,txnData,programId=None):
88
108
  return [txn for txn in make_list(complete_catalog) if txn.get(key) == value]
89
109
  def find_account_in_catalog(account,catalog):
90
110
  return ifListGetSection([txn for txn in make_list(catalog) if account in txn.get('associatedAccounts')])
111
+ def associate_logs_with_instructions(txnData):
112
+ accountKeys = get_all_account_keys(txnData)
113
+ instructions = txnData['transaction']['message']['instructions']
114
+ innerInstructions = txnData['meta']['innerInstructions'][0]['instructions']
115
+ allLogs = txnData['meta']['logMessages']
116
+ for logIndex,log in enumerate(allLogs):
117
+ log_programId = log['programId']
118
+ log_stackHeight = log.get('stackHeight') # Default to 0 if stackHeight is missing
119
+ # Search for matching instructions by programId and stackHeight
120
+ for instIndex,allInstruction in enumerate([instructions,innerInstructions]):
121
+ for i,instruction in enumerate(allInstruction):
122
+ program_id_index = instruction.get('programIdIndex')
123
+ if program_id_index is not None:
124
+ instruction_program_id = accountKeys[program_id_index]
125
+ instruction_stack_height = instruction.get('stackHeight', 1)
126
+ if instruction_program_id == log_programId and instruction_stack_height == log_stackHeight:
127
+ # Add log data to the matching instruction
128
+ instruction['logs'] = log['logs']
129
+ instruction['event'] = None if log['events'] == [] else log['events'][0]
130
+ instruction['start'] = log['start']
131
+ instruction['end'] = log['end']
132
+ instruction['stackHeight'] = instruction_stack_height
133
+ instruction['programId'] = instruction_program_id
134
+ instruction['associatedAccounts'] = [accountKeys[index] for index in instruction['accounts']]
135
+ if instIndex == 0:
136
+ instructions[i] = instruction
137
+ else:
138
+ innerInstructions[i] = instruction
139
+ allLogs[logIndex].update(instruction)
140
+ txnData['transaction']['message']['instructions'] = instructions
141
+ txnData['meta']['innerInstructions'][0]['instructions'] = innerInstructions
142
+ txnData['meta']['logMessages'] = allLogs
143
+ return txnData
144
+ def update_initial_txnData(txnData):
145
+ accountKeys = get_all_account_keys(txnData)
146
+ txnData = update_balance_data(txnData)
147
+ txnData['transaction']['message']['instructions'] = [{**inst,"instructionIndex":instIndex,"programId":accountKeys[inst.get('programIdIndex')],"stackHeight":inst.get('stackHeight', 1),"associatedAccounts":[accountKeys[index] for index in inst['accounts']]} for instIndex,inst in enumerate(txnData['transaction']['message']['instructions'])]
148
+ txnData['meta']['innerInstructions'][0]['instructions'] = [{**inst,"instructionIndex":instIndex+len(txnData['transaction']['message']['instructions']),"programId":accountKeys[inst.get('programIdIndex')],"stackHeight":inst.get('stackHeight', 1),"associatedAccounts":[accountKeys[index] for index in inst['accounts']]} for instIndex,inst in enumerate(txnData['meta']['innerInstructions'][0]['instructions'])]
149
+ txnData['meta']['logMessages'] = get_all_logs(txnData)
150
+ return txnData
151
+ def get_for_program_ids_info(txnData):
152
+ txnData = update_initial_txnData(txnData)
153
+ txnData = associate_logs_with_instructions(txnData)
154
+ return txnData
@@ -1,9 +1,10 @@
1
1
  from solders.pubkey import Pubkey
2
2
  from solders.signature import Signature
3
3
  from spl.token.instructions import get_associated_token_address
4
+ TOKEN_PROGRAM_ID = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
4
5
 
5
6
  def pubkey_find_program_address(string,address,programId):
6
- return Pubkey.find_program_address([str(string).encode(), bytes(get_pubkey(address))],programId)
7
+ return Pubkey.find_program_address([str(string).encode(), bytes(get_pubkey(address))],get_pubkey(programId))
7
8
 
8
9
  def get_pubString(obj):
9
10
  return Pubkey.from_string(str(obj))
@@ -67,5 +68,5 @@ def derive_associated_bonding_curve(mint,programId=None):
67
68
  return get_associated_token_address(derive_bonding_curve(mint,programId)[0], get_pubkey(mint))
68
69
 
69
70
  def derive_bonding_curve(mint,programId=None):
70
- programId = programId or "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
71
+ programId = programId or TOKEN_PROGRAM_ID
71
72
  return pubkey_find_program_address("bonding-curve",mint,programId)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: abstract_solana
3
- Version: 0.0.0.16
3
+ Version: 0.0.0.18
4
4
  Home-page: https://github.com/AbstractEndeavors/abstract_solana
5
5
  Author: putkoff
6
6
  Author-email: partners@abstractendeavors.com
@@ -3,12 +3,12 @@ abstract_solana/account_key_utils.py,sha256=VMJd4GOTK1vn8UZsfXDnjxDOGoQWGY6fvflJ
3
3
  abstract_solana/constants.py,sha256=m1TsZLBAgcdM7Rrw_3_6YrFU9zdVFpghZXZKk7T38J8,1624
4
4
  abstract_solana/genesis_functions.py,sha256=2WRQUxN9j-dpLfYIBiX3URM-_uDGkh-eTy08Gi-qWgo,939
5
5
  abstract_solana/index_utils.py,sha256=Ed07BYTZWp-SVfpthAUqjRY00U3ZYldPCqd7LJy9AO8,1884
6
- abstract_solana/log_message_functions.py,sha256=bsofpTSMr0P5yEIUs2Y2Qsmwz_AQNn2HATTvz0IWodM,4603
6
+ abstract_solana/log_message_functions.py,sha256=vXcIk8TyMBcRyg2iM4UE0pQ3UsDkbvYswmRR-yrQO9g,8428
7
7
  abstract_solana/price_utils.py,sha256=BLkwFLhlsTHeW0NTdzCAUi2xhc2lX7SrHz5sslDbUrY,4288
8
- abstract_solana/pubkey_utils.py,sha256=ojBkJ5RDagnty-MtDRLT8Grfod_TdDFuxaEtKBR89Gk,1962
8
+ abstract_solana/pubkey_utils.py,sha256=TAYF74fKAuTBnqIP2SnA-BttO5uoHbxI9BRZRpGCMNY,2010
9
9
  abstract_solana/signature_data_parse.py,sha256=5AOMtJZADWcwR0JLDbd2kXZNzW129qeB0lvYUrE_tm0,1974
10
10
  abstract_solana/utils.py,sha256=Y1nyq-x7GqN09MEDrmiBM5iNDLJHDafFZ_lXrV0ua8k,348
11
- abstract_solana-0.0.0.16.dist-info/METADATA,sha256=-60JwpQUyojtrlUqGOt7eULtk5kso19gompdkF5W8so,924
12
- abstract_solana-0.0.0.16.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
13
- abstract_solana-0.0.0.16.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
14
- abstract_solana-0.0.0.16.dist-info/RECORD,,
11
+ abstract_solana-0.0.0.18.dist-info/METADATA,sha256=mGMlJ3pQ0hmW2pzsP8bNApIQZS_YYfIfKOqUTRHg2YI,924
12
+ abstract_solana-0.0.0.18.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
13
+ abstract_solana-0.0.0.18.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
14
+ abstract_solana-0.0.0.18.dist-info/RECORD,,