parent
4495bf0f78
commit
cbb473ecbd
|
@ -36,6 +36,7 @@ SplitView {
|
||||||
fromTokenAmount: ctrlFromTokenAmount.text
|
fromTokenAmount: ctrlFromTokenAmount.text
|
||||||
toTokenKey: ctrlToTokenKey.text
|
toTokenKey: ctrlToTokenKey.text
|
||||||
toTokenAmount: ctrlToTokenAmount.text
|
toTokenAmount: ctrlToTokenAmount.text
|
||||||
|
defaultToTokenKey: "STT"
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly property SwapModalAdaptor adaptor: SwapModalAdaptor {
|
readonly property SwapModalAdaptor adaptor: SwapModalAdaptor {
|
||||||
|
|
|
@ -96,11 +96,11 @@ SplitView {
|
||||||
closePolicy: Popup.CloseOnEscape
|
closePolicy: Popup.CloseOnEscape
|
||||||
destroyOnClose: true
|
destroyOnClose: true
|
||||||
swapInputParamsForm: SwapInputParamsForm {
|
swapInputParamsForm: SwapInputParamsForm {
|
||||||
|
defaultToTokenKey: "STT"
|
||||||
onSelectedAccountAddressChanged: {
|
onSelectedAccountAddressChanged: {
|
||||||
if (selectedAccountAddress !== accountComboBox.currentValue)
|
if (selectedAccountAddress !== accountComboBox.currentValue)
|
||||||
accountComboBox.currentIndex = accountComboBox.indexOfValue(selectedAccountAddress)
|
accountComboBox.currentIndex = accountComboBox.indexOfValue(selectedAccountAddress)
|
||||||
}
|
}
|
||||||
fromTokenAmount: swapInput.text
|
|
||||||
}
|
}
|
||||||
swapAdaptor: SwapModalAdaptor {
|
swapAdaptor: SwapModalAdaptor {
|
||||||
swapStore: dSwapStore
|
swapStore: dSwapStore
|
||||||
|
|
|
@ -5,6 +5,7 @@ import StatusQ 0.1 // See #10218
|
||||||
import StatusQ.Core 0.1
|
import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Utils 0.1 as SQUtils
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
|
import StatusQ.Controls 0.1
|
||||||
|
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
|
||||||
|
@ -62,7 +63,9 @@ Item {
|
||||||
accountAddress: !!root.swapFormData && root.swapFormData.selectedAccountAddress
|
accountAddress: !!root.swapFormData && root.swapFormData.selectedAccountAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
property SwapInputParamsForm swapFormData: SwapInputParamsForm { }
|
property SwapInputParamsForm swapFormData: SwapInputParamsForm {
|
||||||
|
defaultToTokenKey: "STT"
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: componentUnderTest
|
id: componentUnderTest
|
||||||
|
@ -108,6 +111,7 @@ Item {
|
||||||
controlUnderTest.close()
|
controlUnderTest.close()
|
||||||
verify(!controlUnderTest.opened)
|
verify(!controlUnderTest.opened)
|
||||||
formValuesChanged.clear()
|
formValuesChanged.clear()
|
||||||
|
root.swapFormData.resetFormData()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAndVerifyAccountsModalHeader() {
|
function getAndVerifyAccountsModalHeader() {
|
||||||
|
@ -386,8 +390,6 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_network_and_account_header_items() {
|
function test_network_and_account_header_items() {
|
||||||
root.swapFormData.fromTokensKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(0).key
|
|
||||||
|
|
||||||
// Launch popup
|
// Launch popup
|
||||||
launchAndVerfyModal()
|
launchAndVerfyModal()
|
||||||
|
|
||||||
|
@ -415,6 +417,8 @@ Item {
|
||||||
mouseClick(delegateUnderTest)
|
mouseClick(delegateUnderTest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
root.swapFormData.fromTokensKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(0).key
|
||||||
|
|
||||||
// verify values in accouns modal header dropdown
|
// verify values in accouns modal header dropdown
|
||||||
const accountsModalHeader = getAndVerifyAccountsModalHeader()
|
const accountsModalHeader = getAndVerifyAccountsModalHeader()
|
||||||
launchAccountSelectionPopup(accountsModalHeader)
|
launchAccountSelectionPopup(accountsModalHeader)
|
||||||
|
@ -544,13 +548,12 @@ Item {
|
||||||
root.swapFormData.fromTokensKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(0).key
|
root.swapFormData.fromTokensKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(0).key
|
||||||
compare(formValuesChanged.count, 1)
|
compare(formValuesChanged.count, 1)
|
||||||
root.swapFormData.toTokenKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(1).key
|
root.swapFormData.toTokenKey = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel.get(1).key
|
||||||
compare(formValuesChanged.count, 2)
|
|
||||||
root.swapFormData.fromTokenAmount = "0.001"
|
root.swapFormData.fromTokenAmount = "0.001"
|
||||||
compare(formValuesChanged.count, 3)
|
compare(formValuesChanged.count, 2)
|
||||||
root.swapFormData.selectedNetworkChainId = root.swapAdaptor.filteredFlatNetworksModel.get(0).chainId
|
root.swapFormData.selectedNetworkChainId = root.swapAdaptor.filteredFlatNetworksModel.get(0).chainId
|
||||||
compare(formValuesChanged.count, 4)
|
compare(formValuesChanged.count, 3)
|
||||||
root.swapFormData.selectedAccountAddress = root.swapAdaptor.nonWatchAccounts.get(0).address
|
root.swapFormData.selectedAccountAddress = root.swapAdaptor.nonWatchAccounts.get(0).address
|
||||||
compare(formValuesChanged.count, 5)
|
compare(formValuesChanged.count, 4)
|
||||||
|
|
||||||
// wait for fetchSuggestedRoutes function to be called
|
// wait for fetchSuggestedRoutes function to be called
|
||||||
wait(1000)
|
wait(1000)
|
||||||
|
@ -587,7 +590,7 @@ Item {
|
||||||
|
|
||||||
// edit some params to retry swap
|
// edit some params to retry swap
|
||||||
root.swapFormData.fromTokenAmount = "0.00011"
|
root.swapFormData.fromTokenAmount = "0.00011"
|
||||||
compare(formValuesChanged.count, 6)
|
compare(formValuesChanged.count, 5)
|
||||||
|
|
||||||
// wait for fetchSuggestedRoutes function to be called
|
// wait for fetchSuggestedRoutes function to be called
|
||||||
wait(1000)
|
wait(1000)
|
||||||
|
@ -636,7 +639,7 @@ Item {
|
||||||
|
|
||||||
// edit some params to retry swap
|
// edit some params to retry swap
|
||||||
root.swapFormData.fromTokenAmount = "0.012"
|
root.swapFormData.fromTokenAmount = "0.012"
|
||||||
compare(formValuesChanged.count, 7)
|
compare(formValuesChanged.count, 6)
|
||||||
|
|
||||||
// wait for fetchSuggestedRoutes function to be called
|
// wait for fetchSuggestedRoutes function to be called
|
||||||
wait(1000)
|
wait(1000)
|
||||||
|
@ -696,8 +699,8 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(payPanel, "maxTagButton")
|
const maxTagButton = findChild(payPanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(payPanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
|
|
||||||
waitForRendering(payPanel)
|
waitForRendering(payPanel)
|
||||||
|
|
||||||
|
@ -709,7 +712,7 @@ Item {
|
||||||
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
||||||
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, "")
|
compare(holdingSelector.currentTokensKey, "")
|
||||||
compare(holdingSelectorsContentItemText.text, qsTr("Select asset"))
|
compare(tokenSelectorContentItemText.text, qsTr("Select asset"))
|
||||||
verify(!maxTagButton.visible)
|
verify(!maxTagButton.visible)
|
||||||
compare(payPanel.selectedHoldingId, "")
|
compare(payPanel.selectedHoldingId, "")
|
||||||
compare(payPanel.value, 0)
|
compare(payPanel.value, 0)
|
||||||
|
@ -745,10 +748,10 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(payPanel, "maxTagButton")
|
const maxTagButton = findChild(payPanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(payPanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
const holdingSelectorsTokenIcon = findChild(payPanel, "holdingSelectorsTokenIcon")
|
const tokenSelectorIcon = findChild(payPanel, "tokenSelectorIcon")
|
||||||
verify(!!holdingSelectorsTokenIcon)
|
verify(!!tokenSelectorIcon)
|
||||||
|
|
||||||
compare(amountToSendInput.caption, qsTr("Pay"))
|
compare(amountToSendInput.caption, qsTr("Pay"))
|
||||||
verify(amountToSendInput.interactive)
|
verify(amountToSendInput.interactive)
|
||||||
|
@ -757,9 +760,9 @@ Item {
|
||||||
tryCompare(amountToSendInput.input.input.edit, "cursorVisible", true)
|
tryCompare(amountToSendInput.input.input.edit, "cursorVisible", true)
|
||||||
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToExchange * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToExchange * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
||||||
compare(holdingSelectorsContentItemText.text, expectedToken.symbol)
|
compare(tokenSelectorContentItemText.text, expectedToken.symbol)
|
||||||
compare(holdingSelectorsTokenIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
compare(tokenSelectorIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
||||||
verify(holdingSelectorsTokenIcon.visible)
|
verify(tokenSelectorIcon.visible)
|
||||||
verify(maxTagButton.visible)
|
verify(maxTagButton.visible)
|
||||||
compare(maxTagButton.text, qsTr("Max. %1").arg(root.swapAdaptor.currencyStore.formatCurrencyAmount(WalletUtils.calculateMaxSafeSendAmount(expectedToken.currentBalance, expectedToken.symbol), expectedToken.symbol, {noSymbol: true})))
|
compare(maxTagButton.text, qsTr("Max. %1").arg(root.swapAdaptor.currencyStore.formatCurrencyAmount(WalletUtils.calculateMaxSafeSendAmount(expectedToken.currentBalance, expectedToken.symbol), expectedToken.symbol, {noSymbol: true})))
|
||||||
compare(payPanel.selectedHoldingId, expectedToken.symbol)
|
compare(payPanel.selectedHoldingId, expectedToken.symbol)
|
||||||
|
@ -793,8 +796,8 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(payPanel, "maxTagButton")
|
const maxTagButton = findChild(payPanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(payPanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
|
|
||||||
waitForRendering(payPanel)
|
waitForRendering(payPanel)
|
||||||
|
|
||||||
|
@ -804,7 +807,7 @@ Item {
|
||||||
verify(amountToSendInput.input.input.edit.cursorVisible)
|
verify(amountToSendInput.input.input.edit.cursorVisible)
|
||||||
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, "")
|
compare(holdingSelector.currentTokensKey, "")
|
||||||
compare(holdingSelectorsContentItemText.text, "Select asset")
|
compare(tokenSelectorContentItemText.text, "Select asset")
|
||||||
verify(!maxTagButton.visible)
|
verify(!maxTagButton.visible)
|
||||||
compare(payPanel.selectedHoldingId, "")
|
compare(payPanel.selectedHoldingId, "")
|
||||||
compare(payPanel.value, 0)
|
compare(payPanel.value, 0)
|
||||||
|
@ -841,10 +844,10 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(payPanel, "maxTagButton")
|
const maxTagButton = findChild(payPanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(payPanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
const holdingSelectorsTokenIcon = findChild(payPanel, "holdingSelectorsTokenIcon")
|
const tokenSelectorIcon = findChild(payPanel, "tokenSelectorIcon")
|
||||||
verify(!!holdingSelectorsTokenIcon)
|
verify(!!tokenSelectorIcon)
|
||||||
|
|
||||||
compare(amountToSendInput.caption, qsTr("Pay"))
|
compare(amountToSendInput.caption, qsTr("Pay"))
|
||||||
verify(amountToSendInput.interactive)
|
verify(amountToSendInput.interactive)
|
||||||
|
@ -853,9 +856,9 @@ Item {
|
||||||
verify(amountToSendInput.input.input.edit.cursorVisible)
|
verify(amountToSendInput.input.input.edit.cursorVisible)
|
||||||
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToExchange * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToExchange * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
||||||
compare(holdingSelectorsContentItemText.text, expectedToken.symbol)
|
compare(tokenSelectorContentItemText.text, expectedToken.symbol)
|
||||||
compare(holdingSelectorsTokenIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
compare(tokenSelectorIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
||||||
verify(holdingSelectorsTokenIcon.visible)
|
verify(tokenSelectorIcon.visible)
|
||||||
verify(maxTagButton.visible)
|
verify(maxTagButton.visible)
|
||||||
compare(maxTagButton.text, qsTr("Max. %1").arg(root.swapAdaptor.currencyStore.formatCurrencyAmount(WalletUtils.calculateMaxSafeSendAmount(expectedToken.currentBalance, expectedToken.symbol), expectedToken.symbol, {noSymbol: true})))
|
compare(maxTagButton.text, qsTr("Max. %1").arg(root.swapAdaptor.currencyStore.formatCurrencyAmount(WalletUtils.calculateMaxSafeSendAmount(expectedToken.currentBalance, expectedToken.symbol), expectedToken.symbol, {noSymbol: true})))
|
||||||
compare(payPanel.selectedHoldingId, expectedToken.symbol)
|
compare(payPanel.selectedHoldingId, expectedToken.symbol)
|
||||||
|
@ -866,7 +869,7 @@ Item {
|
||||||
closeAndVerfyModal()
|
closeAndVerfyModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_modal_pay_input_switching_networks() {
|
function test_modal_switching_networks() {
|
||||||
// try setting value before popup is launched and check values
|
// try setting value before popup is launched and check values
|
||||||
let valueToExchange = 0.3
|
let valueToExchange = 0.3
|
||||||
let valueToExchangeString = valueToExchange.toString()
|
let valueToExchangeString = valueToExchange.toString()
|
||||||
|
@ -914,8 +917,8 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(receivePanel, "maxTagButton")
|
const maxTagButton = findChild(receivePanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(receivePanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(receivePanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
|
|
||||||
// check default states for the from input selector
|
// check default states for the from input selector
|
||||||
compare(amountToSendInput.caption, qsTr("Receive"))
|
compare(amountToSendInput.caption, qsTr("Receive"))
|
||||||
|
@ -926,7 +929,7 @@ Item {
|
||||||
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
||||||
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, "")
|
compare(holdingSelector.currentTokensKey, "")
|
||||||
compare(holdingSelectorsContentItemText.text, qsTr("Select asset"))
|
compare(tokenSelectorContentItemText.text, qsTr("Select asset"))
|
||||||
verify(!maxTagButton.visible)
|
verify(!maxTagButton.visible)
|
||||||
compare(receivePanel.selectedHoldingId, "")
|
compare(receivePanel.selectedHoldingId, "")
|
||||||
compare(receivePanel.value, 0)
|
compare(receivePanel.value, 0)
|
||||||
|
@ -962,10 +965,10 @@ Item {
|
||||||
verify(!!holdingSelector)
|
verify(!!holdingSelector)
|
||||||
const maxTagButton = findChild(receivePanel, "maxTagButton")
|
const maxTagButton = findChild(receivePanel, "maxTagButton")
|
||||||
verify(!!maxTagButton)
|
verify(!!maxTagButton)
|
||||||
const holdingSelectorsContentItemText = findChild(receivePanel, "holdingSelectorsContentItemText")
|
const tokenSelectorContentItemText = findChild(receivePanel, "tokenSelectorContentItemText")
|
||||||
verify(!!holdingSelectorsContentItemText)
|
verify(!!tokenSelectorContentItemText)
|
||||||
const holdingSelectorsTokenIcon = findChild(receivePanel, "holdingSelectorsTokenIcon")
|
const tokenSelectorIcon = findChild(receivePanel, "tokenSelectorIcon")
|
||||||
verify(!!holdingSelectorsTokenIcon)
|
verify(!!tokenSelectorIcon)
|
||||||
|
|
||||||
compare(amountToSendInput.caption, qsTr("Receive"))
|
compare(amountToSendInput.caption, qsTr("Receive"))
|
||||||
// TODO: this should be come interactive under https://github.com/status-im/status-desktop/issues/15095
|
// TODO: this should be come interactive under https://github.com/status-im/status-desktop/issues/15095
|
||||||
|
@ -975,9 +978,9 @@ Item {
|
||||||
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0))
|
||||||
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToReceive * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
tryCompare(bottomItemText, "text", root.swapAdaptor.currencyStore.formatCurrencyAmount(valueToReceive * expectedToken.marketDetails.currencyPrice.amount, root.swapAdaptor.currencyStore.currentCurrency))
|
||||||
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
compare(holdingSelector.currentTokensKey, expectedToken.tokensKey)
|
||||||
compare(holdingSelectorsContentItemText.text, expectedToken.symbol)
|
compare(tokenSelectorContentItemText.text, expectedToken.symbol)
|
||||||
compare(holdingSelectorsTokenIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
compare(tokenSelectorIcon.image.source, Constants.tokenIcon(expectedToken.symbol))
|
||||||
verify(holdingSelectorsTokenIcon.visible)
|
verify(tokenSelectorIcon.visible)
|
||||||
verify(!maxTagButton.visible)
|
verify(!maxTagButton.visible)
|
||||||
compare(receivePanel.selectedHoldingId, expectedToken.symbol)
|
compare(receivePanel.selectedHoldingId, expectedToken.symbol)
|
||||||
compare(receivePanel.value, valueToReceive)
|
compare(receivePanel.value, valueToReceive)
|
||||||
|
@ -997,7 +1000,7 @@ Item {
|
||||||
root.swapFormData.fromTokenAmount = valueToExchangeString
|
root.swapFormData.fromTokenAmount = valueToExchangeString
|
||||||
root.swapFormData.toTokenKey = "STT"
|
root.swapFormData.toTokenKey = "STT"
|
||||||
|
|
||||||
compare(formValuesChanged.count, 6)
|
compare(formValuesChanged.count, 4)
|
||||||
|
|
||||||
// Launch popup
|
// Launch popup
|
||||||
launchAndVerfyModal()
|
launchAndVerfyModal()
|
||||||
|
@ -1034,9 +1037,6 @@ Item {
|
||||||
mouseClick(maxTagButton)
|
mouseClick(maxTagButton)
|
||||||
waitForItemPolished(payPanel)
|
waitForItemPolished(payPanel)
|
||||||
|
|
||||||
// FIXME flaky; value is 2 in isolation, 3 in TestCase run
|
|
||||||
//tryCompare(formValuesChanged, "count", 3)
|
|
||||||
|
|
||||||
verify(amountToSendInput.interactive)
|
verify(amountToSendInput.interactive)
|
||||||
verify(amountToSendInput.input.input.edit.cursorVisible)
|
verify(amountToSendInput.input.input.edit.cursorVisible)
|
||||||
tryCompare(amountToSendInput.input, "text", maxPossibleValue === 0 ? "" : maxPossibleValue.toLocaleString(Qt.locale(), 'f', -128))
|
tryCompare(amountToSendInput.input, "text", maxPossibleValue === 0 ? "" : maxPossibleValue.toLocaleString(Qt.locale(), 'f', -128))
|
||||||
|
@ -1058,7 +1058,7 @@ Item {
|
||||||
root.swapFormData.fromTokensKey = "ETH"
|
root.swapFormData.fromTokensKey = "ETH"
|
||||||
root.swapFormData.toTokenKey = "STT"
|
root.swapFormData.toTokenKey = "STT"
|
||||||
|
|
||||||
compare(formValuesChanged.count, 4)
|
compare(formValuesChanged.count, 3)
|
||||||
|
|
||||||
const payPanel = findChild(controlUnderTest, "payPanel")
|
const payPanel = findChild(controlUnderTest, "payPanel")
|
||||||
verify(!!payPanel)
|
verify(!!payPanel)
|
||||||
|
@ -1087,7 +1087,7 @@ Item {
|
||||||
maxTagButton.clicked()
|
maxTagButton.clicked()
|
||||||
waitForItemPolished(payPanel)
|
waitForItemPolished(payPanel)
|
||||||
|
|
||||||
tryCompare(formValuesChanged, "count", 5)
|
tryCompare(formValuesChanged, "count", 4)
|
||||||
|
|
||||||
verify(amountToSendInput.interactive)
|
verify(amountToSendInput.interactive)
|
||||||
verify(amountToSendInput.input.input.edit.cursorVisible)
|
verify(amountToSendInput.input.input.edit.cursorVisible)
|
||||||
|
@ -1153,5 +1153,130 @@ Item {
|
||||||
closeAndVerfyModal()
|
closeAndVerfyModal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_modal_exchange_button_default_state() {
|
||||||
|
let default_test_data = [{fromToken: "", fromTokenAmount: "", toToken: "", toTokenAmount: ""},
|
||||||
|
{fromToken: "", fromTokenAmount: "", toToken: "STT", toTokenAmount: ""},
|
||||||
|
{fromToken: "ETH", fromTokenAmount: "", toToken: "", toTokenAmount: ""},
|
||||||
|
{fromToken: "ETH", fromTokenAmount: "", toToken: "STT", toTokenAmount: ""},
|
||||||
|
{fromToken: "ETH", fromTokenAmount: "100", toToken: "STT", toTokenAmount: ""},
|
||||||
|
{fromToken: "ETH", fromTokenAmount: "", toToken: "STT", toTokenAmount: "50"},
|
||||||
|
{fromToken: "ETH", fromTokenAmount: "100", toToken: "STT", toTokenAmount: "50"},
|
||||||
|
{fromToken: "", fromTokenAmount: "", toToken: "", toTokenAmount: "50"},
|
||||||
|
{fromToken: "", fromTokenAmount: "100", toToken: "", toTokenAmount: ""}]
|
||||||
|
|
||||||
|
const payPanel = findChild(controlUnderTest, "payPanel")
|
||||||
|
verify(!!payPanel)
|
||||||
|
const receivePanel = findChild(controlUnderTest, "receivePanel")
|
||||||
|
verify(!!receivePanel)
|
||||||
|
const swapExchangeButton = findChild(controlUnderTest, "swapExchangeButton")
|
||||||
|
verify(!!swapExchangeButton)
|
||||||
|
|
||||||
|
const payAmountToSendInput = findChild(payPanel, "amountToSendInput")
|
||||||
|
verify(!!payAmountToSendInput)
|
||||||
|
const payBottomItemText = findChild(payPanel, "bottomItemText")
|
||||||
|
verify(!!payBottomItemText)
|
||||||
|
const maxTagButton = findChild(payPanel, "maxTagButton")
|
||||||
|
verify(!!maxTagButton)
|
||||||
|
|
||||||
|
const receiveAmountToSendInput = findChild(receivePanel, "amountToSendInput")
|
||||||
|
verify(!!receiveAmountToSendInput)
|
||||||
|
const receiveBottomItemText = findChild(receivePanel, "bottomItemText")
|
||||||
|
verify(!!receiveBottomItemText)
|
||||||
|
|
||||||
|
for (let i =0; i< default_test_data.length; i++) {
|
||||||
|
root.swapAdaptor.reset()
|
||||||
|
|
||||||
|
// set network and address by default same
|
||||||
|
root.swapFormData.selectedNetworkChainId = root.swapAdaptor.filteredFlatNetworksModel.get(0).chainId
|
||||||
|
root.swapFormData.selectedAccountAddress = root.swapAdaptor.nonWatchAccounts.get(0).address
|
||||||
|
root.swapFormData.fromTokensKey = default_test_data[i].fromToken
|
||||||
|
root.swapFormData.fromTokenAmount = default_test_data[i].fromTokenAmount
|
||||||
|
root.swapFormData.toTokenKey = default_test_data[i].toToken
|
||||||
|
root.swapFormData.toTokenAmount = default_test_data[i].toTokenAmount
|
||||||
|
|
||||||
|
let expectedFromTokenIcon = !!root.swapAdaptor.fromToken && !!root.swapAdaptor.fromToken.symbol ?
|
||||||
|
Constants.tokenIcon(root.swapAdaptor.fromToken.symbol): ""
|
||||||
|
let expectedToTokenIcon = !!root.swapAdaptor.toToken && !!root.swapAdaptor.toToken.symbol ?
|
||||||
|
Constants.tokenIcon(root.swapAdaptor.toToken.symbol): ""
|
||||||
|
|
||||||
|
// Launch popup
|
||||||
|
launchAndVerfyModal()
|
||||||
|
waitForRendering(payPanel)
|
||||||
|
waitForRendering(receivePanel)
|
||||||
|
|
||||||
|
let paytokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
|
verify(!!paytokenSelectorContentItemText)
|
||||||
|
let paytokenSelectorIcon = findChild(payPanel, "tokenSelectorIcon")
|
||||||
|
compare(!!default_test_data[i].fromToken , !!paytokenSelectorIcon)
|
||||||
|
let receivetokenSelectorContentItemText = findChild(receivePanel, "tokenSelectorContentItemText")
|
||||||
|
verify(!!receivetokenSelectorContentItemText)
|
||||||
|
let receivetokenSelectorIcon = findChild(receivePanel, "tokenSelectorIcon")
|
||||||
|
compare(!!default_test_data[i].toToken, !!receivetokenSelectorIcon)
|
||||||
|
|
||||||
|
// verify pay values
|
||||||
|
compare(payPanel.tokenKey, default_test_data[i].fromToken)
|
||||||
|
compare(payPanel.tokenAmount, default_test_data[i].fromTokenAmount)
|
||||||
|
verify(payAmountToSendInput.input.input.edit.cursorVisible)
|
||||||
|
compare(paytokenSelectorContentItemText.text, !!root.swapFormData.fromTokensKey ? root.swapFormData.fromTokensKey : qsTr("Select asset"))
|
||||||
|
compare(!!default_test_data[i].fromToken , !!paytokenSelectorIcon)
|
||||||
|
if(!!paytokenSelectorIcon) {
|
||||||
|
compare(paytokenSelectorIcon.image.source, expectedFromTokenIcon)
|
||||||
|
}
|
||||||
|
verify(!!default_test_data[i].fromToken ? maxTagButton.visible: !maxTagButton.visible)
|
||||||
|
|
||||||
|
// verify receive values
|
||||||
|
compare(receivePanel.tokenKey, default_test_data[i].toToken)
|
||||||
|
compare(receivePanel.tokenAmount, default_test_data[i].toTokenAmount)
|
||||||
|
verify(!receiveAmountToSendInput.input.input.edit.cursorVisible)
|
||||||
|
compare(receivetokenSelectorContentItemText.text, !!root.swapFormData.toTokenKey ? root.swapFormData.toTokenKey : qsTr("Select asset"))
|
||||||
|
if(!!receivetokenSelectorIcon) {
|
||||||
|
compare(receivetokenSelectorIcon.image.source, expectedToTokenIcon)
|
||||||
|
}
|
||||||
|
|
||||||
|
// click exchange button
|
||||||
|
swapExchangeButton.clicked()
|
||||||
|
waitForRendering(payPanel)
|
||||||
|
waitForRendering(receivePanel)
|
||||||
|
|
||||||
|
// verify form values
|
||||||
|
compare(root.swapFormData.fromTokensKey, default_test_data[i].toToken)
|
||||||
|
compare(root.swapFormData.fromTokenAmount, default_test_data[i].toTokenAmount)
|
||||||
|
compare(root.swapFormData.toTokenKey, default_test_data[i].fromToken)
|
||||||
|
compare(root.swapFormData.toTokenAmount, default_test_data[i].fromTokenAmount)
|
||||||
|
|
||||||
|
paytokenSelectorContentItemText = findChild(payPanel, "tokenSelectorContentItemText")
|
||||||
|
verify(!!paytokenSelectorContentItemText)
|
||||||
|
paytokenSelectorIcon = findChild(payPanel, "tokenSelectorIcon")
|
||||||
|
compare(!!root.swapFormData.fromTokensKey , !!paytokenSelectorIcon)
|
||||||
|
receivetokenSelectorContentItemText = findChild(receivePanel, "tokenSelectorContentItemText")
|
||||||
|
verify(!!receivetokenSelectorContentItemText)
|
||||||
|
receivetokenSelectorIcon = findChild(receivePanel, "tokenSelectorIcon")
|
||||||
|
compare(!!root.swapFormData.toTokenKey, !!receivetokenSelectorIcon)
|
||||||
|
|
||||||
|
// verify pay values
|
||||||
|
compare(payPanel.tokenKey, default_test_data[i].toToken)
|
||||||
|
compare(payPanel.tokenAmount, default_test_data[i].toTokenAmount)
|
||||||
|
verify(payAmountToSendInput.input.input.edit.cursorVisible)
|
||||||
|
compare(paytokenSelectorContentItemText.text, !!default_test_data[i].toToken ? default_test_data[i].toToken : qsTr("Select asset"))
|
||||||
|
if(!!paytokenSelectorIcon) {
|
||||||
|
compare(paytokenSelectorIcon.image.source, expectedToTokenIcon)
|
||||||
|
}
|
||||||
|
verify(!!default_test_data[i].toToken ? maxTagButton.visible: !maxTagButton.visible)
|
||||||
|
compare(maxTagButton.text, qsTr("Max. %1").arg(Qt.locale().zeroDigit))
|
||||||
|
compare(maxTagButton.type, (payAmountToSendInput.input.valid || !payAmountToSendInput.input.text) && maxTagButton.value > 0 ? StatusBaseButton.Type.Normal : StatusBaseButton.Type.Danger)
|
||||||
|
|
||||||
|
// verify receive values
|
||||||
|
compare(receivePanel.tokenKey, default_test_data[i].fromToken)
|
||||||
|
compare(receivePanel.tokenAmount, default_test_data[i].fromTokenAmount)
|
||||||
|
verify(!receiveAmountToSendInput.input.input.edit.cursorVisible)
|
||||||
|
compare(receivetokenSelectorContentItemText.text, !!default_test_data[i].fromToken ? default_test_data[i].fromToken : qsTr("Select asset"))
|
||||||
|
if(!!receivetokenSelectorIcon) {
|
||||||
|
compare(receivetokenSelectorIcon.image.source, expectedFromTokenIcon)
|
||||||
|
}
|
||||||
|
|
||||||
|
closeAndVerfyModal()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ Item {
|
||||||
d.swapFormData.selectedAccountAddress = RootStore.selectedAddress
|
d.swapFormData.selectedAccountAddress = RootStore.selectedAddress
|
||||||
d.swapFormData.selectedNetworkChainId = StatusQUtils.ModelUtils.getByKey(RootStore.filteredFlatModel, "layer", 1, "chainId")
|
d.swapFormData.selectedNetworkChainId = StatusQUtils.ModelUtils.getByKey(RootStore.filteredFlatModel, "layer", 1, "chainId")
|
||||||
d.swapFormData.fromTokensKey = tokensKey
|
d.swapFormData.fromTokensKey = tokensKey
|
||||||
d.swapFormData.toTokenKey = RootStore.areTestNetworksEnabled ? Constants.swap.testStatusTokenKey : Constants.swap.mainnetStatusTokenKey
|
d.swapFormData.defaultToTokenKey = RootStore.areTestNetworksEnabled ? Constants.swap.testStatusTokenKey : Constants.swap.mainnetStatusTokenKey
|
||||||
Global.openSwapModalRequested(d.swapFormData)
|
Global.openSwapModalRequested(d.swapFormData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ Item {
|
||||||
if(!!walletStore.currentViewedHoldingTokensKey && walletStore.currentViewedHoldingType === Constants.TokenType.ERC20) {
|
if(!!walletStore.currentViewedHoldingTokensKey && walletStore.currentViewedHoldingType === Constants.TokenType.ERC20) {
|
||||||
d.swapFormData.fromTokensKey = walletStore.currentViewedHoldingTokensKey
|
d.swapFormData.fromTokensKey = walletStore.currentViewedHoldingTokensKey
|
||||||
}
|
}
|
||||||
d.swapFormData.toTokenKey = RootStore.areTestNetworksEnabled ? Constants.swap.testStatusTokenKey : Constants.swap.mainnetStatusTokenKey
|
d.swapFormData.defaultToTokenKey = RootStore.areTestNetworksEnabled ? Constants.swap.testStatusTokenKey : Constants.swap.mainnetStatusTokenKey
|
||||||
Global.openSwapModalRequested(d.swapFormData)
|
Global.openSwapModalRequested(d.swapFormData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ ComboBox {
|
||||||
Component {
|
Component {
|
||||||
id: textContentItem
|
id: textContentItem
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
objectName: "holdingSelectorsContentItemText"
|
objectName: "tokenSelectorContentItemText"
|
||||||
font.pixelSize: root.font.pixelSize
|
font.pixelSize: root.font.pixelSize
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
color: Theme.palette.primaryColor1
|
color: Theme.palette.primaryColor1
|
||||||
|
@ -196,13 +196,13 @@ ComboBox {
|
||||||
: ""
|
: ""
|
||||||
spacing: root.spacing
|
spacing: root.spacing
|
||||||
StatusRoundedImage {
|
StatusRoundedImage {
|
||||||
objectName: "holdingSelectorsTokenIcon"
|
objectName: "tokenSelectorIcon"
|
||||||
Layout.preferredWidth: 20
|
Layout.preferredWidth: 20
|
||||||
Layout.preferredHeight: 20
|
Layout.preferredHeight: 20
|
||||||
image.source: Constants.tokenIcon(parent.currentSymbol)
|
image.source: Constants.tokenIcon(parent.currentSymbol)
|
||||||
}
|
}
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
objectName: "holdingSelectorsContentItemText"
|
objectName: "tokenSelectorContentItemText"
|
||||||
font.pixelSize: 28
|
font.pixelSize: 28
|
||||||
color: root.hovered ? Theme.palette.blue : Theme.palette.darkBlue
|
color: root.hovered ? Theme.palette.blue : Theme.palette.darkBlue
|
||||||
text: parent.currentSymbol
|
text: parent.currentSymbol
|
||||||
|
|
|
@ -37,14 +37,7 @@ Control {
|
||||||
onTokenKeyChanged: Qt.callLater(reevaluateSelectedId)
|
onTokenKeyChanged: Qt.callLater(reevaluateSelectedId)
|
||||||
|
|
||||||
property string tokenAmount
|
property string tokenAmount
|
||||||
onTokenAmountChanged: {
|
onTokenAmountChanged: Qt.callLater(d.updateInputText)
|
||||||
if (tokenAmount === "") {
|
|
||||||
amountToSendInput.input.input.edit.clear()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Qt.callLater(() => amountToSendInput.input.text =
|
|
||||||
SQUtils.AmountsArithmetic.fromString(tokenAmount).toFixed().replace('.', LocaleUtils.userInputLocale.decimalPoint))
|
|
||||||
}
|
|
||||||
|
|
||||||
property int swapSide: SwapInputPanel.SwapSide.Pay
|
property int swapSide: SwapInputPanel.SwapSide.Pay
|
||||||
property bool fiatInputInteractive
|
property bool fiatInputInteractive
|
||||||
|
@ -53,10 +46,8 @@ Control {
|
||||||
property bool interactive: true
|
property bool interactive: true
|
||||||
|
|
||||||
function reevaluateSelectedId() {
|
function reevaluateSelectedId() {
|
||||||
if (!!tokenKey) {
|
holdingSelector.selectToken(tokenKey)
|
||||||
holdingSelector.selectToken(tokenKey)
|
d.selectedHolding = SQUtils.ModelUtils.getByKey(holdingSelector.model, "tokensKey", holdingSelector.currentTokensKey)
|
||||||
d.selectedHolding = SQUtils.ModelUtils.getByKey(holdingSelector.model, "tokensKey", holdingSelector.currentTokensKey)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// output API
|
// output API
|
||||||
|
@ -107,6 +98,17 @@ Control {
|
||||||
accountAddress: root.selectedAccountAddress || ""
|
accountAddress: root.selectedAccountAddress || ""
|
||||||
searchString: holdingSelector.searchString
|
searchString: holdingSelector.searchString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateInputText() {
|
||||||
|
if (!tokenAmount) {
|
||||||
|
amountToSendInput.input.input.edit.clear()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let amountToSet = SQUtils.AmountsArithmetic.fromString(tokenAmount).toFixed().replace('.', LocaleUtils.userInputLocale.decimalPoint)
|
||||||
|
if (amountToSendInput.input.text !== amountToSet) {
|
||||||
|
amountToSendInput.input.text = amountToSet
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
background: Shape {
|
background: Shape {
|
||||||
|
|
|
@ -13,10 +13,13 @@ QtObject {
|
||||||
property int selectedNetworkChainId: -1
|
property int selectedNetworkChainId: -1
|
||||||
property string fromTokensKey: ""
|
property string fromTokensKey: ""
|
||||||
property string fromTokenAmount: ""
|
property string fromTokenAmount: ""
|
||||||
property string toTokenKey: ""
|
property string toTokenKey: root.defaultToTokenKey
|
||||||
property string toTokenAmount: ""
|
property string toTokenAmount: ""
|
||||||
property double selectedSlippage: 0.5
|
property double selectedSlippage: 0.5
|
||||||
|
|
||||||
|
// default token key
|
||||||
|
property string defaultToTokenKey: ""
|
||||||
|
|
||||||
onSelectedAccountAddressChanged: root.formValuesChanged()
|
onSelectedAccountAddressChanged: root.formValuesChanged()
|
||||||
onSelectedNetworkChainIdChanged: root.formValuesChanged()
|
onSelectedNetworkChainIdChanged: root.formValuesChanged()
|
||||||
onFromTokensKeyChanged: root.formValuesChanged()
|
onFromTokensKeyChanged: root.formValuesChanged()
|
||||||
|
@ -27,11 +30,15 @@ QtObject {
|
||||||
function resetFormData() {
|
function resetFormData() {
|
||||||
selectedAccountAddress = ""
|
selectedAccountAddress = ""
|
||||||
selectedNetworkChainId = -1
|
selectedNetworkChainId = -1
|
||||||
|
selectedSlippage = 0.5
|
||||||
|
root.resetToAndFromTokenValues()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetToAndFromTokenValues() {
|
||||||
fromTokensKey = ""
|
fromTokensKey = ""
|
||||||
fromTokenAmount = ""
|
fromTokenAmount = ""
|
||||||
toTokenKey = ""
|
toTokenKey = root.defaultToTokenKey
|
||||||
toTokenAmount = ""
|
toTokenAmount = ""
|
||||||
selectedSlippage = 0.5
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFormFilledCorrectly() {
|
function isFormFilledCorrectly() {
|
||||||
|
|
|
@ -40,9 +40,10 @@ StatusDialog {
|
||||||
})
|
})
|
||||||
|
|
||||||
function fetchSuggestedRoutes() {
|
function fetchSuggestedRoutes() {
|
||||||
if (payPanel.valueValid && !!payPanel.selectedHoldingId) {
|
if (payPanel.valueValid && root.swapInputParamsForm.isFormFilledCorrectly()) {
|
||||||
root.swapAdaptor.newFetchReset()
|
root.swapAdaptor.validSwapProposalReceived = false
|
||||||
root.swapAdaptor.swapProposalLoading = true
|
root.swapAdaptor.swapProposalLoading = true
|
||||||
|
root.swapAdaptor.swapOutputData.resetAllButReceivedTokenValuesForSwap()
|
||||||
debounceFetchSuggestedRoutes()
|
debounceFetchSuggestedRoutes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,10 +158,14 @@ StatusDialog {
|
||||||
nonInteractiveTokensKey: receivePanel.selectedHoldingId
|
nonInteractiveTokensKey: receivePanel.selectedHoldingId
|
||||||
|
|
||||||
swapSide: SwapInputPanel.SwapSide.Pay
|
swapSide: SwapInputPanel.SwapSide.Pay
|
||||||
swapExchangeButtonWidth: swapButton.width
|
swapExchangeButtonWidth: swapExchangeButton.width
|
||||||
|
|
||||||
onSelectedHoldingIdChanged: root.swapInputParamsForm.fromTokensKey = selectedHoldingId
|
onSelectedHoldingIdChanged: root.swapInputParamsForm.fromTokensKey = selectedHoldingId
|
||||||
onValueChanged: root.swapInputParamsForm.fromTokenAmount = value.toLocaleString(locale, 'f', -128)
|
onValueChanged: {
|
||||||
|
if(root.swapInputParamsForm.fromTokensKey === selectedHoldingId) {
|
||||||
|
root.swapInputParamsForm.fromTokenAmount = !tokenAmount && value === 0 ? "" : value.toLocaleString(locale, 'f', -128)
|
||||||
|
}
|
||||||
|
}
|
||||||
onValueValidChanged: d.fetchSuggestedRoutes()
|
onValueValidChanged: d.fetchSuggestedRoutes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +191,7 @@ StatusDialog {
|
||||||
nonInteractiveTokensKey: payPanel.selectedHoldingId
|
nonInteractiveTokensKey: payPanel.selectedHoldingId
|
||||||
|
|
||||||
swapSide: SwapInputPanel.SwapSide.Receive
|
swapSide: SwapInputPanel.SwapSide.Receive
|
||||||
swapExchangeButtonWidth: swapButton.width
|
swapExchangeButtonWidth: swapExchangeButton.width
|
||||||
|
|
||||||
mainInputLoading: root.swapAdaptor.swapProposalLoading
|
mainInputLoading: root.swapAdaptor.swapProposalLoading
|
||||||
bottomTextLoading: root.swapAdaptor.swapProposalLoading
|
bottomTextLoading: root.swapAdaptor.swapProposalLoading
|
||||||
|
@ -200,8 +205,17 @@ StatusDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
SwapExchangeButton {
|
SwapExchangeButton {
|
||||||
id: swapButton
|
id: swapExchangeButton
|
||||||
|
objectName: "swapExchangeButton"
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
onClicked: {
|
||||||
|
const tempPayToken = root.swapInputParamsForm.fromTokensKey
|
||||||
|
const tempPayAmount = root.swapInputParamsForm.fromTokenAmount
|
||||||
|
root.swapInputParamsForm.fromTokensKey = root.swapInputParamsForm.toTokenKey
|
||||||
|
root.swapInputParamsForm.fromTokenAmount = !!root.swapAdaptor.swapOutputData.toTokenAmount ? root.swapAdaptor.swapOutputData.toTokenAmount : root.swapInputParamsForm.toTokenAmount
|
||||||
|
root.swapInputParamsForm.toTokenKey = tempPayToken
|
||||||
|
root.swapInputParamsForm.toTokenAmount = tempPayAmount
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,13 +168,6 @@ QObject {
|
||||||
root.swapProposalLoading = false
|
root.swapProposalLoading = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function will not reset input params but only the output ones and loading states
|
|
||||||
function newFetchReset() {
|
|
||||||
root.swapOutputData.reset()
|
|
||||||
root.validSwapProposalReceived = false
|
|
||||||
root.swapProposalLoading = false
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNetworkShortNames(chainIds) {
|
function getNetworkShortNames(chainIds) {
|
||||||
var networkString = ""
|
var networkString = ""
|
||||||
let chainIdsArray = chainIds.split(":")
|
let chainIdsArray = chainIds.split(":")
|
||||||
|
@ -212,8 +205,8 @@ QObject {
|
||||||
|
|
||||||
function fetchSuggestedRoutes(cryptoValueRaw) {
|
function fetchSuggestedRoutes(cryptoValueRaw) {
|
||||||
if (root.swapFormData.isFormFilledCorrectly() && !!cryptoValueRaw) {
|
if (root.swapFormData.isFormFilledCorrectly() && !!cryptoValueRaw) {
|
||||||
|
root.swapProposalLoading = true
|
||||||
root.swapOutputData.reset()
|
root.swapOutputData.reset()
|
||||||
root.validSwapProposalReceived = false
|
|
||||||
|
|
||||||
// Identify new swap with a different uuid
|
// Identify new swap with a different uuid
|
||||||
d.uuid = Utils.uuid()
|
d.uuid = Utils.uuid()
|
||||||
|
@ -228,7 +221,6 @@ QObject {
|
||||||
disabledChainIds, disabledChainIds, preferedChainIds,
|
disabledChainIds, disabledChainIds, preferedChainIds,
|
||||||
Constants.SendType.Swap, "")
|
Constants.SendType.Swap, "")
|
||||||
} else {
|
} else {
|
||||||
root.validSwapProposalReceived = false
|
|
||||||
root.swapProposalLoading = false
|
root.swapProposalLoading = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,10 @@ QtObject {
|
||||||
function reset() {
|
function reset() {
|
||||||
root.fromTokenAmount = ""
|
root.fromTokenAmount = ""
|
||||||
root.toTokenAmount = ""
|
root.toTokenAmount = ""
|
||||||
|
root.resetAllButReceivedTokenValuesForSwap()
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetAllButReceivedTokenValuesForSwap() {
|
||||||
root.totalFees = 0
|
root.totalFees = 0
|
||||||
root.bestRoutes = []
|
root.bestRoutes = []
|
||||||
root.approvalNeeded = false
|
root.approvalNeeded = false
|
||||||
|
|
|
@ -43,13 +43,17 @@ Item {
|
||||||
implicitHeight: comboBox.implicitHeight
|
implicitHeight: comboBox.implicitHeight
|
||||||
|
|
||||||
onSelectedItemChanged: {
|
onSelectedItemChanged: {
|
||||||
d.iconSource = itemIconSourceFn(selectedItem) ?? defaultIconSource
|
let iconSource = itemIconSourceFn(selectedItem)
|
||||||
d.text = itemTextFn(selectedItem) ?? placeholderText
|
d.iconSource = !selectedItem ? "" : !!iconSource ? iconSource : defaultIconSource
|
||||||
|
let itemText = itemTextFn(selectedItem)
|
||||||
|
d.text = !!itemText ? itemText : placeholderText
|
||||||
}
|
}
|
||||||
|
|
||||||
onHoveredItemChanged: {
|
onHoveredItemChanged: {
|
||||||
d.iconSource = itemIconSourceFn(hoveredItem) ?? defaultIconSource
|
let iconSource = itemIconSourceFn(hoveredItem)
|
||||||
d.text = itemTextFn(hoveredItem) ?? placeholderText
|
d.iconSource = !!iconSource ? iconSource : defaultIconSource
|
||||||
|
let itemText = itemTextFn(hoveredItem)
|
||||||
|
d.text = !!itemText ? itemText : placeholderText
|
||||||
}
|
}
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
|
@ -105,7 +109,7 @@ Item {
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
objectName: "holdingSelectorsContentItemText"
|
objectName: "holdingSelectorsContentItemText"
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
font.pixelSize: root.contentTextSize
|
font.pixelSize: !selectedItem && !hoveredItem ? Theme.primaryTextFontSize : root.contentTextSize
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
color: Theme.palette.primaryColor1
|
color: Theme.palette.primaryColor1
|
||||||
|
|
|
@ -190,7 +190,7 @@ Item {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
|
||||||
defaultIconSource: Style.png("tokens/DEFAULT-TOKEN@3x")
|
defaultIconSource: Style.png("tokens/DEFAULT-TOKEN@3x")
|
||||||
placeholderText: d.isCurrentBrowsingTypeAsset ? qsTr("Select token") : qsTr("Select collectible")
|
placeholderText: d.isCurrentBrowsingTypeAsset ? qsTr("Select asset") : qsTr("Select collectible")
|
||||||
property bool hasCommunityTokens: false
|
property bool hasCommunityTokens: false
|
||||||
|
|
||||||
comboBoxDelegate: Item {
|
comboBoxDelegate: Item {
|
||||||
|
|
Loading…
Reference in New Issue