feat(MintToken): Validation on name / symbol if exists in standard token list
- It adds link to the corresponding tokens model in `EditCommunityTokenView`. - It adds validation for `name` and `symbol`. - It updates `storybook accordingly.` Closes #12365
This commit is contained in:
parent
aaa759f70c
commit
743ba6929c
|
@ -32,9 +32,18 @@ SplitView {
|
|||
layer2Networks: NetworksModel.layer2Networks
|
||||
accounts: WalletAccountsModel {}
|
||||
tokensModel: MintedTokensModel {}
|
||||
tokensModelWallet: ListModel {
|
||||
referenceAssetsBySymbolModel: ListModel {
|
||||
ListElement {
|
||||
symbol: "MAI"
|
||||
name: "eth"
|
||||
symbol: "ETH"
|
||||
}
|
||||
ListElement {
|
||||
name: "dai"
|
||||
symbol: "DAI"
|
||||
}
|
||||
ListElement {
|
||||
name: "snt"
|
||||
symbol: "SNT"
|
||||
}
|
||||
}
|
||||
onPreviewClicked: logs.logEvent("EditCommunityTokenView::previewClicked")
|
||||
|
|
|
@ -114,9 +114,18 @@ SplitView {
|
|||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
accounts: WalletAccountsModel {}
|
||||
tokensModelWallet: ListModel {
|
||||
referenceAssetsBySymbolModel: ListModel {
|
||||
ListElement {
|
||||
symbol: "MAI"
|
||||
name: "eth"
|
||||
symbol: "ETH"
|
||||
}
|
||||
ListElement {
|
||||
name: "dai"
|
||||
symbol: "DAI"
|
||||
}
|
||||
ListElement {
|
||||
name: "snt"
|
||||
symbol: "SNT"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ StackLayout {
|
|||
readonly property var contactsStore: rootStore.contactsStore
|
||||
readonly property var permissionsStore: rootStore.permissionsStore
|
||||
property var communitiesStore
|
||||
required property WalletStore.TokensStore tokensStore
|
||||
|
||||
property var sectionItemModel
|
||||
property var sendModalPopup
|
||||
|
@ -188,6 +189,7 @@ StackLayout {
|
|||
id: communitySettingsView
|
||||
rootStore: root.rootStore
|
||||
walletAccountsModel: WalletStore.RootStore.nonWatchAccounts
|
||||
tokensStore: root.tokensStore
|
||||
sendModalPopup: root.sendModalPopup
|
||||
|
||||
isPendingOwnershipRequest: root.isPendingOwnershipRequest
|
||||
|
|
|
@ -50,8 +50,9 @@ StackView {
|
|||
|
||||
// Models:
|
||||
property var tokensModel
|
||||
property var tokensModelWallet
|
||||
property var accounts // Expected roles: address, name, color, emoji, walletType
|
||||
required property var referenceAssetsBySymbolModel
|
||||
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
|
@ -375,7 +376,7 @@ StackView {
|
|||
layer2Networks: root.layer2Networks
|
||||
accounts: root.accounts
|
||||
tokensModel: root.tokensModel
|
||||
tokensModelWallet: root.tokensModelWallet
|
||||
referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel
|
||||
|
||||
referenceName: newTokenPage.referenceName
|
||||
referenceSymbol: newTokenPage.referenceSymbol
|
||||
|
|
|
@ -23,6 +23,8 @@ import AppLayouts.Communities.panels 1.0
|
|||
import AppLayouts.Communities.popups 1.0
|
||||
import AppLayouts.Communities.helpers 1.0
|
||||
|
||||
import AppLayouts.Wallet.stores 1.0
|
||||
|
||||
StatusSectionLayout {
|
||||
id: root
|
||||
|
||||
|
@ -32,6 +34,7 @@ StatusSectionLayout {
|
|||
|
||||
property var rootStore
|
||||
property var chatCommunitySectionModule
|
||||
required property TokensStore tokensStore
|
||||
property var community
|
||||
property var transactionStore: TransactionStore {}
|
||||
property bool communitySettingsDisabled
|
||||
|
@ -346,12 +349,12 @@ StatusSectionLayout {
|
|||
|
||||
// Models
|
||||
tokensModel: root.community.communityTokens
|
||||
tokensModelWallet: root.rootStore.tokensModelWallet
|
||||
layer1Networks: communityTokensStore.layer1Networks
|
||||
layer2Networks: communityTokensStore.layer2Networks
|
||||
enabledNetworks: communityTokensStore.enabledNetworks
|
||||
allNetworks: communityTokensStore.allNetworks
|
||||
accounts: root.walletAccountsModel
|
||||
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel
|
||||
|
||||
onRegisterDeployFeesSubscriber: d.feesBroker.registerDeployFeesSubscriber(feeSubscriber)
|
||||
|
||||
|
|
|
@ -26,10 +26,12 @@ StatusScrollView {
|
|||
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
|
||||
|
||||
property var tokensModel
|
||||
property var tokensModelWallet
|
||||
property TokenObject token: TokenObject {
|
||||
type: root.isAssetView ? Constants.TokenType.ERC20 : Constants.TokenType.ERC721
|
||||
}
|
||||
|
||||
// Used for reference validation
|
||||
required property var referenceAssetsBySymbolModel
|
||||
|
||||
// Used for reference validation when editing a failed deployment
|
||||
property string referenceName: ""
|
||||
|
@ -66,6 +68,24 @@ StatusScrollView {
|
|||
|
||||
readonly property int imageSelectorRectWidth: root.isAssetView ? 128 : 290
|
||||
|
||||
readonly property bool containsAssetReferenceName: root.isAssetView ? checkNameProxy.count > 0 : false
|
||||
readonly property SortFilterProxyModel checkNameProxy : SortFilterProxyModel {
|
||||
sourceModel: root.referenceAssetsBySymbolModel
|
||||
filters: ValueFilter {
|
||||
roleName: "name"
|
||||
value: nameInput.text
|
||||
}
|
||||
}
|
||||
|
||||
readonly property bool containsAssetReferenceSymbol: root.isAssetView ? checkSymbolProxy.count > 0 : false
|
||||
readonly property SortFilterProxyModel checkSymbolProxy: SortFilterProxyModel {
|
||||
sourceModel: root.referenceAssetsBySymbolModel
|
||||
filters: ValueFilter {
|
||||
roleName: "symbol"
|
||||
value: symbolInput.text
|
||||
}
|
||||
}
|
||||
|
||||
function hasEmoji(text) {
|
||||
return SQUtils.Emoji.hasEmoji(SQUtils.Emoji.parse(text));
|
||||
}
|
||||
|
@ -126,9 +146,10 @@ StatusScrollView {
|
|||
return true
|
||||
|
||||
// Otherwise, no repeated names allowed:
|
||||
return !SQUtils.ModelUtils.contains(root.tokensModel, "name", nameInput.text, Qt.CaseInsensitive)
|
||||
return (!SQUtils.ModelUtils.contains(root.tokensModel, "name", nameInput.text, Qt.CaseInsensitive) && !d.containsAssetReferenceName)
|
||||
}
|
||||
extraValidator.errorMessage: qsTr("You have used this token name before")
|
||||
extraValidator.errorMessage: d.containsAssetReferenceName ? qsTr("Asset name already exists") :
|
||||
qsTr("You have used this token name before")
|
||||
|
||||
onTextChanged: root.token.name = text
|
||||
}
|
||||
|
@ -173,12 +194,9 @@ StatusScrollView {
|
|||
return true
|
||||
|
||||
// Otherwise, no repeated names allowed:
|
||||
return (!SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) &&
|
||||
!SQUtils.ModelUtils.contains(root.tokensModelWallet, "symbol", symbolInput.text))
|
||||
return (!SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) && !d.containsAssetReferenceSymbol)
|
||||
}
|
||||
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")
|
||||
extraValidator.errorMessage: d.containsAssetReferenceSymbol ? qsTr("Symbol already exists") : qsTr("You have used this token symbol before")
|
||||
|
||||
onTextChanged: {
|
||||
const cursorPos = input.edit.cursorPosition
|
||||
|
|
|
@ -73,7 +73,7 @@ QtObject {
|
|||
of symbol clash when minting community tokens, so in case of community tokens
|
||||
there will be one entry per address + network pair */
|
||||
// TODO in #12513
|
||||
readonly property var tokensBySymbolModel: SortFilterProxyModel {
|
||||
readonly property var assetsBySymbolModel: SortFilterProxyModel {
|
||||
sourceModel: !!root._allTokensModule ? root._allTokensModule.tokensBySymbolModel : null
|
||||
proxyRoles: [
|
||||
ExpressionRole {
|
||||
|
|
|
@ -146,7 +146,6 @@ 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
|
||||
|
|
|
@ -1168,6 +1168,7 @@ Item {
|
|||
networkConnectionStore: appMain.networkConnectionStore
|
||||
}
|
||||
createChatPropertiesStore: appMain.createChatPropertiesStore
|
||||
tokensStore: appMain.tokensStore
|
||||
emojiPopup: statusEmojiPopup.item
|
||||
stickersPopup: statusStickersPopupLoader.item
|
||||
|
||||
|
@ -1336,6 +1337,7 @@ Item {
|
|||
return appMain.rootStore.mainModuleInst.getCommunitySectionModule()
|
||||
}
|
||||
}
|
||||
tokensStore: appMain.tokensStore
|
||||
|
||||
onProfileButtonClicked: {
|
||||
Global.changeAppSectionBySectionType(Constants.appSection.profile);
|
||||
|
|
Loading…
Reference in New Issue