Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and ercv2 boilerplate #2395

Merged
merged 44 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
d574f9d
rename variable to something more obvious
smk762 Dec 15, 2023
44a1e6e
update variable to something more obvious
smk762 Dec 15, 2023
7bbf144
use generalised async func for orderbook
smk762 Dec 16, 2023
e974d29
complete async orderbook
smk762 Dec 16, 2023
2c09414
make bestorders async
smk762 Dec 17, 2023
5e241b2
refactor utx_merge_params
smk762 Dec 17, 2023
49cb990
clean up
smk762 Dec 17, 2023
17691a9
adds peerid to settings > about
smk762 Dec 17, 2023
cde14c7
add log
smk762 Dec 17, 2023
bcf3275
show segwit in simple mode
smk762 Dec 17, 2023
fa1e8d6
add ercv2 activation functions
smk762 Dec 17, 2023
88224f2
rename variable for clarity
smk762 Dec 18, 2023
eb099a1
add note for segwit self pair bug
smk762 Dec 18, 2023
33c4d4b
update api
smk762 Dec 19, 2023
d5e1900
rm logs
smk762 Dec 19, 2023
d3e69a2
rm comments
smk762 Dec 19, 2023
f89d124
tweak logs
smk762 Dec 19, 2023
9950a91
fix fallback_swap_contract variable
smk762 Dec 19, 2023
f261c90
add logs and id in req
smk762 Dec 19, 2023
336d560
add logs and id in req
smk762 Dec 19, 2023
e554766
add logs
smk762 Dec 19, 2023
62891f4
tweak logs
smk762 Dec 19, 2023
00f95b3
update default coins
smk762 Dec 19, 2023
5873a66
twaek logs
smk762 Dec 20, 2023
306b8db
add queued activation
smk762 Dec 20, 2023
427fdc8
fix moved function, dont use new methods
smk762 Dec 20, 2023
4cd0c92
fix conflicts
smk762 Dec 20, 2023
fe122ef
update autogen ts files
smk762 Dec 20, 2023
d7faa7d
add wording to faq
smk762 Dec 20, 2023
cbfb63b
add qml function for block url endpoint
smk762 Dec 20, 2023
aaa5ce0
rm QRC option for custom coins
smk762 Dec 20, 2023
8b1f6ca
coin_config -> coin_config_t
smk762 Dec 20, 2023
eba328e
Matic -> PLG20
smk762 Dec 20, 2023
6e802ac
fix custom coin import
smk762 Dec 20, 2023
d02c9fb
Merge branch 'v7-dev' into activation-v2-boilerplate
smk762 Dec 20, 2023
cae8416
fix CI reference error
smk762 Dec 20, 2023
5901b98
fix matic assignment, add links in support
smk762 Dec 20, 2023
f74a836
update ts
smk762 Dec 20, 2023
dbd7eb1
fix false positive for already init coins
smk762 Dec 20, 2023
63da539
fix type loading
smk762 Dec 20, 2023
5f84480
hide option for standard coins
smk762 Dec 21, 2023
c7dff8d
update var names
smk762 Dec 21, 2023
33b2558
fix zhtlc sync percentage display
smk762 Dec 21, 2023
b123f69
restore update checker
smk762 Dec 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ endif ()
##! We fetch our dependencies
if (APPLE)
FetchContent_Declare(mm2
URL https://sdk.devbuilds.komodo.earth/dev/mm2_6d7d05f-mac-x86-64.zip)
URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-mac-x86-64.zip)
elseif (UNIX AND NOT APPLE)
FetchContent_Declare(mm2
URL https://sdk.devbuilds.komodo.earth/dev/mm2_6d7d05f-linux-x86-64.zip)
URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-linux-x86-64.zip)
else ()
FetchContent_Declare(mm2
URL https://sdk.devbuilds.komodo.earth/dev/mm2_6d7d05f-win-x86-64.zip)
URL https://sdk.devbuilds.komodo.earth/main/mm2_b0fd99e-win-x86-64.zip)
endif ()

#FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip)
Expand Down
6 changes: 6 additions & 0 deletions atomic_defi_design/Dex/Components/CoinMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Menu {

MenuItem {
id: disable_action
height: 40
text: qsTr("Disable %1", "TICKER").arg(ticker)
onTriggered: API.app.disable_coins([ticker])
enabled: can_disable
Expand All @@ -41,22 +42,27 @@ Menu {
restart_modal.open()
}
enabled: disable_action.enabled && API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_custom_coin
visible: enabled
height: enabled ? 40 : 0
}

MenuItem {
height: 40
enabled: !General.prevent_coin_disabling.running
text: qsTr("Disable all %1 assets").arg(type)
onTriggered: API.app.disable_coins(API.app.portfolio_pg.get_all_coins_by_type(type))
}

MenuItem {
height: 40
enabled: !General.prevent_coin_disabling.running
text: qsTr("Disable all assets")
onTriggered: API.app.disable_coins(API.app.portfolio_pg.get_all_enabled_coins())
}

MenuItem
{
height: 40
enabled: !General.prevent_coin_disabling.running
text: qsTr("Disable 0 balance assets")
onTriggered: API.app.disable_no_balance_coins()
Expand Down
114 changes: 60 additions & 54 deletions atomic_defi_design/Dex/Constants/General.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ QtObject {
readonly property string custom_coin_icons_path: os_file_prefix + API.app.settings_pg.get_custom_coins_icons_path() + "/"
readonly property string providerIconsPath: image_path + "providers/"

/* Timers */
property Timer prevent_coin_disabling: Timer { interval: 5000 }

function coinIcon(ticker)
{
if (ticker === "" || ticker === "All" || ticker===undefined)
Expand Down Expand Up @@ -67,19 +70,12 @@ QtObject {
}

function coinName(ticker) {
if(ticker === "" || ticker === "All" || ticker===undefined) {
return ""
} else {
const name = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).name
return name
}
return (ticker === "" || ticker === "All" || ticker===undefined) ? "" : API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).name
}

function canSend(ticker, progress=100)
{
if (!API.app.wallet_pg.send_available) return false
if (isZhtlc(ticker) && progress < 100) return false
return true
return !API.app.wallet_pg.send_available ? false : progress < 100 ? false : true
}

function isWalletOnly(ticker)
Expand All @@ -92,78 +88,84 @@ QtObject {
return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).is_faucet_coin
}

function isCoinWithMemo(ticker) {
const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker)
return coin_info.has_memos
function isCoinWithMemo(ticker)
{
return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker).has_memos
}

function getLanguage()
{
return API.app.settings_pg.lang
}

function isZhtlc(ticker)
function isZhtlc(coin)
{
const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker)
return coin_info.is_zhtlc_family
return API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin).is_zhtlc_family
}

function isZhtlcReady(ticker)
function isZhtlcReady(coin)
{
if (!isZhtlc(ticker)) return true
let activation_status = API.app.get_zhtlc_status(ticker)
let progress = zhtlcActivationProgress(activation_status, ticker)
if (progress == 100) return true
return false
return !isZhtlc(coin) ? true : (zhtlcActivationProgress(coin) == 100) ? true : false
}

function zhtlcActivationProgress(activation_status, coin='ARRR')
{
let progress = 100
if (!activation_status.hasOwnProperty("result")) return progress
const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(coin)
let block_offset = coin_info.checkpoint_height
if (!isZhtlc(coin)) return progress
if (!activation_status.hasOwnProperty("result"))
{
return progress
}
let status = activation_status.result.status
let details = activation_status.result.details
// use range from checkpoint block to present

if (!status)
{
return -1
return 0
}
else if (status == "Ok")
{
if (details.hasOwnProperty("error"))
{
console.log("["+coin+"] [zhtlcActivationProgress] Error enabling: " + JSON.stringify(details.error))
return 0
}
}
else if (status == "InProgress")
{
if (details.hasOwnProperty("UpdatingBlocksCache"))
{
block_offset = details.UpdatingBlocksCache.first_sync_block.actual
let n = details.UpdatingBlocksCache.current_scanned_block - block_offset
let d = details.UpdatingBlocksCache.latest_block - block_offset
progress = 5 + parseInt(n/d*20)
let current = details.UpdatingBlocksCache.current_scanned_block
let latest = details.UpdatingBlocksCache.latest_block
let abs_pct = parseFloat(current/latest)
progress = parseInt(15 * abs_pct)
// console.log("["+coin+"] [zhtlcActivationProgress] UpdatingBlocksCache ["+current+"/"+latest+" * "+abs_pct+" | "+progress+"%]: " + JSON.stringify(details.UpdatingBlocksCache))
}
else if (details.hasOwnProperty("BuildingWalletDb"))
{
block_offset = details.BuildingWalletDb.first_sync_block.actual
let n = details.BuildingWalletDb.current_scanned_block - block_offset
let d = details.BuildingWalletDb.latest_block - block_offset
progress = 45 + parseInt(n/d*60)
if (progress > 95) {
progress = 95
let current = details.BuildingWalletDb.current_scanned_block
let latest = details.BuildingWalletDb.latest_block
let abs_pct = parseFloat(current/latest)
progress = parseInt(98 * abs_pct)
// console.log("["+coin+"] [zhtlcActivationProgress] BuildingWalletDb ["+current+"/"+latest+" * "+abs_pct+" * 98 | "+progress+"%]: " + JSON.stringify(details.BuildingWalletDb))
if (progress < 15) {
progress = 15
}
else if (progress > 98) {
progress = 98
}

}
else if (details.hasOwnProperty("RequestingBalance")) progress = 95
else if (details.hasOwnProperty("ActivatingCoin")) progress = 5
else progress = 5
else if (details.hasOwnProperty("RequestingWalletBalance")) progress = 99
else if (details.hasOwnProperty("ActivatingCoin")) progress = 1
else
{
progress = 2
}
}
else console.log("["+coin+"] [zhtlcActivationProgress] Unexpected status: " + status)
else console.log("["+coin+"] [zhtlcActivationProgress] Unexpected status: " + JSON.stringify(status))
if (progress > 100) {
progress = 98
}

progress = 100
}
return progress
}

Expand Down Expand Up @@ -476,6 +478,11 @@ QtObject {
return coin_info.tx_uri
}

function getBlockUri(coin_info) {
if (coin_info.block_uri == "") return "block/"
return coin_info.block_uri
}

function getTxExplorerURL(ticker, txid, add_0x=true) {
if(txid !== '') {
const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker)
Expand Down Expand Up @@ -678,13 +685,12 @@ QtObject {
return false
}

property Timer prevent_coin_disabling: Timer { interval: 5000 }

function canDisable(ticker) {
if (prevent_coin_disabling.running) return false
if (ticker === atomic_app_primary_coin || ticker === atomic_app_secondary_coin) return false
if (ticker === "ETH") return !General.isParentCoinNeeded("ETH", "ERC-20")
if (ticker === "MATIC") return !General.isParentCoinNeeded("MATIC", "Matic")
if (ticker === "MATIC") return !General.isParentCoinNeeded("MATIC", "PLG-20")
if (ticker === "FTM") return !General.isParentCoinNeeded("FTM", "FTM-20")
if (ticker === "AVAX") return !General.isParentCoinNeeded("AVAX", "AVX-20")
if (ticker === "BNB") return !General.isParentCoinNeeded("BNB", "BEP-20")
Expand All @@ -695,13 +701,9 @@ QtObject {
if (ticker === "BCH") return !General.isParentCoinNeeded("BCH", "SLP")
if (ticker === "UBQ") return !General.isParentCoinNeeded("UBQ", "Ubiq")
if (ticker === "MOVR") return !General.isParentCoinNeeded("MOVR", "Moonriver")
if (ticker === "GLMR") return !General.isParentCoinNeeded("GLMR", "Moonbeam")
if (General.isZhtlc(ticker))
{
let progress = General.zhtlcActivationProgress(API.app.wallet_pg.ticker_infos.activation_status, ticker)
if (progress != 100) return false
}

if (ticker === "IRIS") return !General.isParentCoinNeeded("IRIS", "COSMOS")
if (ticker === "OSMO") return !General.isParentCoinNeeded("OSMO", "COSMOS")
if (ticker === "ATOM") return !General.isParentCoinNeeded("ATOM", "COSMOS")
return true
}

Expand All @@ -722,7 +724,11 @@ QtObject {
}

function isERC20(current_ticker_infos) {
return current_ticker_infos.type === "ERC-20" || current_ticker_infos.type === "BEP-20" || current_ticker_infos.type == "Matic"
return current_ticker_infos.type === "ERC-20"
|| current_ticker_infos.type === "BEP-20"
|| current_ticker_infos.type == "PLG-20"
|| current_ticker_infos.type == "FTM-20"
|| current_ticker_infos.type == "AVX-20"
}

function isParentCoin(ticker) {
Expand Down
6 changes: 4 additions & 2 deletions atomic_defi_design/Dex/Constants/Style.qml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ QtObject {
case 'QRC-20': return dark_theme ? colorCoinDark["QTUM"] : colorCoin["QTUM"]
case 'KRC-20': return dark_theme ? colorCoinDark["KCS"] : colorCoin["KCS"]
case 'Smart Chain': return dark_theme ? colorCoinDark["KMD"] : colorCoin["KMD"]
case 'Matic': return dark_theme ? colorCoinDark["MATIC"] : colorCoin["MATIC"]
case 'Matic':
case 'PLG-20': return dark_theme ? colorCoinDark["MATIC"] : colorCoin["MATIC"]
case 'Moonriver': return dark_theme ? colorCoinDark["MOVR"] : colorCoin["MOVR"]
case 'HRC-20': return dark_theme ? colorCoinDark["ONE"] : colorCoin["ONE"]
case 'SmartBCH': return dark_theme ? colorCoinDark["SBCH"] : colorCoin["SBCH"]
Expand Down Expand Up @@ -245,7 +246,8 @@ QtObject {
case 'QRC-20': return dark_theme ? colorCoinDark["QTUM"] : colorCoin["QTUM"]
case 'KRC-20': return dark_theme ? colorCoinDark["KCS"] : colorCoin["KCS"]
case 'Smart Chain': return dark_theme ? colorCoinDark["KMD"] : colorCoin["KMD"]
case 'Matic': return dark_theme ? colorCoinDark["MATIC"] : colorCoin["MATIC"]
case 'Matic':
case 'PLG-20': return dark_theme ? colorCoinDark["MATIC"] : colorCoin["MATIC"]
case 'Moonriver': return dark_theme ? colorCoinDark["MOVR"] : colorCoin["MOVR"]
case 'HRC-20': return dark_theme ? colorCoinDark["ONE"] : colorCoin["ONE"]
case 'SmartBCH': return dark_theme ? colorCoinDark["SBCH"] : colorCoin["SBCH"]
Expand Down
16 changes: 11 additions & 5 deletions atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@ RowLayout
property color color: !details ? "white" : Style.getCoinColor(details.ticker)
property alias middle_text: middle_line.text_value
property alias bottom_text: bottom_line.text_value
property int activation_progress: Dex.General.zhtlcActivationProgress(details.activation_status, details.ticker)

property int activation_pct: General.zhtlcActivationProgress(API.app.get_zhtlc_status(details.ticker), details.ticker)
Connections
{
target: API.app.settings_pg
function onZhtlcStatusChanged() {
activation_pct = General.zhtlcActivationProgress(API.app.get_zhtlc_status(details.ticker), details.ticker)
}
}
Behavior on color { ColorAnimation { duration: Style.animationDuration } }

Dex.Image
Expand All @@ -40,7 +46,7 @@ RowLayout
anchors.centerIn: parent
anchors.fill: parent
radius: 10
enabled: Dex.General.isZhtlc(details.ticker) ? activation_progress < 100 : false
enabled: activation_pct < 100
visible: enabled
opacity: .9
color: Dex.DexTheme.backgroundColor
Expand All @@ -50,11 +56,11 @@ RowLayout
{
anchors.centerIn: parent
anchors.fill: parent
enabled: Dex.General.isZhtlc(details.ticker) ? activation_progress < 100 : false
enabled: activation_pct < 100
visible: enabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: activation_progress + "%"
text: activation_pct + "%"
font: Dex.DexTypo.body2
color: Dex.DexTheme.okColor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ ColumnLayout
function getMaxBalance()
{
if (General.isFilled(base_ticker))
return API.app.get_balance(base_ticker)

return API.app.get_balance_info_qstr(base_ticker)
return "0"
}

Expand Down
6 changes: 3 additions & 3 deletions atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ClipRRect // Trade Card
readonly property var fees: Constants.API.app.trading_pg.fees
readonly property var max_trade_volume: Constants.API.app.trading_pg.max_volume
readonly property var min_trade_volume: Constants.API.app.trading_pg.min_trade_vol
readonly property var sell_ticker_balance: parseFloat(API.app.get_balance(left_ticker))
readonly property var sell_ticker_balance: parseFloat(API.app.get_balance_info_qstr(left_ticker))
readonly property bool coin_tradable: selectedTicker !== "" && sell_ticker_balance > 0
readonly property bool waiting_for_sell_coin_info: (max_trade_volume == 0 || !Constants.General.isZhtlcReady(left_ticker)) && sell_ticker_balance != 0

Expand Down Expand Up @@ -398,7 +398,7 @@ ClipRRect // Trade Card

width: 60

text: _selectedTickerIcon.enabled ? atomic_qt_utilities.retrieve_main_ticker(selectedTicker) : qsTr("Pick a coin")
text: _selectedTickerIcon.enabled ? atomic_qt_utilities.retrieve_main_ticker(selectedTicker, false, true) : qsTr("Pick a coin")
font.pixelSize: Constants.Style.textSizeSmall2

wrapMode: Text.NoWrap
Expand Down Expand Up @@ -580,7 +580,7 @@ ClipRRect // Trade Card
anchors.leftMargin: 10
width: 60

text: enabled ? atomic_qt_utilities.retrieve_main_ticker(selectedOrder.coin) : ""
text: enabled ? atomic_qt_utilities.retrieve_main_ticker(selectedOrder.coin, false, true) : ""
font.pixelSize: Constants.Style.textSizeSmall2
wrapMode: Text.NoWrap

Expand Down
Loading
Loading