-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
583dbc8
commit ff8af30
Showing
6 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from common.config import config | ||
|
||
|
||
class localconfig(config): | ||
|
||
ibc_addresses = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
EXCHANGE_BLD = "bld_blockchain" | ||
MINTSCAN_LABEL_BLD = "bld" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import logging | ||
import common.ibc.processor | ||
import bld.constants as co | ||
import common.ibc.processor | ||
import common.ibc.handle | ||
from bld.config_bld import localconfig | ||
from settings_csv import BLD_NODE | ||
|
||
|
||
def process_txs(wallet_address, elems, exporter): | ||
for elem in elems: | ||
process_tx(wallet_address, elem, exporter) | ||
|
||
|
||
def process_tx(wallet_address, elem, exporter): | ||
txinfo = common.ibc.processor.txinfo( | ||
wallet_address, elem, co.MINTSCAN_LABEL_BLD, localconfig.ibc_addresses, BLD_NODE, co.EXCHANGE_BLD) | ||
|
||
for msginfo in txinfo.msgs: | ||
result = common.ibc.processor.handle_message(exporter, txinfo, msginfo, localconfig.debug) | ||
if result: | ||
continue | ||
|
||
common.ibc.handle.handle_unknown_detect_transfers(exporter, txinfo, msginfo) | ||
|
||
return txinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from bld.config_bld import localconfig | ||
from common.progress import Progress | ||
|
||
SECONDS_PER_PAGE = 4 | ||
|
||
|
||
class ProgressBld(Progress): | ||
|
||
def __init__(self): | ||
super().__init__(localconfig) | ||
|
||
def set_estimate(self, count_pages): | ||
self.add_stage("default", count_pages, SECONDS_PER_PAGE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
""" | ||
usage: python3 report_bld.py <walletaddress> [--format all|cointracking|koinly|..] | ||
Prints transactions and writes CSV(s) to _reports/BLD*.csv | ||
""" | ||
|
||
import logging | ||
import pprint | ||
|
||
from bld.config_bld import localconfig | ||
from bld.progress_bld import SECONDS_PER_PAGE, ProgressBld | ||
from common import report_util | ||
from common.Cache import Cache | ||
from common.Exporter import Exporter | ||
from common.ExporterTypes import FORMAT_DEFAULT | ||
from settings_csv import TICKER_BLD, BLD_NODE | ||
import bld.processor | ||
import common.ibc.api_lcd | ||
|
||
|
||
def main(): | ||
wallet_address, export_format, txid, options = report_util.parse_args(TICKER_BLD) | ||
|
||
if txid: | ||
_read_options(options) | ||
exporter = txone(wallet_address, txid) | ||
exporter.export_print() | ||
if export_format != FORMAT_DEFAULT: | ||
report_util.export_format_for_txid(exporter, export_format, txid) | ||
else: | ||
exporter = txhistory(wallet_address, options) | ||
report_util.run_exports(TICKER_BLD, wallet_address, exporter, export_format) | ||
|
||
|
||
def _read_options(options): | ||
report_util.read_common_options(localconfig, options) | ||
logging.info("localconfig: %s", localconfig.__dict__) | ||
|
||
|
||
def wallet_exists(wallet_address): | ||
return common.ibc.api_lcd.LcdAPI(BLD_NODE).account_exists(wallet_address) | ||
|
||
|
||
def txone(wallet_address, txid): | ||
elem = common.ibc.api_lcd.LcdAPI(BLD_NODE).get_tx(txid) | ||
|
||
print("Transaction data:") | ||
pprint.pprint(elem) | ||
|
||
exporter = Exporter(wallet_address, localconfig, TICKER_BLD) | ||
txinfo = bld.processor.process_tx(wallet_address, elem, exporter) | ||
txinfo.print() | ||
return exporter | ||
|
||
|
||
def estimate_duration(wallet_address, options): | ||
max_txs = localconfig.limit | ||
return SECONDS_PER_PAGE * common.ibc.api_lcd.get_txs_pages_count(BLD_NODE, wallet_address, max_txs) | ||
|
||
|
||
def txhistory(wallet_address, options): | ||
# Configure localconfig based on options | ||
_read_options(options) | ||
if localconfig.cache: | ||
localconfig.ibc_addresses = Cache().get_ibc_addresses() | ||
logging.info("Loaded ibc_addresses from cache ...") | ||
|
||
max_txs = localconfig.limit | ||
progress = ProgressBld() | ||
exporter = Exporter(wallet_address, localconfig, TICKER_BLD) | ||
|
||
# Fetch count of transactions to estimate progress more accurately | ||
count_pages = common.ibc.api_lcd.get_txs_pages_count(BLD_NODE, wallet_address, max_txs, debug=localconfig.debug) | ||
progress.set_estimate(count_pages) | ||
|
||
# Fetch transactions | ||
elems = common.ibc.api_lcd.get_txs_all(BLD_NODE, wallet_address, progress, max_txs, debug=localconfig.debug) | ||
|
||
progress.report_message(f"Processing {len(elems)} transactions... ") | ||
bld.processor.process_txs(wallet_address, elems, exporter) | ||
|
||
if localconfig.cache: | ||
Cache().set_ibc_addresses(localconfig.ibc_addresses) | ||
return exporter | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters