2023-05-04 10:01:59 +00:00
|
|
|
|
import QtQuick 2.15
|
2023-03-07 11:32:45 +00:00
|
|
|
|
import QtQuick.Layouts 1.14
|
2023-05-04 10:01:59 +00:00
|
|
|
|
import QtGraphicalEffects 1.0
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
2023-05-16 14:50:43 +00:00
|
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
|
|
|
|
|
import AppLayouts.Chat.panels.communities 1.0
|
|
|
|
|
|
|
|
|
|
StatusScrollView {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property int viewWidth: 560 // by design
|
|
|
|
|
property bool preview: false
|
2023-05-25 10:31:32 +00:00
|
|
|
|
property bool isAssetView: false
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
2023-05-25 10:31:32 +00:00
|
|
|
|
// Token properties
|
2023-03-07 11:32:45 +00:00
|
|
|
|
property alias artworkSource: image.source
|
2023-05-04 10:01:59 +00:00
|
|
|
|
property rect artworkCropRect
|
2023-05-25 10:31:32 +00:00
|
|
|
|
property string name
|
2023-03-07 11:32:45 +00:00
|
|
|
|
property alias symbol: symbolBox.value
|
|
|
|
|
property alias description: descriptionItem.text
|
2023-03-28 07:47:12 +00:00
|
|
|
|
property int supplyAmount
|
2023-05-15 12:49:26 +00:00
|
|
|
|
property int remainingTokens
|
2023-03-07 11:32:45 +00:00
|
|
|
|
property bool infiniteSupply
|
2023-05-25 10:31:32 +00:00
|
|
|
|
|
|
|
|
|
property alias accountName: accountBox.value
|
2023-03-07 11:32:45 +00:00
|
|
|
|
property int chainId
|
|
|
|
|
property string chainIcon
|
2023-05-25 10:31:32 +00:00
|
|
|
|
property alias chainName: chainText.text
|
|
|
|
|
|
|
|
|
|
property var tokenOwnersModel
|
|
|
|
|
|
2023-05-05 11:03:59 +00:00
|
|
|
|
property int deployState: Constants.ContractTransactionStatus.None
|
|
|
|
|
property int burnState: Constants.ContractTransactionStatus.None
|
2023-05-25 10:31:32 +00:00
|
|
|
|
|
|
|
|
|
// Collectible object properties (ERC721)
|
|
|
|
|
property bool transferable
|
|
|
|
|
property bool selfDestruct
|
2023-05-05 11:03:59 +00:00
|
|
|
|
property int remotelyDestructState: Constants.ContractTransactionStatus.None
|
2023-05-25 10:31:32 +00:00
|
|
|
|
|
|
|
|
|
// Asset properties (ERC20)
|
|
|
|
|
property alias assetDecimals: decimalsBox.value
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
2023-03-08 13:44:47 +00:00
|
|
|
|
signal mintCollectible(url artworkSource,
|
2023-03-07 11:32:45 +00:00
|
|
|
|
string name,
|
|
|
|
|
string symbol,
|
|
|
|
|
string description,
|
|
|
|
|
int supply,
|
|
|
|
|
bool infiniteSupply,
|
|
|
|
|
bool transferable,
|
|
|
|
|
bool selfDestruct,
|
2023-03-17 15:09:27 +00:00
|
|
|
|
int chainId,
|
|
|
|
|
string accountName)
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
2023-05-25 10:31:32 +00:00
|
|
|
|
signal mintAsset(url artworkSource,
|
|
|
|
|
string name,
|
|
|
|
|
string symbol,
|
|
|
|
|
string description,
|
|
|
|
|
int supply,
|
|
|
|
|
bool infiniteSupply,
|
|
|
|
|
int decimals,
|
|
|
|
|
int chainId,
|
|
|
|
|
string accountName)
|
|
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
|
2023-05-25 10:31:32 +00:00
|
|
|
|
readonly property int imageSelectorRectSize: root.isAssetView ? 104 : 280
|
2023-03-07 11:32:45 +00:00
|
|
|
|
readonly property int iconSize: 20
|
2023-05-15 12:49:26 +00:00
|
|
|
|
readonly property string infiniteSymbol: "∞"
|
2023-05-16 14:50:43 +00:00
|
|
|
|
|
|
|
|
|
function startAnimation(isBurn) {
|
|
|
|
|
totalbox.highlighted = true
|
|
|
|
|
|
|
|
|
|
if(isBurn)
|
|
|
|
|
remainingBox.highlighted = true
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
padding: 0
|
|
|
|
|
|
2023-05-05 11:03:59 +00:00
|
|
|
|
onRemotelyDestructStateChanged: if(remotelyDestructState === Constants.ContractTransactionStatus.Completed) d.startAnimation(false)
|
|
|
|
|
onBurnStateChanged: if(burnState === Constants.ContractTransactionStatus.Completed) d.startAnimation(true)
|
2023-05-16 14:50:43 +00:00
|
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: mainLayout
|
|
|
|
|
|
|
|
|
|
width: root.viewWidth
|
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
2023-05-05 11:03:59 +00:00
|
|
|
|
visible: !root.preview && ((root.deployState === Constants.ContractTransactionStatus.InProgress) ||
|
|
|
|
|
(root.deployState === Constants.ContractTransactionStatus.Failed))
|
2023-03-07 11:32:45 +00:00
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
|
|
2023-05-17 10:00:52 +00:00
|
|
|
|
StatusDotsLoadingIndicator {
|
2023-05-05 11:03:59 +00:00
|
|
|
|
visible: (root.deployState === Constants.ContractTransactionStatus.InProgress)
|
2023-05-17 10:00:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusIcon {
|
2023-05-05 11:03:59 +00:00
|
|
|
|
visible: (root.deployState === Constants.ContractTransactionStatus.Failed)
|
2023-05-17 10:00:52 +00:00
|
|
|
|
icon: "warning"
|
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
font.pixelSize: Theme.primaryTextFontSize
|
2023-05-05 11:03:59 +00:00
|
|
|
|
text: (root.deployState === Constants.ContractTransactionStatus.InProgress) ?
|
2023-05-25 10:31:32 +00:00
|
|
|
|
(root.isAssetView ?
|
|
|
|
|
qsTr("Asset is being minted") : qsTr("Collectible is being minted")) :
|
2023-05-05 11:03:59 +00:00
|
|
|
|
(root.deployState === Constants.ContractTransactionStatus.Failed) ?
|
2023-05-25 10:31:32 +00:00
|
|
|
|
(root.isAssetView ? qsTr("Asset minting failed") : qsTr("Collectible minting failed")) : ""
|
2023-05-05 11:03:59 +00:00
|
|
|
|
color: (root.deployState === Constants.ContractTransactionStatus.Failed) ? Theme.palette.dangerColor1 : Theme.palette.directColor1
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.preferredHeight: d.imageSelectorRectSize
|
|
|
|
|
Layout.preferredWidth: Layout.preferredHeight
|
2023-05-04 10:01:59 +00:00
|
|
|
|
|
2023-05-25 10:31:32 +00:00
|
|
|
|
radius: root.isAssetView ? Layout.preferredWidth / 2 : 8
|
2023-05-04 10:01:59 +00:00
|
|
|
|
color:Theme.palette.baseColor2
|
|
|
|
|
clip: true
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
Image {
|
|
|
|
|
id: image
|
|
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2023-05-04 10:01:59 +00:00
|
|
|
|
visible: false
|
|
|
|
|
sourceClipRect: root.artworkCropRect ? root.artworkCropRect : undefined
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OpacityMask {
|
|
|
|
|
anchors.fill: image
|
|
|
|
|
source: image
|
|
|
|
|
maskSource: parent
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Flow {
|
|
|
|
|
spacing: Style.current.halfPadding
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
component CustomPreviewBox: Rectangle {
|
|
|
|
|
id: previewBox
|
|
|
|
|
|
|
|
|
|
property string label
|
|
|
|
|
property string value
|
2023-05-16 14:50:43 +00:00
|
|
|
|
property bool isLoading: false
|
|
|
|
|
property bool highlighted: false
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
radius: 8
|
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
|
implicitWidth: Math.min(boxContent.implicitWidth + Style.current.padding, mainLayout.width)
|
|
|
|
|
implicitHeight: boxContent.implicitHeight + Style.current.padding
|
2023-05-16 14:50:43 +00:00
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
when: !previewBox.highlighted
|
|
|
|
|
PropertyChanges { target: previewBox; color: "transparent" }
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
when: previewBox.highlighted
|
|
|
|
|
PropertyChanges { target: previewBox; color: Theme.palette.primaryColor3 }
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
onHighlightedChanged: if(highlighted) animation.start()
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
|
id: boxContent
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
spacing: 2
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
text: previewBox.label
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-16 14:50:43 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
spacing: 3
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
text: StatusQUtils.Emoji.fromCodePoint("1f525") // :fire: emoji
|
|
|
|
|
font.pixelSize: Theme.tertiaryTextFontSize
|
|
|
|
|
visible: previewBox.isLoading
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.maximumWidth: mainLayout.width - Style.current.padding
|
|
|
|
|
text: previewBox.value
|
|
|
|
|
elide: Text.ElideRight
|
|
|
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusLoadingIndicator {
|
|
|
|
|
Layout.preferredHeight: Theme.primaryTextFontSize
|
|
|
|
|
Layout.preferredWidth: Layout.preferredHeight
|
|
|
|
|
Layout.leftMargin: 6
|
|
|
|
|
Layout.rightMargin: 3
|
|
|
|
|
visible: previewBox.isLoading
|
|
|
|
|
color: Theme.palette.primaryColor1
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-16 14:50:43 +00:00
|
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
|
id: animation
|
|
|
|
|
|
|
|
|
|
interval: 1500
|
|
|
|
|
onRunningChanged: if(!running) previewBox.highlighted = false
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPreviewBox {
|
2023-05-15 12:49:26 +00:00
|
|
|
|
id: symbolBox
|
|
|
|
|
|
|
|
|
|
label: qsTr("Symbol")
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPreviewBox {
|
2023-05-16 14:50:43 +00:00
|
|
|
|
id: totalbox
|
|
|
|
|
|
2023-05-15 12:49:26 +00:00
|
|
|
|
label: qsTr("Total")
|
|
|
|
|
value: root.infiniteSupply ? d.infiniteSymbol : LocaleUtils.numberToLocaleString(root.supplyAmount)
|
2023-05-16 14:50:43 +00:00
|
|
|
|
isLoading: !root.infiniteSupply &&
|
2023-05-05 11:03:59 +00:00
|
|
|
|
((root.remotelyDestructState === Constants.ContractTransactionStatus.InProgress) ||
|
|
|
|
|
(root.burnState === Constants.ContractTransactionStatus.InProgress))
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPreviewBox {
|
2023-05-16 14:50:43 +00:00
|
|
|
|
id: remainingBox
|
|
|
|
|
|
2023-05-15 12:49:26 +00:00
|
|
|
|
label: qsTr("Remaining")
|
|
|
|
|
value: root.infiniteSupply ? d.infiniteSymbol : LocaleUtils.numberToLocaleString(root.remainingTokens)
|
2023-05-05 11:03:59 +00:00
|
|
|
|
isLoading: !root.infiniteSupply && (root.burnState === Constants.ContractTransactionStatus.InProgress)
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPreviewBox {
|
2023-05-25 10:31:32 +00:00
|
|
|
|
id: decimalsBox
|
|
|
|
|
|
|
|
|
|
visible: root.isAssetView
|
|
|
|
|
label: qsTr("DP")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CustomPreviewBox {
|
|
|
|
|
visible: !root.isAssetView
|
2023-05-15 12:49:26 +00:00
|
|
|
|
label: qsTr("Transferable")
|
|
|
|
|
value: root.transferable ? qsTr("Yes") : qsTr("No")
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
2023-05-15 12:49:26 +00:00
|
|
|
|
CustomPreviewBox {
|
2023-05-25 10:31:32 +00:00
|
|
|
|
visible: !root.isAssetView
|
2023-05-15 12:49:26 +00:00
|
|
|
|
label: qsTr("Remotely destructible")
|
|
|
|
|
value: root.selfDestruct ? qsTr("Yes") : qsTr("No")
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-17 15:09:27 +00:00
|
|
|
|
CustomPreviewBox {
|
|
|
|
|
id: accountBox
|
|
|
|
|
|
|
|
|
|
label: qsTr("Account")
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
|
Rectangle {
|
|
|
|
|
height: symbolBox.height
|
|
|
|
|
width: rowChain.implicitWidth + 2 * Style.current.padding
|
|
|
|
|
border.width: 1
|
|
|
|
|
radius: 8
|
|
|
|
|
border.color: Theme.palette.baseColor2
|
|
|
|
|
color: "transparent"
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
id: rowChain
|
|
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
spacing: Style.current.padding
|
|
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
|
id: chainIcon
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
height: 24
|
|
|
|
|
width: height
|
|
|
|
|
source: Style.svg(root.chainIcon)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: chainText
|
|
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignVCenter
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
|
font.weight: Font.Medium
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-15 12:49:26 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: descriptionItem
|
|
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
wrapMode: TextEdit.WordWrap
|
|
|
|
|
font.pixelSize: Theme.primaryTextFontSize
|
|
|
|
|
lineHeight: 1.2
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-07 11:32:45 +00:00
|
|
|
|
RowLayout {
|
|
|
|
|
visible: root.preview
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
StatusIcon {
|
|
|
|
|
Layout.preferredWidth: d.iconSize
|
|
|
|
|
Layout.preferredHeight: d.iconSize
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
icon: "info"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
wrapMode: Text.Wrap
|
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
|
color: Theme.palette.baseColor1
|
2023-05-15 12:49:26 +00:00
|
|
|
|
text: qsTr("Make sure you’re happy with your token before minting it as it can’t be edited later")
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
|
visible: root.preview
|
|
|
|
|
Layout.preferredHeight: 44
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.topMargin: Style.current.halfPadding
|
|
|
|
|
text: qsTr("Mint")
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
2023-05-25 10:31:32 +00:00
|
|
|
|
if(root.isAssetView) {
|
|
|
|
|
root.mintAsset(root.artworkSource,
|
|
|
|
|
root.name,
|
|
|
|
|
root.symbol,
|
|
|
|
|
root.description,
|
|
|
|
|
root.supplyAmount,
|
|
|
|
|
root.infiniteSupply,
|
|
|
|
|
root.assetDecimals,
|
|
|
|
|
root.chainId,
|
|
|
|
|
root.accountName)
|
|
|
|
|
} else {
|
|
|
|
|
root.mintCollectible(root.artworkSource,
|
|
|
|
|
root.name,
|
|
|
|
|
root.symbol,
|
|
|
|
|
root.description,
|
|
|
|
|
root.supplyAmount,
|
|
|
|
|
root.infiniteSupply,
|
|
|
|
|
root.transferable,
|
|
|
|
|
root.selfDestruct,
|
|
|
|
|
root.chainId,
|
|
|
|
|
root.accountName)
|
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TokenHoldersPanel {
|
2023-04-13 08:09:06 +00:00
|
|
|
|
visible: !root.preview
|
2023-03-07 11:32:45 +00:00
|
|
|
|
tokenName: root.name
|
2023-04-13 08:09:06 +00:00
|
|
|
|
model: root.tokenOwnersModel
|
2023-03-07 11:32:45 +00:00
|
|
|
|
Layout.topMargin: Style.current.padding
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|