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