Skip to content

Commit

Permalink
interim
Browse files Browse the repository at this point in the history
  • Loading branch information
mihanixa1 committed May 27, 2024
1 parent 7e5c5c1 commit 82dd205
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 4 additions & 2 deletions services/pg_tx_fetcher/src/app/lib/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from moralis import evm_api

from app.cfg import PgTxFetcherConfig
# from app.cfg import PgTxFetcherConfig


@dataclasses.dataclass
Expand All @@ -14,6 +14,7 @@ class MoralisNativeTransaction:
input: str
from_address: str
to_address: str

value: int
receipt_status: int
tx_hash: str
Expand Down Expand Up @@ -41,7 +42,8 @@ def fetch_batch(tx_from: str, chain_id: int, block_from: int, step: int = 1) ->
"to_block": block_from + step
}
result = evm_api.transaction.get_wallet_transactions(
api_key=PgTxFetcherConfig.MORALIS_API_KEY,
api_key="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImE1ZTgzNGFhLWM1NGUtNDQ2Zi04Y2U1LTM0NDFkNGQ4YjAyMCIsIm9yZ0lkIjoiMzg4Mzg1IiwidXNlcklkIjoiMzk5MDg5IiwidHlwZUlkIjoiYzA1NDY3NjEtYTVkZi00OGUyLWE4OWUtMWNjM2Q0NjA2MTFhIiwidHlwZSI6IlBST0pFQ1QiLCJpYXQiOjE3MTMzNzE2MDUsImV4cCI6NDg2OTEzMTYwNX0.W9-i2c5ai8ukWMRtM9XHmK9Pbvd83kjB1bWokFvdZHw",
# api_key=PgTxFetcherConfig.MORALIS_API_KEY,
params=params,
)['result']
return list(map(lambda x: MoralisNativeTransaction(**{
Expand Down
12 changes: 9 additions & 3 deletions services/pg_tx_fetcher/src/app/lib/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@
from app.cfg import PostgresClientConfig


def get_connection() -> pg_conn:
def _get_connection() -> pg_conn:
conn = pg.connect(host=PostgresClientConfig.POSTGRES_HOST,
databaset=PostgresClientConfig.POSTGRES_DB,
user=PostgresClientConfig.POSTGRES_USER)
conn.autocommit = True
return conn


select_interaction_by_hash_sql: str = """



_select_interaction_by_hash_sql: str = """
select interaction_hash, chain_id, selector, tx_to
from public.interaction
where
interaction_hash = '%x';"""


select_max_block_id_for_holder_for_interaction_sql: str = """
_select_max_block_id_for_holder_for_interaction_sql: str = """
select max(block_id)
from public.moralis_scan_checkpoints
where
interaction_hash = '%x' and
eth_address = '%x';"""


def load_interactions(interaction_hash: str, ):
...

0 comments on commit 82dd205

Please sign in to comment.