diff --git a/src/app/modules/main/wallet_section/send/io_interface.nim b/src/app/modules/main/wallet_section/send/io_interface.nim index 38b492a72f..1d8bb5c11e 100644 --- a/src/app/modules/main/wallet_section/send/io_interface.nim +++ b/src/app/modules/main/wallet_section/send/io_interface.nim @@ -3,7 +3,6 @@ import app/modules/shared_models/currency_amount import app_service/service/transaction/dto import app_service/service/network/network_item import app/modules/shared_models/collectibles_model as collectibles -import app/modules/shared_models/collectibles_nested_model as nested_collectibles from app_service/service/keycard/service import KeycardEvent type @@ -67,9 +66,6 @@ method authenticateUser*(self: AccessInterface) {.base.} = method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string) {.base.} = raise newException(ValueError, "No implementation available") -method notifySelectedSenderAccountChanged*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - method setSelectedReceiveAccountIndex*(self: AccessInterface, index: int) {.base.} = raise newException(ValueError, "No implementation available") @@ -79,9 +75,6 @@ method filterChanged*(self: AccessInterface, addresses: seq[string], chainIds: s method getCollectiblesModel*(self: AccessInterface): collectibles.Model {.base.} = raise newException(ValueError, "No implementation available") -method getNestedCollectiblesModel*(self: AccessInterface): nested_collectibles.Model {.base.} = - raise newException(ValueError, "No implementation available") - method splitAndFormatAddressPrefix*(self: AccessInterface, text : string, updateInStore: bool): string {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/wallet_section/send/module.nim b/src/app/modules/main/wallet_section/send/module.nim index 815c4ca39e..f9eef6b96e 100644 --- a/src/app/modules/main/wallet_section/send/module.nim +++ b/src/app/modules/main/wallet_section/send/module.nim @@ -16,11 +16,6 @@ import app_service/service/transaction/dto_conversion import app/modules/shared_models/currency_amount import app_service/service/network/network_item as network_service_item -import app/modules/shared_modules/collectibles/controller as collectiblesc -import app/modules/shared_models/collectibles_model as collectibles -import app/modules/shared_models/collectibles_nested_model as nested_collectibles -import backend/collectibles as backend_collectibles - export io_interface logScope: @@ -50,9 +45,6 @@ type view: View viewVariant: QVariant controller: controller.Controller - # Get the list of owned collectibles by the currently selected account - collectiblesController: collectiblesc.Controller - nestedCollectiblesModel: nested_collectibles.Model moduleLoaded: bool tmpSendTransactionDetails: TmpSendTransactionDetails tmpPin: string @@ -75,13 +67,6 @@ proc newModule*( result.events = events result.controller = controller.newController(result, events, walletAccountService, networkService, currencyService, transactionService, keycardService) - result.collectiblesController = collectiblesc.newController( - requestId = int32(backend_collectibles.CollectiblesRequestID.WalletSend), - loadType = collectiblesc.LoadType.AutoLoadSingleUpdate, - networkService = networkService, - events = events - ) - result.nestedCollectiblesModel = nested_collectibles.newModel(result.collectiblesController.getModel()) result.view = newView(result) result.viewVariant = newQVariant(result.view) @@ -91,8 +76,6 @@ method delete*(self: Module) = self.viewVariant.delete self.view.delete self.controller.delete - self.nestedCollectiblesModel.delete - self.collectiblesController.delete proc convertSendToNetworkToNetworkItem(self: Module, network: SendToNetwork): NetworkRouteItem = result = initNetworkRouteItem( @@ -334,22 +317,6 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) self.view.setSenderAccount(addresses[0]) self.view.setReceiverAccount(addresses[0]) -proc updateCollectiblesFilter*(self: Module) = - let senderAddress = self.view.getSelectedSenderAccountAddress() - let addresses = @[senderAddress] - let chainIds = self.controller.getChainIds() - self.collectiblesController.setFilterAddressesAndChains(addresses, chainIds) - self.nestedCollectiblesModel.setAddress(senderAddress) - -method notifySelectedSenderAccountChanged*(self: Module) = - self.updateCollectiblesFilter() - -method getCollectiblesModel*(self: Module): collectibles.Model = - return self.collectiblesController.getModel() - -method getNestedCollectiblesModel*(self: Module): nested_collectibles.Model = - return self.nestedCollectiblesModel - proc getNetworkColor(self: Module, shortName: string): string = let networks = self.controller.getCurrentNetworks() for network in networks: diff --git a/src/app/modules/main/wallet_section/send/view.nim b/src/app/modules/main/wallet_section/send/view.nim index 188464e89c..c60de6f575 100644 --- a/src/app/modules/main/wallet_section/send/view.nim +++ b/src/app/modules/main/wallet_section/send/view.nim @@ -2,8 +2,6 @@ import NimQml, Tables, json, sequtils, strutils, stint, options, chronicles import uuids import ./io_interface, ./network_route_model, ./network_route_item, ./suggested_route_item, ./transaction_routes -import app/modules/shared_models/collectibles_model as collectibles -import app/modules/shared_models/collectibles_nested_model as nested_collectibles import app_service/service/network/service as network_service import app_service/service/transaction/dto as transaction_dto @@ -15,9 +13,6 @@ QtObject: type View* = ref object of QObject delegate: io_interface.AccessInterface - # list of collectibles owned by the selected sender account - collectiblesModel: collectibles.Model - nestedCollectiblesModel: nested_collectibles.Model # for send modal fromNetworksRouteModel: NetworkRouteModel toNetworksRouteModel: NetworkRouteModel @@ -52,8 +47,6 @@ QtObject: result.fromNetworksRouteModel = newNetworkRouteModel() result.toNetworksRouteModel = newNetworkRouteModel() result.transactionRoutes = newTransactionRoutes() - result.collectiblesModel = delegate.getCollectiblesModel() - result.nestedCollectiblesModel = delegate.getNestedCollectiblesModel() proc load*(self: View) = self.delegate.viewDidLoad() @@ -69,20 +62,6 @@ QtObject: read = getSelectedSenderAccountAddress notify = selectedSenderAccountAddressChanged - proc collectiblesModelChanged*(self: View) {.signal.} - proc getCollectiblesModel(self: View): QVariant {.slot.} = - return newQVariant(self.collectiblesModel) - QtProperty[QVariant] collectiblesModel: - read = getCollectiblesModel - notify = collectiblesModelChanged - - proc nestedCollectiblesModelChanged*(self: View) {.signal.} - proc getNestedCollectiblesModel(self: View): QVariant {.slot.} = - return newQVariant(self.nestedCollectiblesModel) - QtProperty[QVariant] nestedCollectiblesModel: - read = getNestedCollectiblesModel - notify = nestedCollectiblesModelChanged - proc selectedReceiveAccountAddressChanged*(self: View) {.signal.} proc getSelectedReceiveAccountAddress*(self: View): string {.slot.} = return self.selectedReceiveAccountAddress @@ -247,7 +226,6 @@ QtObject: self.toNetworksRouteModel.resetPathData() for path in paths: let fromChainId = path.getfromNetwork() - let networkItem = self.delegate.getNetworkItem(fromChainId) self.fromNetworksRouteModel.updateFromNetworks(path, not chainsWithNoGas.hasKey(fromChainId)) self.toNetworksRouteModel.updateToNetworks(path) @@ -331,7 +309,6 @@ QtObject: proc setSenderAccount*(self: View, address: string) {.slot.} = self.setSelectedSenderAccountAddress(address) - self.delegate.notifySelectedSenderAccountChanged() proc setReceiverAccount*(self: View, address: string) {.slot.} = self.setSelectedReceiveAccountAddress(address) diff --git a/src/app/modules/shared_models/collectibles_nested_item.nim b/src/app/modules/shared_models/collectibles_nested_item.nim deleted file mode 100644 index 099630e946..0000000000 --- a/src/app/modules/shared_models/collectibles_nested_item.nim +++ /dev/null @@ -1,86 +0,0 @@ -import stew/shims/strformat -import app_service/common/types -import stint - -type - ItemType* {.pure.} = enum - CommunityCollectible = 0, - NonCommunityCollectible = 1, - Collection = 2, - Community = 3 - -type - Item* = object - id: string # CollectibleID if single collectible, GroupID (CollectionID/CommunityID) otherwise - chainId: int - name: string - iconUrl: string - groupId: string - groupName: string - tokenType: TokenType - itemType: ItemType - count: UInt256 - -proc initItem*( - id: string, - chainId: int, - name: string, - iconUrl: string, - groupId: string, - groupName: string, - tokenType: TokenType, - itemType: ItemType, - count: UInt256, -): Item = - result.id = id - result.chainId = chainId - result.name = name - result.iconUrl = iconUrl - result.groupId = groupId - result.groupName = groupName - result.tokenType = tokenType - result.itemType = itemType - result.count = count - -proc `$`*(self: Item): string = - result = fmt"""CollectiblesNestedEntry( - id: {self.id}, - chainId: {self.chainId}, - name: {self.name}, - iconUrl: {self.iconUrl}, - groupId: {self.groupId}, - groupName: {self.groupName}, - tokenType: {self.tokenType}, - itemType: {self.itemType}, - count: {self.count}, - ]""" - -proc getId*(self: Item): string = - return self.id - -proc getChainId*(self: Item): int = - return self.chainId - -proc getName*(self: Item): string = - return self.name - -proc getIconUrl*(self: Item): string = - return self.iconUrl - -proc getGroupId*(self: Item): string = - return self.groupId - -proc getGroupName*(self: Item): string = - return self.groupName - -proc getTokenType*(self: Item): int = - return self.tokenType.int - -proc getItemType*(self: Item): int = - return self.itemType.int - -proc getCount*(self: Item): UInt256 = - return self.count - -proc getCountAsString*(self: Item): string = - return $self.count diff --git a/src/app/modules/shared_models/collectibles_nested_model.nim b/src/app/modules/shared_models/collectibles_nested_model.nim deleted file mode 100644 index b1da871945..0000000000 --- a/src/app/modules/shared_models/collectibles_nested_model.nim +++ /dev/null @@ -1,201 +0,0 @@ -import NimQml, Tables, strutils, stew/shims/strformat, sequtils -import stint - -import ./collectible_ownership_model -import ./collectibles_model as flat_model -import ./collectibles_entry as flat_item -import ./collectibles_nested_item as nested_item - -import ./collectibles_nested_utils - -type - CollectiblesNestedRole {.pure.} = enum - Uid = UserRole + 1, - ChainId - Name - IconUrl - GroupId - GroupName - TokenType - ItemType - Count - -type - CollectiblesPerGroupId = Table[string, seq[flat_item.CollectiblesEntry]] - -QtObject: - type - Model* = ref object of QAbstractListModel - flatModel: flat_model.Model - items: seq[nested_item.Item] - currentGroupId: string - address: string - - proc delete(self: Model) = - self.items = @[] - self.QAbstractListModel.delete - - proc setup(self: Model) = - self.QAbstractListModel.setup - - proc newModel*(flatModel: flat_model.Model): Model = - new(result, delete) - result.flatModel = flatModel - result.items = @[] - result.currentGroupId = "" - result.setup - - signalConnect(result.flatModel, "countChanged()", result, "refreshItems()") - signalConnect(result.flatModel, "itemsDataUpdated()", result, "refreshItems()") - - # Forward declaration - proc refreshItems*(self: Model) - - proc `$`*(self: Model): string = - result = fmt"""CollectiblesNestedModel( - flatModel: {self.flatModel}, - currentGroupId: {self.currentGroupId}, - ]""" - - proc countChanged(self: Model) {.signal.} - proc getCount*(self: Model): int {.slot.} = - self.items.len - QtProperty[int] count: - read = getCount - notify = countChanged - - proc getCurrentCollectionUid*(self: Model): string {.slot.} = - result = self.currentGroupId - proc currentCollectionUidChanged(self: Model) {.signal.} - proc setCurrentCollectionUid(self: Model, currentGroupId: string) {.slot.} = - self.currentGroupId = currentGroupId - self.currentCollectionUidChanged() - self.refreshItems() - QtProperty[string] currentGroupId: - read = getCurrentCollectionUid - write = setCurrentCollectionUid - notify = currentCollectionUidChanged - - method rowCount(self: Model, index: QModelIndex = nil): int = - return self.items.len - - method roleNames(self: Model): Table[int, string] = - { - CollectiblesNestedRole.Uid.int:"uid", - CollectiblesNestedRole.ChainId.int:"chainId", - CollectiblesNestedRole.Name.int:"name", - CollectiblesNestedRole.IconUrl.int:"iconUrl", - CollectiblesNestedRole.GroupId.int:"groupId", - CollectiblesNestedRole.GroupName.int:"groupName", - CollectiblesNestedRole.TokenType.int:"tokenType", - CollectiblesNestedRole.ItemType.int:"itemType", - CollectiblesNestedRole.Count.int:"count", - }.toTable - - method data(self: Model, index: QModelIndex, role: int): QVariant = - if (not index.isValid): - return - - if (index.row < 0 or index.row >= self.getCount()): - return - - let item = self.items[index.row] - let enumRole = role.CollectiblesNestedRole - - case enumRole: - of CollectiblesNestedRole.Uid: - result = newQVariant(item.getId()) - of CollectiblesNestedRole.ChainId: - result = newQVariant(item.getChainId()) - of CollectiblesNestedRole.Name: - result = newQVariant(item.getName()) - of CollectiblesNestedRole.IconUrl: - result = newQVariant(item.getIconUrl()) - of CollectiblesNestedRole.GroupId: - result = newQVariant(item.getGroupId()) - of CollectiblesNestedRole.GroupName: - result = newQVariant(item.getGroupName()) - of CollectiblesNestedRole.TokenType: - result = newQVariant(item.getTokenType()) - of CollectiblesNestedRole.ItemType: - result = newQVariant(item.getItemType()) - of CollectiblesNestedRole.Count: - result = newQVariant(item.getCountAsString()) - - # Groups collectibles by CommunityID if available, or CollectionID otherwise. - # Returns pair (collectiblesPerCommunity, collectiblesPerCollection) - proc getCollectiblesPerGroupId(items: seq[flat_item.CollectiblesEntry]): (CollectiblesPerGroupId, CollectiblesPerGroupId) = - var collectiblesPerCommunity = initTable[string, seq[flat_item.CollectiblesEntry]]() - var collectiblesPerCollection = initTable[string, seq[flat_item.CollectiblesEntry]]() - - for item in items: - let collectionId = item.getCollectionIDAsString() - let communityId = item.getCommunityId() - if communityId == "": - if not collectiblesPerCollection.hasKey(collectionId): - collectiblesPerCollection[collectionId] = @[] - collectiblesPerCollection[collectionId].add(item) - else: - if not collectiblesPerCommunity.hasKey(communityId): - collectiblesPerCommunity[communityId] = @[] - collectiblesPerCommunity[communityId].add(item) - return (collectiblesPerCommunity, collectiblesPerCollection) - - proc refreshItems*(self: Model) {.slot.} = - let (collectiblesPerCommunity, collectiblesPerCollection) = getCollectiblesPerGroupId(self.flatModel.getItems()) - - self.beginResetModel() - self.items = @[] - - var addCollections = true - # Add communities - for communityId, communityCollectibles in collectiblesPerCommunity.pairs: - if self.currentGroupId == "": - # No collection selected - if communityCollectibles.len > 0: - let communityItem = collectibleToCommunityNestedItem(communityCollectibles[0], stint.u256(communityCollectibles.len)) - self.items.add(communityItem) - else: - if self.currentGroupId == communityId: - for collectible in communityCollectibles: - let collectibleItem = collectibleToCommunityCollectibleNestedItem(collectible, collectible.getOwnershipModel().getBalance(self.address)) - self.items.add(collectibleItem) - - # Inside community folder we dont add collection items - addCollections = false - break - - if addCollections: - # Add collections and collection items - for collectionId, collectionCollectibles in collectiblesPerCollection.pairs: - if self.currentGroupId == "": - # No collection selected - # If the collection contains more than 1 collectible, we add a single collection item - # Otherwise, we add the collectible - if collectionCollectibles.len > 1: - let collectionItem = collectibleToCollectionNestedItem(collectionCollectibles[0], stint.u256(collectionCollectibles.len)) - self.items.add(collectionItem) - else: - for collectible in collectionCollectibles: - let collectibleItem = collectibleToNonCommunityCollectibleNestedItem(collectible, collectible.getOwnershipModel().getBalance(self.address)) - self.items.add(collectibleItem) - else: - if self.currentGroupId == collectionId: - for collectible in collectionCollectibles: - let collectibleItem = collectibleToNonCommunityCollectibleNestedItem(collectible, collectible.getOwnershipModel().getBalance(self.address)) - self.items.add(collectibleItem) - # No need to keep looking - break - - self.endResetModel() - self.countChanged() - - proc resetModel*(self: Model) = - self.beginResetModel() - self.items = @[] - self.endResetModel() - self.countChanged() - - proc setAddress*(self: Model, address: string) {.slot.} = - self.address = address - self.refreshItems() diff --git a/src/app/modules/shared_models/collectibles_nested_utils.nim b/src/app/modules/shared_models/collectibles_nested_utils.nim deleted file mode 100644 index 0d5ec8cc97..0000000000 --- a/src/app/modules/shared_models/collectibles_nested_utils.nim +++ /dev/null @@ -1,57 +0,0 @@ -import stint - -import ./collectibles_entry as flat_item -import ./collectibles_nested_item as nested_item -import app_service/common/types - -proc collectibleToCommunityCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry, count: UInt256): nested_item.Item = - return nested_item.initItem( - flatItem.getIDAsString(), - flatItem.getChainID(), - flatItem.getName(), - flatItem.getImageURL(), - flatItem.getCommunityId(), - flatItem.getCommunityName(), - TokenType(flatItem.getTokenType()), - ItemType.CommunityCollectible, - count - ) - -proc collectibleToCommunityNestedItem*(flatItem: flat_item.CollectiblesEntry, count: UInt256): nested_item.Item = - return nested_item.initItem( - flatItem.getCommunityId(), - flatItem.getChainID(), - flatItem.getCommunityName(), - flatItem.getCommunityImage(), - flatItem.getCommunityId(), - flatItem.getCommunityName(), - TokenType(flatItem.getTokenType()), - ItemType.Community, - count - ) - -proc collectibleToNonCommunityCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry, count: UInt256): nested_item.Item = - return nested_item.initItem( - flatItem.getIDAsString(), - flatItem.getChainID(), - flatItem.getName(), - flatItem.getImageURL(), - flatItem.getCollectionIDAsString(), - flatItem.getCollectionName(), - TokenType(flatItem.getTokenType()), - ItemType.NonCommunityCollectible, - count - ) - -proc collectibleToCollectionNestedItem*(flatItem: flat_item.CollectiblesEntry, count: UInt256): nested_item.Item = - return nested_item.initItem( - flatItem.getCollectionIDAsString(), - flatItem.getChainID(), - flatItem.getCollectionName(), - flatItem.getCollectionImageURL(), - flatItem.getCollectionIDAsString(), - flatItem.getCollectionName(), - TokenType(flatItem.getTokenType()), - ItemType.Collection, - count - ) \ No newline at end of file diff --git a/src/backend/collectibles.nim b/src/backend/collectibles.nim index 25cbe6ad93..c8d2d2de2e 100644 --- a/src/backend/collectibles.nim +++ b/src/backend/collectibles.nim @@ -12,7 +12,6 @@ type CollectiblesRequestID* = enum WalletAccount ProfileShowcase - WalletSend AllCollectibles # Declared in services/wallet/collectibles/service.go diff --git a/storybook/stubs/shared/stores/send/TransactionStore.qml b/storybook/stubs/shared/stores/send/TransactionStore.qml index 7770a29b1e..abcf7fa888 100644 --- a/storybook/stubs/shared/stores/send/TransactionStore.qml +++ b/storybook/stubs/shared/stores/send/TransactionStore.qml @@ -43,8 +43,6 @@ QtObject { property var fromNetworksRouteModel: NetworksModel.sendFromNetworks property var toNetworksRouteModel: NetworksModel.sendToNetworks property string selectedSenderAccountAddress - readonly property QtObject collectiblesModel: ManageCollectiblesModel {} - readonly property QtObject nestedCollectiblesModel: ListModel {} readonly property QtObject walletSectionSendInst: QtObject { signal transactionSent(var chainId, var txHash, var uuid, var error) diff --git a/ui/imports/shared/popups/send/SendModal.qml b/ui/imports/shared/popups/send/SendModal.qml index 7863b3532a..8ce5e96a31 100644 --- a/ui/imports/shared/popups/send/SendModal.qml +++ b/ui/imports/shared/popups/send/SendModal.qml @@ -426,8 +426,8 @@ StatusDialog { onCollectibleSelected: { const entry = SQUtils.ModelUtils.getByKey( - popup.store.collectiblesModel, - "uid", key) + popup.collectiblesStore.allCollectiblesModel, + "symbol", key) d.selectedHoldingType = entry.tokenType d.selectedHolding = entry selectedItem = entry @@ -435,7 +435,7 @@ StatusDialog { onCollectionSelected: { const entry = SQUtils.ModelUtils.getByKey( - popup.store.collectiblesModel, + popup.collectiblesStore.allCollectiblesModel, "collectionUid", key) d.selectedHoldingType = entry.tokenType d.selectedHolding = entry diff --git a/ui/imports/shared/stores/send/TransactionStore.qml b/ui/imports/shared/stores/send/TransactionStore.qml index 93d254fac0..a4f3b6bc28 100644 --- a/ui/imports/shared/stores/send/TransactionStore.qml +++ b/ui/imports/shared/stores/send/TransactionStore.qml @@ -28,8 +28,6 @@ QtObject { readonly property var toNetworksRouteModel: walletSectionSendInst.toNetworksRouteModel readonly property string selectedReceiverAccountAddress: walletSectionSendInst.selectedReceiveAccountAddress readonly property string selectedSenderAccountAddress: walletSectionSendInst.selectedSenderAccountAddress - property var collectiblesModel: walletSectionSendInst.collectiblesModel - property var nestedCollectiblesModel: walletSectionSendInst.nestedCollectiblesModel property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled property var tmpActivityController0: walletSection.tmpActivityController0 readonly property var _tmpActivityController1: walletSection.tmpActivityController1 @@ -96,14 +94,6 @@ QtObject { return {} } - function getCollectible(uid) { - const idx = ModelUtils.indexOf(collectiblesModel, "uid", uid) - if (idx < 0) { - return {} - } - return ModelUtils.get(collectiblesModel, idx) - } - function setSenderAccount(address) { walletSectionSendInst.setSenderAccount(address) } @@ -166,7 +156,6 @@ QtObject { function resetStoredProperties() { walletSectionSendInst.resetStoredProperties() - nestedCollectiblesModel.currentCollectionUid = "" } function splitAndFormatAddressPrefix(text, updateInStore) { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index fa636d7dc0..421fb13920 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -1409,14 +1409,6 @@ QtObject { UrlUnfurlingModeDisableAll = 3 } - // these are in sync with src/app/modules/shared_models/collectibles_nested_item.nim ItemType - enum CollectiblesNestedItemType { - CommunityCollectible = 0, - NonCommunityCollectible = 1, - Collection = 2, - Community = 3 - } - enum RequestToJoinState { None = 0, InProgress = 1,