Skip to content

Commit

Permalink
Merge pull request #1 from KomodoPlatform/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
zatJUM authored Apr 24, 2020
2 parents 2243a7b + 2684390 commit ad39540
Show file tree
Hide file tree
Showing 45 changed files with 675 additions and 171 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ ci_tools_atomic_dex/build-Release
ci_tools_atomic_dex/build-Debug
ci_tools_atomic_dex/bundle-Release
ci_tools_atomic_dex/bundle-Debug
ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdexpro/data
ci_tools_atomic_dex/installer/linux/packages/com.komodoplatform.atomicdexpro/data
cmake-build-debug
cmake-build-release
.idea
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ else ()
endif ()

FetchContent_Declare(jl777-coins
URL https://github.com/jl777/coins/archive/master.zip)
URL https://github.com/KomodoPlatform/coins/archive/master.zip)

FetchContent_MakeAvailable(mm2 jl777-coins)

Expand Down
204 changes: 99 additions & 105 deletions README.md

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions assets/config/coins.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,56 @@
"active": true,
"currently_enabled": false
},
"LABS": {
"coin": "LABS",
"name": "Labs",
"type": "Smart Chain",
"rpcport": 40265,
"mm2": 1,
"coingecko_id": "test-coin",
"coinpaprika_id": "test-coin",
"is_erc_20": false,
"electrum": [
{
"url": "electrum1.cipig.net:10019"
},
{
"url": "electrum2.cipig.net:10019"
},
{
"url": "electrum3.cipig.net:10019"
}
],
"explorer_url": [
"https://labs.explorer.dexstats.info/"
],
"active": false,
"currently_enabled": false
},
"VOTE2020": {
"coin": "VOTE2020",
"name": "Vote2020",
"type": "Smart Chain",
"coingecko_id": "test-coin",
"coinpaprika_id": "test-coin",
"is_erc_20": false,
"electrum": [
{
"url": "electrum1.cipig.net:10002"
},
{
"url": "electrum2.cipig.net:10002"
},
{
"url": "electrum3.cipig.net:10002"
}
],
"explorer_url": [
"https://vote.kmdexplorer.io/"
],
"active": false,
"currently_enabled": false
},
"DEX": {
"coin": "DEX",
"name": "Dex",
Expand Down
Binary file added atomic_qt_design/assets/images/coins/labs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added atomic_qt_design/assets/images/coins/vote2020.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions atomic_qt_design/qml/Components/DefaultTextArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ TextArea {
KeyNavigation.backtab: nextItemInFocusChain(false)
KeyNavigation.tab: nextItemInFocusChain(true)
Keys.onPressed: {
if(onReturn !== undefined && event.key === Qt.Key_Return) {
onReturn()
if(event.key === Qt.Key_Return) {
if(onReturn !== undefined) {
onReturn()
}

// Ignore \n \r stuff
event.accepted = true
}
}

onTextChanged: {
text = text.replace(/[\r\n]/, '')
}

// Right click Context Menu
selectByMouse: true
Expand Down
26 changes: 26 additions & 0 deletions atomic_qt_design/qml/Components/HideFieldButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
import "../Constants"

// Hide button
Image {
property alias mouse_area: mouse_area
property bool use_default_behaviour: true
source: General.image_path + "dashboard-eye" + (hiding ? "" : "-hide") + ".svg"
visible: hidable
scale: 0.8
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: input_field.height * -0.0625
antialiasing: true


MouseArea {
id: mouse_area
anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
height: input_field.height; width: input_field.height
onClicked: if(use_default_behaviour) hiding = !hiding
}
}
14 changes: 7 additions & 7 deletions atomic_qt_design/qml/Components/PasswordField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ ColumnLayout {
property bool new_password: true

function isValid() {
return pw.field.acceptableInput && RegExp(/^(?=.{16,})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?]).*$/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_valid).test(pw.field.text)
}

function hasEnoughUppercaseCharacters() {
return pw.field.acceptableInput && RegExp(/(?=.*[A-Z])/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_uppercase).test(pw.field.text)
}

function hasEnoughLowercaseCharacters() {
return pw.field.acceptableInput && RegExp(/(?=.*[a-z])/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_lowercase).test(pw.field.text)
}

function hasEnoughNumericCharacters() {
return pw.field.acceptableInput && RegExp(/(?=.*[0-9])/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_numeric).test(pw.field.text)
}

function hasEnoughSpecialCharacters() {
return pw.field.acceptableInput && RegExp(/(?=.*[@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?])/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_special).test(pw.field.text)
}

function hasEnoughCharacters() {
return pw.field.acceptableInput && RegExp(/(?=.{16,})/).test(pw.field.text)
return pw.field.acceptableInput && RegExp(General.reg_pass_count).test(pw.field.text)
}

function hintColor(valid) {
Expand All @@ -47,7 +47,7 @@ ColumnLayout {
hidable: true
title: API.get().empty_string + (qsTr("Password"))
field.placeholderText: API.get().empty_string + (new_password ? qsTr("Enter a password for your wallet") : qsTr("Enter the password of your wallet"))
field.validator: RegExpValidator { regExp: /[A-Za-z0-9@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?]+/ }
field.validator: RegExpValidator { regExp: General.reg_pass_input }
}

ColumnLayout {
Expand Down
10 changes: 10 additions & 0 deletions atomic_qt_design/qml/Components/TextAreaWithTitle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ import "../Constants"
ColumnLayout {
property alias title: title_text.text
property alias field: input_field
property alias hide_button: hide_button
property alias hide_button_area: hide_button.mouse_area
property bool copyable: false
property bool hidable: false
property var onReturn // function

property bool hiding: true



// Local
function reset() {
Expand All @@ -26,6 +32,10 @@ ColumnLayout {
id: input_field
Layout.fillWidth: true

HideFieldButton {
id: hide_button
}

CopyFieldButton {

}
Expand Down
24 changes: 9 additions & 15 deletions atomic_qt_design/qml/Components/TextFieldWithTitle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import "../Constants"
ColumnLayout {
property alias title: title_text.text
property alias field: input_field
property alias hide_button: hide_button
property alias hide_button_area: hide_button.mouse_area
property bool copyable: false
property bool hidable: false

property bool hiding: true

// Local
function reset() {
input_field.text = ''
}

DefaultText {
id: title_text
visible: text !== ''
Expand All @@ -25,21 +32,8 @@ ColumnLayout {
Layout.fillWidth: true
selectByMouse: true

// Hide button
Image {
source: General.image_path + "dashboard-eye" + (hiding ? "" : "-hide") + ".svg"
visible: hidable
scale: 0.8
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: input_field.height * -0.0625
antialiasing: true

MouseArea {
anchors { horizontalCenter: parent.horizontalCenter; verticalCenter: parent.verticalCenter }
height: input_field.height; width: input_field.height
onClicked: hiding = !hiding
}
HideFieldButton {
id: hide_button
}

CopyFieldButton {
Expand Down
2 changes: 1 addition & 1 deletion atomic_qt_design/qml/Components/WalletNameField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TextFieldWithTitle {
id: input_wallet_name
title: API.get().empty_string + (qsTr("Wallet Name"))
field.placeholderText: API.get().empty_string + (qsTr("Enter the name of your wallet here"))
field.validator: RegExpValidator { regExp: /\w+/ }
field.validator: RegExpValidator { regExp: /[a-zA-Z0-9]+/ }

function reset() {
field.text = ''
Expand Down
1 change: 1 addition & 0 deletions atomic_qt_design/qml/Constants/API.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ QtObject {
get_mm2_version: () => { return "5.1.1" },
get_version: () => { return "0.1.1-alpha" },

mnemonic_validate: (entropy) => { return true },
wallet_default_name: "",

balance_fiat_all: "12345678.90",
Expand Down
8 changes: 8 additions & 0 deletions atomic_qt_design/qml/Constants/General.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ QtObject {
readonly property int idx_exchange_orders: 1
readonly property int idx_exchange_history: 2

readonly property var reg_pass_input: /[A-Za-z0-9@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?]+/
readonly property var reg_pass_valid: /^(?=.{16,})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?]).*$/
readonly property var reg_pass_uppercase: /(?=.*[A-Z])/
readonly property var reg_pass_lowercase: /(?=.*[a-z])/
readonly property var reg_pass_numeric: /(?=.*[0-9])/
readonly property var reg_pass_special: /(?=.*[@#$%{}[\]()\/\\'"`~,;:.<>+\-_=!^&*|?])/
readonly property var reg_pass_count: /(?=.{16,})/

function diffPrefix(received) {
return received === "" ? "" : received === true ? "+ " : "- "
}
Expand Down
13 changes: 12 additions & 1 deletion atomic_qt_design/qml/Exchange/Trade/OrderForm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,24 @@ Rectangle {
return General.isEthEnabled() && API.get().do_i_have_enough_funds("ETH", curr_trade_info.erc_fees)
}

function getMinTradeAmount() {
return 0.00777
}

function higherThanMinTradeAmount() {
return input_volume.field.text !== '' && parseFloat(input_volume.field.text) >= getMinTradeAmount()
}

function isValid() {
if(!my_side) return fieldsAreFilled()

const ticker = getTicker()

let valid = fieldsAreFilled() && API.get().do_i_have_enough_funds(ticker, input_volume.field.text)
let valid = true

if(valid) valid = fieldsAreFilled()
if(valid) valid = higherThanMinTradeAmount()
if(valid) valid = API.get().do_i_have_enough_funds(ticker, input_volume.field.text)
if(valid && hasEthFees()) valid = hasEnoughEthForFees()

return valid
Expand Down
27 changes: 25 additions & 2 deletions atomic_qt_design/qml/Exchange/Trade/Trade.qml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ Item {
updateTradeInfo(true) // Force update trade info
form_base.capVolume() // To cap the value for one last time

action_result = API.get().place_sell_order(base, rel, getCurrentPrice(), form_base.field.text) ? "success" : "error"
const price = getCurrentPrice()
const volume = form_base.field.text
console.log("QML place_sell_order: max balance:", form_base.getMaxVolume())
console.log("QML place_sell_order: params:", base, " <-> ", rel, " / price:", price, " / volume:", volume)
console.log("QML place_sell_order: trade info:", JSON.stringify(curr_trade_info))
action_result = API.get().place_sell_order(base, rel, price, volume) ? "success" : "error"
if(action_result === "success") {
onOrderSuccess()
}
Expand Down Expand Up @@ -338,10 +343,28 @@ Item {
DefaultText {
Layout.alignment: Qt.AlignHCenter

text: API.get().empty_string + ("Not enough ETH for the transaction fee")
text: API.get().empty_string + (qsTr("Not enough ETH for the transaction fee"))
color: Style.colorRed
visible: form_base.hasEthFees() && !form_base.hasEnoughEthForFees()
}

// Show min amount error
DefaultText {
Layout.alignment: Qt.AlignHCenter

text: API.get().empty_string + (qsTr("Sell amount is lower than minimum trade amount") + " : " + form_base.getMinTradeAmount())
color: Style.colorRed
visible: form_base.fieldsAreFilled() && !form_base.higherThanMinTradeAmount()
}

// Show min amount error
DefaultText {
Layout.alignment: Qt.AlignHCenter

text: API.get().empty_string + (qsTr("Receive amount is lower than minimum trade amount") + " : " + form_rel.getMinTradeAmount())
color: Style.colorRed
visible: form_rel.fieldsAreFilled() && !form_rel.higherThanMinTradeAmount()
}
}
}

Expand Down
Loading

0 comments on commit ad39540

Please sign in to comment.