2023-02-17 11:56:13 +00:00
import QtQuick 2.15
2022-08-23 08:46:37 +00:00
2023-02-15 21:45:37 +00:00
import AppLayouts . Chat . controls . community 1.0
2023-02-20 08:31:39 +00:00
import StatusQ . Core . Utils 0.1
2022-08-23 08:46:37 +00:00
QtObject {
2022-11-25 17:35:30 +00:00
id: root
2023-01-20 11:04:12 +00:00
readonly property bool isOwner: false
2023-02-17 11:56:13 +00:00
property var mintingModuleInst: mintingModule ? ? null
2023-01-09 12:51:31 +00:00
2023-01-23 15:50:34 +00:00
property var permissionsModel: ListModel { } // Backend permissions list object model assignment. Please check the current expected data in qml defined in `createPermissions` method
property var permissionConflict: QtObject { // Backend conflicts object model assignment. Now mocked data.
property bool exists: false
property string holdings: qsTr ( "1 ETH" )
property string permissions: qsTr ( "View and Post" )
property string channels: qsTr ( "#general" )
}
2022-08-23 08:46:37 +00:00
// TODO: Replace to real data, now dummy model
2023-01-12 13:18:52 +00:00
property var assetsModel: ListModel {
2023-02-15 21:45:37 +00:00
Component.onCompleted: {
append ( [
{
key: "socks" ,
iconSource: "qrc:imports/assets/png/tokens/SOCKS.png" ,
name: "Unisocks" ,
shortName: "SOCKS" ,
category: TokenCategories . Category . Community
} ,
{
key: "zrx" ,
iconSource: "qrc:imports/assets/png/tokens/ZRX.png" ,
name: "Ox" ,
shortName: "ZRX" ,
category: TokenCategories . Category . Own
} ,
{
key: "1inch" ,
iconSource: "qrc:imports/assets/png/tokens/CUSTOM-TOKEN.png" ,
name: "1inch" ,
shortName: "ZRX" ,
category: TokenCategories . Category . Own
} ,
{
key: "Aave" ,
iconSource: "qrc:imports/assets/png/tokens/CUSTOM-TOKEN.png" ,
name: "Aave" ,
shortName: "AAVE" ,
category: TokenCategories . Category . Own
} ,
{
key: "Amp" ,
iconSource: "qrc:imports/assets/png/tokens/CUSTOM-TOKEN.png" ,
name: "Amp" ,
shortName: "AMP" ,
category: TokenCategories . Category . Own
}
] )
}
2022-08-23 08:46:37 +00:00
}
// TODO: Replace to real data, now dummy model
property var collectiblesModel: ListModel {
2023-02-15 21:45:37 +00:00
Component.onCompleted: {
append ( [
{
key: "Anniversary" ,
iconSource: "qrc:imports/assets/png/collectibles/Anniversary.png" ,
name: "Anniversary" ,
category: TokenCategories . Category . Community
} ,
{
key: "CryptoKitties" ,
iconSource: "qrc:imports/assets/png/collectibles/CryptoKitties.png" ,
name: "CryptoKitties" ,
category: TokenCategories . Category . Own ,
subItems: [
{
key: "Kitty1" ,
iconSource: "qrc:imports/assets/png/collectibles/Furbeard.png" ,
imageSource: "qrc:imports/assets/png/collectibles/FurbeardBig.png" ,
name: "Furbeard"
} ,
{
key: "Kitty2" ,
iconSource: "qrc:imports/assets/png/collectibles/Magicat.png" ,
imageSource: "qrc:imports/assets/png/collectibles/MagicatBig.png" ,
name: "Magicat"
} ,
{
key: "Kitty3" ,
iconSource: "qrc:imports/assets/png/collectibles/HappyMeow.png" ,
imageSource: "qrc:imports/assets/png/collectibles/HappyMeowBig.png" ,
name: "Happy Meow"
} ,
{
key: "Kitty4" ,
iconSource: "qrc:imports/assets/png/collectibles/Furbeard.png" ,
imageSource: "qrc:imports/assets/png/collectibles/FurbeardBig.png" ,
name: "Furbeard-2"
} ,
{
key: "Kitty5" ,
iconSource: "qrc:imports/assets/png/collectibles/Magicat.png" ,
imageSource: "qrc:imports/assets/png/collectibles/MagicatBig.png" ,
name: "Magicat-3"
}
]
} ,
{
key: "SuperRare" ,
iconSource: "qrc:imports/assets/png/collectibles/SuperRare.png" ,
name: "SuperRare" ,
category: TokenCategories . Category . Own
} ,
{
key: "Custom" ,
iconSource: "qrc:imports/assets/png/collectibles/SNT.png" ,
name: "Custom Collectible" ,
category: TokenCategories . Category . General
}
] )
2022-08-23 08:46:37 +00:00
}
}
2022-11-25 17:35:30 +00:00
// TODO: Replace to real data, now dummy model
property var channelsModel: ListModel {
2022-12-01 16:31:03 +00:00
ListElement { key: "welcome" ; iconSource: "qrc:imports/assets/png/tokens/CUSTOM-TOKEN.png" ; name: "#welcome" }
2022-11-25 17:35:30 +00:00
ListElement { key: "general" ; iconSource: "qrc:imports/assets/png/tokens/CUSTOM-TOKEN.png" ; name: "#general" }
}
2023-02-20 08:31:39 +00:00
readonly property QtObject _d : QtObject {
id: d
property int keyCounter: 0
function createPermissionEntry ( holdings , permissionType , isPrivate , channels ) {
const permission = {
2023-02-22 12:26:02 +00:00
holdingsListModel: holdings ,
channelsListModel: channels ,
2023-02-20 08:31:39 +00:00
permissionType ,
isPrivate
}
return permission
2022-11-25 17:35:30 +00:00
}
2023-02-20 08:31:39 +00:00
}
2022-11-25 17:35:30 +00:00
2023-02-20 08:31:39 +00:00
function createPermission ( holdings , permissionType , isPrivate , channels , index = null ) {
// TO BE REPLACED: It shold just be a call to the backend sharing
// `holdings`, `permissions`, `channels` and `isPrivate` properties.
2023-01-27 09:22:04 +00:00
2023-02-20 08:31:39 +00:00
const permissionEntry = d . createPermissionEntry (
holdings , permissionType , isPrivate , channels )
2023-01-27 09:22:04 +00:00
2023-02-20 08:31:39 +00:00
permissionEntry . key = "" + d . keyCounter ++
root . permissionsModel . append ( permissionEntry )
2022-11-25 17:35:30 +00:00
}
2023-02-20 08:31:39 +00:00
function editPermission ( key , holdings , permissionType , channels , isPrivate ) {
2022-11-24 16:23:54 +00:00
// TO BE REPLACED: Call to backend
2023-02-20 08:31:39 +00:00
const permissionEntry = d . createPermissionEntry (
holdings , permissionType , isPrivate , channels )
const index = ModelUtils . indexOf ( root . permissionsModel , "key" , key )
root . permissionsModel . set ( index , permissionEntry )
2022-11-25 17:35:30 +00:00
}
2023-02-20 08:31:39 +00:00
function removePermission ( key ) {
const index = ModelUtils . indexOf ( root . permissionsModel , "key" , key )
2022-11-24 16:23:54 +00:00
root . permissionsModel . remove ( index )
2022-08-23 08:46:37 +00:00
}
2023-01-09 12:51:31 +00:00
2023-02-17 11:56:13 +00:00
// Minting tokens:
2023-02-22 17:10:46 +00:00
function mintCollectible ( communityId , address , artworkSource , name , symbol , description , supply ,
infiniteSupply , transferable , selfDestruct , chainId )
2023-01-09 12:51:31 +00:00
{
2023-02-22 17:10:46 +00:00
// TODO: Backend needs to add `artworkSource` param
2023-01-29 13:33:58 +00:00
mintingModuleInst . mintCollectible ( communityId , address , name , symbol , description , supply ,
2023-02-22 17:10:46 +00:00
infiniteSupply , transferable , selfDestruct , chainId )
2023-01-09 12:51:31 +00:00
}
2023-02-22 17:10:46 +00:00
// Network selection properties:
property var layer1Networks: networksModule . layer1
property var layer2Networks: networksModule . layer2
property var testNetworks: networksModule . test
property var enabledNetworks: networksModule . enabled
property var allNetworks: networksModule . all
2022-08-23 08:46:37 +00:00
}