abstract-solana 0.0.0.17__py3-none-any.whl → 0.0.0.19__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.

@@ -1,5 +1,6 @@
1
1
  from abstract_utilities import make_list
2
2
  import json,pprint
3
+ from .price_functions import *
3
4
  from .signature_data_parse import get_log_messages_from_txn,get_instructions_from_txn,get_inner_instructions_from_txn
4
5
  from .account_key_utils import get_all_account_keys
5
6
  from .constants import TOKEN_PROGRAM_ID
@@ -30,15 +31,35 @@ def get_end_log_index(txnData,index):
30
31
  if 'invoke' in log.lower():
31
32
  return index+1+i
32
33
  return len(allLogs)
33
- def get_for_program_ids_info(txnData):
34
+ def get_stack_height_from_logs(logs):
35
+ for log in make_list(logs):
36
+ if 'invoke' in log.lower():
37
+ return int(log.split(' ')[-1][1:-1])
38
+ def get_program_id_from_log(logs):
39
+ for log in make_list(logs):
40
+ if 'invoke' in log.lower():
41
+ return log.split(' ')[1]
42
+
43
+ def get_all_logs(txnData):
44
+ logits = []
34
45
  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()]
46
+ for i,log in enumerate(allLogs):
47
+ if 'invoke' in log.lower():
48
+ logits.append([])
49
+ logits[-1].append(log)
50
+ start = 0
51
+ for i,log in enumerate(logits):
52
+ length = len(log)
53
+ end = start+length
54
+ logits[i]={"programId":get_program_id_from_log(log[0]),
55
+ "start":start,
56
+ "end":end-1,
57
+ 'stackHeight':get_stack_height_from_logs(log[0]) or 1,
58
+ 'events':[event.split(':')[-1] or 'unknown' for event in get_log_events(log)],
59
+ 'vars':[event.split(':')[1:] or 'unknown' for event in get_log_events(log)],
60
+ 'logs':log}
61
+ start = end
62
+ return logits
42
63
  def split_log_for_instruction(log):
43
64
  return log.split('log:')[-1].split('Instruction:')[-1]
44
65
  def clean_split_string(string,delim=' '):
@@ -88,3 +109,47 @@ def findKeyValueIdInCatalog(key,value,txnData,programId=None):
88
109
  return [txn for txn in make_list(complete_catalog) if txn.get(key) == value]
89
110
  def find_account_in_catalog(account,catalog):
90
111
  return ifListGetSection([txn for txn in make_list(catalog) if account in txn.get('associatedAccounts')])
112
+ def associate_logs_with_instructions(txnData):
113
+ accountKeys = get_all_account_keys(txnData)
114
+ instructions = txnData['transaction']['message']['instructions']
115
+ innerInstructions = txnData['meta']['innerInstructions'][0]['instructions']
116
+ allLogs = txnData['meta']['logMessages']
117
+ for logIndex,log in enumerate(allLogs):
118
+ log_programId = log['programId']
119
+ log_stackHeight = log.get('stackHeight') # Default to 0 if stackHeight is missing
120
+ # Search for matching instructions by programId and stackHeight
121
+ for instIndex,allInstruction in enumerate([instructions,innerInstructions]):
122
+ for i,instruction in enumerate(allInstruction):
123
+ program_id_index = instruction.get('programIdIndex')
124
+ if program_id_index is not None:
125
+ instruction_program_id = accountKeys[program_id_index]
126
+ instruction_stack_height = instruction.get('stackHeight', 1)
127
+ if instruction_program_id == log_programId and instruction_stack_height == log_stackHeight:
128
+ # Add log data to the matching instruction
129
+ instruction['logs'] = log['logs']
130
+ instruction['event'] = None if log['events'] == [] else log['events'][0]
131
+ instruction['start'] = log['start']
132
+ instruction['end'] = log['end']
133
+ instruction['stackHeight'] = instruction_stack_height
134
+ instruction['programId'] = instruction_program_id
135
+ instruction['associatedAccounts'] = [accountKeys[index] for index in instruction['accounts']]
136
+ if instIndex == 0:
137
+ instructions[i] = instruction
138
+ else:
139
+ innerInstructions[i] = instruction
140
+ allLogs[logIndex].update(instruction)
141
+ txnData['transaction']['message']['instructions'] = instructions
142
+ txnData['meta']['innerInstructions'][0]['instructions'] = innerInstructions
143
+ txnData['meta']['logMessages'] = allLogs
144
+ return txnData
145
+ def update_initial_txnData(txnData):
146
+ accountKeys = get_all_account_keys(txnData)
147
+ txnData = update_balance_data(txnData)
148
+ 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'])]
149
+ 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'])]
150
+ txnData['meta']['logMessages'] = get_all_logs(txnData)
151
+ return txnData
152
+ def get_for_program_ids_info(txnData):
153
+ txnData = update_initial_txnData(txnData)
154
+ txnData = associate_logs_with_instructions(txnData)
155
+ return txnData
@@ -1,6 +1,7 @@
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
7
  return Pubkey.find_program_address([str(string).encode(), bytes(get_pubkey(address))],get_pubkey(programId))
@@ -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.17
3
+ Version: 0.0.0.19
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=Iy2dZGEDAcV7I1Y6IufLXUqnsqMdurBP16B7KL4LQa4,8459
7
7
  abstract_solana/price_utils.py,sha256=BLkwFLhlsTHeW0NTdzCAUi2xhc2lX7SrHz5sslDbUrY,4288
8
- abstract_solana/pubkey_utils.py,sha256=-AEwi_pM5PNoq5912t8O52rCkPlnh823SFerBvhnSRM,1974
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.17.dist-info/METADATA,sha256=NLGhYe9YneGDjFMvNDC7U5JCl0F2IPduRUfzcJXmuw4,924
12
- abstract_solana-0.0.0.17.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
13
- abstract_solana-0.0.0.17.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
14
- abstract_solana-0.0.0.17.dist-info/RECORD,,
11
+ abstract_solana-0.0.0.19.dist-info/METADATA,sha256=gw0vSJsdv83gbwBzRjiLJj6W5ho1diUsyUIEgDe1Du4,924
12
+ abstract_solana-0.0.0.19.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
13
+ abstract_solana-0.0.0.19.dist-info/top_level.txt,sha256=SsJYent8eZQ0FU2jmP8wTj7aFZFhNwxxP-5cCTQ2B-o,16
14
+ abstract_solana-0.0.0.19.dist-info/RECORD,,