From 2ac1216b68a42bcfe3c7cd18c81e86ee973e3faa Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Tue, 7 Mar 2023 17:05:27 +0100 Subject: [PATCH] fix(@desktop/communities): Fix community tokens model Fix #9781 --- .../main/communities/minting/models/token_model.nim | 10 +++++++--- src/app/modules/main/networks/model.nim | 6 ++++++ .../service/community_tokens/service.nim | 6 +++--- .../CommunityMintTokensSettingsPanel.qml | 13 ++++++------- ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml | 6 ++---- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/app/modules/main/communities/minting/models/token_model.nim b/src/app/modules/main/communities/minting/models/token_model.nim index 0e0580d841..44dc407614 100644 --- a/src/app/modules/main/communities/minting/models/token_model.nim +++ b/src/app/modules/main/communities/minting/models/token_model.nim @@ -6,12 +6,13 @@ type TokenType = UserRole + 1 TokenAddress Name + Symbol Description Supply InfiniteSupply Transferable RemoteSelfDestruct - NetworkId + ChainId DeployState Image @@ -70,12 +71,13 @@ QtObject: ModelRole.TokenType.int:"tokenType", ModelRole.TokenAddress.int:"tokenAddress", ModelRole.Name.int:"name", + ModelRole.Symbol.int:"symbol", ModelRole.Description.int:"description", ModelRole.Supply.int:"supply", ModelRole.InfiniteSupply.int:"infiniteSupply", ModelRole.Transferable.int:"transferable", ModelRole.RemoteSelfDestruct.int:"remoteSelfDestruct", - ModelRole.NetworkId.int:"networkId", + ModelRole.ChainId.int:"chainId", ModelRole.DeployState.int:"deployState", ModelRole.Image.int:"image", }.toTable @@ -94,6 +96,8 @@ QtObject: result = newQVariant(item.address) of ModelRole.Name: result = newQVariant(item.name) + of ModelRole.Symbol: + result = newQVariant(item.symbol) of ModelRole.Description: result = newQVariant(item.description) of ModelRole.Supply: @@ -104,7 +108,7 @@ QtObject: result = newQVariant(item.transferable) of ModelRole.RemoteSelfDestruct: result = newQVariant(item.remoteSelfDestruct) - of ModelRole.NetworkId: + of ModelRole.ChainId: result = newQVariant(item.chainId) of ModelRole.DeployState: result = newQVariant(item.deployState.int) diff --git a/src/app/modules/main/networks/model.nim b/src/app/modules/main/networks/model.nim index ff4f447d1a..07fea97629 100644 --- a/src/app/modules/main/networks/model.nim +++ b/src/app/modules/main/networks/model.nim @@ -155,6 +155,12 @@ QtObject: return item.getShortName() return "" + proc getNetworkFullName*(self: Model, chainId: int): string {.slot.} = + for item in self.items: + if(item.getChainId() == chainId): + return item.getChainName() + return "" + proc getNetworkIconUrl*(self: Model, shortName: string): string {.slot.} = for item in self.items: if cmpIgnoreCase(item.getShortName(), shortName) == 0: diff --git a/src/app_service/service/community_tokens/service.nim b/src/app_service/service/community_tokens/service.nim index 5140e4e58a..880df32b45 100644 --- a/src/app_service/service/community_tokens/service.nim +++ b/src/app_service/service/community_tokens/service.nim @@ -77,9 +77,9 @@ QtObject: let contractGasUnits = "3702411" let txData = ens_utils.buildTransaction(parseAddress(addressFrom), 0.u256, contractGasUnits, - if suggestedFees.eip1559Enabled: "" else: $suggestedFees.gasPrice, suggestedFees.eip1559Enabled, - if suggestedFees.eip1559Enabled: $suggestedFees.maxPriorityFeePerGas else: "", - if suggestedFees.eip1559Enabled: $suggestedFees.maxFeePerGasM else: "") + if suggestedFees.eip1559Enabled: "" else: $suggestedFees.gasPrice, suggestedFees.eip1559Enabled, + if suggestedFees.eip1559Enabled: $suggestedFees.maxPriorityFeePerGas else: "", + if suggestedFees.eip1559Enabled: $suggestedFees.maxFeePerGasM else: "") let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password) let contractAddress = response.result["contractAddress"].getStr() diff --git a/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml b/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml index 952fa07995..03f51d963f 100644 --- a/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/communities/CommunityMintTokensSettingsPanel.qml @@ -79,7 +79,6 @@ SettingsPageLayout { chainIcon = "" } - // TO CHECK: Some backend properties are not working correctly function loadData(model) { deployState = model.deployState collectibleName = model.name @@ -87,12 +86,12 @@ SettingsPageLayout { supplyText = model.supply.toString() infiniteSupply = model.infiniteSupply transferable = model.transferable - chainName = communitiesStore.getChainName(model.chainId) // Backend NOT WORKING - chainIcon = communitiesStore.getChainIcon(model.chainId) // Backend NOT WORKING - artworkSource = model.tokenUri // Backend NOT WORKING - symbol = model.symbol // Backend NOT WORKING - selfDestruct = model.selfDestruct // Backend NOT WORKING - chainId = model.chainId // Backend NOT WORKING + chainName = communitiesStore.getChainName(model.chainId) + chainIcon = communitiesStore.getChainIcon(model.chainId) + artworkSource = model.image + symbol = model.symbol + selfDestruct = model.remoteSelfDestruct + chainId = model.chainId } } diff --git a/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml b/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml index 15064b52be..183229cbee 100644 --- a/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml +++ b/ui/app/AppLayouts/Chat/stores/CommunitiesStore.qml @@ -22,13 +22,11 @@ QtObject { property var allNetworks: networksModule.all function getChainName(chainId) { - // TODO: MOCKED now - return "Goerli" + return allNetworks.getNetworkFullName(chainId) } function getChainIcon(chainId) { - // TODO: MOCKED now - return "network/Network=Custom" + return allNetworks.getIconUrl(chainId) } // Token holders model: MOCKED DATA -> TODO: Update with real data