2023-02-17 11:57:17 +00:00
|
|
|
import QtQuick 2.14
|
2023-03-09 11:12:49 +00:00
|
|
|
import QtQuick.Controls 2.14
|
2023-03-07 11:32:45 +00:00
|
|
|
import QtQuick.Layouts 1.14
|
2023-03-09 11:12:49 +00:00
|
|
|
import QtQml 2.15
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-03-09 11:12:49 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2023-02-17 11:57:17 +00:00
|
|
|
|
|
|
|
import AppLayouts.Chat.layouts 1.0
|
|
|
|
import AppLayouts.Chat.views.communities 1.0
|
2023-03-23 13:17:07 +00:00
|
|
|
import AppLayouts.Chat.popups.community 1.0
|
2023-02-17 11:57:17 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2023-03-28 13:55:34 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2023-02-17 11:57:17 +00:00
|
|
|
|
|
|
|
SettingsPageLayout {
|
|
|
|
id: root
|
|
|
|
|
2023-03-08 13:44:47 +00:00
|
|
|
// Models:
|
2023-02-17 11:57:17 +00:00
|
|
|
property var tokensModel
|
2023-04-13 08:09:06 +00:00
|
|
|
|
2023-03-23 13:17:07 +00:00
|
|
|
property string feeText
|
2023-04-03 11:29:36 +00:00
|
|
|
property string errorText
|
2023-03-23 13:17:07 +00:00
|
|
|
property bool isFeeLoading: true
|
2023-03-08 13:44:47 +00:00
|
|
|
|
|
|
|
// Network related properties:
|
|
|
|
property var layer1Networks
|
|
|
|
property var layer2Networks
|
|
|
|
property var testNetworks
|
|
|
|
property var enabledNetworks
|
|
|
|
property var allNetworks
|
|
|
|
|
2023-03-17 15:09:27 +00:00
|
|
|
// Account expected roles: address, name, color, emoji
|
|
|
|
property var accounts
|
|
|
|
|
2023-02-17 11:57:17 +00:00
|
|
|
property int viewWidth: 560 // by design
|
|
|
|
|
2023-03-08 13:44:47 +00:00
|
|
|
signal mintCollectible(url artworkSource,
|
|
|
|
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-05-08 11:33:49 +00:00
|
|
|
string accountAddress,
|
|
|
|
var artworkCropRect)
|
2023-03-08 13:44:47 +00:00
|
|
|
|
2023-04-03 11:29:36 +00:00
|
|
|
signal signMintTransactionOpened(int chainId, string accountAddress)
|
|
|
|
|
2023-04-27 10:12:09 +00:00
|
|
|
signal remoteSelfDestructCollectibles(var selfDestructTokensList, // [key , amount]
|
2023-03-31 12:52:51 +00:00
|
|
|
int chainId,
|
|
|
|
string accountName,
|
|
|
|
string accountAddress)
|
|
|
|
|
|
|
|
signal signSelfDestructTransactionOpened(int chainId)
|
|
|
|
|
2023-04-17 12:11:31 +00:00
|
|
|
signal airdropCollectible(string key)
|
|
|
|
|
|
|
|
function setFeeLoading() {
|
|
|
|
root.isFeeLoading = true
|
|
|
|
root.feeText = ""
|
|
|
|
root.errorText = ""
|
|
|
|
}
|
|
|
|
|
2023-02-17 11:57:17 +00:00
|
|
|
function navigateBack() {
|
2023-03-09 11:12:49 +00:00
|
|
|
stackManager.pop(StackView.Immediate)
|
2023-02-17 11:57:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
readonly property string initialViewState: "WELCOME_OR_LIST_COLLECTIBLES"
|
2023-02-17 11:57:17 +00:00
|
|
|
readonly property string newCollectibleViewState: "NEW_COLLECTIBLE"
|
2023-03-07 11:32:45 +00:00
|
|
|
readonly property string previewCollectibleViewState: "PREVIEW_COLLECTIBLE"
|
|
|
|
readonly property string collectibleViewState: "VIEW_COLLECTIBLE"
|
|
|
|
|
|
|
|
readonly property string welcomePageTitle: qsTr("Mint tokens")
|
|
|
|
readonly property string newCollectiblePageTitle: qsTr("Create new collectible")
|
2023-03-09 11:12:49 +00:00
|
|
|
readonly property string newTokenButtonText: qsTr("Create new token")
|
2023-03-07 11:32:45 +00:00
|
|
|
readonly property string backButtonText: qsTr("Back")
|
|
|
|
readonly property string backTokensText: qsTr("Tokens")
|
|
|
|
|
2023-03-17 15:09:27 +00:00
|
|
|
property string accountAddress
|
2023-03-31 12:52:51 +00:00
|
|
|
property string accountName
|
|
|
|
property int chainId
|
|
|
|
property string chainName
|
|
|
|
|
2023-04-13 08:09:06 +00:00
|
|
|
property var tokenOwnersModel
|
2023-04-27 10:12:09 +00:00
|
|
|
property var selfDestructTokensList
|
2023-05-09 06:49:51 +00:00
|
|
|
property bool selfDestruct
|
2023-04-13 08:09:06 +00:00
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
|
2023-03-29 10:52:20 +00:00
|
|
|
onInitialItemChanged: updateInitialStackView()
|
|
|
|
|
2023-04-17 12:11:31 +00:00
|
|
|
signal airdropClicked()
|
|
|
|
|
2023-03-29 10:52:20 +00:00
|
|
|
function updateInitialStackView() {
|
|
|
|
if(stackManager.stackView) {
|
|
|
|
if(initialItem === welcomeView)
|
|
|
|
stackManager.stackView.replace(mintedTokensView, welcomeView, StackView.Immediate)
|
|
|
|
if(initialItem === mintedTokensView)
|
|
|
|
stackManager.stackView.replace(welcomeView, mintedTokensView, StackView.Immediate)
|
|
|
|
}
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
content: StackView {
|
|
|
|
anchors.fill: parent
|
|
|
|
initialItem: d.initialItem
|
2023-03-07 11:32:45 +00:00
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
Component.onCompleted: stackManager.pushInitialState(d.initialViewState)
|
2023-02-17 11:57:17 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
state: stackManager.currentState
|
2023-02-17 11:57:17 +00:00
|
|
|
states: [
|
|
|
|
State {
|
2023-03-09 11:12:49 +00:00
|
|
|
name: d.initialViewState
|
2023-03-07 11:32:45 +00:00
|
|
|
PropertyChanges {target: root; title: d.welcomePageTitle}
|
2023-02-17 11:57:17 +00:00
|
|
|
PropertyChanges {target: root; previousPageName: ""}
|
|
|
|
PropertyChanges {target: root; headerButtonVisible: true}
|
2023-03-09 11:12:49 +00:00
|
|
|
PropertyChanges {target: root; headerButtonText: d.newTokenButtonText}
|
2023-02-17 11:57:17 +00:00
|
|
|
PropertyChanges {target: root; headerWidth: root.viewWidth}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: d.newCollectibleViewState
|
2023-03-07 11:32:45 +00:00
|
|
|
PropertyChanges {target: root; title: d.newCollectiblePageTitle}
|
|
|
|
PropertyChanges {target: root; previousPageName: d.welcomePageTitle}
|
2023-02-17 11:57:17 +00:00
|
|
|
PropertyChanges {target: root; headerButtonVisible: false}
|
|
|
|
PropertyChanges {target: root; headerWidth: 0}
|
2023-03-07 11:32:45 +00:00
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: d.previewCollectibleViewState
|
|
|
|
PropertyChanges {target: root; previousPageName: d.backButtonText}
|
|
|
|
PropertyChanges {target: root; headerButtonVisible: false}
|
|
|
|
PropertyChanges {target: root; headerWidth: 0}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: d.collectibleViewState
|
|
|
|
PropertyChanges {target: root; previousPageName: d.backTokensText}
|
|
|
|
PropertyChanges {target: root; headerButtonVisible: false}
|
|
|
|
PropertyChanges {target: root; headerWidth: 0}
|
|
|
|
PropertyChanges {target: root; footer: mintTokenFooter}
|
2023-02-17 11:57:17 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
onHeaderButtonClicked: stackManager.push(d.newCollectibleViewState, newCollectiblesView, null, StackView.Immediate)
|
2023-02-17 11:57:17 +00:00
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
StackViewStates {
|
|
|
|
id: stackManager
|
|
|
|
|
|
|
|
stackView: root.contentItem
|
|
|
|
}
|
|
|
|
|
2023-02-17 11:57:17 +00:00
|
|
|
// Mint tokens possible view contents:
|
|
|
|
Component {
|
|
|
|
id: welcomeView
|
|
|
|
|
|
|
|
CommunityWelcomeSettingsView {
|
|
|
|
viewWidth: root.viewWidth
|
|
|
|
image: Style.png("community/mint2_1")
|
|
|
|
title: qsTr("Mint community tokens")
|
|
|
|
subtitle: qsTr("You can mint custom tokens and collectibles for your community")
|
|
|
|
checkersModel: [
|
|
|
|
qsTr("Reward individual members with custom tokens for their contribution"),
|
|
|
|
qsTr("Incentivise joining, retention, moderation and desired behaviour"),
|
|
|
|
qsTr("Monetise your community by selling exclusive tokens")
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: newCollectiblesView
|
|
|
|
|
2023-02-22 17:10:46 +00:00
|
|
|
CommunityNewCollectibleView {
|
2023-03-09 11:12:49 +00:00
|
|
|
viewWidth: root.viewWidth
|
2023-03-08 13:44:47 +00:00
|
|
|
layer1Networks: root.layer1Networks
|
|
|
|
layer2Networks: root.layer2Networks
|
|
|
|
testNetworks: root.testNetworks
|
|
|
|
enabledNetworks: root.testNetworks
|
|
|
|
allNetworks: root.allNetworks
|
2023-03-17 15:09:27 +00:00
|
|
|
accounts: root.accounts
|
2023-03-09 11:12:49 +00:00
|
|
|
|
|
|
|
onPreviewClicked: {
|
2023-03-17 15:09:27 +00:00
|
|
|
d.accountAddress = accountAddress
|
2023-03-09 11:12:49 +00:00
|
|
|
stackManager.push(d.previewCollectibleViewState,
|
2023-03-28 13:55:34 +00:00
|
|
|
previewCollectibleView,
|
2023-03-09 11:12:49 +00:00
|
|
|
{
|
2023-03-23 13:17:07 +00:00
|
|
|
preview: true,
|
2023-03-09 11:12:49 +00:00
|
|
|
name,
|
|
|
|
artworkSource,
|
2023-05-04 10:01:59 +00:00
|
|
|
artworkCropRect,
|
2023-03-09 11:12:49 +00:00
|
|
|
symbol,
|
|
|
|
description,
|
2023-03-28 07:47:12 +00:00
|
|
|
supplyAmount,
|
2023-03-09 11:12:49 +00:00
|
|
|
infiniteSupply,
|
2023-03-23 13:14:24 +00:00
|
|
|
transferable: !notTransferable,
|
2023-03-09 11:12:49 +00:00
|
|
|
selfDestruct,
|
|
|
|
chainId,
|
|
|
|
chainName,
|
2023-03-17 15:09:27 +00:00
|
|
|
chainIcon,
|
|
|
|
accountName
|
2023-03-09 11:12:49 +00:00
|
|
|
},
|
|
|
|
StackView.Immediate)
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2023-03-28 13:55:34 +00:00
|
|
|
id: previewCollectibleView
|
2023-03-07 11:32:45 +00:00
|
|
|
|
|
|
|
CommunityCollectibleView {
|
2023-03-28 13:55:34 +00:00
|
|
|
id: preview
|
2023-03-07 11:32:45 +00:00
|
|
|
|
2023-03-23 13:17:07 +00:00
|
|
|
function signMintTransaction() {
|
2023-04-03 11:29:36 +00:00
|
|
|
root.setFeeLoading()
|
2023-03-08 13:44:47 +00:00
|
|
|
root.mintCollectible(artworkSource,
|
|
|
|
name,
|
|
|
|
symbol,
|
|
|
|
description,
|
2023-03-28 07:47:12 +00:00
|
|
|
supplyAmount,
|
2023-03-08 13:44:47 +00:00
|
|
|
infiniteSupply,
|
|
|
|
transferable,
|
|
|
|
selfDestruct,
|
2023-03-17 15:09:27 +00:00
|
|
|
chainId,
|
|
|
|
accountName,
|
2023-05-08 11:33:49 +00:00
|
|
|
d.accountAddress,
|
|
|
|
artworkCropRect)
|
2023-03-07 11:32:45 +00:00
|
|
|
|
2023-03-09 11:12:49 +00:00
|
|
|
stackManager.clear(d.initialViewState, StackView.Immediate)
|
|
|
|
}
|
2023-03-23 13:17:07 +00:00
|
|
|
|
|
|
|
viewWidth: root.viewWidth
|
|
|
|
|
|
|
|
onMintCollectible: popup.open()
|
|
|
|
|
|
|
|
Binding {
|
|
|
|
target: root
|
|
|
|
property: "title"
|
2023-03-28 13:55:34 +00:00
|
|
|
value: preview.name
|
2023-03-23 13:17:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SignMintTokenTransactionPopup {
|
|
|
|
id: popup
|
|
|
|
|
|
|
|
anchors.centerIn: Overlay.overlay
|
|
|
|
collectibleName: parent.name
|
|
|
|
accountName: parent.accountName
|
|
|
|
networkName: parent.chainName
|
|
|
|
feeText: root.feeText
|
2023-04-03 11:29:36 +00:00
|
|
|
errorText: root.errorText
|
2023-03-23 13:17:07 +00:00
|
|
|
isFeeLoading: root.isFeeLoading
|
|
|
|
|
2023-04-03 11:29:36 +00:00
|
|
|
onOpened: {
|
|
|
|
root.setFeeLoading()
|
|
|
|
root.signMintTransactionOpened(parent.chainId, d.accountAddress)
|
|
|
|
}
|
2023-03-23 13:17:07 +00:00
|
|
|
onCancelClicked: close()
|
|
|
|
onSignTransactionClicked: parent.signMintTransaction()
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mintTokenFooter
|
|
|
|
|
|
|
|
MintTokensFooterPanel {
|
2023-03-31 12:52:51 +00:00
|
|
|
id: footerPanel
|
|
|
|
|
|
|
|
function closePopups() {
|
|
|
|
remoteSelfdestructPopup.close()
|
|
|
|
alertPopup.close()
|
|
|
|
signSelfDestructPopup.close()
|
|
|
|
}
|
|
|
|
|
2023-04-17 12:11:31 +00:00
|
|
|
airdropEnabled: true
|
2023-03-07 11:32:45 +00:00
|
|
|
retailEnabled: false
|
2023-05-09 06:49:51 +00:00
|
|
|
remotelySelfDestructVisible: d.selfDestruct
|
2023-03-07 11:32:45 +00:00
|
|
|
burnEnabled: false
|
2023-03-31 12:52:51 +00:00
|
|
|
|
2023-04-17 12:11:31 +00:00
|
|
|
onAirdropClicked: d.airdropClicked()
|
2023-03-31 12:52:51 +00:00
|
|
|
onRemotelySelfDestructClicked: remoteSelfdestructPopup.open()
|
|
|
|
|
|
|
|
RemoteSelfDestructPopup {
|
|
|
|
id: remoteSelfdestructPopup
|
|
|
|
|
|
|
|
collectibleName: root.title
|
2023-04-13 08:09:06 +00:00
|
|
|
model: d.tokenOwnersModel
|
2023-03-31 12:52:51 +00:00
|
|
|
|
|
|
|
onSelfDestructClicked: {
|
2023-04-27 10:12:09 +00:00
|
|
|
d.selfDestructTokensList = selfDestructTokensList
|
2023-03-31 12:52:51 +00:00
|
|
|
alertPopup.tokenCount = tokenCount
|
|
|
|
alertPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SelfDestructAlertPopup {
|
|
|
|
id: alertPopup
|
|
|
|
|
|
|
|
onSelfDestructClicked: signSelfDestructPopup.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
SignMintTokenTransactionPopup {
|
|
|
|
id: signSelfDestructPopup
|
|
|
|
|
|
|
|
function signSelfRemoteDestructTransaction() {
|
|
|
|
root.isFeeLoading = true
|
|
|
|
root.feeText = ""
|
2023-04-27 10:12:09 +00:00
|
|
|
root.remoteSelfDestructCollectibles(d.selfDestructTokensList,
|
2023-03-31 12:52:51 +00:00
|
|
|
d.chainId,
|
|
|
|
d.accountName,
|
|
|
|
d.accountAddress)
|
|
|
|
|
|
|
|
footerPanel.closePopups()
|
|
|
|
}
|
|
|
|
|
|
|
|
title: qsTr("Sign transaction - Self-destruct %1 tokens").arg(root.title)
|
|
|
|
collectibleName: root.title
|
|
|
|
accountName: d.accountName
|
|
|
|
networkName: d.chainName
|
|
|
|
feeText: root.feeText
|
|
|
|
isFeeLoading: root.isFeeLoading
|
|
|
|
|
|
|
|
onOpened: root.signSelfDestructTransactionOpened(d.chainId)
|
|
|
|
onCancelClicked: close()
|
|
|
|
onSignTransactionClicked: signSelfRemoteDestructTransaction()
|
|
|
|
}
|
2023-03-07 11:32:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mintedTokensView
|
|
|
|
|
2023-03-10 15:55:50 +00:00
|
|
|
CommunityMintedTokensView {
|
2023-03-09 11:12:49 +00:00
|
|
|
viewWidth: root.viewWidth
|
|
|
|
model: root.tokensModel
|
|
|
|
onItemClicked: {
|
2023-03-31 12:52:51 +00:00
|
|
|
d.accountAddress = accountAddress
|
|
|
|
d.chainId = chainId
|
|
|
|
d.chainName = chainName
|
|
|
|
d.accountName = accountName
|
2023-03-09 11:12:49 +00:00
|
|
|
stackManager.push(d.collectibleViewState,
|
|
|
|
collectibleView,
|
|
|
|
{
|
2023-03-23 13:17:07 +00:00
|
|
|
preview: false,
|
2023-03-28 13:55:34 +00:00
|
|
|
index
|
2023-03-09 11:12:49 +00:00
|
|
|
},
|
|
|
|
StackView.Immediate)
|
|
|
|
}
|
2023-02-17 11:57:17 +00:00
|
|
|
}
|
|
|
|
}
|
2023-03-28 13:55:34 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: collectibleView
|
|
|
|
|
|
|
|
CommunityCollectibleView {
|
|
|
|
id: view
|
|
|
|
|
|
|
|
property int index // TODO: Update it to key when model has role key implemented
|
|
|
|
|
|
|
|
viewWidth: root.viewWidth
|
|
|
|
|
|
|
|
Binding {
|
|
|
|
target: root
|
|
|
|
property: "title"
|
|
|
|
value: view.name
|
|
|
|
}
|
|
|
|
|
2023-04-13 08:09:06 +00:00
|
|
|
Binding {
|
|
|
|
target: d
|
|
|
|
property: "tokenOwnersModel"
|
|
|
|
value: view.tokenOwnersModel
|
|
|
|
}
|
|
|
|
|
2023-05-09 06:49:51 +00:00
|
|
|
Binding {
|
|
|
|
target: d
|
|
|
|
property: "selfDestruct"
|
|
|
|
value: view.selfDestruct
|
|
|
|
}
|
|
|
|
|
2023-03-28 13:55:34 +00:00
|
|
|
Instantiator {
|
|
|
|
id: instantiator
|
|
|
|
|
2023-04-13 08:09:06 +00:00
|
|
|
|
2023-03-28 13:55:34 +00:00
|
|
|
model: SortFilterProxyModel {
|
|
|
|
sourceModel: root.tokensModel
|
|
|
|
filters: IndexFilter {
|
|
|
|
minimumIndex: view.index
|
|
|
|
maximumIndex: view.index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delegate: QtObject {
|
|
|
|
component Bind: Binding { target: view }
|
|
|
|
readonly property list<Binding> bindings: [
|
|
|
|
Bind { property: "deployState"; value: model.deployState },
|
|
|
|
Bind { property: "name"; value: model.name },
|
|
|
|
Bind { property: "artworkSource"; value: model.image },
|
|
|
|
Bind { property: "symbol"; value: model.symbol },
|
|
|
|
Bind { property: "description"; value: model.description },
|
|
|
|
Bind { property: "supplyAmount"; value: model.supply },
|
|
|
|
Bind { property: "infiniteSupply"; value: model.infiniteSupply },
|
|
|
|
Bind { property: "selfDestruct"; value: model.remoteSelfDestruct },
|
|
|
|
Bind { property: "chainId"; value: model.chainId },
|
|
|
|
Bind { property: "chainName"; value: model.chainName },
|
|
|
|
Bind { property: "chainIcon"; value: model.chainIcon },
|
2023-04-13 08:09:06 +00:00
|
|
|
Bind { property: "accountName"; value: model.accountName },
|
|
|
|
Bind { property: "tokenOwnersModel"; value: model.tokenOwnersModel }
|
2023-03-28 13:55:34 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
2023-04-17 12:11:31 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: d
|
|
|
|
|
|
|
|
function onAirdropClicked() {
|
|
|
|
root.airdropCollectible(view.symbol) // TODO: Backend. It should just be the key (hash(chainId + contractAddress)
|
|
|
|
}
|
|
|
|
}
|
2023-03-28 13:55:34 +00:00
|
|
|
}
|
|
|
|
}
|
2023-02-17 11:57:17 +00:00
|
|
|
}
|