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 TokenType = UserRole + 1
TokenAddress TokenAddress
Name Name
Symbol
Description Description
Supply Supply
InfiniteSupply InfiniteSupply
Transferable Transferable
RemoteSelfDestruct RemoteSelfDestruct
NetworkId ChainId
DeployState DeployState
Image Image
@ -70,12 +71,13 @@ QtObject:
ModelRole.TokenType.int:"tokenType", ModelRole.TokenType.int:"tokenType",
ModelRole.TokenAddress.int:"tokenAddress", ModelRole.TokenAddress.int:"tokenAddress",
ModelRole.Name.int:"name", ModelRole.Name.int:"name",
ModelRole.Symbol.int:"symbol",
ModelRole.Description.int:"description", ModelRole.Description.int:"description",
ModelRole.Supply.int:"supply", ModelRole.Supply.int:"supply",
ModelRole.InfiniteSupply.int:"infiniteSupply", ModelRole.InfiniteSupply.int:"infiniteSupply",
ModelRole.Transferable.int:"transferable", ModelRole.Transferable.int:"transferable",
ModelRole.RemoteSelfDestruct.int:"remoteSelfDestruct", ModelRole.RemoteSelfDestruct.int:"remoteSelfDestruct",
ModelRole.NetworkId.int:"networkId", ModelRole.ChainId.int:"chainId",
ModelRole.DeployState.int:"deployState", ModelRole.DeployState.int:"deployState",
ModelRole.Image.int:"image", ModelRole.Image.int:"image",
}.toTable }.toTable
@ -94,6 +96,8 @@ QtObject:
result = newQVariant(item.address) result = newQVariant(item.address)
of ModelRole.Name: of ModelRole.Name:
result = newQVariant(item.name) result = newQVariant(item.name)
of ModelRole.Symbol:
result = newQVariant(item.symbol)
of ModelRole.Description: of ModelRole.Description:
result = newQVariant(item.description) result = newQVariant(item.description)
of ModelRole.Supply: of ModelRole.Supply:
@ -104,7 +108,7 @@ QtObject:
result = newQVariant(item.transferable) result = newQVariant(item.transferable)
of ModelRole.RemoteSelfDestruct: of ModelRole.RemoteSelfDestruct:
result = newQVariant(item.remoteSelfDestruct) result = newQVariant(item.remoteSelfDestruct)
of ModelRole.NetworkId: of ModelRole.ChainId:
result = newQVariant(item.chainId) result = newQVariant(item.chainId)
of ModelRole.DeployState: of ModelRole.DeployState:
result = newQVariant(item.deployState.int) result = newQVariant(item.deployState.int)

View File

@ -155,6 +155,12 @@ QtObject:
return item.getShortName() return item.getShortName()
return "" 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.} = proc getNetworkIconUrl*(self: Model, shortName: string): string {.slot.} =
for item in self.items: for item in self.items:
if cmpIgnoreCase(item.getShortName(), shortName) == 0: if cmpIgnoreCase(item.getShortName(), shortName) == 0:

View File

@ -77,9 +77,9 @@ QtObject:
let contractGasUnits = "3702411" let contractGasUnits = "3702411"
let txData = ens_utils.buildTransaction(parseAddress(addressFrom), 0.u256, contractGasUnits, let txData = ens_utils.buildTransaction(parseAddress(addressFrom), 0.u256, contractGasUnits,
if suggestedFees.eip1559Enabled: "" else: $suggestedFees.gasPrice, suggestedFees.eip1559Enabled, if suggestedFees.eip1559Enabled: "" else: $suggestedFees.gasPrice, suggestedFees.eip1559Enabled,
if suggestedFees.eip1559Enabled: $suggestedFees.maxPriorityFeePerGas else: "", if suggestedFees.eip1559Enabled: $suggestedFees.maxPriorityFeePerGas else: "",
if suggestedFees.eip1559Enabled: $suggestedFees.maxFeePerGasM else: "") if suggestedFees.eip1559Enabled: $suggestedFees.maxFeePerGasM else: "")
let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password) let response = tokens_backend.deployCollectibles(chainId, %deploymentParams, %txData, password)
let contractAddress = response.result["contractAddress"].getStr() let contractAddress = response.result["contractAddress"].getStr()

View File

@ -79,7 +79,6 @@ SettingsPageLayout {
chainIcon = "" chainIcon = ""
} }
// TO CHECK: Some backend properties are not working correctly
function loadData(model) { function loadData(model) {
deployState = model.deployState deployState = model.deployState
collectibleName = model.name collectibleName = model.name
@ -87,12 +86,12 @@ SettingsPageLayout {
supplyText = model.supply.toString() supplyText = model.supply.toString()
infiniteSupply = model.infiniteSupply infiniteSupply = model.infiniteSupply
transferable = model.transferable transferable = model.transferable
chainName = communitiesStore.getChainName(model.chainId) // Backend NOT WORKING chainName = communitiesStore.getChainName(model.chainId)
chainIcon = communitiesStore.getChainIcon(model.chainId) // Backend NOT WORKING chainIcon = communitiesStore.getChainIcon(model.chainId)
artworkSource = model.tokenUri // Backend NOT WORKING artworkSource = model.image
symbol = model.symbol // Backend NOT WORKING symbol = model.symbol
selfDestruct = model.selfDestruct // Backend NOT WORKING selfDestruct = model.remoteSelfDestruct
chainId = model.chainId // Backend NOT WORKING chainId = model.chainId
} }
} }

View File

@ -22,13 +22,11 @@ QtObject {
property var allNetworks: networksModule.all property var allNetworks: networksModule.all
function getChainName(chainId) { function getChainName(chainId) {
// TODO: MOCKED now return allNetworks.getNetworkFullName(chainId)
return "Goerli"
} }
function getChainIcon(chainId) { function getChainIcon(chainId) {
// TODO: MOCKED now return allNetworks.getIconUrl(chainId)
return "network/Network=Custom"
} }
// Token holders model: MOCKED DATA -> TODO: Update with real data // Token holders model: MOCKED DATA -> TODO: Update with real data