2023-07-18 14:39:38 +02:00
import QtQuick 2.15
2024-10-15 21:26:12 +02:00
import QtQuick . Layouts 1.15
2023-07-18 14:39:38 +02:00
2024-06-16 00:33:12 +03:00
import StatusQ 0.1
2023-08-11 14:16:53 +02:00
import StatusQ . Components 0.1
import StatusQ . Controls 0.1
2023-07-18 14:39:38 +02:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
import StatusQ . Core . Utils 0.1 as SQUtils
import StatusQ . Popups 0.1
2023-08-11 14:16:53 +02:00
import AppLayouts . Communities . controls 1.0
2023-07-18 14:39:38 +02:00
import AppLayouts . Communities . helpers 1.0
2023-08-11 14:16:53 +02:00
import AppLayouts . Communities . panels 1.0
2023-07-18 14:39:38 +02:00
import AppLayouts . Wallet . controls 1.0
2023-08-11 14:16:53 +02:00
import utils 1.0
2023-07-18 14:39:38 +02:00
2024-06-07 15:27:56 +03:00
import shared . controls 1.0
2023-07-18 14:39:38 +02:00
import SortFilterProxyModel 0.2
StatusScrollView {
id: root
property int viewWidth: 560 // by design
// Community info:
property string communityName
property url communityLogo
property color communityColor
// Network related properties:
2024-03-13 18:38:16 +01:00
property var flatNetworks
2023-07-18 14:39:38 +02:00
// Wallet account expected roles: address, name, color, emoji, walletType
property var accounts
2023-07-27 00:39:13 +02:00
property string feeText
property string feeErrorText
property bool isFeeLoading
2023-07-18 14:39:38 +02:00
// Privileged tokens:
readonly property TokenObject ownerToken: TokenObject {
2023-08-04 18:41:21 +02:00
name: PermissionsHelpers . ownerTokenNameTag + root . communityName
2023-07-18 14:39:38 +02:00
type: Constants . TokenType . ERC721
2023-08-04 18:41:21 +02:00
privilegesLevel: Constants . TokenPrivilegesLevel . Owner
2023-07-18 14:39:38 +02:00
artworkSource: root . communityLogo
color: root . communityColor
2023-08-04 18:41:21 +02:00
symbol: PermissionsHelpers . communityNameToSymbol ( true , root . communityName )
2023-07-18 14:39:38 +02:00
transferable: true
remotelyDestruct: false
2023-08-10 14:23:59 +02:00
supply: "1"
2023-07-18 14:39:38 +02:00
infiniteSupply: false
description: qsTr ( "This is the %1 Owner token. The hodler of this collectible has ultimate control over %1 Community token administration." ) . arg ( root . communityName )
}
readonly property TokenObject tMasterToken: TokenObject {
2023-08-04 18:41:21 +02:00
name: PermissionsHelpers . tMasterTokenNameTag + root . communityName
2023-07-18 14:39:38 +02:00
type: Constants . TokenType . ERC721
2023-08-04 18:41:21 +02:00
privilegesLevel: Constants . TokenPrivilegesLevel . TMaster
2023-07-18 14:39:38 +02:00
artworkSource: root . communityLogo
color: root . communityColor
2023-08-04 18:41:21 +02:00
symbol: PermissionsHelpers . communityNameToSymbol ( false , root . communityName )
2023-07-18 14:39:38 +02:00
remotelyDestruct: true
description: qsTr ( "This is the %1 TokenMaster token. The hodler of this collectible has full admin rights for the %1 Community in Status and can mint and airdrop %1 Community tokens." ) . arg ( root . communityName )
}
2023-07-27 00:39:13 +02:00
readonly property string feeLabel:
qsTr ( "Mint %1 Owner and TokenMaster tokens on %2" )
. arg ( communityName ) . arg ( ownerToken . chainName )
2023-07-18 14:39:38 +02:00
signal mintClicked
QtObject {
id: d
readonly property int titleSize: 17
readonly property int iconSize: 20
}
padding: 0
contentWidth: mainLayout . width
contentHeight: mainLayout . height
ColumnLayout {
id: mainLayout
width: root . viewWidth
2024-10-15 21:26:12 +02:00
spacing: Theme . padding
2023-07-18 14:39:38 +02:00
// Owner token defintion:
StatusBaseText {
Layout.maximumWidth: root . viewWidth
elide: Text . ElideMiddle
font.pixelSize: d . titleSize
font.bold: true
2023-08-04 18:41:21 +02:00
text: ownerToken . name
2023-07-18 14:39:38 +02:00
}
TokenInfoPanel {
Layout.fillWidth: true
token: root . ownerToken
2023-07-18 19:34:57 +02:00
accountBoxVisible: false
networkBoxVisible: false
2023-07-18 14:39:38 +02:00
}
StatusModalDivider {
Layout.fillWidth: true
2024-10-15 21:26:12 +02:00
topPadding: Theme . padding
bottomPadding: Theme . padding
2023-07-18 14:39:38 +02:00
}
// TMaster token definition:
StatusBaseText {
Layout.maximumWidth: root . viewWidth
elide: Text . ElideMiddle
font.pixelSize: d . titleSize
font.bold: true
2023-08-04 18:41:21 +02:00
text: tMasterToken . name
2023-07-18 14:39:38 +02:00
}
TokenInfoPanel {
Layout.fillWidth: true
token: root . tMasterToken
2023-07-18 19:34:57 +02:00
accountBoxVisible: false
networkBoxVisible: false
2023-07-18 14:39:38 +02:00
}
StatusModalDivider {
Layout.fillWidth: true
2024-10-15 21:26:12 +02:00
topPadding: Theme . padding
bottomPadding: Theme . padding
2023-07-18 14:39:38 +02:00
}
CustomLabelDescriptionComponent {
label: qsTr ( "Select account" )
description: qsTr ( "This account will be where you receive your Owner token and will also be the account that pays the token minting gas fees." )
}
2023-08-11 14:16:53 +02:00
ColumnLayout {
spacing: 11
2023-07-18 14:39:38 +02:00
2023-08-11 14:16:53 +02:00
AccountSelector {
id: accountBox
2023-07-27 00:39:13 +02:00
2023-08-11 14:16:53 +02:00
Layout.fillWidth: true
2024-10-15 21:26:12 +02:00
Layout.topMargin: - Theme . halfPadding
2023-08-11 14:16:53 +02:00
model: root . accounts
2024-06-07 15:27:56 +03:00
selectedAddress: ownerToken . accountAddress
Binding {
target: root . ownerToken
property: "accountAddress"
value: accountBox . currentAccountAddress
}
2023-07-18 14:39:38 +02:00
2024-06-07 15:27:56 +03:00
Binding {
target: root . ownerToken
property: "accountName"
value: accountBox . currentAccount . name
2023-08-11 14:16:53 +02:00
}
2024-06-07 15:27:56 +03:00
Binding {
target: root . tMasterToken
property: "accountAddress"
value: accountBox . currentAccountAddress
}
Binding {
target: root . tMasterToken
property: "accountName"
value: accountBox . currentAccount . name
2023-08-11 14:16:53 +02:00
}
2023-07-18 14:39:38 +02:00
}
2023-08-11 14:16:53 +02:00
StatusBaseText {
Layout.fillWidth: true
visible: ! ! root . feeErrorText
horizontalAlignment: Text . AlignRight
font.pixelSize: Theme . tertiaryTextFontSize
color: Theme . palette . dangerColor1
text: root . feeErrorText
wrapMode: Text . Wrap
2023-07-18 14:39:38 +02:00
}
}
CustomNetworkFilterRowComponent {
id: networkSelector
label: qsTr ( "Select network" )
2023-09-12 11:26:25 +02:00
description: qsTr ( "The network you select will be where all your community’ s tokens reside. Once set, this setting can’ t be changed and tokens can’ t move to other networks." )
2023-07-18 14:39:38 +02:00
}
2023-07-27 00:39:13 +02:00
FeesBox {
Layout.fillWidth: true
2024-10-15 21:26:12 +02:00
Layout.topMargin: Theme . padding
2023-07-27 00:39:13 +02:00
model: QtObject {
id: singleFeeModel
readonly property string title: root . feeLabel
readonly property string feeText: root . isFeeLoading ?
"" : root . feeText
readonly property bool error: root . feeErrorText !== ""
}
showAccountsSelector: false
}
2023-07-18 14:39:38 +02:00
StatusButton {
Layout.preferredHeight: 44
Layout.alignment: Qt . AlignHCenter
Layout.fillWidth: true
2023-07-27 00:39:13 +02:00
Layout.topMargin: 4
2024-10-15 21:26:12 +02:00
Layout.bottomMargin: Theme . padding
2023-08-11 14:16:53 +02:00
enabled: root . feeText && ! root . feeErrorText
2024-06-20 14:32:59 +07:00
objectName: "mintButton"
2023-07-18 14:39:38 +02:00
text: qsTr ( "Mint" )
onClicked: root . mintClicked ( )
}
}
component CustomLabelDescriptionComponent: ColumnLayout {
id: labelDescComponent
property string label
property string description
Layout.fillWidth: true
StatusBaseText {
text: labelDescComponent . label
color: Theme . palette . directColor1
font.pixelSize: Theme . primaryTextFontSize
}
StatusBaseText {
Layout.fillWidth: true
Layout.fillHeight: true
text: labelDescComponent . description
color: Theme . palette . baseColor1
font.pixelSize: Theme . primaryTextFontSize
lineHeight: 1.2
wrapMode: Text . WordWrap
}
}
component CustomNetworkFilterRowComponent: ColumnLayout {
id: networkComponent
property string label
property string description
Layout.fillWidth: true
2024-10-15 21:26:12 +02:00
Layout.topMargin: Theme . padding
2023-07-18 14:39:38 +02:00
spacing: 8
CustomLabelDescriptionComponent {
label: networkComponent . label
description: networkComponent . description
}
NetworkFilter {
id: netFilter
2024-06-20 14:32:59 +07:00
objectName: "netFilter"
2023-07-18 14:39:38 +02:00
Layout.fillWidth: true
2024-03-13 18:38:16 +01:00
flatNetworks: root . flatNetworks
2024-06-16 00:33:12 +03:00
selection: ! ! ownerToken . chainId ? [ ownerToken . chainId ] : [ SQUtils . ModelUtils . getByKey ( flatNetworks , "layer" , 2 ) . chainId /*first layer 2 network*/ ]
2023-07-18 14:39:38 +02:00
multiSelection: false
2023-09-12 11:26:25 +02:00
control.topPadding: 10
control.background: Rectangle {
height: 44
radius: 8
color: "transparent"
border.color: Theme . palette . directColor7
}
2024-06-16 00:33:12 +03:00
onToggleNetwork: {
2023-07-27 00:39:13 +02:00
// Set Owner Token network properties:
2024-06-16 00:33:12 +03:00
ownerToken . chainId = singleSelectionItemData . chainId
ownerToken . chainName = singleSelectionItemData . chainName
ownerToken . chainIcon = singleSelectionItemData . iconUrl
2023-07-27 00:39:13 +02:00
// Set TMaster Token network properties:
2024-06-16 00:33:12 +03:00
tMasterToken . chainId = singleSelectionItemData . chainId
tMasterToken . chainName = singleSelectionItemData . chainName
tMasterToken . chainIcon = singleSelectionItemData . iconUrl
2023-07-27 00:39:13 +02:00
}
2023-07-18 14:39:38 +02:00
}
}
}