1
0
personal-data/personal_data/fetchers/defi_partisia_blockchain.py

50 lines
1.6 KiB
Python
Raw Normal View History

2024-08-22 13:35:06 +00:00
"""# Partisia Blockchain Scraper
Currently only scrapes certain interesting addresses.
TODO:
- Do something with this interesting endpoint: <https://backend.browser.partisiablockchain.com/supply/top>
"""
2024-04-16 21:23:27 +00:00
import dataclasses
2024-04-23 20:58:25 +00:00
import logging
2024-05-15 22:47:42 +00:00
from collections.abc import Iterator, Mapping
2024-04-16 21:23:27 +00:00
2024-06-02 16:52:33 +00:00
import fin_depo
2024-04-23 20:58:25 +00:00
2024-06-02 21:16:11 +00:00
from personal_data.data import DeduplicateMode, Scraper
2024-04-16 21:23:27 +00:00
logger = logging.getLogger(__name__)
2024-05-21 21:37:59 +00:00
PBC_FOUNDATION_CONTRACT_ADDRESSES = [
('012635f1c0a9bffd59853c6496e1c26ebda0e2b4da', 'Foundation Sales'),
('0135edec2c9fed33f45cf2538dc06ba139c4bb8f62', 'Foundation Team'),
('01ad44bb0277a8df16408006c375a6fa015bb22c97', 'Foundation Eco-System'),
2024-08-22 13:35:06 +00:00
('016fe3c61bf8f8bd623deebb74cd80fcedc646b605', 'Foundation Reserve'),
2024-05-21 21:37:59 +00:00
]
@dataclasses.dataclass(frozen=True)
class PbcFoundationBalance(Scraper):
dataset_name = 'pbc_foundation_balances'
deduplicate_mode = DeduplicateMode.BY_ALL_COLUMNS
deduplicate_ignore_columns = [
'contract.update_time',
'contract.name',
'contract.state.balance',
]
def scrape(self) -> Iterator[Mapping[str, object]]:
2024-06-02 16:52:33 +00:00
client = fin_depo.defi_partisia_blockchain.PbcClient(self.session)
2024-05-21 21:37:59 +00:00
for address, contract_name in PBC_FOUNDATION_CONTRACT_ADDRESSES:
contract_state, update_time = client.get_contract_state(address)
yield {
'contract.update_time': update_time,
'contract.name': contract_name,
'contract.address': address,
'contract.state.nonce': contract_state['nonce'],
'contract.state.balance': contract_state['remainingTokens'],
}