Skip to content

Commit

Permalink
Merge pull request #32 from marmarachain/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
rumeysayilmaz committed May 26, 2022
2 parents 3c905bc + ca7e4b7 commit 83680e4
Show file tree
Hide file tree
Showing 8 changed files with 799 additions and 640 deletions.
2 changes: 1 addition & 1 deletion src/build/settings/base.json
Expand Up @@ -2,6 +2,6 @@
"app_name": "MarmaraConnector",
"author": "Marmara Credit Loops",
"main_module": "src/main/python/mainApp.py",
"version": "0.3.9",
"version": "0.4.0",
"public_settings": ["app_name", "author", "version"]
}
22 changes: 16 additions & 6 deletions src/main/python/api_request.py
Expand Up @@ -8,8 +8,9 @@
marmara_api_url = "https://api.github.com/repos/marmarachain/marmara/releases/latest"
app_api_url = "https://api.github.com/repos/marmarachain/marmara-connector/releases/latest"

coinpaprika = ['https://api.coinpaprika.com/v1/coins/mcl-marmara-credit-loops/markets?quotes=USD,TRY,BTC,EUR,RUB',
'https://api.coinpaprika.com/v1/tickers/mcl-marmara-credit-loops?quotes=USD,TRY,BTC,EUR,RUB']
coinpaprika = {'market': 'https://api.coinpaprika.com/v1/coins/mcl-marmara-credit-loops/markets?quotes=USD,TRY,BTC,EUR,RUB',
'tickers': 'https://api.coinpaprika.com/v1/tickers/mcl-marmara-credit-loops?quotes=',
'fiatlist': ['USD', 'TRY', 'BTC', 'EUR', 'RUB']}
exchange_market_api_list = {'coinpaprika': coinpaprika}
"""
requests to get the latest releases' tag_name of a git api url
Expand Down Expand Up @@ -73,13 +74,23 @@ def get_marmara_stats():
def mcl_exchange_market(api_list_key):
api_url_list = exchange_market_api_list.get(api_list_key)
response_list = []
for api_url in api_url_list:
tickers_list = {}
try:
response = requests.get(api_url_list.get('market'), timeout=5)
response_list.append(response.json())
except Exception as e:
logging.error(e)
response_list.append('error')

for app_api_url in api_url_list.get('fiatlist'):
app_api_url = api_url_list.get('tickers') + app_api_url
try:
response = requests.get(api_url, timeout=5)
response_list.append(response.json())
response = requests.get(app_api_url, timeout=5)
tickers_list.update(response.json().get('quotes'))
except Exception as e:
logging.error(e)
response_list.append('error')
response_list.append(tickers_list)
return response_list


Expand Down Expand Up @@ -135,4 +146,3 @@ def get_block_hash(hash, index):
except Exception:
return


110 changes: 75 additions & 35 deletions src/main/python/mainApp.py
Expand Up @@ -163,13 +163,16 @@ def __init__(self, parent=None):
self.looprequest_search_button.clicked.connect(self.search_marmarareceivelist)
self.request_date_checkBox.clicked.connect(self.set_request_date_state)
self.request_dateTimeEdit.setDateTime(QDateTime.currentDateTime())

self.contactpk_otherpk_looprequest_comboBox.currentTextChanged.connect(self.get_selected_contact_pukey)
# -----Make credit Loop Request
self.contactpk_makeloop_comboBox.currentTextChanged.connect(self.get_selected_contact_loop_pubkey)
self.contactpk_transferrequest_comboBox.currentTextChanged.connect(self.get_selected_contact_transfer_pubkey)
self.make_credit_loop_matures_dateTimeEdit.setMinimumDateTime(QDateTime.currentDateTime())
self.send_loop_request_button.clicked.connect(self.marmarareceive)
self.send_transfer_request_button.clicked.connect(self.marmararecieve_transfer)
self.looprequest_otherpk_radioButton.clicked.connect(self.change_visibilty_looprequestpubkey)
self.looprequest_currentpk_radioButton.clicked.connect(self.change_visibilty_looprequestpubkey)
self.change_visibilty_looprequestpubkey()
# -----Total Credit Loops page -----
self.activeloops_search_button.clicked.connect(self.search_active_loops)
self.holderloops_search_button.clicked.connect(self.marmaraholderloops)
Expand Down Expand Up @@ -373,7 +376,6 @@ def check_app_version_errtout(self, out):
self.custom_message(self.tr('Connection Error'), self.tr('Check your internet Connection '), 'information',
QMessageBox.Information)


def read_lang_setting(self):
language = configuration.ApplicationConfig().get_value('USER', 'lang')
if language:
Expand Down Expand Up @@ -1115,6 +1117,7 @@ def refresh_side_panel_result(self, result_out):
def update_datetime_edit_maxdates(self):
self.transactions_startdate_dateTimeEdit.setMaximumDateTime(QDateTime.currentDateTime())
self.earning_stop_dateTimeEdit.setMaximumDateTime(QDateTime.currentDateTime())
self.earning_start_dateTimeEdit.setMaximumDateTime(QDateTime.currentDateTime())
self.earning_stop_dateTimeEdit.setDateTime(QDateTime.currentDateTime())
self.transactions_endtdate_dateTimeEdit.setDateTime(QDateTime.currentDateTime())
self.make_credit_loop_matures_dateTimeEdit.setMinimumDateTime(QDateTime.currentDateTime())
Expand Down Expand Up @@ -1589,7 +1592,7 @@ def download_bootstrap_via_webbrowser(self):
def browse_bootstrap(self):
home_path = str(pathlib.Path.home())
get_bootstrap_path = QFileDialog.getOpenFileName(self, caption=self.tr('select bootstrap.tar.gz'),
directory=home_path, filter='*.tar.gz')
directory=home_path, filter='*.tar.gz')
bootstrap_path = str(get_bootstrap_path).split(',')[0].replace('(', '').replace("'", '')
if platform.system() == 'Darwin':
destination_path = os.environ['HOME'] + '/Library/Application Support/Komodo/MCL'
Expand Down Expand Up @@ -1751,7 +1754,6 @@ def toggle_textbrowser(self):
self.rescan_checkBox.setVisible(True)
self.reindex_checkBox.setVisible(True)


# ------------------
# Chain --- wallet Address Add, import
# -------------------
Expand Down Expand Up @@ -2125,7 +2127,8 @@ def getaddresstxids(self):
address = self.currentaddress_value.text()
start_date = self.transactions_startdate_dateTimeEdit.dateTime()
end_date = self.transactions_endtdate_dateTimeEdit.dateTime()
start_height = int(self.currentblock_value_label.text()) - int(self.change_datetime_to_block_age(start_date))
start_height = int(self.currentblock_value_label.text()) - int(
self.change_datetime_to_block_age(start_date))
end_height = int(self.currentblock_value_label.text()) - int(self.change_datetime_to_block_age(end_date))
if start_height < end_height:
if end_date > datetime.now():
Expand Down Expand Up @@ -2236,8 +2239,39 @@ def set_request_date_state(self):
self.request_dateTimeEdit.setDateTime(QDateTime.currentDateTime())
self.request_dateTimeEdit.setMaximumDateTime(QDateTime.currentDateTime())

@pyqtSlot()
def change_visibilty_looprequestpubkey(self):
if self.looprequest_currentpk_radioButton.isChecked():
self.looprequest_otherpk_lineEdit.setHidden(True)
self.contactpk_otherpk_looprequest_comboBox.setHidden(True)
self.transferrequests_tableWidget.setColumnHidden(0, False)
self.loop_request_tableWidget.setColumnHidden(0, False)
self.loop_request_tableWidget.setRowCount(0)
self.transferrequests_tableWidget.setRowCount(0)
if self.looprequest_otherpk_radioButton.isChecked():
self.looprequest_otherpk_lineEdit.setHidden(False)
self.looprequest_otherpk_lineEdit.clear()
self.contactpk_otherpk_looprequest_comboBox.setHidden(False)
self.loop_request_tableWidget.setColumnHidden(0, True)
self.transferrequests_tableWidget.setColumnHidden(0, True)
self.loop_request_tableWidget.setRowCount(0)
self.transferrequests_tableWidget.setRowCount(0)
self.get_contact_names_pubkeys()

@pyqtSlot()
def get_selected_contact_pukey(self):
contacts_data = configuration.ContactsSettings().read_csv_file()
selected_contactpubkey_transfer = contacts_data[self.contactpk_otherpk_looprequest_comboBox.currentIndex()]
if selected_contactpubkey_transfer[2] != 'Pubkey':
self.looprequest_otherpk_lineEdit.setText(selected_contactpubkey_transfer[2])
if selected_contactpubkey_transfer[2] == 'Pubkey':
self.looprequest_otherpk_lineEdit.clear()

@pyqtSlot()
def search_marmarareceivelist(self):
pubkey = self.current_pubkey_value.text()
if self.looprequest_otherpk_radioButton.isChecked():
pubkey = self.looprequest_otherpk_lineEdit.text()
if self.request_date_checkBox.checkState():
maxage = '1440'
else:
Expand All @@ -2248,7 +2282,7 @@ def search_marmarareceivelist(self):
logging.info('querying incoming loop requests with marmarareceivelist')
self.worker_marmarareceivelist = marmarachain_rpc.RpcHandler()
method = cp.marmarareceivelist
params = [self.current_pubkey_value.text(), str(maxage)]
params = [pubkey, str(maxage)]
self.worker_thread(self.thread_marmarareceivelist, self.worker_marmarareceivelist, method, params,
self.search_marmarareceivelist_result)

Expand All @@ -2258,26 +2292,30 @@ def search_marmarareceivelist_result(self, result_out):
self.bottom_info(self.tr('finished searching incoming loop requests'))
logging.info('finished querying incoming loop requests')
result = json.loads(str(result_out[0]))
self.loop_request_tableWidget.setRowCount(len(result))
loop_create_request_list = []
loop_transfer_request_list = []
for item in result:
tx_id = item.get('txid')
func_id = item.get('funcid')
amount = item.get('amount')
matures = item.get('matures')
maturity = self.change_block_to_date(matures)
receive_pk = item.get('receivepk')
receive_pubkey = self.check_pubkey_contact_name(receive_pk)
# issuer_pk = item.get('issuerpk')
if func_id == 'B':
row = [tx_id, amount, maturity, receive_pubkey, receive_pk]
loop_create_request_list.append(row)
if func_id == 'R':
row = [tx_id, amount, maturity, receive_pubkey, receive_pk]
loop_transfer_request_list.append(row)
self.set_credit_request_table(loop_create_request_list)
self.set_transfer_request_table(loop_transfer_request_list)
if type(result) == list:
self.loop_request_tableWidget.setRowCount(len(result))
loop_create_request_list = []
loop_transfer_request_list = []
for item in result:
tx_id = item.get('txid')
func_id = item.get('funcid')
amount = item.get('amount')
matures = item.get('matures')
maturity = self.change_block_to_date(matures)
receive_pk = item.get('receivepk')
receive_pubkey = self.check_pubkey_contact_name(receive_pk)
# issuer_pk = item.get('issuerpk')
if func_id == 'B':
row = [tx_id, amount, maturity, receive_pubkey, receive_pk]
loop_create_request_list.append(row)
if func_id == 'R':
row = [tx_id, amount, maturity, receive_pubkey, receive_pk]
loop_transfer_request_list.append(row)
self.set_credit_request_table(loop_create_request_list)
self.set_transfer_request_table(loop_transfer_request_list)
if type(result) == dict:
if result.get('result') == 'error':
self.bottom_err_info(result.get('error'))
elif result_out[1]:
self.bottom_err_info(result_out[1])

Expand Down Expand Up @@ -2774,15 +2812,18 @@ def get_selected_contact_address(self):
def get_contact_names_pubkeys(self):
self.contactpk_makeloop_comboBox.clear()
self.contactpk_transferrequest_comboBox.clear()
self.contactpk_otherpk_looprequest_comboBox.clear()
self.make_credit_loop_senderpubkey_lineEdit.clear()
self.transfer_senderpubkey_lineEdit.clear()
self.contactpk_makeloop_comboBox.addItem(self.tr('Contacts'))
self.contactpk_transferrequest_comboBox.addItem(self.tr('Contacts'))
self.contactpk_otherpk_looprequest_comboBox.addItem(self.tr('Contacts'))
contacts_data = configuration.ContactsSettings().read_csv_file()
for name in contacts_data:
if name[0] != 'Name':
self.contactpk_makeloop_comboBox.addItem(name[0])
self.contactpk_transferrequest_comboBox.addItem(name[0])
self.contactpk_otherpk_looprequest_comboBox.addItem(name[0])

@pyqtSlot()
def get_selected_contact_loop_pubkey(self):
Expand Down Expand Up @@ -3120,7 +3161,6 @@ def earnings_output_info(self, output):
if output == 'calculating earnings':
self.bottom_info(self.tr('Calculating earnings for normal and activated addresses'))


@pyqtSlot()
def pay_for_export(self):
if self.earning_stats_tableWidget.rowCount() > 0:
Expand Down Expand Up @@ -3249,18 +3289,18 @@ def update_exchange_table(self):

def update_ticker_table(self):
fiat = self.market_fiat_comboBox.currentText()
price = ('%.8f' % self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('price'))
volume = ('%.8f' % self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('volume_24h'))
price = ('%.8f' % self.mcl_exchange_ticker_result.get(fiat).get('price'))
volume = ('%.8f' % self.mcl_exchange_ticker_result.get(fiat).get('volume_24h'))
self.ticker_price_label_value.setText(str(price))
self.ticker_volume_label_value.setText(str(volume))
self.ticker_1hour_label_value.setText(
str(self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('percent_change_1h')))
str(self.mcl_exchange_ticker_result.get(fiat).get('percent_change_1h')))
self.ticker_24hour_label_value.setText(
str(self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('percent_change_24h')))
str(self.mcl_exchange_ticker_result.get(fiat).get('percent_change_24h')))
self.ticker_1week_label_value.setText(
str(self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('percent_change_7d')))
str(self.mcl_exchange_ticker_result.get(fiat).get('percent_change_7d')))
self.ticker_1month_label_value.setText(
str(self.mcl_exchange_ticker_result.get('quotes').get(fiat).get('percent_change_30d')))
str(self.mcl_exchange_ticker_result.get(fiat).get('percent_change_30d')))
if self.ticker_price_label_value.text():
self.mcl_amount_lineEdit.setEnabled(True)
self.usd_amount_lineEdit.setEnabled(True)
Expand All @@ -3277,15 +3317,15 @@ def market_fiat_changed(self):
def calculate_usd_price(self):
if self.mcl_amount_lineEdit.text():
current_fiat = self.market_fiat_comboBox.currentText()
price = float(self.mcl_exchange_ticker_result.get('quotes').get(current_fiat).get('price'))
price = float(self.mcl_exchange_ticker_result.get(current_fiat).get('price'))
calculation = float(self.mcl_amount_lineEdit.text()) * price
self.usd_amount_lineEdit.setText(str('%.8f' % calculation))

@pyqtSlot()
def calculate_mcl_price(self):
if self.usd_amount_lineEdit.text():
current_fiat = self.market_fiat_comboBox.currentText()
price = float(self.mcl_exchange_ticker_result.get('quotes').get(current_fiat).get('price'))
price = float(self.mcl_exchange_ticker_result.get(current_fiat).get('price'))
calculation = float(self.usd_amount_lineEdit.text()) / price
self.mcl_amount_lineEdit.setText(str('%.8f' % calculation))

Expand Down

0 comments on commit 83680e4

Please sign in to comment.