chore(CommunityTokensMinting): TokenObject usage refactored

AssetObject and CollectibleObject removed to avoid distinguishing
between those two types in many places.
This commit is contained in:
Michał Cieślak 2023-06-22 23:24:30 +02:00 committed by Michał
parent c47140a406
commit 3a801955e8
11 changed files with 457 additions and 441 deletions

View File

@ -1,19 +1,16 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import AppLayouts.Chat.views.communities 1.0
import AppLayouts.Chat.helpers 1.0
import StatusQ.Core 0.1
import Storybook 1.0
import Models 1.0
import utils 1.0
SplitView {
Logs { id: logs }
SplitView {
@ -24,42 +21,36 @@ SplitView {
SplitView.fillWidth: true
SplitView.fillHeight: true
CollectibleObject {
id: collectibleObj
TokenObject {
id: tokenObject
artworkSource: ModelsData.icons.superRare
remotelyDestructState: remotelyDestructStateBox.checked ? 1 /*In progress*/ : 2 /*Completed*/
burnState: burnDestructStateBox.checked ? 1 /*In progress*/ : 2 /*Completed*/
type: tokenTypeButtonGroup.checkedButton.type
artworkSource: artworkButtonGroup.checkedButton.source
burnState: burnDestructStateBox.checked
? Constants.ContractTransactionStatus.InProgress
: Constants.ContractTransactionStatus.Completed
name: nameText.text
deployState: mintingStateButtonGroup.checkedButton.mintingState
symbol: symbolText.text
description: descriptionText.text
supply: parseInt(supplyText.text)
infiniteSupply: unlimitedSupplyChecker.checked
remainingTokens: parseInt(remainingText.text)
chainId: networksGroup.checkedButton.chainId
chainName: networksGroup.checkedButton.text
chainIcon: networksGroup.checkedButton.chainIcon
accountName: "helloworld"
// collectible-specific properties
remotelyDestructState: remotelyDestructStateBox.checked
? Constants.ContractTransactionStatus.InProgress
: Constants.ContractTransactionStatus.Completed
transferable: transferibleChecker.checked
remotelyDestruct: selfdestructChecker.checked
chainId: 1
chainName: "Ethereum Mainnet"
chainIcon: ModelsData.networks.ethereum
accountName: "helloworld"
}
AssetObject {
id: assetObj
artworkSource: ModelsData.icons.superRare
burnState: burnDestructStateBox.checked ? 1 /*In progress*/ : 2 /*Completed*/
name: nameText.text
symbol: symbolText.text
description: descriptionText.text
supply: parseInt(supplyText.text)
infiniteSupply: unlimitedSupplyChecker.checked
// asset-specific properties
decimals: parseInt(decimalText.text)
remainingTokens: parseInt(remainingText.text)
chainId: 1
chainName: "Ethereum Mainnet"
chainIcon: ModelsData.networks.ethereum
accountName: "helloworld"
}
CommunityTokenView {
@ -68,15 +59,14 @@ SplitView {
anchors.fill: parent
anchors.margins: 50
preview: previewBox.checked
isAssetView: isAssetBox.checked
collectible: collectibleObj
asset: assetObj
token: tokenObject
tokenOwnersModel: TokenHoldersModel {}
onMintClicked: logs.logEvent("CommunityTokenView::onMintClicked")
}
}
}
LogsAndControlsPanel {
id: logsAndControlsPanel
@ -91,257 +81,311 @@ SplitView {
SplitView.minimumWidth: 300
SplitView.preferredWidth: 300
StatusScrollView {
ScrollView {
width: parent.width
height: parent.height
contentHeight: _column.implicitHeight
contentWidth: _column.implicitWidth
contentHeight: column.implicitHeight
contentWidth: width
ColumnLayout {
id: _column
id: column
CheckBox {
id: previewBox
text: "Is preview view?"
checked: true
}
width: parent.width
CheckBox {
id: isAssetBox
text: "Is Assets View?"
checked: false
}
GroupBox {
Layout.fillWidth: true
ColumnLayout {
Label {
text: "Minting state:"
title: "Token type"
ButtonGroup {
id: tokenTypeButtonGroup
buttons: tokenTypeColumn.children
}
RadioButton {
id: mintingInProgress
text: "In progress"
onCheckedChanged: {
if(view.isAssetView) assetObj.deployState = Constants.ContractTransactionStatus.InProgress
else collectibleObj.deployState = Constants.ContractTransactionStatus.InProgress
ColumnLayout {
id: tokenTypeColumn
RadioButton {
id: isAssetRadioButton
readonly property int type:
TokenObject.Type.Asset
text: "Asset"
}
RadioButton {
readonly property int type:
TokenObject.Type.Collectible
checked: true
text: "Collectible"
}
}
}
RadioButton {
id: mintingFailed
text: "Failed"
onCheckedChanged: {
if(view.isAssetView) assetObj.deployState = Constants.ContractTransactionStatus.Failed
else collectibleObj.deployState = Constants.ContractTransactionStatus.Failed
}
}
GroupBox {
Layout.fillWidth: true
RadioButton {
id: mintingCompleted
text: "Completed"
CheckBox {
id: previewBox
text: "Preview"
checked: true
onCheckedChanged: {
if(view.isAssetView) assetObj.deployState = Constants.ContractTransactionStatus.Completed
else collectibleObj.deployState = Constants.ContractTransactionStatus.Completed
}
}
GroupBox {
Layout.fillWidth: true
title: "Minting state"
ButtonGroup {
id: mintingStateButtonGroup
buttons: mintingStateColumn.children
}
ColumnLayout {
id: mintingStateColumn
RadioButton {
readonly property int mintingState:
Constants.ContractTransactionStatus.InProgress
text: "In progress"
}
RadioButton {
readonly property int mintingState:
Constants.ContractTransactionStatus.Failed
text: "Failed"
}
RadioButton {
readonly property int mintingState:
Constants.ContractTransactionStatus.Completed
text: "Completed"
checked: true
}
}
}
CheckBox {
id: remotelyDestructStateBox
visible: !isAssetBox.checked
text: "Remotely destruct in progress"
checked: false
}
CheckBox {
id: burnDestructStateBox
text: "Burn in progress"
checked: false
}
Label {
Layout.topMargin: 10
GroupBox {
Layout.fillWidth: true
text: "Artwork"
}
RadioButton {
text: "Small"
checked: true
onCheckedChanged: {
if(view.isAssetView) assetObj.artworkSource = ModelsData.icons.superRare
else collectibleObj.artworkSource = ModelsData.icons.superRare
}
}
ColumnLayout {
CheckBox {
id: remotelyDestructStateBox
RadioButton {
text: "Medium"
onCheckedChanged: {
if(view.isAssetView) assetObj.artworkSource = ModelsData.collectibles.kitty2Big
else collectibleObj.artworkSource = ModelsData.collectibles.kitty2Big
}
}
visible: !isAssetRadioButton.checked
text: "Remotely destruct in progress"
checked: false
}
RadioButton {
text: "Large"
onCheckedChanged: {
if(view.isAssetView) assetObj.artworkSource = ModelsData.banners.superRare
else collectibleObj.artworkSource = ModelsData.banners.superRare
}
}
CheckBox {
id: burnDestructStateBox
Label {
Layout.topMargin: 10
Layout.fillWidth: true
text: "Name"
}
TextField {
id: nameText
background: Rectangle { border.color: 'lightgrey' }
Layout.preferredWidth: 200
text: "Art work"
}
Label {
Layout.topMargin: 10
Layout.fillWidth: true
text: "Description"
}
TextField {
id: descriptionText
background: Rectangle { border.color: 'lightgrey' }
Layout.preferredWidth: 200
text: "Long art work description Long art work description Long art work description Long art work description Long art work description Long art work description Long art work description Long art work description Long art work description"
}
Label {
Layout.topMargin: 10
Layout.fillWidth: true
text: "Symbol"
}
TextField {
id: symbolText
background: Rectangle { border.color: 'lightgrey' }
Layout.preferredWidth: 200
text: "ABC"
}
CheckBox {
id: unlimitedSupplyChecker
Layout.topMargin: 10
text: "Unlimited supply"
checked: true
}
Label {
visible: !unlimitedSupplyChecker.checked
Layout.fillWidth: true
text: "Supply"
}
TextField {
id: supplyText
visible: !unlimitedSupplyChecker.checked
background: Rectangle { border.color: 'lightgrey' }
Layout.preferredWidth: 200
text: "123"
}
TextField {
id: remainingText
visible: !unlimitedSupplyChecker.checked
background: Rectangle { border.color: 'lightgrey' }
Layout.preferredWidth: 200
text: "123"
}
Label {
Layout.topMargin: 10
Layout.fillWidth: true
visible: isAssetBox.checked
text: "Decimal"
}
TextField {
id: decimalText
Layout.preferredWidth: 200
background: Rectangle { border.color: 'lightgrey' }
visible: isAssetBox.checked
text: "2"
}
CheckBox {
id: transferibleChecker
Layout.topMargin: 10
visible: !isAssetBox.checked
text: "Tranferible"
checked: true
}
CheckBox {
id: selfdestructChecker
visible: !isAssetBox.checked
text: "Remote self-desctruct"
checked: true
}
Label {
Layout.topMargin: 10
Layout.fillWidth: true
text: "Network"
}
RadioButton {
id: eth
text: "Ethereum Mainnet"
checked: true
onCheckedChanged: {
if(view.isAssetView) {
assetObj.chainName = text
assetObj.chainIcon = ModelsData.networks.ethereum
assetObj.chainId = 1
} else {
collectibleObj.chainName = text
collectibleObj.chainIcon = ModelsData.networks.ethereum
collectibleObj.chainId = 1
text: "Burn in progress"
checked: false
}
}
}
RadioButton {
id: opt
text: "Optimism"
onCheckedChanged: {
if(view.isAssetView) {
assetObj.chainName = text
assetObj.chainIcon = ModelsData.networks.optimism
assetObj.chainId = 2
} else {
collectibleObj.chainName = text
collectibleObj.chainIcon = ModelsData.networks.optimism
collectibleObj.chainId = 2
GroupBox {
Layout.fillWidth: true
title: "Artwork"
ButtonGroup {
id: artworkButtonGroup
buttons: artworkColumn.children
}
ColumnLayout {
id: artworkColumn
RadioButton {
readonly property string source:
ModelsData.icons.superRare
text: "Small"
checked: true
}
RadioButton {
readonly property string source:
ModelsData.collectibles.kitty2Big
text: "Medium"
}
RadioButton {
readonly property string source:
ModelsData.banners.superRare
text: "Large"
}
}
}
RadioButton {
id: arb
text: "Arbitrum"
onCheckedChanged: {
if(view.isAssetView) {
assetObj.chainName = text
assetObj.chainIcon = ModelsData.networks.arbitrum
assetObj.chainId = 3
} else {
collectibleObj.chainName = text
collectibleObj.chainIcon = ModelsData.networks.arbitrum
collectibleObj.chainId = 3
GroupBox {
Layout.fillWidth: true
ColumnLayout {
width: parent.width
Label {
text: "Name"
}
TextField {
id: nameText
Layout.fillWidth: true
text: "Art work"
}
Label {
text: "Description"
}
TextField {
id: descriptionText
Layout.fillWidth: true
text: ModelsData.descriptions.medium
}
Label {
text: "Symbol"
}
TextField {
id: symbolText
Layout.fillWidth: true
text: "ABC"
}
}
}
GroupBox {
Layout.fillWidth: true
ColumnLayout {
CheckBox {
id: unlimitedSupplyChecker
text: "Unlimited supply"
checked: true
}
Label {
visible: !unlimitedSupplyChecker.checked
text: "Supply"
}
TextField {
id: supplyText
visible: !unlimitedSupplyChecker.checked
text: "123"
}
TextField {
id: remainingText
visible: !unlimitedSupplyChecker.checked
text: "123"
}
Label {
visible: isAssetRadioButton.checked
text: "Decimal"
}
TextField {
id: decimalText
visible: isAssetRadioButton.checked
text: "2"
}
}
}
GroupBox {
Layout.fillWidth: true
visible: !isAssetRadioButton.checked
ColumnLayout {
CheckBox {
id: transferibleChecker
text: "Tranferible"
checked: true
}
CheckBox {
id: selfdestructChecker
text: "Remote self-desctruct"
checked: true
}
}
}
GroupBox {
Layout.fillWidth: true
title: "Network"
ButtonGroup {
id: networksGroup
buttons: networksColumn.children
}
ColumnLayout {
id: networksColumn
RadioButton {
text: "Ethereum Mainnet"
checked: true
readonly property string chainIcon:
ModelsData.networks.ethereum
readonly property int chainId: 1
}
RadioButton {
text: "Optimism"
readonly property string chainIcon:
ModelsData.networks.optimism
readonly property int chainId: 2
}
RadioButton {
text: "Arbitrum"
readonly property string chainIcon:
ModelsData.networks.arbitrum
readonly property int chainId: 3
}
}
}
Component.onCompleted: spacing *= 2
}
}
}

View File

@ -71,6 +71,12 @@ QtObject {
readonly property string optimism: "network/Network=Optimism"
readonly property string testnet: "network/Network=Testnet"
}
readonly property QtObject descriptions: QtObject {
readonly property string _short_: "Lorem Ipsum is simply dummy text."
readonly property string medium: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
readonly property string _long: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
}
}

View File

@ -1,6 +1,6 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import Qt.labs.settings 1.0
@ -16,8 +16,6 @@ ColumnLayout {
Layout.fillWidth: true
contentHeight: 30
currentIndex: settings.logsOrControlsTab
TabButton {
text: "Events"
width: implicitWidth
@ -46,8 +44,6 @@ ColumnLayout {
}
Settings {
id: settings
property alias logsOrControlsTab: tabs.currentIndex
}
}

View File

@ -1,15 +0,0 @@
import QtQuick 2.15
/*!
\qmltype AssetObject
\inherits TokenObject
\brief ERC20 token object properties definition (also known as asset).
*/
TokenObject {
property int decimals: 2 // Default value
function copyAsset(tokenObject) {
copyToken(tokenObject)
decimals = tokenObject.decimals
}
}

View File

@ -1,21 +0,0 @@
import QtQuick 2.15
import utils 1.0
/*!
\qmltype CollectibleObject
\inherits TokenObject
\brief ERC721 token object properties definition (also known as collectible).
*/
TokenObject {
property bool transferable: false
property bool remotelyDestruct: true
property int remotelyDestructState: Constants.ContractTransactionStatus.None
function copyCollectible(tokenObject) {
copyToken(tokenObject)
transferable = tokenObject.transferable
remotelyDestruct = tokenObject.remotelyDestruct
remotelyDestructState = tokenObject.remotelyDestructState
}
}

View File

@ -8,6 +8,12 @@ import utils 1.0
\brief Token object properties definition.
*/
QtObject {
enum Type {
Asset, Collectible
}
property int type: TokenObject.Type.Asset
// Unique identifier:
property string key
@ -36,7 +42,16 @@ QtObject {
property int deployState: Constants.ContractTransactionStatus.None
property int burnState: Constants.ContractTransactionStatus.None
// Collectible-specific properties:
property bool transferable: false
property bool remotelyDestruct: true
property int remotelyDestructState: Constants.ContractTransactionStatus.None
// Asset-specific properties:
property int decimals: 2 // Default value
function copyToken(tokenObject) {
type = tokenObject.type
key = tokenObject.key
name = tokenObject.name
symbol = tokenObject.symbol
@ -53,5 +68,9 @@ QtObject {
accountName = tokenObject.accountName
deployState = tokenObject.deployState
burnState = tokenObject.burnState
transferable = tokenObject.transferable
remotelyDestruct = tokenObject.remotelyDestruct
remotelyDestructState = tokenObject.remotelyDestructState
decimals = tokenObject.decimals
}
}

View File

@ -1,4 +1,2 @@
singleton CommunityPermissionsHelpers 1.0 CommunityPermissionsHelpers.qml
AssetObject 1.0 AssetObject.qml
CollectibleObject 1.0 CollectibleObject.qml
TokenObject 1.0 TokenObject.qml

View File

@ -1,10 +1,8 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQml 2.15
import StatusQ.Core 0.1
import StatusQ.Components 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Core.Utils 0.1
import StatusQ.Controls 0.1
@ -100,7 +98,8 @@ SettingsPageLayout {
property int remainingTokens
property url artworkSource
property bool isAssetView: false
property var currentToken // CollectibleObject or AssetObject type
property TokenObject currentToken
readonly property var initialItem: (root.tokensModel && root.tokensModel.count > 0) ? mintedTokensView : welcomeView
@ -123,8 +122,7 @@ SettingsPageLayout {
QtObject {
id: temp_
readonly property CollectibleObject collectible: CollectibleObject{}
readonly property AssetObject asset: AssetObject{}
readonly property TokenObject token: TokenObject {}
}
secondaryHeaderButton.type: StatusBaseButton.Type.Danger
@ -172,60 +170,41 @@ SettingsPageLayout {
onPrimaryHeaderButtonClicked: {
if(root.state == d.initialViewState) {
// Then move on to the new token view, with the specific tab selected:
stackManager.push(d.newTokenViewState,
newTokenView,
{
isAssetView: d.isAssetView
},
const properties = {
isAssetView: d.isAssetView
}
stackManager.push(d.newTokenViewState, newTokenView, properties,
StackView.Immediate)
}
if(root.state == d.tokenViewState) {
if(d.currentToken) {
if(d.isAssetView) {
// Copy current data:
temp_.asset.copyAsset(d.currentToken)
if (!d.currentToken) {
console.warn("Mint Token Settings - Trying to retry undefined token object.")
return
}
// Update to point to new instance
d.currentToken = temp_.asset
// Copy current data:
temp_.token.copyToken(d.currentToken)
// Reset the stack:
root.resetNavigation(true)
// Update to point to new instance
d.currentToken = temp_.token
// Then move on to the new token view, but asset pre-filled:
stackManager.push(d.newTokenViewState,
newTokenView,
{
isAssetView: d.isAssetView,
referenceName: d.currentToken.name,
referenceSymbol: d.currentToken.symbol,
validationMode: StatusInput.ValidationMode.Always,
asset: d.currentToken
},
StackView.Immediate)
} else {
// Copy current data:
temp_.collectible.copyCollectible(d.currentToken)
// Reset the stack:
root.resetNavigation(true)
// Update to point to new instance
d.currentToken = temp_.collectible
// 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
}
// Reset the stack:
root.resetNavigation(false)
// Then move on to the new token view, but collectible pre-filled:
stackManager.push(d.newTokenViewState,
newTokenView,
{
isAssetView: d.isAssetView,
referenceName: d.currentToken.name,
referenceSymbol: d.currentToken.symbol,
validationMode: StatusInput.ValidationMode.Always,
collectible: d.currentToken
},
StackView.Immediate)
}
} else console.warn("Mint Token Settings - Trying to retry undefined token object.")
stackManager.push(d.newTokenViewState, newTokenView, properties,
StackView.Immediate)
}
}
@ -263,8 +242,14 @@ SettingsPageLayout {
ColumnLayout {
id: colLayout
property CollectibleObject collectible: CollectibleObject{}
property AssetObject asset: AssetObject{}
property TokenObject asset: TokenObject{
type: TokenObject.Type.Asset
}
property TokenObject collectible: TokenObject {
type: TokenObject.Type.Collectible
}
property bool isAssetView: false
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
property string referenceName: ""
@ -302,7 +287,9 @@ SettingsPageLayout {
id: newCollectibleView
isAssetView: false
validationMode: !colLayout.isAssetView ? colLayout.validationMode : StatusInput.ValidationMode.OnlyWhenDirty
validationMode: !colLayout.isAssetView
? colLayout.validationMode
: StatusInput.ValidationMode.OnlyWhenDirty
collectible: colLayout.collectible
referenceName: colLayout.referenceName
referenceSymbol: colLayout.referenceSymbol
@ -312,14 +299,15 @@ SettingsPageLayout {
id: newAssetView
isAssetView: true
validationMode: colLayout.isAssetView ? colLayout.validationMode : StatusInput.ValidationMode.OnlyWhenDirty
validationMode: colLayout.isAssetView
? colLayout.validationMode
: StatusInput.ValidationMode.OnlyWhenDirty
asset: colLayout.asset
referenceName: colLayout.referenceName
referenceSymbol: colLayout.referenceSymbol
}
component CustomCommunityNewTokenView: CommunityNewTokenView {
isAssetView: false
viewWidth: root.viewWidth
layer1Networks: root.layer1Networks
layer2Networks: root.layer2Networks
@ -330,14 +318,13 @@ SettingsPageLayout {
tokensModel: root.tokensModel
onPreviewClicked: {
const properties = {
preview: true,
token: isAssetView ? asset : collectible
}
stackManager.push(d.previewTokenViewState,
previewTokenView,
{
preview: true,
isAssetView,
asset,
collectible
},
previewTokenView, properties,
StackView.Immediate)
}
}
@ -346,7 +333,8 @@ SettingsPageLayout {
Binding {
target: root
property: "title"
value: optionsTab.currentItem == collectiblesTab ? d.newCollectiblePageTitle : d.newAssetPageTitle
value: optionsTab.currentItem == collectiblesTab
? d.newCollectiblePageTitle : d.newAssetPageTitle
restoreMode: Binding.RestoreBindingOrValue
}
}
@ -413,7 +401,9 @@ SettingsPageLayout {
MintTokensFooterPanel {
id: footerPanel
readonly property bool deployStateCompleted : (!!d.currentToken) ? d.currentToken.deployState === Constants.ContractTransactionStatus.Completed : false
readonly property bool deployStateCompleted: !!d.currentToken
? d.currentToken.deployState === Constants.ContractTransactionStatus.Completed
: false
function closePopups() {
remotelyDestructPopup.close()
@ -480,8 +470,9 @@ SettingsPageLayout {
footerPanel.closePopups()
}
title: signTransactionPopup.isRemotelyDestructTransaction ? qsTr("Sign transaction - Self-destruct %1 tokens").arg(root.title) :
qsTr("Sign transaction - Burn %1 tokens").arg(root.title)
title: signTransactionPopup.isRemotelyDestructTransaction
? qsTr("Sign transaction - Self-destruct %1 tokens").arg(root.title)
: qsTr("Sign transaction - Burn %1 tokens").arg(root.title)
tokenName: root.title
accountName: d.accountName
networkName: d.chainName
@ -491,8 +482,9 @@ SettingsPageLayout {
onOpened: {
root.setFeeLoading()
signTransactionPopup.isRemotelyDestructTransaction ? root.signRemoteDestructTransactionOpened(d.remotelyDestructTokensList, d.tokenKey) :
root.signBurnTransactionOpened(d.tokenKey, d.burnAmount)
signTransactionPopup.isRemotelyDestructTransaction
? root.signRemoteDestructTransactionOpened(d.remotelyDestructTokensList, d.tokenKey)
: root.signBurnTransactionOpened(d.tokenKey, d.burnAmount)
}
onCancelClicked: close()
onSignTransactionClicked: signTransaction()
@ -556,8 +548,8 @@ SettingsPageLayout {
property int tokenType
viewWidth: root.viewWidth
collectible: CollectibleObject{}
asset: AssetObject{}
token: TokenObject {}
Binding {
target: root
@ -605,7 +597,7 @@ SettingsPageLayout {
Binding {
target: d
property: "remotelyDestruct"
value: view.collectible.remotelyDestruct
value: view.token.remotelyDestruct
}
Binding {
@ -630,13 +622,13 @@ SettingsPageLayout {
Binding {
target: d
property: "isAssetView"
value: view.tokenType === Constants.TokenType.ERC20
value: view.isAssetView
}
Binding {
target: d
property: "currentToken"
value: view.isAssetView ? view.asset : view.collectible
value: view.token
}
Instantiator {
@ -652,52 +644,34 @@ SettingsPageLayout {
delegate: QtObject {
component Bind: Binding { target: view }
readonly property list<Binding> bindings: [
Bind { property: "isAssetView"; value: model.tokenType === Constants.TokenType.ERC20 },
Bind { property: "tokenOwnersModel"; value: model.tokenOwnersModel },
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
]
component BindCollectible: Binding { target: view.collectible }
component BindToken: Binding { target: view.token }
readonly property list<Binding> collectibleBindings: [
BindCollectible { property: "key"; value: model.contractUniqueKey },
BindCollectible { property: "deployState"; value: model.deployState },
BindCollectible { property: "burnState"; value: model.burnState },
BindCollectible { property: "name"; value: model.name },
BindCollectible { property: "artworkSource"; value: model.image },
BindCollectible { property: "symbol"; value: model.symbol },
BindCollectible { property: "description"; value: model.description },
BindCollectible { property: "supply"; value: model.supply },
BindCollectible { property: "infiniteSupply"; value: model.infiniteSupply },
BindCollectible { property: "remainingTokens"; value: model.remainingSupply },
BindCollectible { property: "chainId"; value: model.chainId },
BindCollectible { property: "chainName"; value: model.chainName },
BindCollectible { property: "chainIcon"; value: model.chainIcon },
BindCollectible { property: "accountName"; value: model.accountName },
BindCollectible { property: "accountAddress"; value: model.accountAddress }, // TODO: Backend
BindCollectible { property: "transferable"; value: model.transferable },
BindCollectible { property: "remotelyDestructState"; value: model.remotelyDestructState },
BindCollectible { property: "remotelyDestruct"; value: model.remoteSelfDestruct }
]
component BindAsset: Binding { target: view.asset }
readonly property list<Binding> assetBindings: [
BindAsset { property: "key"; value: model.contractUniqueKey },
BindAsset { property: "deployState"; value: model.deployState },
BindAsset { property: "burnState"; value: model.burnState },
BindAsset { property: "name"; value: model.name },
BindAsset { property: "artworkSource"; value: model.image },
BindAsset { property: "symbol"; value: model.symbol },
BindAsset { property: "description"; value: model.description },
BindAsset { property: "supply"; value: model.supply },
BindAsset { property: "infiniteSupply"; value: model.infiniteSupply },
BindAsset { property: "remainingTokens"; value: model.remainingSupply },
BindAsset { property: "chainId"; value: model.chainId },
BindAsset { property: "chainName"; value: model.chainName },
BindAsset { property: "chainIcon"; value: model.chainIcon },
BindAsset { property: "accountName"; value: model.accountName },
BindCollectible { property: "accountAddress"; value: model.accountAddress }, // TODO: Backend
BindAsset { property: "decimals"; value: model.decimals }
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 }
]
}
}

View File

@ -44,7 +44,7 @@ Control {
TokenHoldersProxyModel {
id: proxyModel
sourceModel: root.model
sourceModel: root.model || null
searchText: searcher.text
sortBy: holdersList.sortBy

View File

@ -25,8 +25,14 @@ StatusScrollView {
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
property var tokensModel
property CollectibleObject collectible: CollectibleObject{}
property AssetObject asset: AssetObject{}
property TokenObject collectible: TokenObject {
type: TokenObject.Type.Collectible
}
property TokenObject asset: TokenObject{
type: TokenObject.Type.Asset
}
// Used for reference validation when editing a failed deployment
property string referenceName: ""

View File

@ -19,22 +19,30 @@ StatusScrollView {
property int viewWidth: 560 // by design
property bool preview: false
property bool isAssetView: false
property CollectibleObject collectible
property AssetObject asset
// https://bugreports.qt.io/browse/QTBUG-84269
/* readonly */ property TokenObject token
readonly property string name: root.isAssetView ? asset.name : collectible.name
readonly property string symbol: root.isAssetView ? asset.symbol : collectible.symbol
readonly property url artworkSource: root.isAssetView ? asset.artworkSource : collectible.artworkSource
readonly property bool infiniteSupply: root.isAssetView ? asset.infiniteSupply : collectible.infiniteSupply
readonly property int supply: root.isAssetView ? asset.supply : collectible.supply
readonly property int remainingTokens: root.preview ? root.supply : (root.isAssetView ? asset.remainingTokens : collectible.remainingTokens)
readonly property int deployState: root.isAssetView ? asset.deployState : collectible.deployState
readonly property string accountName: root.isAssetView ? asset.accountName : collectible.accountName
readonly property string chainName: root.isAssetView ? asset.chainName : collectible.chainName
readonly property string chainId: root.isAssetView ? asset.chainId : collectible.chainId
readonly property string accountAddress: root.isAssetView ? asset.accountAddress : collectible.accountAddress
readonly property bool isAssetView: token.type === TokenObject.Type.Asset
readonly property string name: token.name
readonly property string description: token.description
readonly property string symbol: token.symbol
readonly property int supply: token.supply
readonly property url artworkSource: token.artworkSource
readonly property rect artworkCropRect: token.artworkCropRect
readonly property bool infiniteSupply: token.infiniteSupply
readonly property int remainingTokens: root.preview ? root.supply : token.remainingTokens
readonly property int deployState: token.deployState
readonly property string accountName: token.accountName
readonly property string chainName: token.chainName
readonly property string chainId: token.chainId
readonly property string accountAddress: token.accountAddress
readonly property bool remotelyDestruct: token.remotelyDestruct
readonly property int remotelyDestructState: token.remotelyDestructState
readonly property bool transferable: token.transferable
readonly property string chainIcon: token.chainIcon
readonly property int decimals: token.decimals
// Models:
property var tokenOwnersModel
@ -52,7 +60,7 @@ StatusScrollView {
readonly property int imageSelectorRectSize: root.isAssetView ? 104 : 280
readonly property int iconSize: 20
readonly property string infiniteSymbol: "∞"
readonly property int burnState: root.isAssetView ? asset.burnState : collectible.burnState
readonly property int burnState: root.token.burnState
function startAnimation(isBurn) {
totalbox.highlighted = true
@ -110,7 +118,7 @@ StatusScrollView {
Image {
id: image
property rect imageCropRect: root.isAssetView ? asset.artworkCropRect : collectible.artworkCropRect
readonly property rect imageCropRect: root.artworkCropRect
anchors.fill: parent
fillMode: Image.PreserveAspectFit
@ -218,7 +226,7 @@ StatusScrollView {
label: qsTr("Total")
value: root.infiniteSupply ? d.infiniteSymbol : LocaleUtils.numberToLocaleString(root.supply)
isLoading: !root.infiniteSupply &&
((!root.isAssetView && collectible.remotelyDestructState === Constants.ContractTransactionStatus.InProgress) ||
((!root.isAssetView && root.remotelyDestructState === Constants.ContractTransactionStatus.InProgress) ||
(d.burnState === Constants.ContractTransactionStatus.InProgress))
}
@ -233,19 +241,20 @@ StatusScrollView {
CustomPreviewBox {
visible: root.isAssetView
label: qsTr("DP")
value: asset.decimals
value: root.decimals
}
CustomPreviewBox {
visible: !root.isAssetView
label: qsTr("Transferable")
value: collectible.transferable ? qsTr("Yes") : qsTr("No")
value: root.transferable ? qsTr("Yes") : qsTr("No")
}
CustomPreviewBox {
visible: !root.isAssetView
label: qsTr("Destructible")
value: collectible.remotelyDestruct ? qsTr("Yes") : qsTr("No")
value: root.remotelyDestruct ? qsTr("Yes") : qsTr("No")
}
CustomPreviewBox {
@ -272,7 +281,7 @@ StatusScrollView {
height: 24
width: height
source: Style.svg(root.isAssetView ? asset.chainIcon : collectible.chainIcon)
source: Style.svg(root.chainIcon)
}
StatusBaseText {
@ -290,7 +299,7 @@ StatusScrollView {
StatusBaseText {
Layout.fillWidth: true
text: root.isAssetView ? asset.description : collectible.description
text: root.description
wrapMode: TextEdit.WordWrap
font.pixelSize: Theme.primaryTextFontSize
lineHeight: 1.2
@ -333,7 +342,7 @@ StatusScrollView {
model: root.tokenOwnersModel
tokenName: root.name
showRemotelyDestructMenuItem: !root.isAssetView && collectible.remotelyDestruct
showRemotelyDestructMenuItem: !root.isAssetView && root.remotelyDestruct
Layout.topMargin: Style.current.padding
Layout.fillWidth: true
@ -345,10 +354,10 @@ StatusScrollView {
}
Connections {
target: collectible
target: root.token
function onRemotelyDestructStateChanged() {
if(collectible.remotelyDestructState === Constants.ContractTransactionStatus.Completed) d.startAnimation(false)
if(root.remotelyDestructState === Constants.ContractTransactionStatus.Completed) d.startAnimation(false)
}
}
}