fix(@desktop/communities): Fix community tokens model

Fix #9781
This commit is contained in:
Michal Iskierko 2023-03-07 17:05:27 +01:00 committed by Michał Iskierko
parent 948a1fb085
commit 2ac1216b68
5 changed files with 24 additions and 17 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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()

View File

@ -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
}
}

View File

@ -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