2023-06-22 21:24:30 +00:00
import QtQuick 2.15
import QtQuick . Controls 2.15
import QtQuick . Layouts 1.15
2023-03-09 11:12:49 +00:00
import QtQml 2.15
2023-03-07 11:32:45 +00:00
import StatusQ . Core . Theme 0.1
2023-03-09 11:12:49 +00:00
import StatusQ . Core . Utils 0.1
2023-05-22 13:00:40 +00:00
import StatusQ . Controls 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-06-01 10:38:56 +00:00
import AppLayouts . Chat . helpers 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-06-01 10:38:56 +00:00
// General properties:
property string communityName
property int viewWidth: 560 // by design
2023-03-08 13:44:47 +00:00
// Models:
2023-02-17 11:57:17 +00:00
property var tokensModel
2023-06-20 10:12:56 +00:00
property var accounts // Expected roles: address, name, color, emoji, walletType
2023-04-13 08:09:06 +00:00
2023-06-01 10:38:56 +00:00
// Transaction related properties:
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-06-01 10:38:56 +00:00
signal mintCollectible ( var collectibleItem )
signal mintAsset ( var assetItem )
2023-04-03 11:29:36 +00:00
signal signMintTransactionOpened ( int chainId , string accountAddress )
2023-06-06 12:54:35 +00:00
2023-06-21 16:36:20 +00:00
signal signRemoteDestructTransactionOpened ( var remotelyDestructTokensList , // [key , amount]
string tokenKey )
2023-06-06 12:54:35 +00:00
2023-06-21 16:36:20 +00:00
signal remotelyDestructCollectibles ( var remotelyDestructTokensList , // [key , amount]
string tokenKey )
2023-06-06 12:54:35 +00:00
signal signBurnTransactionOpened ( string tokenKey , int amount )
2023-06-01 10:38:56 +00:00
signal burnToken ( string tokenKey , int amount )
2023-06-06 12:54:35 +00:00
2023-06-21 16:40:26 +00:00
signal airdropToken ( string tokenKey , int type , var addresses )
2023-06-06 12:54:35 +00:00
2023-05-30 15:18:45 +00:00
signal deleteToken ( string tokenKey )
2023-04-17 12:11:31 +00:00
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
}
2023-06-14 07:19:45 +00:00
function resetNavigation ( isAssetView = false ) {
d . isAssetView = isAssetView
stackManager . clear ( d . initialViewState , StackView . Immediate )
}
2023-02-17 11:57:17 +00:00
QtObject {
id: d
2023-05-22 13:00:40 +00:00
readonly property string initialViewState: "WELCOME_OR_LIST_TOKENS"
readonly property string newTokenViewState: "NEW_TOKEN"
2023-05-25 10:46:53 +00:00
readonly property string previewTokenViewState: "PREVIEW_TOKEN"
2023-05-25 14:45:46 +00:00
readonly property string tokenViewState: "VIEW_TOKEN"
2023-03-07 11:32:45 +00:00
2023-05-11 15:29:09 +00:00
readonly property string welcomePageTitle: qsTr ( "Tokens" )
2023-05-11 15:51:50 +00:00
readonly property string newCollectiblePageTitle: qsTr ( "Mint collectible" )
2023-05-22 13:00:40 +00:00
readonly property string newAssetPageTitle: qsTr ( "Mint asset" )
2023-05-11 15:29:09 +00:00
readonly property string newTokenButtonText: qsTr ( "Mint token" )
2023-03-07 11:32:45 +00:00
readonly property string backButtonText: qsTr ( "Back" )
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-06-01 10:38:56 +00:00
property var remotelyDestructTokensList
property bool remotelyDestruct
2023-06-21 16:41:13 +00:00
property bool infiniteSupply
2023-05-26 15:00:51 +00:00
property string tokenKey
2023-05-18 15:01:48 +00:00
property int burnAmount
property int remainingTokens
property url artworkSource
2023-06-14 07:19:45 +00:00
property bool isAssetView: false
2023-06-22 21:24:30 +00:00
property TokenObject currentToken
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
2023-04-17 12:11:31 +00:00
signal airdropClicked ( )
2023-06-05 13:49:36 +00:00
signal remoteDestructAddressClicked ( string address )
2023-05-30 15:18:45 +00:00
signal retryMintClicked ( )
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-06-01 10:38:56 +00:00
onInitialItemChanged: updateInitialStackView ( )
2023-03-07 11:32:45 +00:00
}
2023-06-09 11:50:22 +00:00
QtObject {
id: temp_
2023-06-22 21:24:30 +00:00
readonly property TokenObject token: TokenObject { }
2023-06-09 11:50:22 +00:00
}
2023-05-30 15:18:45 +00:00
secondaryHeaderButton.type: StatusBaseButton . Type . Danger
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-05-15 12:49:26 +00:00
PropertyChanges { target: root ; subTitle: "" }
2023-02-17 11:57:17 +00:00
PropertyChanges { target: root ; previousPageName: "" }
2023-05-30 15:18:45 +00:00
PropertyChanges { target: root ; primaryHeaderButton.visible: true }
PropertyChanges { target: root ; primaryHeaderButton.text: d . newTokenButtonText }
PropertyChanges { target: root ; secondaryHeaderButton.visible: false }
2023-02-17 11:57:17 +00:00
} ,
State {
2023-05-22 13:00:40 +00:00
name: d . newTokenViewState
2023-06-14 07:19:45 +00:00
PropertyChanges { target: root ; title: d . isAssetView ? d.newAssetPageTitle : d . newCollectiblePageTitle }
2023-05-15 12:49:26 +00:00
PropertyChanges { target: root ; subTitle: "" }
2023-05-11 15:51:50 +00:00
PropertyChanges { target: root ; previousPageName: d . backButtonText }
2023-05-30 15:18:45 +00:00
PropertyChanges { target: root ; primaryHeaderButton.visible: false }
PropertyChanges { target: root ; secondaryHeaderButton.visible: false }
2023-03-07 11:32:45 +00:00
} ,
State {
2023-05-25 10:46:53 +00:00
name: d . previewTokenViewState
2023-03-07 11:32:45 +00:00
PropertyChanges { target: root ; previousPageName: d . backButtonText }
2023-05-30 15:18:45 +00:00
PropertyChanges { target: root ; primaryHeaderButton.visible: false }
PropertyChanges { target: root ; secondaryHeaderButton.visible: false }
2023-03-07 11:32:45 +00:00
} ,
State {
2023-05-25 14:45:46 +00:00
name: d . tokenViewState
2023-05-15 12:49:26 +00:00
PropertyChanges { target: root ; previousPageName: d . backButtonText }
2023-05-30 15:18:45 +00:00
PropertyChanges { target: root ; primaryHeaderButton.visible: false }
2023-03-07 11:32:45 +00:00
PropertyChanges { target: root ; footer: mintTokenFooter }
2023-02-17 11:57:17 +00:00
}
]
2023-05-30 15:18:45 +00:00
onPrimaryHeaderButtonClicked: {
2023-06-14 07:19:45 +00:00
if ( root . state == d . initialViewState ) {
// Then move on to the new token view, with the specific tab selected:
2023-06-22 21:24:30 +00:00
const properties = {
isAssetView: d . isAssetView
}
stackManager . push ( d . newTokenViewState , newTokenView , properties ,
2023-06-14 07:19:45 +00:00
StackView . Immediate )
}
2023-06-09 11:50:22 +00:00
if ( root . state == d . tokenViewState ) {
2023-06-22 21:24:30 +00:00
if ( ! d . currentToken ) {
console . warn ( "Mint Token Settings - Trying to retry undefined token object." )
return
}
// Copy current data:
temp_ . token . copyToken ( d . currentToken )
// Update to point to new instance
d . currentToken = temp_ . token
// Reset the stack:
root . resetNavigation ( true )
// Then move on to the new token view, but asset pre-filled:
const properties = {
isAssetView: d . currentToken . type === TokenObject . Type . Asset ,
referenceName: d . currentToken . name ,
referenceSymbol: d . currentToken . symbol ,
validationMode: StatusInput . ValidationMode . Always ,
asset: d . currentToken ,
collectible: d . currentToken
}
stackManager . push ( d . newTokenViewState , newTokenView , properties ,
StackView . Immediate )
2023-06-09 11:50:22 +00:00
}
2023-05-30 15:18:45 +00:00
}
onSecondaryHeaderButtonClicked: {
if ( root . state == d . tokenViewState )
deleteTokenAlertPopup . open ( )
}
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" )
2023-05-11 15:29:09 +00:00
title: qsTr ( "Community tokens" )
subtitle: qsTr ( "You can mint custom tokens and import tokens for your community" )
2023-02-17 11:57:17 +00:00
checkersModel: [
2023-05-11 15:29:09 +00:00
qsTr ( "Create remotely destructible soulbound tokens for admin permissions" ) ,
2023-02-17 11:57:17 +00:00
qsTr ( "Reward individual members with custom tokens for their contribution" ) ,
2023-05-11 15:29:09 +00:00
qsTr ( "Mint tokens for use with community and channel permissions" )
2023-02-17 11:57:17 +00:00
]
}
}
Component {
2023-05-22 13:00:40 +00:00
id: newTokenView
2023-02-17 11:57:17 +00:00
2023-05-22 13:00:40 +00:00
ColumnLayout {
2023-06-13 10:29:21 +00:00
id: colLayout
2023-06-09 11:50:22 +00:00
2023-06-22 21:24:30 +00:00
property TokenObject asset: TokenObject {
type: TokenObject . Type . Asset
}
property TokenObject collectible: TokenObject {
type: TokenObject . Type . Collectible
}
2023-06-09 11:50:22 +00:00
property bool isAssetView: false
2023-06-09 16:42:35 +00:00
property int validationMode: StatusInput . ValidationMode . OnlyWhenDirty
property string referenceName: ""
property string referenceSymbol: ""
2023-06-09 11:50:22 +00:00
2023-05-22 13:00:40 +00:00
width: root . viewWidth
spacing: Style . current . padding
StatusSwitchTabBar {
id: optionsTab
Layout.preferredWidth: root . viewWidth
2023-06-13 10:29:21 +00:00
currentIndex: colLayout . isAssetView ? 1 : 0
2023-05-22 13:00:40 +00:00
StatusSwitchTabButton {
id: collectiblesTab
text: qsTr ( "Collectibles" )
}
StatusSwitchTabButton {
id: assetsTab
text: qsTr ( "Assets" )
}
}
StackLayout {
Layout.preferredWidth: root . viewWidth
Layout.fillHeight: true
2023-06-01 10:38:56 +00:00
currentIndex: optionsTab . currentItem == collectiblesTab ? 0 : 1
2023-05-22 13:00:40 +00:00
2023-06-09 11:50:22 +00:00
CustomCommunityNewTokenView {
id: newCollectibleView
2023-05-22 13:00:40 +00:00
2023-06-09 11:50:22 +00:00
isAssetView: false
2023-06-22 21:24:30 +00:00
validationMode: ! colLayout . isAssetView
? colLayout . validationMode
: StatusInput . ValidationMode . OnlyWhenDirty
2023-06-13 10:29:21 +00:00
collectible: colLayout . collectible
referenceName: colLayout . referenceName
referenceSymbol: colLayout . referenceSymbol
2023-06-09 11:50:22 +00:00
}
CustomCommunityNewTokenView {
id: newAssetView
isAssetView: true
2023-06-22 21:24:30 +00:00
validationMode: colLayout . isAssetView
? colLayout . validationMode
: StatusInput . ValidationMode . OnlyWhenDirty
2023-06-13 10:29:21 +00:00
asset: colLayout . asset
referenceName: colLayout . referenceName
referenceSymbol: colLayout . referenceSymbol
2023-06-09 11:50:22 +00:00
}
2023-05-22 13:00:40 +00:00
2023-06-01 10:38:56 +00:00
component CustomCommunityNewTokenView: CommunityNewTokenView {
2023-05-22 13:00:40 +00:00
viewWidth: root . viewWidth
layer1Networks: root . layer1Networks
layer2Networks: root . layer2Networks
testNetworks: root . testNetworks
enabledNetworks: root . testNetworks
allNetworks: root . allNetworks
accounts: root . accounts
tokensModel: root . tokensModel
2023-05-25 10:46:53 +00:00
onPreviewClicked: {
2023-06-22 21:24:30 +00:00
const properties = {
preview: true ,
token: isAssetView ? asset : collectible
}
2023-05-25 10:46:53 +00:00
stackManager . push ( d . previewTokenViewState ,
2023-06-22 21:24:30 +00:00
previewTokenView , properties ,
2023-05-25 10:46:53 +00:00
StackView . Immediate )
}
2023-05-22 13:00:40 +00:00
}
2023-03-09 11:12:49 +00:00
}
2023-06-09 11:50:22 +00:00
Binding {
target: root
property: "title"
2023-06-22 21:24:30 +00:00
value: optionsTab . currentItem == collectiblesTab
? d.newCollectiblePageTitle : d . newAssetPageTitle
2023-06-09 11:50:22 +00:00
restoreMode: Binding . RestoreBindingOrValue
}
2023-03-07 11:32:45 +00:00
}
}
Component {
2023-05-25 10:46:53 +00:00
id: previewTokenView
2023-03-07 11:32:45 +00:00
2023-05-25 09:11:27 +00:00
CommunityTokenView {
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-06-01 10:38:56 +00:00
if ( preview . isAssetView )
root . mintAsset ( asset )
else
root . mintCollectible ( collectible )
2023-03-07 11:32:45 +00:00
2023-06-14 07:19:45 +00:00
root . resetNavigation ( )
2023-03-09 11:12:49 +00:00
}
2023-03-23 13:17:07 +00:00
viewWidth: root . viewWidth
2023-06-01 10:38:56 +00:00
onMintClicked: signMintPopup . open ( )
2023-03-23 13:17:07 +00:00
Binding {
target: root
property: "title"
2023-03-28 13:55:34 +00:00
value: preview . name
2023-03-23 13:17:07 +00:00
}
2023-05-15 12:49:26 +00:00
Binding {
target: root
property: "subTitle"
value: preview . symbol
restoreMode: Binding . RestoreBindingOrValue
}
2023-05-22 10:36:47 +00:00
SignTokenTransactionsPopup {
2023-06-01 10:38:56 +00:00
id: signMintPopup
2023-03-23 13:17:07 +00:00
anchors.centerIn: Overlay . overlay
2023-06-01 10:38:56 +00:00
title: qsTr ( "Sign transaction - Mint %1 token" ) . arg ( signMintPopup . tokenName )
2023-06-02 09:20:51 +00:00
tokenName: preview . name
accountName: preview . accountName
networkName: preview . chainName
2023-03-23 13:17:07 +00:00
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 ( )
2023-06-01 10:38:56 +00:00
root . signMintTransactionOpened ( preview . chainId , preview . accountAddress )
2023-04-03 11:29:36 +00:00
}
2023-03-23 13:17:07 +00:00
onCancelClicked: close ( )
2023-06-02 09:20:51 +00:00
onSignTransactionClicked: preview . signMintTransaction ( )
2023-03-23 13:17:07 +00:00
}
2023-03-07 11:32:45 +00:00
}
}
Component {
id: mintTokenFooter
MintTokensFooterPanel {
2023-03-31 12:52:51 +00:00
id: footerPanel
2023-06-22 21:24:30 +00:00
readonly property bool deployStateCompleted: ! ! d . currentToken
? d . currentToken . deployState === Constants . ContractTransactionStatus . Completed
: false
2023-06-12 10:25:59 +00:00
2023-03-31 12:52:51 +00:00
function closePopups ( ) {
2023-05-15 14:52:50 +00:00
remotelyDestructPopup . close ( )
2023-03-31 12:52:51 +00:00
alertPopup . close ( )
2023-05-18 15:01:48 +00:00
signTransactionPopup . close ( )
2023-06-06 12:54:35 +00:00
burnTokensPopup . close ( )
2023-03-31 12:52:51 +00:00
}
2023-06-21 16:41:13 +00:00
airdropEnabled: deployStateCompleted && ( d . infiniteSupply || d . remainingTokens != 0 )
remotelyDestructEnabled: deployStateCompleted && ( d . tokenOwnersModel && d . tokenOwnersModel . count > 0 )
burnEnabled: deployStateCompleted
2023-06-12 10:25:59 +00:00
remotelyDestructVisible: d . remotelyDestruct
2023-06-21 16:41:13 +00:00
burnVisible: ! d . infiniteSupply
2023-03-31 12:52:51 +00:00
2023-04-17 12:11:31 +00:00
onAirdropClicked: d . airdropClicked ( )
2023-05-15 14:52:50 +00:00
onRemotelyDestructClicked: remotelyDestructPopup . open ( )
2023-05-18 15:01:48 +00:00
onBurnClicked: burnTokensPopup . open ( )
2023-03-31 12:52:51 +00:00
2023-05-15 14:52:50 +00:00
RemotelyDestructPopup {
id: remotelyDestructPopup
2023-03-31 12:52:51 +00:00
collectibleName: root . title
2023-04-13 08:09:06 +00:00
model: d . tokenOwnersModel
2023-06-05 13:49:36 +00:00
destroyOnClose: false
2023-03-31 12:52:51 +00:00
2023-05-15 14:52:50 +00:00
onRemotelyDestructClicked: {
2023-06-01 10:38:56 +00:00
d . remotelyDestructTokensList = remotelyDestructTokensList
2023-03-31 12:52:51 +00:00
alertPopup . tokenCount = tokenCount
alertPopup . open ( )
}
}
2023-05-30 15:18:45 +00:00
AlertPopup {
2023-03-31 12:52:51 +00:00
id: alertPopup
2023-05-30 15:18:45 +00:00
property int tokenCount
2023-06-05 13:49:36 +00:00
destroyOnClose: false
2023-05-30 15:18:45 +00:00
title: qsTr ( "Remotely destruct %n token(s)" , "" , tokenCount )
acceptBtnText: qsTr ( "Remotely destruct" )
alertText: qsTr ( "Continuing will destroy tokens held by members and revoke any permissions they are given. To undo you will have to issue them new tokens." )
onAcceptClicked: {
2023-05-18 15:01:48 +00:00
signTransactionPopup . isRemotelyDestructTransaction = true
signTransactionPopup . open ( )
}
2023-03-31 12:52:51 +00:00
}
2023-05-22 10:36:47 +00:00
SignTokenTransactionsPopup {
2023-05-18 15:01:48 +00:00
id: signTransactionPopup
2023-03-31 12:52:51 +00:00
2023-05-18 15:01:48 +00:00
property bool isRemotelyDestructTransaction
function signTransaction ( ) {
2023-05-05 11:03:59 +00:00
root . setFeeLoading ( )
2023-05-18 15:01:48 +00:00
if ( signTransactionPopup . isRemotelyDestructTransaction ) {
2023-06-01 10:38:56 +00:00
root . remotelyDestructCollectibles ( d . remotelyDestructTokensList , d . tokenKey )
2023-05-18 15:01:48 +00:00
} else {
2023-06-01 10:38:56 +00:00
root . burnToken ( d . tokenKey , d . burnAmount )
2023-05-18 15:01:48 +00:00
}
2023-03-31 12:52:51 +00:00
footerPanel . closePopups ( )
}
2023-06-22 21:24:30 +00:00
title: signTransactionPopup . isRemotelyDestructTransaction
? qsTr ( "Sign transaction - Self-destruct %1 tokens" ) . arg ( root . title )
: qsTr ( "Sign transaction - Burn %1 tokens" ) . arg ( root . title )
2023-05-25 10:46:53 +00:00
tokenName: root . title
2023-03-31 12:52:51 +00:00
accountName: d . accountName
networkName: d . chainName
feeText: root . feeText
isFeeLoading: root . isFeeLoading
2023-05-05 11:03:59 +00:00
errorText: root . errorText
2023-03-31 12:52:51 +00:00
2023-05-05 11:03:59 +00:00
onOpened: {
root . setFeeLoading ( )
2023-06-22 21:24:30 +00:00
signTransactionPopup . isRemotelyDestructTransaction
? root . signRemoteDestructTransactionOpened ( d . remotelyDestructTokensList , d . tokenKey )
: root . signBurnTransactionOpened ( d . tokenKey , d . burnAmount )
2023-05-05 11:03:59 +00:00
}
2023-03-31 12:52:51 +00:00
onCancelClicked: close ( )
2023-05-18 15:01:48 +00:00
onSignTransactionClicked: signTransaction ( )
}
BurnTokensPopup {
id: burnTokensPopup
communityName: root . communityName
tokenName: root . title
remainingTokens: d . remainingTokens
tokenSource: d . artworkSource
onBurnClicked: {
d . burnAmount = burnAmount
signTransactionPopup . isRemotelyDestructTransaction = false
signTransactionPopup . open ( )
}
2023-03-31 12:52:51 +00:00
}
2023-06-05 13:49:36 +00:00
Connections {
target: d
function onRemoteDestructAddressClicked ( address ) {
remotelyDestructPopup . open ( )
// TODO: set the address selected in the popup's list
}
}
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 . chainId = chainId
d . chainName = chainName
d . accountName = accountName
2023-06-01 10:38:56 +00:00
d . tokenKey = tokenKey
2023-05-25 14:45:46 +00:00
stackManager . push ( d . tokenViewState ,
tokenView ,
2023-03-09 11:12:49 +00:00
{
2023-03-23 13:17:07 +00:00
preview: false ,
2023-06-01 10:38:56 +00:00
tokenKey
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 {
2023-05-25 14:45:46 +00:00
id: tokenView
2023-03-28 13:55:34 +00:00
2023-05-25 09:11:27 +00:00
CommunityTokenView {
2023-03-28 13:55:34 +00:00
id: view
2023-06-01 10:38:56 +00:00
property string airdropKey // TO REMOVE: Temporal property until airdrop backend is not ready to use token key instead of symbol
property int tokenType
2023-03-28 13:55:34 +00:00
viewWidth: root . viewWidth
2023-06-22 21:24:30 +00:00
token: TokenObject { }
2023-03-28 13:55:34 +00:00
Binding {
target: root
property: "title"
value: view . name
}
2023-05-15 12:49:26 +00:00
Binding {
target: root
property: "subTitle"
value: view . symbol
restoreMode: Binding . RestoreBindingOrValue
}
2023-05-30 15:18:45 +00:00
Binding {
target: root
property: "primaryHeaderButton.visible"
value: view . deployState === Constants . ContractTransactionStatus . Failed
}
Binding {
target: root
property: "primaryHeaderButton.text"
value: ( view . deployState === Constants . ContractTransactionStatus . Failed ) ? qsTr ( "Retry mint" ) : ""
}
Binding {
target: root
property: "secondaryHeaderButton.visible"
value: view . deployState === Constants . ContractTransactionStatus . Failed
}
Binding {
target: root
property: "secondaryHeaderButton.text"
value: ( view . deployState === Constants . ContractTransactionStatus . Failed ) ? qsTr ( "Delete" ) : ""
}
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
2023-06-01 10:38:56 +00:00
property: "remotelyDestruct"
2023-06-22 21:24:30 +00:00
value: view . token . remotelyDestruct
2023-05-09 06:49:51 +00:00
}
2023-05-18 15:01:48 +00:00
Binding {
target: d
2023-06-21 16:41:13 +00:00
property: "infiniteSupply"
value: view . infiniteSupply
2023-05-18 15:01:48 +00:00
restoreMode: Binding . RestoreBindingOrValue
}
Binding {
target: d
property: "remainingTokens"
value: view . remainingTokens
}
Binding {
target: d
property: "artworkSource"
value: view . artworkSource
}
2023-06-09 11:50:22 +00:00
Binding {
target: d
2023-06-14 07:19:45 +00:00
property: "isAssetView"
2023-06-22 21:24:30 +00:00
value: view . isAssetView
2023-06-09 11:50:22 +00:00
}
Binding {
target: d
property: "currentToken"
2023-06-22 21:24:30 +00:00
value: view . token
2023-06-09 11:50:22 +00:00
}
2023-03-28 13:55:34 +00:00
Instantiator {
id: instantiator
model: SortFilterProxyModel {
sourceModel: root . tokensModel
2023-05-26 15:00:51 +00:00
filters: ValueFilter {
roleName: "contractUniqueKey"
2023-06-01 10:38:56 +00:00
value: d . tokenKey
2023-03-28 13:55:34 +00:00
}
}
delegate: QtObject {
component Bind: Binding { target: view }
readonly property list < Binding > bindings: [
2023-05-25 14:45:46 +00:00
Bind { property: "tokenOwnersModel" ; value: model . tokenOwnersModel } ,
2023-06-01 10:38:56 +00:00
Bind { property: "tokenType" ; value: model . tokenType } ,
Bind { property: "airdropKey" ; value: model . symbol } // TO BE REMOVED: When airdrop backend is ready to use token key instead of symbol
]
2023-06-22 21:24:30 +00:00
component BindToken: Binding { target: view . token }
2023-06-01 10:38:56 +00:00
readonly property list < Binding > collectibleBindings: [
2023-06-22 21:24:30 +00:00
BindToken { property: "type" ; value: model . tokenType === Constants . TokenType . ERC20
? TokenObject.Type.Asset : TokenObject . Type . Collectible } ,
BindToken { property: "key" ; value: model . contractUniqueKey } ,
BindToken { property: "deployState" ; value: model . deployState } ,
BindToken { property: "burnState" ; value: model . burnState } ,
BindToken { property: "name" ; value: model . name } ,
BindToken { property: "artworkSource" ; value: model . image } ,
BindToken { property: "symbol" ; value: model . symbol } ,
BindToken { property: "description" ; value: model . description } ,
BindToken { property: "supply" ; value: model . supply } ,
BindToken { property: "infiniteSupply" ; value: model . infiniteSupply } ,
BindToken { property: "remainingTokens" ; value: model . remainingSupply } ,
BindToken { property: "chainId" ; value: model . chainId } ,
BindToken { property: "chainName" ; value: model . chainName } ,
BindToken { property: "chainIcon" ; value: model . chainIcon } ,
BindToken { property: "accountName" ; value: model . accountName } ,
BindToken { property: "accountAddress" ; value: model . accountAddress } , // TODO: Backend
BindToken { property: "transferable" ; value: model . transferable } ,
BindToken { property: "remotelyDestructState" ; value: model . remotelyDestructState } ,
BindToken { property: "remotelyDestruct" ; value: model . remoteSelfDestruct } ,
BindToken { property: "decimals" ; value: model . decimals }
2023-03-28 13:55:34 +00:00
]
}
}
2023-04-17 12:11:31 +00:00
2023-06-05 13:49:36 +00:00
onGeneralAirdropRequested: {
2023-06-01 10:38:56 +00:00
root . airdropToken ( view . airdropKey , view . tokenType , [ ] ) // d.tokenKey instead when backend airdrop ready to use key instead of symbol
2023-06-05 13:49:36 +00:00
}
onAirdropRequested: {
2023-06-01 10:38:56 +00:00
root . airdropToken ( view . airdropKey , view . tokenType , [ address ] ) // d.tokenKey instead when backend airdrop ready to use key instead of symbol
2023-06-05 13:49:36 +00:00
}
onRemoteDestructRequested: {
d . remoteDestructAddressClicked ( address )
}
2023-04-17 12:11:31 +00:00
Connections {
target: d
2023-06-05 13:49:36 +00:00
// handle airdrop request from the footer
2023-04-17 12:11:31 +00:00
function onAirdropClicked ( ) {
2023-06-01 10:38:56 +00:00
root . airdropToken ( view . airdropKey , // d.tokenKey instead when backend airdrop ready to use key instead of symbol
view . tokenType ,
[ ] )
2023-04-17 12:11:31 +00:00
}
}
2023-03-28 13:55:34 +00:00
}
}
2023-05-30 15:18:45 +00:00
AlertPopup {
id: deleteTokenAlertPopup
width: 521
title: qsTr ( "Delete %1" ) . arg ( root . title )
acceptBtnText: qsTr ( "Delete %1 token" ) . arg ( root . title )
alertText: qsTr ( "%1 is not yet minted, are you sure you want to delete it? All data associated with this token including its icon and description will be permanently deleted." ) . arg ( root . title )
onAcceptClicked: {
root . deleteToken ( d . tokenKey )
2023-06-14 07:19:45 +00:00
root . resetNavigation ( )
2023-05-30 15:18:45 +00:00
}
onCancelClicked: close ( )
}
2023-02-17 11:57:17 +00:00
}