fix(EditCommunityToken): prevent using already existing symbols

Closes #10784
This commit is contained in:
Alexandra Betouni 2023-07-04 16:21:15 +03:00
parent a6494bfe33
commit ce06fc3a99
6 changed files with 22 additions and 4 deletions

View File

@ -35,6 +35,11 @@ SplitView {
allNetworks: enabledNetworks
accounts: WalletAccountsModel {}
tokensModel: MintedTokensModel {}
tokensModelWallet: ListModel {
ListElement {
symbol: "MAI"
}
}
onPreviewClicked: logs.logEvent("EditCommunityTokenView::previewClicked")
}
}

View File

@ -57,7 +57,11 @@ SplitView {
enabledNetworks: NetworksModel.enabledNetworks
allNetworks: enabledNetworks
accounts: WalletAccountsModel {}
tokensModelWallet: ListModel {
ListElement {
symbol: "MAI"
}
}
onMintCollectible: logs.logEvent("CommunityMintTokensSettingsPanel::mintCollectible")
onMintAsset: logs.logEvent("CommunityMintTokensSettingsPanel::mintAssets")
onDeleteToken: logs.logEvent("CommunityMintTokensSettingsPanel::deleteToken: " + tokenKey)

View File

@ -24,6 +24,7 @@ StackView {
// Models:
property var tokensModel
property var tokensModelWallet
property var accounts // Expected roles: address, name, color, emoji, walletType
// Transaction related properties:
@ -183,6 +184,7 @@ StackView {
allNetworks: root.allNetworks
accounts: root.accounts
tokensModel: root.tokensModel
tokensModelWallet: root.tokensModelWallet
referenceName: newTokenPage.referenceName
referenceSymbol: newTokenPage.referenceSymbol

View File

@ -295,13 +295,13 @@ StatusSectionLayout {
mintPanel.isFeeLoading = true
return
}
mintPanel.errorText = qsTr("Unknown error")
mintPanel.isFeeLoading = true
}
communityName: root.community.name
tokensModel: root.community.communityTokens
tokensModelWallet: root.rootStore.tokensModelWallet
layer1Networks: communityTokensStore.layer1Networks
layer2Networks: communityTokensStore.layer2Networks
testNetworks: communityTokensStore.testNetworks

View File

@ -24,6 +24,7 @@ StatusScrollView {
property bool isAssetView: false
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
property var tokensModel
property var tokensModelWallet
property TokenObject collectible: TokenObject {
@ -197,9 +198,11 @@ StatusScrollView {
return true
// Otherwise, no repeated names allowed:
return !SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text)
return (!SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) &&
!SQUtils.ModelUtils.contains(root.tokensModelWallet, "symbol", symbolInput.text))
}
extraValidator.errorMessage: qsTr("You have used this token symbol before")
extraValidator.errorMessage: SQUtils.ModelUtils.contains(root.tokensModelWallet, "symbol", symbolInput.text) ?
qsTr("This token symbol is already in use") : qsTr("You have used this token symbol before")
onTextChanged: {
const cursorPos = input.edit.cursorPosition
@ -395,6 +398,9 @@ StatusScrollView {
},
StatusValidator {
id: extraValidatorItem
onErrorMessageChanged: {
customInput.validate();
}
}
]
}

View File

@ -54,6 +54,7 @@ QtObject {
property var accounts: walletSectionSendInst.accounts
// Not Refactored Yet
// property var profileModelInst: profileModel
property var tokensModelWallet//TODO this is not available yet
property var contactStore: profileSectionStore.contactsStore
property var privacyStore: profileSectionStore.privacyStore