fix(wallet) don't show too big account index for custom path
The warning for not supported bigger than 99 for the account index make sense only for standard derivation paths that we support. Also added test case to story book for investigating the issue #10479 updates #10479
This commit is contained in:
parent
b07ba7fb2d
commit
6a0a7770b2
|
@ -21,7 +21,7 @@ SplitView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
DerivationPathInput {
|
DerivationPathInput {
|
||||||
id: devTxtEdit
|
id: testControl
|
||||||
|
|
||||||
initialDerivationPath: initialBasePath + (initialBasePath.split("'").length > 4 ? "/0" : "/0'")
|
initialDerivationPath: initialBasePath + (initialBasePath.split("'").length > 4 ? "/0" : "/0'")
|
||||||
initialBasePath: stdBaseListView.currentIndex >= 0
|
initialBasePath: stdBaseListView.currentIndex >= 0
|
||||||
|
@ -41,7 +41,7 @@ SplitView {
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
derivationPathSelection.popup(0, devTxtEdit.height + Style.current.halfPadding)
|
derivationPathSelection.popup(0, testControl.height + Style.current.halfPadding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,13 +110,13 @@ SplitView {
|
||||||
highlighted: hovered
|
highlighted: hovered
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
devTxtEdit.resetDerivationPath(customDerivationPathBaseInput.text, customDerivationPathInput.text)
|
testControl.resetDerivationPath(customDerivationPathBaseInput.text, customDerivationPathInput.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: devTxtEdit.errorMessage
|
text: testControl.errorMessage
|
||||||
visible: devTxtEdit.errorMessage.length > 0
|
visible: testControl.errorMessage.length > 0
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ SplitView {
|
||||||
color: "red"
|
color: "red"
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
text: devTxtEdit.warningMessage
|
text: testControl.warningMessage
|
||||||
visible: devTxtEdit.warningMessage.length > 0
|
visible: testControl.warningMessage.length > 0
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
@ -136,12 +136,38 @@ SplitView {
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Label { text: "Output: " }
|
Label { text: "Output: " }
|
||||||
Label { id: base; text: devTxtEdit.derivationPath }
|
Label { id: base; text: testControl.derivationPath }
|
||||||
}
|
}
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Label { text: "Last event: " }
|
Label { text: "Last event: " }
|
||||||
Label { id: lastEvent; text: "" }
|
Label { id: lastEvent; text: "" }
|
||||||
}
|
}
|
||||||
|
CheckBox {
|
||||||
|
id: reflexiveMode
|
||||||
|
text: "Auto echo derivation path onto itself every " + reflexiveTimer.interval + " ms"
|
||||||
|
checked: false
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
text: "Standard base path detected"
|
||||||
|
checked: testControl.detectedStandardBasePath
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: reflexiveTimer
|
||||||
|
interval: 100
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
onTriggered: testControl.resetDerivationPath(testControl.basePath, testControl.derivationPath)
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: testControl
|
||||||
|
function onDerivationPathChanged() {
|
||||||
|
if (reflexiveMode.checked) {
|
||||||
|
reflexiveTimer.restart()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Border {
|
Border {
|
||||||
|
@ -151,10 +177,10 @@ SplitView {
|
||||||
target: customDerivationPathBaseInput
|
target: customDerivationPathBaseInput
|
||||||
}
|
}
|
||||||
Border {
|
Border {
|
||||||
target: devTxtEdit
|
target: testControl
|
||||||
}
|
}
|
||||||
Border {
|
Border {
|
||||||
target: devTxtEdit
|
target: testControl
|
||||||
radius: 0
|
radius: 0
|
||||||
border.color: "#22FF0000"
|
border.color: "#22FF0000"
|
||||||
}
|
}
|
||||||
|
@ -172,7 +198,7 @@ SplitView {
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
onCurrentIndexChanged: {
|
||||||
const newBasePath = standardBasePathModel.get(currentIndex).derivationPath
|
const newBasePath = standardBasePathModel.get(currentIndex).derivationPath
|
||||||
devTxtEdit.resetDerivationPath(newBasePath, newBasePath + (newBasePath.split("'").length > 3 ? "/0" : "/0'"))
|
testControl.resetDerivationPath(newBasePath, newBasePath + (newBasePath.split("'").length > 3 ? "/0" : "/0'"))
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: ItemDelegate {
|
delegate: ItemDelegate {
|
||||||
|
|
|
@ -16,6 +16,7 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property alias derivationPath: d.currentDerivationPath
|
readonly property alias derivationPath: d.currentDerivationPath
|
||||||
|
readonly property alias basePath: d.currentBasePath
|
||||||
|
|
||||||
required property string initialDerivationPath
|
required property string initialDerivationPath
|
||||||
required property string initialBasePath
|
required property string initialBasePath
|
||||||
|
@ -27,6 +28,8 @@ Item {
|
||||||
|
|
||||||
property alias input: input
|
property alias input: input
|
||||||
|
|
||||||
|
readonly property alias detectedStandardBasePath: d.detectedStandardBasePath
|
||||||
|
|
||||||
signal editingFinished()
|
signal editingFinished()
|
||||||
|
|
||||||
implicitWidth: input.implicitWidth
|
implicitWidth: input.implicitWidth
|
||||||
|
@ -41,7 +44,12 @@ Item {
|
||||||
}
|
}
|
||||||
d.resetMessages()
|
d.resetMessages()
|
||||||
d.elements = res.elements
|
d.elements = res.elements
|
||||||
|
|
||||||
|
// Check if we enforced a standard derivation path
|
||||||
|
d.frozenLevelCount = d.elements.filter((e) => e.isFrozen && e.isNumber()).length
|
||||||
|
|
||||||
d.updateText(d.elements)
|
d.updateText(d.elements)
|
||||||
|
d.currentBasePath = basePath
|
||||||
input.cursorPosition = d.elements[d.elements.length - 1].endIndex
|
input.cursorPosition = d.elements[d.elements.length - 1].endIndex
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -50,6 +58,7 @@ Item {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
property string currentDerivationPath: ""
|
property string currentDerivationPath: ""
|
||||||
|
property string currentBasePath: ""
|
||||||
|
|
||||||
property var elements: []
|
property var elements: []
|
||||||
/// element index at cursor position
|
/// element index at cursor position
|
||||||
|
@ -60,6 +69,9 @@ Item {
|
||||||
property string errorMessage: ""
|
property string errorMessage: ""
|
||||||
property string warningMessage: ""
|
property string warningMessage: ""
|
||||||
|
|
||||||
|
property int frozenLevelCount: 0
|
||||||
|
property bool detectedStandardBasePath: frozenLevelCount >= 3
|
||||||
|
|
||||||
function resetMessages() { errorMessage = ""; warningMessage = "" }
|
function resetMessages() { errorMessage = ""; warningMessage = "" }
|
||||||
|
|
||||||
readonly property bool selectionIsActive: Math.abs(input.selectionEnd - input.selectionStart) > 0
|
readonly property bool selectionIsActive: Math.abs(input.selectionEnd - input.selectionStart) > 0
|
||||||
|
@ -85,6 +97,7 @@ Item {
|
||||||
frozenColor: Theme.palette.getColor('grey5')
|
frozenColor: Theme.palette.getColor('grey5')
|
||||||
errorColor: Theme.palette.dangerColor1
|
errorColor: Theme.palette.dangerColor1
|
||||||
warningColor: Theme.palette.warningColor1
|
warningColor: Theme.palette.warningColor1
|
||||||
|
complainTooBigAccIndex: d.detectedStandardBasePath
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBaseInput {
|
StatusBaseInput {
|
||||||
|
|
|
@ -14,6 +14,7 @@ Item {
|
||||||
|
|
||||||
/// Don't allow inserting more than \c levelsLimit Number elements
|
/// Don't allow inserting more than \c levelsLimit Number elements
|
||||||
property int levelsLimit: 0
|
property int levelsLimit: 0
|
||||||
|
property bool complainTooBigAccIndex: true
|
||||||
|
|
||||||
readonly property string inputError: qsTr("Please enter numbers only")
|
readonly property string inputError: qsTr("Please enter numbers only")
|
||||||
readonly property string tooBigError: qsTr("Account number must be <100")
|
readonly property string tooBigError: qsTr("Account number must be <100")
|
||||||
|
@ -415,7 +416,7 @@ Item {
|
||||||
return {error: root.inputError, warning: ""}
|
return {error: root.inputError, warning: ""}
|
||||||
} else if(numberLevel == 0 && !element.isEmptyNumber() && element.number() != d.ethereumCoinType) {
|
} else if(numberLevel == 0 && !element.isEmptyNumber() && element.number() != d.ethereumCoinType) {
|
||||||
return {error: "", warning: root.nonEthCoinWarning}
|
return {error: "", warning: root.nonEthCoinWarning}
|
||||||
} else if(numberLevel >= d.addressIndexStart && element.number() >= 100) {
|
} else if(root.complainTooBigAccIndex && numberLevel >= d.addressIndexStart && element.number() >= 100) {
|
||||||
return {error: root.tooBigError, warning: ""}
|
return {error: root.tooBigError, warning: ""}
|
||||||
}
|
}
|
||||||
return {error: "", warning: ""}
|
return {error: "", warning: ""}
|
||||||
|
|
Loading…
Reference in New Issue