chore(MintingToken): Refactor access to stores in minting components
- Refactored minting components store access, since some panels were accessing stores directly. Now `CommunitySettingsView` is the single place where stores are accessed. - Renamed store `CommunitesStore` to `CommunityTokensStore` for handling minting / airdrop actions / request models. - `NetworkFilter` refactored to prevent direct access to store inside the component. Closes #9663
This commit is contained in:
parent
5db989db6e
commit
c7f18978de
|
@ -23,28 +23,16 @@ SplitView {
|
|||
CommunityMintTokensSettingsPanel {
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 50
|
||||
transactionStore: QtObject {
|
||||
readonly property var currentAccount: QtObject {
|
||||
readonly property string address: "0x0000001"
|
||||
}
|
||||
}
|
||||
communitiesStore: QtObject {
|
||||
readonly property TokenHoldersModel holdersModel: TokenHoldersModel {}
|
||||
property var layer1Networks: NetworksModel.layer1Networks
|
||||
property var layer2Networks: NetworksModel.layer2Networks
|
||||
property var testNetworks: NetworksModel.testNetworks
|
||||
property var enabledNetworks: NetworksModel.enabledNetworks
|
||||
property var allNetworks: enabledNetworks
|
||||
|
||||
function mintCollectible(communityId, address, artworkSource, name, symbol, description, supply,
|
||||
infiniteSupply, transferable, selfDestruct, chainId)
|
||||
{
|
||||
logs.logEvent("CommunityMintTokensSettingsPanel::mintCollectible")
|
||||
}
|
||||
}
|
||||
|
||||
tokensModel: ListModel {}
|
||||
}
|
||||
holdersModel: TokenHoldersModel {}
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
testNetworks: NetworksModel.testNetworks
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
|
||||
onMintCollectible: ogs.logEvent("CommunityMintTokensSettingsPanel::mintCollectible")
|
||||
}
|
||||
}
|
||||
|
||||
LogsAndControlsPanel {
|
||||
|
|
|
@ -27,13 +27,11 @@ SplitView {
|
|||
CommunityNewCollectibleView {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 50
|
||||
store: QtObject {
|
||||
property var layer1Networks: NetworksModel.layer1Networks
|
||||
property var layer2Networks: NetworksModel.layer2Networks
|
||||
property var testNetworks: NetworksModel.testNetworks
|
||||
property var enabledNetworks: NetworksModel.enabledNetworks
|
||||
property var allNetworks: enabledNetworks
|
||||
}
|
||||
layer1Networks: NetworksModel.layer1Networks
|
||||
layer2Networks: NetworksModel.layer2Networks
|
||||
testNetworks: NetworksModel.testNetworks
|
||||
enabledNetworks: NetworksModel.enabledNetworks
|
||||
allNetworks: enabledNetworks
|
||||
|
||||
onPreviewClicked: logs.logEvent("CommunityNewCollectibleView::previewClicked")
|
||||
}
|
||||
|
|
|
@ -112,7 +112,6 @@ StackLayout {
|
|||
|
||||
sourceComponent: CommunitySettingsView {
|
||||
rootStore: root.rootStore
|
||||
communityStore: CommunitiesStore {}
|
||||
|
||||
hasAddedContacts: root.contactsStore.myContactsModel.count > 0
|
||||
chatCommunitySectionModule: root.rootStore.chatCommunitySectionModule
|
||||
|
|
|
@ -13,12 +13,36 @@ import utils 1.0
|
|||
SettingsPageLayout {
|
||||
id: root
|
||||
|
||||
property string communityId
|
||||
// Models:
|
||||
property var tokensModel
|
||||
property var communitiesStore
|
||||
property var transactionStore
|
||||
property var holdersModel
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
property var testNetworks
|
||||
property var enabledNetworks
|
||||
property var allNetworks
|
||||
|
||||
// Other properties:
|
||||
property alias chainName: collectibleItem.chainName
|
||||
property alias chainIcon: collectibleItem.chainIcon
|
||||
|
||||
property int viewWidth: 560 // by design
|
||||
|
||||
signal mintCollectible(url artworkSource,
|
||||
string name,
|
||||
string symbol,
|
||||
string description,
|
||||
int supply,
|
||||
bool infiniteSupply,
|
||||
bool transferable,
|
||||
bool selfDestruct,
|
||||
int chainId)
|
||||
|
||||
signal requestChainName(int chainId)
|
||||
signal requestChainIcon(int chainId)
|
||||
|
||||
function navigateBack() {
|
||||
if (root.state === d.newCollectibleViewState) {
|
||||
root.state = d.initialState
|
||||
|
@ -86,12 +110,12 @@ SettingsPageLayout {
|
|||
supplyText = model.supply.toString()
|
||||
infiniteSupply = model.infiniteSupply
|
||||
transferable = model.transferable
|
||||
chainName = communitiesStore.getChainName(model.chainId)
|
||||
chainIcon = communitiesStore.getChainIcon(model.chainId)
|
||||
artworkSource = model.image
|
||||
symbol = model.symbol
|
||||
selfDestruct = model.remoteSelfDestruct
|
||||
chainId = model.chainId
|
||||
requestChainName(model.chainId)
|
||||
requestChainIcon(model.chainId)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,7 +198,11 @@ SettingsPageLayout {
|
|||
|
||||
CommunityNewCollectibleView {
|
||||
anchors.fill: parent
|
||||
store: root.communitiesStore
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
testNetworks: root.testNetworks
|
||||
enabledNetworks: root.testNetworks
|
||||
allNetworks: root.allNetworks
|
||||
name: collectibleItem.collectibleName
|
||||
artworkSource: collectibleItem.artworkSource
|
||||
symbol: collectibleItem.symbol
|
||||
|
@ -208,7 +236,7 @@ SettingsPageLayout {
|
|||
CommunityCollectibleView {
|
||||
anchors.fill: parent
|
||||
preview: d.preview
|
||||
holdersModel: root.communitiesStore.holdersModel
|
||||
holdersModel: root.holdersModel
|
||||
deployState: collectibleItem.deployState
|
||||
name: collectibleItem.collectibleName
|
||||
artworkSource: collectibleItem.artworkSource
|
||||
|
@ -222,18 +250,16 @@ SettingsPageLayout {
|
|||
chainName: collectibleItem.chainName
|
||||
chainIcon: collectibleItem.chainIcon
|
||||
|
||||
onDeployCollectible: {
|
||||
root.communitiesStore.deployCollectible(root.communityId,
|
||||
root.transactionStore.currentAccount.address, /*TODO use address from SendModal*/
|
||||
name,
|
||||
symbol,
|
||||
description,
|
||||
supply,
|
||||
infiniteSupply,
|
||||
transferable,
|
||||
selfDestruct,
|
||||
chainId,
|
||||
artworkSource)
|
||||
onMintCollectible: {
|
||||
root.mintCollectible(artworkSource,
|
||||
name,
|
||||
symbol,
|
||||
description,
|
||||
supply,
|
||||
infiniteSupply,
|
||||
transferable,
|
||||
selfDestruct,
|
||||
chainId)
|
||||
|
||||
root.state = d.mintedCollectibleViewState
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ QtObject {
|
|||
chatCommunitySectionModuleInst: chatCommunitySectionModule
|
||||
}
|
||||
|
||||
readonly property CommunityTokensStore communityTokensStore: CommunityTokensStore {}
|
||||
|
||||
property bool openCreateChat: false
|
||||
property string createChatInitMessage: ""
|
||||
property var createChatFileUrls: []
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CommunitiesStore 1.0 CommunitiesStore.qml
|
||||
CommunityTokensStore 1.0 CommunityTokensStore.qml
|
||||
PermissionsStore 1.0 PermissionsStore.qml
|
||||
RootStore 1.0 RootStore.qml
|
||||
StickerData 1.0 StickerData.qml
|
||||
|
|
|
@ -34,19 +34,16 @@ StatusSectionLayout {
|
|||
onNotificationButtonClicked: Global.openActivityCenterPopup()
|
||||
// TODO: get this model from backend?
|
||||
property var settingsMenuModel: [{name: qsTr("Overview"), icon: "show", enabled: true},
|
||||
{name: qsTr("Members"), icon: "group-chat", enabled: true},
|
||||
{name: qsTr("Permissions"), icon: "objects", enabled: root.rootStore.communityPermissionsEnabled},
|
||||
{name: qsTr("Mint Tokens"), icon: "token", enabled: root.rootStore.communityTokensEnabled}]
|
||||
|
||||
{name: qsTr("Members"), icon: "group-chat", enabled: true},
|
||||
{name: qsTr("Permissions"), icon: "objects", enabled: root.rootStore.communityPermissionsEnabled},
|
||||
{name: qsTr("Mint Tokens"), icon: "token", enabled: root.rootStore.communityTokensEnabled}]
|
||||
// TODO: Next community settings options:
|
||||
// {name: qsTr("Airdrops"), icon: "airdrop"},
|
||||
// {name: qsTr("Token sales"), icon: "token-sale"},
|
||||
// {name: qsTr("Subscriptions"), icon: "subscription"},
|
||||
|
||||
property var rootStore
|
||||
property var community
|
||||
property var chatCommunitySectionModule
|
||||
required property CommunitiesStore communityStore
|
||||
property bool hasAddedContacts: false
|
||||
property var transactionStore: TransactionStore {}
|
||||
|
||||
|
@ -198,18 +195,18 @@ StatusSectionLayout {
|
|||
|
||||
onEdited: {
|
||||
const error = root.chatCommunitySectionModule.editCommunity(
|
||||
StatusQUtils.Utils.filterXSS(item.name),
|
||||
StatusQUtils.Utils.filterXSS(item.description),
|
||||
StatusQUtils.Utils.filterXSS(item.introMessage),
|
||||
StatusQUtils.Utils.filterXSS(item.outroMessage),
|
||||
item.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
|
||||
item.color.toString().toUpperCase(),
|
||||
item.selectedTags,
|
||||
Utils.getImageAndCropInfoJson(item.logoImagePath, item.logoCropRect),
|
||||
Utils.getImageAndCropInfoJson(item.bannerPath, item.bannerCropRect),
|
||||
item.options.archiveSupportEnabled,
|
||||
item.options.pinMessagesEnabled
|
||||
)
|
||||
StatusQUtils.Utils.filterXSS(item.name),
|
||||
StatusQUtils.Utils.filterXSS(item.description),
|
||||
StatusQUtils.Utils.filterXSS(item.introMessage),
|
||||
StatusQUtils.Utils.filterXSS(item.outroMessage),
|
||||
item.options.requestToJoinEnabled ? Constants.communityChatOnRequestAccess : Constants.communityChatPublicAccess,
|
||||
item.color.toString().toUpperCase(),
|
||||
item.selectedTags,
|
||||
Utils.getImageAndCropInfoJson(item.logoImagePath, item.logoCropRect),
|
||||
Utils.getImageAndCropInfoJson(item.bannerPath, item.bannerCropRect),
|
||||
item.options.archiveSupportEnabled,
|
||||
item.options.pinMessagesEnabled
|
||||
)
|
||||
if (error) {
|
||||
errorDialog.text = error.error
|
||||
errorDialog.open()
|
||||
|
@ -225,8 +222,8 @@ StatusSectionLayout {
|
|||
onAirdropTokensClicked: { /* TODO in future */ }
|
||||
onBackUpClicked: {
|
||||
Global.openPopup(transferOwnershipPopup, {
|
||||
privateKey: root.chatCommunitySectionModule.exportCommunity(root.communityId),
|
||||
})
|
||||
privateKey: root.chatCommunitySectionModule.exportCommunity(root.communityId),
|
||||
})
|
||||
}
|
||||
onPreviousPageNameChanged: root.backButtonName = previousPageName
|
||||
}
|
||||
|
@ -286,11 +283,35 @@ StatusSectionLayout {
|
|||
}
|
||||
|
||||
CommunityMintTokensSettingsPanel {
|
||||
communityId: root.community.id
|
||||
communitiesStore: root.communityStore
|
||||
transactionStore: root.transactionStore
|
||||
readonly property CommunityTokensStore communityTokensStore:
|
||||
rootStore.communityTokensStore
|
||||
|
||||
tokensModel: root.community.communityTokens
|
||||
holdersModel: communityTokensStore.holdersModel
|
||||
layer1Networks: communityTokensStore.layer1Networks
|
||||
layer2Networks: communityTokensStore.layer2Networks
|
||||
testNetworks: communityTokensStore.testNetworks
|
||||
enabledNetworks: communityTokensStore.enabledNetworks
|
||||
allNetworks: communityTokensStore.allNetworks
|
||||
|
||||
onPreviousPageNameChanged: root.backButtonName = previousPageName
|
||||
onRequestChainName: chainName = communityTokensStore.getChainName(chainId)
|
||||
onRequestChainIcon: chainIcon = communityTokensStore.getChainIcon(chainId)
|
||||
onMintCollectible: {
|
||||
communityTokensStore.deployCollectible(root.community.id,
|
||||
root.transactionStore.currentAccount.address, /*TODO use address from SendModal*/
|
||||
name,
|
||||
symbol,
|
||||
description,
|
||||
supply,
|
||||
infiniteSupply,
|
||||
transferable,
|
||||
selfDestruct,
|
||||
chainId,
|
||||
artworkSource)
|
||||
|
||||
root.state = d.mintedCollectibleViewState
|
||||
}
|
||||
}
|
||||
|
||||
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
|
||||
|
|
|
@ -32,7 +32,7 @@ StatusScrollView {
|
|||
property string chainIcon
|
||||
property int deployState
|
||||
|
||||
signal deployCollectible(url artworkSource,
|
||||
signal mintCollectible(url artworkSource,
|
||||
string name,
|
||||
string symbol,
|
||||
string description,
|
||||
|
@ -231,7 +231,7 @@ StatusScrollView {
|
|||
text: qsTr("Mint")
|
||||
|
||||
onClicked: {
|
||||
root.deployCollectible(root.artworkSource,
|
||||
root.mintCollectible(root.artworkSource,
|
||||
root.name,
|
||||
root.symbol,
|
||||
root.description,
|
||||
|
|
|
@ -14,7 +14,6 @@ import shared.panels 1.0
|
|||
StatusScrollView {
|
||||
id: root
|
||||
|
||||
property var store
|
||||
property int viewWidth: 560 // by design
|
||||
|
||||
// Collectible properties
|
||||
|
@ -30,6 +29,13 @@ StatusScrollView {
|
|||
property string chainName
|
||||
property string chainIcon
|
||||
|
||||
// Network related properties:
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
property var testNetworks
|
||||
property var enabledNetworks
|
||||
property var allNetworks
|
||||
|
||||
signal chooseArtWork
|
||||
signal previewClicked
|
||||
|
||||
|
@ -159,7 +165,11 @@ StatusScrollView {
|
|||
NetworkFilter {
|
||||
visible: !rowComponent.isSwitchCase
|
||||
Layout.preferredWidth: 160
|
||||
store: root.store
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
testNetworks: root.testNetworks
|
||||
enabledNetworks: root.testNetworks
|
||||
allNetworks: root.allNetworks
|
||||
isChainVisible: false
|
||||
multiSelection: false
|
||||
|
||||
|
|
|
@ -16,10 +16,15 @@ Item {
|
|||
implicitWidth: 130
|
||||
implicitHeight: parent.height
|
||||
|
||||
property var store
|
||||
property var layer1Networks
|
||||
property var layer2Networks
|
||||
property var testNetworks
|
||||
property var enabledNetworks
|
||||
property var allNetworks
|
||||
property bool isChainVisible: true
|
||||
property bool multiSelection: true
|
||||
|
||||
signal toggleNetwork(int chainId)
|
||||
signal singleNetworkSelected(int chainId, string chainName, string chainIcon)
|
||||
|
||||
QtObject {
|
||||
|
@ -47,7 +52,7 @@ Item {
|
|||
statusListItemTitle.font.pixelSize: 13
|
||||
statusListItemTitle.font.weight: Font.Medium
|
||||
statusListItemTitle.color: Theme.palette.baseColor1
|
||||
title: root.multiSelection ? (store.enabledNetworks.count === store.allNetworks.count ? qsTr("All networks") : qsTr("%n network(s)", "", store.enabledNetworks.count)) :
|
||||
title: root.multiSelection ? (root.enabledNetworks.count === root.allNetworks.count ? qsTr("All networks") : qsTr("%n network(s)", "", root.enabledNetworks.count)) :
|
||||
d.selectedChainName
|
||||
asset.height: 24
|
||||
asset.width: asset.height
|
||||
|
@ -80,7 +85,7 @@ Item {
|
|||
|
||||
Repeater {
|
||||
id: chainRepeater
|
||||
model: store.enabledNetworks
|
||||
model: root.enabledNetworks
|
||||
delegate: InformationTag {
|
||||
tagPrimaryLabel.text: model.shortName
|
||||
tagPrimaryLabel.color: model.chainColor
|
||||
|
@ -93,13 +98,13 @@ Item {
|
|||
id: selectPopup
|
||||
x: (parent.width - width + 5)
|
||||
y: (selectRectangleItem.height + 5)
|
||||
layer1Networks: store.layer1Networks
|
||||
layer2Networks: store.layer2Networks
|
||||
testNetworks: store.testNetworks
|
||||
layer1Networks: root.layer1Networks
|
||||
layer2Networks: root.layer2Networks
|
||||
testNetworks: root.testNetworks
|
||||
multiSelection: root.multiSelection
|
||||
|
||||
onToggleNetwork: {
|
||||
store.toggleNetwork(network.chainId)
|
||||
root.toggleNetwork(network.chainId)
|
||||
}
|
||||
|
||||
onSingleNetworkSelected: {
|
||||
|
|
|
@ -55,7 +55,13 @@ Item {
|
|||
id: networkFilter
|
||||
Layout.alignment: Qt.AlignTrailing
|
||||
Layout.rowSpan: 2
|
||||
store: root.walletStore
|
||||
layer1Networks: walletStore.layer1Networks
|
||||
layer2Networks: walletStore.layer2Networks
|
||||
testNetworks: walletStore.testNetworks
|
||||
enabledNetworks: walletStore.enabledNetworks
|
||||
allNetworks: walletStore.allNetworks
|
||||
|
||||
onToggleNetwork: walletStore.toggleNetwork(chainId)
|
||||
}
|
||||
|
||||
StatusAddressPanel {
|
||||
|
|
Loading…
Reference in New Issue