fix(CommunityTokens): Fixing crash on token update

closes: #16875 #16860 #16859
This commit is contained in:
Alex Jbanca 2024-12-05 13:53:55 +02:00 committed by Anthony Laibe
parent cf98aa0d96
commit 5fcb425b47

View File

@ -59,7 +59,7 @@ QtObject:
proc updateDeployState*(self: TokenModel, chainId: int, contractAddress: string, deployState: DeployState) = proc updateDeployState*(self: TokenModel, chainId: int, contractAddress: string, deployState: DeployState) =
let itemIdx = self.getItemIndex(chainId, contractAddress) let itemIdx = self.getItemIndex(chainId, contractAddress)
if itemIdx == -1 and self.items[itemIdx].tokenDto.deployState == deployState: if itemIdx == -1 or self.items[itemIdx].tokenDto.deployState == deployState:
return return
self.items[itemIdx].tokenDto.deployState = deployState self.items[itemIdx].tokenDto.deployState = deployState
@ -69,7 +69,7 @@ QtObject:
proc updateAddress*(self: TokenModel, chainId: int, oldContractAddress: string, newContractAddress: string) = proc updateAddress*(self: TokenModel, chainId: int, oldContractAddress: string, newContractAddress: string) =
let itemIdx = self.getItemIndex(chainId, oldContractAddress) let itemIdx = self.getItemIndex(chainId, oldContractAddress)
if itemIdx == -1 and self.items[itemIdx].tokenDto.address == newContractAddress: if itemIdx == -1 or self.items[itemIdx].tokenDto.address == newContractAddress:
return return
self.items[itemIdx].tokenDto.address = newContractAddress self.items[itemIdx].tokenDto.address = newContractAddress
@ -79,7 +79,7 @@ QtObject:
proc updateBurnState*(self: TokenModel, chainId: int, contractAddress: string, burnState: ContractTransactionStatus) = proc updateBurnState*(self: TokenModel, chainId: int, contractAddress: string, burnState: ContractTransactionStatus) =
let itemIdx = self.getItemIndex(chainId, contractAddress) let itemIdx = self.getItemIndex(chainId, contractAddress)
if itemIdx == -1 and self.items[itemIdx].burnState == burnState: if itemIdx == -1 or self.items[itemIdx].burnState == burnState:
return return
self.items[itemIdx].burnState = burnState self.items[itemIdx].burnState = burnState
@ -89,7 +89,7 @@ QtObject:
proc updateRemoteDestructedAddresses*(self: TokenModel, chainId: int, contractAddress: string, remoteDestructedAddresses: seq[string]) = proc updateRemoteDestructedAddresses*(self: TokenModel, chainId: int, contractAddress: string, remoteDestructedAddresses: seq[string]) =
let itemIdx = self.getItemIndex(chainId, contractAddress) let itemIdx = self.getItemIndex(chainId, contractAddress)
if itemIdx == -1 and self.items[itemIdx].remoteDestructedAddresses == remoteDestructedAddresses: if itemIdx == -1 or self.items[itemIdx].remoteDestructedAddresses == remoteDestructedAddresses:
return return
self.items[itemIdx].remoteDestructedAddresses = remoteDestructedAddresses self.items[itemIdx].remoteDestructedAddresses = remoteDestructedAddresses
@ -113,7 +113,7 @@ QtObject:
proc updateRemainingSupply*(self: TokenModel, chainId: int, contractAddress: string, remainingSupply: Uint256) = proc updateRemainingSupply*(self: TokenModel, chainId: int, contractAddress: string, remainingSupply: Uint256) =
let itemIdx = self.getItemIndex(chainId, contractAddress) let itemIdx = self.getItemIndex(chainId, contractAddress)
if itemIdx == -1 and self.items[itemIdx].remainingSupply == remainingSupply: if itemIdx == -1 or self.items[itemIdx].remainingSupply == remainingSupply:
return return
self.items[itemIdx].remainingSupply = remainingSupply self.items[itemIdx].remainingSupply = remainingSupply
@ -143,7 +143,7 @@ QtObject:
proc setCommunityTokenHoldersLoading*(self: TokenModel, chainId: int, contractAddress: string, value: bool) = proc setCommunityTokenHoldersLoading*(self: TokenModel, chainId: int, contractAddress: string, value: bool) =
let itemIdx = self.getItemIndex(chainId, contractAddress) let itemIdx = self.getItemIndex(chainId, contractAddress)
if itemIdx == -1 and self.items[itemIdx].tokenHoldersLoading == value: if itemIdx == -1 or self.items[itemIdx].tokenHoldersLoading == value:
return return
self.items[itemIdx].tokenHoldersLoading = value self.items[itemIdx].tokenHoldersLoading = value