Skip to content

Commit 9b45c08

Browse files
authored
Merge pull request #643 from neonlabsorg/639-neon-api
Add implementation of neon_getSolanaTransactionByNeonTransaction. #639
2 parents f8a6c03 + d61c342 commit 9b45c08

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

proxy/indexer/indexer_db.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,6 @@ def get_contract_code(self, address) -> str:
134134

135135
def fill_account_info_by_indexer(self, neon_account: str, pda_account: str, code_account: str, slot: int):
136136
self._account_db.set_acc_indexer(neon_account, pda_account, code_account, slot)
137+
138+
def get_sol_sign_list_by_neon_sign(self, neon_sign: str) -> [str]:
139+
return self._txs_db.get_sol_sign_list_by_neon_sign(neon_sign)

proxy/indexer/transactions_db.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ def set_txs(self, neon_sign: str, used_ixs: [SolanaIxSignInfo]):
2222
VALUES(%s, %s, %s, %s) ON CONFLICT DO NOTHING''',
2323
rows)
2424

25+
def get_sol_sign_list_by_neon_sign(self, neon_sign: str) -> [str]:
26+
request = f'''
27+
SELECT sol_sign
28+
FROM {self._table_name} AS a
29+
WHERE neon_sign = %s
30+
'''
31+
32+
with self._conn.cursor() as cursor:
33+
cursor.execute(request, [neon_sign])
34+
values = cursor.fetchall()
35+
36+
if not values:
37+
return []
38+
39+
return [v[0] for v in values]
40+
2541

2642
class NeonTxsDB(BaseDB):
2743
def __init__(self):
@@ -112,3 +128,6 @@ def get_tx_list_by_sol_sign(self, sol_sign_list: [str]) -> [NeonTxFullInfo]:
112128
return []
113129

114130
return [self._tx_from_value(v) for v in values if v is not None]
131+
132+
def get_sol_sign_list_by_neon_sign(self, neon_sign: str) -> [str]:
133+
return self._sol_neon_txs_db.get_sol_sign_list_by_neon_sign(neon_sign)

proxy/memdb/memdb.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@ def get_logs(self, from_block, to_block, addresses, topics, block_hash):
5959

6060
def get_contract_code(self, address: str) -> str:
6161
return self._db.get_contract_code(address)
62+
63+
def get_sol_sign_list_by_neon_sign(self, neon_sign: str) -> [str]:
64+
return self._db.get_sol_sign_list_by_neon_sign(neon_sign)

proxy/plugin/solana_rest_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ def eth_sendRawTransaction(self, rawTrx):
386386
# self.error(f"eth_sendRawTransaction type(err): {type(err}}, Exception: {err}")
387387
raise
388388

389+
def neon_getSolanaTransactionByNeonTransaction(self, neonTxId: str) -> [str]:
390+
if not isinstance(neonTxId, str):
391+
return []
392+
return self._db.get_sol_sign_list_by_neon_sign(neonTxId)
393+
394+
389395

390396
class JsonEncoder(json.JSONEncoder):
391397
def default(self, obj):

0 commit comments

Comments
 (0)