Set custom network id

This commit is contained in:
Richard Ramos 2021-01-08 19:07:32 -04:00 committed by Iuri Matias
parent 6b1cef9235
commit 29742e2074
1 changed files with 28 additions and 3 deletions

View File

@ -62,16 +62,18 @@ ModalPopup {
ModalPopup {
id: addNetworkPopup
title: qsTr("Add network")
height: 600
height: 650
property string nameValidationError: ""
property string rpcValidationError: ""
property string networkValidationError: ""
property int networkId: 1;
property string networkType: Constants.networkMainnet
function validate() {
nameValidationError = ""
rpcValidationError = ""
networkValidationError = "";
if (nameInput.text === "") {
nameValidationError = qsTr("You need to enter a name")
@ -83,18 +85,29 @@ ModalPopup {
rpcValidationError = qsTr("Invalid URL")
}
return !nameValidationError && !rpcValidationError
if (customRadioBtn.checked) {
if (networkInput.text === "") {
networkValidationError = qsTr("You need to enter the network id")
} else if (isNaN(networkInput.text)){
networkValidationError = qsTr("Should be a number");
} else if (parseInt(networkInput.text, 10) <= 4){
networkValidationError = qsTr("Invalid network id");
}
}
return !nameValidationError && !rpcValidationError && !networkValidationError
}
onOpened: {
nameInput.text = "";
rpcInput.text = "";
networkInput.text = "";
mainnetRadioBtn.checked = true;
addNetworkPopup.networkId = 1;
addNetworkPopup.networkType = Constants.networkMainnet;
nameValidationError = "";
rpcValidationError = "";
networkValidationError = "";
}
footer: StyledButton {
@ -107,6 +120,11 @@ ModalPopup {
if (!addNetworkPopup.validate()) {
return;
}
if (customRadioBtn.checked){
addNetworkPopup.networkId = parseInt(networkInput.text, 10);
}
profileModel.network.add(nameInput.text, rpcInput.text, addNetworkPopup.networkId, addNetworkPopup.networkType)
profileModel.network.reloadCustomNetworks();
addNetworkPopup.close()
@ -211,11 +229,18 @@ ModalPopup {
ButtonGroup.group: networkChainGroup
rightPadding: 0
onClicked: {
addNetworkPopup.networkId = 55; // TODO
addNetworkPopup.networkType = "";
}
}
}
Input {
id: networkInput
visible: customRadioBtn.checked
label: qsTr("Network Id")
placeholderText: qsTr("Specify the network id")
validationError: addNetworkPopup.networkValidationError
}
}
}
}